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
7e195c56
Commit
7e195c56
authored
Feb 25, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit 'bf2bae' into refcounting
builds but doesn't run yet
parents
f40abdee
bf2bae9d
Changes
32
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
272 additions
and
348 deletions
+272
-348
from_cpython/Objects/iterobject.c
from_cpython/Objects/iterobject.c
+1
-1
src/capi/typeobject.cpp
src/capi/typeobject.cpp
+1
-2
src/codegen/ast_interpreter.cpp
src/codegen/ast_interpreter.cpp
+33
-58
src/codegen/ast_interpreter.h
src/codegen/ast_interpreter.h
+0
-3
src/codegen/irgen.cpp
src/codegen/irgen.cpp
+5
-9
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+148
-165
src/codegen/irgen/irgenerator.h
src/codegen/irgen/irgenerator.h
+6
-5
src/codegen/opt/inliner.cpp
src/codegen/opt/inliner.cpp
+3
-0
src/codegen/patchpoints.cpp
src/codegen/patchpoints.cpp
+10
-10
src/codegen/patchpoints.h
src/codegen/patchpoints.h
+5
-1
src/codegen/unwinding.cpp
src/codegen/unwinding.cpp
+8
-20
src/core/options.cpp
src/core/options.cpp
+1
-2
src/core/options.h
src/core/options.h
+1
-1
src/core/types.h
src/core/types.h
+13
-3
src/runtime/dict.h
src/runtime/dict.h
+1
-1
src/runtime/generator.cpp
src/runtime/generator.cpp
+1
-1
src/runtime/inline/boxing.cpp
src/runtime/inline/boxing.cpp
+4
-0
src/runtime/inline/dict.cpp
src/runtime/inline/dict.cpp
+1
-1
src/runtime/inline/list.cpp
src/runtime/inline/list.cpp
+2
-18
src/runtime/inline/tuple.cpp
src/runtime/inline/tuple.cpp
+1
-1
src/runtime/inline/xrange.cpp
src/runtime/inline/xrange.cpp
+1
-1
src/runtime/int.cpp
src/runtime/int.cpp
+0
-25
src/runtime/int.h
src/runtime/int.h
+0
-6
src/runtime/iterobject.cpp
src/runtime/iterobject.cpp
+3
-3
src/runtime/iterobject.h
src/runtime/iterobject.h
+1
-1
src/runtime/list.cpp
src/runtime/list.cpp
+16
-0
src/runtime/list.h
src/runtime/list.h
+2
-2
src/runtime/str.cpp
src/runtime/str.cpp
+1
-1
src/runtime/tuple.h
src/runtime/tuple.h
+1
-1
src/runtime/types.cpp
src/runtime/types.cpp
+1
-1
src/runtime/types.h
src/runtime/types.h
+1
-1
src/runtime/util.cpp
src/runtime/util.cpp
+0
-4
No files found.
from_cpython/Objects/iterobject.c
View file @
7e195c56
...
...
@@ -42,7 +42,7 @@ calliter_traverse(calliterobject *it, visitproc visit, void *arg)
}
// Pyston change: extract most of the body of calliter_iternext here
// so we can use it from both calliter_iternext and calliter
_hasnext
// so we can use it from both calliter_iternext and calliter
HasnextUnboxed
PyObject
*
calliter_next
(
calliterobject
*
it
)
{
...
...
src/capi/typeobject.cpp
View file @
7e195c56
...
...
@@ -777,10 +777,9 @@ PyObject* slot_tp_iter(PyObject* self) noexcept {
return
call_method
(
self
,
"next"
,
&
next_str
,
"()"
);
}
static
bool
slotTppHasnext
(
PyObject
*
self
)
{
static
llvm_compat_
bool
slotTppHasnext
(
PyObject
*
self
)
{
STAT_TIMER
(
t0
,
"us_timer_slot_tpphasnext"
,
SLOT_AVOIDABILITY
(
self
));
static
PyObject
*
hasnext_str
;
Box
*
r
=
self
->
hasnextOrNullIC
();
assert
(
r
);
return
r
->
nonzeroIC
();
...
...
src/codegen/ast_interpreter.cpp
View file @
7e195c56
This diff is collapsed.
Click to expand it.
src/codegen/ast_interpreter.h
View file @
7e195c56
...
...
@@ -76,13 +76,10 @@ Box* astInterpretFunctionEval(FunctionMetadata* cf, Box* globals, Box* boxedLoca
Box
*
astInterpretDeopt
(
FunctionMetadata
*
cf
,
AST_expr
*
after_expr
,
AST_stmt
*
enclosing_stmt
,
Box
*
expr_val
,
FrameStackState
frame_state
);
AST_stmt
*
getCurrentStatementForInterpretedFrame
(
void
*
frame_ptr
);
Box
*
getGlobalsForInterpretedFrame
(
void
*
frame_ptr
);
FunctionMetadata
*
getMDForInterpretedFrame
(
void
*
frame_ptr
);
struct
FrameInfo
;
FrameInfo
*
getFrameInfoForInterpretedFrame
(
void
*
frame_ptr
);
Box
**
getVRegsForInterpretedFrame
(
void
*
frame_ptr
);
BoxedDict
*
localsForInterpretedFrame
(
Box
**
vregs
,
CFG
*
cfg
);
BoxedDict
*
localsForInterpretedFrame
(
void
*
frame_ptr
);
...
...
src/codegen/irgen.cpp
View file @
7e195c56
...
...
@@ -369,6 +369,8 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
llvm_entry_blocks
[
block
]
=
llvm
::
BasicBlock
::
Create
(
g
.
context
,
buf
,
irstate
->
getLLVMFunction
());
}
llvm
::
Value
*
osr_frame_info_arg
=
NULL
;
// the function entry block, where we add the type guards [no guards anymore]
llvm
::
BasicBlock
*
osr_entry_block
=
NULL
;
llvm
::
BasicBlock
*
osr_unbox_block_end
=
NULL
;
// the block after type guards where we up/down-convert things
...
...
@@ -438,17 +440,11 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
if
(
from_arg
->
getType
()
==
g
.
llvm_frame_info_type
->
getPointerTo
())
{
assert
(
p
.
first
.
s
()
==
FRAME_INFO_PTR_NAME
);
irstate
->
setFrameInfoArgument
(
from_arg
)
;
osr_frame_info_arg
=
from_arg
;
// Don't add the frame info to the symbol table since we will store it separately:
continue
;
}
if
(
p
.
first
.
s
()
==
PASSED_GLOBALS_NAME
)
{
assert
(
!
source
->
scoping
->
areGlobalsFromModule
());
irstate
->
setGlobals
(
from_arg
);
continue
;
}
ConcreteCompilerType
*
phi_type
;
phi_type
=
getTypeAtBlockStart
(
types
,
p
.
first
,
target_block
);
...
...
@@ -609,13 +605,13 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
assert
(
osr_entry_block
);
assert
(
phis
);
irstate
->
setupFrameInfoVarOSR
(
osr_frame_info_arg
);
for
(
const
auto
&
p
:
entry_descriptor
->
args
)
{
// Don't add the frame info to the symbol table since we will store it separately
// (we manually added it during the calculation of osr_syms):
if
(
p
.
first
.
s
()
==
FRAME_INFO_PTR_NAME
)
continue
;
if
(
p
.
first
.
s
()
==
PASSED_GLOBALS_NAME
)
continue
;
ConcreteCompilerType
*
analyzed_type
=
getTypeAtBlockStart
(
types
,
p
.
first
,
block
);
...
...
src/codegen/irgen/irgenerator.cpp
View file @
7e195c56
This diff is collapsed.
Click to expand it.
src/codegen/irgen/irgenerator.h
View file @
7e195c56
...
...
@@ -51,7 +51,6 @@ extern const std::string CREATED_CLOSURE_NAME;
extern
const
std
::
string
PASSED_CLOSURE_NAME
;
extern
const
std
::
string
PASSED_GENERATOR_NAME
;
extern
const
std
::
string
FRAME_INFO_PTR_NAME
;
extern
const
std
::
string
PASSED_GLOBALS_NAME
;
// Class that holds state of the current IR generation, that might not be local
...
...
@@ -73,9 +72,9 @@ private:
llvm
::
AllocaInst
*
scratch_space
;
llvm
::
Value
*
frame_info
;
llvm
::
Value
*
boxed_locals
;
llvm
::
Value
*
frame_info_arg
;
llvm
::
Value
*
globals
;
llvm
::
Value
*
vregs
;
llvm
::
Value
*
stmt
;
int
scratch_size
;
public:
...
...
@@ -94,10 +93,15 @@ public:
GCBuilder
*
getGC
()
{
return
gc
;
}
void
setupFrameInfoVar
(
llvm
::
Value
*
passed_closure
,
llvm
::
Value
*
passed_globals
,
llvm
::
Value
*
frame_info_arg
=
NULL
);
void
setupFrameInfoVarOSR
(
llvm
::
Value
*
frame_info_arg
)
{
return
setupFrameInfoVar
(
NULL
,
NULL
,
frame_info_arg
);
}
llvm
::
Value
*
getScratchSpace
(
int
min_bytes
);
llvm
::
Value
*
getFrameInfoVar
();
llvm
::
Value
*
getBoxedLocalsVar
();
llvm
::
Value
*
getVRegsVar
();
llvm
::
Value
*
getStmtVar
();
ConcreteCompilerType
*
getReturnType
()
{
return
cf
->
getReturnType
();
}
...
...
@@ -115,9 +119,6 @@ public:
ParamNames
*
getParamNames
()
{
return
param_names
;
}
void
setFrameInfoArgument
(
llvm
::
Value
*
v
)
{
frame_info_arg
=
v
;
}
void
setGlobals
(
llvm
::
Value
*
globals
);
// Returns the custom globals, or the module if the globals come from the module.
llvm
::
Value
*
getGlobals
();
// Returns the custom globals, or null if the globals come from the module.
...
...
src/codegen/opt/inliner.cpp
View file @
7e195c56
...
...
@@ -212,6 +212,9 @@ public:
RELEASE_ASSERT
(
arg
.
getType
()
==
call
->
getOperand
(
op_idx
)
->
getType
(),
""
);
}
if
(
f
->
getName
()
==
"allowGLReadPreemption"
)
continue
;
assert
(
!
f
->
isDeclaration
());
CS
.
setCalledFunction
(
f
);
calls
.
push_back
(
CS
);
...
...
src/codegen/patchpoints.cpp
View file @
7e195c56
...
...
@@ -80,16 +80,6 @@ void PatchpointInfo::parseLocationMap(StackMap::Record* r, LocationMap* map) {
// printf("parsing pp %ld:\n", reinterpret_cast<int64_t>(this));
StackMap
::
Record
::
Location
frame_info_location
=
r
->
locations
[
cur_arg
];
cur_arg
++
;
// We could allow the frame_info to exist in a different location for each callsite,
// but in reality it will always live at a fixed stack offset.
if
(
map
->
frameInfoFound
())
{
assert
(
frame_info_location
==
map
->
frame_info_location
);
}
else
{
map
->
frame_info_location
=
frame_info_location
;
}
for
(
FrameVarInfo
&
frame_var
:
frame_vars
)
{
int
num_args
=
frame_var
.
type
->
numFrameArgs
();
...
...
@@ -165,6 +155,16 @@ void processStackmap(CompiledFunction* cf, StackMap* stackmap) {
PatchpointInfo
*
pp
=
new_patchpoints
[
r
->
id
].
first
;
assert
(
pp
);
if
(
pp
->
isFrameInfoStackmap
())
{
assert
(
r
->
locations
.
size
()
==
pp
->
totalStackmapArgs
());
StackMap
::
Record
::
Location
frame_info_location
=
r
->
locations
[
0
];
assert
(
!
cf
->
location_map
->
frameInfoFound
());
assert
(
frame_info_location
.
type
==
StackMap
::
Record
::
Location
::
Direct
);
assert
(
frame_info_location
.
regnum
==
6
/* must be rbp based */
);
cf
->
location_map
->
frame_info_location
=
frame_info_location
;
continue
;
}
void
*
slowpath_func
=
PatchpointInfo
::
getSlowpathAddr
(
r
->
id
);
if
(
VERBOSITY
()
>=
2
)
{
printf
(
"Processing pp %ld; [%d, %d)
\n
"
,
reinterpret_cast
<
int64_t
>
(
pp
),
r
->
offset
,
...
...
src/codegen/patchpoints.h
View file @
7e195c56
...
...
@@ -106,6 +106,7 @@ private:
const
ICSetupInfo
*
icinfo
;
int
num_ic_stackmap_args
;
int
num_frame_stackmap_args
;
bool
is_frame_info_stackmap
;
std
::
vector
<
FrameVarInfo
>
frame_vars
;
unsigned
int
id
;
...
...
@@ -115,6 +116,7 @@ private:
icinfo
(
icinfo
),
num_ic_stackmap_args
(
num_ic_stackmap_args
),
num_frame_stackmap_args
(
-
1
),
is_frame_info_stackmap
(
false
),
id
(
0
)
{}
...
...
@@ -129,6 +131,7 @@ public:
int
scratchStackmapArg
()
{
return
0
;
}
int
scratchSize
()
{
return
80
+
MAX_FRAME_SPILLS
*
sizeof
(
void
*
);
}
bool
isDeopt
()
const
{
return
icinfo
?
icinfo
->
isDeopt
()
:
false
;
}
bool
isFrameInfoStackmap
()
const
{
return
is_frame_info_stackmap
;
}
int
numFrameSpillsSupported
()
const
{
return
isDeopt
()
?
MAX_FRAME_SPILLS
:
0
;
}
void
addFrameVar
(
llvm
::
StringRef
name
,
CompilerType
*
type
);
...
...
@@ -136,8 +139,9 @@ public:
assert
(
num_frame_stackmap_args
==
-
1
);
num_frame_stackmap_args
=
num_frame_args
;
}
void
setIsFrameInfoStackmap
(
bool
b
=
true
)
{
is_frame_info_stackmap
=
b
;
}
int
icStackmapArgsStart
()
{
return
1
;
}
int
icStackmapArgsStart
()
{
return
isFrameInfoStackmap
()
?
0
:
1
;
}
int
numICStackmapArgs
()
{
return
num_ic_stackmap_args
;
}
int
frameStackmapArgsStart
()
{
return
icStackmapArgsStart
()
+
numICStackmapArgs
();
}
...
...
src/codegen/unwinding.cpp
View file @
7e195c56
...
...
@@ -342,7 +342,6 @@ public:
assert
(
cf
->
location_map
);
const
LocationMap
::
LocationTable
&
table
=
cf
->
location_map
->
names
[
name
];
assert
(
table
.
locations
.
size
());
auto
entry
=
table
.
findEntry
(
offset
);
if
(
!
entry
)
...
...
@@ -354,27 +353,17 @@ public:
AST_stmt
*
getCurrentStatement
()
{
if
(
id
.
type
==
PythonFrameId
::
COMPILED
)
{
auto
locations
=
findLocations
(
"!current_stmt"
);
RELEASE_ASSERT
(
locations
.
size
()
==
1
,
"%ld"
,
locations
.
size
());
return
reinterpret_cast
<
AST_stmt
*>
(
readLocation
(
locations
[
0
]));
}
else
if
(
id
.
type
==
PythonFrameId
::
INTERPRETED
)
{
return
getCurrentStatementForInterpretedFrame
((
void
*
)
id
.
bp
);
if
(
locations
.
size
()
==
1
)
return
reinterpret_cast
<
AST_stmt
*>
(
readLocation
(
locations
[
0
]));
}
abort
();
assert
(
getFrameInfo
()
->
stmt
);
return
getFrameInfo
()
->
stmt
;
}
Box
*
getGlobals
()
{
if
(
id
.
type
==
PythonFrameId
::
COMPILED
)
{
CompiledFunction
*
cf
=
getCF
();
if
(
cf
->
md
->
source
->
scoping
->
areGlobalsFromModule
())
return
cf
->
md
->
source
->
parent_module
;
auto
locations
=
findLocations
(
PASSED_GLOBALS_NAME
);
assert
(
locations
.
size
()
==
1
);
Box
*
r
=
(
Box
*
)
readLocation
(
locations
[
0
]);
return
incref
(
r
);
}
else
if
(
id
.
type
==
PythonFrameId
::
INTERPRETED
)
{
return
getGlobalsForInterpretedFrame
((
void
*
)
id
.
bp
);
}
abort
();
assert
(
0
&&
"check refcounting (of callers)"
);
Box
*
r
=
getFrameInfo
()
->
globals
;
return
incref
(
r
);
}
Box
*
getGlobalsDict
()
{
...
...
@@ -394,8 +383,7 @@ public:
CompiledFunction
*
cf
=
getCF
();
assert
(
cf
->
location_map
->
frameInfoFound
());
const
auto
&
frame_info_loc
=
cf
->
location_map
->
frame_info_location
;
return
reinterpret_cast
<
FrameInfo
*>
(
readLocation
(
frame_info_loc
));
return
*
reinterpret_cast
<
FrameInfo
**>
(
readLocation
(
frame_info_loc
));
}
else
if
(
id
.
type
==
PythonFrameId
::
INTERPRETED
)
{
return
getFrameInfoForInterpretedFrame
((
void
*
)
id
.
bp
);
}
...
...
src/core/options.cpp
View file @
7e195c56
...
...
@@ -39,7 +39,7 @@ bool ENABLE_INTERPRETER = false; // XXX
bool
ENABLE_BASELINEJIT
=
false
;
// XXX
bool
ENABLE_PYPA_PARSER
=
true
;
bool
ENABLE_CPYTHON_PARSER
=
false
;
bool
USE_REGALLOC_BASIC
=
tru
e
;
bool
USE_REGALLOC_BASIC
=
fals
e
;
bool
PAUSE_AT_ABORT
=
false
;
bool
ENABLE_TRACEBACKS
=
true
;
// Forces the llvm jit to use capi exceptions whenever it can, as opposed to whenever it thinks
...
...
@@ -83,7 +83,6 @@ bool ENABLE_JIT_OBJECT_CACHE = 1 && _GLOBAL_ENABLE;
bool
LAZY_SCOPING_ANALYSIS
=
1
;
bool
ENABLE_FRAME_INTROSPECTION
=
1
;
bool
BOOLS_AS_I64
=
ENABLE_FRAME_INTROSPECTION
;
extern
"C"
{
int
Py_FrozenFlag
=
1
;
...
...
src/core/options.h
View file @
7e195c56
...
...
@@ -48,7 +48,7 @@ extern bool ENABLE_ICS, ENABLE_ICGENERICS, ENABLE_ICGETITEMS, ENABLE_ICSETITEMS,
LAZY_SCOPING_ANALYSIS
;
// Due to a temporary LLVM limitation, represent bools as i64's instead of i1's.
extern
bool
BOOLS_AS_I64
;
#define BOOLS_AS_I64 1
#define ENABLE_SAMPLING_PROFILER 0
}
...
...
src/core/types.h
View file @
7e195c56
...
...
@@ -525,7 +525,11 @@ CompiledFunction* compileFunction(FunctionMetadata* f, FunctionSpecialization* s
ExceptionStyle
forced_exception_style
=
CXX
);
EffortLevel
initialEffort
();
typedef
bool
i1
;
#if BOOLS_AS_I64
typedef
int64_t
llvm_compat_bool
;
#else
typedef
bool
llvm_compat_bool
;
#endif
typedef
int64_t
i64
;
const
char
*
getNameOfClass
(
BoxedClass
*
cls
);
...
...
@@ -940,8 +944,14 @@ struct FrameInfo {
BoxedClosure
*
passed_closure
;
Box
**
vregs
;
FrameInfo
(
ExcInfo
exc
)
:
exc
(
exc
),
boxedLocals
(
NULL
),
frame_obj
(
0
),
passed_closure
(
0
),
vregs
(
0
)
{}
// Current statement
// Caution the llvm tier only updates this information on direct external calls but not for patchpoints.
// This means if a patchpoint "current_stmt" info is available it must be used instead of this field.
AST_stmt
*
stmt
;
// This is either a module or a dict
Box
*
globals
;
FrameInfo
(
ExcInfo
exc
)
:
exc
(
exc
),
boxedLocals
(
NULL
),
frame_obj
(
0
),
passed_closure
(
0
),
vregs
(
0
),
stmt
(
0
),
globals
(
0
)
{}
};
// callattr() takes a number of flags and arguments, and for performance we pack them into a single register:
...
...
src/runtime/dict.h
View file @
7e195c56
...
...
@@ -58,7 +58,7 @@ Box* dictIterValues(Box* self);
Box
*
dictIterItems
(
Box
*
self
);
Box
*
dictIterIter
(
Box
*
self
);
Box
*
dictIterHasnext
(
Box
*
self
);
i1
dictIterHasnextUnboxed
(
Box
*
self
);
llvm_compat_bool
dictIterHasnextUnboxed
(
Box
*
self
);
Box
*
dictiter_next
(
Box
*
self
)
noexcept
;
Box
*
dictIterNext
(
Box
*
self
);
...
...
src/runtime/generator.cpp
View file @
7e195c56
...
...
@@ -289,7 +289,7 @@ template <ExceptionStyle S> static Box* generatorNext(Box* s) noexcept(S == CAPI
return
generatorSend
<
S
>
(
s
,
None
);
}
i1
generatorHasnextUnboxed
(
Box
*
s
)
{
llvm_compat_bool
generatorHasnextUnboxed
(
Box
*
s
)
{
assert
(
s
->
cls
==
generator_cls
);
BoxedGenerator
*
self
=
static_cast
<
BoxedGenerator
*>
(
s
);
...
...
src/runtime/inline/boxing.cpp
View file @
7e195c56
...
...
@@ -47,5 +47,9 @@ i64 unboxInt(Box* b) {
return
((
BoxedInt
*
)
b
)
->
n
;
}
extern
"C"
bool
hasnext
(
Box
*
o
)
{
return
o
->
cls
->
tpp_hasnext
(
o
);
}
// BoxedInt::BoxedInt(int64_t n) : Box(int_cls), n(n) {}
}
src/runtime/inline/dict.cpp
View file @
7e195c56
...
...
@@ -49,7 +49,7 @@ Box* dictIterIter(Box* s) {
return
s
;
}
i1
dictIterHasnextUnboxed
(
Box
*
s
)
{
llvm_compat_bool
dictIterHasnextUnboxed
(
Box
*
s
)
{
assert
(
s
->
cls
==
dict_iterator_cls
);
BoxedDictIterator
*
self
=
static_cast
<
BoxedDictIterator
*>
(
s
);
...
...
src/runtime/inline/list.cpp
View file @
7e195c56
...
...
@@ -52,7 +52,7 @@ Box* listiterHasnext(Box* s) {
return
boxBool
(
ans
);
}
i1
listiterHasnextUnboxed
(
Box
*
s
)
{
llvm_compat_bool
listiterHasnextUnboxed
(
Box
*
s
)
{
assert
(
s
->
cls
==
list_iterator_cls
);
BoxedListIterator
*
self
=
static_cast
<
BoxedListIterator
*>
(
s
);
...
...
@@ -86,22 +86,6 @@ Box* listiter_next(Box* s) noexcept {
return
incref
(
rtn
);
}
template
<
ExceptionStyle
S
>
Box
*
listiterNext
(
Box
*
s
)
noexcept
(
S
==
CAPI
)
{
Box
*
rtn
=
listiter_next
(
s
);
if
(
!
rtn
)
{
if
(
S
==
CAPI
)
{
PyErr_SetObject
(
StopIteration
,
None
);
return
NULL
;
}
else
raiseExcHelper
(
StopIteration
,
""
);
}
return
rtn
;
}
// force instantiation:
template
Box
*
listiterNext
<
CAPI
>(
Box
*
);
template
Box
*
listiterNext
<
CXX
>(
Box
*
);
Box
*
listReversed
(
Box
*
s
)
{
assert
(
PyList_Check
(
s
));
BoxedList
*
self
=
static_cast
<
BoxedList
*>
(
s
);
...
...
@@ -115,7 +99,7 @@ Box* listreviterHasnext(Box* s) {
return
boxBool
(
self
->
pos
>=
0
);
}
i1
listreviterHasnextUnboxed
(
Box
*
s
)
{
llvm_compat_bool
listreviterHasnextUnboxed
(
Box
*
s
)
{
assert
(
s
->
cls
==
list_reverse_iterator_cls
);
BoxedListIterator
*
self
=
static_cast
<
BoxedListIterator
*>
(
s
);
...
...
src/runtime/inline/tuple.cpp
View file @
7e195c56
...
...
@@ -37,7 +37,7 @@ Box* tupleiterHasnext(Box* s) {
return
boxBool
(
tupleiterHasnextUnboxed
(
s
));
}
i1
tupleiterHasnextUnboxed
(
Box
*
s
)
{
llvm_compat_bool
tupleiterHasnextUnboxed
(
Box
*
s
)
{
assert
(
s
->
cls
==
tuple_iterator_cls
);
BoxedTupleIterator
*
self
=
static_cast
<
BoxedTupleIterator
*>
(
s
);
...
...
src/runtime/inline/xrange.cpp
View file @
7e195c56
...
...
@@ -89,7 +89,7 @@ public:
DEFAULT_CLASS
(
xrange_iterator_cls
);
static
bool
xrangeIteratorHasnextUnboxed
(
Box
*
s
)
__attribute__
((
visibility
(
"default"
)))
{
static
llvm_compat_
bool
xrangeIteratorHasnextUnboxed
(
Box
*
s
)
__attribute__
((
visibility
(
"default"
)))
{
assert
(
s
->
cls
==
xrange_iterator_cls
);
BoxedXrangeIterator
*
self
=
static_cast
<
BoxedXrangeIterator
*>
(
s
);
...
...
src/runtime/int.cpp
View file @
7e195c56
...
...
@@ -465,31 +465,6 @@ extern "C" Box* mul_i64_i64(i64 lhs, i64 rhs) {
return
longMul
(
autoDecref
(
boxLong
(
lhs
)),
autoDecref
(
boxLong
(
rhs
)));
}
extern
"C"
i1
eq_i64_i64
(
i64
lhs
,
i64
rhs
)
{
return
lhs
==
rhs
;
}
extern
"C"
i1
ne_i64_i64
(
i64
lhs
,
i64
rhs
)
{
return
lhs
!=
rhs
;
}
extern
"C"
i1
lt_i64_i64
(
i64
lhs
,
i64
rhs
)
{
return
lhs
<
rhs
;
}
extern
"C"
i1
le_i64_i64
(
i64
lhs
,
i64
rhs
)
{
return
lhs
<=
rhs
;
}
extern
"C"
i1
gt_i64_i64
(
i64
lhs
,
i64
rhs
)
{
return
lhs
>
rhs
;
}
extern
"C"
i1
ge_i64_i64
(
i64
lhs
,
i64
rhs
)
{
return
lhs
>=
rhs
;
}
extern
"C"
Box
*
intAddInt
(
BoxedInt
*
lhs
,
BoxedInt
*
rhs
)
{
assert
(
PyInt_Check
(
lhs
));
assert
(
PyInt_Check
(
rhs
));
...
...
src/runtime/int.h
View file @
7e195c56
...
...
@@ -34,12 +34,6 @@ extern "C" Box* add_i64_i64(i64 lhs, i64 rhs);
extern
"C"
Box
*
sub_i64_i64
(
i64
lhs
,
i64
rhs
);
extern
"C"
Box
*
pow_i64_i64
(
i64
lhs
,
i64
rhs
,
Box
*
mod
=
None
);
extern
"C"
Box
*
mul_i64_i64
(
i64
lhs
,
i64
rhs
);
extern
"C"
i1
eq_i64_i64
(
i64
lhs
,
i64
rhs
);
extern
"C"
i1
ne_i64_i64
(
i64
lhs
,
i64
rhs
);
extern
"C"
i1
lt_i64_i64
(
i64
lhs
,
i64
rhs
);
extern
"C"
i1
le_i64_i64
(
i64
lhs
,
i64
rhs
);
extern
"C"
i1
gt_i64_i64
(
i64
lhs
,
i64
rhs
);
extern
"C"
i1
ge_i64_i64
(
i64
lhs
,
i64
rhs
);
extern
"C"
Box
*
intAdd
(
BoxedInt
*
lhs
,
Box
*
rhs
);
extern
"C"
Box
*
intAnd
(
BoxedInt
*
lhs
,
Box
*
rhs
);
extern
"C"
Box
*
intDiv
(
BoxedInt
*
lhs
,
Box
*
rhs
);
...
...
src/runtime/iterobject.cpp
View file @
7e195c56
...
...
@@ -70,7 +70,7 @@ Box* seqiterHasnext(Box* s) {
return
rtn
;
}
bool
seqiterHasnextUnboxed
(
Box
*
s
)
{
llvm_compat_
bool
seqiterHasnextUnboxed
(
Box
*
s
)
{
return
unboxBool
(
seqiterHasnext
(
s
));
}
...
...
@@ -131,7 +131,7 @@ Box* seqiterNext(Box* s) {
return
rtn
;
}
bool
iterwrapperHasnextUnboxed
(
Box
*
s
)
{
llvm_compat_
bool
iterwrapperHasnextUnboxed
(
Box
*
s
)
{
RELEASE_ASSERT
(
s
->
cls
==
iterwrapper_cls
,
""
);
BoxedIterWrapper
*
self
=
static_cast
<
BoxedIterWrapper
*>
(
s
);
...
...
@@ -176,7 +176,7 @@ extern "C" PyObject* PySeqIter_New(PyObject* seq) noexcept {
}
}
bool
calliter_hasnext
(
Box
*
b
)
{
llvm_compat_bool
calliterHasnextUnboxed
(
Box
*
b
)
{
calliterobject
*
it
=
(
calliterobject
*
)
b
;
if
(
!
it
->
it_nextvalue
)
{
it
->
it_nextvalue
=
calliter_next
(
it
);
...
...
src/runtime/iterobject.h
View file @
7e195c56
...
...
@@ -77,7 +77,7 @@ public:
}
};
bool
calliter_hasnext
(
Box
*
b
);
llvm_compat_bool
calliterHasnextUnboxed
(
Box
*
b
);
void
setupIter
();
}
...
...
src/runtime/list.cpp
View file @
7e195c56
...
...
@@ -1315,6 +1315,22 @@ void BoxedList::dealloc(Box* b) noexcept {
Py_TRASHCAN_SAFE_END
(
op
)
}
template
<
ExceptionStyle
S
>
Box
*
listiterNext
(
Box
*
s
)
noexcept
(
S
==
CAPI
)
{
Box
*
rtn
=
listiter_next
(
s
);
if
(
!
rtn
)
{
if
(
S
==
CAPI
)
{
PyErr_SetObject
(
StopIteration
,
None
);
return
NULL
;
}
else
raiseExcHelper
(
StopIteration
,
(
const
char
*
)
NULL
);
}
return
rtn
;
}
// force instantiation:
template
Box
*
listiterNext
<
CAPI
>(
Box
*
)
noexcept
;
template
Box
*
listiterNext
<
CXX
>(
Box
*
);
int
BoxedList
::
traverse
(
Box
*
_o
,
visitproc
visit
,
void
*
arg
)
noexcept
{
PyListObject
*
o
=
(
PyListObject
*
)
_o
;
Py_ssize_t
i
;
...
...
src/runtime/list.h
View file @
7e195c56
...
...
@@ -45,12 +45,12 @@ public:
Box
*
listIter
(
Box
*
self
)
noexcept
;
Box
*
listIterIter
(
Box
*
self
);
Box
*
listiterHasnext
(
Box
*
self
);
i1
listiterHasnextUnboxed
(
Box
*
self
);
llvm_compat_bool
listiterHasnextUnboxed
(
Box
*
self
);
template
<
ExceptionStyle
S
>
Box
*
listiterNext
(
Box
*
self
)
noexcept
(
S
==
CAPI
);
Box
*
listiter_next
(
Box
*
s
)
noexcept
;
Box
*
listReversed
(
Box
*
self
);
Box
*
listreviterHasnext
(
Box
*
self
);
i1
listreviterHasnextUnboxed
(
Box
*
self
);
llvm_compat_bool
listreviterHasnextUnboxed
(
Box
*
self
);
Box
*
listreviterNext
(
Box
*
self
);
Box
*
listreviter_next
(
Box
*
s
)
noexcept
;
void
listSort
(
BoxedList
*
self
,
Box
*
cmp
,
Box
*
key
,
Box
*
reverse
);
...
...
src/runtime/str.cpp
View file @
7e195c56
...
...
@@ -2378,7 +2378,7 @@ public:
DEFAULT_CLASS
(
str_iterator_cls
);
static
bool
hasnextUnboxed
(
BoxedStringIterator
*
self
)
{
static
llvm_compat_
bool
hasnextUnboxed
(
BoxedStringIterator
*
self
)
{
assert
(
self
->
cls
==
str_iterator_cls
);
return
self
->
it
!=
self
->
end
;
}
...
...
src/runtime/tuple.h
View file @
7e195c56
...
...
@@ -44,7 +44,7 @@ public:
Box
*
tupleIter
(
Box
*
self
)
noexcept
;
Box
*
tupleIterIter
(
Box
*
self
);
Box
*
tupleiterHasnext
(
Box
*
self
);
i1
tupleiterHasnextUnboxed
(
Box
*
self
);
llvm_compat_bool
tupleiterHasnextUnboxed
(
Box
*
self
);
Box
*
tupleiter_next
(
Box
*
self
)
noexcept
;
Box
*
tupleiterNext
(
Box
*
self
);
}
...
...
src/runtime/types.cpp
View file @
7e195c56
...
...
@@ -4220,7 +4220,7 @@ void setupRuntime() {
PyType_Ready
(
&
PyByteArrayIter_Type
);
PyType_Ready
(
&
PyCapsule_Type
);
PyCallIter_Type
.
tpp_hasnext
=
calliter
_hasnext
;
PyCallIter_Type
.
tpp_hasnext
=
calliter
HasnextUnboxed
;
PyType_Ready
(
&
PyCallIter_Type
);
PyType_Ready
(
&
PyCObject_Type
);
...
...
src/runtime/types.h
View file @
7e195c56
...
...
@@ -244,7 +244,7 @@ public:
bool
has_subclasscheck
;
bool
has_getattribute
;
typedef
bool
(
*
pyston_inquiry
)(
Box
*
);
typedef
llvm_compat_
bool
(
*
pyston_inquiry
)(
Box
*
);
// tpp_descr_get is currently just a cache only for the use of tp_descr_get, and shouldn't
// be called or examined by clients:
...
...
src/runtime/util.cpp
View file @
7e195c56
...
...
@@ -118,10 +118,6 @@ Box* boxStringFromCharPtr(const char* s) {
return
boxString
(
s
);
}
extern
"C"
bool
hasnext
(
Box
*
o
)
{
return
o
->
cls
->
tpp_hasnext
(
o
);
}
extern
"C"
void
_PyObject_Dump
(
Box
*
b
)
noexcept
{
dump
(
b
);
}
...
...
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