Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(501)

Unified Diff: runtime/vm/intrinsifier_x64.cc

Issue 11415116: Port intrisification of setIndexed on Uint8 and Int8 arrays from ia32 to x64. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/intrinsifier_ia32.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intrinsifier_x64.cc
diff --git a/runtime/vm/intrinsifier_x64.cc b/runtime/vm/intrinsifier_x64.cc
index e5dd2b404a8b3a05d09cea8633227cf100ecabae..8d52b6a3febfcfbe351f6eb48f4a54adf2ff80df 100644
--- a/runtime/vm/intrinsifier_x64.cc
+++ b/runtime/vm/intrinsifier_x64.cc
@@ -471,6 +471,26 @@ 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);
+ __ movq(RDI, Address(RSP, + 1 * kWordSize)); // Value.
+ __ testq(RDI, Immediate(kSmiTagMask));
+ __ j(NOT_ZERO, &fall_through, Assembler::kNearJump);
+ __ SmiUntag(RDI);
+ // Check that the value is a byte. Add 128 to the value to bring it into
+ // the range 0..FF.
+ __ addq(RDI, Immediate(128));
+ __ cmpq(RDI, Immediate(0xFF));
+ __ j(ABOVE, &fall_through, Assembler::kNearJump);
+ // Undo addition.
+ __ subq(RDI, Immediate(128));
+ __ movb(FieldAddress(RAX, R12, TIMES_1, Uint8Array::data_offset()), RDI);
+ __ ret();
__ Bind(&fall_through);
return false;
}
@@ -478,6 +498,22 @@ 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);
+ __ movq(RDI, Address(RSP, + 1 * kWordSize)); // Value.
+ __ testq(RDI, Immediate(kSmiTagMask));
+ __ j(NOT_ZERO, &fall_through, Assembler::kNearJump);
+ __ SmiUntag(RDI);
+ // Check that value is a byte.
+ __ cmpq(RDI, Immediate(0xFF));
+ __ j(ABOVE, &fall_through, Assembler::kNearJump);
+ __ movb(FieldAddress(RAX, R12, TIMES_1, Uint8Array::data_offset()), RDI);
+ __ ret();
__ Bind(&fall_through);
return false;
}
« no previous file with comments | « runtime/vm/intrinsifier_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698