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
fc9ad920
Commit
fc9ad920
authored
Mar 24, 2015
by
Travis Hance
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inline the assert check
parent
de5fde04
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
36 additions
and
17 deletions
+36
-17
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+24
-9
src/codegen/runtime_hooks.cpp
src/codegen/runtime_hooks.cpp
+1
-1
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
-1
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+2
-4
src/runtime/objmodel.h
src/runtime/objmodel.h
+1
-1
tools/tester.py
tools/tester.py
+6
-0
No files found.
src/codegen/irgen/irgenerator.cpp
View file @
fc9ad920
...
@@ -917,8 +917,30 @@ private:
...
@@ -917,8 +917,30 @@ private:
llvm
::
ConstantInt
::
get
(
g
.
i32
,
deref_info
.
offset
)
});
llvm
::
ConstantInt
::
get
(
g
.
i32
,
deref_info
.
offset
)
});
llvm
::
Value
*
lookupResult
=
emitter
.
getBuilder
()
->
CreateLoad
(
gep
);
llvm
::
Value
*
lookupResult
=
emitter
.
getBuilder
()
->
CreateLoad
(
gep
);
emitter
.
createCall
(
unw_info
,
g
.
funcs
.
assertDerefNameDefined
,
// If the value is NULL, it is undefined.
{
lookupResult
,
getStringConstantPtr
(
node
->
id
.
str
()
+
'\0'
)
});
// Create a branch on if the value is NULL
llvm
::
BasicBlock
*
success_bb
=
llvm
::
BasicBlock
::
Create
(
g
.
context
,
"deref_defined"
,
irstate
->
getLLVMFunction
());
success_bb
->
moveAfter
(
curblock
);
llvm
::
BasicBlock
*
fail_bb
=
llvm
::
BasicBlock
::
Create
(
g
.
context
,
"deref_undefined"
,
irstate
->
getLLVMFunction
());
llvm
::
Value
*
check_val
=
emitter
.
getBuilder
()
->
CreateICmpEQ
(
lookupResult
,
embedConstantPtr
(
NULL
,
g
.
llvm_value_type_ptr
));
llvm
::
BranchInst
*
non_null_check
=
emitter
.
getBuilder
()
->
CreateCondBr
(
check_val
,
fail_bb
,
success_bb
);
// In the case that it failed, call the assert fail function
curblock
=
fail_bb
;
emitter
.
getBuilder
()
->
SetInsertPoint
(
curblock
);
llvm
::
CallSite
call
=
emitter
.
createCall
(
unw_info
,
g
.
funcs
.
assertFailDerefNameDefined
,
getStringConstantPtr
(
node
->
id
.
str
()
+
'\0'
));
call
.
setDoesNotReturn
();
emitter
.
getBuilder
()
->
CreateUnreachable
();
// Carry on in the case that it succeeded
curblock
=
success_bb
;
emitter
.
getBuilder
()
->
SetInsertPoint
(
curblock
);
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
lookupResult
,
true
);
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
lookupResult
,
true
);
}
else
if
(
vst
==
ScopeInfo
::
VarScopeType
::
NAME
)
{
}
else
if
(
vst
==
ScopeInfo
::
VarScopeType
::
NAME
)
{
...
@@ -1459,13 +1481,6 @@ private:
...
@@ -1459,13 +1481,6 @@ private:
closureValue
,
{
llvm
::
ConstantInt
::
get
(
g
.
i32
,
0
),
llvm
::
ConstantInt
::
get
(
g
.
i32
,
3
),
closureValue
,
{
llvm
::
ConstantInt
::
get
(
g
.
i32
,
0
),
llvm
::
ConstantInt
::
get
(
g
.
i32
,
3
),
llvm
::
ConstantInt
::
get
(
g
.
i32
,
offset
)
});
llvm
::
ConstantInt
::
get
(
g
.
i32
,
offset
)
});
emitter
.
getBuilder
()
->
CreateStore
(
val
->
makeConverted
(
emitter
,
UNKNOWN
)
->
getValue
(),
gep
);
emitter
.
getBuilder
()
->
CreateStore
(
val
->
makeConverted
(
emitter
,
UNKNOWN
)
->
getValue
(),
gep
);
/*
CompilerVariable* closure = symbol_table[internString(CREATED_CLOSURE_NAME)];
assert(closure);
closure->setattr(emitter, getEmptyOpInfo(unw_info), &name.str(), val);
*/
}
}
}
}
}
}
...
...
src/codegen/runtime_hooks.cpp
View file @
fc9ad920
...
@@ -216,7 +216,7 @@ void initGlobalFuncs(GlobalState& g) {
...
@@ -216,7 +216,7 @@ void initGlobalFuncs(GlobalState& g) {
GET
(
raiseAttributeErrorStr
);
GET
(
raiseAttributeErrorStr
);
GET
(
raiseNotIterableError
);
GET
(
raiseNotIterableError
);
GET
(
assertNameDefined
);
GET
(
assertNameDefined
);
GET
(
assertDerefNameDefined
);
GET
(
assert
Fail
DerefNameDefined
);
GET
(
assertFail
);
GET
(
assertFail
);
GET
(
printFloat
);
GET
(
printFloat
);
...
...
src/codegen/runtime_hooks.h
View file @
fc9ad920
...
@@ -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
,
*
assertDerefNameDefined
;
*
assertNameDefined
,
*
assertFail
,
*
assert
Fail
DerefNameDefined
;
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 @
fc9ad920
...
@@ -98,7 +98,7 @@ void force() {
...
@@ -98,7 +98,7 @@ void force() {
FORCE
(
raiseAttributeErrorStr
);
FORCE
(
raiseAttributeErrorStr
);
FORCE
(
raiseNotIterableError
);
FORCE
(
raiseNotIterableError
);
FORCE
(
assertNameDefined
);
FORCE
(
assertNameDefined
);
FORCE
(
assertDerefNameDefined
);
FORCE
(
assert
Fail
DerefNameDefined
);
FORCE
(
assertFail
);
FORCE
(
assertFail
);
FORCE
(
printFloat
);
FORCE
(
printFloat
);
...
...
src/runtime/objmodel.cpp
View file @
fc9ad920
...
@@ -233,10 +233,8 @@ extern "C" void assertNameDefined(bool b, const char* name, BoxedClass* exc_cls,
...
@@ -233,10 +233,8 @@ extern "C" void assertNameDefined(bool b, const char* name, BoxedClass* exc_cls,
}
}
}
}
extern
"C"
void
assertDerefNameDefined
(
Box
*
b
,
const
char
*
name
)
{
extern
"C"
void
assertFailDerefNameDefined
(
const
char
*
name
)
{
if
(
b
==
NULL
)
{
raiseExcHelper
(
NameError
,
"free variable '%s' referenced before assignment in enclosing scope"
,
name
);
raiseExcHelper
(
NameError
,
"free variable '%s' referenced before assignment in enclosing scope"
,
name
);
}
}
}
extern
"C"
void
raiseAttributeErrorStr
(
const
char
*
typeName
,
const
char
*
attr
)
{
extern
"C"
void
raiseAttributeErrorStr
(
const
char
*
typeName
,
const
char
*
attr
)
{
...
...
src/runtime/objmodel.h
View file @
fc9ad920
...
@@ -83,7 +83,7 @@ extern "C" Box* importFrom(Box* obj, const std::string* attr);
...
@@ -83,7 +83,7 @@ extern "C" Box* importFrom(Box* obj, const std::string* attr);
extern
"C"
Box
*
importStar
(
Box
*
from_module
,
BoxedModule
*
to_module
);
extern
"C"
Box
*
importStar
(
Box
*
from_module
,
BoxedModule
*
to_module
);
extern
"C"
Box
**
unpackIntoArray
(
Box
*
obj
,
int64_t
expected_size
);
extern
"C"
Box
**
unpackIntoArray
(
Box
*
obj
,
int64_t
expected_size
);
extern
"C"
void
assertNameDefined
(
bool
b
,
const
char
*
name
,
BoxedClass
*
exc_cls
,
bool
local_var_msg
);
extern
"C"
void
assertNameDefined
(
bool
b
,
const
char
*
name
,
BoxedClass
*
exc_cls
,
bool
local_var_msg
);
extern
"C"
void
assert
DerefNameDefined
(
Box
*
b
,
const
char
*
name
);
extern
"C"
void
assert
FailDerefNameDefined
(
const
char
*
name
);
extern
"C"
void
assertFail
(
BoxedModule
*
inModule
,
Box
*
msg
);
extern
"C"
void
assertFail
(
BoxedModule
*
inModule
,
Box
*
msg
);
extern
"C"
bool
isSubclass
(
BoxedClass
*
child
,
BoxedClass
*
parent
);
extern
"C"
bool
isSubclass
(
BoxedClass
*
child
,
BoxedClass
*
parent
);
extern
"C"
BoxedClosure
*
createClosure
(
BoxedClosure
*
parent_closure
,
size_t
size
);
extern
"C"
BoxedClosure
*
createClosure
(
BoxedClosure
*
parent_closure
,
size_t
size
);
...
...
tools/tester.py
View file @
fc9ad920
...
@@ -158,6 +158,8 @@ def run_test(fn, check_stats, run_memcheck):
...
@@ -158,6 +158,8 @@ def run_test(fn, check_stats, run_memcheck):
skip
=
eval
(
skip_if
)
skip
=
eval
(
skip_if
)
if
skip
:
if
skip
:
return
r
+
" (skipped due to 'skip-if: %s')"
%
skip_if
[:
30
]
return
r
+
" (skipped due to 'skip-if: %s')"
%
skip_if
[:
30
]
elif
fn
.
split
(
'.'
)[
0
]
in
TESTS_TO_SKIP
:
return
r
+
" (skipped due to command line option)"
elif
l
.
startswith
(
"# allow-warning:"
):
elif
l
.
startswith
(
"# allow-warning:"
):
allow_warnings
.
append
(
"Warning: "
+
l
.
split
(
':'
,
1
)[
1
].
strip
())
allow_warnings
.
append
(
"Warning: "
+
l
.
split
(
':'
,
1
)[
1
].
strip
())
elif
l
.
startswith
(
"# no-collect-stats"
):
elif
l
.
startswith
(
"# no-collect-stats"
):
...
@@ -386,6 +388,8 @@ parser.add_argument('-a', '--extra-args', default=[], action='append',
...
@@ -386,6 +388,8 @@ parser.add_argument('-a', '--extra-args', default=[], action='append',
help="additional arguments to pyston (must be invoked with equal sign: -a=-ARG)")
help="additional arguments to pyston (must be invoked with equal sign: -a=-ARG)")
parser.add_argument('-t', '--time-limit', type=int, default=TIME_LIMIT,
parser.add_argument('-t', '--time-limit', type=int, default=TIME_LIMIT,
help='set time limit in seconds for each test')
help='set time limit in seconds for each test')
parser.add_argument('-s', '--skip-tests', type=str, default='',
help='tests to skip (comma-separated)')
parser.add_argument('test_dir')
parser.add_argument('test_dir')
parser.add_argument('patterns', nargs='*')
parser.add_argument('patterns', nargs='*')
...
@@ -397,6 +401,7 @@ def main(orig_dir):
...
@@ -397,6 +401,7 @@ def main(orig_dir):
global TIME_LIMIT
global TIME_LIMIT
global TEST_DIR
global TEST_DIR
global FN_JUST_SIZE
global FN_JUST_SIZE
global TESTS_TO_SKIP
run_memcheck = False
run_memcheck = False
start = 1
start = 1
...
@@ -408,6 +413,7 @@ def main(orig_dir):
...
@@ -408,6 +413,7 @@ def main(orig_dir):
KEEP_GOING = opts.keep_going
KEEP_GOING = opts.keep_going
EXTRA_JIT_ARGS += opts.extra_args
EXTRA_JIT_ARGS += opts.extra_args
TIME_LIMIT = opts.time_limit
TIME_LIMIT = opts.time_limit
TESTS_TO_SKIP = opts.skip_tests.split(',')
TEST_DIR = os.path.join(orig_dir, opts.test_dir)
TEST_DIR = os.path.join(orig_dir, opts.test_dir)
patterns = opts.patterns
patterns = opts.patterns
...
...
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