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

Unified Diff: runtime/vm/intrinsifier_ia32.cc

Issue 11074016: Intrinsify writing to Uint8 and Int8 arrays on IA32. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Comments, fixed signed check, and tests. Created 8 years, 2 months 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
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);

Powered by Google App Engine
This is Rietveld 408576698