Skip to content

Commit

Permalink
Revert "try to improve literal variable access in compiled methods"
Browse files Browse the repository at this point in the history
This reverts commit 815f973.

Conflicts:
	rsqueakvm/model/compiled_methods.py
  • Loading branch information
timfel committed May 10, 2016
1 parent eabe104 commit dc8b8e2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 34 deletions.
22 changes: 16 additions & 6 deletions rsqueakvm/interpreter_bytecodes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from rsqueakvm import error
from rsqueakvm import wrapper, error
from rsqueakvm.model.compiled_methods import W_CompiledMethod
from rsqueakvm.model.pointers import W_PointersObject
from rsqueakvm.primitives import bytecodes, prim_table, prim_holder
Expand Down Expand Up @@ -126,7 +126,9 @@ def pushLiteralVariableBytecode(self, interp, current_bytecode):
# which is an object with two named vars, and fetches the second
# named var (the value).
index = current_bytecode & 31
self.push(self.w_method().getliteralvariable(self.space, index))
w_association = self.w_method().getliteral(index)
association = wrapper.AssociationWrapper(self.space, w_association)
self.push(association.value())

@bytecode_implementation()
def storeAndPopReceiverVariableBytecode(self, interp, current_bytecode):
Expand Down Expand Up @@ -207,7 +209,9 @@ def extendedPushBytecode(self, interp, current_bytecode, descriptor):
elif variableType == 2:
self.push(self.w_method().getliteral(variableIndex))
elif variableType == 3:
self.push(self.w_method().getliteralvariable(self.space, variableIndex))
w_association = self.w_method().getliteral(variableIndex)
association = wrapper.AssociationWrapper(self.space, w_association)
self.push(association.value())
else:
assert 0

Expand All @@ -220,7 +224,9 @@ def _extendedStoreBytecode(self, interp, current_bytecode, descriptor):
elif variableType == 2:
raise error.FatalError("Illegal ExtendedStoreBytecode. veriableType 2.")
elif variableType == 3:
self.w_method().setliteralvariable(self.space, variableIndex, self.top())
w_association = self.w_method().getliteral(variableIndex)
association = wrapper.AssociationWrapper(self.space, w_association)
association.store_value(self.top())

@bytecode_implementation(parameter_bytes=1)
def extendedStoreBytecode(self, interp, current_bytecode, descriptor):
Expand Down Expand Up @@ -501,13 +507,17 @@ def doubleExtendedDoAnythingBytecode(self, interp, current_bytecode,
self.push(self.w_method().getliteral(third))
elif opType == 4:
# pushLiteralVariable
self.push(self.w_method().getliteralvariable(self.space, third))
w_association = self.w_method().getliteral(third)
association = wrapper.AssociationWrapper(self.space, w_association)
self.push(association.value())
elif opType == 5:
self.w_receiver().store(self.space, third, self.top())
elif opType == 6:
self.w_receiver().store(self.space, third, self.pop())
elif opType == 7:
self.w_method().setliteralvariable(self.space, third, self.top())
w_association = self.w_method().getliteral(third)
association = wrapper.AssociationWrapper(self.space, w_association)
association.store_value(self.top())

@bytecode_implementation(parameter_bytes=1)
def singleExtendedSuperBytecode(self, interp, current_bytecode, descriptor):
Expand Down
14 changes: 0 additions & 14 deletions rsqueakvm/model/compiled_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,6 @@ def setliteral(self, index, w_lit):
self.compiledin_class = None
self.changed()

def setliteralvariable(self, space, index, w_value):
w_assoc = self.getliteral(index)
from rsqueakvm import wrapper
association = wrapper.AssociationWrapper(space, w_assoc)
association.store_value(w_value)
self.changed()

def setliterals(self, literals):
"""NOT RPYTHON""" # Only for testing, not safe.
self.literals = literals
Expand Down Expand Up @@ -182,13 +175,6 @@ def getheader(self):
def getliteral(self, index):
return self.literals[index]

@elidable_for_version(2)
def getliteralvariable(self, space, index):
from rsqueakvm import wrapper
w_assoc = self.getliteral(index)
association = wrapper.AssociationWrapper(space, w_assoc)
return association.value()

@elidable_for_version(0)
def primitive(self):
return self._primitive
Expand Down
7 changes: 7 additions & 0 deletions rsqueakvm/test/jittest/test_modern.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ def test_named_access_fresh(self, spy, squeak, tmpdir):
setfield_gc(ConstPtr(ptr163), i171, descr=<FieldS rsqueakvm.interpreter.Interpreter.inst_interrupt_check_counter 20>)
i172 = int_le(i171, 0)
guard_false(i172, descr=<Guard0xe445c9c>)
i174 = arraylen_gc(p61, descr=<ArrayP 4>)
i175 = arraylen_gc(p68, descr=<ArrayP 4>)
i176 = arraylen_gc(p94, descr=<ArrayP 4>)
i177 = arraylen_gc(p112, descr=<ArrayP 4>)
i178 = arraylen_gc(p140, descr=<ArrayP 4>)
jump(p0, p1, i2, p3, p6, p7, i8, i9, p10, p11, i13, p14, i170, p23, p25, p27, p29, p31, p33, p35, p37, p39, p41, p43, p45, p47, p61, p68, p63, p94, p112, p114, p140, p142, p154, i171, descr=TargetToken(241143860))
""")

Expand Down Expand Up @@ -125,6 +130,8 @@ def test_named_access_and_send(self, spy, squeak, tmpdir):
guard_false(i237, descr=<Guard0xdba7380>)
i239 = arraylen_gc(p65, descr=<ArrayP 4>)
i240 = arraylen_gc(p86, descr=<ArrayP 4>)
i241 = arraylen_gc(p89, descr=<ArrayP 4>)
i242 = arraylen_gc(p97, descr=<ArrayP 4>)
i243 = arraylen_gc(p119, descr=<ArrayP 4>)
i245 = int_sub_ovf(i147, 10)
guard_no_overflow(descr=<Guard0xdba7354>)
Expand Down
14 changes: 0 additions & 14 deletions rsqueakvm/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,20 +180,6 @@ class AssociationWrapper(Wrapper):
key = make_getter(0)
value, store_value = make_getter_setter(1)

def read(self, index0):
try:
strategy = self.wrapped._get_strategy()
from rsqueakvm.storage import SimpleStorageStrategy
# tfel: We are certain that the storage is _not_ something crazy
# like ContextPartShadow. ContextPartShadow>>fetch has random
# effects so that any read from an association wrapper could not be
# used inside an elidable function
assert isinstance(strategy, SimpleStorageStrategy)
return strategy.fetch(self.wrapped, index0)
# XXX Index error never raised after translation
except IndexError:
raise WrapperException("Unexpected instance layout. Too small")

class SchedulerWrapper(Wrapper):
priority_list = make_getter(0)
active_process, store_active_process = make_getter_setter(1)
Expand Down

0 comments on commit dc8b8e2

Please sign in to comment.