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
ce616ca2
Commit
ce616ca2
authored
Jul 31, 2014
by
Travis Hance
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
got rid of 2s
parent
db5bd976
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
725 additions
and
729 deletions
+725
-729
src/asm_writing/rewriter.cpp
src/asm_writing/rewriter.cpp
+95
-96
src/asm_writing/rewriter.h
src/asm_writing/rewriter.h
+49
-49
src/core/types.h
src/core/types.h
+8
-8
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+562
-565
src/runtime/objmodel.h
src/runtime/objmodel.h
+11
-11
No files found.
src/asm_writing/rewriter
2
.cpp
→
src/asm_writing/rewriter.cpp
View file @
ce616ca2
This diff is collapsed.
Click to expand it.
src/asm_writing/rewriter
2
.h
→
src/asm_writing/rewriter.h
View file @
ce616ca2
...
...
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef PYSTON_ASMWRITING_REWRITER
2
_H
#define PYSTON_ASMWRITING_REWRITER
2
_H
#ifndef PYSTON_ASMWRITING_REWRITER_H
#define PYSTON_ASMWRITING_REWRITER_H
#include <memory>
...
...
@@ -29,7 +29,7 @@ class ICSlotInfo;
class
ICSlotRewrite
;
class
ICInvalidator
;
class
RewriterVar
2
;
class
RewriterVar
;
struct
Location
{
public:
...
...
@@ -112,7 +112,7 @@ template <> struct hash<pyston::Location> {
namespace
pyston
{
class
RewriterVarUsage
2
{
class
RewriterVarUsage
{
public:
enum
KillFlag
{
NoKill
,
...
...
@@ -120,12 +120,12 @@ public:
};
private:
RewriterVar
2
*
var
;
RewriterVar
*
var
;
bool
done_using
;
RewriterVarUsage
2
();
RewriterVarUsage
2
(
const
RewriterVarUsage2
&
)
=
delete
;
RewriterVarUsage
2
&
operator
=
(
const
RewriterVarUsage2
&
)
=
delete
;
RewriterVarUsage
();
RewriterVarUsage
(
const
RewriterVarUsage
&
)
=
delete
;
RewriterVarUsage
&
operator
=
(
const
RewriterVarUsage
&
)
=
delete
;
void
assertValid
()
{
assert
(
var
);
...
...
@@ -135,17 +135,17 @@ private:
public:
// Creates a new Usage object of this var; ownership of
// one use of the var gets passed to this new object.
RewriterVarUsage
2
(
RewriterVar2
*
var
);
RewriterVarUsage
(
RewriterVar
*
var
);
// Move constructor; don't need it for performance reasons, but because
// semantically we have to pass the ownership of the use.
RewriterVarUsage
2
(
RewriterVarUsage2
&&
usage
);
RewriterVarUsage
2
&
operator
=
(
RewriterVarUsage2
&&
usage
);
RewriterVarUsage
(
RewriterVarUsage
&&
usage
);
RewriterVarUsage
&
operator
=
(
RewriterVarUsage
&&
usage
);
static
RewriterVarUsage
2
empty
();
static
RewriterVarUsage
empty
();
#ifndef NDEBUG
~
RewriterVarUsage
2
()
{
~
RewriterVarUsage
()
{
if
(
!
std
::
uncaught_exception
())
assert
(
done_using
);
}
...
...
@@ -155,25 +155,25 @@ public:
bool
isDoneUsing
();
void
ensureDoneUsing
();
RewriterVarUsage
2
addUse
();
RewriterVarUsage
addUse
();
void
addGuard
(
uint64_t
val
);
void
addGuardNotEq
(
uint64_t
val
);
void
addAttrGuard
(
int
offset
,
uint64_t
val
);
RewriterVarUsage
2
getAttr
(
int
offset
,
KillFlag
kill
,
Location
loc
=
Location
::
any
());
void
setAttr
(
int
offset
,
RewriterVarUsage
2
other
);
RewriterVarUsage
2
cmp
(
AST_TYPE
::
AST_TYPE
cmp_type
,
RewriterVarUsage2
other
,
Location
loc
=
Location
::
any
());
RewriterVarUsage
2
toBool
(
KillFlag
kill
,
Location
loc
=
Location
::
any
());
RewriterVarUsage
getAttr
(
int
offset
,
KillFlag
kill
,
Location
loc
=
Location
::
any
());
void
setAttr
(
int
offset
,
RewriterVarUsage
other
);
RewriterVarUsage
cmp
(
AST_TYPE
::
AST_TYPE
cmp_type
,
RewriterVarUsage
other
,
Location
loc
=
Location
::
any
());
RewriterVarUsage
toBool
(
KillFlag
kill
,
Location
loc
=
Location
::
any
());
friend
class
Rewriter
2
;
friend
class
Rewriter
;
};
class
Rewriter
2
;
// This might make more sense as an inner class of Rewriter
2
, but
class
Rewriter
;
// This might make more sense as an inner class of Rewriter, but
// you can't forward-declare that :/
class
RewriterVar
2
{
class
RewriterVar
{
private:
Rewriter
2
*
rewriter
;
Rewriter
*
rewriter
;
int
num_uses
;
std
::
unordered_set
<
Location
>
locations
;
...
...
@@ -181,7 +181,7 @@ private:
// Indicates that this value is a pointer to a fixed-size range in the scratch space.
// This is a vector of variable usages that keep the range allocated.
std
::
vector
<
RewriterVarUsage
2
>
scratch_range
;
std
::
vector
<
RewriterVarUsage
>
scratch_range
;
// Gets a copy of this variable in a register, spilling/reloading if necessary.
// TODO have to be careful with the result since the interface doesn't guarantee
...
...
@@ -198,16 +198,16 @@ public:
void
incUse
();
void
decUse
();
RewriterVar
2
(
Rewriter2
*
rewriter
,
Location
location
)
:
rewriter
(
rewriter
),
num_uses
(
0
)
{
RewriterVar
(
Rewriter
*
rewriter
,
Location
location
)
:
rewriter
(
rewriter
),
num_uses
(
0
)
{
assert
(
rewriter
);
locations
.
insert
(
location
);
}
friend
class
RewriterVarUsage
2
;
friend
class
Rewriter
2
;
friend
class
RewriterVarUsage
;
friend
class
Rewriter
;
};
class
Rewriter
2
:
public
ICSlotRewrite
::
CommitHook
{
class
Rewriter
:
public
ICSlotRewrite
::
CommitHook
{
private:
std
::
unique_ptr
<
ICSlotRewrite
>
rewrite
;
assembler
::
Assembler
*
assembler
;
...
...
@@ -218,15 +218,15 @@ private:
std
::
vector
<
int
>
live_out_regs
;
std
::
unordered_map
<
Location
,
RewriterVar
2
*>
vars_by_location
;
std
::
vector
<
RewriterVar
2
*>
args
;
std
::
vector
<
RewriterVar
2
*>
live_outs
;
std
::
unordered_map
<
Location
,
RewriterVar
*>
vars_by_location
;
std
::
vector
<
RewriterVar
*>
args
;
std
::
vector
<
RewriterVar
*>
live_outs
;
Rewriter
2
(
ICSlotRewrite
*
rewrite
,
int
num_args
,
const
std
::
vector
<
int
>&
live_outs
);
Rewriter
(
ICSlotRewrite
*
rewrite
,
int
num_args
,
const
std
::
vector
<
int
>&
live_outs
);
void
assertChangesOk
()
{
assert
(
done_guarding
);
}
void
kill
(
RewriterVar
2
*
var
);
void
kill
(
RewriterVar
*
var
);
// Allocates a register. dest must be of type Register or AnyReg
assembler
::
Register
allocReg
(
Location
dest
);
...
...
@@ -240,22 +240,22 @@ private:
void
spillRegister
(
assembler
::
XMMRegister
reg
);
// Given an empty location, do the internal bookkeeping to create a new var out of that location.
RewriterVarUsage
2
createNewVar
(
Location
dest
);
RewriterVarUsage
createNewVar
(
Location
dest
);
// Do the bookkeeping to say that var is now also in location l
void
addLocationToVar
(
RewriterVar
2
*
var
,
Location
l
);
void
addLocationToVar
(
RewriterVar
*
var
,
Location
l
);
// Do the bookkeeping to say that var is no longer in location l
void
removeLocationFromVar
(
RewriterVar
2
*
var
,
Location
l
);
void
removeLocationFromVar
(
RewriterVar
*
var
,
Location
l
);
void
finishAssembly
(
int
continue_offset
)
override
;
std
::
pair
<
RewriterVarUsage
2
,
int
>
_allocate
(
int
n
);
std
::
pair
<
RewriterVarUsage
,
int
>
_allocate
(
int
n
);
int
ndecisions
;
uint64_t
decision_path
;
public:
// This should be called exactly once for each argument
RewriterVarUsage
2
getArg
(
int
argnum
);
RewriterVarUsage
getArg
(
int
argnum
);
Location
getReturnDestination
();
...
...
@@ -265,26 +265,26 @@ public:
TypeRecorder
*
getTypeRecorder
();
void
trap
();
RewriterVarUsage
2
loadConst
(
int64_t
val
,
Location
loc
=
Location
::
any
());
RewriterVarUsage
2
call
(
bool
can_call_into_python
,
void
*
func_addr
,
std
::
vector
<
RewriterVarUsage2
>
args
);
RewriterVarUsage
2
call
(
bool
can_call_into_python
,
void
*
func_addr
,
RewriterVarUsage2
arg0
);
RewriterVarUsage
2
call
(
bool
can_call_into_python
,
void
*
func_addr
,
RewriterVarUsage2
arg0
,
RewriterVarUsage2
arg1
);
RewriterVarUsage
2
allocate
(
int
n
);
RewriterVarUsage
2
allocateAndCopy
(
RewriterVarUsage2
array
,
int
n
);
RewriterVarUsage
2
allocateAndCopyPlus1
(
RewriterVarUsage2
first_elem
,
RewriterVarUsage2
rest
,
int
n_rest
);
RewriterVarUsage
loadConst
(
int64_t
val
,
Location
loc
=
Location
::
any
());
RewriterVarUsage
call
(
bool
can_call_into_python
,
void
*
func_addr
,
std
::
vector
<
RewriterVarUsage
>
args
);
RewriterVarUsage
call
(
bool
can_call_into_python
,
void
*
func_addr
,
RewriterVarUsage
arg0
);
RewriterVarUsage
call
(
bool
can_call_into_python
,
void
*
func_addr
,
RewriterVarUsage
arg0
,
RewriterVarUsage
arg1
);
RewriterVarUsage
allocate
(
int
n
);
RewriterVarUsage
allocateAndCopy
(
RewriterVarUsage
array
,
int
n
);
RewriterVarUsage
allocateAndCopyPlus1
(
RewriterVarUsage
first_elem
,
RewriterVarUsage
rest
,
int
n_rest
);
void
deallocateStack
(
int
nbytes
);
void
commit
();
void
commitReturning
(
RewriterVarUsage
2
rtn
);
void
commitReturning
(
RewriterVarUsage
rtn
);
void
addDependenceOn
(
ICInvalidator
&
);
static
Rewriter
2
*
createRewriter
(
void
*
rtn_addr
,
int
num_args
,
const
char
*
debug_name
);
static
Rewriter
*
createRewriter
(
void
*
rtn_addr
,
int
num_args
,
const
char
*
debug_name
);
void
addDecision
(
int
way
);
friend
class
RewriterVar
2
;
friend
class
RewriterVarUsage
2
;
friend
class
RewriterVar
;
friend
class
RewriterVarUsage
;
};
}
...
...
src/core/types.h
View file @
ce616ca2
...
...
@@ -238,7 +238,7 @@ public:
};
typedef
std
::
vector
<
CompiledFunction
*>
FunctionList
;
class
CallRewriteArgs
2
;
class
CallRewriteArgs
;
class
CLFunction
{
public:
int
num_args
;
...
...
@@ -254,7 +254,7 @@ public:
// of the normal dispatch through the functionlist.
// This can be used to implement functions which know how to rewrite themselves,
// such as typeCall.
typedef
Box
*
(
*
InternalCallable
)(
BoxedFunction
*
,
CallRewriteArgs
2
*
,
ArgPassSpec
,
Box
*
,
Box
*
,
Box
*
,
Box
**
,
typedef
Box
*
(
*
InternalCallable
)(
BoxedFunction
*
,
CallRewriteArgs
*
,
ArgPassSpec
,
Box
*
,
Box
*
,
Box
*
,
Box
**
,
const
std
::
vector
<
const
std
::
string
*>*
);
InternalCallable
internal_callable
=
NULL
;
...
...
@@ -376,9 +376,9 @@ private:
};
class
SetattrRewriteArgs
2
;
class
GetattrRewriteArgs
2
;
class
DelattrRewriteArgs
2
;
class
SetattrRewriteArgs
;
class
GetattrRewriteArgs
;
class
DelattrRewriteArgs
;
struct
HCAttrs
{
public:
...
...
@@ -402,15 +402,15 @@ public:
HCAttrs
*
getAttrsPtr
();
void
setattr
(
const
std
::
string
&
attr
,
Box
*
val
,
SetattrRewriteArgs
2
*
rewrite_args2
);
void
setattr
(
const
std
::
string
&
attr
,
Box
*
val
,
SetattrRewriteArgs
*
rewrite_args
);
void
giveAttr
(
const
std
::
string
&
attr
,
Box
*
val
)
{
assert
(
this
->
getattr
(
attr
)
==
NULL
);
this
->
setattr
(
attr
,
val
,
NULL
);
}
Box
*
getattr
(
const
std
::
string
&
attr
,
GetattrRewriteArgs
2
*
rewrite_args2
);
Box
*
getattr
(
const
std
::
string
&
attr
,
GetattrRewriteArgs
*
rewrite_args
);
Box
*
getattr
(
const
std
::
string
&
attr
)
{
return
getattr
(
attr
,
NULL
);
}
void
delattr
(
const
std
::
string
&
attr
,
DelattrRewriteArgs
2
*
rewrite_args
);
void
delattr
(
const
std
::
string
&
attr
,
DelattrRewriteArgs
*
rewrite_args
);
};
...
...
src/runtime/objmodel.cpp
View file @
ce616ca2
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/runtime/objmodel.h
View file @
ce616ca2
...
...
@@ -81,11 +81,11 @@ extern "C" void assertFail(BoxedModule* inModule, Box* msg);
extern
"C"
bool
isSubclass
(
BoxedClass
*
child
,
BoxedClass
*
parent
);
extern
"C"
BoxedClosure
*
createClosure
(
BoxedClosure
*
parent_closure
);
class
BinopRewriteArgs
2
;
extern
"C"
Box
*
binopInternal
(
Box
*
lhs
,
Box
*
rhs
,
int
op_type
,
bool
inplace
,
BinopRewriteArgs
2
*
rewrite_args
);
class
BinopRewriteArgs
;
extern
"C"
Box
*
binopInternal
(
Box
*
lhs
,
Box
*
rhs
,
int
op_type
,
bool
inplace
,
BinopRewriteArgs
*
rewrite_args
);
class
CallRewriteArgs
2
;
Box
*
typeCallInternal
(
BoxedFunction
*
f
,
CallRewriteArgs
2
*
rewrite_args
,
ArgPassSpec
argspec
,
Box
*
arg1
,
Box
*
arg2
,
class
CallRewriteArgs
;
Box
*
typeCallInternal
(
BoxedFunction
*
f
,
CallRewriteArgs
*
rewrite_args
,
ArgPassSpec
argspec
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
);
enum
LookupScope
{
...
...
@@ -93,17 +93,17 @@ enum LookupScope {
INST_ONLY
=
2
,
CLASS_OR_INST
=
3
,
};
extern
"C"
Box
*
callattrInternal
(
Box
*
obj
,
const
std
::
string
*
attr
,
LookupScope
,
CallRewriteArgs
2
*
rewrite_args
,
extern
"C"
Box
*
callattrInternal
(
Box
*
obj
,
const
std
::
string
*
attr
,
LookupScope
,
CallRewriteArgs
*
rewrite_args
,
ArgPassSpec
argspec
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
);
extern
"C"
void
delattr_internal
(
Box
*
obj
,
const
std
::
string
&
attr
,
bool
allow_custom
,
DelattrRewriteArgs
2
*
rewrite_args
);
struct
CompareRewriteArgs
2
;
Box
*
compareInternal
(
Box
*
lhs
,
Box
*
rhs
,
int
op_type
,
CompareRewriteArgs
2
*
rewrite_args
);
DelattrRewriteArgs
*
rewrite_args
);
struct
CompareRewriteArgs
;
Box
*
compareInternal
(
Box
*
lhs
,
Box
*
rhs
,
int
op_type
,
CompareRewriteArgs
*
rewrite_args
);
Box
*
getattr_internal
(
Box
*
obj
,
const
std
::
string
&
attr
,
bool
check_cls
,
bool
allow_custom
,
GetattrRewriteArgs
2
*
rewrite_args2
);
GetattrRewriteArgs
*
rewrite_args
);
Box
*
typeLookup
(
BoxedClass
*
cls
,
const
std
::
string
&
attr
,
GetattrRewriteArgs
2
*
rewrite_args2
);
Box
*
typeLookup
(
BoxedClass
*
cls
,
const
std
::
string
&
attr
,
GetattrRewriteArgs
*
rewrite_args
);
extern
"C"
void
raiseAttributeErrorStr
(
const
char
*
typeName
,
const
char
*
attr
)
__attribute__
((
__noreturn__
));
extern
"C"
void
raiseAttributeError
(
Box
*
obj
,
const
char
*
attr
)
__attribute__
((
__noreturn__
));
...
...
@@ -113,7 +113,7 @@ Box* typeCall(Box*, BoxedList*);
Box
*
typeNew
(
Box
*
,
Box
*
);
bool
isUserDefined
(
BoxedClass
*
cls
);
Box
*
callCLFunc
(
CLFunction
*
f
,
CallRewriteArgs
2
*
rewrite_args
,
int
num_output_args
,
BoxedClosure
*
closure
,
Box
*
callCLFunc
(
CLFunction
*
f
,
CallRewriteArgs
*
rewrite_args
,
int
num_output_args
,
BoxedClosure
*
closure
,
BoxedGenerator
*
generator
,
Box
*
oarg1
,
Box
*
oarg2
,
Box
*
oarg3
,
Box
**
oargs
);
}
#endif
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