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
f1e90870
Commit
f1e90870
authored
Mar 28, 2016
by
Kevin Modzelewski
Committed by
Kevin Modzelewski
Mar 29, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some basic compile()/exec refcounting
parent
5e13f1e3
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
26 additions
and
26 deletions
+26
-26
src/codegen/codegen.cpp
src/codegen/codegen.cpp
+5
-2
src/codegen/irgen/hooks.cpp
src/codegen/irgen/hooks.cpp
+12
-4
src/codegen/irgen/hooks.h
src/codegen/irgen/hooks.h
+1
-1
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+1
-0
src/core/types.h
src/core/types.h
+1
-1
src/runtime/code.cpp
src/runtime/code.cpp
+4
-4
src/runtime/code.h
src/runtime/code.h
+2
-2
test/tests/ast_test.py
test/tests/ast_test.py
+0
-1
test/tests/backtick.py
test/tests/backtick.py
+0
-1
test/tests/compile_eval.py
test/tests/compile_eval.py
+0
-1
test/tests/compile_future.py
test/tests/compile_future.py
+0
-1
test/tests/del_closure_var_syntax_error.py
test/tests/del_closure_var_syntax_error.py
+0
-1
test/tests/deopt_namescope_tests.py
test/tests/deopt_namescope_tests.py
+0
-1
test/tests/exec_in_basic_test.py
test/tests/exec_in_basic_test.py
+0
-1
test/tests/exec_set_local.py
test/tests/exec_set_local.py
+0
-1
test/tests/exec_syntax_error.py
test/tests/exec_syntax_error.py
+0
-1
test/tests/exec_syntaxerror.py
test/tests/exec_syntaxerror.py
+0
-1
test/tests/import_globals.py
test/tests/import_globals.py
+0
-1
test/tests/parsing_bom.py
test/tests/parsing_bom.py
+0
-1
No files found.
src/codegen/codegen.cpp
View file @
f1e90870
...
...
@@ -131,8 +131,11 @@ SourceInfo::SourceInfo(BoxedModule* m, ScopingAnalysis* scoping, FutureFlags fut
cfg
(
NULL
),
body
(
std
::
move
(
body
))
{
assert
(
fn
);
// TODO: we should track this reference correctly rather than making it a root
//gc::registerPermanentRoot(fn, true);
// TODO: this is a very bad way of handling this:
incref
(
fn
);
late_constants
.
push_back
(
fn
);
this
->
fn
=
fn
;
switch
(
ast
->
type
)
{
...
...
src/codegen/irgen/hooks.cpp
View file @
f1e90870
...
...
@@ -107,6 +107,11 @@ InternedStringPool& SourceInfo::getInternedStrings() {
return
scoping
->
getInternedStrings
();
}
BORROWED
(
BoxedString
*
)
SourceInfo
::
getFn
()
{
assert
(
fn
->
ob_refcnt
>=
1
);
return
fn
;
}
BORROWED
(
BoxedString
*
)
SourceInfo
::
getName
()
{
assert
(
ast
);
...
...
@@ -323,7 +328,8 @@ void compileAndRunModule(AST_Module* m, BoxedModule* bm) {
FutureFlags
future_flags
=
getFutureFlags
(
m
->
body
,
fn
);
ScopingAnalysis
*
scoping
=
new
ScopingAnalysis
(
m
,
true
);
auto
fn_str
=
getStaticString
(
fn
);
// XXX this is not a static string
auto
fn_str
=
boxString
(
fn
);
AUTO_DECREF
(
fn_str
);
std
::
unique_ptr
<
SourceInfo
>
si
(
new
SourceInfo
(
bm
,
scoping
,
future_flags
,
m
,
m
->
body
,
fn_str
));
static
BoxedString
*
doc_str
=
getStaticString
(
"__doc__"
);
...
...
@@ -525,7 +531,7 @@ extern "C" PyObject* PyEval_EvalCode(PyCodeObject* co, PyObject* globals, PyObje
}
}
Box
*
exec
(
Box
*
boxedCode
,
Box
*
globals
,
Box
*
locals
,
FutureFlags
caller_future_flags
)
{
void
exec
(
Box
*
boxedCode
,
Box
*
globals
,
Box
*
locals
,
FutureFlags
caller_future_flags
)
{
if
(
!
globals
)
globals
=
None
;
if
(
!
locals
)
...
...
@@ -608,7 +614,7 @@ Box* exec(Box* boxedCode, Box* globals, Box* locals, FutureFlags caller_future_f
}
#endif
if
(
PyString_AsStringAndSize
(
prog
,
&
str
,
NULL
))
return
0
;
throwCAPIException
()
;
cf
.
cf_flags
|=
caller_future_flags
&
PyCF_MASK
;
if
(
cf
.
cf_flags
)
v
=
PyRun_StringFlags
(
str
,
Py_file_input
,
globals
,
locals
,
&
cf
);
...
...
@@ -619,7 +625,9 @@ Box* exec(Box* boxedCode, Box* globals, Box* locals, FutureFlags caller_future_f
if
(
!
v
)
throwCAPIException
();
return
v
;
assert
(
v
==
None
);
// not really necessary but I think this should be true
Py_DECREF
(
v
);
}
// If a function version keeps failing its speculations, kill it (remove it
...
...
src/codegen/irgen/hooks.h
View file @
f1e90870
...
...
@@ -39,7 +39,7 @@ void compileAndRunModule(AST_Module* m, BoxedModule* bm);
// will we always want to generate unique function names? (ie will this function always be reasonable?)
CompiledFunction
*
cfForMachineFunctionName
(
const
std
::
string
&
);
extern
"C"
Box
*
exec
(
Box
*
boxedCode
,
Box
*
globals
,
Box
*
locals
,
FutureFlags
caller_future_flags
);
extern
"C"
void
exec
(
Box
*
boxedCode
,
Box
*
globals
,
Box
*
locals
,
FutureFlags
caller_future_flags
);
}
#endif
src/codegen/irgen/irgenerator.cpp
View file @
f1e90870
...
...
@@ -1394,6 +1394,7 @@ private:
std
::
vector
<
llvm
::
Value
*>
args
{
cvar
->
getValue
()
};
llvm
::
Value
*
rtn
=
emitter
.
createCall
(
unw_info
,
g
.
funcs
.
repr
,
args
);
emitter
.
setType
(
rtn
,
RefType
::
BORROWED
);
// Well, really it's owned, and we handoff the ref to the bitcast
rtn
=
emitter
.
getBuilder
()
->
CreateBitCast
(
rtn
,
g
.
llvm_value_type_ptr
);
emitter
.
setType
(
rtn
,
RefType
::
OWNED
);
...
...
src/core/types.h
View file @
f1e90870
...
...
@@ -409,7 +409,7 @@ public:
const
std
::
vector
<
AST_stmt
*>
body
;
BORROWED
(
BoxedString
*
)
getName
();
BORROWED
(
BoxedString
*
)
getFn
()
{
return
fn
;
}
BORROWED
(
BoxedString
*
)
getFn
()
;
InternedString
mangleName
(
InternedString
id
);
...
...
src/runtime/code.cpp
View file @
f1e90870
...
...
@@ -34,7 +34,7 @@ BORROWED(Box*) BoxedCode::name(Box* b, void*) {
return
code
->
f
->
source
->
getName
();
}
Box
*
BoxedCode
::
f
_name
(
Box
*
b
,
void
*
arg
)
{
Box
*
BoxedCode
::
co
_name
(
Box
*
b
,
void
*
arg
)
{
return
incref
(
name
(
b
,
arg
));
}
...
...
@@ -46,7 +46,7 @@ BORROWED(Box*) BoxedCode::filename(Box* b, void*) {
return
code
->
f
->
source
->
getFn
();
}
Box
*
BoxedCode
::
f
_filename
(
Box
*
b
,
void
*
arg
)
{
Box
*
BoxedCode
::
co
_filename
(
Box
*
b
,
void
*
arg
)
{
return
incref
(
filename
(
b
,
arg
));
}
...
...
@@ -213,8 +213,8 @@ void setupCode() {
code_cls
->
giveAttrBorrowed
(
"__new__"
,
None
);
// Hacky way of preventing users from instantiating this
code_cls
->
giveAttrDescriptor
(
"co_name"
,
BoxedCode
::
f
_name
,
NULL
);
code_cls
->
giveAttrDescriptor
(
"co_filename"
,
BoxedCode
::
f
_filename
,
NULL
);
code_cls
->
giveAttrDescriptor
(
"co_name"
,
BoxedCode
::
co
_name
,
NULL
);
code_cls
->
giveAttrDescriptor
(
"co_filename"
,
BoxedCode
::
co
_filename
,
NULL
);
code_cls
->
giveAttrDescriptor
(
"co_firstlineno"
,
BoxedCode
::
firstlineno
,
NULL
);
code_cls
->
giveAttrDescriptor
(
"co_argcount"
,
BoxedCode
::
argcount
,
NULL
);
code_cls
->
giveAttrDescriptor
(
"co_varnames"
,
BoxedCode
::
varnames
,
NULL
);
...
...
src/runtime/code.h
View file @
f1e90870
...
...
@@ -41,8 +41,8 @@ public:
// pointers could point to them.
static
BORROWED
(
Box
*
)
name
(
Box
*
b
,
void
*
);
static
BORROWED
(
Box
*
)
filename
(
Box
*
b
,
void
*
);
static
Box
*
f
_name
(
Box
*
b
,
void
*
);
static
Box
*
f
_filename
(
Box
*
b
,
void
*
);
static
Box
*
co
_name
(
Box
*
b
,
void
*
);
static
Box
*
co
_filename
(
Box
*
b
,
void
*
);
static
Box
*
firstlineno
(
Box
*
b
,
void
*
);
static
Box
*
argcount
(
Box
*
b
,
void
*
);
static
Box
*
varnames
(
Box
*
b
,
void
*
);
...
...
test/tests/ast_test.py
View file @
f1e90870
# expected: reffail
import
_ast
def
ast_parse
(
source
,
filename
=
'<unknown>'
,
mode
=
'exec'
):
...
...
test/tests/backtick.py
View file @
f1e90870
# expected: reffail
print
`42`
print
`int`
print
`2+3`
...
...
test/tests/compile_eval.py
View file @
f1e90870
# expected: reffail
print
compile
c
=
compile
(
"a"
,
"test.py"
,
"eval"
)
print
type
(
c
),
c
.
co_filename
,
c
.
co_name
...
...
test/tests/compile_future.py
View file @
f1e90870
# expected: reffail
from
__future__
import
division
# compile() inherits the future flags of the parent module
...
...
test/tests/del_closure_var_syntax_error.py
View file @
f1e90870
# expected: reffail
try
:
import
__pyston__
__pyston__
.
setOption
(
"LAZY_SCOPING_ANALYSIS"
,
0
)
...
...
test/tests/deopt_namescope_tests.py
View file @
f1e90870
# expected: reffail
# skip-if: '-O' in EXTRA_JIT_ARGS
# statcheck: 4 <= noninit_count('num_deopt') < 50
# statcheck: 1 <= stats["num_osr_exits"] <= 2
...
...
test/tests/exec_in_basic_test.py
View file @
f1e90870
# expected: reffail
d
=
{}
exec
"a = 5"
in
d
print
d
[
'a'
]
...
...
test/tests/exec_set_local.py
View file @
f1e90870
# expected: reffail
def
f
():
exec
"a = 5"
print
a
...
...
test/tests/exec_syntax_error.py
View file @
f1e90870
# expected: reffail
s
=
"""
def f():
a = 1
...
...
test/tests/exec_syntaxerror.py
View file @
f1e90870
# expected: reffail
# fail-if: '-x' in EXTRA_JIT_ARGS
# - we don't get syntax errors through the old parser correctly
...
...
test/tests/import_globals.py
View file @
f1e90870
# expected: reffail
import
test_package.import_target
import
import_target
print
...
...
test/tests/parsing_bom.py
View file @
f1e90870
# expected: reffail
# I really don't understand all the intricacies of unicode parsing, but apparently in addition to
# Python-specific coding lines, you can put a unicode byte order mark to signify that the text
# is encoded.
...
...
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