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
cefce6a5
Commit
cefce6a5
authored
Feb 12, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rip out the vestiges of the old vref-counting system
parent
c9b0d8f9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
97 additions
and
493 deletions
+97
-493
src/codegen/compvars.cpp
src/codegen/compvars.cpp
+48
-204
src/codegen/compvars.h
src/codegen/compvars.h
+2
-78
src/codegen/irgen.cpp
src/codegen/irgen.cpp
+5
-15
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+42
-196
No files found.
src/codegen/compvars.cpp
View file @
cefce6a5
...
@@ -117,9 +117,7 @@ public:
...
@@ -117,9 +117,7 @@ public:
static
CompilerVariable
*
makeIM
(
CompilerVariable
*
obj
,
CompilerVariable
*
func
,
CompilerVariable
*
im_class
)
{
static
CompilerVariable
*
makeIM
(
CompilerVariable
*
obj
,
CompilerVariable
*
func
,
CompilerVariable
*
im_class
)
{
CompilerVariable
*
rtn
=
new
ValuedCompilerVariable
<
RawInstanceMethod
*>
(
CompilerVariable
*
rtn
=
new
ValuedCompilerVariable
<
RawInstanceMethod
*>
(
InstanceMethodType
::
get
(
obj
->
getType
(),
func
->
getType
()),
new
RawInstanceMethod
(
obj
,
func
,
im_class
),
true
);
InstanceMethodType
::
get
(
obj
->
getType
(),
func
->
getType
()),
new
RawInstanceMethod
(
obj
,
func
,
im_class
));
obj
->
incvref
();
func
->
incvref
();
return
rtn
;
return
rtn
;
}
}
...
@@ -136,14 +134,6 @@ public:
...
@@ -136,14 +134,6 @@ public:
return
"instanceMethod("
+
obj_type
->
debugName
()
+
" ; "
+
function_type
->
debugName
()
+
")"
;
return
"instanceMethod("
+
obj_type
->
debugName
()
+
" ; "
+
function_type
->
debugName
()
+
")"
;
}
}
void
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
checkVar
(
var
);
RawInstanceMethod
*
val
=
var
->
getValue
();
val
->
obj
->
decvref
(
emitter
);
val
->
func
->
decvref
(
emitter
);
delete
val
;
}
CompilerVariable
*
call
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ValuedCompilerVariable
<
RawInstanceMethod
*>*
var
,
CompilerVariable
*
call
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ValuedCompilerVariable
<
RawInstanceMethod
*>*
var
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
override
{
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
override
{
...
@@ -172,10 +162,7 @@ public:
...
@@ -172,10 +162,7 @@ public:
llvm
::
Value
*
boxed
=
emitter
.
getBuilder
()
->
CreateCall3
(
g
.
funcs
.
boxInstanceMethod
,
obj
->
getValue
(),
llvm
::
Value
*
boxed
=
emitter
.
getBuilder
()
->
CreateCall3
(
g
.
funcs
.
boxInstanceMethod
,
obj
->
getValue
(),
func
->
getValue
(),
im_class
->
getValue
());
func
->
getValue
(),
im_class
->
getValue
());
obj
->
decvref
(
emitter
);
return
new
ConcreteCompilerVariable
(
other_type
,
boxed
);
func
->
decvref
(
emitter
);
return
new
ConcreteCompilerVariable
(
other_type
,
boxed
,
true
);
}
}
CompilerVariable
*
dup
(
VAR
*
var
,
DupCache
&
cache
)
override
{
CompilerVariable
*
dup
(
VAR
*
var
,
DupCache
&
cache
)
override
{
checkVar
(
var
);
checkVar
(
var
);
...
@@ -185,9 +172,7 @@ public:
...
@@ -185,9 +172,7 @@ public:
RawInstanceMethod
*
im
=
var
->
getValue
();
RawInstanceMethod
*
im
=
var
->
getValue
();
RawInstanceMethod
*
new_im
RawInstanceMethod
*
new_im
=
new
RawInstanceMethod
(
im
->
obj
->
dup
(
cache
),
im
->
func
->
dup
(
cache
),
im
->
im_class
->
dup
(
cache
));
=
new
RawInstanceMethod
(
im
->
obj
->
dup
(
cache
),
im
->
func
->
dup
(
cache
),
im
->
im_class
->
dup
(
cache
));
rtn
=
new
VAR
(
this
,
new_im
,
var
->
isGrabbed
());
rtn
=
new
VAR
(
this
,
new_im
);
while
(
rtn
->
getVrefs
()
<
var
->
getVrefs
())
rtn
->
incvref
();
}
}
return
rtn
;
return
rtn
;
}
}
...
@@ -209,7 +194,6 @@ std::unordered_map<std::pair<CompilerType*, CompilerType*>, InstanceMethodType*>
...
@@ -209,7 +194,6 @@ std::unordered_map<std::pair<CompilerType*, CompilerType*>, InstanceMethodType*>
ConcreteCompilerVariable
*
ConcreteCompilerType
::
makeConverted
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
,
ConcreteCompilerVariable
*
ConcreteCompilerType
::
makeConverted
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
,
ConcreteCompilerType
*
other_type
)
{
ConcreteCompilerType
*
other_type
)
{
if
(
other_type
==
this
)
{
if
(
other_type
==
this
)
{
var
->
incvref
();
return
var
;
return
var
;
}
}
printf
(
"makeConverted not defined for %s
\n
"
,
debugName
().
c_str
());
printf
(
"makeConverted not defined for %s
\n
"
,
debugName
().
c_str
());
...
@@ -218,9 +202,7 @@ ConcreteCompilerVariable* ConcreteCompilerType::makeConverted(IREmitter& emitter
...
@@ -218,9 +202,7 @@ ConcreteCompilerVariable* ConcreteCompilerType::makeConverted(IREmitter& emitter
CompilerVariable
*
ConcreteCompilerType
::
dup
(
ConcreteCompilerVariable
*
v
,
DupCache
&
cache
)
{
CompilerVariable
*
ConcreteCompilerType
::
dup
(
ConcreteCompilerVariable
*
v
,
DupCache
&
cache
)
{
auto
&
rtn
=
cache
[
v
];
auto
&
rtn
=
cache
[
v
];
if
(
rtn
==
NULL
)
{
if
(
rtn
==
NULL
)
{
rtn
=
new
ConcreteCompilerVariable
(
this
,
v
->
getValue
(),
v
->
isGrabbed
());
rtn
=
new
ConcreteCompilerVariable
(
this
,
v
->
getValue
());
while
(
rtn
->
getVrefs
()
<
v
->
getVrefs
())
rtn
->
incvref
();
}
}
return
rtn
;
return
rtn
;
}
}
...
@@ -231,9 +213,6 @@ public:
...
@@ -231,9 +213,6 @@ public:
std
::
string
debugName
()
override
{
return
"AnyBox"
;
}
std
::
string
debugName
()
override
{
return
"AnyBox"
;
}
void
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
emitter
.
getGC
()
->
dropPointer
(
emitter
,
var
->
getValue
());
}
void
grab
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
emitter
.
getGC
()
->
grabPointer
(
emitter
,
var
->
getValue
());
}
bool
isFitBy
(
BoxedClass
*
c
)
override
{
return
true
;
}
bool
isFitBy
(
BoxedClass
*
c
)
override
{
return
true
;
}
CompilerVariable
*
getattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
BoxedString
*
attr
,
CompilerVariable
*
getattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
BoxedString
*
attr
,
...
@@ -270,7 +249,6 @@ public:
...
@@ -270,7 +249,6 @@ public:
}
else
{
}
else
{
emitter
.
createCall3
(
info
.
unw_info
,
g
.
funcs
.
setattr
,
var
->
getValue
(),
ptr
,
converted
->
getValue
());
emitter
.
createCall3
(
info
.
unw_info
,
g
.
funcs
.
setattr
,
var
->
getValue
(),
ptr
,
converted
->
getValue
());
}
}
converted
->
decvref
(
emitter
);
}
}
void
delattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
BoxedString
*
attr
)
override
{
void
delattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
BoxedString
*
attr
)
override
{
...
@@ -317,7 +295,6 @@ public:
...
@@ -317,7 +295,6 @@ public:
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
,
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
,
ConcreteCompilerType
*
other_type
)
override
{
ConcreteCompilerType
*
other_type
)
override
{
if
(
other_type
==
this
)
{
if
(
other_type
==
this
)
{
var
->
incvref
();
return
var
;
return
var
;
}
}
fprintf
(
stderr
,
"Can't convert unknown to %s...
\n
"
,
other_type
->
debugName
().
c_str
());
fprintf
(
stderr
,
"Can't convert unknown to %s...
\n
"
,
other_type
->
debugName
().
c_str
());
...
@@ -363,7 +340,7 @@ public:
...
@@ -363,7 +340,7 @@ public:
emitter
.
checkAndPropagateCapiException
(
info
.
unw_info
,
r
,
getNullPtr
(
g
.
llvm_value_type_ptr
));
emitter
.
checkAndPropagateCapiException
(
info
.
unw_info
,
r
,
getNullPtr
(
g
.
llvm_value_type_ptr
));
return
new
ConcreteCompilerVariable
(
static_cast
<
ConcreteCompilerType
*>
(
return_type
),
r
,
true
);
return
new
ConcreteCompilerVariable
(
static_cast
<
ConcreteCompilerType
*>
(
return_type
),
r
);
}
}
}
}
...
@@ -389,12 +366,11 @@ public:
...
@@ -389,12 +366,11 @@ public:
target_exception_style
==
CAPI
?
g
.
funcs
.
getitem_capi
:
g
.
funcs
.
getitem
,
target_exception_style
==
CAPI
?
g
.
funcs
.
getitem_capi
:
g
.
funcs
.
getitem
,
var
->
getValue
(),
converted_slice
->
getValue
(),
target_exception_style
);
var
->
getValue
(),
converted_slice
->
getValue
(),
target_exception_style
);
}
}
converted_slice
->
decvref
(
emitter
);
if
(
target_exception_style
==
CAPI
)
if
(
target_exception_style
==
CAPI
)
emitter
.
checkAndPropagateCapiException
(
info
.
unw_info
,
rtn
,
getNullPtr
(
g
.
llvm_value_type_ptr
));
emitter
.
checkAndPropagateCapiException
(
info
.
unw_info
,
rtn
,
getNullPtr
(
g
.
llvm_value_type_ptr
));
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
rtn
,
true
);
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
rtn
);
}
}
CompilerVariable
*
getPystonIter
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
)
override
{
CompilerVariable
*
getPystonIter
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
)
override
{
...
@@ -407,7 +383,6 @@ public:
...
@@ -407,7 +383,6 @@ public:
// If the type analysis could determine the iter type is a valid pyston iter (has 'hasnext') we are finished.
// If the type analysis could determine the iter type is a valid pyston iter (has 'hasnext') we are finished.
CompilerType
*
iter_type
=
var
->
getType
()
->
getPystonIterType
();
CompilerType
*
iter_type
=
var
->
getType
()
->
getPystonIterType
();
if
(
iter_type
!=
UNKNOWN
)
{
if
(
iter_type
!=
UNKNOWN
)
{
iter_call
->
decvref
(
emitter
);
return
converted_iter_call
;
return
converted_iter_call
;
}
}
...
@@ -444,10 +419,7 @@ public:
...
@@ -444,10 +419,7 @@ public:
phi
->
addIncoming
(
value_has_iter
,
value_has_iter_bb
);
phi
->
addIncoming
(
value_has_iter
,
value_has_iter_bb
);
phi
->
addIncoming
(
value_no_iter
,
value_no_iter_bb
);
phi
->
addIncoming
(
value_no_iter
,
value_no_iter_bb
);
converted_iter_call
->
decvref
(
emitter
);
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
phi
);
iter_call
->
decvref
(
emitter
);
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
phi
,
true
);
}
}
CompilerVariable
*
binexp
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
CompilerVariable
*
rhs
,
CompilerVariable
*
binexp
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
CompilerVariable
*
rhs
,
...
@@ -485,15 +457,13 @@ public:
...
@@ -485,15 +457,13 @@ public:
getConstantInt
(
op_type
,
g
.
i32
));
getConstantInt
(
op_type
,
g
.
i32
));
}
}
converted_rhs
->
decvref
(
emitter
);
if
(
op_type
==
AST_TYPE
::
In
||
op_type
==
AST_TYPE
::
NotIn
||
op_type
==
AST_TYPE
::
Is
if
(
op_type
==
AST_TYPE
::
In
||
op_type
==
AST_TYPE
::
NotIn
||
op_type
==
AST_TYPE
::
Is
||
op_type
==
AST_TYPE
::
IsNot
)
{
||
op_type
==
AST_TYPE
::
IsNot
)
{
llvm
::
Value
*
unboxed
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
unboxBool
,
rtn
);
llvm
::
Value
*
unboxed
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
unboxBool
,
rtn
);
return
boolFromI1
(
emitter
,
unboxed
);
return
boolFromI1
(
emitter
,
unboxed
);
}
}
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
rtn
,
true
);
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
rtn
);
}
}
CompilerVariable
*
contains
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
CompilerVariable
*
lhs
)
override
{
CompilerVariable
*
contains
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
CompilerVariable
*
lhs
)
override
{
...
@@ -516,7 +486,7 @@ public:
...
@@ -516,7 +486,7 @@ public:
llvm
::
Value
*
val
=
emitter
.
getBuilder
()
->
CreateLoad
(
ptr
);
llvm
::
Value
*
val
=
emitter
.
getBuilder
()
->
CreateLoad
(
ptr
);
assert
(
val
->
getType
()
==
g
.
llvm_value_type_ptr
);
assert
(
val
->
getType
()
==
g
.
llvm_value_type_ptr
);
rtn
.
push_back
(
new
ConcreteCompilerVariable
(
UNKNOWN
,
val
,
true
));
rtn
.
push_back
(
new
ConcreteCompilerVariable
(
UNKNOWN
,
val
));
}
}
return
rtn
;
return
rtn
;
}
}
...
@@ -569,7 +539,7 @@ CompilerVariable* UnknownType::getattr(IREmitter& emitter, const OpInfo& info, C
...
@@ -569,7 +539,7 @@ CompilerVariable* UnknownType::getattr(IREmitter& emitter, const OpInfo& info, C
if
(
target_exception_style
==
CAPI
)
if
(
target_exception_style
==
CAPI
)
emitter
.
checkAndPropagateCapiException
(
info
.
unw_info
,
rtn_val
,
getNullPtr
(
g
.
llvm_value_type_ptr
));
emitter
.
checkAndPropagateCapiException
(
info
.
unw_info
,
rtn_val
,
getNullPtr
(
g
.
llvm_value_type_ptr
));
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
rtn_val
,
true
);
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
rtn_val
);
}
}
static
ConcreteCompilerVariable
*
_call
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
llvm
::
Value
*
func
,
static
ConcreteCompilerVariable
*
_call
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
llvm
::
Value
*
func
,
...
@@ -669,17 +639,13 @@ static ConcreteCompilerVariable* _call(IREmitter& emitter, const OpInfo& info, l
...
@@ -669,17 +639,13 @@ static ConcreteCompilerVariable* _call(IREmitter& emitter, const OpInfo& info, l
rtn
=
emitter
.
createCall
(
info
.
unw_info
,
func
,
llvm_args
,
target_exception_style
);
rtn
=
emitter
.
createCall
(
info
.
unw_info
,
func
,
llvm_args
,
target_exception_style
);
}
}
for
(
int
i
=
0
;
i
<
args
.
size
();
i
++
)
{
converted_args
[
i
]
->
decvref
(
emitter
);
}
assert
(
rtn
->
getType
()
==
rtn_type
->
llvmType
());
assert
(
rtn
->
getType
()
==
rtn_type
->
llvmType
());
if
(
target_exception_style
==
CAPI
)
{
if
(
target_exception_style
==
CAPI
)
{
emitter
.
checkAndPropagateCapiException
(
info
.
unw_info
,
rtn
,
getNullPtr
(
g
.
llvm_value_type_ptr
));
emitter
.
checkAndPropagateCapiException
(
info
.
unw_info
,
rtn
,
getNullPtr
(
g
.
llvm_value_type_ptr
));
}
}
return
new
ConcreteCompilerVariable
(
rtn_type
,
rtn
,
true
);
return
new
ConcreteCompilerVariable
(
rtn_type
,
rtn
);
}
}
CompilerVariable
*
UnknownType
::
call
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
CompilerVariable
*
UnknownType
::
call
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
...
@@ -787,9 +753,7 @@ ConcreteCompilerVariable* UnknownType::unaryop(IREmitter& emitter, const OpInfo&
...
@@ -787,9 +753,7 @@ ConcreteCompilerVariable* UnknownType::unaryop(IREmitter& emitter, const OpInfo&
getConstantInt
(
op_type
,
g
.
i32
));
getConstantInt
(
op_type
,
g
.
i32
));
}
}
converted
->
decvref
(
emitter
);
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
rtn
);
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
rtn
,
true
);
}
}
ConcreteCompilerVariable
*
UnknownType
::
hasnext
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
)
{
ConcreteCompilerVariable
*
UnknownType
::
hasnext
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
)
{
...
@@ -848,9 +812,7 @@ CompilerVariable* makeFunction(IREmitter& emitter, FunctionMetadata* f, Compiler
...
@@ -848,9 +812,7 @@ CompilerVariable* makeFunction(IREmitter& emitter, FunctionMetadata* f, Compiler
std
::
vector
<
llvm
::
Value
*>
{
embedRelocatablePtr
(
f
,
g
.
llvm_functionmetadata_type_ptr
),
closure_v
,
globals
,
std
::
vector
<
llvm
::
Value
*>
{
embedRelocatablePtr
(
f
,
g
.
llvm_functionmetadata_type_ptr
),
closure_v
,
globals
,
scratch
,
getConstantInt
(
defaults
.
size
(),
g
.
i64
)
});
scratch
,
getConstantInt
(
defaults
.
size
(),
g
.
i64
)
});
if
(
convertedClosure
)
return
new
ConcreteCompilerVariable
(
typeFromClass
(
function_cls
),
boxed
);
convertedClosure
->
decvref
(
emitter
);
return
new
ConcreteCompilerVariable
(
typeFromClass
(
function_cls
),
boxed
,
true
);
}
}
class
AbstractFunctionType
:
public
CompilerType
{
class
AbstractFunctionType
:
public
CompilerType
{
...
@@ -965,22 +927,12 @@ public:
...
@@ -965,22 +927,12 @@ public:
// Subclasses need to implement:
// Subclasses need to implement:
// _makeConverted
// _makeConverted
// _dup
// _dup
// _drop
// _numFrameArgs
// _numFrameArgs
// _serializeToFrame
// _serializeToFrame
// _deserializeFromFrame
// _deserializeFromFrame
typedef
UnboxedVal
<
T
>
Unboxed
;
typedef
UnboxedVal
<
T
>
Unboxed
;
typedef
typename
ValuedCompilerType
<
std
::
shared_ptr
<
UnboxedVal
<
T
>>>::
VAR
VAR
;
typedef
typename
ValuedCompilerType
<
std
::
shared_ptr
<
UnboxedVal
<
T
>>>::
VAR
VAR
;
void
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
override
final
{
auto
v
=
var
->
getValue
();
if
(
v
->
boxed
)
v
->
boxed
->
decvref
(
emitter
);
static_cast
<
D
*>
(
this
)
->
_drop
(
emitter
,
v
->
val
);
}
void
grab
(
IREmitter
&
emitter
,
VAR
*
var
)
override
final
{
RELEASE_ASSERT
(
0
,
""
);
}
void
assertMatches
(
std
::
shared_ptr
<
Unboxed
>
val
)
override
final
{
void
assertMatches
(
std
::
shared_ptr
<
Unboxed
>
val
)
override
final
{
static_cast
<
D
*>
(
this
)
->
_assertMatches
(
val
->
val
);
static_cast
<
D
*>
(
this
)
->
_assertMatches
(
val
->
val
);
assert
(
!
val
->
boxed
||
val
->
boxed
->
getType
()
==
static_cast
<
D
*>
(
this
)
->
getBoxType
());
assert
(
!
val
->
boxed
||
val
->
boxed
->
getType
()
==
static_cast
<
D
*>
(
this
)
->
getBoxType
());
...
@@ -999,9 +951,7 @@ public:
...
@@ -999,9 +951,7 @@ public:
auto
val
auto
val
=
std
::
make_shared
<
Unboxed
>
(
std
::
move
(
val_duped
),
static_cast
<
ConcreteCompilerVariable
*>
(
box_duped
));
=
std
::
make_shared
<
Unboxed
>
(
std
::
move
(
val_duped
),
static_cast
<
ConcreteCompilerVariable
*>
(
box_duped
));
rtn
=
new
VAR
(
this
,
val
,
var
->
isGrabbed
());
rtn
=
new
VAR
(
this
,
val
);
while
(
rtn
->
getVrefs
()
<
var
->
getVrefs
())
rtn
->
incvref
();
}
}
return
rtn
;
return
rtn
;
}
}
...
@@ -1032,7 +982,6 @@ public:
...
@@ -1032,7 +982,6 @@ public:
return
boxed
->
makeConverted
(
emitter
,
other_type
);
return
boxed
->
makeConverted
(
emitter
,
other_type
);
}
}
boxed
->
incvref
();
return
boxed
;
return
boxed
;
}
}
...
@@ -1082,8 +1031,6 @@ class IntType : public UnboxedType<llvm::Value*, IntType> {
...
@@ -1082,8 +1031,6 @@ class IntType : public UnboxedType<llvm::Value*, IntType> {
public:
public:
IntType
()
{}
IntType
()
{}
void
_drop
(
IREmitter
&
emitter
,
llvm
::
Value
*
v
)
{}
llvm
::
Value
*
_dup
(
llvm
::
Value
*
v
,
DupCache
&
cache
)
{
return
v
;
}
llvm
::
Value
*
_dup
(
llvm
::
Value
*
v
,
DupCache
&
cache
)
{
return
v
;
}
void
_assertMatches
(
llvm
::
Value
*
v
)
{
assert
(
v
->
getType
()
==
g
.
i64
);
}
void
_assertMatches
(
llvm
::
Value
*
v
)
{
assert
(
v
->
getType
()
==
g
.
i64
);
}
...
@@ -1145,7 +1092,6 @@ public:
...
@@ -1145,7 +1092,6 @@ public:
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
override
{
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_INT
);
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_INT
);
CompilerVariable
*
rtn
=
converted
->
callattr
(
emitter
,
info
,
attr
,
flags
,
args
,
keyword_names
);
CompilerVariable
*
rtn
=
converted
->
callattr
(
emitter
,
info
,
attr
,
flags
,
args
,
keyword_names
);
converted
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -1153,7 +1099,6 @@ public:
...
@@ -1153,7 +1099,6 @@ public:
bool
cls_only
)
override
{
bool
cls_only
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_INT
);
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_INT
);
CompilerVariable
*
rtn
=
converted
->
getattr
(
emitter
,
info
,
attr
,
cls_only
);
CompilerVariable
*
rtn
=
converted
->
getattr
(
emitter
,
info
,
attr
,
cls_only
);
converted
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -1180,13 +1125,12 @@ public:
...
@@ -1180,13 +1125,12 @@ public:
}
else
{
}
else
{
boxed
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
boxInt
,
unboxed
);
boxed
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
boxInt
,
unboxed
);
}
}
return
new
ConcreteCompilerVariable
(
other_type
,
boxed
,
true
);
return
new
ConcreteCompilerVariable
(
other_type
,
boxed
);
}
}
CompilerVariable
*
getitem
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
CompilerVariable
*
slice
)
override
{
CompilerVariable
*
getitem
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
CompilerVariable
*
slice
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_INT
);
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_INT
);
CompilerVariable
*
rtn
=
converted
->
getitem
(
emitter
,
info
,
slice
);
CompilerVariable
*
rtn
=
converted
->
getitem
(
emitter
,
info
,
slice
);
converted
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -1218,7 +1162,6 @@ public:
...
@@ -1218,7 +1162,6 @@ public:
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_INT
);
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_INT
);
auto
rtn
=
converted
->
unaryop
(
emitter
,
info
,
op_type
);
auto
rtn
=
converted
->
unaryop
(
emitter
,
info
,
op_type
);
converted
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -1238,7 +1181,6 @@ public:
...
@@ -1238,7 +1181,6 @@ public:
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_INT
);
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_INT
);
CompilerVariable
*
rtn
=
converted
->
binexp
(
emitter
,
info
,
rhs
,
op_type
,
exp_type
);
CompilerVariable
*
rtn
=
converted
->
binexp
(
emitter
,
info
,
rhs
,
op_type
,
exp_type
);
converted
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -1326,7 +1268,7 @@ public:
...
@@ -1326,7 +1268,7 @@ public:
llvm
::
CallSite
call
llvm
::
CallSite
call
=
emitter
.
createCall
(
info
.
unw_info
,
g
.
funcs
.
raiseNotIterableError
,
embedConstantPtr
(
"int"
,
g
.
i8_ptr
));
=
emitter
.
createCall
(
info
.
unw_info
,
g
.
funcs
.
raiseNotIterableError
,
embedConstantPtr
(
"int"
,
g
.
i8_ptr
));
call
.
setDoesNotReturn
();
call
.
setDoesNotReturn
();
return
new
ConcreteCompilerVariable
(
BOOL
,
llvm
::
UndefValue
::
get
(
BOOL
->
llvmType
())
,
true
);
return
new
ConcreteCompilerVariable
(
BOOL
,
llvm
::
UndefValue
::
get
(
BOOL
->
llvmType
()));
}
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
BOXED_INT
;
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
BOXED_INT
;
}
...
@@ -1350,7 +1292,7 @@ CompilerType* INT = &_INT;
...
@@ -1350,7 +1292,7 @@ CompilerType* INT = &_INT;
CompilerVariable
*
makeInt
(
llvm
::
Value
*
n
)
{
CompilerVariable
*
makeInt
(
llvm
::
Value
*
n
)
{
assert
(
n
->
getType
()
==
g
.
i64
);
assert
(
n
->
getType
()
==
g
.
i64
);
return
new
IntType
::
VAR
(
&
_INT
,
std
::
make_shared
<
IntType
::
Unboxed
>
(
n
,
nullptr
)
,
true
);
return
new
IntType
::
VAR
(
&
_INT
,
std
::
make_shared
<
IntType
::
Unboxed
>
(
n
,
nullptr
));
}
}
CompilerVariable
*
makeInt
(
int64_t
n
)
{
CompilerVariable
*
makeInt
(
int64_t
n
)
{
...
@@ -1360,12 +1302,12 @@ CompilerVariable* makeInt(int64_t n) {
...
@@ -1360,12 +1302,12 @@ CompilerVariable* makeInt(int64_t n) {
CompilerVariable
*
makeUnboxedInt
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
v
)
{
CompilerVariable
*
makeUnboxedInt
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
v
)
{
assert
(
v
->
getType
()
==
BOXED_INT
);
assert
(
v
->
getType
()
==
BOXED_INT
);
llvm
::
Value
*
unboxed
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
unboxInt
,
v
->
getValue
());
llvm
::
Value
*
unboxed
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
unboxInt
,
v
->
getValue
());
return
new
IntType
::
VAR
(
&
_INT
,
std
::
make_shared
<
IntType
::
Unboxed
>
(
unboxed
,
v
)
,
true
);
return
new
IntType
::
VAR
(
&
_INT
,
std
::
make_shared
<
IntType
::
Unboxed
>
(
unboxed
,
v
));
}
}
CompilerVariable
*
makeUnboxedInt
(
IREmitter
&
emitter
,
llvm
::
Value
*
v
)
{
CompilerVariable
*
makeUnboxedInt
(
IREmitter
&
emitter
,
llvm
::
Value
*
v
)
{
assert
(
v
->
getType
()
==
g
.
llvm_value_type_ptr
);
assert
(
v
->
getType
()
==
g
.
llvm_value_type_ptr
);
return
makeUnboxedInt
(
emitter
,
new
ConcreteCompilerVariable
(
BOXED_INT
,
v
,
false
));
return
makeUnboxedInt
(
emitter
,
new
ConcreteCompilerVariable
(
BOXED_INT
,
v
));
}
}
class
FloatType
:
public
UnboxedType
<
llvm
::
Value
*
,
FloatType
>
{
class
FloatType
:
public
UnboxedType
<
llvm
::
Value
*
,
FloatType
>
{
...
@@ -1374,10 +1316,6 @@ public:
...
@@ -1374,10 +1316,6 @@ public:
std
::
string
debugName
()
override
{
return
"float"
;
}
std
::
string
debugName
()
override
{
return
"float"
;
}
void
_drop
(
IREmitter
&
emitter
,
llvm
::
Value
*
v
)
{
// pass
}
void
_assertMatches
(
llvm
::
Value
*
v
)
{
assert
(
v
->
getType
()
==
g
.
double_
);
}
void
_assertMatches
(
llvm
::
Value
*
v
)
{
assert
(
v
->
getType
()
==
g
.
double_
);
}
llvm
::
Value
*
_dup
(
llvm
::
Value
*
v
,
DupCache
&
cache
)
{
return
v
;
}
llvm
::
Value
*
_dup
(
llvm
::
Value
*
v
,
DupCache
&
cache
)
{
return
v
;
}
...
@@ -1420,7 +1358,6 @@ public:
...
@@ -1420,7 +1358,6 @@ public:
bool
cls_only
)
override
{
bool
cls_only
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_FLOAT
);
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_FLOAT
);
CompilerVariable
*
rtn
=
converted
->
getattr
(
emitter
,
info
,
attr
,
cls_only
);
CompilerVariable
*
rtn
=
converted
->
getattr
(
emitter
,
info
,
attr
,
cls_only
);
converted
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -1429,7 +1366,6 @@ public:
...
@@ -1429,7 +1366,6 @@ public:
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
override
{
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_FLOAT
);
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_FLOAT
);
CompilerVariable
*
rtn
=
converted
->
callattr
(
emitter
,
info
,
attr
,
flags
,
args
,
keyword_names
);
CompilerVariable
*
rtn
=
converted
->
callattr
(
emitter
,
info
,
attr
,
flags
,
args
,
keyword_names
);
converted
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -1458,7 +1394,7 @@ public:
...
@@ -1458,7 +1394,7 @@ public:
}
else
{
}
else
{
boxed
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
boxFloat
,
unboxed
);
boxed
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
boxFloat
,
unboxed
);
}
}
return
new
ConcreteCompilerVariable
(
other_type
,
boxed
,
true
);
return
new
ConcreteCompilerVariable
(
other_type
,
boxed
);
}
}
ConcreteCompilerVariable
*
nonzero
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
)
override
{
ConcreteCompilerVariable
*
nonzero
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
)
override
{
...
@@ -1470,14 +1406,12 @@ public:
...
@@ -1470,14 +1406,12 @@ public:
CompilerVariable
*
unaryop
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
AST_TYPE
::
AST_TYPE
op_type
)
override
{
CompilerVariable
*
unaryop
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
AST_TYPE
::
AST_TYPE
op_type
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_FLOAT
);
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_FLOAT
);
auto
rtn
=
converted
->
unaryop
(
emitter
,
info
,
op_type
);
auto
rtn
=
converted
->
unaryop
(
emitter
,
info
,
op_type
);
converted
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
CompilerVariable
*
getitem
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
CompilerVariable
*
slice
)
override
{
CompilerVariable
*
getitem
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
CompilerVariable
*
slice
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_FLOAT
);
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_FLOAT
);
CompilerVariable
*
rtn
=
converted
->
getitem
(
emitter
,
info
,
slice
);
CompilerVariable
*
rtn
=
converted
->
getitem
(
emitter
,
info
,
slice
);
converted
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -1488,7 +1422,6 @@ public:
...
@@ -1488,7 +1422,6 @@ public:
if
(
rhs
->
getType
()
!=
INT
&&
rhs
->
getType
()
!=
FLOAT
)
{
if
(
rhs
->
getType
()
!=
INT
&&
rhs
->
getType
()
!=
FLOAT
)
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_FLOAT
);
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_FLOAT
);
CompilerVariable
*
rtn
=
converted
->
binexp
(
emitter
,
info
,
rhs
,
op_type
,
exp_type
);
CompilerVariable
*
rtn
=
converted
->
binexp
(
emitter
,
info
,
rhs
,
op_type
,
exp_type
);
converted
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -1585,7 +1518,6 @@ public:
...
@@ -1585,7 +1518,6 @@ public:
// TODO duplication with top of function, other functions, etc
// TODO duplication with top of function, other functions, etc
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_FLOAT
);
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_FLOAT
);
CompilerVariable
*
rtn
=
converted
->
binexp
(
emitter
,
info
,
rhs
,
op_type
,
exp_type
);
CompilerVariable
*
rtn
=
converted
->
binexp
(
emitter
,
info
,
rhs
,
op_type
,
exp_type
);
converted
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -1593,7 +1525,7 @@ public:
...
@@ -1593,7 +1525,7 @@ public:
llvm
::
CallSite
call
llvm
::
CallSite
call
=
emitter
.
createCall
(
info
.
unw_info
,
g
.
funcs
.
raiseNotIterableError
,
embedConstantPtr
(
"float"
,
g
.
i8_ptr
));
=
emitter
.
createCall
(
info
.
unw_info
,
g
.
funcs
.
raiseNotIterableError
,
embedConstantPtr
(
"float"
,
g
.
i8_ptr
));
call
.
setDoesNotReturn
();
call
.
setDoesNotReturn
();
return
new
ConcreteCompilerVariable
(
BOOL
,
llvm
::
UndefValue
::
get
(
BOOL
->
llvmType
())
,
true
);
return
new
ConcreteCompilerVariable
(
BOOL
,
llvm
::
UndefValue
::
get
(
BOOL
->
llvmType
()));
}
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
BOXED_FLOAT
;
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
BOXED_FLOAT
;
}
...
@@ -1633,7 +1565,7 @@ ConcreteCompilerType* UNBOXED_FLOAT = new PhonyUnboxedType(llvm::Type::getDouble
...
@@ -1633,7 +1565,7 @@ ConcreteCompilerType* UNBOXED_FLOAT = new PhonyUnboxedType(llvm::Type::getDouble
CompilerVariable
*
makeFloat
(
llvm
::
Value
*
n
)
{
CompilerVariable
*
makeFloat
(
llvm
::
Value
*
n
)
{
assert
(
n
->
getType
()
==
g
.
double_
);
assert
(
n
->
getType
()
==
g
.
double_
);
return
new
FloatType
::
VAR
(
&
_FLOAT
,
std
::
make_shared
<
FloatType
::
Unboxed
>
(
n
,
nullptr
)
,
true
);
return
new
FloatType
::
VAR
(
&
_FLOAT
,
std
::
make_shared
<
FloatType
::
Unboxed
>
(
n
,
nullptr
));
}
}
CompilerVariable
*
makeFloat
(
double
n
)
{
CompilerVariable
*
makeFloat
(
double
n
)
{
...
@@ -1643,21 +1575,21 @@ CompilerVariable* makeFloat(double n) {
...
@@ -1643,21 +1575,21 @@ CompilerVariable* makeFloat(double n) {
CompilerVariable
*
makeUnboxedFloat
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
v
)
{
CompilerVariable
*
makeUnboxedFloat
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
v
)
{
assert
(
v
->
getType
()
==
BOXED_FLOAT
);
assert
(
v
->
getType
()
==
BOXED_FLOAT
);
llvm
::
Value
*
unboxed
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
unboxFloat
,
v
->
getValue
());
llvm
::
Value
*
unboxed
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
unboxFloat
,
v
->
getValue
());
return
new
FloatType
::
VAR
(
&
_FLOAT
,
std
::
make_shared
<
FloatType
::
Unboxed
>
(
unboxed
,
v
)
,
true
);
return
new
FloatType
::
VAR
(
&
_FLOAT
,
std
::
make_shared
<
FloatType
::
Unboxed
>
(
unboxed
,
v
));
}
}
CompilerVariable
*
makeUnboxedFloat
(
IREmitter
&
emitter
,
llvm
::
Value
*
v
)
{
CompilerVariable
*
makeUnboxedFloat
(
IREmitter
&
emitter
,
llvm
::
Value
*
v
)
{
assert
(
v
->
getType
()
==
g
.
llvm_value_type_ptr
);
assert
(
v
->
getType
()
==
g
.
llvm_value_type_ptr
);
return
makeUnboxedFloat
(
emitter
,
new
ConcreteCompilerVariable
(
BOXED_FLOAT
,
v
,
false
));
return
makeUnboxedFloat
(
emitter
,
new
ConcreteCompilerVariable
(
BOXED_FLOAT
,
v
));
}
}
ConcreteCompilerVariable
*
makeLong
(
Box
*
v
)
{
ConcreteCompilerVariable
*
makeLong
(
Box
*
v
)
{
return
new
ConcreteCompilerVariable
(
LONG
,
embedRelocatablePtr
(
v
,
g
.
llvm_value_type_ptr
)
,
true
);
return
new
ConcreteCompilerVariable
(
LONG
,
embedRelocatablePtr
(
v
,
g
.
llvm_value_type_ptr
));
}
}
ConcreteCompilerVariable
*
makePureImaginary
(
Box
*
v
)
{
ConcreteCompilerVariable
*
makePureImaginary
(
Box
*
v
)
{
return
new
ConcreteCompilerVariable
(
BOXED_COMPLEX
,
embedRelocatablePtr
(
v
,
g
.
llvm_value_type_ptr
)
,
true
);
return
new
ConcreteCompilerVariable
(
BOXED_COMPLEX
,
embedRelocatablePtr
(
v
,
g
.
llvm_value_type_ptr
));
}
}
class
KnownClassobjType
:
public
ValuedCompilerType
<
BoxedClass
*>
{
class
KnownClassobjType
:
public
ValuedCompilerType
<
BoxedClass
*>
{
...
@@ -1726,17 +1658,12 @@ public:
...
@@ -1726,17 +1658,12 @@ public:
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
,
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
,
ConcreteCompilerType
*
other_type
)
override
{
ConcreteCompilerType
*
other_type
)
override
{
if
(
other_type
==
this
)
{
if
(
other_type
==
this
)
{
var
->
incvref
();
return
var
;
return
var
;
}
}
ASSERT
(
other_type
==
UNKNOWN
,
"%s"
,
other_type
->
debugName
().
c_str
());
ASSERT
(
other_type
==
UNKNOWN
,
"%s"
,
other_type
->
debugName
().
c_str
());
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
var
->
getValue
(),
false
);
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
var
->
getValue
());
// return (new ConcreteCompilerVariable(UNKNOWN, var->getValue(), false))->split(emitter);
}
}
void
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
emitter
.
getGC
()
->
dropPointer
(
emitter
,
var
->
getValue
());
}
void
grab
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
emitter
.
getGC
()
->
grabPointer
(
emitter
,
var
->
getValue
());
}
bool
isFitBy
(
BoxedClass
*
c
)
override
{
bool
isFitBy
(
BoxedClass
*
c
)
override
{
// I don't think it's ok to accept subclasses
// I don't think it's ok to accept subclasses
return
c
==
cls
;
return
c
==
cls
;
...
@@ -1795,11 +1722,11 @@ public:
...
@@ -1795,11 +1722,11 @@ public:
ASSERT
(
rtattr
,
"%s.%s"
,
debugName
().
c_str
(),
attr
->
data
());
ASSERT
(
rtattr
,
"%s.%s"
,
debugName
().
c_str
(),
attr
->
data
());
if
(
rtattr
->
cls
==
function_cls
)
{
if
(
rtattr
->
cls
==
function_cls
)
{
CompilerVariable
*
clattr
=
new
ConcreteCompilerVariable
(
CompilerVariable
*
clattr
=
new
ConcreteCompilerVariable
(
typeFromClass
(
function_cls
),
embedRelocatablePtr
(
rtattr
,
g
.
llvm_value_type_ptr
)
,
false
);
typeFromClass
(
function_cls
),
embedRelocatablePtr
(
rtattr
,
g
.
llvm_value_type_ptr
));
return
InstanceMethodType
::
makeIM
(
return
InstanceMethodType
::
makeIM
(
var
,
clattr
,
var
,
clattr
,
new
ConcreteCompilerVariable
(
UNKNOWN
,
embedRelocatablePtr
(
cls
,
g
.
llvm_value_type_ptr
)
,
false
));
new
ConcreteCompilerVariable
(
UNKNOWN
,
embedRelocatablePtr
(
cls
,
g
.
llvm_value_type_ptr
)));
}
}
}
}
...
@@ -1821,7 +1748,6 @@ public:
...
@@ -1821,7 +1748,6 @@ public:
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
override
{
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
UNKNOWN
);
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
UNKNOWN
);
CompilerVariable
*
rtn
=
converted
->
call
(
emitter
,
info
,
argspec
,
args
,
keyword_names
);
CompilerVariable
*
rtn
=
converted
->
call
(
emitter
,
info
,
argspec
,
args
,
keyword_names
);
converted
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -1949,7 +1875,7 @@ public:
...
@@ -1949,7 +1875,7 @@ public:
else
else
llvm_value
=
getNullPtr
(
g
.
llvm_value_type_ptr
);
llvm_value
=
getNullPtr
(
g
.
llvm_value_type_ptr
);
new_args
.
push_back
(
new
ConcreteCompilerVariable
(
UNKNOWN
,
llvm_value
,
true
));
new_args
.
push_back
(
new
ConcreteCompilerVariable
(
UNKNOWN
,
llvm_value
));
}
}
std
::
vector
<
llvm
::
Value
*>
other_args
;
std
::
vector
<
llvm
::
Value
*>
other_args
;
...
@@ -1993,7 +1919,6 @@ public:
...
@@ -1993,7 +1919,6 @@ public:
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
UNKNOWN
);
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
UNKNOWN
);
CompilerVariable
*
rtn
=
converted
->
callattr
(
emitter
,
info
,
attr
,
flags
,
args
,
keyword_names
);
CompilerVariable
*
rtn
=
converted
->
callattr
(
emitter
,
info
,
attr
,
flags
,
args
,
keyword_names
);
converted
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -2021,20 +1946,17 @@ public:
...
@@ -2021,20 +1946,17 @@ public:
// Kind of hacky, but just call into getitem like normal. except...
// Kind of hacky, but just call into getitem like normal. except...
auto
r
=
UNKNOWN
->
binexp
(
emitter
,
info
,
var
,
converted_rhs
,
op_type
,
exp_type
);
auto
r
=
UNKNOWN
->
binexp
(
emitter
,
info
,
var
,
converted_rhs
,
op_type
,
exp_type
);
r
->
decvref
(
emitter
);
// ... return the undef value, since that matches what the type analyzer thought we would do.
// ... return the undef value, since that matches what the type analyzer thought we would do.
return
called_constant
;
return
called_constant
;
}
}
if
(
called_constant
)
{
if
(
called_constant
)
{
converted_rhs
->
decvref
(
emitter
);
return
called_constant
;
return
called_constant
;
}
}
}
}
}
}
auto
rtn
=
UNKNOWN
->
binexp
(
emitter
,
info
,
var
,
converted_rhs
,
op_type
,
exp_type
);
auto
rtn
=
UNKNOWN
->
binexp
(
emitter
,
info
,
var
,
converted_rhs
,
op_type
,
exp_type
);
converted_rhs
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -2087,7 +2009,7 @@ public:
...
@@ -2087,7 +2009,7 @@ public:
var
->
getValue
(),
start
,
stop
);
var
->
getValue
(),
start
,
stop
);
emitter
.
checkAndPropagateCapiException
(
info
.
unw_info
,
r
,
getNullPtr
(
g
.
llvm_value_type_ptr
));
emitter
.
checkAndPropagateCapiException
(
info
.
unw_info
,
r
,
getNullPtr
(
g
.
llvm_value_type_ptr
));
return
new
ConcreteCompilerVariable
(
static_cast
<
ConcreteCompilerType
*>
(
return_type
),
r
,
true
);
return
new
ConcreteCompilerVariable
(
static_cast
<
ConcreteCompilerType
*>
(
return_type
),
r
);
}
}
}
}
}
}
...
@@ -2106,7 +2028,6 @@ public:
...
@@ -2106,7 +2028,6 @@ public:
// Kind of hacky, but just call into getitem like normal. except...
// Kind of hacky, but just call into getitem like normal. except...
auto
r
=
UNKNOWN
->
getitem
(
emitter
,
info
,
var
,
slice
);
auto
r
=
UNKNOWN
->
getitem
(
emitter
,
info
,
var
,
slice
);
r
->
decvref
(
emitter
);
// ... return the undef value, since that matches what the type analyzer thought we would do.
// ... return the undef value, since that matches what the type analyzer thought we would do.
return
called_constant
;
return
called_constant
;
}
}
...
@@ -2227,9 +2148,6 @@ public:
...
@@ -2227,9 +2148,6 @@ public:
ConcreteCompilerType
*
getConcreteType
()
override
{
return
this
;
}
ConcreteCompilerType
*
getConcreteType
()
override
{
return
this
;
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
this
;
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
this
;
}
void
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{}
void
grab
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{}
Box
*
deserializeFromFrame
(
const
FrameVals
&
vals
)
override
{
Box
*
deserializeFromFrame
(
const
FrameVals
&
vals
)
override
{
assert
(
vals
.
size
()
==
1
);
assert
(
vals
.
size
()
==
1
);
return
reinterpret_cast
<
Box
*>
(
vals
[
0
]);
return
reinterpret_cast
<
Box
*>
(
vals
[
0
]);
...
@@ -2245,13 +2163,6 @@ public:
...
@@ -2245,13 +2163,6 @@ public:
ConcreteCompilerType
*
getConcreteType
()
override
{
return
this
;
}
ConcreteCompilerType
*
getConcreteType
()
override
{
return
this
;
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
GENERATOR
;
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
GENERATOR
;
}
void
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
// pass
}
void
grab
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
// pass
}
Box
*
deserializeFromFrame
(
const
FrameVals
&
vals
)
override
{
Box
*
deserializeFromFrame
(
const
FrameVals
&
vals
)
override
{
assert
(
vals
.
size
()
==
numFrameArgs
());
assert
(
vals
.
size
()
==
numFrameArgs
());
return
reinterpret_cast
<
Box
*>
(
vals
[
0
]);
return
reinterpret_cast
<
Box
*>
(
vals
[
0
]);
...
@@ -2267,13 +2178,6 @@ public:
...
@@ -2267,13 +2178,6 @@ public:
ConcreteCompilerType
*
getConcreteType
()
override
{
return
this
;
}
ConcreteCompilerType
*
getConcreteType
()
override
{
return
this
;
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
FRAME_INFO
;
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
FRAME_INFO
;
}
void
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
// pass
}
void
grab
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
// pass
}
Box
*
deserializeFromFrame
(
const
FrameVals
&
vals
)
override
{
Box
*
deserializeFromFrame
(
const
FrameVals
&
vals
)
override
{
RELEASE_ASSERT
(
false
,
"should not be called"
);
// This function shouldn't be called.
RELEASE_ASSERT
(
false
,
"should not be called"
);
// This function shouldn't be called.
}
}
...
@@ -2290,18 +2194,10 @@ public:
...
@@ -2290,18 +2194,10 @@ public:
ConcreteCompilerType
*
getBoxType
()
override
{
return
STR
;
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
STR
;
}
void
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
// pass
}
void
grab
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
// pass
}
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
VAR
*
var
,
ConcreteCompilerType
*
other_type
)
override
{
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
VAR
*
var
,
ConcreteCompilerType
*
other_type
)
override
{
assert
(
other_type
==
STR
||
other_type
==
UNKNOWN
);
assert
(
other_type
==
STR
||
other_type
==
UNKNOWN
);
llvm
::
Value
*
boxed
=
embedRelocatablePtr
(
var
->
getValue
(),
g
.
llvm_value_type_ptr
);
llvm
::
Value
*
boxed
=
embedRelocatablePtr
(
var
->
getValue
(),
g
.
llvm_value_type_ptr
);
return
new
ConcreteCompilerVariable
(
other_type
,
boxed
,
true
);
return
new
ConcreteCompilerVariable
(
other_type
,
boxed
);
}
}
bool
canConvertTo
(
CompilerType
*
other
)
override
{
return
(
other
==
STR
||
other
==
UNKNOWN
);
}
bool
canConvertTo
(
CompilerType
*
other
)
override
{
return
(
other
==
STR
||
other
==
UNKNOWN
);
}
...
@@ -2310,7 +2206,6 @@ public:
...
@@ -2310,7 +2206,6 @@ public:
bool
cls_only
)
override
{
bool
cls_only
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
STR
);
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
STR
);
CompilerVariable
*
rtn
=
converted
->
getattr
(
emitter
,
info
,
attr
,
cls_only
);
CompilerVariable
*
rtn
=
converted
->
getattr
(
emitter
,
info
,
attr
,
cls_only
);
converted
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -2319,14 +2214,12 @@ public:
...
@@ -2319,14 +2214,12 @@ public:
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
override
{
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
STR
);
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
STR
);
CompilerVariable
*
rtn
=
converted
->
callattr
(
emitter
,
info
,
attr
,
flags
,
args
,
keyword_names
);
CompilerVariable
*
rtn
=
converted
->
callattr
(
emitter
,
info
,
attr
,
flags
,
args
,
keyword_names
);
converted
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
CompilerVariable
*
getitem
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
CompilerVariable
*
slice
)
override
{
CompilerVariable
*
getitem
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
CompilerVariable
*
slice
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
STR
);
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
STR
);
CompilerVariable
*
rtn
=
converted
->
getitem
(
emitter
,
info
,
slice
);
CompilerVariable
*
rtn
=
converted
->
getitem
(
emitter
,
info
,
slice
);
converted
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -2334,14 +2227,12 @@ public:
...
@@ -2334,14 +2227,12 @@ public:
AST_TYPE
::
AST_TYPE
op_type
,
BinExpType
exp_type
)
override
{
AST_TYPE
::
AST_TYPE
op_type
,
BinExpType
exp_type
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
STR
);
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
STR
);
CompilerVariable
*
rtn
=
converted
->
binexp
(
emitter
,
info
,
rhs
,
op_type
,
exp_type
);
CompilerVariable
*
rtn
=
converted
->
binexp
(
emitter
,
info
,
rhs
,
op_type
,
exp_type
);
converted
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
CompilerVariable
*
contains
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
CompilerVariable
*
lhs
)
override
{
CompilerVariable
*
contains
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
CompilerVariable
*
lhs
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
STR
);
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
STR
);
CompilerVariable
*
rtn
=
converted
->
contains
(
emitter
,
info
,
lhs
);
CompilerVariable
*
rtn
=
converted
->
contains
(
emitter
,
info
,
lhs
);
converted
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -2353,9 +2244,7 @@ public:
...
@@ -2353,9 +2244,7 @@ public:
CompilerVariable
*&
rtn
=
cache
[
var
];
CompilerVariable
*&
rtn
=
cache
[
var
];
if
(
rtn
==
NULL
)
{
if
(
rtn
==
NULL
)
{
rtn
=
new
VAR
(
this
,
var
->
getValue
(),
var
->
isGrabbed
());
rtn
=
new
VAR
(
this
,
var
->
getValue
());
while
(
rtn
->
getVrefs
()
<
var
->
getVrefs
())
rtn
->
incvref
();
}
}
return
rtn
;
return
rtn
;
}
}
...
@@ -2385,7 +2274,7 @@ public:
...
@@ -2385,7 +2274,7 @@ public:
static
ValuedCompilerType
<
BoxedString
*>*
STR_CONSTANT
=
new
StrConstantType
();
static
ValuedCompilerType
<
BoxedString
*>*
STR_CONSTANT
=
new
StrConstantType
();
CompilerVariable
*
makeStr
(
BoxedString
*
s
)
{
CompilerVariable
*
makeStr
(
BoxedString
*
s
)
{
return
new
ValuedCompilerVariable
<
BoxedString
*>
(
STR_CONSTANT
,
s
,
true
);
return
new
ValuedCompilerVariable
<
BoxedString
*>
(
STR_CONSTANT
,
s
);
}
}
ConcreteCompilerType
*
typeFromClass
(
BoxedClass
*
c
)
{
ConcreteCompilerType
*
typeFromClass
(
BoxedClass
*
c
)
{
...
@@ -2405,15 +2294,7 @@ public:
...
@@ -2405,15 +2294,7 @@ public:
bool
isFitBy
(
BoxedClass
*
c
)
override
{
return
false
;
}
bool
isFitBy
(
BoxedClass
*
c
)
override
{
return
false
;
}
void
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
// pass
}
void
grab
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
// pass
}
ConcreteCompilerVariable
*
nonzero
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
)
override
{
ConcreteCompilerVariable
*
nonzero
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
)
override
{
var
->
incvref
();
return
var
;
return
var
;
}
}
...
@@ -2424,7 +2305,6 @@ public:
...
@@ -2424,7 +2305,6 @@ public:
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
,
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
,
ConcreteCompilerType
*
other_type
)
override
{
ConcreteCompilerType
*
other_type
)
override
{
if
(
other_type
==
BOOL
)
{
if
(
other_type
==
BOOL
)
{
var
->
incvref
();
return
var
;
return
var
;
}
}
...
@@ -2432,7 +2312,7 @@ public:
...
@@ -2432,7 +2312,7 @@ public:
llvm
::
Value
*
boxed
=
emitter
.
getBuilder
()
->
CreateSelect
(
i1FromBool
(
emitter
,
var
),
llvm
::
Value
*
boxed
=
emitter
.
getBuilder
()
->
CreateSelect
(
i1FromBool
(
emitter
,
var
),
embedConstantPtr
(
True
,
g
.
llvm_value_type_ptr
),
embedConstantPtr
(
True
,
g
.
llvm_value_type_ptr
),
embedConstantPtr
(
False
,
g
.
llvm_value_type_ptr
));
embedConstantPtr
(
False
,
g
.
llvm_value_type_ptr
));
return
new
ConcreteCompilerVariable
(
other_type
,
boxed
,
true
);
return
new
ConcreteCompilerVariable
(
other_type
,
boxed
);
}
}
CompilerType
*
getattrType
(
BoxedString
*
attr
,
bool
cls_only
)
override
{
CompilerType
*
getattrType
(
BoxedString
*
attr
,
bool
cls_only
)
override
{
...
@@ -2443,7 +2323,6 @@ public:
...
@@ -2443,7 +2323,6 @@ public:
bool
cls_only
)
override
{
bool
cls_only
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_BOOL
);
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_BOOL
);
CompilerVariable
*
rtn
=
converted
->
getattr
(
emitter
,
info
,
attr
,
cls_only
);
CompilerVariable
*
rtn
=
converted
->
getattr
(
emitter
,
info
,
attr
,
cls_only
);
converted
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -2452,7 +2331,6 @@ public:
...
@@ -2452,7 +2331,6 @@ public:
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
override
{
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_BOOL
);
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_BOOL
);
CompilerVariable
*
rtn
=
converted
->
callattr
(
emitter
,
info
,
attr
,
flags
,
args
,
keyword_names
);
CompilerVariable
*
rtn
=
converted
->
callattr
(
emitter
,
info
,
attr
,
flags
,
args
,
keyword_names
);
converted
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -2460,7 +2338,6 @@ public:
...
@@ -2460,7 +2338,6 @@ public:
AST_TYPE
::
AST_TYPE
op_type
,
BinExpType
exp_type
)
override
{
AST_TYPE
::
AST_TYPE
op_type
,
BinExpType
exp_type
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
UNKNOWN
);
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
UNKNOWN
);
CompilerVariable
*
rtn
=
converted
->
binexp
(
emitter
,
info
,
rhs
,
op_type
,
exp_type
);
CompilerVariable
*
rtn
=
converted
->
binexp
(
emitter
,
info
,
rhs
,
op_type
,
exp_type
);
converted
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -2468,7 +2345,7 @@ public:
...
@@ -2468,7 +2345,7 @@ public:
llvm
::
CallSite
call
llvm
::
CallSite
call
=
emitter
.
createCall
(
info
.
unw_info
,
g
.
funcs
.
raiseNotIterableError
,
embedConstantPtr
(
"bool"
,
g
.
i8_ptr
));
=
emitter
.
createCall
(
info
.
unw_info
,
g
.
funcs
.
raiseNotIterableError
,
embedConstantPtr
(
"bool"
,
g
.
i8_ptr
));
call
.
setDoesNotReturn
();
call
.
setDoesNotReturn
();
return
new
ConcreteCompilerVariable
(
BOOL
,
llvm
::
UndefValue
::
get
(
BOOL
->
llvmType
())
,
true
);
return
new
ConcreteCompilerVariable
(
BOOL
,
llvm
::
UndefValue
::
get
(
BOOL
->
llvmType
()));
}
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
BOXED_BOOL
;
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
BOXED_BOOL
;
}
...
@@ -2482,7 +2359,7 @@ public:
...
@@ -2482,7 +2359,7 @@ public:
};
};
ConcreteCompilerType
*
BOOL
=
new
BoolType
();
ConcreteCompilerType
*
BOOL
=
new
BoolType
();
ConcreteCompilerVariable
*
makeBool
(
bool
b
)
{
ConcreteCompilerVariable
*
makeBool
(
bool
b
)
{
return
new
ConcreteCompilerVariable
(
BOOL
,
llvm
::
ConstantInt
::
get
(
BOOL
->
llvmType
(),
b
,
false
)
,
true
);
return
new
ConcreteCompilerVariable
(
BOOL
,
llvm
::
ConstantInt
::
get
(
BOOL
->
llvmType
(),
b
,
false
));
}
}
ConcreteCompilerVariable
*
doIs
(
IREmitter
&
emitter
,
CompilerVariable
*
lhs
,
CompilerVariable
*
rhs
,
bool
negate
)
{
ConcreteCompilerVariable
*
doIs
(
IREmitter
&
emitter
,
CompilerVariable
*
lhs
,
CompilerVariable
*
rhs
,
bool
negate
)
{
...
@@ -2496,9 +2373,6 @@ ConcreteCompilerVariable* doIs(IREmitter& emitter, CompilerVariable* lhs, Compil
...
@@ -2496,9 +2373,6 @@ ConcreteCompilerVariable* doIs(IREmitter& emitter, CompilerVariable* lhs, Compil
else
else
cmp
=
emitter
.
getBuilder
()
->
CreateICmpNE
(
converted_left
->
getValue
(),
converted_right
->
getValue
());
cmp
=
emitter
.
getBuilder
()
->
CreateICmpNE
(
converted_left
->
getValue
(),
converted_right
->
getValue
());
converted_left
->
decvref
(
emitter
);
converted_right
->
decvref
(
emitter
);
return
boolFromI1
(
emitter
,
cmp
);
return
boolFromI1
(
emitter
,
cmp
);
}
}
...
@@ -2533,12 +2407,6 @@ public:
...
@@ -2533,12 +2407,6 @@ public:
std
::
string
debugName
()
override
{
return
name
;
}
std
::
string
debugName
()
override
{
return
name
;
}
void
_drop
(
IREmitter
&
emitter
,
const
VEC
&
val
)
{
for
(
int
i
=
0
;
i
<
val
.
size
();
i
++
)
{
val
[
i
]
->
decvref
(
emitter
);
}
}
VEC
_dup
(
const
VEC
&
orig_elts
,
DupCache
&
cache
)
{
VEC
_dup
(
const
VEC
&
orig_elts
,
DupCache
&
cache
)
{
std
::
vector
<
CompilerVariable
*>
elts
;
std
::
vector
<
CompilerVariable
*>
elts
;
...
@@ -2576,10 +2444,7 @@ public:
...
@@ -2576,10 +2444,7 @@ public:
llvm
::
Value
*
rtn
=
emitter
.
getBuilder
()
->
CreateCall2
(
g
.
funcs
.
createTuple
,
nelts
,
scratch
);
llvm
::
Value
*
rtn
=
emitter
.
getBuilder
()
->
CreateCall2
(
g
.
funcs
.
createTuple
,
nelts
,
scratch
);
for
(
int
i
=
0
;
i
<
converted_args
.
size
();
i
++
)
{
return
new
ConcreteCompilerVariable
(
other_type
,
rtn
);
converted_args
[
i
]
->
decvref
(
emitter
);
}
return
new
ConcreteCompilerVariable
(
other_type
,
rtn
,
true
);
}
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
BOXED_TUPLE
;
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
BOXED_TUPLE
;
}
...
@@ -2597,11 +2462,9 @@ public:
...
@@ -2597,11 +2462,9 @@ public:
const
VEC
*
elts
=
&
v
->
val
;
const
VEC
*
elts
=
&
v
->
val
;
if
(
i
>=
0
&&
i
<
elts
->
size
())
{
if
(
i
>=
0
&&
i
<
elts
->
size
())
{
CompilerVariable
*
rtn
=
(
*
elts
)[
i
];
CompilerVariable
*
rtn
=
(
*
elts
)[
i
];
rtn
->
incvref
();
return
rtn
;
return
rtn
;
}
else
if
(
i
<
0
&&
-
i
<=
elts
->
size
())
{
}
else
if
(
i
<
0
&&
-
i
<=
elts
->
size
())
{
CompilerVariable
*
rtn
=
(
*
elts
)[
elts
->
size
()
+
i
];
CompilerVariable
*
rtn
=
(
*
elts
)[
elts
->
size
()
+
i
];
rtn
->
incvref
();
return
rtn
;
return
rtn
;
}
else
{
}
else
{
ExceptionStyle
target_exception_style
=
info
.
preferredExceptionStyle
();
ExceptionStyle
target_exception_style
=
info
.
preferredExceptionStyle
();
...
@@ -2623,7 +2486,6 @@ public:
...
@@ -2623,7 +2486,6 @@ public:
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_TUPLE
);
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_TUPLE
);
CompilerVariable
*
rtn
=
converted
->
getitem
(
emitter
,
info
,
slice
);
CompilerVariable
*
rtn
=
converted
->
getitem
(
emitter
,
info
,
slice
);
converted
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -2639,7 +2501,6 @@ public:
...
@@ -2639,7 +2501,6 @@ public:
AST_TYPE
::
AST_TYPE
op_type
,
BinExpType
exp_type
)
override
{
AST_TYPE
::
AST_TYPE
op_type
,
BinExpType
exp_type
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
UNKNOWN
);
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
UNKNOWN
);
CompilerVariable
*
rtn
=
converted
->
binexp
(
emitter
,
info
,
rhs
,
op_type
,
exp_type
);
CompilerVariable
*
rtn
=
converted
->
binexp
(
emitter
,
info
,
rhs
,
op_type
,
exp_type
);
converted
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -2690,8 +2551,6 @@ public:
...
@@ -2690,8 +2551,6 @@ public:
phi
->
addIncoming
(
p
.
second
,
p
.
first
);
phi
->
addIncoming
(
p
.
second
,
p
.
first
);
}
}
converted_lhs
->
decvref
(
emitter
);
return
boolFromI1
(
emitter
,
phi
);
return
boolFromI1
(
emitter
,
phi
);
}
}
...
@@ -2739,10 +2598,6 @@ public:
...
@@ -2739,10 +2598,6 @@ public:
return
ValuedCompilerType
::
unpack
(
emitter
,
info
,
var
,
num_into
);
return
ValuedCompilerType
::
unpack
(
emitter
,
info
,
var
,
num_into
);
}
}
// Not sure if this is right:
for
(
auto
e
:
var
->
getValue
()
->
val
)
e
->
incvref
();
return
var
->
getValue
()
->
val
;
return
var
->
getValue
()
->
val
;
}
}
...
@@ -2762,22 +2617,18 @@ CompilerType* makeTupleType(const std::vector<CompilerType*>& elt_types) {
...
@@ -2762,22 +2617,18 @@ CompilerType* makeTupleType(const std::vector<CompilerType*>& elt_types) {
CompilerVariable
*
makeTuple
(
const
std
::
vector
<
CompilerVariable
*>&
elts
)
{
CompilerVariable
*
makeTuple
(
const
std
::
vector
<
CompilerVariable
*>&
elts
)
{
std
::
vector
<
CompilerType
*>
elt_types
;
std
::
vector
<
CompilerType
*>
elt_types
;
for
(
int
i
=
0
;
i
<
elts
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
elts
.
size
();
i
++
)
{
elts
[
i
]
->
incvref
();
elt_types
.
push_back
(
elts
[
i
]
->
getType
());
elt_types
.
push_back
(
elts
[
i
]
->
getType
());
}
}
TupleType
*
type
=
TupleType
::
make
(
elt_types
);
TupleType
*
type
=
TupleType
::
make
(
elt_types
);
auto
alloc_var
=
std
::
make_shared
<
TupleType
::
Unboxed
>
(
elts
,
nullptr
);
auto
alloc_var
=
std
::
make_shared
<
TupleType
::
Unboxed
>
(
elts
,
nullptr
);
return
new
TupleType
::
VAR
(
type
,
alloc_var
,
true
);
return
new
TupleType
::
VAR
(
type
,
alloc_var
);
}
}
class
UnboxedSliceType
:
public
ValuedCompilerType
<
UnboxedSlice
>
{
class
UnboxedSliceType
:
public
ValuedCompilerType
<
UnboxedSlice
>
{
public:
public:
std
::
string
debugName
()
override
{
return
"slice"
;
}
std
::
string
debugName
()
override
{
return
"slice"
;
}
void
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{}
void
grab
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{}
void
assertMatches
(
UnboxedSlice
slice
)
{}
void
assertMatches
(
UnboxedSlice
slice
)
{}
int
numFrameArgs
()
override
{
RELEASE_ASSERT
(
0
,
"unboxed slice should never get serialized"
);
}
int
numFrameArgs
()
override
{
RELEASE_ASSERT
(
0
,
"unboxed slice should never get serialized"
);
}
...
@@ -2811,16 +2662,13 @@ public:
...
@@ -2811,16 +2662,13 @@ public:
args
.
push_back
(
cstep
->
getValue
());
args
.
push_back
(
cstep
->
getValue
());
llvm
::
Value
*
rtn
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
createSlice
,
args
);
llvm
::
Value
*
rtn
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
createSlice
,
args
);
cstart
->
decvref
(
emitter
);
return
new
ConcreteCompilerVariable
(
SLICE
,
rtn
);
cstop
->
decvref
(
emitter
);
cstep
->
decvref
(
emitter
);
return
new
ConcreteCompilerVariable
(
SLICE
,
rtn
,
true
);
}
}
}
_UNBOXED_SLICE
;
}
_UNBOXED_SLICE
;
CompilerType
*
UNBOXED_SLICE
=
&
_UNBOXED_SLICE
;
CompilerType
*
UNBOXED_SLICE
=
&
_UNBOXED_SLICE
;
CompilerVariable
*
makeSlice
(
CompilerVariable
*
start
,
CompilerVariable
*
stop
,
CompilerVariable
*
step
)
{
CompilerVariable
*
makeSlice
(
CompilerVariable
*
start
,
CompilerVariable
*
stop
,
CompilerVariable
*
step
)
{
return
new
UnboxedSliceType
::
VAR
(
&
_UNBOXED_SLICE
,
UnboxedSlice
{
start
,
stop
,
step
}
,
true
);
return
new
UnboxedSliceType
::
VAR
(
&
_UNBOXED_SLICE
,
UnboxedSlice
{
start
,
stop
,
step
});
}
}
UnboxedSlice
extractSlice
(
CompilerVariable
*
slice
)
{
UnboxedSlice
extractSlice
(
CompilerVariable
*
slice
)
{
...
@@ -2830,7 +2678,7 @@ UnboxedSlice extractSlice(CompilerVariable* slice) {
...
@@ -2830,7 +2678,7 @@ UnboxedSlice extractSlice(CompilerVariable* slice) {
ConcreteCompilerVariable
*
getNone
()
{
ConcreteCompilerVariable
*
getNone
()
{
llvm
::
Constant
*
none
=
embedRelocatablePtr
(
None
,
g
.
llvm_value_type_ptr
,
"cNone"
);
llvm
::
Constant
*
none
=
embedRelocatablePtr
(
None
,
g
.
llvm_value_type_ptr
,
"cNone"
);
return
new
ConcreteCompilerVariable
(
typeFromClass
(
none_cls
),
none
,
false
);
return
new
ConcreteCompilerVariable
(
typeFromClass
(
none_cls
),
none
);
}
}
class
UndefType
:
public
ConcreteCompilerType
{
class
UndefType
:
public
ConcreteCompilerType
{
...
@@ -2848,21 +2696,17 @@ public:
...
@@ -2848,21 +2696,17 @@ public:
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
override
{
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
override
{
return
undefVariable
();
return
undefVariable
();
}
}
void
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{}
void
grab
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{}
CompilerVariable
*
dup
(
VAR
*
v
,
DupCache
&
cache
)
override
{
CompilerVariable
*
dup
(
VAR
*
v
,
DupCache
&
cache
)
override
{
// TODO copied from UnknownType
// TODO copied from UnknownType
auto
&
rtn
=
cache
[
v
];
auto
&
rtn
=
cache
[
v
];
if
(
rtn
==
NULL
)
{
if
(
rtn
==
NULL
)
{
rtn
=
new
VAR
(
this
,
v
->
getValue
(),
v
->
isGrabbed
());
rtn
=
new
VAR
(
this
,
v
->
getValue
());
while
(
rtn
->
getVrefs
()
<
v
->
getVrefs
())
rtn
->
incvref
();
}
}
return
rtn
;
return
rtn
;
}
}
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
VAR
*
var
,
ConcreteCompilerType
*
other_type
)
override
{
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
VAR
*
var
,
ConcreteCompilerType
*
other_type
)
override
{
llvm
::
Value
*
v
=
llvm
::
UndefValue
::
get
(
other_type
->
llvmType
());
llvm
::
Value
*
v
=
llvm
::
UndefValue
::
get
(
other_type
->
llvmType
());
return
new
ConcreteCompilerVariable
(
other_type
,
v
,
true
);
return
new
ConcreteCompilerVariable
(
other_type
,
v
);
}
}
CompilerVariable
*
getattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
BoxedString
*
attr
,
CompilerVariable
*
getattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
BoxedString
*
attr
,
bool
cls_only
)
override
{
bool
cls_only
)
override
{
...
@@ -2881,7 +2725,7 @@ public:
...
@@ -2881,7 +2725,7 @@ public:
}
}
ConcreteCompilerVariable
*
nonzero
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
)
override
{
ConcreteCompilerVariable
*
nonzero
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
)
override
{
return
new
ConcreteCompilerVariable
(
BOOL
,
llvm
::
UndefValue
::
get
(
BOOL
->
llvmType
())
,
true
);
return
new
ConcreteCompilerVariable
(
BOOL
,
llvm
::
UndefValue
::
get
(
BOOL
->
llvmType
()));
}
}
CompilerVariable
*
binexp
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
CompilerVariable
*
rhs
,
CompilerVariable
*
binexp
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
CompilerVariable
*
rhs
,
...
@@ -2916,7 +2760,7 @@ public:
...
@@ -2916,7 +2760,7 @@ public:
CompilerType
*
UNDEF
=
&
_UNDEF
;
CompilerType
*
UNDEF
=
&
_UNDEF
;
ConcreteCompilerVariable
*
undefVariable
()
{
ConcreteCompilerVariable
*
undefVariable
()
{
return
new
ConcreteCompilerVariable
(
&
_UNDEF
,
llvm
::
UndefValue
::
get
(
_UNDEF
.
llvmType
())
,
true
);
return
new
ConcreteCompilerVariable
(
&
_UNDEF
,
llvm
::
UndefValue
::
get
(
_UNDEF
.
llvmType
()));
}
}
ConcreteCompilerVariable
*
boolFromI1
(
IREmitter
&
emitter
,
llvm
::
Value
*
v
)
{
ConcreteCompilerVariable
*
boolFromI1
(
IREmitter
&
emitter
,
llvm
::
Value
*
v
)
{
...
@@ -2924,9 +2768,9 @@ ConcreteCompilerVariable* boolFromI1(IREmitter& emitter, llvm::Value* v) {
...
@@ -2924,9 +2768,9 @@ ConcreteCompilerVariable* boolFromI1(IREmitter& emitter, llvm::Value* v) {
assert
(
v
->
getType
()
==
g
.
i1
);
assert
(
v
->
getType
()
==
g
.
i1
);
assert
(
BOOL
->
llvmType
()
==
g
.
i64
);
assert
(
BOOL
->
llvmType
()
==
g
.
i64
);
llvm
::
Value
*
v2
=
emitter
.
getBuilder
()
->
CreateZExt
(
v
,
BOOL
->
llvmType
());
llvm
::
Value
*
v2
=
emitter
.
getBuilder
()
->
CreateZExt
(
v
,
BOOL
->
llvmType
());
return
new
ConcreteCompilerVariable
(
BOOL
,
v2
,
true
);
return
new
ConcreteCompilerVariable
(
BOOL
,
v2
);
}
else
{
}
else
{
return
new
ConcreteCompilerVariable
(
BOOL
,
v
,
true
);
return
new
ConcreteCompilerVariable
(
BOOL
,
v
);
}
}
}
}
...
...
src/codegen/compvars.h
View file @
cefce6a5
...
@@ -93,14 +93,6 @@ public:
...
@@ -93,14 +93,6 @@ public:
printf
(
"getBoxType not defined for %s
\n
"
,
debugName
().
c_str
());
printf
(
"getBoxType not defined for %s
\n
"
,
debugName
().
c_str
());
abort
();
abort
();
}
}
virtual
void
drop
(
IREmitter
&
emmitter
,
VAR
*
var
)
{
printf
(
"drop not defined for %s
\n
"
,
debugName
().
c_str
());
abort
();
}
virtual
void
grab
(
IREmitter
&
emmitter
,
VAR
*
var
)
{
printf
(
"grab not defined for %s
\n
"
,
debugName
().
c_str
());
abort
();
}
bool
canConvertTo
(
CompilerType
*
other_type
)
override
{
bool
canConvertTo
(
CompilerType
*
other_type
)
override
{
printf
(
"canConvertTo not defined for %s
\n
"
,
debugName
().
c_str
());
printf
(
"canConvertTo not defined for %s
\n
"
,
debugName
().
c_str
());
abort
();
abort
();
...
@@ -216,52 +208,10 @@ public:
...
@@ -216,52 +208,10 @@ public:
};
};
class
CompilerVariable
{
class
CompilerVariable
{
private:
int
vrefs
;
bool
grabbed
;
protected:
virtual
void
drop
(
IREmitter
&
emitter
)
=
0
;
virtual
void
grab
(
IREmitter
&
emmitter
)
=
0
;
public:
public:
CompilerVariable
(
bool
grabbed
)
:
vrefs
(
1
),
grabbed
(
grabbed
)
{}
CompilerVariable
()
{}
virtual
~
CompilerVariable
()
{}
virtual
~
CompilerVariable
()
{}
bool
isGrabbed
()
{
return
grabbed
;
}
void
incvref
()
{
assert
(
vrefs
);
vrefs
++
;
}
void
decvrefNodrop
()
{
assert
(
vrefs
>
0
&&
vrefs
<
(
1
<<
20
));
// It'd be nice to print out the type of the variable, but this is all happening
// after the object got deleted so it's pretty precarious, and the getType()
// debugging call will probably segfault:
// ASSERT(vrefs, "%s", getType()->debugName().c_str());
vrefs
--
;
if
(
vrefs
==
0
)
{
delete
this
;
}
}
void
decvref
(
IREmitter
&
emitter
)
{
ASSERT
(
vrefs
>
0
&&
vrefs
<
(
1
<<
20
),
"%d"
,
vrefs
);
// ASSERT(vrefs, "%s", getType()->debugName().c_str());
vrefs
--
;
if
(
vrefs
==
0
)
{
if
(
grabbed
)
drop
(
emitter
);
delete
this
;
}
}
int
getVrefs
()
{
return
vrefs
;
}
void
ensureGrabbed
(
IREmitter
&
emitter
)
{
if
(
!
grabbed
)
{
grab
(
emitter
);
grabbed
=
true
;
}
}
virtual
CompilerVariable
*
split
(
IREmitter
&
emitter
)
=
0
;
virtual
CompilerVariable
*
dup
(
DupCache
&
cache
)
=
0
;
virtual
CompilerVariable
*
dup
(
DupCache
&
cache
)
=
0
;
virtual
CompilerType
*
getType
()
=
0
;
virtual
CompilerType
*
getType
()
=
0
;
...
@@ -302,12 +252,8 @@ private:
...
@@ -302,12 +252,8 @@ private:
T
*
type
;
T
*
type
;
V
value
;
V
value
;
protected:
void
drop
(
IREmitter
&
emitter
)
override
{
type
->
drop
(
emitter
,
this
);
}
void
grab
(
IREmitter
&
emitter
)
override
{
type
->
grab
(
emitter
,
this
);
}
public:
public:
ValuedCompilerVariable
(
T
*
type
,
V
value
,
bool
grabbed
)
:
CompilerVariable
(
grabbed
),
type
(
type
),
value
(
value
)
{
ValuedCompilerVariable
(
T
*
type
,
V
value
)
:
CompilerVariable
(
),
type
(
type
),
value
(
value
)
{
#ifndef NDEBUG
#ifndef NDEBUG
type
->
assertMatches
(
value
);
type
->
assertMatches
(
value
);
#endif
#endif
...
@@ -318,21 +264,9 @@ public:
...
@@ -318,21 +264,9 @@ public:
ConcreteCompilerType
*
getConcreteType
()
override
{
return
type
->
getConcreteType
();
}
ConcreteCompilerType
*
getConcreteType
()
override
{
return
type
->
getConcreteType
();
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
type
->
getBoxType
();
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
type
->
getBoxType
();
}
ValuedCompilerVariable
<
V
>*
split
(
IREmitter
&
emitter
)
override
{
ValuedCompilerVariable
<
V
>*
rtn
;
if
(
getVrefs
()
==
1
)
{
rtn
=
this
;
}
else
{
rtn
=
new
ValuedCompilerVariable
<
V
>
(
type
,
value
,
false
);
this
->
decvref
(
emitter
);
}
rtn
->
ensureGrabbed
(
emitter
);
return
rtn
;
}
CompilerVariable
*
dup
(
DupCache
&
cache
)
override
{
CompilerVariable
*
dup
(
DupCache
&
cache
)
override
{
CompilerVariable
*
rtn
=
type
->
dup
(
this
,
cache
);
CompilerVariable
*
rtn
=
type
->
dup
(
this
,
cache
);
ASSERT
(
rtn
->
getVrefs
()
==
getVrefs
(),
"%d %s"
,
rtn
->
getVrefs
(),
type
->
debugName
().
c_str
());
return
rtn
;
return
rtn
;
}
}
...
@@ -402,12 +336,6 @@ public:
...
@@ -402,12 +336,6 @@ public:
}
}
};
};
// template <>
// inline ConcreteCompilerVariable::ValuedCompilerVariable(ConcreteCompilerType *type, llvm::Value* value, bool grabbed)
// : CompilerVariable(grabbed), type(type), value(value) {
// assert(value->getType() == type->llvmType());
//}
// Emit the test for whether one variable 'is' another one.
// Emit the test for whether one variable 'is' another one.
ConcreteCompilerVariable
*
doIs
(
IREmitter
&
emitter
,
CompilerVariable
*
lhs
,
CompilerVariable
*
rhs
,
bool
negate
);
ConcreteCompilerVariable
*
doIs
(
IREmitter
&
emitter
,
CompilerVariable
*
lhs
,
CompilerVariable
*
rhs
,
bool
negate
);
...
@@ -457,7 +385,6 @@ template <typename V>
...
@@ -457,7 +385,6 @@ template <typename V>
CompilerVariable
*
_ValuedCompilerType
<
V
>::
getPystonIter
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
)
{
CompilerVariable
*
_ValuedCompilerType
<
V
>::
getPystonIter
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
)
{
ConcreteCompilerVariable
*
converted
=
makeConverted
(
emitter
,
var
,
getBoxType
());
ConcreteCompilerVariable
*
converted
=
makeConverted
(
emitter
,
var
,
getBoxType
());
auto
r
=
UNKNOWN
->
getPystonIter
(
emitter
,
info
,
converted
);
auto
r
=
UNKNOWN
->
getPystonIter
(
emitter
,
info
,
converted
);
converted
->
decvref
(
emitter
);
return
r
;
return
r
;
}
}
...
@@ -466,7 +393,6 @@ CompilerVariable* _ValuedCompilerType<V>::contains(IREmitter& emitter, const OpI
...
@@ -466,7 +393,6 @@ CompilerVariable* _ValuedCompilerType<V>::contains(IREmitter& emitter, const OpI
CompilerVariable
*
rhs
)
{
CompilerVariable
*
rhs
)
{
ConcreteCompilerVariable
*
converted
=
makeConverted
(
emitter
,
var
,
getBoxType
());
ConcreteCompilerVariable
*
converted
=
makeConverted
(
emitter
,
var
,
getBoxType
());
auto
r
=
UNKNOWN
->
contains
(
emitter
,
info
,
converted
,
rhs
);
auto
r
=
UNKNOWN
->
contains
(
emitter
,
info
,
converted
,
rhs
);
converted
->
decvref
(
emitter
);
return
r
;
return
r
;
}
}
...
@@ -475,7 +401,6 @@ CompilerVariable* _ValuedCompilerType<V>::unaryop(IREmitter& emitter, const OpIn
...
@@ -475,7 +401,6 @@ CompilerVariable* _ValuedCompilerType<V>::unaryop(IREmitter& emitter, const OpIn
AST_TYPE
::
AST_TYPE
op_type
)
{
AST_TYPE
::
AST_TYPE
op_type
)
{
ConcreteCompilerVariable
*
converted
=
makeConverted
(
emitter
,
var
,
getBoxType
());
ConcreteCompilerVariable
*
converted
=
makeConverted
(
emitter
,
var
,
getBoxType
());
auto
r
=
UNKNOWN
->
unaryop
(
emitter
,
info
,
converted
,
op_type
);
auto
r
=
UNKNOWN
->
unaryop
(
emitter
,
info
,
converted
,
op_type
);
converted
->
decvref
(
emitter
);
return
r
;
return
r
;
}
}
...
@@ -486,7 +411,6 @@ std::vector<CompilerVariable*> _ValuedCompilerType<V>::unpack(IREmitter& emitter
...
@@ -486,7 +411,6 @@ std::vector<CompilerVariable*> _ValuedCompilerType<V>::unpack(IREmitter& emitter
ConcreteCompilerVariable
*
converted
=
makeConverted
(
emitter
,
var
,
UNKNOWN
);
ConcreteCompilerVariable
*
converted
=
makeConverted
(
emitter
,
var
,
UNKNOWN
);
auto
r
=
UNKNOWN
->
unpack
(
emitter
,
info
,
converted
,
num_into
);
auto
r
=
UNKNOWN
->
unpack
(
emitter
,
info
,
converted
,
num_into
);
converted
->
decvref
(
emitter
);
return
r
;
return
r
;
}
}
...
...
src/codegen/irgen.cpp
View file @
cefce6a5
...
@@ -452,7 +452,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
...
@@ -452,7 +452,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
ConcreteCompilerType
*
phi_type
;
ConcreteCompilerType
*
phi_type
;
phi_type
=
getTypeAtBlockStart
(
types
,
p
.
first
,
target_block
);
phi_type
=
getTypeAtBlockStart
(
types
,
p
.
first
,
target_block
);
ConcreteCompilerVariable
*
var
=
new
ConcreteCompilerVariable
(
p
.
second
,
from_arg
,
true
);
ConcreteCompilerVariable
*
var
=
new
ConcreteCompilerVariable
(
p
.
second
,
from_arg
);
(
*
initial_syms
)[
p
.
first
]
=
var
;
(
*
initial_syms
)[
p
.
first
]
=
var
;
// It's possible to OSR into a version of the function with a higher speculation level;
// It's possible to OSR into a version of the function with a higher speculation level;
...
@@ -477,7 +477,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
...
@@ -477,7 +477,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
if
(
VERBOSITY
(
"irgen"
)
>=
2
)
if
(
VERBOSITY
(
"irgen"
)
>=
2
)
v
->
setName
(
"prev_"
+
p
.
first
.
s
());
v
->
setName
(
"prev_"
+
p
.
first
.
s
());
(
*
osr_syms
)[
p
.
first
]
=
new
ConcreteCompilerVariable
(
phi_type
,
v
,
true
);
(
*
osr_syms
)[
p
.
first
]
=
new
ConcreteCompilerVariable
(
phi_type
,
v
);
}
}
entry_emitter
->
getBuilder
()
->
CreateBr
(
osr_unbox_block
);
entry_emitter
->
getBuilder
()
->
CreateBr
(
osr_unbox_block
);
...
@@ -624,7 +624,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
...
@@ -624,7 +624,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
llvm
::
PHINode
*
phi
=
emitter
->
getBuilder
()
->
CreatePHI
(
analyzed_type
->
llvmType
(),
llvm
::
PHINode
*
phi
=
emitter
->
getBuilder
()
->
CreatePHI
(
analyzed_type
->
llvmType
(),
block
->
predecessors
.
size
()
+
1
,
p
.
first
.
s
());
block
->
predecessors
.
size
()
+
1
,
p
.
first
.
s
());
ConcreteCompilerVariable
*
var
=
new
ConcreteCompilerVariable
(
analyzed_type
,
phi
,
true
);
ConcreteCompilerVariable
*
var
=
new
ConcreteCompilerVariable
(
analyzed_type
,
phi
);
generator
->
giveLocalSymbol
(
p
.
first
,
var
);
generator
->
giveLocalSymbol
(
p
.
first
,
var
);
(
*
phis
)[
p
.
first
]
=
std
::
make_pair
(
analyzed_type
,
phi
);
(
*
phis
)[
p
.
first
]
=
std
::
make_pair
(
analyzed_type
,
phi
);
}
}
...
@@ -661,7 +661,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
...
@@ -661,7 +661,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
ConcreteCompilerType
*
type
=
getTypeAtBlockStart
(
types
,
s
,
block
);
ConcreteCompilerType
*
type
=
getTypeAtBlockStart
(
types
,
s
,
block
);
llvm
::
PHINode
*
phi
llvm
::
PHINode
*
phi
=
emitter
->
getBuilder
()
->
CreatePHI
(
type
->
llvmType
(),
block
->
predecessors
.
size
(),
s
.
s
());
=
emitter
->
getBuilder
()
->
CreatePHI
(
type
->
llvmType
(),
block
->
predecessors
.
size
(),
s
.
s
());
ConcreteCompilerVariable
*
var
=
new
ConcreteCompilerVariable
(
type
,
phi
,
true
);
ConcreteCompilerVariable
*
var
=
new
ConcreteCompilerVariable
(
type
,
phi
);
generator
->
giveLocalSymbol
(
s
,
var
);
generator
->
giveLocalSymbol
(
s
,
var
);
(
*
phis
)[
s
]
=
std
::
make_pair
(
type
,
phi
);
(
*
phis
)[
s
]
=
std
::
make_pair
(
type
,
phi
);
...
@@ -761,7 +761,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
...
@@ -761,7 +761,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
llvm
::
PHINode
*
phi
=
emitter
->
getBuilder
()
->
CreatePHI
(
cv
->
getType
()
->
llvmType
(),
llvm
::
PHINode
*
phi
=
emitter
->
getBuilder
()
->
CreatePHI
(
cv
->
getType
()
->
llvmType
(),
block
->
predecessors
.
size
(),
name
.
s
());
block
->
predecessors
.
size
(),
name
.
s
());
// emitter->getBuilder()->CreateCall(g.funcs.dump, phi);
// emitter->getBuilder()->CreateCall(g.funcs.dump, phi);
ConcreteCompilerVariable
*
var
=
new
ConcreteCompilerVariable
(
cv
->
getType
(),
phi
,
true
);
ConcreteCompilerVariable
*
var
=
new
ConcreteCompilerVariable
(
cv
->
getType
(),
phi
);
generator
->
giveLocalSymbol
(
name
,
var
);
generator
->
giveLocalSymbol
(
name
,
var
);
(
*
phis
)[
name
]
=
std
::
make_pair
(
cv
->
getType
(),
phi
);
(
*
phis
)[
name
]
=
std
::
make_pair
(
cv
->
getType
(),
phi
);
...
@@ -851,7 +851,6 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
...
@@ -851,7 +851,6 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
ConcreteCompilerVariable
*
v
=
(
*
phi_ending_symbol_tables
[
bpred
])[
it
->
first
];
ConcreteCompilerVariable
*
v
=
(
*
phi_ending_symbol_tables
[
bpred
])[
it
->
first
];
assert
(
v
);
assert
(
v
);
assert
(
v
->
isGrabbed
());
// Make sure they all prepared for the same type:
// Make sure they all prepared for the same type:
ASSERT
(
it
->
second
.
first
==
v
->
getType
(),
"%d %d: %s %s %s"
,
b
->
idx
,
bpred
->
idx
,
it
->
first
.
c_str
(),
ASSERT
(
it
->
second
.
first
==
v
->
getType
(),
"%d %d: %s %s %s"
,
b
->
idx
,
bpred
->
idx
,
it
->
first
.
c_str
(),
...
@@ -864,7 +863,6 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
...
@@ -864,7 +863,6 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
if
(
this_is_osr_entry
)
{
if
(
this_is_osr_entry
)
{
ConcreteCompilerVariable
*
v
=
(
*
osr_syms
)[
it
->
first
];
ConcreteCompilerVariable
*
v
=
(
*
osr_syms
)[
it
->
first
];
assert
(
v
);
assert
(
v
);
assert
(
v
->
isGrabbed
());
ASSERT
(
it
->
second
.
first
==
v
->
getType
(),
""
);
ASSERT
(
it
->
second
.
first
==
v
->
getType
(),
""
);
llvm_phi
->
addIncoming
(
v
->
getValue
(),
osr_unbox_block_end
);
llvm_phi
->
addIncoming
(
v
->
getValue
(),
osr_unbox_block_end
);
...
@@ -880,14 +878,6 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
...
@@ -880,14 +878,6 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
if
(
ending_symbol_tables
[
b
]
==
NULL
)
if
(
ending_symbol_tables
[
b
]
==
NULL
)
continue
;
continue
;
for
(
SymbolTable
::
iterator
it
=
ending_symbol_tables
[
b
]
->
begin
();
it
!=
ending_symbol_tables
[
b
]
->
end
();
++
it
)
{
it
->
second
->
decvrefNodrop
();
}
for
(
ConcreteSymbolTable
::
iterator
it
=
phi_ending_symbol_tables
[
b
]
->
begin
();
it
!=
phi_ending_symbol_tables
[
b
]
->
end
();
++
it
)
{
it
->
second
->
decvrefNodrop
();
}
delete
phi_ending_symbol_tables
[
b
];
delete
ending_symbol_tables
[
b
];
delete
ending_symbol_tables
[
b
];
delete
created_phis
[
b
];
delete
created_phis
[
b
];
}
}
...
...
src/codegen/irgen/irgenerator.cpp
View file @
cefce6a5
...
@@ -645,14 +645,12 @@ private:
...
@@ -645,14 +645,12 @@ private:
CompilerVariable
*
value
=
evalExpr
(
node
->
value
,
unw_info
);
CompilerVariable
*
value
=
evalExpr
(
node
->
value
,
unw_info
);
CompilerVariable
*
rtn
=
value
->
getattr
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
),
node
->
attr
.
getBox
(),
false
);
CompilerVariable
*
rtn
=
value
->
getattr
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
),
node
->
attr
.
getBox
(),
false
);
value
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
CompilerVariable
*
evalClsAttribute
(
AST_ClsAttribute
*
node
,
const
UnwindInfo
&
unw_info
)
{
CompilerVariable
*
evalClsAttribute
(
AST_ClsAttribute
*
node
,
const
UnwindInfo
&
unw_info
)
{
CompilerVariable
*
value
=
evalExpr
(
node
->
value
,
unw_info
);
CompilerVariable
*
value
=
evalExpr
(
node
->
value
,
unw_info
);
CompilerVariable
*
rtn
=
value
->
getattr
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
),
node
->
attr
.
getBox
(),
true
);
CompilerVariable
*
rtn
=
value
->
getattr
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
),
node
->
attr
.
getBox
(),
true
);
value
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -665,8 +663,6 @@ private:
...
@@ -665,8 +663,6 @@ private:
ConcreteCompilerVariable
*
converted_obj
=
obj
->
makeConverted
(
emitter
,
obj
->
getBoxType
());
ConcreteCompilerVariable
*
converted_obj
=
obj
->
makeConverted
(
emitter
,
obj
->
getBoxType
());
ConcreteCompilerVariable
*
converted_cls
=
cls
->
makeConverted
(
emitter
,
cls
->
getBoxType
());
ConcreteCompilerVariable
*
converted_cls
=
cls
->
makeConverted
(
emitter
,
cls
->
getBoxType
());
obj
->
decvref
(
emitter
);
cls
->
decvref
(
emitter
);
llvm
::
Value
*
v
=
emitter
.
createCall
(
unw_info
,
g
.
funcs
.
exceptionMatches
,
llvm
::
Value
*
v
=
emitter
.
createCall
(
unw_info
,
g
.
funcs
.
exceptionMatches
,
{
converted_obj
->
getValue
(),
converted_cls
->
getValue
()
});
{
converted_obj
->
getValue
(),
converted_cls
->
getValue
()
});
...
@@ -696,9 +692,9 @@ private:
...
@@ -696,9 +692,9 @@ private:
phi_exc_value
->
addIncoming
(
e
.
exc_value
->
getValue
(),
e
.
from_block
);
phi_exc_value
->
addIncoming
(
e
.
exc_value
->
getValue
(),
e
.
from_block
);
phi_exc_tb
->
addIncoming
(
e
.
exc_tb
->
getValue
(),
e
.
from_block
);
phi_exc_tb
->
addIncoming
(
e
.
exc_tb
->
getValue
(),
e
.
from_block
);
}
}
exc_type
=
new
ConcreteCompilerVariable
(
UNKNOWN
,
phi_exc_type
,
true
);
exc_type
=
new
ConcreteCompilerVariable
(
UNKNOWN
,
phi_exc_type
);
exc_value
=
new
ConcreteCompilerVariable
(
UNKNOWN
,
phi_exc_value
,
true
);
exc_value
=
new
ConcreteCompilerVariable
(
UNKNOWN
,
phi_exc_value
);
exc_tb
=
new
ConcreteCompilerVariable
(
UNKNOWN
,
phi_exc_tb
,
true
);
exc_tb
=
new
ConcreteCompilerVariable
(
UNKNOWN
,
phi_exc_tb
);
}
}
}
else
{
}
else
{
// There can be no incoming exception if the irgenerator was able to prove that
// There can be no incoming exception if the irgenerator was able to prove that
...
@@ -717,13 +713,12 @@ private:
...
@@ -717,13 +713,12 @@ private:
return
makeTuple
({
exc_type
,
exc_value
,
exc_tb
});
return
makeTuple
({
exc_type
,
exc_value
,
exc_tb
});
}
}
case
AST_LangPrimitive
:
:
LOCALS
:
{
case
AST_LangPrimitive
:
:
LOCALS
:
{
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
irstate
->
getBoxedLocalsVar
()
,
true
);
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
irstate
->
getBoxedLocalsVar
());
}
}
case
AST_LangPrimitive
:
:
GET_ITER
:
{
case
AST_LangPrimitive
:
:
GET_ITER
:
{
assert
(
node
->
args
.
size
()
==
1
);
assert
(
node
->
args
.
size
()
==
1
);
CompilerVariable
*
obj
=
evalExpr
(
node
->
args
[
0
],
unw_info
);
CompilerVariable
*
obj
=
evalExpr
(
node
->
args
[
0
],
unw_info
);
auto
rtn
=
obj
->
getPystonIter
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
));
auto
rtn
=
obj
->
getPystonIter
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
));
obj
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
case
AST_LangPrimitive
:
:
IMPORT_FROM
:
{
case
AST_LangPrimitive
:
:
IMPORT_FROM
:
{
...
@@ -733,7 +728,6 @@ private:
...
@@ -733,7 +728,6 @@ private:
CompilerVariable
*
module
=
evalExpr
(
node
->
args
[
0
],
unw_info
);
CompilerVariable
*
module
=
evalExpr
(
node
->
args
[
0
],
unw_info
);
ConcreteCompilerVariable
*
converted_module
=
module
->
makeConverted
(
emitter
,
module
->
getBoxType
());
ConcreteCompilerVariable
*
converted_module
=
module
->
makeConverted
(
emitter
,
module
->
getBoxType
());
module
->
decvref
(
emitter
);
auto
ast_str
=
ast_cast
<
AST_Str
>
(
node
->
args
[
1
]);
auto
ast_str
=
ast_cast
<
AST_Str
>
(
node
->
args
[
1
]);
assert
(
ast_str
->
str_type
==
AST_Str
::
STR
);
assert
(
ast_str
->
str_type
==
AST_Str
::
STR
);
...
@@ -746,9 +740,7 @@ private:
...
@@ -746,9 +740,7 @@ private:
llvm
::
Value
*
r
llvm
::
Value
*
r
=
emitter
.
createCall2
(
unw_info
,
g
.
funcs
.
importFrom
,
converted_module
->
getValue
(),
name_arg
);
=
emitter
.
createCall2
(
unw_info
,
g
.
funcs
.
importFrom
,
converted_module
->
getValue
(),
name_arg
);
CompilerVariable
*
v
=
new
ConcreteCompilerVariable
(
UNKNOWN
,
r
,
true
);
CompilerVariable
*
v
=
new
ConcreteCompilerVariable
(
UNKNOWN
,
r
);
converted_module
->
decvref
(
emitter
);
return
v
;
return
v
;
}
}
case
AST_LangPrimitive
:
:
IMPORT_STAR
:
{
case
AST_LangPrimitive
:
:
IMPORT_STAR
:
{
...
@@ -760,13 +752,10 @@ private:
...
@@ -760,13 +752,10 @@ private:
CompilerVariable
*
module
=
evalExpr
(
node
->
args
[
0
],
unw_info
);
CompilerVariable
*
module
=
evalExpr
(
node
->
args
[
0
],
unw_info
);
ConcreteCompilerVariable
*
converted_module
=
module
->
makeConverted
(
emitter
,
module
->
getBoxType
());
ConcreteCompilerVariable
*
converted_module
=
module
->
makeConverted
(
emitter
,
module
->
getBoxType
());
module
->
decvref
(
emitter
);
llvm
::
Value
*
r
=
emitter
.
createCall2
(
unw_info
,
g
.
funcs
.
importStar
,
converted_module
->
getValue
(),
llvm
::
Value
*
r
=
emitter
.
createCall2
(
unw_info
,
g
.
funcs
.
importStar
,
converted_module
->
getValue
(),
irstate
->
getGlobals
());
irstate
->
getGlobals
());
CompilerVariable
*
v
=
new
ConcreteCompilerVariable
(
UNKNOWN
,
r
,
true
);
CompilerVariable
*
v
=
new
ConcreteCompilerVariable
(
UNKNOWN
,
r
);
converted_module
->
decvref
(
emitter
);
return
v
;
return
v
;
}
}
case
AST_LangPrimitive
:
:
IMPORT_NAME
:
{
case
AST_LangPrimitive
:
:
IMPORT_NAME
:
{
...
@@ -780,7 +769,6 @@ private:
...
@@ -780,7 +769,6 @@ private:
// TODO this could be a constant Box* too
// TODO this could be a constant Box* too
CompilerVariable
*
froms
=
evalExpr
(
node
->
args
[
1
],
unw_info
);
CompilerVariable
*
froms
=
evalExpr
(
node
->
args
[
1
],
unw_info
);
ConcreteCompilerVariable
*
converted_froms
=
froms
->
makeConverted
(
emitter
,
froms
->
getBoxType
());
ConcreteCompilerVariable
*
converted_froms
=
froms
->
makeConverted
(
emitter
,
froms
->
getBoxType
());
froms
->
decvref
(
emitter
);
auto
ast_str
=
ast_cast
<
AST_Str
>
(
node
->
args
[
2
]);
auto
ast_str
=
ast_cast
<
AST_Str
>
(
node
->
args
[
2
]);
assert
(
ast_str
->
str_type
==
AST_Str
::
STR
);
assert
(
ast_str
->
str_type
==
AST_Str
::
STR
);
...
@@ -790,9 +778,7 @@ private:
...
@@ -790,9 +778,7 @@ private:
{
getConstantInt
(
level
,
g
.
i32
),
converted_froms
->
getValue
(),
{
getConstantInt
(
level
,
g
.
i32
),
converted_froms
->
getValue
(),
embedRelocatablePtr
(
module_name
.
c_str
(),
g
.
i8_ptr
),
embedRelocatablePtr
(
module_name
.
c_str
(),
g
.
i8_ptr
),
getConstantInt
(
module_name
.
size
(),
g
.
i64
)
});
getConstantInt
(
module_name
.
size
(),
g
.
i64
)
});
ConcreteCompilerVariable
*
v
=
new
ConcreteCompilerVariable
(
UNKNOWN
,
imported
,
true
);
ConcreteCompilerVariable
*
v
=
new
ConcreteCompilerVariable
(
UNKNOWN
,
imported
);
converted_froms
->
decvref
(
emitter
);
return
v
;
return
v
;
}
}
case
AST_LangPrimitive
:
:
NONE
:
{
case
AST_LangPrimitive
:
:
NONE
:
{
...
@@ -803,7 +789,6 @@ private:
...
@@ -803,7 +789,6 @@ private:
CompilerVariable
*
obj
=
evalExpr
(
node
->
args
[
0
],
unw_info
);
CompilerVariable
*
obj
=
evalExpr
(
node
->
args
[
0
],
unw_info
);
CompilerVariable
*
rtn
=
obj
->
nonzero
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
));
CompilerVariable
*
rtn
=
obj
->
nonzero
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
));
obj
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
case
AST_LangPrimitive
:
:
HASNEXT
:
{
case
AST_LangPrimitive
:
:
HASNEXT
:
{
...
@@ -811,7 +796,6 @@ private:
...
@@ -811,7 +796,6 @@ private:
CompilerVariable
*
obj
=
evalExpr
(
node
->
args
[
0
],
unw_info
);
CompilerVariable
*
obj
=
evalExpr
(
node
->
args
[
0
],
unw_info
);
CompilerVariable
*
rtn
=
obj
->
hasnext
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
));
CompilerVariable
*
rtn
=
obj
->
hasnext
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
));
obj
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
case
AST_LangPrimitive
:
:
SET_EXC_INFO
:
{
case
AST_LangPrimitive
:
:
SET_EXC_INFO
:
{
...
@@ -828,14 +812,11 @@ private:
...
@@ -828,14 +812,11 @@ private:
ConcreteCompilerVariable
*
converted_type
=
type
->
makeConverted
(
emitter
,
UNKNOWN
);
ConcreteCompilerVariable
*
converted_type
=
type
->
makeConverted
(
emitter
,
UNKNOWN
);
builder
->
CreateStore
(
converted_type
->
getValue
(),
builder
->
CreateConstInBoundsGEP2_32
(
exc_info
,
0
,
0
));
builder
->
CreateStore
(
converted_type
->
getValue
(),
builder
->
CreateConstInBoundsGEP2_32
(
exc_info
,
0
,
0
));
converted_type
->
decvref
(
emitter
);
ConcreteCompilerVariable
*
converted_value
=
value
->
makeConverted
(
emitter
,
UNKNOWN
);
ConcreteCompilerVariable
*
converted_value
=
value
->
makeConverted
(
emitter
,
UNKNOWN
);
builder
->
CreateStore
(
converted_value
->
getValue
(),
builder
->
CreateConstInBoundsGEP2_32
(
exc_info
,
0
,
1
));
builder
->
CreateStore
(
converted_value
->
getValue
(),
builder
->
CreateConstInBoundsGEP2_32
(
exc_info
,
0
,
1
));
converted_value
->
decvref
(
emitter
);
ConcreteCompilerVariable
*
converted_traceback
=
traceback
->
makeConverted
(
emitter
,
UNKNOWN
);
ConcreteCompilerVariable
*
converted_traceback
=
traceback
->
makeConverted
(
emitter
,
UNKNOWN
);
builder
->
CreateStore
(
converted_traceback
->
getValue
(),
builder
->
CreateStore
(
converted_traceback
->
getValue
(),
builder
->
CreateConstInBoundsGEP2_32
(
exc_info
,
0
,
2
));
builder
->
CreateConstInBoundsGEP2_32
(
exc_info
,
0
,
2
));
converted_traceback
->
decvref
(
emitter
);
return
getNone
();
return
getNone
();
}
}
...
@@ -899,8 +880,6 @@ private:
...
@@ -899,8 +880,6 @@ private:
assert
(
node
->
op_type
!=
AST_TYPE
::
Is
&&
node
->
op_type
!=
AST_TYPE
::
IsNot
&&
"not tested yet"
);
assert
(
node
->
op_type
!=
AST_TYPE
::
Is
&&
node
->
op_type
!=
AST_TYPE
::
IsNot
&&
"not tested yet"
);
CompilerVariable
*
rtn
=
this
->
_evalBinExp
(
node
,
left
,
right
,
node
->
op_type
,
BinOp
,
unw_info
);
CompilerVariable
*
rtn
=
this
->
_evalBinExp
(
node
,
left
,
right
,
node
->
op_type
,
BinOp
,
unw_info
);
left
->
decvref
(
emitter
);
right
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -911,8 +890,6 @@ private:
...
@@ -911,8 +890,6 @@ private:
assert
(
node
->
op_type
!=
AST_TYPE
::
Is
&&
node
->
op_type
!=
AST_TYPE
::
IsNot
&&
"not tested yet"
);
assert
(
node
->
op_type
!=
AST_TYPE
::
Is
&&
node
->
op_type
!=
AST_TYPE
::
IsNot
&&
"not tested yet"
);
CompilerVariable
*
rtn
=
this
->
_evalBinExp
(
node
,
left
,
right
,
node
->
op_type
,
AugBinOp
,
unw_info
);
CompilerVariable
*
rtn
=
this
->
_evalBinExp
(
node
,
left
,
right
,
node
->
op_type
,
AugBinOp
,
unw_info
);
left
->
decvref
(
emitter
);
right
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -930,8 +907,6 @@ private:
...
@@ -930,8 +907,6 @@ private:
}
}
CompilerVariable
*
rtn
=
_evalBinExp
(
node
,
left
,
right
,
node
->
ops
[
0
],
Compare
,
unw_info
);
CompilerVariable
*
rtn
=
_evalBinExp
(
node
,
left
,
right
,
node
->
ops
[
0
],
Compare
,
unw_info
);
left
->
decvref
(
emitter
);
right
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -992,17 +967,12 @@ private:
...
@@ -992,17 +967,12 @@ private:
rtn
=
func
->
call
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
),
argspec
,
args
,
keyword_names
);
rtn
=
func
->
call
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
),
argspec
,
args
,
keyword_names
);
}
}
func
->
decvref
(
emitter
);
for
(
int
i
=
0
;
i
<
args
.
size
();
i
++
)
{
args
[
i
]
->
decvref
(
emitter
);
}
return
rtn
;
return
rtn
;
}
}
CompilerVariable
*
evalDict
(
AST_Dict
*
node
,
const
UnwindInfo
&
unw_info
)
{
CompilerVariable
*
evalDict
(
AST_Dict
*
node
,
const
UnwindInfo
&
unw_info
)
{
llvm
::
Value
*
v
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
createDict
);
llvm
::
Value
*
v
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
createDict
);
ConcreteCompilerVariable
*
rtn
=
new
ConcreteCompilerVariable
(
DICT
,
v
,
true
);
ConcreteCompilerVariable
*
rtn
=
new
ConcreteCompilerVariable
(
DICT
,
v
);
if
(
node
->
keys
.
size
())
{
if
(
node
->
keys
.
size
())
{
static
BoxedString
*
setitem_str
=
getStaticString
(
"__setitem__"
);
static
BoxedString
*
setitem_str
=
getStaticString
(
"__setitem__"
);
CompilerVariable
*
setitem
=
rtn
->
getattr
(
emitter
,
getEmptyOpInfo
(
unw_info
),
setitem_str
,
true
);
CompilerVariable
*
setitem
=
rtn
->
getattr
(
emitter
,
getEmptyOpInfo
(
unw_info
),
setitem_str
,
true
);
...
@@ -1017,12 +987,7 @@ private:
...
@@ -1017,12 +987,7 @@ private:
args
.
push_back
(
value
);
args
.
push_back
(
value
);
// TODO should use callattr
// TODO should use callattr
CompilerVariable
*
rtn
=
setitem
->
call
(
emitter
,
getEmptyOpInfo
(
unw_info
),
ArgPassSpec
(
2
),
args
,
NULL
);
CompilerVariable
*
rtn
=
setitem
->
call
(
emitter
,
getEmptyOpInfo
(
unw_info
),
ArgPassSpec
(
2
),
args
,
NULL
);
rtn
->
decvref
(
emitter
);
key
->
decvref
(
emitter
);
value
->
decvref
(
emitter
);
}
}
setitem
->
decvref
(
emitter
);
}
}
return
rtn
;
return
rtn
;
}
}
...
@@ -1044,7 +1009,6 @@ private:
...
@@ -1044,7 +1009,6 @@ private:
std
::
vector
<
AST_stmt
*>
body
=
{
expr
};
std
::
vector
<
AST_stmt
*>
body
=
{
expr
};
CompilerVariable
*
func
=
_createFunction
(
node
,
unw_info
,
node
->
args
,
body
);
CompilerVariable
*
func
=
_createFunction
(
node
,
unw_info
,
node
->
args
,
body
);
ConcreteCompilerVariable
*
converted
=
func
->
makeConverted
(
emitter
,
func
->
getBoxType
());
ConcreteCompilerVariable
*
converted
=
func
->
makeConverted
(
emitter
,
func
->
getBoxType
());
func
->
decvref
(
emitter
);
return
converted
;
return
converted
;
}
}
...
@@ -1058,7 +1022,7 @@ private:
...
@@ -1058,7 +1022,7 @@ private:
}
}
llvm
::
Value
*
v
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
createList
);
llvm
::
Value
*
v
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
createList
);
ConcreteCompilerVariable
*
rtn
=
new
ConcreteCompilerVariable
(
LIST
,
v
,
true
);
ConcreteCompilerVariable
*
rtn
=
new
ConcreteCompilerVariable
(
LIST
,
v
);
llvm
::
Value
*
f
=
g
.
funcs
.
listAppendInternal
;
llvm
::
Value
*
f
=
g
.
funcs
.
listAppendInternal
;
llvm
::
Value
*
bitcast
=
emitter
.
getBuilder
()
->
CreateBitCast
(
llvm
::
Value
*
bitcast
=
emitter
.
getBuilder
()
->
CreateBitCast
(
...
@@ -1068,10 +1032,8 @@ private:
...
@@ -1068,10 +1032,8 @@ private:
for
(
int
i
=
0
;
i
<
node
->
elts
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
node
->
elts
.
size
();
i
++
)
{
CompilerVariable
*
elt
=
elts
[
i
];
CompilerVariable
*
elt
=
elts
[
i
];
ConcreteCompilerVariable
*
converted
=
elt
->
makeConverted
(
emitter
,
elt
->
getBoxType
());
ConcreteCompilerVariable
*
converted
=
elt
->
makeConverted
(
emitter
,
elt
->
getBoxType
());
elt
->
decvref
(
emitter
);
emitter
.
createCall2
(
unw_info
,
f
,
bitcast
,
converted
->
getValue
());
emitter
.
createCall2
(
unw_info
,
f
,
bitcast
,
converted
->
getValue
());
converted
->
decvref
(
emitter
);
}
}
return
rtn
;
return
rtn
;
}
}
...
@@ -1079,7 +1041,7 @@ private:
...
@@ -1079,7 +1041,7 @@ private:
ConcreteCompilerVariable
*
getEllipsis
()
{
ConcreteCompilerVariable
*
getEllipsis
()
{
llvm
::
Constant
*
ellipsis
=
embedRelocatablePtr
(
Ellipsis
,
g
.
llvm_value_type_ptr
,
"cEllipsis"
);
llvm
::
Constant
*
ellipsis
=
embedRelocatablePtr
(
Ellipsis
,
g
.
llvm_value_type_ptr
,
"cEllipsis"
);
auto
ellipsis_cls
=
Ellipsis
->
cls
;
auto
ellipsis_cls
=
Ellipsis
->
cls
;
return
new
ConcreteCompilerVariable
(
typeFromClass
(
ellipsis_cls
),
ellipsis
,
false
);
return
new
ConcreteCompilerVariable
(
typeFromClass
(
ellipsis_cls
),
ellipsis
);
}
}
llvm
::
Constant
*
embedParentModulePtr
()
{
llvm
::
Constant
*
embedParentModulePtr
()
{
...
@@ -1101,11 +1063,11 @@ private:
...
@@ -1101,11 +1063,11 @@ private:
llvm
::
Value
*
uncasted
=
emitter
.
createIC
(
pp
,
(
void
*
)
pyston
::
getGlobal
,
llvm_args
,
unw_info
);
llvm
::
Value
*
uncasted
=
emitter
.
createIC
(
pp
,
(
void
*
)
pyston
::
getGlobal
,
llvm_args
,
unw_info
);
llvm
::
Value
*
r
=
emitter
.
getBuilder
()
->
CreateIntToPtr
(
uncasted
,
g
.
llvm_value_type_ptr
);
llvm
::
Value
*
r
=
emitter
.
getBuilder
()
->
CreateIntToPtr
(
uncasted
,
g
.
llvm_value_type_ptr
);
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
r
,
true
);
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
r
);
}
else
{
}
else
{
llvm
::
Value
*
r
=
emitter
.
createCall2
(
unw_info
,
g
.
funcs
.
getGlobal
,
irstate
->
getGlobals
(),
llvm
::
Value
*
r
=
emitter
.
createCall2
(
unw_info
,
g
.
funcs
.
getGlobal
,
irstate
->
getGlobals
(),
embedRelocatablePtr
(
node
->
id
.
getBox
(),
g
.
llvm_boxedstring_type_ptr
));
embedRelocatablePtr
(
node
->
id
.
getBox
(),
g
.
llvm_boxedstring_type_ptr
));
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
r
,
true
);
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
r
);
}
}
}
}
...
@@ -1135,7 +1097,6 @@ private:
...
@@ -1135,7 +1097,6 @@ private:
// Where the parent lookup is done `deref_info.num_parents_from_passed_closure` times
// Where the parent lookup is done `deref_info.num_parents_from_passed_closure` times
CompilerVariable
*
closure
=
symbol_table
[
internString
(
PASSED_CLOSURE_NAME
)];
CompilerVariable
*
closure
=
symbol_table
[
internString
(
PASSED_CLOSURE_NAME
)];
llvm
::
Value
*
closureValue
=
closure
->
makeConverted
(
emitter
,
CLOSURE
)
->
getValue
();
llvm
::
Value
*
closureValue
=
closure
->
makeConverted
(
emitter
,
CLOSURE
)
->
getValue
();
closure
->
decvref
(
emitter
);
for
(
int
i
=
0
;
i
<
deref_info
.
num_parents_from_passed_closure
;
i
++
)
{
for
(
int
i
=
0
;
i
<
deref_info
.
num_parents_from_passed_closure
;
i
++
)
{
closureValue
=
emitter
.
getBuilder
()
->
CreateLoad
(
getClosureParentGep
(
emitter
,
closureValue
));
closureValue
=
emitter
.
getBuilder
()
->
CreateLoad
(
getClosureParentGep
(
emitter
,
closureValue
));
}
}
...
@@ -1167,13 +1128,13 @@ private:
...
@@ -1167,13 +1128,13 @@ private:
curblock
=
success_bb
;
curblock
=
success_bb
;
emitter
.
getBuilder
()
->
SetInsertPoint
(
curblock
);
emitter
.
getBuilder
()
->
SetInsertPoint
(
curblock
);
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
lookupResult
,
true
);
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
lookupResult
);
}
else
if
(
vst
==
ScopeInfo
::
VarScopeType
::
NAME
)
{
}
else
if
(
vst
==
ScopeInfo
::
VarScopeType
::
NAME
)
{
llvm
::
Value
*
boxedLocals
=
irstate
->
getBoxedLocalsVar
();
llvm
::
Value
*
boxedLocals
=
irstate
->
getBoxedLocalsVar
();
llvm
::
Value
*
attr
=
embedRelocatablePtr
(
node
->
id
.
getBox
(),
g
.
llvm_boxedstring_type_ptr
);
llvm
::
Value
*
attr
=
embedRelocatablePtr
(
node
->
id
.
getBox
(),
g
.
llvm_boxedstring_type_ptr
);
llvm
::
Value
*
module
=
irstate
->
getGlobals
();
llvm
::
Value
*
module
=
irstate
->
getGlobals
();
llvm
::
Value
*
r
=
emitter
.
createCall3
(
unw_info
,
g
.
funcs
.
boxedLocalsGet
,
boxedLocals
,
attr
,
module
);
llvm
::
Value
*
r
=
emitter
.
createCall3
(
unw_info
,
g
.
funcs
.
boxedLocalsGet
,
boxedLocals
,
attr
,
module
);
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
r
,
true
);
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
r
);
}
else
{
}
else
{
// vst is one of {FAST, CLOSURE}
// vst is one of {FAST, CLOSURE}
if
(
symbol_table
.
find
(
node
->
id
)
==
symbol_table
.
end
())
{
if
(
symbol_table
.
find
(
node
->
id
)
==
symbol_table
.
end
())
{
...
@@ -1204,8 +1165,6 @@ private:
...
@@ -1204,8 +1165,6 @@ private:
CompilerVariable
*
rtn
=
symbol_table
[
node
->
id
];
CompilerVariable
*
rtn
=
symbol_table
[
node
->
id
];
if
(
is_kill
)
if
(
is_kill
)
symbol_table
.
erase
(
node
->
id
);
symbol_table
.
erase
(
node
->
id
);
else
rtn
->
incvref
();
return
rtn
;
return
rtn
;
}
}
}
}
...
@@ -1227,14 +1186,12 @@ private:
...
@@ -1227,14 +1186,12 @@ private:
CompilerVariable
*
evalRepr
(
AST_Repr
*
node
,
const
UnwindInfo
&
unw_info
)
{
CompilerVariable
*
evalRepr
(
AST_Repr
*
node
,
const
UnwindInfo
&
unw_info
)
{
CompilerVariable
*
var
=
evalExpr
(
node
->
value
,
unw_info
);
CompilerVariable
*
var
=
evalExpr
(
node
->
value
,
unw_info
);
ConcreteCompilerVariable
*
cvar
=
var
->
makeConverted
(
emitter
,
var
->
getBoxType
());
ConcreteCompilerVariable
*
cvar
=
var
->
makeConverted
(
emitter
,
var
->
getBoxType
());
var
->
decvref
(
emitter
);
std
::
vector
<
llvm
::
Value
*>
args
{
cvar
->
getValue
()
};
std
::
vector
<
llvm
::
Value
*>
args
{
cvar
->
getValue
()
};
llvm
::
Value
*
rtn
=
emitter
.
createCall
(
unw_info
,
g
.
funcs
.
repr
,
args
);
llvm
::
Value
*
rtn
=
emitter
.
createCall
(
unw_info
,
g
.
funcs
.
repr
,
args
);
cvar
->
decvref
(
emitter
);
rtn
=
emitter
.
getBuilder
()
->
CreateBitCast
(
rtn
,
g
.
llvm_value_type_ptr
);
rtn
=
emitter
.
getBuilder
()
->
CreateBitCast
(
rtn
,
g
.
llvm_value_type_ptr
);
return
new
ConcreteCompilerVariable
(
STR
,
rtn
,
true
);
return
new
ConcreteCompilerVariable
(
STR
,
rtn
);
}
}
CompilerVariable
*
evalSet
(
AST_Set
*
node
,
const
UnwindInfo
&
unw_info
)
{
CompilerVariable
*
evalSet
(
AST_Set
*
node
,
const
UnwindInfo
&
unw_info
)
{
...
@@ -1245,7 +1202,7 @@ private:
...
@@ -1245,7 +1202,7 @@ private:
}
}
llvm
::
Value
*
v
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
createSet
);
llvm
::
Value
*
v
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
createSet
);
ConcreteCompilerVariable
*
rtn
=
new
ConcreteCompilerVariable
(
SET
,
v
,
true
);
ConcreteCompilerVariable
*
rtn
=
new
ConcreteCompilerVariable
(
SET
,
v
);
static
BoxedString
*
add_str
=
getStaticString
(
"add"
);
static
BoxedString
*
add_str
=
getStaticString
(
"add"
);
...
@@ -1254,8 +1211,6 @@ private:
...
@@ -1254,8 +1211,6 @@ private:
CallattrFlags
flags
=
{.
cls_only
=
true
,
.
null_on_nonexistent
=
false
,
.
argspec
=
ArgPassSpec
(
1
)
};
CallattrFlags
flags
=
{.
cls_only
=
true
,
.
null_on_nonexistent
=
false
,
.
argspec
=
ArgPassSpec
(
1
)
};
CompilerVariable
*
r
CompilerVariable
*
r
=
rtn
->
callattr
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
),
add_str
,
flags
,
{
elt
},
NULL
);
=
rtn
->
callattr
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
),
add_str
,
flags
,
{
elt
},
NULL
);
r
->
decvref
(
emitter
);
elt
->
decvref
(
emitter
);
}
}
return
rtn
;
return
rtn
;
...
@@ -1276,11 +1231,7 @@ private:
...
@@ -1276,11 +1231,7 @@ private:
elts
.
push_back
(
evalSlice
(
e
,
unw_info
));
elts
.
push_back
(
evalSlice
(
e
,
unw_info
));
}
}
// TODO makeTuple should probably just transfer the vref, but I want to keep things consistent
CompilerVariable
*
rtn
=
makeTuple
(
elts
);
CompilerVariable
*
rtn
=
makeTuple
(
elts
);
for
(
auto
*
e
:
elts
)
{
e
->
decvref
(
emitter
);
}
return
rtn
;
return
rtn
;
}
}
...
@@ -1290,12 +1241,12 @@ private:
...
@@ -1290,12 +1241,12 @@ private:
=
embedRelocatablePtr
(
irstate
->
getSourceInfo
()
->
parent_module
->
getStringConstant
(
node
->
str_data
,
true
),
=
embedRelocatablePtr
(
irstate
->
getSourceInfo
()
->
parent_module
->
getStringConstant
(
node
->
str_data
,
true
),
g
.
llvm_value_type_ptr
);
g
.
llvm_value_type_ptr
);
return
new
ConcreteCompilerVariable
(
STR
,
rtn
,
true
);
return
new
ConcreteCompilerVariable
(
STR
,
rtn
);
}
else
if
(
node
->
str_type
==
AST_Str
::
UNICODE
)
{
}
else
if
(
node
->
str_type
==
AST_Str
::
UNICODE
)
{
llvm
::
Value
*
rtn
=
embedRelocatablePtr
(
llvm
::
Value
*
rtn
=
embedRelocatablePtr
(
irstate
->
getSourceInfo
()
->
parent_module
->
getUnicodeConstant
(
node
->
str_data
),
g
.
llvm_value_type_ptr
);
irstate
->
getSourceInfo
()
->
parent_module
->
getUnicodeConstant
(
node
->
str_data
),
g
.
llvm_value_type_ptr
);
return
new
ConcreteCompilerVariable
(
typeFromClass
(
unicode_cls
),
rtn
,
true
);
return
new
ConcreteCompilerVariable
(
typeFromClass
(
unicode_cls
),
rtn
);
}
else
{
}
else
{
RELEASE_ASSERT
(
0
,
"%d"
,
node
->
str_type
);
RELEASE_ASSERT
(
0
,
"%d"
,
node
->
str_type
);
}
}
...
@@ -1306,8 +1257,6 @@ private:
...
@@ -1306,8 +1257,6 @@ private:
CompilerVariable
*
slice
=
evalSlice
(
node
->
slice
,
unw_info
);
CompilerVariable
*
slice
=
evalSlice
(
node
->
slice
,
unw_info
);
CompilerVariable
*
rtn
=
value
->
getitem
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
),
slice
);
CompilerVariable
*
rtn
=
value
->
getitem
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
),
slice
);
value
->
decvref
(
emitter
);
slice
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
...
@@ -1318,11 +1267,7 @@ private:
...
@@ -1318,11 +1267,7 @@ private:
elts
.
push_back
(
value
);
elts
.
push_back
(
value
);
}
}
// TODO makeTuple should probably just transfer the vref, but I want to keep things consistent
CompilerVariable
*
rtn
=
makeTuple
(
elts
);
CompilerVariable
*
rtn
=
makeTuple
(
elts
);
for
(
int
i
=
0
;
i
<
node
->
elts
.
size
();
i
++
)
{
elts
[
i
]
->
decvref
(
emitter
);
}
return
rtn
;
return
rtn
;
}
}
...
@@ -1331,18 +1276,15 @@ private:
...
@@ -1331,18 +1276,15 @@ private:
if
(
node
->
op_type
==
AST_TYPE
::
Not
)
{
if
(
node
->
op_type
==
AST_TYPE
::
Not
)
{
CompilerVariable
*
rtn
=
operand
->
nonzero
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
));
CompilerVariable
*
rtn
=
operand
->
nonzero
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
));
operand
->
decvref
(
emitter
);
assert
(
rtn
->
getType
()
==
BOOL
);
assert
(
rtn
->
getType
()
==
BOOL
);
llvm
::
Value
*
v
=
i1FromBool
(
emitter
,
static_cast
<
ConcreteCompilerVariable
*>
(
rtn
));
llvm
::
Value
*
v
=
i1FromBool
(
emitter
,
static_cast
<
ConcreteCompilerVariable
*>
(
rtn
));
assert
(
v
->
getType
()
==
g
.
i1
);
assert
(
v
->
getType
()
==
g
.
i1
);
llvm
::
Value
*
negated
=
emitter
.
getBuilder
()
->
CreateNot
(
v
);
llvm
::
Value
*
negated
=
emitter
.
getBuilder
()
->
CreateNot
(
v
);
rtn
->
decvref
(
emitter
);
return
boolFromI1
(
emitter
,
negated
);
return
boolFromI1
(
emitter
,
negated
);
}
else
{
}
else
{
CompilerVariable
*
rtn
=
operand
->
unaryop
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
),
node
->
op_type
);
CompilerVariable
*
rtn
=
operand
->
unaryop
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
),
node
->
op_type
);
operand
->
decvref
(
emitter
);
return
rtn
;
return
rtn
;
}
}
}
}
...
@@ -1355,14 +1297,11 @@ private:
...
@@ -1355,14 +1297,11 @@ private:
CompilerVariable
*
value
=
node
->
value
?
evalExpr
(
node
->
value
,
unw_info
)
:
getNone
();
CompilerVariable
*
value
=
node
->
value
?
evalExpr
(
node
->
value
,
unw_info
)
:
getNone
();
ConcreteCompilerVariable
*
convertedValue
=
value
->
makeConverted
(
emitter
,
value
->
getBoxType
());
ConcreteCompilerVariable
*
convertedValue
=
value
->
makeConverted
(
emitter
,
value
->
getBoxType
());
value
->
decvref
(
emitter
);
llvm
::
Value
*
rtn
llvm
::
Value
*
rtn
=
emitter
.
createCall2
(
unw_info
,
g
.
funcs
.
yield
,
convertedGenerator
->
getValue
(),
convertedValue
->
getValue
());
=
emitter
.
createCall2
(
unw_info
,
g
.
funcs
.
yield
,
convertedGenerator
->
getValue
(),
convertedValue
->
getValue
());
convertedGenerator
->
decvref
(
emitter
);
convertedValue
->
decvref
(
emitter
);
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
rtn
,
true
);
return
new
ConcreteCompilerVariable
(
UNKNOWN
,
rtn
);
}
}
CompilerVariable
*
evalMakeClass
(
AST_MakeClass
*
mkclass
,
const
UnwindInfo
&
unw_info
)
{
CompilerVariable
*
evalMakeClass
(
AST_MakeClass
*
mkclass
,
const
UnwindInfo
&
unw_info
)
{
...
@@ -1378,12 +1317,7 @@ private:
...
@@ -1378,12 +1317,7 @@ private:
}
}
CompilerVariable
*
_bases_tuple
=
makeTuple
(
bases
);
CompilerVariable
*
_bases_tuple
=
makeTuple
(
bases
);
for
(
auto
b
:
bases
)
{
b
->
decvref
(
emitter
);
}
ConcreteCompilerVariable
*
bases_tuple
=
_bases_tuple
->
makeConverted
(
emitter
,
_bases_tuple
->
getBoxType
());
ConcreteCompilerVariable
*
bases_tuple
=
_bases_tuple
->
makeConverted
(
emitter
,
_bases_tuple
->
getBoxType
());
_bases_tuple
->
decvref
(
emitter
);
std
::
vector
<
CompilerVariable
*>
decorators
;
std
::
vector
<
CompilerVariable
*>
decorators
;
for
(
auto
d
:
node
->
decorator_list
)
{
for
(
auto
d
:
node
->
decorator_list
)
{
...
@@ -1413,24 +1347,19 @@ private:
...
@@ -1413,24 +1347,19 @@ private:
CompilerVariable
*
attr_dict
=
func
->
call
(
emitter
,
getEmptyOpInfo
(
unw_info
),
ArgPassSpec
(
0
),
{},
NULL
);
CompilerVariable
*
attr_dict
=
func
->
call
(
emitter
,
getEmptyOpInfo
(
unw_info
),
ArgPassSpec
(
0
),
{},
NULL
);
func
->
decvref
(
emitter
);
ConcreteCompilerVariable
*
converted_attr_dict
=
attr_dict
->
makeConverted
(
emitter
,
attr_dict
->
getBoxType
());
ConcreteCompilerVariable
*
converted_attr_dict
=
attr_dict
->
makeConverted
(
emitter
,
attr_dict
->
getBoxType
());
attr_dict
->
decvref
(
emitter
);
llvm
::
Value
*
classobj
=
emitter
.
createCall3
(
llvm
::
Value
*
classobj
=
emitter
.
createCall3
(
unw_info
,
g
.
funcs
.
createUserClass
,
embedRelocatablePtr
(
node
->
name
.
getBox
(),
g
.
llvm_boxedstring_type_ptr
),
unw_info
,
g
.
funcs
.
createUserClass
,
embedRelocatablePtr
(
node
->
name
.
getBox
(),
g
.
llvm_boxedstring_type_ptr
),
bases_tuple
->
getValue
(),
converted_attr_dict
->
getValue
());
bases_tuple
->
getValue
(),
converted_attr_dict
->
getValue
());
// Note: createuserClass is free to manufacture non-class objects
// Note: createuserClass is free to manufacture non-class objects
CompilerVariable
*
cls
=
new
ConcreteCompilerVariable
(
UNKNOWN
,
classobj
,
true
);
CompilerVariable
*
cls
=
new
ConcreteCompilerVariable
(
UNKNOWN
,
classobj
);
for
(
int
i
=
decorators
.
size
()
-
1
;
i
>=
0
;
i
--
)
{
for
(
int
i
=
decorators
.
size
()
-
1
;
i
>=
0
;
i
--
)
{
cls
=
decorators
[
i
]
->
call
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
),
ArgPassSpec
(
1
),
{
cls
},
NULL
);
cls
=
decorators
[
i
]
->
call
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
),
ArgPassSpec
(
1
),
{
cls
},
NULL
);
decorators
[
i
]
->
decvref
(
emitter
);
}
}
// do we need to decvref this?
return
cls
;
return
cls
;
}
}
...
@@ -1442,7 +1371,6 @@ private:
...
@@ -1442,7 +1371,6 @@ private:
for
(
auto
d
:
args
->
defaults
)
{
for
(
auto
d
:
args
->
defaults
)
{
CompilerVariable
*
e
=
evalExpr
(
d
,
unw_info
);
CompilerVariable
*
e
=
evalExpr
(
d
,
unw_info
);
ConcreteCompilerVariable
*
converted
=
e
->
makeConverted
(
emitter
,
e
->
getBoxType
());
ConcreteCompilerVariable
*
converted
=
e
->
makeConverted
(
emitter
,
e
->
getBoxType
());
e
->
decvref
(
emitter
);
defaults
.
push_back
(
converted
);
defaults
.
push_back
(
converted
);
}
}
...
@@ -1474,10 +1402,6 @@ private:
...
@@ -1474,10 +1402,6 @@ private:
CompilerVariable
*
func
=
makeFunction
(
emitter
,
md
,
created_closure
,
irstate
->
getGlobalsIfCustom
(),
defaults
);
CompilerVariable
*
func
=
makeFunction
(
emitter
,
md
,
created_closure
,
irstate
->
getGlobalsIfCustom
(),
defaults
);
for
(
auto
d
:
defaults
)
{
d
->
decvref
(
emitter
);
}
return
func
;
return
func
;
}
}
...
@@ -1492,14 +1416,13 @@ private:
...
@@ -1492,14 +1416,13 @@ private:
for
(
int
i
=
decorators
.
size
()
-
1
;
i
>=
0
;
i
--
)
{
for
(
int
i
=
decorators
.
size
()
-
1
;
i
>=
0
;
i
--
)
{
func
=
decorators
[
i
]
->
call
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
),
ArgPassSpec
(
1
),
{
func
},
NULL
);
func
=
decorators
[
i
]
->
call
(
emitter
,
getOpInfoForNode
(
node
,
unw_info
),
ArgPassSpec
(
1
),
{
func
},
NULL
);
decorators
[
i
]
->
decvref
(
emitter
);
}
}
return
func
;
return
func
;
}
}
// Note: the behavior of this function must match type_analysis.cpp:unboxedType()
// Note: the behavior of this function must match type_analysis.cpp:unboxedType()
CompilerVariable
*
unboxVar
(
ConcreteCompilerType
*
t
,
llvm
::
Value
*
v
,
bool
grabbed
)
{
CompilerVariable
*
unboxVar
(
ConcreteCompilerType
*
t
,
llvm
::
Value
*
v
)
{
if
(
t
==
BOXED_INT
)
{
if
(
t
==
BOXED_INT
)
{
return
makeUnboxedInt
(
emitter
,
v
);
return
makeUnboxedInt
(
emitter
,
v
);
}
}
...
@@ -1510,7 +1433,7 @@ private:
...
@@ -1510,7 +1433,7 @@ private:
llvm
::
Value
*
unboxed
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
unboxBool
,
v
);
llvm
::
Value
*
unboxed
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
unboxBool
,
v
);
return
boolFromI1
(
emitter
,
unboxed
);
return
boolFromI1
(
emitter
,
unboxed
);
}
}
return
new
ConcreteCompilerVariable
(
t
,
v
,
grabbed
);
return
new
ConcreteCompilerVariable
(
t
,
v
);
}
}
template
<
typename
AstType
>
template
<
typename
AstType
>
...
@@ -1546,13 +1469,12 @@ private:
...
@@ -1546,13 +1469,12 @@ private:
#endif
#endif
ConcreteCompilerVariable
*
old_rtn
=
rtn
->
makeConverted
(
emitter
,
UNKNOWN
);
ConcreteCompilerVariable
*
old_rtn
=
rtn
->
makeConverted
(
emitter
,
UNKNOWN
);
rtn
->
decvref
(
emitter
);
llvm
::
Value
*
guard_check
=
old_rtn
->
makeClassCheck
(
emitter
,
speculated_class
);
llvm
::
Value
*
guard_check
=
old_rtn
->
makeClassCheck
(
emitter
,
speculated_class
);
assert
(
guard_check
->
getType
()
==
g
.
i1
);
assert
(
guard_check
->
getType
()
==
g
.
i1
);
createExprTypeGuard
(
guard_check
,
node
,
old_rtn
->
getValue
(),
unw_info
.
current_stmt
);
createExprTypeGuard
(
guard_check
,
node
,
old_rtn
->
getValue
(),
unw_info
.
current_stmt
);
rtn
=
unboxVar
(
speculated_type
,
old_rtn
->
getValue
()
,
true
);
rtn
=
unboxVar
(
speculated_type
,
old_rtn
->
getValue
());
}
}
assert
(
rtn
);
assert
(
rtn
);
...
@@ -1714,15 +1636,13 @@ private:
...
@@ -1714,15 +1636,13 @@ private:
if
(
vst
==
ScopeInfo
::
VarScopeType
::
GLOBAL
)
{
if
(
vst
==
ScopeInfo
::
VarScopeType
::
GLOBAL
)
{
if
(
irstate
->
getSourceInfo
()
->
scoping
->
areGlobalsFromModule
())
{
if
(
irstate
->
getSourceInfo
()
->
scoping
->
areGlobalsFromModule
())
{
auto
parent_module
=
llvm
::
ConstantExpr
::
getPointerCast
(
embedParentModulePtr
(),
g
.
llvm_value_type_ptr
);
auto
parent_module
=
llvm
::
ConstantExpr
::
getPointerCast
(
embedParentModulePtr
(),
g
.
llvm_value_type_ptr
);
ConcreteCompilerVariable
*
module
=
new
ConcreteCompilerVariable
(
MODULE
,
parent_module
,
false
);
ConcreteCompilerVariable
*
module
=
new
ConcreteCompilerVariable
(
MODULE
,
parent_module
);
module
->
setattr
(
emitter
,
getEmptyOpInfo
(
unw_info
),
name
.
getBox
(),
val
);
module
->
setattr
(
emitter
,
getEmptyOpInfo
(
unw_info
),
name
.
getBox
(),
val
);
module
->
decvref
(
emitter
);
}
else
{
}
else
{
auto
converted
=
val
->
makeConverted
(
emitter
,
val
->
getBoxType
());
auto
converted
=
val
->
makeConverted
(
emitter
,
val
->
getBoxType
());
emitter
.
createCall3
(
unw_info
,
g
.
funcs
.
setGlobal
,
irstate
->
getGlobals
(),
emitter
.
createCall3
(
unw_info
,
g
.
funcs
.
setGlobal
,
irstate
->
getGlobals
(),
embedRelocatablePtr
(
name
.
getBox
(),
g
.
llvm_boxedstring_type_ptr
),
embedRelocatablePtr
(
name
.
getBox
(),
g
.
llvm_boxedstring_type_ptr
),
converted
->
getValue
());
converted
->
getValue
());
converted
->
decvref
(
emitter
);
}
}
}
else
if
(
vst
==
ScopeInfo
::
VarScopeType
::
NAME
)
{
}
else
if
(
vst
==
ScopeInfo
::
VarScopeType
::
NAME
)
{
// TODO inefficient
// TODO inefficient
...
@@ -1734,11 +1654,7 @@ private:
...
@@ -1734,11 +1654,7 @@ private:
// FAST or CLOSURE
// FAST or CLOSURE
CompilerVariable
*&
prev
=
symbol_table
[
name
];
CompilerVariable
*&
prev
=
symbol_table
[
name
];
if
(
prev
!=
NULL
)
{
prev
->
decvref
(
emitter
);
}
prev
=
val
;
prev
=
val
;
val
->
incvref
();
// Clear out the is_defined name since it is now definitely defined:
// Clear out the is_defined name since it is now definitely defined:
assert
(
!
isIsDefinedName
(
name
.
s
()));
assert
(
!
isIsDefinedName
(
name
.
s
()));
...
@@ -1751,7 +1667,6 @@ private:
...
@@ -1751,7 +1667,6 @@ private:
// This is basically `closure->elts[offset] = val;`
// This is basically `closure->elts[offset] = val;`
CompilerVariable
*
closure
=
symbol_table
[
internString
(
CREATED_CLOSURE_NAME
)];
CompilerVariable
*
closure
=
symbol_table
[
internString
(
CREATED_CLOSURE_NAME
)];
llvm
::
Value
*
closureValue
=
closure
->
makeConverted
(
emitter
,
CLOSURE
)
->
getValue
();
llvm
::
Value
*
closureValue
=
closure
->
makeConverted
(
emitter
,
CLOSURE
)
->
getValue
();
closure
->
decvref
(
emitter
);
llvm
::
Value
*
gep
=
getClosureElementGep
(
emitter
,
closureValue
,
offset
);
llvm
::
Value
*
gep
=
getClosureElementGep
(
emitter
,
closureValue
,
offset
);
emitter
.
getBuilder
()
->
CreateStore
(
val
->
makeConverted
(
emitter
,
UNKNOWN
)
->
getValue
(),
gep
);
emitter
.
getBuilder
()
->
CreateStore
(
val
->
makeConverted
(
emitter
,
UNKNOWN
)
->
getValue
(),
gep
);
}
}
...
@@ -1761,7 +1676,6 @@ private:
...
@@ -1761,7 +1676,6 @@ private:
void
_doSetattr
(
AST_Attribute
*
target
,
CompilerVariable
*
val
,
const
UnwindInfo
&
unw_info
)
{
void
_doSetattr
(
AST_Attribute
*
target
,
CompilerVariable
*
val
,
const
UnwindInfo
&
unw_info
)
{
CompilerVariable
*
t
=
evalExpr
(
target
->
value
,
unw_info
);
CompilerVariable
*
t
=
evalExpr
(
target
->
value
,
unw_info
);
t
->
setattr
(
emitter
,
getEmptyOpInfo
(
unw_info
),
target
->
attr
.
getBox
(),
val
);
t
->
setattr
(
emitter
,
getEmptyOpInfo
(
unw_info
),
target
->
attr
.
getBox
(),
val
);
t
->
decvref
(
emitter
);
}
}
void
_doSetitem
(
AST_Subscript
*
target
,
CompilerVariable
*
val
,
const
UnwindInfo
&
unw_info
)
{
void
_doSetitem
(
AST_Subscript
*
target
,
CompilerVariable
*
val
,
const
UnwindInfo
&
unw_info
)
{
...
@@ -1770,8 +1684,6 @@ private:
...
@@ -1770,8 +1684,6 @@ private:
ConcreteCompilerVariable
*
converted_target
=
tget
->
makeConverted
(
emitter
,
tget
->
getBoxType
());
ConcreteCompilerVariable
*
converted_target
=
tget
->
makeConverted
(
emitter
,
tget
->
getBoxType
());
ConcreteCompilerVariable
*
converted_slice
=
slice
->
makeConverted
(
emitter
,
slice
->
getBoxType
());
ConcreteCompilerVariable
*
converted_slice
=
slice
->
makeConverted
(
emitter
,
slice
->
getBoxType
());
tget
->
decvref
(
emitter
);
slice
->
decvref
(
emitter
);
ConcreteCompilerVariable
*
converted_val
=
val
->
makeConverted
(
emitter
,
val
->
getBoxType
());
ConcreteCompilerVariable
*
converted_val
=
val
->
makeConverted
(
emitter
,
val
->
getBoxType
());
...
@@ -1792,10 +1704,6 @@ private:
...
@@ -1792,10 +1704,6 @@ private:
emitter
.
createCall3
(
unw_info
,
g
.
funcs
.
setitem
,
converted_target
->
getValue
(),
converted_slice
->
getValue
(),
emitter
.
createCall3
(
unw_info
,
g
.
funcs
.
setitem
,
converted_target
->
getValue
(),
converted_slice
->
getValue
(),
converted_val
->
getValue
());
converted_val
->
getValue
());
}
}
converted_target
->
decvref
(
emitter
);
converted_slice
->
decvref
(
emitter
);
converted_val
->
decvref
(
emitter
);
}
}
void
_doUnpackTuple
(
AST_Tuple
*
target
,
CompilerVariable
*
val
,
const
UnwindInfo
&
unw_info
)
{
void
_doUnpackTuple
(
AST_Tuple
*
target
,
CompilerVariable
*
val
,
const
UnwindInfo
&
unw_info
)
{
...
@@ -1813,7 +1721,6 @@ private:
...
@@ -1813,7 +1721,6 @@ private:
for
(
int
i
=
0
;
i
<
ntargets
;
i
++
)
{
for
(
int
i
=
0
;
i
<
ntargets
;
i
++
)
{
CompilerVariable
*
thisval
=
unpacked
[
i
];
CompilerVariable
*
thisval
=
unpacked
[
i
];
_doSet
(
target
->
elts
[
i
],
thisval
,
unw_info
);
_doSet
(
target
->
elts
[
i
],
thisval
,
unw_info
);
thisval
->
decvref
(
emitter
);
}
}
}
}
...
@@ -1857,7 +1764,6 @@ private:
...
@@ -1857,7 +1764,6 @@ private:
if
(
node
->
msg
)
{
if
(
node
->
msg
)
{
CompilerVariable
*
msg
=
evalExpr
(
node
->
msg
,
unw_info
);
CompilerVariable
*
msg
=
evalExpr
(
node
->
msg
,
unw_info
);
converted_msg
=
msg
->
makeConverted
(
emitter
,
msg
->
getBoxType
());
converted_msg
=
msg
->
makeConverted
(
emitter
,
msg
->
getBoxType
());
msg
->
decvref
(
emitter
);
llvm_args
.
push_back
(
converted_msg
->
getValue
());
llvm_args
.
push_back
(
converted_msg
->
getValue
());
}
else
{
}
else
{
llvm_args
.
push_back
(
getNullPtr
(
g
.
llvm_value_type_ptr
));
llvm_args
.
push_back
(
getNullPtr
(
g
.
llvm_value_type_ptr
));
...
@@ -1872,7 +1778,6 @@ private:
...
@@ -1872,7 +1778,6 @@ private:
for
(
int
i
=
0
;
i
<
node
->
targets
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
node
->
targets
.
size
();
i
++
)
{
_doSet
(
node
->
targets
[
i
],
val
,
unw_info
);
_doSet
(
node
->
targets
[
i
],
val
,
unw_info
);
}
}
val
->
decvref
(
emitter
);
}
}
void
doDelete
(
AST_Delete
*
node
,
const
UnwindInfo
&
unw_info
)
{
void
doDelete
(
AST_Delete
*
node
,
const
UnwindInfo
&
unw_info
)
{
...
@@ -1901,8 +1806,6 @@ private:
...
@@ -1901,8 +1806,6 @@ private:
ConcreteCompilerVariable
*
converted_target
=
tget
->
makeConverted
(
emitter
,
tget
->
getBoxType
());
ConcreteCompilerVariable
*
converted_target
=
tget
->
makeConverted
(
emitter
,
tget
->
getBoxType
());
ConcreteCompilerVariable
*
converted_slice
=
slice
->
makeConverted
(
emitter
,
slice
->
getBoxType
());
ConcreteCompilerVariable
*
converted_slice
=
slice
->
makeConverted
(
emitter
,
slice
->
getBoxType
());
tget
->
decvref
(
emitter
);
slice
->
decvref
(
emitter
);
bool
do_patchpoint
=
ENABLE_ICDELITEMS
;
bool
do_patchpoint
=
ENABLE_ICDELITEMS
;
if
(
do_patchpoint
)
{
if
(
do_patchpoint
)
{
...
@@ -1916,9 +1819,6 @@ private:
...
@@ -1916,9 +1819,6 @@ private:
}
else
{
}
else
{
emitter
.
createCall2
(
unw_info
,
g
.
funcs
.
delitem
,
converted_target
->
getValue
(),
converted_slice
->
getValue
());
emitter
.
createCall2
(
unw_info
,
g
.
funcs
.
delitem
,
converted_target
->
getValue
(),
converted_slice
->
getValue
());
}
}
converted_target
->
decvref
(
emitter
);
converted_slice
->
decvref
(
emitter
);
}
}
void
_doDelAttr
(
AST_Attribute
*
node
,
const
UnwindInfo
&
unw_info
)
{
void
_doDelAttr
(
AST_Attribute
*
node
,
const
UnwindInfo
&
unw_info
)
{
...
@@ -1974,13 +1874,11 @@ private:
...
@@ -1974,13 +1874,11 @@ private:
void
doExec
(
AST_Exec
*
node
,
const
UnwindInfo
&
unw_info
)
{
void
doExec
(
AST_Exec
*
node
,
const
UnwindInfo
&
unw_info
)
{
CompilerVariable
*
body
=
evalExpr
(
node
->
body
,
unw_info
);
CompilerVariable
*
body
=
evalExpr
(
node
->
body
,
unw_info
);
llvm
::
Value
*
vbody
=
body
->
makeConverted
(
emitter
,
body
->
getBoxType
())
->
getValue
();
llvm
::
Value
*
vbody
=
body
->
makeConverted
(
emitter
,
body
->
getBoxType
())
->
getValue
();
body
->
decvref
(
emitter
);
llvm
::
Value
*
vglobals
;
llvm
::
Value
*
vglobals
;
if
(
node
->
globals
)
{
if
(
node
->
globals
)
{
CompilerVariable
*
globals
=
evalExpr
(
node
->
globals
,
unw_info
);
CompilerVariable
*
globals
=
evalExpr
(
node
->
globals
,
unw_info
);
vglobals
=
globals
->
makeConverted
(
emitter
,
globals
->
getBoxType
())
->
getValue
();
vglobals
=
globals
->
makeConverted
(
emitter
,
globals
->
getBoxType
())
->
getValue
();
globals
->
decvref
(
emitter
);
}
else
{
}
else
{
vglobals
=
getNullPtr
(
g
.
llvm_value_type_ptr
);
vglobals
=
getNullPtr
(
g
.
llvm_value_type_ptr
);
}
}
...
@@ -1989,7 +1887,6 @@ private:
...
@@ -1989,7 +1887,6 @@ private:
if
(
node
->
locals
)
{
if
(
node
->
locals
)
{
CompilerVariable
*
locals
=
evalExpr
(
node
->
locals
,
unw_info
);
CompilerVariable
*
locals
=
evalExpr
(
node
->
locals
,
unw_info
);
vlocals
=
locals
->
makeConverted
(
emitter
,
locals
->
getBoxType
())
->
getValue
();
vlocals
=
locals
->
makeConverted
(
emitter
,
locals
->
getBoxType
())
->
getValue
();
locals
->
decvref
(
emitter
);
}
else
{
}
else
{
vlocals
=
getNullPtr
(
g
.
llvm_value_type_ptr
);
vlocals
=
getNullPtr
(
g
.
llvm_value_type_ptr
);
}
}
...
@@ -2004,10 +1901,9 @@ private:
...
@@ -2004,10 +1901,9 @@ private:
if
(
node
->
dest
)
{
if
(
node
->
dest
)
{
auto
d
=
evalExpr
(
node
->
dest
,
unw_info
);
auto
d
=
evalExpr
(
node
->
dest
,
unw_info
);
dest
=
d
->
makeConverted
(
emitter
,
d
->
getBoxType
());
dest
=
d
->
makeConverted
(
emitter
,
d
->
getBoxType
());
d
->
decvref
(
emitter
);
}
else
{
}
else
{
llvm
::
Value
*
sys_stdout_val
=
emitter
.
createCall
(
unw_info
,
g
.
funcs
.
getSysStdout
);
llvm
::
Value
*
sys_stdout_val
=
emitter
.
createCall
(
unw_info
,
g
.
funcs
.
getSysStdout
);
dest
=
new
ConcreteCompilerVariable
(
UNKNOWN
,
sys_stdout_val
,
true
);
dest
=
new
ConcreteCompilerVariable
(
UNKNOWN
,
sys_stdout_val
);
// TODO: speculate that sys.stdout is a file?
// TODO: speculate that sys.stdout is a file?
}
}
assert
(
dest
);
assert
(
dest
);
...
@@ -2018,16 +1914,12 @@ private:
...
@@ -2018,16 +1914,12 @@ private:
if
(
node
->
values
.
size
()
==
1
)
{
if
(
node
->
values
.
size
()
==
1
)
{
CompilerVariable
*
var
=
evalExpr
(
node
->
values
[
0
],
unw_info
);
CompilerVariable
*
var
=
evalExpr
(
node
->
values
[
0
],
unw_info
);
converted
=
var
->
makeConverted
(
emitter
,
var
->
getBoxType
());
converted
=
var
->
makeConverted
(
emitter
,
var
->
getBoxType
());
var
->
decvref
(
emitter
);
}
else
{
}
else
{
converted
=
new
ConcreteCompilerVariable
(
UNKNOWN
,
getNullPtr
(
g
.
llvm_value_type_ptr
)
,
true
);
converted
=
new
ConcreteCompilerVariable
(
UNKNOWN
,
getNullPtr
(
g
.
llvm_value_type_ptr
));
}
}
emitter
.
createCall3
(
unw_info
,
g
.
funcs
.
printHelper
,
dest
->
getValue
(),
converted
->
getValue
(),
emitter
.
createCall3
(
unw_info
,
g
.
funcs
.
printHelper
,
dest
->
getValue
(),
converted
->
getValue
(),
getConstantInt
(
node
->
nl
,
g
.
i1
));
getConstantInt
(
node
->
nl
,
g
.
i1
));
dest
->
decvref
(
emitter
);
converted
->
decvref
(
emitter
);
}
}
void
doReturn
(
AST_Return
*
node
,
const
UnwindInfo
&
unw_info
)
{
void
doReturn
(
AST_Return
*
node
,
const
UnwindInfo
&
unw_info
)
{
...
@@ -2041,30 +1933,16 @@ private:
...
@@ -2041,30 +1933,16 @@ private:
}
}
assert
(
val
);
assert
(
val
);
// If we ask the return variable to become UNKNOWN (the typical return type),
// it will be forced to split a copy of itself and incref.
// But often the return variable will already be in the right shape, so in
// that case asking it to convert to itself ends up just being an incvref
// and doesn't end up emitting an incref+decref pair.
// This could also be handled by casting from the CompilerVariable to
// ConcreteCompilerVariable, but this way feels a little more robust to me.
ConcreteCompilerType
*
opt_rtn_type
=
irstate
->
getReturnType
();
ConcreteCompilerType
*
opt_rtn_type
=
irstate
->
getReturnType
();
if
(
irstate
->
getReturnType
()
->
llvmType
()
==
val
->
getConcreteType
()
->
llvmType
())
if
(
irstate
->
getReturnType
()
->
llvmType
()
==
val
->
getConcreteType
()
->
llvmType
())
opt_rtn_type
=
val
->
getConcreteType
();
opt_rtn_type
=
val
->
getConcreteType
();
ConcreteCompilerVariable
*
rtn
=
val
->
makeConverted
(
emitter
,
opt_rtn_type
);
ConcreteCompilerVariable
*
rtn
=
val
->
makeConverted
(
emitter
,
opt_rtn_type
);
rtn
->
ensureGrabbed
(
emitter
);
val
->
decvref
(
emitter
);
for
(
auto
&
p
:
symbol_table
)
{
p
.
second
->
decvref
(
emitter
);
}
symbol_table
.
clear
();
symbol_table
.
clear
();
endBlock
(
DEAD
);
endBlock
(
DEAD
);
// This is tripping in test/tests/return_selfreferential.py. kmod says it should be removed.
// ASSERT(rtn->getVrefs() == 1, "%d", rtn->getVrefs());
assert
(
rtn
->
getValue
());
assert
(
rtn
->
getValue
());
emitter
.
getBuilder
()
->
CreateRet
(
rtn
->
getValue
());
emitter
.
getBuilder
()
->
CreateRet
(
rtn
->
getValue
());
}
}
...
@@ -2094,8 +1972,6 @@ private:
...
@@ -2094,8 +1972,6 @@ private:
void
doExpr
(
AST_Expr
*
node
,
const
UnwindInfo
&
unw_info
)
{
void
doExpr
(
AST_Expr
*
node
,
const
UnwindInfo
&
unw_info
)
{
CompilerVariable
*
var
=
evalExpr
(
node
->
value
,
unw_info
);
CompilerVariable
*
var
=
evalExpr
(
node
->
value
,
unw_info
);
var
->
decvref
(
emitter
);
}
}
void
doOSRExit
(
llvm
::
BasicBlock
*
normal_target
,
AST_Jump
*
osr_key
)
{
void
doOSRExit
(
llvm
::
BasicBlock
*
normal_target
,
AST_Jump
*
osr_key
)
{
...
@@ -2137,11 +2013,11 @@ private:
...
@@ -2137,11 +2013,11 @@ private:
SortedSymbolTable
sorted_symbol_table
(
symbol_table
.
begin
(),
symbol_table
.
end
());
SortedSymbolTable
sorted_symbol_table
(
symbol_table
.
begin
(),
symbol_table
.
end
());
sorted_symbol_table
[
internString
(
FRAME_INFO_PTR_NAME
)]
sorted_symbol_table
[
internString
(
FRAME_INFO_PTR_NAME
)]
=
new
ConcreteCompilerVariable
(
FRAME_INFO
,
irstate
->
getFrameInfoVar
()
,
true
);
=
new
ConcreteCompilerVariable
(
FRAME_INFO
,
irstate
->
getFrameInfoVar
());
if
(
!
irstate
->
getSourceInfo
()
->
scoping
->
areGlobalsFromModule
())
{
if
(
!
irstate
->
getSourceInfo
()
->
scoping
->
areGlobalsFromModule
())
{
sorted_symbol_table
[
internString
(
PASSED_GLOBALS_NAME
)]
sorted_symbol_table
[
internString
(
PASSED_GLOBALS_NAME
)]
=
new
ConcreteCompilerVariable
(
UNKNOWN
,
irstate
->
getGlobals
()
,
true
);
=
new
ConcreteCompilerVariable
(
UNKNOWN
,
irstate
->
getGlobals
());
}
}
// For OSR calls, we use the same calling convention as in some other places; namely,
// For OSR calls, we use the same calling convention as in some other places; namely,
...
@@ -2192,12 +2068,6 @@ private:
...
@@ -2192,12 +2068,6 @@ private:
assert
(
var
->
getType
()
!=
BOXED_FLOAT
assert
(
var
->
getType
()
!=
BOXED_FLOAT
&&
"should probably unbox it, but why is it boxed in the first place?"
);
&&
"should probably unbox it, but why is it boxed in the first place?"
);
// This line can never get hit right now for the same reason that the variables must already be
// concrete,
// because we're over-generating phis.
ASSERT
(
var
->
isGrabbed
(),
"%s"
,
p
.
first
.
c_str
());
// var->ensureGrabbed(emitter);
llvm
::
Value
*
val
=
var
->
getValue
();
llvm
::
Value
*
val
=
var
->
getValue
();
if
(
arg_num
<
3
)
{
if
(
arg_num
<
3
)
{
...
@@ -2260,10 +2130,6 @@ private:
...
@@ -2260,10 +2130,6 @@ private:
emitter
.
getBuilder
()
->
CreateCall
(
l_free
,
malloc_save
);
emitter
.
getBuilder
()
->
CreateCall
(
l_free
,
malloc_save
);
}
}
for
(
int
i
=
0
;
i
<
converted_args
.
size
();
i
++
)
{
converted_args
[
i
]
->
decvref
(
emitter
);
}
emitter
.
getBuilder
()
->
CreateRet
(
rtn
);
emitter
.
getBuilder
()
->
CreateRet
(
rtn
);
emitter
.
getBuilder
()
->
SetInsertPoint
(
starting_block
);
emitter
.
getBuilder
()
->
SetInsertPoint
(
starting_block
);
...
@@ -2317,7 +2183,6 @@ private:
...
@@ -2317,7 +2183,6 @@ private:
if
(
a
)
{
if
(
a
)
{
CompilerVariable
*
v
=
evalExpr
(
a
,
unw_info
);
CompilerVariable
*
v
=
evalExpr
(
a
,
unw_info
);
ConcreteCompilerVariable
*
converted
=
v
->
makeConverted
(
emitter
,
v
->
getBoxType
());
ConcreteCompilerVariable
*
converted
=
v
->
makeConverted
(
emitter
,
v
->
getBoxType
());
v
->
decvref
(
emitter
);
args
.
push_back
(
converted
->
getValue
());
args
.
push_back
(
converted
->
getValue
());
}
else
{
}
else
{
args
.
push_back
(
embedRelocatablePtr
(
None
,
g
.
llvm_value_type_ptr
,
"cNone"
));
args
.
push_back
(
embedRelocatablePtr
(
None
,
g
.
llvm_value_type_ptr
,
"cNone"
));
...
@@ -2414,15 +2279,13 @@ private:
...
@@ -2414,15 +2279,13 @@ private:
void
loadArgument
(
InternedString
name
,
ConcreteCompilerType
*
t
,
llvm
::
Value
*
v
,
const
UnwindInfo
&
unw_info
)
{
void
loadArgument
(
InternedString
name
,
ConcreteCompilerType
*
t
,
llvm
::
Value
*
v
,
const
UnwindInfo
&
unw_info
)
{
assert
(
name
.
s
()
!=
FRAME_INFO_PTR_NAME
);
assert
(
name
.
s
()
!=
FRAME_INFO_PTR_NAME
);
CompilerVariable
*
var
=
unboxVar
(
t
,
v
,
false
);
CompilerVariable
*
var
=
unboxVar
(
t
,
v
);
_doSet
(
name
,
var
,
unw_info
);
_doSet
(
name
,
var
,
unw_info
);
var
->
decvref
(
emitter
);
}
}
void
loadArgument
(
AST_expr
*
name
,
ConcreteCompilerType
*
t
,
llvm
::
Value
*
v
,
const
UnwindInfo
&
unw_info
)
{
void
loadArgument
(
AST_expr
*
name
,
ConcreteCompilerType
*
t
,
llvm
::
Value
*
v
,
const
UnwindInfo
&
unw_info
)
{
CompilerVariable
*
var
=
unboxVar
(
t
,
v
,
false
);
CompilerVariable
*
var
=
unboxVar
(
t
,
v
);
_doSet
(
name
,
var
,
unw_info
);
_doSet
(
name
,
var
,
unw_info
);
var
->
decvref
(
emitter
);
}
}
bool
allowableFakeEndingSymbol
(
InternedString
name
)
{
bool
allowableFakeEndingSymbol
(
InternedString
name
)
{
...
@@ -2451,10 +2314,6 @@ private:
...
@@ -2451,10 +2314,6 @@ private:
// symbol table? '%s'", p.first.c_str());
// symbol table? '%s'", p.first.c_str());
if
(
!
irstate
->
getLiveness
()
->
isLiveAtEnd
(
p
.
first
,
myblock
))
{
if
(
!
irstate
->
getLiveness
()
->
isLiveAtEnd
(
p
.
first
,
myblock
))
{
// printf("%s dead at end of %d; grabbed = %d, %d vrefs\n", p.first.c_str(), myblock->idx,
// p.second->isGrabbed(), p.second->getVrefs());
p
.
second
->
decvref
(
emitter
);
symbol_table
.
erase
(
getIsDefinedName
(
p
.
first
));
symbol_table
.
erase
(
getIsDefinedName
(
p
.
first
));
symbol_table
.
erase
(
p
.
first
);
symbol_table
.
erase
(
p
.
first
);
}
else
if
(
irstate
->
getPhis
()
->
isRequiredAfter
(
p
.
first
,
myblock
))
{
}
else
if
(
irstate
->
getPhis
()
->
isRequiredAfter
(
p
.
first
,
myblock
))
{
...
@@ -2466,8 +2325,7 @@ private:
...
@@ -2466,8 +2325,7 @@ private:
// printf("have to convert %s from %s to %s\n", p.first.c_str(),
// printf("have to convert %s from %s to %s\n", p.first.c_str(),
// p.second->getType()->debugName().c_str(), phi_type->debugName().c_str());
// p.second->getType()->debugName().c_str(), phi_type->debugName().c_str());
ConcreteCompilerVariable
*
v
=
p
.
second
->
makeConverted
(
emitter
,
phi_type
);
ConcreteCompilerVariable
*
v
=
p
.
second
->
makeConverted
(
emitter
,
phi_type
);
p
.
second
->
decvref
(
emitter
);
symbol_table
[
p
.
first
]
=
v
;
symbol_table
[
p
.
first
]
=
v
->
split
(
emitter
);
}
else
{
}
else
{
#ifndef NDEBUG
#ifndef NDEBUG
if
(
myblock
->
successors
.
size
())
{
if
(
myblock
->
successors
.
size
())
{
...
@@ -2512,7 +2370,7 @@ private:
...
@@ -2512,7 +2370,7 @@ private:
// printf("no st entry, setting undefined\n");
// printf("no st entry, setting undefined\n");
ConcreteCompilerType
*
phi_type
=
types
->
getTypeAtBlockEnd
(
*
it
,
myblock
);
ConcreteCompilerType
*
phi_type
=
types
->
getTypeAtBlockEnd
(
*
it
,
myblock
);
assert
(
phi_type
->
isUsable
());
assert
(
phi_type
->
isUsable
());
cur
=
new
ConcreteCompilerVariable
(
phi_type
,
llvm
::
UndefValue
::
get
(
phi_type
->
llvmType
())
,
true
);
cur
=
new
ConcreteCompilerVariable
(
phi_type
,
llvm
::
UndefValue
::
get
(
phi_type
->
llvmType
()));
_setFake
(
defined_name
,
makeBool
(
0
));
_setFake
(
defined_name
,
makeBool
(
0
));
}
}
}
}
...
@@ -2567,10 +2425,6 @@ public:
...
@@ -2567,10 +2425,6 @@ public:
EndingState
getEndingSymbolTable
()
override
{
EndingState
getEndingSymbolTable
()
override
{
assert
(
state
==
FINISHED
||
state
==
DEAD
);
assert
(
state
==
FINISHED
||
state
==
DEAD
);
// for (SymbolTable::iterator it = symbol_table.begin(); it != symbol_table.end(); ++it) {
// printf("%s %p %d\n", it->first.c_str(), it->second, it->second->getVrefs());
//}
SourceInfo
*
source
=
irstate
->
getSourceInfo
();
SourceInfo
*
source
=
irstate
->
getSourceInfo
();
SymbolTable
*
st
=
new
SymbolTable
(
symbol_table
);
SymbolTable
*
st
=
new
SymbolTable
(
symbol_table
);
...
@@ -2584,9 +2438,6 @@ public:
...
@@ -2584,9 +2438,6 @@ public:
}
}
if
(
myblock
->
successors
.
size
()
==
0
)
{
if
(
myblock
->
successors
.
size
()
==
0
)
{
for
(
auto
&
p
:
*
st
)
{
p
.
second
->
decvref
(
emitter
);
}
st
->
clear
();
st
->
clear
();
symbol_table
.
clear
();
symbol_table
.
clear
();
return
EndingState
(
st
,
phi_st
,
curblock
,
outgoing_exc_state
);
return
EndingState
(
st
,
phi_st
,
curblock
,
outgoing_exc_state
);
...
@@ -2610,8 +2461,6 @@ public:
...
@@ -2610,8 +2461,6 @@ public:
// We're going to sort out which symbols need to go in phi_st and which belong inst.
// We're going to sort out which symbols need to go in phi_st and which belong inst.
for
(
SymbolTable
::
iterator
it
=
st
->
begin
();
it
!=
st
->
end
();)
{
for
(
SymbolTable
::
iterator
it
=
st
->
begin
();
it
!=
st
->
end
();)
{
if
(
allowableFakeEndingSymbol
(
it
->
first
)
||
irstate
->
getPhis
()
->
isRequiredAfter
(
it
->
first
,
myblock
))
{
if
(
allowableFakeEndingSymbol
(
it
->
first
)
||
irstate
->
getPhis
()
->
isRequiredAfter
(
it
->
first
,
myblock
))
{
ASSERT
(
it
->
second
->
isGrabbed
(),
"%s"
,
it
->
first
.
c_str
());
assert
(
it
->
second
->
getVrefs
()
==
1
);
// this conversion should have already happened... should refactor this.
// this conversion should have already happened... should refactor this.
ConcreteCompilerType
*
ending_type
;
ConcreteCompilerType
*
ending_type
;
if
(
isIsDefinedName
(
it
->
first
.
s
()))
{
if
(
isIsDefinedName
(
it
->
first
.
s
()))
{
...
@@ -2630,8 +2479,7 @@ public:
...
@@ -2630,8 +2479,7 @@ public:
}
}
assert
(
ending_type
->
isUsable
());
assert
(
ending_type
->
isUsable
());
//(*phi_st)[it->first] = it->second->makeConverted(emitter, it->second->getConcreteType());
//(*phi_st)[it->first] = it->second->makeConverted(emitter, it->second->getConcreteType());
// printf("%s %p %d\n", it->first.c_str(), it->second, it->second->getVrefs());
(
*
phi_st
)[
it
->
first
]
=
it
->
second
->
makeConverted
(
emitter
,
ending_type
);
(
*
phi_st
)[
it
->
first
]
=
it
->
second
->
split
(
emitter
)
->
makeConverted
(
emitter
,
ending_type
);
it
=
st
->
erase
(
it
);
it
=
st
->
erase
(
it
);
}
else
{
}
else
{
++
it
;
++
it
;
...
@@ -2657,11 +2505,9 @@ public:
...
@@ -2657,11 +2505,9 @@ public:
assert
(
st
);
assert
(
st
);
DupCache
cache
;
DupCache
cache
;
for
(
SymbolTable
::
iterator
it
=
st
->
begin
();
it
!=
st
->
end
();
++
it
)
{
for
(
SymbolTable
::
iterator
it
=
st
->
begin
();
it
!=
st
->
end
();
++
it
)
{
// printf("Copying in %s: %p, %d\n", it->first.c_str(), it->second, it->second->getVrefs());
// printf("Copying in %s, a %s\n", it->first.c_str(), it->second->getType()->debugName().c_str());
// printf("Copying in %s, a %s\n", it->first.c_str(), it->second->getType()->debugName().c_str());
symbol_table
[
it
->
first
]
=
it
->
second
->
dup
(
cache
);
symbol_table
[
it
->
first
]
=
it
->
second
->
dup
(
cache
);
assert
(
symbol_table
[
it
->
first
]
->
getType
()
->
isUsable
());
assert
(
symbol_table
[
it
->
first
]
->
getType
()
->
isUsable
());
// printf("got: %p, %d\n", symbol_table[it->first], symbol_table[it->first]->getVrefs());
}
}
}
}
...
@@ -2686,7 +2532,7 @@ public:
...
@@ -2686,7 +2532,7 @@ public:
if
(
scope_info
->
takesClosure
())
{
if
(
scope_info
->
takesClosure
())
{
passed_closure
=
AI
;
passed_closure
=
AI
;
symbol_table
[
internString
(
PASSED_CLOSURE_NAME
)]
symbol_table
[
internString
(
PASSED_CLOSURE_NAME
)]
=
new
ConcreteCompilerVariable
(
getPassedClosureType
(),
AI
,
true
);
=
new
ConcreteCompilerVariable
(
getPassedClosureType
(),
AI
);
++
AI
;
++
AI
;
}
}
...
@@ -2697,11 +2543,11 @@ public:
...
@@ -2697,11 +2543,11 @@ public:
llvm
::
Value
*
new_closure
=
emitter
.
getBuilder
()
->
CreateCall2
(
llvm
::
Value
*
new_closure
=
emitter
.
getBuilder
()
->
CreateCall2
(
g
.
funcs
.
createClosure
,
passed_closure
,
getConstantInt
(
scope_info
->
getClosureSize
(),
g
.
i64
));
g
.
funcs
.
createClosure
,
passed_closure
,
getConstantInt
(
scope_info
->
getClosureSize
(),
g
.
i64
));
symbol_table
[
internString
(
CREATED_CLOSURE_NAME
)]
symbol_table
[
internString
(
CREATED_CLOSURE_NAME
)]
=
new
ConcreteCompilerVariable
(
getCreatedClosureType
(),
new_closure
,
true
);
=
new
ConcreteCompilerVariable
(
getCreatedClosureType
(),
new_closure
);
}
}
if
(
irstate
->
getSourceInfo
()
->
is_generator
)
{
if
(
irstate
->
getSourceInfo
()
->
is_generator
)
{
symbol_table
[
internString
(
PASSED_GENERATOR_NAME
)]
=
new
ConcreteCompilerVariable
(
GENERATOR
,
AI
,
true
);
symbol_table
[
internString
(
PASSED_GENERATOR_NAME
)]
=
new
ConcreteCompilerVariable
(
GENERATOR
,
AI
);
++
AI
;
++
AI
;
}
}
...
@@ -2857,9 +2703,9 @@ public:
...
@@ -2857,9 +2703,9 @@ public:
llvm
::
Value
*
exc_traceback
=
emitter
.
getBuilder
()
->
CreateLoad
(
exc_traceback_ptr
);
llvm
::
Value
*
exc_traceback
=
emitter
.
getBuilder
()
->
CreateLoad
(
exc_traceback_ptr
);
addOutgoingExceptionState
(
addOutgoingExceptionState
(
IRGenerator
::
ExceptionState
(
capi_exc_dest
,
new
ConcreteCompilerVariable
(
UNKNOWN
,
exc_type
,
true
),
IRGenerator
::
ExceptionState
(
capi_exc_dest
,
new
ConcreteCompilerVariable
(
UNKNOWN
,
exc_type
),
new
ConcreteCompilerVariable
(
UNKNOWN
,
exc_value
,
true
),
new
ConcreteCompilerVariable
(
UNKNOWN
,
exc_value
),
new
ConcreteCompilerVariable
(
UNKNOWN
,
exc_traceback
,
true
)));
new
ConcreteCompilerVariable
(
UNKNOWN
,
exc_traceback
)));
emitter
.
getBuilder
()
->
CreateBr
(
final_dest
);
emitter
.
getBuilder
()
->
CreateBr
(
final_dest
);
}
}
...
@@ -2916,9 +2762,9 @@ public:
...
@@ -2916,9 +2762,9 @@ public:
if
(
final_dest
)
{
if
(
final_dest
)
{
// Catch the exception and forward to final_dest:
// Catch the exception and forward to final_dest:
addOutgoingExceptionState
(
ExceptionState
(
cxx_exc_dest
,
addOutgoingExceptionState
(
ExceptionState
(
cxx_exc_dest
,
new
ConcreteCompilerVariable
(
UNKNOWN
,
exc_type
,
true
),
new
ConcreteCompilerVariable
(
UNKNOWN
,
exc_type
),
new
ConcreteCompilerVariable
(
UNKNOWN
,
exc_value
,
true
),
new
ConcreteCompilerVariable
(
UNKNOWN
,
exc_value
),
new
ConcreteCompilerVariable
(
UNKNOWN
,
exc_traceback
,
true
)));
new
ConcreteCompilerVariable
(
UNKNOWN
,
exc_traceback
)));
builder
->
CreateBr
(
final_dest
);
builder
->
CreateBr
(
final_dest
);
}
else
{
}
else
{
...
...
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