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
d08aff31
Commit
d08aff31
authored
Jan 27, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add small version of pidigits ubenchmark and fix gc issue
parent
2d19b2c1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
1 deletion
+41
-1
src/runtime/long.cpp
src/runtime/long.cpp
+8
-0
src/runtime/long.h
src/runtime/long.h
+2
-0
src/runtime/types.cpp
src/runtime/types.cpp
+1
-1
test/tests/pidigits_small.py
test/tests/pidigits_small.py
+30
-0
No files found.
src/runtime/long.cpp
View file @
d08aff31
...
...
@@ -35,6 +35,14 @@ BoxedClass* long_cls;
#define IS_LITTLE_ENDIAN (int)*(unsigned char*)&one
#define PY_ABS_LLONG_MIN (0 - (unsigned PY_LONG_LONG)PY_LLONG_MIN)
void
BoxedLong
::
gchandler
(
GCVisitor
*
v
,
Box
*
b
)
{
boxGCHandler
(
v
,
b
);
BoxedLong
*
l
=
(
BoxedLong
*
)
b
;
v
->
visitPotentialRange
((
void
**
)
&
l
->
n
,
(
void
**
)((
&
l
->
n
)
+
1
));
}
extern
"C"
int
_PyLong_Sign
(
PyObject
*
l
)
noexcept
{
return
mpz_sgn
(
static_cast
<
BoxedLong
*>
(
l
)
->
n
);
}
...
...
src/runtime/long.h
View file @
d08aff31
...
...
@@ -32,6 +32,8 @@ public:
BoxedLong
()
__attribute__
((
visibility
(
"default"
)))
{}
static
void
gchandler
(
GCVisitor
*
v
,
Box
*
b
);
DEFAULT_CLASS
(
long_cls
);
};
...
...
src/runtime/types.cpp
View file @
d08aff31
...
...
@@ -1024,7 +1024,7 @@ void setupRuntime() {
bool_cls
=
new
BoxedHeapClass
(
int_cls
,
NULL
,
0
,
sizeof
(
BoxedBool
),
false
);
complex_cls
=
new
BoxedHeapClass
(
object_cls
,
NULL
,
0
,
sizeof
(
BoxedComplex
),
false
);
// TODO we're leaking long memory!
long_cls
=
new
BoxedHeapClass
(
object_cls
,
NULL
,
0
,
sizeof
(
BoxedLong
),
false
);
long_cls
=
new
BoxedHeapClass
(
object_cls
,
&
BoxedLong
::
gchandler
,
0
,
sizeof
(
BoxedLong
),
false
);
float_cls
=
new
BoxedHeapClass
(
object_cls
,
NULL
,
0
,
sizeof
(
BoxedFloat
),
false
);
function_cls
=
new
BoxedHeapClass
(
object_cls
,
&
functionGCHandler
,
offsetof
(
BoxedFunction
,
attrs
),
sizeof
(
BoxedFunction
),
false
);
...
...
test/tests/pidigits_small.py
0 → 100644
View file @
d08aff31
import
time
def
pidigits
(
length
):
i
=
k
=
ns
=
0
k1
=
1
n
,
a
,
d
,
t
,
u
=
1
,
0
,
1
,
0
,
0
while
(
True
):
k
+=
1
t
=
n
<<
1
n
*=
k
a
+=
t
k1
+=
2
a
*=
k1
d
*=
k1
if
a
>=
n
:
t
,
u
=
divmod
(
n
*
3
+
a
,
d
)
u
+=
n
if
d
>
u
:
ns
=
ns
*
10
+
t
i
+=
1
if
i
%
10
==
0
:
print
i
,
ns
ns
=
0
if
i
>=
length
:
break
a
-=
d
*
t
a
*=
10
n
*=
10
pidigits
(
1000
)
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