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
8e8c910f
Commit
8e8c910f
authored
Jul 24, 2015
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bjit: add support for the import nodes
parent
0fdbc574
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
7 deletions
+25
-7
src/codegen/ast_interpreter.cpp
src/codegen/ast_interpreter.cpp
+7
-7
src/codegen/baseline_jit.cpp
src/codegen/baseline_jit.cpp
+15
-0
src/codegen/baseline_jit.h
src/codegen/baseline_jit.h
+3
-0
No files found.
src/codegen/ast_interpreter.cpp
View file @
8e8c910f
...
...
@@ -788,7 +788,6 @@ Value ASTInterpreter::visit_langPrimitive(AST_LangPrimitive* node) {
Value
val
=
visit_expr
(
node
->
args
[
0
]);
v
=
Value
(
getPystonIter
(
val
.
o
),
jit
?
jit
->
emitGetPystonIter
(
val
)
:
NULL
);
}
else
if
(
node
->
opcode
==
AST_LangPrimitive
::
IMPORT_FROM
)
{
abortJITing
();
assert
(
node
->
args
.
size
()
==
2
);
assert
(
node
->
args
[
0
]
->
type
==
AST_TYPE
::
Name
);
assert
(
node
->
args
[
1
]
->
type
==
AST_TYPE
::
Str
);
...
...
@@ -798,10 +797,11 @@ Value ASTInterpreter::visit_langPrimitive(AST_LangPrimitive* node) {
assert
(
ast_str
->
str_type
==
AST_Str
::
STR
);
const
std
::
string
&
name
=
ast_str
->
str_data
;
assert
(
name
.
size
());
// TODO: shouldn't have to rebox here
v
.
o
=
importFrom
(
module
.
o
,
internStringMortal
(
name
));
BoxedString
*
name_boxed
=
source_info
->
parent_module
->
getStringConstant
(
name
,
true
);
if
(
jit
)
v
.
var
=
jit
->
emitImportFrom
(
module
,
name_boxed
);
v
.
o
=
importFrom
(
module
.
o
,
name_boxed
);
}
else
if
(
node
->
opcode
==
AST_LangPrimitive
::
IMPORT_NAME
)
{
abortJITing
();
assert
(
node
->
args
.
size
()
==
3
);
assert
(
node
->
args
[
0
]
->
type
==
AST_TYPE
::
Num
);
assert
(
static_cast
<
AST_Num
*>
(
node
->
args
[
0
])
->
num_type
==
AST_Num
::
INT
);
...
...
@@ -812,9 +812,10 @@ Value ASTInterpreter::visit_langPrimitive(AST_LangPrimitive* node) {
auto
ast_str
=
ast_cast
<
AST_Str
>
(
node
->
args
[
2
]);
assert
(
ast_str
->
str_type
==
AST_Str
::
STR
);
const
std
::
string
&
module_name
=
ast_str
->
str_data
;
if
(
jit
)
v
.
var
=
jit
->
emitImportName
(
level
,
froms
,
module_name
);
v
.
o
=
import
(
level
,
froms
.
o
,
module_name
);
}
else
if
(
node
->
opcode
==
AST_LangPrimitive
::
IMPORT_STAR
)
{
abortJITing
();
assert
(
node
->
args
.
size
()
==
1
);
assert
(
node
->
args
[
0
]
->
type
==
AST_TYPE
::
Name
);
...
...
@@ -822,8 +823,7 @@ Value ASTInterpreter::visit_langPrimitive(AST_LangPrimitive* node) {
"import * not supported in functions"
);
Value
module
=
visit_expr
(
node
->
args
[
0
]);
v
.
o
=
importStar
(
module
.
o
,
globals
);
v
=
Value
(
importStar
(
module
.
o
,
globals
),
jit
?
jit
->
emitImportStar
(
module
)
:
NULL
);
}
else
if
(
node
->
opcode
==
AST_LangPrimitive
::
NONE
)
{
v
=
getNone
();
}
else
if
(
node
->
opcode
==
AST_LangPrimitive
::
LANDINGPAD
)
{
...
...
src/codegen/baseline_jit.cpp
View file @
8e8c910f
...
...
@@ -22,6 +22,7 @@
#include "codegen/type_recording.h"
#include "core/cfg.h"
#include "runtime/generator.h"
#include "runtime/import.h"
#include "runtime/inline/list.h"
#include "runtime/objmodel.h"
#include "runtime/set.h"
...
...
@@ -330,6 +331,20 @@ RewriterVar* JitFragmentWriter::emitHasnext(RewriterVar* v) {
return
call
(
false
,
(
void
*
)
hasnextHelper
,
v
);
}
RewriterVar
*
JitFragmentWriter
::
emitImportFrom
(
RewriterVar
*
module
,
BoxedString
*
name
)
{
return
call
(
false
,
(
void
*
)
importFrom
,
module
,
imm
(
name
));
}
RewriterVar
*
JitFragmentWriter
::
emitImportName
(
int
level
,
RewriterVar
*
from_imports
,
llvm
::
StringRef
module_name
)
{
return
call
(
false
,
(
void
*
)
import
,
imm
(
level
),
from_imports
,
imm
(
const_cast
<
char
*>
(
module_name
.
data
())),
imm
(
module_name
.
size
()));
}
RewriterVar
*
JitFragmentWriter
::
emitImportStar
(
RewriterVar
*
module
)
{
RewriterVar
*
globals
=
getInterp
()
->
getAttr
(
ASTInterpreterJitInterface
::
getGlobalsOffset
());
return
call
(
false
,
(
void
*
)
importStar
,
module
,
globals
);
}
RewriterVar
*
JitFragmentWriter
::
emitLandingpad
()
{
return
call
(
false
,
(
void
*
)
ASTInterpreterJitInterface
::
landingpadHelper
,
getInterp
());
}
...
...
src/codegen/baseline_jit.h
View file @
8e8c910f
...
...
@@ -226,6 +226,9 @@ public:
RewriterVar
*
emitGetLocal
(
InternedString
s
,
int
vreg
);
RewriterVar
*
emitGetPystonIter
(
RewriterVar
*
v
);
RewriterVar
*
emitHasnext
(
RewriterVar
*
v
);
RewriterVar
*
emitImportFrom
(
RewriterVar
*
module
,
BoxedString
*
name
);
RewriterVar
*
emitImportName
(
int
level
,
RewriterVar
*
from_imports
,
llvm
::
StringRef
module_name
);
RewriterVar
*
emitImportStar
(
RewriterVar
*
module
);
RewriterVar
*
emitLandingpad
();
RewriterVar
*
emitNonzero
(
RewriterVar
*
v
);
RewriterVar
*
emitNotNonzero
(
RewriterVar
*
v
);
...
...
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