Chromium Code Reviews| Index: runtime/vm/intrinsifier_x64.cc |
| diff --git a/runtime/vm/intrinsifier_x64.cc b/runtime/vm/intrinsifier_x64.cc |
| index e5dd2b404a8b3a05d09cea8633227cf100ecabae..b3722466b0c4e605f51b462d4de33520d6357d36 100644 |
| --- a/runtime/vm/intrinsifier_x64.cc |
| +++ b/runtime/vm/intrinsifier_x64.cc |
| @@ -471,6 +471,31 @@ 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: |
| + // * RAX has the base address of the byte array. |
| + // * R12 has the index into the array. |
| + // R12 contains the SMI index which is shifted by 1. |
| + __ SmiUntag(R12); |
| + // Move R12 into RDI. |
|
Florian Schneider
2012/11/22 14:35:53
This comment is not very useful. I suggest removin
|
| + __ movq(RDI, R12); |
| + // Load the value into R12. |
| + __ movq(R12, Address(RSP, + 1 * kWordSize)); // Value. |
|
Florian Schneider
2012/11/22 14:35:53
Maybe use a different register than R12 vor the va
|
| + // If R12 is not an Smi, jump to fall through. |
| + __ testq(R12, Immediate(kSmiTagMask)); |
| + __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); |
| + __ SmiUntag(R12); |
| + // Add 128 to R12 to bring it into the range 0..FF. |
| + __ addq(R12, Immediate(128)); |
| + // If R12 is too large for an Int8, jump to fall through. |
| + __ cmpq(R12, Immediate(0xFF)); |
| + __ j(ABOVE, &fall_through, Assembler::kNearJump); |
| + // Undo addition. |
| + __ subq(R12, Immediate(128)); |
| + // Store byte from RBX into array RAX[RDI]. |
| + __ movb(FieldAddress(RAX, RDI, TIMES_1, Uint8Array::data_offset()), R12); |
| + __ ret(); |
| __ Bind(&fall_through); |
| return false; |
| } |
| @@ -478,6 +503,27 @@ bool Intrinsifier::Int8Array_setIndexed(Assembler* assembler) { |
| bool Intrinsifier::Uint8Array_setIndexed(Assembler* assembler) { |
| Label fall_through; |
| + // Verify that the array index is valid. |
| + TestByteArraySetIndex(assembler, &fall_through); |
| + // After TestByteArraySetIndex: |
| + // * RAX has the base address of the byte array. |
| + // * R12 has the index into the array. |
| + // R12 contains the SMI index which is shifted by 1. |
| + __ SmiUntag(R12); |
| + // Move R12 into RDI. |
|
Florian Schneider
2012/11/22 14:35:53
Same comments as for Int8Array.
|
| + __ movq(RDI, R12); |
| + // Load the value into R12. |
| + __ movq(R12, Address(RSP, + 1 * kWordSize)); // Value. |
| + // If R12 is not an Smi, jump to fall through. |
| + __ testq(R12, Immediate(kSmiTagMask)); |
| + __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); |
| + __ SmiUntag(R12); |
| + // If R12 is too large for an Uint8, jump to fall through. |
| + __ cmpq(R12, Immediate(0xFF)); |
| + __ j(ABOVE, &fall_through, Assembler::kNearJump); |
| + // Store byte from RBX into array RAX[RDI]. |
| + __ movb(FieldAddress(RAX, RDI, TIMES_1, Uint8Array::data_offset()), R12); |
| + __ ret(); |
| __ Bind(&fall_through); |
| return false; |
| } |