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

Unified Diff: runtime/vm/intrinsifier_x64.cc

Issue 11032011: Intrinsify Float32Array_setIndexed on IA32 and X64 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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
« runtime/vm/intrinsifier_ia32.cc ('K') | « 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 03f42778c6f31dcfece67b6cb2d4df65dfc949b0..489882720fac2a314453255843012133221ea65f 100644
--- a/runtime/vm/intrinsifier_x64.cc
+++ b/runtime/vm/intrinsifier_x64.cc
@@ -432,6 +432,20 @@ void TestByteArrayIndex(Assembler* assembler, Label* fall_through) {
}
+// Operates in the same manner as TestByteArrayIndex.
+// This should be used only for setIndexed intrinsics.
+static void TestByteArraySetIndex(Assembler* assembler, Label* fall_through) {
+ __ movq(RAX, Address(RSP, + 3 * kWordSize)); // Array.
+ __ movq(RBX, Address(RSP, + 2 * kWordSize)); // Index.
srdjan 2012/10/01 22:59:40 You cannot use RBX if there is a slow path. This i
+ __ testq(RBX, Immediate(kSmiTagMask));
+ __ j(NOT_ZERO, fall_through, Assembler::kNearJump); // Non-smi index.
+ // Range check.
+ __ cmpq(RBX, FieldAddress(RAX, 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);
@@ -517,6 +531,7 @@ bool Intrinsifier::Uint32Array_getIndexed(Assembler* assembler) {
return false;
}
+
bool Intrinsifier::Float32Array_getIndexed(Assembler* assembler) {
Label fall_through;
TestByteArrayIndex(assembler, &fall_through);
@@ -544,8 +559,29 @@ bool Intrinsifier::Float32Array_getIndexed(Assembler* assembler) {
return false;
}
+
bool Intrinsifier::Float32Array_setIndexed(Assembler* assembler) {
- return false;
+ Label fall_through;
+ TestByteArraySetIndex(assembler, &fall_through);
+ // After TestByteArraySetIndex:
+ // * RAX has the base address of the byte array.
+ // * RBX has the index into the array.
+ // RBX contains the SMI index which is shifted by 1.
+ // This shift means we only multiply the index by 2 not 4 (sizeof float).
+ __ movq(RDX, Address(RSP, + 1 * kWordSize)); // Value.
+ // If RDX is not an instance of double, jump to fall through.
+ __ CompareClassId(RDX, kDoubleCid);
+ __ j(NOT_EQUAL, &fall_through);
+ // Load double value into XMM7.
+ __ movsd(XMM7, FieldAddress(RDX, Double::value_offset()));
+ // Convert from double precision float to single precision float.
+ __ cvtsd2ss(XMM7, XMM7);
+ // Store into array.
+ __ movss(FieldAddress(RAX, RBX, TIMES_2, Float32Array::data_offset()), XMM7);
+ // End fast path.
+ __ ret();
+ __ Bind(&fall_through);
+ return false;
}
« runtime/vm/intrinsifier_ia32.cc ('K') | « runtime/vm/intrinsifier_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698