Chromium Code Reviews| Index: runtime/vm/intrinsifier_ia32.cc |
| diff --git a/runtime/vm/intrinsifier_ia32.cc b/runtime/vm/intrinsifier_ia32.cc |
| index 6f4eb81fbeb7ea4e50b764c8deb6a839529bc9fa..4b72367d0677b49469294bfff5a9869e3ab05c81 100644 |
| --- a/runtime/vm/intrinsifier_ia32.cc |
| +++ b/runtime/vm/intrinsifier_ia32.cc |
| @@ -520,6 +520,38 @@ bool Intrinsifier::Int8Array_getIndexed(Assembler* assembler) { |
| } |
| +bool Intrinsifier::Int8Array_setIndexed(Assembler* assembler) { |
| + Label fall_through; |
| + // Verify that the array index is valid. |
| + TestByteArraySetIndex(assembler, &fall_through); |
| + // After TestByteArraySetIndex: |
| + // * EAX has the base address of the byte array. |
| + // * EBX has the index into the array. |
| + // EBX contains the SMI index which is shifted by 1. |
| + __ SmiUntag(EBX); |
| + // Move EBX into EDI. |
| + __ movl(EDI, EBX); |
| + // Load the value into EBX. |
| + __ movl(EBX, Address(ESP, + 1 * kWordSize)); // Value. |
| + // If EBX is not an Smi, jump to fall through. |
| + __ testl(EBX, Immediate(kSmiTagMask)); |
| + __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); |
| + __ SmiUntag(EBX); |
| + // Add 128 to EBX to bring it into 0..FF. |
| + __ addl(EBX, Immediate(128)); |
|
cshapiro
2012/10/12 23:05:21
It would be great if we could put these magic numb
|
| + __ cmpl(EBX, Immediate(0xFF)); |
| + // If EBX is too large an Int8, jump to fall through. |
| + __ j(ABOVE, &fall_through, Assembler::kNearJump); |
| + // Remove addition. |
| + __ subl(EBX, Immediate(128)); |
| + // Store BL into array EAX[EDI] = BL. |
| + __ movb(FieldAddress(EAX, EDI, TIMES_1, Int8Array::data_offset()), BL); |
| + __ ret(); |
| + __ Bind(&fall_through); |
| + return false; |
| +} |
| + |
| + |
| bool Intrinsifier::Uint8Array_getIndexed(Assembler* assembler) { |
| Label fall_through; |
| TestByteArrayIndex(assembler, &fall_through); |
| @@ -535,6 +567,34 @@ bool Intrinsifier::Uint8Array_getIndexed(Assembler* assembler) { |
| } |
| +bool Intrinsifier::Uint8Array_setIndexed(Assembler* assembler) { |
| + Label fall_through; |
| + // Verify that the array index is valid. |
| + TestByteArraySetIndex(assembler, &fall_through); |
| + // After TestByteArraySetIndex: |
| + // * EAX has the base address of the byte array. |
| + // * EBX has the index into the array. |
| + // EBX contains the SMI index which is shifted by 1. |
| + __ SmiUntag(EBX); |
| + // Move EBX into EDI. |
| + __ movl(EDI, EBX); |
| + // Load the value into EBX. |
| + __ movl(EBX, Address(ESP, + 1 * kWordSize)); // Value. |
| + // If EBX is not an Smi, jump to fall through. |
| + __ testl(EBX, Immediate(kSmiTagMask)); |
| + __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); |
| + __ SmiUntag(EBX); |
| + // If EBX is too large an Uint8, jump to fall through. |
| + __ cmpl(EBX, Immediate(0xFF)); |
| + __ j(ABOVE, &fall_through, Assembler::kNearJump); |
| + // Store BL into array EAX[EDI] = BL. |
| + __ movb(FieldAddress(EAX, EDI, TIMES_1, Uint8Array::data_offset()), BL); |
| + __ ret(); |
| + __ Bind(&fall_through); |
| + return false; |
| +} |
| + |
| + |
| bool Intrinsifier::Int16Array_getIndexed(Assembler* assembler) { |
| Label fall_through; |
| TestByteArrayIndex(assembler, &fall_through); |