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
daa0ffd5
Commit
daa0ffd5
authored
Aug 08, 2016
by
Marius Wachtler
Committed by
GitHub
Aug 08, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1321 from undingen/more_unique_ptr
use more often std::unique_ptr
parents
81c744b5
9536f7f8
Changes
15
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
131 additions
and
152 deletions
+131
-152
src/asm_writing/icinfo.cpp
src/asm_writing/icinfo.cpp
+4
-9
src/asm_writing/icinfo.h
src/asm_writing/icinfo.h
+0
-1
src/codegen/compvars.cpp
src/codegen/compvars.cpp
+31
-30
src/codegen/irgen.cpp
src/codegen/irgen.cpp
+0
-1
src/codegen/irgen.h
src/codegen/irgen.h
+4
-3
src/codegen/irgen/hooks.cpp
src/codegen/irgen/hooks.cpp
+2
-3
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+26
-23
src/codegen/irgen/util.cpp
src/codegen/irgen/util.cpp
+0
-8
src/codegen/patchpoints.cpp
src/codegen/patchpoints.cpp
+32
-38
src/codegen/patchpoints.h
src/codegen/patchpoints.h
+22
-21
src/codegen/stackmaps.cpp
src/codegen/stackmaps.cpp
+2
-2
src/codegen/stackmaps.h
src/codegen/stackmaps.h
+1
-1
src/codegen/type_recording.cpp
src/codegen/type_recording.cpp
+5
-6
src/core/types.h
src/core/types.h
+2
-5
src/runtime/ics.cpp
src/runtime/ics.cpp
+0
-1
No files found.
src/asm_writing/icinfo.cpp
View file @
daa0ffd5
...
...
@@ -348,6 +348,10 @@ ICInfo::ICInfo(void* start_addr, void* slowpath_rtn_addr, void* continue_addr, S
}
ICInfo
::~
ICInfo
()
{
// if this ICInfo got created with registerCompiledPatchpoint we have to unregister this
ics_by_return_addr
.
erase
(
slowpath_rtn_addr
);
deregisterGCTrackedICInfo
(
this
);
for
(
auto
&
slot
:
slots
)
{
for
(
auto
invalidator
:
slot
.
invalidators
)
{
assert
(
invalidator
->
dependents
.
count
(
&
slot
));
...
...
@@ -409,15 +413,6 @@ std::unique_ptr<ICInfo> registerCompiledPatchpoint(uint8_t* start_addr, uint8_t*
return
std
::
unique_ptr
<
ICInfo
>
(
icinfo
);
}
void
deregisterCompiledPatchpoint
(
ICInfo
*
ic
)
{
ic
->
clearAll
();
assert
(
ics_by_return_addr
[
ic
->
slowpath_rtn_addr
]
==
ic
);
ics_by_return_addr
.
erase
(
ic
->
slowpath_rtn_addr
);
deregisterGCTrackedICInfo
(
ic
);
}
ICInfo
*
getICInfo
(
void
*
rtn_addr
)
{
// TODO: load this from the CF instead of tracking it separately
auto
&&
it
=
ics_by_return_addr
.
find
(
rtn_addr
);
...
...
src/asm_writing/icinfo.h
View file @
daa0ffd5
...
...
@@ -204,7 +204,6 @@ std::unique_ptr<ICInfo>
registerCompiledPatchpoint
(
uint8_t
*
start_addr
,
uint8_t
*
slowpath_start_addr
,
uint8_t
*
continue_addr
,
uint8_t
*
slowpath_rtn_addr
,
const
ICSetupInfo
*
,
StackInfo
stack_info
,
LiveOutSet
live_outs
,
std
::
vector
<
Location
>
ic_global_decref_locations
=
std
::
vector
<
Location
>
());
void
deregisterCompiledPatchpoint
(
ICInfo
*
ic
);
ICInfo
*
getICInfo
(
void
*
rtn_addr
);
...
...
src/codegen/compvars.cpp
View file @
daa0ffd5
This diff is collapsed.
Click to expand it.
src/codegen/irgen.cpp
View file @
daa0ffd5
...
...
@@ -1088,7 +1088,6 @@ std::pair<CompiledFunction*, llvm::Function*> doCompile(FunctionMetadata* md, So
}
CompiledFunction
*
cf
=
new
CompiledFunction
(
md
,
spec
,
NULL
,
effort
,
exception_style
,
entry_descriptor
);
setPointersInCodeStorage
(
&
cf
->
pointers_in_code
);
// Make sure that the instruction memory keeps the module object alive.
// TODO: implement this for real
...
...
src/codegen/irgen.h
View file @
daa0ffd5
...
...
@@ -111,9 +111,10 @@ public:
llvm
::
Value
*
arg2
,
llvm
::
Value
*
arg3
,
ExceptionStyle
target_exception_style
=
CXX
,
llvm
::
Value
*
capi_exc_value
=
NULL
)
=
0
;
virtual
llvm
::
Instruction
*
createIC
(
const
ICSetupInfo
*
pp
,
void
*
func_addr
,
const
std
::
vector
<
llvm
::
Value
*>&
args
,
const
UnwindInfo
&
unw_info
,
ExceptionStyle
target_exception_style
=
CXX
,
llvm
::
Value
*
capi_exc_value
=
NULL
)
=
0
;
virtual
llvm
::
Instruction
*
createIC
(
std
::
unique_ptr
<
const
ICSetupInfo
>
pp
,
void
*
func_addr
,
const
std
::
vector
<
llvm
::
Value
*>&
args
,
const
UnwindInfo
&
unw_info
,
ExceptionStyle
target_exception_style
=
CXX
,
llvm
::
Value
*
capi_exc_value
=
NULL
)
=
0
;
// virtual void checkAndPropagateCapiException(const UnwindInfo& unw_info, llvm::Value* returned_val,
// llvm::Value* exc_val, bool double_check = false) = 0;
...
...
src/codegen/irgen/hooks.cpp
View file @
daa0ffd5
...
...
@@ -199,9 +199,8 @@ static void compileIR(CompiledFunction* cf, llvm::Function* func, EffortLevel ef
printf
(
"Compiled function to %p
\n
"
,
cf
->
code
);
}
StackMap
*
stackmap
=
parseStackMap
();
processStackmap
(
cf
,
stackmap
);
delete
stackmap
;
std
::
unique_ptr
<
StackMap
>
stackmap
=
parseStackMap
();
processStackmap
(
cf
,
stackmap
.
get
());
}
// Compiles a new version of the function with the given signature and adds it to the list;
...
...
src/codegen/irgen/irgenerator.cpp
View file @
daa0ffd5
...
...
@@ -539,7 +539,7 @@ private:
}
}
llvm
::
CallSite
emitPatchpoint
(
llvm
::
Type
*
return_type
,
const
ICSetupInfo
*
pp
,
llvm
::
Value
*
func
,
llvm
::
CallSite
emitPatchpoint
(
llvm
::
Type
*
return_type
,
std
::
unique_ptr
<
const
ICSetupInfo
>
pp
,
llvm
::
Value
*
func
,
const
std
::
vector
<
llvm
::
Value
*>&
args
,
const
std
::
vector
<
llvm
::
Value
*>&
ic_stackmap_args
,
const
UnwindInfo
&
unw_info
,
ExceptionStyle
target_exception_style
,
llvm
::
Value
*
capi_exc_value
)
{
...
...
@@ -563,10 +563,13 @@ private:
}
assert
(
func_addr
);
PatchpointInfo
*
info
=
PatchpointInfo
::
create
(
currentFunction
(),
pp
,
ic_stackmap_args
.
size
(),
func_addr
);
int
pp_size
=
pp
?
pp
->
totalSize
()
:
CALL_ONLY_SIZE
;
auto
calling_convention
=
pp
?
pp
->
getCallingConvention
()
:
(
llvm
::
CallingConv
::
ID
)
llvm
::
CallingConv
::
C
;
PatchpointInfo
*
info
=
PatchpointInfo
::
create
(
currentFunction
(),
std
::
move
(
pp
),
ic_stackmap_args
.
size
(),
func_addr
);
int64_t
pp_id
=
info
->
getId
();
int
pp_size
=
pp
?
pp
->
totalSize
()
:
CALL_ONLY_SIZE
;
std
::
vector
<
llvm
::
Value
*>
pp_args
;
pp_args
.
push_back
(
getConstantInt
(
pp_id
,
g
.
i64
));
...
...
@@ -604,6 +607,7 @@ private:
}
llvm
::
Function
*
patchpoint
=
this
->
getIntrinsic
(
intrinsic_id
);
llvm
::
CallSite
rtn
=
this
->
emitCall
(
unw_info
,
patchpoint
,
pp_args
,
target_exception_style
,
capi_exc_value
);
rtn
.
setCallingConv
(
calling_convention
);
return
rtn
;
}
...
...
@@ -700,23 +704,21 @@ public:
return
createCall
(
unw_info
,
callee
,
{
arg1
,
arg2
,
arg3
},
target_exception_style
,
capi_exc_value
);
}
llvm
::
Instruction
*
createIC
(
const
ICSetupInfo
*
pp
,
void
*
func_addr
,
const
std
::
vector
<
llvm
::
Value
*>&
args
,
const
UnwindInfo
&
unw_info
,
ExceptionStyle
target_exception_style
=
CXX
,
llvm
::
Instruction
*
createIC
(
std
::
unique_ptr
<
const
ICSetupInfo
>
pp
,
void
*
func_addr
,
const
std
::
vector
<
llvm
::
Value
*>&
args
,
const
UnwindInfo
&
unw_info
,
ExceptionStyle
target_exception_style
=
CXX
,
llvm
::
Value
*
capi_exc_value
=
NULL
)
override
{
std
::
vector
<
llvm
::
Value
*>
stackmap_args
;
llvm
::
CallSite
rtn
=
emitPatchpoint
(
pp
->
hasReturnValue
()
?
g
.
i64
:
g
.
void_
,
pp
,
embedConstantPtr
(
func_addr
,
g
.
i8
->
getPointerTo
()),
args
,
stackmap_args
,
unw_info
,
target_exception_style
,
capi_exc_value
);
rtn
.
setCallingConv
(
pp
->
getCallingConvention
());
auto
return_type
=
pp
->
hasReturnValue
()
?
g
.
i64
:
g
.
void_
;
llvm
::
CallSite
rtn
=
emitPatchpoint
(
return_type
,
std
::
move
(
pp
),
embedConstantPtr
(
func_addr
,
g
.
i8
->
getPointerTo
()),
args
,
stackmap_args
,
unw_info
,
target_exception_style
,
capi_exc_value
);
return
rtn
.
getInstruction
();
}
llvm
::
Value
*
createDeopt
(
AST_stmt
*
current_stmt
,
AST_expr
*
node
,
llvm
::
Value
*
node_value
)
override
{
ICSetupInfo
*
pp
=
createDeoptIC
();
llvm
::
Instruction
*
v
=
createIC
(
pp
,
(
void
*
)
pyston
::
deopt
,
{
embedRelocatablePtr
(
node
,
g
.
llvm_astexpr_type_ptr
),
node_value
},
llvm
::
Instruction
*
v
=
createIC
(
createDeoptIC
(),
(
void
*
)
pyston
::
deopt
,
{
embedRelocatablePtr
(
node
,
g
.
llvm_astexpr_type_ptr
),
node_value
},
UnwindInfo
(
current_stmt
,
NULL
,
/* is_after_deopt*/
true
));
llvm
::
Value
*
rtn
=
createAfter
<
llvm
::
IntToPtrInst
>
(
v
,
v
,
g
.
llvm_value_type_ptr
,
""
);
setType
(
rtn
,
RefType
::
OWNED
);
...
...
@@ -1330,14 +1332,15 @@ private:
bool
do_patchpoint
=
ENABLE_ICGETGLOBALS
;
if
(
do_patchpoint
)
{
ICSetupInfo
*
pp
=
createGetGlobalIC
(
getOpInfoForNode
(
node
,
unw_info
).
getTypeRecorder
());
auto
pp
=
createGetGlobalIC
(
getOpInfoForNode
(
node
,
unw_info
).
getTypeRecorder
());
std
::
vector
<
llvm
::
Value
*>
llvm_args
;
llvm_args
.
push_back
(
irstate
->
getGlobals
());
llvm_args
.
push_back
(
emitter
.
setType
(
embedRelocatablePtr
(
node
->
id
.
getBox
(),
g
.
llvm_boxedstring_type_ptr
),
RefType
::
BORROWED
));
llvm
::
Instruction
*
uncasted
=
emitter
.
createIC
(
pp
,
(
void
*
)
pyston
::
getGlobal
,
llvm_args
,
unw_info
);
llvm
::
Instruction
*
uncasted
=
emitter
.
createIC
(
std
::
move
(
pp
),
(
void
*
)
pyston
::
getGlobal
,
llvm_args
,
unw_info
);
llvm
::
Value
*
r
=
createAfter
<
llvm
::
IntToPtrInst
>
(
uncasted
,
uncasted
,
g
.
llvm_value_type_ptr
,
""
);
emitter
.
setType
(
r
,
RefType
::
OWNED
);
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
r
);
...
...
@@ -2025,7 +2028,7 @@ private:
bool
do_patchpoint
=
ENABLE_ICSETITEMS
;
if
(
do_patchpoint
)
{
ICSetupInfo
*
pp
=
createSetitemIC
(
getEmptyOpInfo
(
unw_info
).
getTypeRecorder
());
auto
pp
=
createSetitemIC
(
getEmptyOpInfo
(
unw_info
).
getTypeRecorder
());
std
::
vector
<
llvm
::
Value
*>
llvm_args
;
llvm_args
.
push_back
(
target
);
...
...
@@ -2033,7 +2036,7 @@ private:
llvm_args
.
push_back
(
cstop
);
llvm_args
.
push_back
(
value
);
emitter
.
createIC
(
pp
,
(
void
*
)
pyston
::
assignSlice
,
llvm_args
,
unw_info
);
emitter
.
createIC
(
std
::
move
(
pp
)
,
(
void
*
)
pyston
::
assignSlice
,
llvm_args
,
unw_info
);
}
else
{
emitter
.
createCall
(
unw_info
,
g
.
funcs
.
assignSlice
,
{
target
,
cstart
,
cstop
,
value
});
}
...
...
@@ -2056,14 +2059,14 @@ private:
// patchpoints if it couldn't.
bool
do_patchpoint
=
ENABLE_ICSETITEMS
;
if
(
do_patchpoint
)
{
ICSetupInfo
*
pp
=
createSetitemIC
(
getEmptyOpInfo
(
unw_info
).
getTypeRecorder
());
auto
pp
=
createSetitemIC
(
getEmptyOpInfo
(
unw_info
).
getTypeRecorder
());
std
::
vector
<
llvm
::
Value
*>
llvm_args
;
llvm_args
.
push_back
(
converted_target
->
getValue
());
llvm_args
.
push_back
(
converted_slice
->
getValue
());
llvm_args
.
push_back
(
converted_val
->
getValue
());
emitter
.
createIC
(
pp
,
(
void
*
)
pyston
::
setitem
,
llvm_args
,
unw_info
);
emitter
.
createIC
(
std
::
move
(
pp
)
,
(
void
*
)
pyston
::
setitem
,
llvm_args
,
unw_info
);
}
else
{
emitter
.
createCall3
(
unw_info
,
g
.
funcs
.
setitem
,
converted_target
->
getValue
(),
converted_slice
->
getValue
(),
converted_val
->
getValue
());
...
...
@@ -2186,13 +2189,13 @@ private:
bool
do_patchpoint
=
ENABLE_ICDELITEMS
;
if
(
do_patchpoint
)
{
ICSetupInfo
*
pp
=
createDelitemIC
(
getEmptyOpInfo
(
unw_info
).
getTypeRecorder
());
auto
pp
=
createDelitemIC
(
getEmptyOpInfo
(
unw_info
).
getTypeRecorder
());
std
::
vector
<
llvm
::
Value
*>
llvm_args
;
llvm_args
.
push_back
(
converted_target
->
getValue
());
llvm_args
.
push_back
(
converted_slice
->
getValue
());
emitter
.
createIC
(
pp
,
(
void
*
)
pyston
::
delitem
,
llvm_args
,
unw_info
);
emitter
.
createIC
(
std
::
move
(
pp
)
,
(
void
*
)
pyston
::
delitem
,
llvm_args
,
unw_info
);
}
else
{
emitter
.
createCall2
(
unw_info
,
g
.
funcs
.
delitem
,
converted_target
->
getValue
(),
converted_slice
->
getValue
());
...
...
src/codegen/irgen/util.cpp
View file @
daa0ffd5
...
...
@@ -100,18 +100,10 @@ llvm::Constant* getStringConstantPtr(llvm::StringRef str) {
static
llvm
::
StringMap
<
const
void
*>
relocatable_syms
;
// Pointer to a vector where we want to keep track of all the pointers written directly into
// the compiled code, which the GC needs to be aware of.
std
::
vector
<
const
void
*>*
pointers_in_code
;
void
clearRelocatableSymsMap
()
{
relocatable_syms
.
clear
();
}
void
setPointersInCodeStorage
(
std
::
vector
<
const
void
*>*
v
)
{
pointers_in_code
=
v
;
}
const
void
*
getValueOfRelocatableSym
(
const
std
::
string
&
str
)
{
auto
it
=
relocatable_syms
.
find
(
str
);
if
(
it
!=
relocatable_syms
.
end
())
...
...
src/codegen/patchpoints.cpp
View file @
daa0ffd5
...
...
@@ -42,11 +42,13 @@ int ICSetupInfo::totalSize() const {
return
size
+
call_size
;
}
static
std
::
vector
<
std
::
pair
<
PatchpointInfo
*
,
void
*
/* addr of func to call */
>>
new_patchpoints
;
static
std
::
vector
<
std
::
pair
<
std
::
unique_ptr
<
PatchpointInfo
>
,
void
*
/* addr of func to call */
>>
new_patchpoints
;
ICSetupInfo
*
ICSetupInfo
::
initialize
(
bool
has_return_value
,
int
size
,
ICType
type
,
TypeRecorder
*
type_recorder
,
std
::
unique_ptr
<
ICSetupInfo
>
ICSetupInfo
::
initialize
(
bool
has_return_value
,
int
size
,
ICType
type
,
TypeRecorder
*
type_recorder
,
assembler
::
RegisterSet
allocatable_regs
)
{
ICSetupInfo
*
rtn
=
new
ICSetupInfo
(
type
,
size
,
has_return_value
,
type_recorder
,
allocatable_regs
);
auto
rtn
=
std
::
unique_ptr
<
ICSetupInfo
>
(
new
ICSetupInfo
(
type
,
size
,
has_return_value
,
type_recorder
,
allocatable_regs
));
// We use size == CALL_ONLY_SIZE to imply that the call isn't patchable
...
...
@@ -210,7 +212,7 @@ void processStackmap(CompiledFunction* cf, StackMap* stackmap) {
int
nrecords
=
stackmap
?
stackmap
->
records
.
size
()
:
0
;
assert
(
cf
->
location_map
==
NULL
);
cf
->
location_map
=
new
LocationMap
();
cf
->
location_map
=
llvm
::
make_unique
<
LocationMap
>
();
if
(
stackmap
)
cf
->
location_map
->
constants
=
stackmap
->
constants
;
...
...
@@ -232,7 +234,7 @@ void processStackmap(CompiledFunction* cf, StackMap* stackmap) {
}
RELEASE_ASSERT
(
new_patchpoints
.
size
()
>
r
->
id
,
""
);
PatchpointInfo
*
pp
=
new_patchpoints
[
r
->
id
].
first
;
std
::
unique_ptr
<
PatchpointInfo
>&
pp
=
new_patchpoints
[
r
->
id
].
first
;
assert
(
pp
);
if
(
pp
->
isFrameInfoStackmap
())
{
...
...
@@ -247,13 +249,12 @@ void processStackmap(CompiledFunction* cf, StackMap* stackmap) {
void
*
slowpath_func
=
PatchpointInfo
::
getSlowpathAddr
(
r
->
id
);
if
(
VERBOSITY
()
>=
2
)
{
printf
(
"Processing pp %ld; [%d, %d)
\n
"
,
reinterpret_cast
<
int64_t
>
(
pp
),
r
->
offset
,
r
->
offset
+
pp
->
patchpointSize
());
printf
(
"Processing pp %p; [%d, %d)
\n
"
,
pp
.
get
(),
r
->
offset
,
r
->
offset
+
pp
->
patchpointSize
());
}
assert
(
r
->
locations
.
size
()
==
pp
->
totalStackmapArgs
());
int
scratch_rbp_offset
=
extractScratchOffset
(
pp
,
r
);
int
scratch_rbp_offset
=
extractScratchOffset
(
pp
.
get
()
,
r
);
int
scratch_size
=
pp
->
scratchSize
();
assert
(
scratch_size
%
sizeof
(
void
*
)
==
0
);
assert
(
scratch_rbp_offset
%
sizeof
(
void
*
)
==
0
);
...
...
@@ -290,7 +291,7 @@ void processStackmap(CompiledFunction* cf, StackMap* stackmap) {
// TODO: is something like this necessary?
// llvm::sys::Memory::InvalidateInstructionCache(start, getSlotSize());
pp
->
parseLocationMap
(
r
,
cf
->
location_map
);
pp
->
parseLocationMap
(
r
,
cf
->
location_map
.
get
()
);
const
ICSetupInfo
*
ic
=
pp
->
getICInfo
();
if
(
ic
==
NULL
)
{
...
...
@@ -340,28 +341,22 @@ void processStackmap(CompiledFunction* cf, StackMap* stackmap) {
std
::
move
(
initialization_info
.
live_outs
));
assert
(
cf
);
// TODO: unsafe. hard to use a unique_ptr here though.
cf
->
ics
.
push_back
(
icinfo
.
release
());
cf
->
ics
.
push_back
(
std
::
move
(
icinfo
));
}
for
(
auto
&
e
:
new_patchpoints
)
{
PatchpointInfo
*
pp
=
e
.
first
;
const
ICSetupInfo
*
ic
=
pp
->
getICInfo
();
if
(
ic
)
delete
ic
;
delete
pp
;
}
new_patchpoints
.
clear
();
}
PatchpointInfo
*
PatchpointInfo
::
create
(
CompiledFunction
*
parent_cf
,
const
ICSetupInfo
*
icinfo
,
int
num_ic_stackmap_args
,
void
*
func_addr
)
{
PatchpointInfo
*
PatchpointInfo
::
create
(
CompiledFunction
*
parent_cf
,
std
::
unique_ptr
<
const
ICSetupInfo
>
icinfo
,
int
num_ic_stackmap_args
,
void
*
func_addr
)
{
if
(
icinfo
==
NULL
)
assert
(
num_ic_stackmap_args
==
0
);
auto
*
r
=
new
PatchpointInfo
(
parent_cf
,
icinfo
,
num_ic_stackmap_args
);
r
->
id
=
new_patchpoints
.
size
();
new_patchpoints
.
push_back
(
std
::
make_pair
(
r
,
func_addr
));
auto
pp_info
=
std
::
unique_ptr
<
PatchpointInfo
>
(
new
PatchpointInfo
(
parent_cf
,
std
::
move
(
icinfo
),
num_ic_stackmap_args
));
pp_info
->
id
=
new_patchpoints
.
size
();
auto
*
r
=
pp_info
.
get
();
new_patchpoints
.
emplace_back
(
std
::
move
(
pp_info
),
func_addr
);
assert
(
r
->
id
!=
DECREF_PP_ID
);
assert
(
r
->
id
!=
XDECREF_PP_ID
);
...
...
@@ -387,57 +382,56 @@ int slotSize(ICInfo* bjit_ic_info, int default_size) {
return
suggested_size
;
}
ICSetupInfo
*
createGenericIC
(
TypeRecorder
*
type_recorder
,
bool
has_return_value
,
int
size
)
{
std
::
unique_ptr
<
ICSetupInfo
>
createGenericIC
(
TypeRecorder
*
type_recorder
,
bool
has_return_value
,
int
size
)
{
return
ICSetupInfo
::
initialize
(
has_return_value
,
size
,
ICSetupInfo
::
Generic
,
type_recorder
);
}
ICSetupInfo
*
createGetattrIC
(
TypeRecorder
*
type_recorder
,
ICInfo
*
bjit_ic_info
)
{
std
::
unique_ptr
<
ICSetupInfo
>
createGetattrIC
(
TypeRecorder
*
type_recorder
,
ICInfo
*
bjit_ic_info
)
{
return
ICSetupInfo
::
initialize
(
true
,
slotSize
(
bjit_ic_info
,
1024
),
ICSetupInfo
::
Getattr
,
type_recorder
);
}
ICSetupInfo
*
createGetitemIC
(
TypeRecorder
*
type_recorder
,
ICInfo
*
bjit_ic_info
)
{
std
::
unique_ptr
<
ICSetupInfo
>
createGetitemIC
(
TypeRecorder
*
type_recorder
,
ICInfo
*
bjit_ic_info
)
{
return
ICSetupInfo
::
initialize
(
true
,
slotSize
(
bjit_ic_info
,
512
),
ICSetupInfo
::
Getitem
,
type_recorder
);
}
ICSetupInfo
*
createSetitemIC
(
TypeRecorder
*
type_recorder
)
{
std
::
unique_ptr
<
ICSetupInfo
>
createSetitemIC
(
TypeRecorder
*
type_recorder
)
{
return
ICSetupInfo
::
initialize
(
true
,
512
,
ICSetupInfo
::
Setitem
,
type_recorder
);
}
ICSetupInfo
*
createDelitemIC
(
TypeRecorder
*
type_recorder
)
{
std
::
unique_ptr
<
ICSetupInfo
>
createDelitemIC
(
TypeRecorder
*
type_recorder
)
{
return
ICSetupInfo
::
initialize
(
false
,
512
,
ICSetupInfo
::
Delitem
,
type_recorder
);
}
ICSetupInfo
*
createSetattrIC
(
TypeRecorder
*
type_recorder
,
ICInfo
*
bjit_ic_info
)
{
std
::
unique_ptr
<
ICSetupInfo
>
createSetattrIC
(
TypeRecorder
*
type_recorder
,
ICInfo
*
bjit_ic_info
)
{
return
ICSetupInfo
::
initialize
(
false
,
slotSize
(
bjit_ic_info
,
1024
),
ICSetupInfo
::
Setattr
,
type_recorder
);
}
ICSetupInfo
*
createDelattrIC
(
TypeRecorder
*
type_recorder
)
{
std
::
unique_ptr
<
ICSetupInfo
>
createDelattrIC
(
TypeRecorder
*
type_recorder
)
{
return
ICSetupInfo
::
initialize
(
false
,
144
,
ICSetupInfo
::
Delattr
,
type_recorder
);
}
ICSetupInfo
*
createCallsiteIC
(
TypeRecorder
*
type_recorder
,
int
num_args
,
ICInfo
*
bjit_ic_info
)
{
std
::
unique_ptr
<
ICSetupInfo
>
createCallsiteIC
(
TypeRecorder
*
type_recorder
,
int
num_args
,
ICInfo
*
bjit_ic_info
)
{
return
ICSetupInfo
::
initialize
(
true
,
slotSize
(
bjit_ic_info
,
4
*
(
640
+
48
*
num_args
)),
ICSetupInfo
::
Callsite
,
type_recorder
);
}
ICSetupInfo
*
createGetGlobalIC
(
TypeRecorder
*
type_recorder
)
{
std
::
unique_ptr
<
ICSetupInfo
>
createGetGlobalIC
(
TypeRecorder
*
type_recorder
)
{
return
ICSetupInfo
::
initialize
(
true
,
128
,
ICSetupInfo
::
GetGlobal
,
type_recorder
);
}
ICSetupInfo
*
createBinexpIC
(
TypeRecorder
*
type_recorder
,
ICInfo
*
bjit_ic_info
)
{
std
::
unique_ptr
<
ICSetupInfo
>
createBinexpIC
(
TypeRecorder
*
type_recorder
,
ICInfo
*
bjit_ic_info
)
{
return
ICSetupInfo
::
initialize
(
true
,
slotSize
(
bjit_ic_info
,
2048
),
ICSetupInfo
::
Binexp
,
type_recorder
);
}
ICSetupInfo
*
createNonzeroIC
(
TypeRecorder
*
type_recorder
)
{
std
::
unique_ptr
<
ICSetupInfo
>
createNonzeroIC
(
TypeRecorder
*
type_recorder
)
{
return
ICSetupInfo
::
initialize
(
true
,
1024
,
ICSetupInfo
::
Nonzero
,
type_recorder
);
}
ICSetupInfo
*
createHasnextIC
(
TypeRecorder
*
type_recorder
)
{
std
::
unique_ptr
<
ICSetupInfo
>
createHasnextIC
(
TypeRecorder
*
type_recorder
)
{
return
ICSetupInfo
::
initialize
(
true
,
128
,
ICSetupInfo
::
Hasnext
,
type_recorder
);
}
ICSetupInfo
*
createDeoptIC
()
{
std
::
unique_ptr
<
ICSetupInfo
>
createDeoptIC
()
{
return
ICSetupInfo
::
initialize
(
true
,
0
,
ICSetupInfo
::
Deopt
,
NULL
);
}
...
...
src/codegen/patchpoints.h
View file @
daa0ffd5
...
...
@@ -97,7 +97,8 @@ public:
return
llvm
::
CallingConv
::
C
;
}
static
ICSetupInfo
*
initialize
(
bool
has_return_value
,
int
size
,
ICType
type
,
TypeRecorder
*
type_recorder
,
static
std
::
unique_ptr
<
ICSetupInfo
>
initialize
(
bool
has_return_value
,
int
size
,
ICType
type
,
TypeRecorder
*
type_recorder
,
assembler
::
RegisterSet
allocatable_regs
=
assembler
::
RegisterSet
::
stdAllocatable
());
};
...
...
@@ -114,7 +115,7 @@ public:
private:
CompiledFunction
*
const
parent_cf
;
const
ICSetupInfo
*
icinfo
;
std
::
unique_ptr
<
const
ICSetupInfo
>
icinfo
;
int
num_ic_stackmap_args
;
int
num_frame_stackmap_args
;
bool
is_frame_info_stackmap
;
...
...
@@ -122,9 +123,9 @@ private:
FrameInfoDesc
frame_info_desc
;
PatchpointInfo
(
CompiledFunction
*
parent_cf
,
const
ICSetupInfo
*
icinfo
,
int
num_ic_stackmap_args
)
PatchpointInfo
(
CompiledFunction
*
parent_cf
,
std
::
unique_ptr
<
const
ICSetupInfo
>
icinfo
,
int
num_ic_stackmap_args
)
:
parent_cf
(
parent_cf
),
icinfo
(
icinfo
),
icinfo
(
std
::
move
(
icinfo
)
),
num_ic_stackmap_args
(
num_ic_stackmap_args
),
num_frame_stackmap_args
(
-
1
),
is_frame_info_stackmap
(
false
),
...
...
@@ -132,7 +133,7 @@ private:
public:
const
ICSetupInfo
*
getICInfo
()
{
return
icinfo
;
}
const
ICSetupInfo
*
getICInfo
()
{
return
icinfo
.
get
()
;
}
int
patchpointSize
();
CompiledFunction
*
parentFunction
()
{
return
parent_cf
;
}
...
...
@@ -171,25 +172,25 @@ public:
int
totalStackmapArgs
()
{
return
frameStackmapArgsStart
()
+
numFrameStackmapArgs
();
}
static
PatchpointInfo
*
create
(
CompiledFunction
*
parent_cf
,
const
ICSetupInfo
*
icinfo
,
int
num_ic_stackmap_args
,
void
*
func_addr
);
static
PatchpointInfo
*
create
(
CompiledFunction
*
parent_cf
,
std
::
unique_ptr
<
const
ICSetupInfo
>
icinfo
,
int
num_ic_stackmap_args
,
void
*
func_addr
);
static
void
*
getSlowpathAddr
(
unsigned
int
pp_id
);
};
class
ICInfo
;
ICSetupInfo
*
createGenericIC
(
TypeRecorder
*
type_recorder
,
bool
has_return_value
,
int
size
);
ICSetupInfo
*
createCallsiteIC
(
TypeRecorder
*
type_recorder
,
int
num_args
,
ICInfo
*
bjit_ic_info
);
ICSetupInfo
*
createGetGlobalIC
(
TypeRecorder
*
type_recorder
);
ICSetupInfo
*
createGetattrIC
(
TypeRecorder
*
type_recorder
,
ICInfo
*
bjit_ic_info
);
ICSetupInfo
*
createSetattrIC
(
TypeRecorder
*
type_recorder
,
ICInfo
*
bjit_ic_info
);
ICSetupInfo
*
createDelattrIC
(
TypeRecorder
*
type_recorder
);
ICSetupInfo
*
createGetitemIC
(
TypeRecorder
*
type_recorder
,
ICInfo
*
bjit_ic_info
);
ICSetupInfo
*
createSetitemIC
(
TypeRecorder
*
type_recorder
);
ICSetupInfo
*
createDelitemIC
(
TypeRecorder
*
type_recorder
);
ICSetupInfo
*
createBinexpIC
(
TypeRecorder
*
type_recorder
,
ICInfo
*
bjit_ic_info
);
ICSetupInfo
*
createNonzeroIC
(
TypeRecorder
*
type_recorder
);
ICSetupInfo
*
createHasnextIC
(
TypeRecorder
*
type_recorder
);
ICSetupInfo
*
createDeoptIC
();
std
::
unique_ptr
<
ICSetupInfo
>
createGenericIC
(
TypeRecorder
*
type_recorder
,
bool
has_return_value
,
int
size
);
std
::
unique_ptr
<
ICSetupInfo
>
createCallsiteIC
(
TypeRecorder
*
type_recorder
,
int
num_args
,
ICInfo
*
bjit_ic_info
);
std
::
unique_ptr
<
ICSetupInfo
>
createGetGlobalIC
(
TypeRecorder
*
type_recorder
);
std
::
unique_ptr
<
ICSetupInfo
>
createGetattrIC
(
TypeRecorder
*
type_recorder
,
ICInfo
*
bjit_ic_info
);
std
::
unique_ptr
<
ICSetupInfo
>
createSetattrIC
(
TypeRecorder
*
type_recorder
,
ICInfo
*
bjit_ic_info
);
std
::
unique_ptr
<
ICSetupInfo
>
createDelattrIC
(
TypeRecorder
*
type_recorder
);
std
::
unique_ptr
<
ICSetupInfo
>
createGetitemIC
(
TypeRecorder
*
type_recorder
,
ICInfo
*
bjit_ic_info
);
std
::
unique_ptr
<
ICSetupInfo
>
createSetitemIC
(
TypeRecorder
*
type_recorder
);
std
::
unique_ptr
<
ICSetupInfo
>
createDelitemIC
(
TypeRecorder
*
type_recorder
);
std
::
unique_ptr
<
ICSetupInfo
>
createBinexpIC
(
TypeRecorder
*
type_recorder
,
ICInfo
*
bjit_ic_info
);
std
::
unique_ptr
<
ICSetupInfo
>
createNonzeroIC
(
TypeRecorder
*
type_recorder
);
std
::
unique_ptr
<
ICSetupInfo
>
createHasnextIC
(
TypeRecorder
*
type_recorder
);
std
::
unique_ptr
<
ICSetupInfo
>
createDeoptIC
();
}
// namespace pyston
...
...
src/codegen/stackmaps.cpp
View file @
daa0ffd5
...
...
@@ -34,14 +34,14 @@ namespace pyston {
// TODO shouldn't be recording this in a global variable
static
uint64_t
stackmap_address
=
0
;
StackMap
*
parseStackMap
()
{
std
::
unique_ptr
<
StackMap
>
parseStackMap
()
{
if
(
!
stackmap_address
)
return
NULL
;
if
(
VERBOSITY
()
>=
3
)
printf
(
"Found the stackmaps at stackmap_address 0x%lx
\n
"
,
stackmap_address
);
StackMap
*
cur_map
=
new
StackMap
(
);
std
::
unique_ptr
<
StackMap
>
cur_map
=
std
::
unique_ptr
<
StackMap
>
(
new
StackMap
()
);
union
{
const
int8_t
*
i8
;
...
...
src/codegen/stackmaps.h
View file @
daa0ffd5
...
...
@@ -107,7 +107,7 @@ public:
llvm
::
DenseMap
<
int
,
LocationTable
>
definedness_vars
;
};
StackMap
*
parseStackMap
();
std
::
unique_ptr
<
StackMap
>
parseStackMap
();
llvm
::
JITEventListener
*
makeStackMapListener
();
}
...
...
src/codegen/type_recording.cpp
View file @
daa0ffd5
...
...
@@ -21,12 +21,12 @@
namespace
pyston
{
static
std
::
unordered_map
<
AST
*
,
TypeRecorder
*
>
type_recorders
;
static
std
::
unordered_map
<
AST
*
,
std
::
unique_ptr
<
TypeRecorder
>
>
type_recorders
;
TypeRecorder
*
getTypeRecorderForNode
(
AST
*
node
)
{
TypeRecorder
*
&
r
=
type_recorders
[
node
];
std
::
unique_ptr
<
TypeRecorder
>
&
r
=
type_recorders
[
node
];
if
(
r
==
NULL
)
r
=
new
TypeRecorder
();
return
r
;
r
=
llvm
::
make_unique
<
TypeRecorder
>
();
return
r
.
get
()
;
}
Box
*
recordType
(
TypeRecorder
*
self
,
Box
*
obj
)
{
...
...
@@ -56,8 +56,7 @@ BoxedClass* predictClassFor(AST* node) {
if
(
it
==
type_recorders
.
end
())
return
NULL
;
TypeRecorder
*
r
=
it
->
second
;
return
r
->
predict
();
return
it
->
second
->
predict
();
}
BoxedClass
*
TypeRecorder
::
predict
()
{
...
...
src/core/types.h
View file @
daa0ffd5
...
...
@@ -345,9 +345,6 @@ public:
// Otherwise this field is NULL.
const
OSREntryDescriptor
*
entry_descriptor
;
// Pointers that were written directly into the code, which the GC should be aware of.
std
::
vector
<
const
void
*>
pointers_in_code
;
// The function pointer to the generated code. For convenience, it can be accessed
// as one of many different types.
// TODO: we instead make these accessor-functions that make sure that the code actually
...
...
@@ -377,10 +374,10 @@ public:
ICInvalidator
dependent_callsites
;
// Metadata that lets us find local variables from the C stack fram.
LocationMap
*
location_map
;
std
::
unique_ptr
<
LocationMap
>
location_map
;
// List of metadata objects for ICs inside this compilation
std
::
vector
<
ICInfo
*
>
ics
;
std
::
vector
<
std
::
unique_ptr
<
ICInfo
>
>
ics
;
CompiledFunction
(
FunctionMetadata
*
func
,
FunctionSpecialization
*
spec
,
void
*
code
,
EffortLevel
effort
,
ExceptionStyle
exception_style
,
const
OSREntryDescriptor
*
entry_descriptor
);
...
...
src/runtime/ics.cpp
View file @
daa0ffd5
...
...
@@ -299,7 +299,6 @@ RuntimeIC::RuntimeIC(void* func_addr, int patchable_size) {
RuntimeIC
::~
RuntimeIC
()
{
if
(
ENABLE_RUNTIME_ICS
)
{
deregisterCompiledPatchpoint
(
icinfo
.
get
());
uint8_t
*
eh_frame_addr
=
(
uint8_t
*
)
addr
-
EH_FRAME_SIZE
;
deregisterEHFrames
(
eh_frame_addr
,
(
uint64_t
)
eh_frame_addr
,
EH_FRAME_SIZE
);
#ifdef NVALGRIND
...
...
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