Fix stack tweaking in array allocation
When Array(0) or new Array(0) is handled by the generated code it is handled by the same code as Array() and new Array(). For this to work the stack is tweaked to remove the argument of value 0. However the argc was still passed as 1 if a call to the runtime system was made. When the stack is tweaked argc is also changed to 0. BUG=634 TEST=test/mjsunittest/mjsunit/regress/regress-634.js Review URL: http://codereview.chromium.org/668155 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4038 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
b83ca84d8f
commit
df4471c8f3
@ -937,13 +937,18 @@ static void ArrayNativeCode(MacroAssembler* masm,
|
|||||||
__ test(ecx, Operand(ecx));
|
__ test(ecx, Operand(ecx));
|
||||||
__ j(not_zero, ¬_empty_array);
|
__ j(not_zero, ¬_empty_array);
|
||||||
|
|
||||||
// Case above assumes there is only a single slot to drop in
|
// The single argument passed is zero, so we jump to the code above used to
|
||||||
// ret, but we have two.
|
// handle the case of no arguments passed. To adapt the stack for that we move
|
||||||
for (int i = push_count; i >= 0; i--) {
|
// the return address and the pushed constructor (if pushed) one stack slot up
|
||||||
|
// thereby removing the passed argument. Argc is also on the stack - at the
|
||||||
|
// bottom - and it needs to be changed from 1 to 0 to have the call into the
|
||||||
|
// runtime system work in case a GC is required.
|
||||||
|
for (int i = push_count; i > 0; i--) {
|
||||||
__ mov(eax, Operand(esp, i * kPointerSize));
|
__ mov(eax, Operand(esp, i * kPointerSize));
|
||||||
__ mov(Operand(esp, (i + 1) * kPointerSize), eax);
|
__ mov(Operand(esp, (i + 1) * kPointerSize), eax);
|
||||||
}
|
}
|
||||||
__ add(Operand(esp), Immediate(kPointerSize));
|
__ add(Operand(esp), Immediate(2 * kPointerSize)); // Drop two stack slots.
|
||||||
|
__ push(Immediate(0)); // Treat this as a call with argc of zero.
|
||||||
__ jmp(&empty_array);
|
__ jmp(&empty_array);
|
||||||
|
|
||||||
__ bind(¬_empty_array);
|
__ bind(¬_empty_array);
|
||||||
|
@ -5742,6 +5742,7 @@ static Object* Runtime_DebugPrint(Arguments args) {
|
|||||||
}
|
}
|
||||||
args[0]->Print();
|
args[0]->Print();
|
||||||
if (args[0]->IsHeapObject()) {
|
if (args[0]->IsHeapObject()) {
|
||||||
|
PrintF("\n");
|
||||||
HeapObject::cast(args[0])->map()->Print();
|
HeapObject::cast(args[0])->map()->Print();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
32
test/mjsunit/regress/regress-634.js
Normal file
32
test/mjsunit/regress/regress-634.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright 2010 the V8 project authors. All rights reserved.
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following
|
||||||
|
// disclaimer in the documentation and/or other materials provided
|
||||||
|
// with the distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived
|
||||||
|
// from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
for (var i = 0; i < 1000000; i++) {
|
||||||
|
a = new Array(0);
|
||||||
|
assertEquals(0, a.length);
|
||||||
|
assertEquals(0, a.length);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user