Index: runtime/vm/intrinsifier_ia32.cc |
diff --git a/runtime/vm/intrinsifier_ia32.cc b/runtime/vm/intrinsifier_ia32.cc |
index 7760a931109937c73def80400eaa0f8edcb0bac1..834cf5f02b2cc32ab35487e77794b72da76574ae 100644 |
--- a/runtime/vm/intrinsifier_ia32.cc |
+++ b/runtime/vm/intrinsifier_ia32.cc |
@@ -564,11 +564,55 @@ bool Intrinsifier::Uint16Array_getIndexed(Assembler* assembler) { |
bool Intrinsifier::Int32Array_getIndexed(Assembler* assembler) { |
+ Label fall_through; |
+ TestByteArrayIndex(assembler, &fall_through); |
+ // After TestByteArrayIndex: |
+ // * EAX has the base address of the byte array. |
+ // * EBX has the index into the array. |
+ // EBX contains the SMI index which is shifted left by 1. |
+ // This shift means we only multiply the index by 2 not 4 (sizeof Int32). |
+ __ movl(EAX, FieldAddress(EAX, |
+ EBX, |
+ TIMES_2, |
+ Int32Array::data_offset())); |
+ // Verify that the signed value in EAX can fit inside a Smi. |
+ __ cmpl(EAX, Immediate(0xC0000000)); |
+ __ j(NEGATIVE, &fall_through, Assembler::kNearJump); // Won't fit Smi. |
+ __ SmiTag(EAX); |
+ __ ret(); |
+ __ Bind(&fall_through); |
return false; |
} |
bool Intrinsifier::Uint32Array_getIndexed(Assembler* assembler) { |
+ Label fall_through; |
+ TestByteArrayIndex(assembler, &fall_through); |
+ // After TestByteArrayIndex: |
+ // * EAX has the base address of the byte array. |
+ // * EBX has the index into the array. |
+ // EBX contains the SMI index which is shifted left by 1. |
+ // This shift means we only multiply the index by 2 not 4 (sizeof Uint32). |
+ __ movl(EAX, FieldAddress(EAX, |
+ EBX, |
+ TIMES_2, |
+ Uint32Array::data_offset())); |
+ // Verify that the unsigned value in EAX can be stored in a Smi. |
+ __ testl(EAX, Immediate(0xC0000000)); |
+ __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Won't fit Smi. |
+ __ SmiTag(EAX); |
+ __ ret(); |
+ __ Bind(&fall_through); |
+ return false; |
+} |
+ |
+ |
+bool Intrinsifier::Int64Array_getIndexed(Assembler* assembler) { |
+ return false; |
+} |
+ |
+ |
+bool Intrinsifier::Uint64Array_getIndexed(Assembler* assembler) { |
return false; |
} |