1.1 --- a/jitcraft/Interpreter.cpp Sun Jul 01 11:25:36 2012 -0700
1.2 +++ b/jitcraft/Interpreter.cpp Sun Jul 01 14:52:57 2012 -0700
1.3 @@ -102,6 +102,20 @@
1.4 return array;
1.5 }
1.6
1.7 +static bool
1.8 +CopyArray(Zone *zone, Array *source, Array *dest)
1.9 +{
1.10 + assert(source->type()->levels() == 1);
1.11 + assert(dest->type()->levels() == 1);
1.12 + assert(source->type()->contained()->primitive() ==
1.13 + dest->type()->contained()->primitive());
1.14 + assert(source->nelements() >= dest->nelements());
1.15 + assert(dest->elementSize() == source->elementSize());
1.16 +
1.17 + memcpy(source->vec(), dest->vec(), dest->nelements() * dest->elementSize());
1.18 + return true;
1.19 +}
1.20 +
1.21 bool
1.22 jc::Interpret(Frame *frame, LocalSlot *result)
1.23 {
1.24 @@ -400,6 +414,15 @@
1.25 break;
1.26 }
1.27
1.28 +case OP_GETARRAY_C:
1.29 +{
1.30 + Array *array = top.sp[-2].array;
1.31 + int index = top.sp[-1].i32;
1.32 + top.sp[-2].i32 = array->readChar(index);
1.33 + top.sp--;
1.34 + break;
1.35 +}
1.36 +
1.37 case OP_SETARRAY_I:
1.38 {
1.39 Array *array = top.sp[-3].array;
1.40 @@ -420,6 +443,16 @@
1.41 break;
1.42 }
1.43
1.44 +case OP_SETARRAY_C:
1.45 +{
1.46 + Array *array = top.sp[-3].array;
1.47 + int index = top.sp[-2].i32;
1.48 + array->writeChar(index, top.sp[-1].i32);
1.49 + top.sp[-3] = top.sp[-1];
1.50 + top.sp -= 2;
1.51 + break;
1.52 +}
1.53 +
1.54 case OP_GETARRAY_O:
1.55 {
1.56 Array *array = top.sp[-2].array;
1.57 @@ -534,6 +567,25 @@
1.58 break;
1.59 }
1.60
1.61 +case OP_OBJECT:
1.62 +{
1.63 + top.sp->obj = frame->code()->object(READ_UINT32(top.pc));
1.64 + top.sp++;
1.65 + break;
1.66 +}
1.67 +
1.68 +case OP_ARRAYCOPY:
1.69 +{
1.70 + // Note for this assignment opcode, we return the left-hand side, not the
1.71 + // right, since in this case the result of the expression could be different.
1.72 + if (!CopyArray(ZONE(), top.sp[-2].array, top.sp[-1].array)) {
1.73 + assert(false);
1.74 + return false;
1.75 + }
1.76 + top.sp--;
1.77 + break;
1.78 +}
1.79 +
1.80 default:
1.81 assert(false);
1.82 return false;