Commit 5e81d51b authored by George Rayns's avatar George Rayns

setfield works for refs

parent 1284e7ba
......@@ -2,7 +2,7 @@ from rpython.jit.backend.llsupport.assembler import BaseAssembler
from rpython.jit.backend.model import CompiledLoopToken
from rpython.jit.metainterp.compile import DoneWithThisFrameDescrInt, ResumeGuardDescr
from rpython.jit.metainterp.history import BasicFinalDescr, ConstInt
from rpython.jit.metainterp.resoperation import rop, InputArgInt, InputArgRef, AbstractResOp, GuardResOp, AbstractInputArg
from rpython.jit.metainterp.resoperation import rop, InputArgInt, InputArgRef, AbstractResOp, GuardResOp, AbstractInputArg, IntOp, RefOp
from rpython.rlib.rmu.holstein import MuCommInst, MuBinOptr, MuCmpOptr, MuID, MuBinOpStatus
from rpython.rlib.rmu.holstein_meta import MuIRBuilder
from rpython.rlib.rmu import holstein
......@@ -705,10 +705,18 @@ class AssemblerMu():
# finish either has 0 or 1 args
finish_args = op.getarglist()
if len(finish_args) > 0:
arg = deps.get_val(finish_args[0])
#arg = self.resolve_rv(finish_args[0], bb)
assert len(finish_args) == 1
finish_arg = finish_args[0]
arg = deps.get_val(finish_arg)
jf_storeargn = self.irblr.unique_gen_sym("@assemble_loop.jf_storearg")
self.irblr.new_store(id=jf_storeargn, is_ptr=False, ord=MuMemOrd.NOT_ATOMIC, refty=self.MuInt(64).id, loc=self.get_jf_int1_ref(ops, deps.get_val("jf")), newval=arg)
# ints and floats(?) in the ints hybrid section, refs in the refs hybrid
if finish_arg.type == "i":
self.irblr.new_store(id=jf_storeargn, is_ptr=False, ord=MuMemOrd.NOT_ATOMIC, refty=self.MuInt(64).id, loc=self.get_jf_int1_ref(ops, deps.get_val("jf")), newval=arg)
elif finish_arg.type == "r":
self.irblr.new_store(id=jf_storeargn, is_ptr=False, ord=MuMemOrd.NOT_ATOMIC, refty=self.MuRef(self.MuVoid()).id, loc=self.get_jf_ref1_ref(ops, deps.get_val("jf")), newval=arg)
else:
# Not implemented for floats yet
raise NotImplementedError
ops.append(jf_storeargn)
# return the jitframe if we are translated
......@@ -887,7 +895,7 @@ class AssemblerMu():
# Setfield doesn't return anything
return ops, None
def consider_getfield_gc_i(self, op, deps):
def impl_getfield_gc(self, op, deps):
ops = []
struct = op.getarg(0)
struct_id = deps.get_val(struct)
......@@ -895,30 +903,30 @@ class AssemblerMu():
field_idx = fielddescr.idx
struct_ty = struct.getref_base().get_ty(self.cpu).id
field_ty = fielddescr.val
assert isinstance(field_ty, MuIntType)
field_muty = field_ty.mutype(self)
# TODO: Do this in the setup bb?
# turn the ref into an iref
struct_iref = self.irblr.unique_gen_sym("@assemble_loop.consider_getfield_gc_i.struct_iref")
get_struct_iref = self.irblr.unique_gen_sym("@assemble_loop.consider_getfield_gc_i.get_struct_iref")
struct_iref = self.irblr.unique_gen_sym("@assemble_loop.impl_getfield_gc.struct_iref")
get_struct_iref = self.irblr.unique_gen_sym("@assemble_loop.impl_getfield_gc.get_struct_iref")
self.irblr.new_getiref(id=get_struct_iref, result_id=struct_iref, refty=struct_ty, opnd=struct_id)
ops.append(get_struct_iref)
field_iref = self.irblr.unique_gen_sym("@assemble_loop.consider_getfield_gc_i.field_iref")
get_field_iref = self.irblr.unique_gen_sym("@assemble_loop.consider_getfield_gc_i.get_field_iref")
field_iref = self.irblr.unique_gen_sym("@assemble_loop.impl_getfield_gc.field_iref")
get_field_iref = self.irblr.unique_gen_sym("@assemble_loop.impl_getfield_gc.get_field_iref")
self.irblr.new_getfieldiref(id=get_field_iref, result_id=field_iref, is_ptr=False, refty=struct_ty, index=field_idx, opnd=struct_iref)
ops.append(get_field_iref)
load_val = self.irblr.unique_gen_sym("@assemble_loop.consider_getfield_gc_i.get_val")
val = self.irblr.unique_gen_sym("@assemble_loop.consider_getfield_gc_i.val")
self.irblr.new_load(id=load_val, result_id=val, is_ptr=False, ord=MuMemOrd.NOT_ATOMIC, refty=self.MuInt(field_ty.BITS).id, loc=field_iref)
load_val = self.irblr.unique_gen_sym("@assemble_loop.impl_getfield_gc.get_val")
val = self.irblr.unique_gen_sym("@assemble_loop.impl_getfield_gc.val")
self.irblr.new_load(id=load_val, result_id=val, is_ptr=False, ord=MuMemOrd.NOT_ATOMIC, refty=field_muty.id, loc=field_iref)
ops.append(load_val)
return ops, val
def consider_getfield_gc_r(self, op, deps):
pass
consider_getfield_gc_i = impl_getfield_gc
consider_getfield_gc_r = impl_getfield_gc
def consider_same_as_i(self, op, deps):
arg = op.getarg(0)
......
......@@ -174,7 +174,8 @@ class RefHybridFactory(Factory): #
self._varty_factory = varty_factory
def from_handle(self, handle):
return RefHybridHandle(self._varty_factory, handle)
return RefHybridHandle(self._varty_factory(), handle)
class RefHybridHandle(Handle): #IrefHybridHandle()
def get_handle(self):
......@@ -189,7 +190,7 @@ class RefHybridHandle(Handle): #IrefHybridHandle()
val = self._ctx.get_iref(self._value)
val = self._ctx.get_var_part_iref(val)
val = self._ctx.shift_iref(val, Int64Handle(key).get_handle())
return self._var_factory.from_handle(Int64Factory(), self._ctx.load(MuMemOrd.NOT_ATOMIC, val))
return self._var_factory.from_handle(self._ctx.load(MuMemOrd.NOT_ATOMIC, val))
def __setitem__(self, key, value):
val = self._ctx.get_iref(self._value)
......@@ -247,6 +248,12 @@ class RefVoidHandle(Handle):
def get_handle(self):
return self._value.ref
def __eq__(self, other):
if isinstance(other, MuValue):
return AssemblerMu.current_assembler.ctx.ref_eq(self._value, other.ref)
else:
raise NotImplementedError
class FloatFactory(Factory):
def from_handle(self, handle):
......
......@@ -186,6 +186,11 @@ class MuCPU(AbstractCPU):
# TODO: shorten the value with something that isn't ctypes?
return ctypes.c_longlong(deadframe.jf_intframe[index].value()).value
def get_ref_value(self, deadframe, index):
val = deadframe.jf_refframe[index]
return val
# ____________________________________________________________
def set_int_value(self, newframe, value, index):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment