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

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: 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 | « no previous file | 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..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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698