Index: src/ia32/code-stubs-ia32.cc |
diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc |
index 006ee46ed428c5e2e66c2a4d16611f42c4619f81..fc6640cb761f52267ff6b813b4566d3112f53948 100644 |
--- a/src/ia32/code-stubs-ia32.cc |
+++ b/src/ia32/code-stubs-ia32.cc |
@@ -6507,6 +6507,54 @@ void ICCompareStub::GenerateMiss(MacroAssembler* masm) { |
} |
+// Loads a indexed element from a pixel array. |
+void GenerateFastPixelArrayLoad(MacroAssembler* masm, |
+ Register receiver, |
+ Register key, |
+ Register elements, |
+ Register untagged_key, |
+ Register result, |
+ Label* not_pixel_array, |
+ Label* key_not_smi, |
+ Label* out_of_range) { |
+ // Register use: |
+ // receiver - holds the receiver and is unchanged. |
+ // key - holds the key and is unchanged (must be a smi). |
+ // elements - is set to the the receiver's element if |
+ // the receiver doesn't have a pixel array or the |
+ // key is not a smi, otherwise it's the elements' |
+ // external pointer. |
+ // untagged_key - is set to the untagged key |
+ |
+ // Some callers already have verified that the key is a smi. key_not_smi is |
+ // set to NULL as a sentinel for that case. Otherwise, add an explicit check |
+ // to ensure the key is a smi must be added. |
+ if (key_not_smi != NULL) { |
+ __ JumpIfNotSmi(key, key_not_smi); |
+ } else { |
+ if (FLAG_debug_code) { |
+ __ AbortIfNotSmi(key); |
+ } |
+ } |
+ __ mov(untagged_key, key); |
+ __ SmiUntag(untagged_key); |
+ |
+ // Verify that the receiver has pixel array elements. |
+ __ mov(elements, FieldOperand(receiver, JSObject::kElementsOffset)); |
+ __ CheckMap(elements, Factory::pixel_array_map(), not_pixel_array, true); |
+ |
+ // Key must be in range. |
+ __ cmp(untagged_key, FieldOperand(elements, PixelArray::kLengthOffset)); |
+ __ j(above_equal, out_of_range); // unsigned check handles negative keys. |
+ |
+ // Perform the indexed load and tag the result as a smi. |
+ __ mov(elements, FieldOperand(elements, PixelArray::kExternalPointerOffset)); |
+ __ movzx_b(result, Operand(elements, untagged_key, times_1, 0)); |
+ __ SmiTag(result); |
+ __ ret(0); |
+} |
+ |
+ |
#undef __ |
} } // namespace v8::internal |