Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
dd25db82
Commit
dd25db82
authored
Apr 06, 2015
by
Michael Arntzenius
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make tuple indexing work in JIT mode
parent
386b688f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
44 additions
and
8 deletions
+44
-8
src/codegen/compvars.cpp
src/codegen/compvars.cpp
+14
-7
src/codegen/runtime_hooks.cpp
src/codegen/runtime_hooks.cpp
+1
-0
src/codegen/runtime_hooks.h
src/codegen/runtime_hooks.h
+1
-1
src/runtime/inline/link_forcer.cpp
src/runtime/inline/link_forcer.cpp
+1
-0
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+4
-0
src/runtime/objmodel.h
src/runtime/objmodel.h
+1
-0
test/tests/tuple_indexing.py
test/tests/tuple_indexing.py
+22
-0
No files found.
src/codegen/compvars.cpp
View file @
dd25db82
...
@@ -2154,21 +2154,28 @@ public:
...
@@ -2154,21 +2154,28 @@ public:
assert
(
v
->
getType
()
==
g
.
i64
);
assert
(
v
->
getType
()
==
g
.
i64
);
if
(
llvm
::
ConstantInt
*
ci
=
llvm
::
dyn_cast
<
llvm
::
ConstantInt
>
(
v
))
{
if
(
llvm
::
ConstantInt
*
ci
=
llvm
::
dyn_cast
<
llvm
::
ConstantInt
>
(
v
))
{
int64_t
i
=
ci
->
getSExtValue
();
int64_t
i
=
ci
->
getSExtValue
();
if
(
i
>=
0
&&
i
<
var
->
getValue
()
->
size
())
{
auto
elts
=
var
->
getValue
();
CompilerVariable
*
rtn
=
(
*
var
->
getValue
())[
i
];
if
(
i
>=
0
&&
i
<
elts
->
size
())
{
CompilerVariable
*
rtn
=
(
*
elts
)[
i
];
rtn
->
incvref
();
return
rtn
;
}
else
if
(
i
<
0
&&
-
i
<=
elts
->
size
())
{
CompilerVariable
*
rtn
=
(
*
elts
)[
elts
->
size
()
+
i
];
rtn
->
incvref
();
rtn
->
incvref
();
return
rtn
;
return
rtn
;
}
else
{
}
else
{
llvm
::
CallSite
call
=
emitter
.
createCall2
(
info
.
unw_info
,
g
.
funcs
.
raiseAttributeErrorStr
,
llvm
::
CallSite
call
=
emitter
.
createCall
(
info
.
unw_info
,
g
.
funcs
.
raiseIndexErrorStr
,
getStringConstantPtr
(
debugName
()
+
'\0'
),
getStringConstantPtr
(
"tuple
\0
"
));
getStringConstantPtr
(
"__getitem__
\0
"
));
call
.
setDoesNotReturn
();
call
.
setDoesNotReturn
();
return
undefVariable
();
return
undefVariable
();
}
}
}
}
}
}
RELEASE_ASSERT
(
0
,
""
);
// return getConstantInt(var->getValue()->size(), g.i64);
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_TUPLE
);
CompilerVariable
*
rtn
=
converted
->
getitem
(
emitter
,
info
,
slice
);
converted
->
decvref
(
emitter
);
return
rtn
;
}
}
ConcreteCompilerVariable
*
len
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
)
override
{
ConcreteCompilerVariable
*
len
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
)
override
{
...
...
src/codegen/runtime_hooks.cpp
View file @
dd25db82
...
@@ -214,6 +214,7 @@ void initGlobalFuncs(GlobalState& g) {
...
@@ -214,6 +214,7 @@ void initGlobalFuncs(GlobalState& g) {
GET
(
unpackIntoArray
);
GET
(
unpackIntoArray
);
GET
(
raiseAttributeError
);
GET
(
raiseAttributeError
);
GET
(
raiseAttributeErrorStr
);
GET
(
raiseAttributeErrorStr
);
GET
(
raiseIndexErrorStr
);
GET
(
raiseNotIterableError
);
GET
(
raiseNotIterableError
);
GET
(
assertNameDefined
);
GET
(
assertNameDefined
);
GET
(
assertFailDerefNameDefined
);
GET
(
assertFailDerefNameDefined
);
...
...
src/codegen/runtime_hooks.h
View file @
dd25db82
...
@@ -41,7 +41,7 @@ struct GlobalFuncs {
...
@@ -41,7 +41,7 @@ struct GlobalFuncs {
*
exceptionMatches
,
*
yield
,
*
getiterHelper
,
*
hasnext
;
*
exceptionMatches
,
*
yield
,
*
getiterHelper
,
*
hasnext
;
llvm
::
Value
*
unpackIntoArray
,
*
raiseAttributeError
,
*
raiseAttributeErrorStr
,
*
raiseNotIterableError
,
llvm
::
Value
*
unpackIntoArray
,
*
raiseAttributeError
,
*
raiseAttributeErrorStr
,
*
raiseNotIterableError
,
*
assertNameDefined
,
*
assertFail
,
*
assertFailDerefNameDefined
;
*
raiseIndexErrorStr
,
*
assertNameDefined
,
*
assertFail
,
*
assertFailDerefNameDefined
;
llvm
::
Value
*
printFloat
,
*
listAppendInternal
,
*
getSysStdout
;
llvm
::
Value
*
printFloat
,
*
listAppendInternal
,
*
getSysStdout
;
llvm
::
Value
*
runtimeCall0
,
*
runtimeCall1
,
*
runtimeCall2
,
*
runtimeCall3
,
*
runtimeCall
,
*
runtimeCallN
;
llvm
::
Value
*
runtimeCall0
,
*
runtimeCall1
,
*
runtimeCall2
,
*
runtimeCall3
,
*
runtimeCall
,
*
runtimeCallN
;
llvm
::
Value
*
callattr0
,
*
callattr1
,
*
callattr2
,
*
callattr3
,
*
callattr
,
*
callattrN
;
llvm
::
Value
*
callattr0
,
*
callattr1
,
*
callattr2
,
*
callattr3
,
*
callattr
,
*
callattrN
;
...
...
src/runtime/inline/link_forcer.cpp
View file @
dd25db82
...
@@ -96,6 +96,7 @@ void force() {
...
@@ -96,6 +96,7 @@ void force() {
FORCE
(
unpackIntoArray
);
FORCE
(
unpackIntoArray
);
FORCE
(
raiseAttributeError
);
FORCE
(
raiseAttributeError
);
FORCE
(
raiseAttributeErrorStr
);
FORCE
(
raiseAttributeErrorStr
);
FORCE
(
raiseIndexErrorStr
);
FORCE
(
raiseNotIterableError
);
FORCE
(
raiseNotIterableError
);
FORCE
(
assertNameDefined
);
FORCE
(
assertNameDefined
);
FORCE
(
assertFailDerefNameDefined
);
FORCE
(
assertFailDerefNameDefined
);
...
...
src/runtime/objmodel.cpp
View file @
dd25db82
...
@@ -252,6 +252,10 @@ extern "C" void raiseAttributeError(Box* obj, const char* attr) {
...
@@ -252,6 +252,10 @@ extern "C" void raiseAttributeError(Box* obj, const char* attr) {
}
}
}
}
extern
"C"
void
raiseIndexErrorStr
(
const
char
*
typeName
)
{
raiseExcHelper
(
IndexError
,
"%s index out of range"
,
typeName
);
}
extern
"C"
void
raiseNotIterableError
(
const
char
*
typeName
)
{
extern
"C"
void
raiseNotIterableError
(
const
char
*
typeName
)
{
raiseExcHelper
(
TypeError
,
"'%s' object is not iterable"
,
typeName
);
raiseExcHelper
(
TypeError
,
"'%s' object is not iterable"
,
typeName
);
}
}
...
...
src/runtime/objmodel.h
View file @
dd25db82
...
@@ -132,6 +132,7 @@ Box* typeLookup(BoxedClass* cls, const std::string& attr, GetattrRewriteArgs* re
...
@@ -132,6 +132,7 @@ Box* typeLookup(BoxedClass* cls, const std::string& attr, GetattrRewriteArgs* re
extern
"C"
void
raiseAttributeErrorStr
(
const
char
*
typeName
,
const
char
*
attr
)
__attribute__
((
__noreturn__
));
extern
"C"
void
raiseAttributeErrorStr
(
const
char
*
typeName
,
const
char
*
attr
)
__attribute__
((
__noreturn__
));
extern
"C"
void
raiseAttributeError
(
Box
*
obj
,
const
char
*
attr
)
__attribute__
((
__noreturn__
));
extern
"C"
void
raiseAttributeError
(
Box
*
obj
,
const
char
*
attr
)
__attribute__
((
__noreturn__
));
extern
"C"
void
raiseNotIterableError
(
const
char
*
typeName
)
__attribute__
((
__noreturn__
));
extern
"C"
void
raiseNotIterableError
(
const
char
*
typeName
)
__attribute__
((
__noreturn__
));
extern
"C"
void
raiseIndexErrorStr
(
const
char
*
typeName
)
__attribute__
((
__noreturn__
));
Box
*
typeCall
(
Box
*
,
BoxedTuple
*
,
BoxedDict
*
);
Box
*
typeCall
(
Box
*
,
BoxedTuple
*
,
BoxedDict
*
);
Box
*
typeNew
(
Box
*
cls
,
Box
*
arg1
,
Box
*
arg2
,
Box
**
_args
);
Box
*
typeNew
(
Box
*
cls
,
Box
*
arg1
,
Box
*
arg2
,
Box
**
_args
);
...
...
test/tests/tuple_indexing.py
0 → 100644
View file @
dd25db82
def
f
():
print
(
1
,
2
,
3
)[
-
1
]
f
()
def
f2
():
try
:
print
(
1
,
2
,
3
)[
4
]
except
IndexError
as
e
:
print
e
try
:
print
(
1
,
2
,
3
)[
-
4
]
except
IndexError
as
e
:
print
e
f2
()
def
f3
():
try
:
print
(
1
,
2
,
3
)[
'hello'
]
except
TypeError
as
e
:
print
e
f3
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment