Skip to content

Commit 1acc829

Browse files
committed
Relax the temporary same-instance copying limitation
1 parent a0c6dac commit 1acc829

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

design/mvp/canonical-abi/definitions.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ def read(self, inst, dst_buffer, on_copy, on_copy_done):
851851
self.set_pending(inst, dst_buffer, on_copy, on_copy_done)
852852
else:
853853
assert(self.t == dst_buffer.t == self.pending_buffer.t)
854-
trap_if(inst is self.pending_inst and self.t is not None) # temporary
854+
trap_if(inst is self.pending_inst and self.t and not is_number_type(self.t)) # temporary
855855
if self.pending_buffer.remain() > 0:
856856
if dst_buffer.remain() > 0:
857857
n = min(dst_buffer.remain(), self.pending_buffer.remain())
@@ -869,7 +869,7 @@ def write(self, inst, src_buffer, on_copy, on_copy_done):
869869
self.set_pending(inst, src_buffer, on_copy, on_copy_done)
870870
else:
871871
assert(self.t == src_buffer.t == self.pending_buffer.t)
872-
trap_if(inst is self.pending_inst and self.t is not None) # temporary
872+
trap_if(inst is self.pending_inst and self.t and not is_number_type(self.t)) # temporary
873873
if self.pending_buffer.remain() > 0:
874874
if src_buffer.remain() > 0:
875875
n = min(src_buffer.remain(), self.pending_buffer.remain())
@@ -882,6 +882,11 @@ def write(self, inst, src_buffer, on_copy, on_copy_done):
882882
self.reset_and_notify_pending(CopyResult.COMPLETED)
883883
self.set_pending(inst, src_buffer, on_copy, on_copy_done)
884884

885+
def is_number_type(t):
886+
return isinstance(t, U8Type | U16Type | U32Type | U64Type |
887+
S8Type | S16Type | S32Type | S64Type |
888+
F32Type | F64Type)
889+
885890
class CopyState(Enum):
886891
IDLE = 1
887892
SYNC_COPYING = 2
@@ -983,7 +988,7 @@ def read(self, inst, dst_buffer, on_copy_done):
983988
if not self.pending_buffer:
984989
self.set_pending(inst, dst_buffer, on_copy_done)
985990
else:
986-
trap_if(inst is self.pending_inst and self.t is not None) # temporary
991+
trap_if(inst is self.pending_inst and self.t and not is_number_type(self.t)) # temporary
987992
dst_buffer.write(self.pending_buffer.read(1))
988993
self.reset_and_notify_pending(CopyResult.COMPLETED)
989994
on_copy_done(CopyResult.COMPLETED)
@@ -995,7 +1000,7 @@ def write(self, inst, src_buffer, on_copy_done):
9951000
elif not self.pending_buffer:
9961001
self.set_pending(inst, src_buffer, on_copy_done)
9971002
else:
998-
trap_if(inst is self.pending_inst and self.t is not None) # temporary
1003+
trap_if(inst is self.pending_inst and self.t and not is_number_type(self.t)) # temporary
9991004
self.pending_buffer.write(src_buffer.read(1))
10001005
self.reset_and_notify_pending(CopyResult.COMPLETED)
10011006
on_copy_done(CopyResult.COMPLETED)

0 commit comments

Comments
 (0)