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
b2d54051
Commit
b2d54051
authored
Mar 20, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add HASNEXT opcode support to the llvm tier
parent
8baec850
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
58 additions
and
6 deletions
+58
-6
microbenchmarks/iteration.py
microbenchmarks/iteration.py
+2
-0
src/analysis/type_analysis.cpp
src/analysis/type_analysis.cpp
+1
-0
src/codegen/compvars.cpp
src/codegen/compvars.cpp
+30
-0
src/codegen/compvars.h
src/codegen/compvars.h
+8
-0
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+8
-5
src/codegen/patchpoints.cpp
src/codegen/patchpoints.cpp
+4
-0
src/codegen/patchpoints.h
src/codegen/patchpoints.h
+2
-0
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
No files found.
microbenchmarks/iteration.py
View file @
b2d54051
t
=
0
for
i
in
range
(
1000000
):
t
=
t
+
i
for
i
in
xrange
(
1000000
):
t
=
t
+
i
print
t
src/analysis/type_analysis.cpp
View file @
b2d54051
...
...
@@ -376,6 +376,7 @@ private:
case
AST_LangPrimitive
:
:
SET_EXC_INFO
:
case
AST_LangPrimitive
:
:
UNCACHE_EXC_INFO
:
return
NONE
;
case
AST_LangPrimitive
:
:
HASNEXT
:
case
AST_LangPrimitive
:
:
NONZERO
:
return
BOOL
;
default:
...
...
src/codegen/compvars.cpp
View file @
b2d54051
...
...
@@ -237,6 +237,7 @@ public:
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
override
;
ConcreteCompilerVariable
*
nonzero
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
)
override
;
ConcreteCompilerVariable
*
hasnext
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
)
override
;
void
setattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
,
CompilerVariable
*
v
)
override
{
...
...
@@ -707,6 +708,23 @@ ConcreteCompilerVariable* UnknownType::nonzero(IREmitter& emitter, const OpInfo&
return
boolFromI1
(
emitter
,
rtn_val
);
}
ConcreteCompilerVariable
*
UnknownType
::
hasnext
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
)
{
bool
do_patchpoint
=
ENABLE_ICS
&&
!
info
.
isInterpreted
();
llvm
::
Value
*
rtn_val
;
if
(
do_patchpoint
)
{
ICSetupInfo
*
pp
=
createHasnextIC
(
info
.
getTypeRecorder
());
std
::
vector
<
llvm
::
Value
*>
llvm_args
;
llvm_args
.
push_back
(
var
->
getValue
());
llvm
::
Value
*
uncasted
=
emitter
.
createIC
(
pp
,
(
void
*
)
pyston
::
hasnext
,
llvm_args
,
info
.
unw_info
);
rtn_val
=
emitter
.
getBuilder
()
->
CreateTrunc
(
uncasted
,
g
.
i1
);
}
else
{
rtn_val
=
emitter
.
createCall
(
info
.
unw_info
,
g
.
funcs
.
hasnext
,
var
->
getValue
());
}
return
boolFromI1
(
emitter
,
rtn_val
);
}
CompilerVariable
*
makeFunction
(
IREmitter
&
emitter
,
CLFunction
*
f
,
CompilerVariable
*
closure
,
bool
isGenerator
,
const
std
::
vector
<
ConcreteCompilerVariable
*>&
defaults
)
{
// Unlike the CLFunction*, which can be shared between recompilations, the Box* around it
...
...
@@ -1719,6 +1737,18 @@ public:
return
UNKNOWN
->
nonzero
(
emitter
,
info
,
var
);
}
ConcreteCompilerVariable
*
hasnext
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
)
override
{
static
const
std
::
string
attr
(
"__hasnext__"
);
ConcreteCompilerVariable
*
called_constant
=
tryCallattrConstant
(
emitter
,
info
,
var
,
&
attr
,
true
,
ArgPassSpec
(
0
,
0
,
0
,
0
),
{},
NULL
,
NULL
);
if
(
called_constant
)
return
called_constant
;
return
UNKNOWN
->
hasnext
(
emitter
,
info
,
var
);
}
static
NormalObjectType
*
fromClass
(
BoxedClass
*
cls
)
{
NormalObjectType
*&
rtn
=
made
[
cls
];
if
(
rtn
==
NULL
)
{
...
...
src/codegen/compvars.h
View file @
b2d54051
...
...
@@ -100,6 +100,10 @@ public:
printf
(
"nonzero not defined for %s
\n
"
,
debugName
().
c_str
());
abort
();
}
virtual
ConcreteCompilerVariable
*
hasnext
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
)
{
printf
(
"hasnext not defined for %s
\n
"
,
debugName
().
c_str
());
abort
();
}
virtual
CompilerVariable
*
getattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
const
std
::
string
*
attr
,
bool
cls_only
)
{
printf
(
"getattr not defined for %s
\n
"
,
debugName
().
c_str
());
...
...
@@ -256,6 +260,7 @@ public:
virtual
BoxedClass
*
guaranteedClass
()
=
0
;
virtual
ConcreteCompilerVariable
*
nonzero
(
IREmitter
&
emitter
,
const
OpInfo
&
info
)
=
0
;
virtual
ConcreteCompilerVariable
*
hasnext
(
IREmitter
&
emitter
,
const
OpInfo
&
info
)
=
0
;
virtual
CompilerVariable
*
getattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
const
std
::
string
*
attr
,
bool
cls_only
)
=
0
;
virtual
void
setattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
const
std
::
string
*
attr
,
CompilerVariable
*
v
)
=
0
;
...
...
@@ -327,6 +332,9 @@ public:
ConcreteCompilerVariable
*
nonzero
(
IREmitter
&
emitter
,
const
OpInfo
&
info
)
override
{
return
type
->
nonzero
(
emitter
,
info
,
this
);
}
ConcreteCompilerVariable
*
hasnext
(
IREmitter
&
emitter
,
const
OpInfo
&
info
)
override
{
return
type
->
hasnext
(
emitter
,
info
,
this
);
}
CompilerVariable
*
getattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
const
std
::
string
*
attr
,
bool
cls_only
)
override
{
return
type
->
getattr
(
emitter
,
info
,
this
,
attr
,
cls_only
);
}
...
...
src/codegen/irgen/irgenerator.cpp
View file @
b2d54051
...
...
@@ -576,13 +576,16 @@ private:
CompilerVariable
*
obj
=
evalExpr
(
node
->
args
[
0
],
unw_info
);
ConcreteCompilerVariable
*
rtn
=
obj
->
nonzero
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
));
assert
(
rtn
->
getType
()
==
BOOL
);
llvm
::
Value
*
v
=
i1FromBool
(
emitter
,
rtn
);
assert
(
v
->
getType
()
==
g
.
i1
);
obj
->
decvref
(
emitter
);
return
rtn
;
}
case
AST_LangPrimitive
:
:
HASNEXT
:
{
assert
(
node
->
args
.
size
()
==
1
);
CompilerVariable
*
obj
=
evalExpr
(
node
->
args
[
0
],
unw_info
);
return
boolFromI1
(
emitter
,
v
);
ConcreteCompilerVariable
*
rtn
=
obj
->
hasnext
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
));
obj
->
decvref
(
emitter
);
return
rtn
;
}
case
AST_LangPrimitive
:
:
SET_EXC_INFO
:
{
assert
(
node
->
args
.
size
()
==
3
);
...
...
src/codegen/patchpoints.cpp
View file @
b2d54051
...
...
@@ -336,4 +336,8 @@ ICSetupInfo* createNonzeroIC(TypeRecorder* type_recorder) {
return
ICSetupInfo
::
initialize
(
true
,
2
,
64
,
ICSetupInfo
::
Nonzero
,
type_recorder
);
}
ICSetupInfo
*
createHasnextIC
(
TypeRecorder
*
type_recorder
)
{
return
ICSetupInfo
::
initialize
(
true
,
2
,
64
,
ICSetupInfo
::
Hasnext
,
type_recorder
);
}
}
// namespace pyston
src/codegen/patchpoints.h
View file @
b2d54051
...
...
@@ -105,6 +105,7 @@ public:
Delitem
,
Binexp
,
Nonzero
,
Hasnext
,
};
private:
...
...
@@ -146,6 +147,7 @@ ICSetupInfo* createSetitemIC(TypeRecorder* type_recorder);
ICSetupInfo
*
createDelitemIC
(
TypeRecorder
*
type_recorder
);
ICSetupInfo
*
createBinexpIC
(
TypeRecorder
*
type_recorder
);
ICSetupInfo
*
createNonzeroIC
(
TypeRecorder
*
type_recorder
);
ICSetupInfo
*
createHasnextIC
(
TypeRecorder
*
type_recorder
);
}
// namespace pyston
...
...
src/codegen/runtime_hooks.cpp
View file @
b2d54051
...
...
@@ -209,6 +209,7 @@ void initGlobalFuncs(GlobalState& g) {
GET
(
isinstance
);
GET
(
yield
);
GET
(
getiterHelper
);
GET
(
hasnext
);
GET
(
unpackIntoArray
);
GET
(
raiseAttributeError
);
...
...
src/codegen/runtime_hooks.h
View file @
b2d54051
...
...
@@ -38,7 +38,7 @@ struct GlobalFuncs {
*
decodeUTF8StringPtr
;
llvm
::
Value
*
getattr
,
*
setattr
,
*
delattr
,
*
delitem
,
*
delGlobal
,
*
nonzero
,
*
binop
,
*
compare
,
*
augbinop
,
*
unboxedLen
,
*
getitem
,
*
getclsattr
,
*
getGlobal
,
*
setitem
,
*
unaryop
,
*
import
,
*
importFrom
,
*
importStar
,
*
repr
,
*
str
,
*
isinstance
,
*
yield
,
*
getiterHelper
;
*
isinstance
,
*
yield
,
*
getiterHelper
,
*
hasnext
;
llvm
::
Value
*
unpackIntoArray
,
*
raiseAttributeError
,
*
raiseAttributeErrorStr
,
*
raiseNotIterableError
,
*
assertNameDefined
,
*
assertFail
;
...
...
src/runtime/inline/link_forcer.cpp
View file @
b2d54051
...
...
@@ -90,6 +90,7 @@ void force() {
FORCE
(
isinstance
);
FORCE
(
yield
);
FORCE
(
getiterHelper
);
FORCE
(
hasnext
);
FORCE
(
unpackIntoArray
);
FORCE
(
raiseAttributeError
);
...
...
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