Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
x-RPySOM
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mu
x-RPySOM
Commits
b42c2142
Commit
b42c2142
authored
Apr 26, 2014
by
Stefan Marr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid pop when not necessary, but might keep objects alive, let them escape
Signed-off-by:
Stefan Marr
<
git@stefan-marr.de
>
parent
afdcafac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
frame.py
src/som/interpreter/frame.py
+8
-1
interpreter.py
src/som/interpreter/interpreter.py
+3
-3
No files found.
src/som/interpreter/frame.py
View file @
b42c2142
...
...
@@ -69,9 +69,15 @@ class Frame(object):
def
get_number_of_arguments
(
self
):
return
self
.
_method
.
get_number_of_arguments
()
def
top
(
self
):
stack_pointer
=
jit
.
promote
(
self
.
_stack_pointer
)
assert
0
<=
stack_pointer
<
len
(
self
.
_stack
)
return
self
.
_stack
[
stack_pointer
]
def
pop
(
self
):
""" Pop an object from the expression stack and return it """
stack_pointer
=
self
.
_stack_pointer
stack_pointer
=
jit
.
promote
(
self
.
_stack_pointer
)
assert
0
<=
stack_pointer
<
len
(
self
.
_stack
)
self
.
_stack_pointer
=
stack_pointer
-
1
result
=
self
.
_stack
[
stack_pointer
]
self
.
_stack
[
stack_pointer
]
=
None
...
...
@@ -81,6 +87,7 @@ class Frame(object):
def
push
(
self
,
value
):
""" Push an object onto the expression stack """
stack_pointer
=
jit
.
promote
(
self
.
_stack_pointer
)
+
1
assert
0
<=
stack_pointer
<
len
(
self
.
_stack
)
self
.
_stack
[
stack_pointer
]
=
value
self
.
_stack_pointer
=
stack_pointer
...
...
src/som/interpreter/interpreter.py
View file @
b42c2142
...
...
@@ -106,12 +106,12 @@ class Interpreter(object):
receiver
.
send_does_not_understand
(
frame
,
signature
,
self
.
_universe
,
self
)
def
_do_return_local
(
self
,
frame
):
return
frame
.
p
op
()
return
frame
.
t
op
()
@
jit
.
unroll_safe
def
_do_return_non_local
(
self
,
frame
):
# get result from stack
result
=
frame
.
p
op
()
result
=
frame
.
t
op
()
# Compute the context for the non-local return
context
=
frame
.
get_outer_context
()
...
...
@@ -127,7 +127,7 @@ class Interpreter(object):
# ... and execute the escapedBlock message instead
sender
.
send_escaped_block
(
frame
,
block
,
self
.
_universe
,
self
)
return
frame
.
p
op
()
return
frame
.
t
op
()
raise
ReturnException
(
result
,
context
)
...
...
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