Reviewers: danno,
Message:
Fix for a MIPS-specific Array.push issue.
Description:
MIPS: Fix return-value from Array.push stub when pushing non-SMI value
Load and update the arrays length in v0 to make sure the length gets
returned correctly when leaving the function.
Add new testcase.
TEST=mjsunit/array-push-non-smi-value
BUG=130022
Please review this at https://codereview.chromium.org/23589002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/mips/stub-cache-mips.cc
A + test/mjsunit/array-push-non-smi-value.js
Index: src/mips/stub-cache-mips.cc
diff --git a/src/mips/stub-cache-mips.cc b/src/mips/stub-cache-mips.cc
index
b84aca74437b424c7b14d6342d391a0665cde8ec..5ebdde66d8a8dee0e42230620c78eb51bdf4d844
100644
--- a/src/mips/stub-cache-mips.cc
+++ b/src/mips/stub-cache-mips.cc
@@ -1803,25 +1803,25 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
&call_builtin,
DONT_DO_SMI_CHECK);
- // Get the array's length into r0 and calculate new length.
- __ lw(a0, FieldMemOperand(receiver, JSArray::kLengthOffset));
+ // Get the array's length into v0 and calculate new length.
+ __ lw(v0, FieldMemOperand(receiver, JSArray::kLengthOffset));
STATIC_ASSERT(kSmiTagSize == 1);
STATIC_ASSERT(kSmiTag == 0);
- __ Addu(a0, a0, Operand(Smi::FromInt(argc)));
+ __ Addu(v0, v0, Operand(Smi::FromInt(argc)));
// Get the elements' length.
__ lw(t0, FieldMemOperand(elements, FixedArray::kLengthOffset));
// Check if we could survive without allocation.
- __ Branch(&call_builtin, gt, a0, Operand(t0));
+ __ Branch(&call_builtin, gt, v0, Operand(t0));
__ lw(t0, MemOperand(sp, (argc - 1) * kPointerSize));
__ StoreNumberToDoubleElements(
- t0, a0, elements, a3, t1, a2, t5,
+ t0, v0, elements, a3, t1, a2, t5,
&call_builtin, argc * kDoubleSize);
// Save new length.
- __ sw(a0, FieldMemOperand(receiver, JSArray::kLengthOffset));
+ __ sw(v0, FieldMemOperand(receiver, JSArray::kLengthOffset));
// Check for a smi.
__ DropAndRet(argc + 1);
Index: test/mjsunit/array-push-non-smi-value.js
diff --git a/test/mjsunit/compare-nil.js
b/test/mjsunit/array-push-non-smi-value.js
similarity index 91%
copy from test/mjsunit/compare-nil.js
copy to test/mjsunit/array-push-non-smi-value.js
index
0895a31fb80cbe697b678eaa1005926d7d65829f..4fe6e859d4612c02f5c6885dcf8d42cdb06670c9
100644
--- a/test/mjsunit/compare-nil.js
+++ b/test/mjsunit/array-push-non-smi-value.js
@@ -27,10 +27,11 @@
// Flags: --allow-natives-syntax
-function test(v) {
- return (v == null);
-}
-assertFalse(test(true));
-assertFalse(test(true));
-assertTrue(test(null));
-assertTrue(test(null));
+// Check pushes of non-SMI values.
+(function() {
+ var a = [];
+
+ %OptimizeFunctionOnNextCall(a.push);
+
+ assertEquals(1, a.push(0x40000000));
+})();
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.