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

Unified Diff: runtime/vm/intrinsifier_ia32.cc

Issue 10546035: Intrinsify some ByteArray methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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 3f4ba6bca92d0dbf4c5b0e5600fcb5edddfeab92..d8d9e7a0dfcf6a321cdaa159189f9f5283cebe96 100644
--- a/runtime/vm/intrinsifier_ia32.cc
+++ b/runtime/vm/intrinsifier_ia32.cc
@@ -417,6 +417,101 @@ bool Intrinsifier::GrowableArray_setData(Assembler* assembler) {
}
+// Gets the length of a ByteArray.
+bool Intrinsifier::ByteArrayBase_getLength(Assembler* assembler) {
+ __ movl(EAX, Address(ESP, + 1 * kWordSize));
+ __ movl(EAX, FieldAddress(EAX, ByteArray::length_offset()));
+ __ ret();
+ return true;
+}
+
+
+// Assumes the first argument is a byte array, tests if the second
+// argument is a smi, tests if the smi is within bounds of the array
+// length, and jumps to label fall_through if any test fails. Leaves
+// the second argument in EBX.
+static void TestByteArrayIndex(Assembler* assembler, Label* fall_through) {
+ __ movl(EAX, Address(ESP, + 1 * kWordSize)); // Array.
+ __ movl(EBX, Address(ESP, + 2 * kWordSize)); // Index.
+ __ testl(EBX, Immediate(kSmiTagMask));
+ __ j(NOT_ZERO, fall_through, Assembler::kNearJump); // Non-smi index.
+ // Range check.
+ __ cmpl(EBX, FieldAddress(EAX, ByteArray::length_offset()));
+ // Runtime throws exception.
+ __ j(ABOVE_EQUAL, fall_through, Assembler::kNearJump);
+}
+
+
+bool Intrinsifier::Int8Array_getIndexed(Assembler* assembler) {
+ Label fall_through;
+ TestByteArrayIndex(assembler, &fall_through);
+ __ SmiUntag(EBX);
+ __ movsxb(EAX, FieldAddress(EAX,
+ EBX,
+ TIMES_1,
+ Int8Array::data_offset()));
+ __ SmiTag(EAX);
+ __ ret();
+ __ Bind(&fall_through);
+ return false;
+}
+
+
+bool Intrinsifier::Uint8Array_getIndexed(Assembler* assembler) {
+ Label fall_through;
+ TestByteArrayIndex(assembler, &fall_through);
+ __ SmiUntag(EBX);
+ __ movzxb(EAX, FieldAddress(EAX,
+ EBX,
+ TIMES_1,
+ Uint8Array::data_offset()));
+ __ SmiTag(EAX);
+ __ ret();
+ __ Bind(&fall_through);
+ return false;
+}
+
+
+bool Intrinsifier::Int16Array_getIndexed(Assembler* assembler) {
+ Label fall_through;
+ TestByteArrayIndex(assembler, &fall_through);
+ __ SmiUntag(EBX);
srdjan 2012/06/06 23:30:00 You could skip untagging EBX and use TIMES_1.
cshapiro 2012/06/06 23:43:07 Thanks! Done.
+ __ movsxw(EAX, FieldAddress(EAX,
+ EBX,
+ TIMES_2,
+ Int16Array::data_offset()));
+ __ SmiTag(EAX);
+ __ ret();
+ __ Bind(&fall_through);
+ return false;
+}
+
+
+bool Intrinsifier::Uint16Array_getIndexed(Assembler* assembler) {
+ Label fall_through;
+ TestByteArrayIndex(assembler, &fall_through);
+ __ SmiUntag(EBX);
srdjan 2012/06/06 23:30:00 ditto
cshapiro 2012/06/06 23:43:07 Done.
+ __ movzxw(EAX, FieldAddress(EAX,
+ EBX,
+ TIMES_2,
+ Uint16Array::data_offset()));
+ __ SmiTag(EAX);
+ __ ret();
+ __ Bind(&fall_through);
+ return false;
+}
+
+
+bool Intrinsifier::Int32Array_getIndexed(Assembler* assembler) {
+ return false;
+}
+
+
+bool Intrinsifier::Uint32Array_getIndexed(Assembler* assembler) {
+ return false;
+}
+
+
// Tests if two top most arguments are smis, jumps to label not_smi if not.
// Topmost argument is in EAX.
static void TestBothArgumentsSmis(Assembler* assembler, Label* not_smi) {

Powered by Google App Engine
This is Rietveld 408576698