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
17b548d9
Commit
17b548d9
authored
Oct 04, 2016
by
Marius Wachtler
Committed by
Boxiang Sun
Oct 20, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BST: use constant table for the interned strings
parent
53a1a557
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
174 additions
and
132 deletions
+174
-132
src/analysis/type_analysis.cpp
src/analysis/type_analysis.cpp
+11
-7
src/codegen/ast_interpreter.cpp
src/codegen/ast_interpreter.cpp
+30
-27
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+32
-26
src/core/bst.cpp
src/core/bst.cpp
+11
-11
src/core/bst.h
src/core/bst.h
+11
-11
src/core/cfg.cpp
src/core/cfg.cpp
+65
-50
src/core/stringpool.h
src/core/stringpool.h
+8
-0
src/runtime/types.h
src/runtime/types.h
+6
-0
No files found.
src/analysis/type_analysis.cpp
View file @
17b548d9
...
...
@@ -279,10 +279,11 @@ private:
void
visit_callattr
(
BST_CallAttr
*
node
)
override
{
CompilerType
*
t
=
getType
(
node
->
vreg_value
);
CompilerType
*
func
=
t
->
getattrType
(
node
->
attr
,
false
);
InternedString
attr
=
getCodeConstants
().
getInternedString
(
node
->
index_attr
);
CompilerType
*
func
=
t
->
getattrType
(
attr
,
false
);
if
(
VERBOSITY
()
>=
2
&&
func
==
UNDEF
)
{
printf
(
"Think %s.%s is undefined, at %d
\n
"
,
t
->
debugName
().
c_str
(),
node
->
attr
.
c_str
(),
node
->
lineno
);
printf
(
"Think %s.%s is undefined, at %d
\n
"
,
t
->
debugName
().
c_str
(),
attr
.
c_str
(),
node
->
lineno
);
print_bst
(
node
,
code_constants
);
printf
(
"
\n
"
);
}
...
...
@@ -292,10 +293,11 @@ private:
void
visit_callclsattr
(
BST_CallClsAttr
*
node
)
override
{
CompilerType
*
t
=
getType
(
node
->
vreg_value
);
CompilerType
*
func
=
t
->
getattrType
(
node
->
attr
,
true
);
InternedString
attr
=
getCodeConstants
().
getInternedString
(
node
->
index_attr
);
CompilerType
*
func
=
t
->
getattrType
(
attr
,
true
);
if
(
VERBOSITY
()
>=
2
&&
func
==
UNDEF
)
{
printf
(
"Think %s.%s is undefined, at %d
\n
"
,
t
->
debugName
().
c_str
(),
node
->
attr
.
c_str
(),
node
->
lineno
);
printf
(
"Think %s.%s is undefined, at %d
\n
"
,
t
->
debugName
().
c_str
(),
attr
.
c_str
(),
node
->
lineno
);
print_bst
(
node
,
code_constants
);
printf
(
"
\n
"
);
}
...
...
@@ -379,7 +381,8 @@ private:
auto
name_scope
=
node
->
lookup_type
;
if
(
name_scope
==
ScopeInfo
::
VarScopeType
::
GLOBAL
)
{
if
(
node
->
id
.
s
()
==
"None"
)
InternedString
id
=
getCodeConstants
().
getInternedString
(
node
->
index_id
);
if
(
id
.
s
()
==
"None"
)
t
=
NONE
;
}
else
if
(
name_scope
==
ScopeInfo
::
VarScopeType
::
FAST
||
name_scope
==
ScopeInfo
::
VarScopeType
::
CLOSURE
)
t
=
getType
(
node
->
vreg
);
...
...
@@ -389,7 +392,8 @@ private:
void
visit_loadattr
(
BST_LoadAttr
*
node
)
override
{
CompilerType
*
t
=
getType
(
node
->
vreg_value
);
CompilerType
*
rtn
=
t
->
getattrType
(
node
->
attr
,
node
->
clsonly
);
InternedString
attr
=
getCodeConstants
().
getInternedString
(
node
->
index_attr
);
CompilerType
*
rtn
=
t
->
getattrType
(
attr
,
node
->
clsonly
);
if
(
speculation
!=
TypeAnalysis
::
NONE
)
{
BoxedClass
*
speculated_class
=
predictClassFor
(
node
);
...
...
@@ -397,7 +401,7 @@ private:
}
if
(
VERBOSITY
()
>=
2
&&
rtn
==
UNDEF
)
{
printf
(
"Think %s.%s is undefined, at %d
\n
"
,
t
->
debugName
().
c_str
(),
node
->
attr
.
c_str
(),
node
->
lineno
);
printf
(
"Think %s.%s is undefined, at %d
\n
"
,
t
->
debugName
().
c_str
(),
attr
.
c_str
(),
node
->
lineno
);
print_bst
(
node
,
code_constants
);
printf
(
"
\n
"
);
}
...
...
src/codegen/ast_interpreter.cpp
View file @
17b548d9
...
...
@@ -1263,7 +1263,8 @@ Value ASTInterpreter::visit_makeClass(BST_MakeClass* mkclass) {
ArgPassSpec
(
0
),
0
,
0
,
0
,
0
,
0
);
AUTO_DECREF
(
attrDict
);
Box
*
classobj
=
createUserClass
(
node
->
name
.
getBox
(),
bases_tuple
,
attrDict
);
InternedString
name
=
getCodeConstants
().
getInternedString
(
node
->
index_name
);
Box
*
classobj
=
createUserClass
(
name
.
getBox
(),
bases_tuple
,
attrDict
);
for
(
int
i
=
decorators
.
size
()
-
1
;
i
>=
0
;
i
--
)
{
classobj
=
runtimeCall
(
autoDecref
(
decorators
[
i
]),
ArgPassSpec
(
1
),
autoDecref
(
classobj
),
0
,
0
,
0
,
0
);
...
...
@@ -1311,7 +1312,7 @@ void ASTInterpreter::visit_assert(BST_Assert* node) {
void
ASTInterpreter
::
visit_deleteattr
(
BST_DeleteAttr
*
node
)
{
Value
target
=
getVReg
(
node
->
vreg_value
);
AUTO_DECREF
(
target
.
o
);
BoxedString
*
str
=
node
->
attr
.
getBox
();
BoxedString
*
str
=
getCodeConstants
().
getInternedString
(
node
->
index_attr
)
.
getBox
();
if
(
jit
)
jit
->
emitDelAttr
(
target
,
str
);
delattr
(
target
.
o
,
str
);
...
...
@@ -1344,27 +1345,28 @@ void ASTInterpreter::visit_deletename(BST_DeleteName* target) {
assert
(
target
->
lookup_type
!=
ScopeInfo
::
VarScopeType
::
UNKNOWN
);
ScopeInfo
::
VarScopeType
vst
=
target
->
lookup_type
;
InternedString
id
=
getCodeConstants
().
getInternedString
(
target
->
index_id
);
if
(
vst
==
ScopeInfo
::
VarScopeType
::
GLOBAL
)
{
if
(
jit
)
jit
->
emitDelGlobal
(
target
->
id
.
getBox
());
delGlobal
(
frame_info
.
globals
,
target
->
id
.
getBox
());
jit
->
emitDelGlobal
(
id
.
getBox
());
delGlobal
(
frame_info
.
globals
,
id
.
getBox
());
}
else
if
(
vst
==
ScopeInfo
::
VarScopeType
::
NAME
)
{
if
(
jit
)
jit
->
emitDelName
(
target
->
id
);
ASTInterpreterJitInterface
::
delNameHelper
(
this
,
target
->
id
);
jit
->
emitDelName
(
id
);
ASTInterpreterJitInterface
::
delNameHelper
(
this
,
id
);
}
else
{
assert
(
vst
==
ScopeInfo
::
VarScopeType
::
FAST
);
assert
(
getVRegInfo
().
getVReg
(
target
->
id
)
==
target
->
vreg
);
assert
(
getVRegInfo
().
getVReg
(
id
)
==
target
->
vreg
);
if
(
target
->
id
.
s
()[
0
]
==
'#'
)
{
if
(
id
.
s
()[
0
]
==
'#'
)
{
assert
(
vregs
[
target
->
vreg
]
!=
NULL
);
if
(
jit
)
jit
->
emitKillTemporary
(
target
->
vreg
);
}
else
{
abortJITing
();
if
(
vregs
[
target
->
vreg
]
==
0
)
{
assertNameDefined
(
0
,
target
->
id
.
c_str
(),
NameError
,
true
/* local_var_msg */
);
assertNameDefined
(
0
,
id
.
c_str
(),
NameError
,
true
/* local_var_msg */
);
return
;
}
}
...
...
@@ -1428,14 +1430,14 @@ Value ASTInterpreter::visit_call(BST_Call* node) {
callattr_clsonly
=
false
;
auto
*
attr_ast
=
bst_cast
<
BST_CallAttr
>
(
node
);
func
=
getVReg
(
attr_ast
->
vreg_value
);
attr
=
attr_ast
->
attr
;
attr
=
getCodeConstants
().
getInternedString
(
attr_ast
->
index_attr
)
;
vreg_elts
=
bst_cast
<
BST_CallAttr
>
(
node
)
->
elts
;
}
else
if
(
node
->
type
==
BST_TYPE
::
CallClsAttr
)
{
is_callattr
=
true
;
callattr_clsonly
=
true
;
auto
*
attr_ast
=
bst_cast
<
BST_CallClsAttr
>
(
node
);
func
=
getVReg
(
attr_ast
->
vreg_value
);
attr
=
attr_ast
->
attr
;
attr
=
getCodeConstants
().
getInternedString
(
attr_ast
->
index_attr
)
;
vreg_elts
=
bst_cast
<
BST_CallClsAttr
>
(
node
)
->
elts
;
}
else
{
auto
*
attr_ast
=
bst_cast
<
BST_CallFunc
>
(
node
);
...
...
@@ -1577,14 +1579,14 @@ Value ASTInterpreter::getVReg(int vreg, bool is_kill) {
Value
ASTInterpreter
::
visit_loadname
(
BST_LoadName
*
node
)
{
assert
(
node
->
lookup_type
!=
ScopeInfo
::
VarScopeType
::
UNKNOWN
);
InternedString
id
=
getCodeConstants
().
getInternedString
(
node
->
index_id
);
switch
(
node
->
lookup_type
)
{
case
ScopeInfo
:
:
VarScopeType
::
GLOBAL
:
{
Value
v
;
if
(
jit
)
v
.
var
=
jit
->
emitGetGlobal
(
node
->
id
.
getBox
());
v
.
var
=
jit
->
emitGetGlobal
(
id
.
getBox
());
v
.
o
=
getGlobal
(
frame_info
.
globals
,
node
->
id
.
getBox
());
v
.
o
=
getGlobal
(
frame_info
.
globals
,
id
.
getBox
());
return
v
;
}
case
ScopeInfo
:
:
VarScopeType
::
DEREF
:
{
...
...
@@ -1601,13 +1603,13 @@ Value ASTInterpreter::visit_loadname(BST_LoadName* node) {
}
if
(
is_live
)
v
.
var
=
jit
->
emitGetLocal
(
node
->
id
,
node
->
vreg
);
v
.
var
=
jit
->
emitGetLocal
(
id
,
node
->
vreg
);
else
v
.
var
=
jit
->
emitGetBlockLocal
(
node
->
id
,
node
->
vreg
);
v
.
var
=
jit
->
emitGetBlockLocal
(
id
,
node
->
vreg
);
}
assert
(
node
->
vreg
>=
0
);
assert
(
getVRegInfo
().
getVReg
(
node
->
id
)
==
node
->
vreg
);
assert
(
getVRegInfo
().
getVReg
(
id
)
==
node
->
vreg
);
frame_info
.
num_vregs
=
std
::
max
(
frame_info
.
num_vregs
,
node
->
vreg
+
1
);
Box
*
val
=
vregs
[
node
->
vreg
];
...
...
@@ -1617,14 +1619,14 @@ Value ASTInterpreter::visit_loadname(BST_LoadName* node) {
return
v
;
}
assertNameDefined
(
0
,
node
->
id
.
c_str
(),
UnboundLocalError
,
true
);
assertNameDefined
(
0
,
id
.
c_str
(),
UnboundLocalError
,
true
);
RELEASE_ASSERT
(
0
,
"should be unreachable"
);
}
case
ScopeInfo
:
:
VarScopeType
::
NAME
:
{
Value
v
;
if
(
jit
)
v
.
var
=
jit
->
emitGetBoxedLocal
(
node
->
id
.
getBox
());
v
.
o
=
boxedLocalsGet
(
frame_info
.
boxedLocals
,
node
->
id
.
getBox
(),
frame_info
.
globals
);
v
.
var
=
jit
->
emitGetBoxedLocal
(
id
.
getBox
());
v
.
o
=
boxedLocalsGet
(
frame_info
.
boxedLocals
,
id
.
getBox
(),
frame_info
.
globals
);
return
v
;
}
default:
...
...
@@ -1636,7 +1638,7 @@ Value ASTInterpreter::visit_loadattr(BST_LoadAttr* node) {
Value
v
=
getVReg
(
node
->
vreg_value
);
AUTO_DECREF
(
v
.
o
);
BoxedString
*
attr
=
node
->
attr
.
getBox
();
BoxedString
*
attr
=
getCodeConstants
().
getInternedString
(
node
->
index_attr
)
.
getBox
();
Value
r
;
if
(
node
->
clsonly
)
r
=
Value
(
getclsattr
(
v
.
o
,
attr
),
jit
?
jit
->
emitGetClsAttr
(
v
,
attr
)
:
NULL
);
...
...
@@ -1680,7 +1682,7 @@ void ASTInterpreter::visit_storename(BST_StoreName* node) {
assert
(
node
->
lookup_type
!=
ScopeInfo
::
VarScopeType
::
UNKNOWN
);
InternedString
name
=
node
->
id
;
InternedString
name
=
getCodeConstants
().
getInternedString
(
node
->
index_id
)
;
ScopeInfo
::
VarScopeType
vst
=
node
->
lookup_type
;
if
(
vst
==
ScopeInfo
::
VarScopeType
::
GLOBAL
)
{
if
(
jit
)
...
...
@@ -1711,7 +1713,7 @@ void ASTInterpreter::visit_storename(BST_StoreName* node) {
if
(
closure
)
{
ASTInterpreterJitInterface
::
setLocalClosureHelper
(
this
,
node
->
vreg
,
node
->
closure_offset
,
value
.
o
);
}
else
{
assert
(
getVRegInfo
().
getVReg
(
n
ode
->
id
)
==
node
->
vreg
);
assert
(
getVRegInfo
().
getVReg
(
n
ame
)
==
node
->
vreg
);
frame_info
.
num_vregs
=
std
::
max
(
frame_info
.
num_vregs
,
node
->
vreg
+
1
);
Box
*
prev
=
vregs
[
node
->
vreg
];
vregs
[
node
->
vreg
]
=
value
.
o
;
...
...
@@ -1724,11 +1726,12 @@ void ASTInterpreter::visit_storename(BST_StoreName* node) {
void
ASTInterpreter
::
visit_storeattr
(
BST_StoreAttr
*
node
)
{
Value
value
=
getVReg
(
node
->
vreg_value
);
Value
o
=
getVReg
(
node
->
vreg_target
);
InternedString
attr
=
getCodeConstants
().
getInternedString
(
node
->
index_attr
);
if
(
jit
)
{
jit
->
emitSetAttr
(
node
,
o
,
node
->
attr
.
getBox
(),
value
);
jit
->
emitSetAttr
(
node
,
o
,
attr
.
getBox
(),
value
);
}
AUTO_DECREF
(
o
.
o
);
pyston
::
setattr
(
o
.
o
,
node
->
attr
.
getBox
(),
value
.
o
);
pyston
::
setattr
(
o
.
o
,
attr
.
getBox
(),
value
.
o
);
}
void
ASTInterpreter
::
visit_storesub
(
BST_StoreSub
*
node
)
{
...
...
@@ -1860,8 +1863,8 @@ Box* ASTInterpreterJitInterface::derefHelper(void* _interpreter, BST_LoadName* n
}
Box
*
val
=
closure
->
elts
[
deref_info
.
offset
];
if
(
val
==
NULL
)
{
raiseExcHelper
(
NameError
,
"free variable '%s' referenced before assignment in enclosing scope"
,
node
->
id
.
c_str
());
InternedString
id
=
interpreter
->
getCodeConstants
().
getInternedString
(
node
->
index_id
);
raiseExcHelper
(
NameError
,
"free variable '%s' referenced before assignment in enclosing scope"
,
id
.
c_str
());
}
Py_INCREF
(
val
);
return
val
;
...
...
src/codegen/irgen/irgenerator.cpp
View file @
17b548d9
This diff is collapsed.
Click to expand it.
src/core/bst.cpp
View file @
17b548d9
...
...
@@ -837,7 +837,7 @@ bool PrintVisitor::visit_callattr(BST_CallAttr* node) {
visit_vreg
(
&
node
->
vreg_dst
,
true
);
visit_vreg
(
&
node
->
vreg_value
);
stream
<<
"."
;
stream
<<
node
->
attr
.
s
();
stream
<<
code_constants
.
getInternedString
(
node
->
index_attr
)
.
s
();
stream
<<
"("
;
bool
prevarg
=
false
;
...
...
@@ -867,7 +867,7 @@ bool PrintVisitor::visit_callclsattr(BST_CallClsAttr* node) {
visit_vreg
(
&
node
->
vreg_dst
,
true
);
visit_vreg
(
&
node
->
vreg_value
);
stream
<<
":"
;
stream
<<
node
->
attr
.
s
();
stream
<<
code_constants
.
getInternedString
(
node
->
index_attr
)
.
s
();
stream
<<
"("
;
bool
prevarg
=
false
;
...
...
@@ -909,7 +909,7 @@ bool PrintVisitor::visit_classdef(BST_ClassDef* node) {
stream
<<
"
\n
"
;
printIndent
();
}
stream
<<
"class "
<<
node
->
name
.
s
()
<<
"("
;
stream
<<
"class "
<<
code_constants
.
getInternedString
(
node
->
index_name
)
.
s
()
<<
"("
;
visit_vreg
(
&
node
->
vreg_bases_tuple
);
stream
<<
")"
;
...
...
@@ -954,7 +954,7 @@ bool PrintVisitor::visit_deleteattr(BST_DeleteAttr* node) {
stream
<<
"del "
;
visit_vreg
(
&
node
->
vreg_value
);
stream
<<
'.'
;
stream
<<
node
->
attr
.
s
();
stream
<<
code_constants
.
getInternedString
(
node
->
index_attr
)
.
s
();
return
true
;
}
bool
PrintVisitor
::
visit_deletename
(
BST_DeleteName
*
node
)
{
...
...
@@ -963,7 +963,7 @@ bool PrintVisitor::visit_deletename(BST_DeleteName* node) {
visit_vreg
(
&
node
->
vreg
);
stream
<<
" "
;
}
stream
<<
node
->
id
.
s
();
stream
<<
code_constants
.
getInternedString
(
node
->
index_id
)
.
s
();
return
true
;
}
...
...
@@ -999,8 +999,8 @@ bool PrintVisitor::visit_functiondef(BST_FunctionDef* node) {
}
stream
<<
"def "
;
if
(
node
->
name
!=
InternedString
()
)
stream
<<
node
->
name
.
s
();
if
(
node
->
index_name
!=
VREG_UNDEFINED
)
stream
<<
code_constants
.
getInternedString
(
node
->
index_name
)
.
s
();
else
stream
<<
"<lambda>"
;
stream
<<
"("
;
...
...
@@ -1226,14 +1226,14 @@ bool PrintVisitor::visit_loadname(BST_LoadName* node) {
visit_vreg
(
&
node
->
vreg
);
stream
<<
" "
;
}
stream
<<
node
->
id
.
s
();
stream
<<
code_constants
.
getInternedString
(
node
->
index_id
)
.
s
();
return
true
;
}
bool
PrintVisitor
::
visit_loadattr
(
BST_LoadAttr
*
node
)
{
visit_vreg
(
&
node
->
vreg_dst
,
true
);
visit_vreg
(
&
node
->
vreg_value
);
stream
<<
(
node
->
clsonly
?
':'
:
'.'
)
<<
node
->
attr
.
s
();
stream
<<
(
node
->
clsonly
?
':'
:
'.'
)
<<
code_constants
.
getInternedString
(
node
->
index_attr
)
.
s
();
return
true
;
}
...
...
@@ -1265,7 +1265,7 @@ bool PrintVisitor::visit_storename(BST_StoreName* node) {
visit_vreg
(
&
node
->
vreg
);
stream
<<
" "
;
}
stream
<<
node
->
id
.
s
();
stream
<<
code_constants
.
getInternedString
(
node
->
index_id
)
.
s
();
stream
<<
" = "
;
visit_vreg
(
&
node
->
vreg_value
);
return
true
;
...
...
@@ -1273,7 +1273,7 @@ bool PrintVisitor::visit_storename(BST_StoreName* node) {
bool
PrintVisitor
::
visit_storeattr
(
BST_StoreAttr
*
node
)
{
visit_vreg
(
&
node
->
vreg_target
);
stream
<<
"."
<<
node
->
attr
.
s
()
<<
" = "
;
stream
<<
"."
<<
code_constants
.
getInternedString
(
node
->
index_attr
)
.
s
()
<<
" = "
;
visit_vreg
(
&
node
->
vreg_value
);
return
true
;
}
...
...
src/core/bst.h
View file @
17b548d9
...
...
@@ -258,7 +258,7 @@ class BST_StoreName : public BST_stmt {
public:
int
vreg_value
=
VREG_UNDEFINED
;
InternedString
id
;
int
index_id
=
VREG_UNDEFINED
;
ScopeInfo
::
VarScopeType
lookup_type
;
int
vreg
=
VREG_UNDEFINED
;
...
...
@@ -272,7 +272,7 @@ public:
class
BST_StoreAttr
:
public
BST_stmt
{
public:
InternedString
attr
;
int
index_attr
=
VREG_UNDEFINED
;
int
vreg_target
=
VREG_UNDEFINED
;
int
vreg_value
=
VREG_UNDEFINED
;
...
...
@@ -299,7 +299,7 @@ public:
class
BST_LoadName
:
public
BST_stmt_with_dest
{
public:
InternedString
id
;
int
index_id
=
VREG_UNDEFINED
;
ScopeInfo
::
VarScopeType
lookup_type
;
// LoadName does not kill this vreg
int
vreg
=
VREG_UNDEFINED
;
...
...
@@ -314,7 +314,7 @@ public:
class
BST_LoadAttr
:
public
BST_stmt_with_dest
{
public:
InternedString
attr
;
int
index_attr
=
VREG_UNDEFINED
;
int
vreg_value
=
VREG_UNDEFINED
;
bool
clsonly
=
false
;
...
...
@@ -376,7 +376,7 @@ public:
class
BST_CallAttr
:
public
BST_Call
{
public:
int
vreg_value
=
VREG_UNDEFINED
;
InternedString
attr
;
int
index_attr
=
VREG_UNDEFINED
;
int
elts
[
1
];
BSTVARVREGS2CALL
(
CallAttr
,
num_args
,
num_keywords
,
elts
)
...
...
@@ -385,7 +385,7 @@ public:
class
BST_CallClsAttr
:
public
BST_Call
{
public:
int
vreg_value
=
VREG_UNDEFINED
;
InternedString
attr
;
int
index_attr
=
VREG_UNDEFINED
;
int
elts
[
1
];
BSTVARVREGS2CALL
(
CallClsAttr
,
num_args
,
num_keywords
,
elts
)
...
...
@@ -403,8 +403,8 @@ public:
class
BST_ClassDef
:
public
BST_stmt
{
public:
InternedString
name
;
int
vreg_bases_tuple
;
int
index_name
=
VREG_UNDEFINED
;
int
vreg_bases_tuple
=
VREG_UNDEFINED
;
const
int
num_decorator
;
int
decorator
[
1
];
...
...
@@ -419,14 +419,14 @@ public:
class
BST_DeleteAttr
:
public
BST_stmt
{
public:
int
vreg_value
=
VREG_UNDEFINED
;
InternedString
attr
;
int
index_attr
=
VREG_UNDEFINED
;
BSTFIXEDVREGS
(
DeleteAttr
,
BST_stmt
)
};
class
BST_DeleteName
:
public
BST_stmt
{
public:
InternedString
id
;
int
index_id
=
VREG_UNDEFINED
;
ScopeInfo
::
VarScopeType
lookup_type
;
int
vreg
=
VREG_UNDEFINED
;
...
...
@@ -466,7 +466,7 @@ public:
class
BST_FunctionDef
:
public
BST_stmt
{
public:
InternedString
name
;
// if the name is not set this is a lambda
int
index_name
=
VREG_UNDEFINED
;
// if the name is not set this is a lambda
const
int
num_decorator
;
const
int
num_defaults
;
...
...
src/core/cfg.cpp
View file @
17b548d9
This diff is collapsed.
Click to expand it.
src/core/stringpool.h
View file @
17b548d9
...
...
@@ -86,6 +86,14 @@ public:
bool
isCompilerCreatedName
()
const
;
static
InternedString
unsafe
(
BoxedString
*
str
)
{
#ifndef NDEBUG
return
InternedString
(
str
,
NULL
);
#else
return
InternedString
(
str
);
#endif
}
friend
class
InternedStringPool
;
friend
struct
std
::
hash
<
InternedString
>
;
friend
struct
std
::
less
<
InternedString
>
;
...
...
src/runtime/types.h
View file @
17b548d9
...
...
@@ -1099,12 +1099,15 @@ public:
BORROWED
(
Box
*
)
getConstant
(
int
vreg
)
const
{
return
constants
[
-
(
vreg
+
1
)];
}
InternedString
getInternedString
(
int
vreg
)
const
{
return
InternedString
::
unsafe
((
BoxedString
*
)
getConstant
(
vreg
));
}
// returns the vreg num for the constant (which is a negative number)
int
createVRegEntryForConstant
(
Box
*
o
)
{
constants
.
push_back
(
o
);
return
-
constants
.
size
();
}
void
addOwnedRef
(
Box
*
o
)
const
{
owned_refs
.
emplace_back
(
o
);
}
BORROWED
(
BoxedInt
*
)
getIntConstant
(
int64_t
n
)
const
;
...
...
@@ -1113,6 +1116,9 @@ public:
std
::
pair
<
BST_stmt
*
,
BORROWED
(
BoxedCode
*
)
>
getFuncOrClass
(
int
constant
)
const
{
return
funcs_and_classes
[
constant
];
}
int
addInternedString
(
InternedString
s
)
{
return
createVRegEntryForConstant
(
s
.
getBox
());
}
int
addFuncOrClass
(
BST_stmt
*
stmt
,
STOLEN
(
BoxedCode
*
)
code
)
{
funcs_and_classes
.
emplace_back
(
stmt
,
code
);
return
funcs_and_classes
.
size
()
-
1
;
...
...
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