Commit 71cd77e2 authored by danno@chromium.org's avatar danno@chromium.org

Fix crashing bugs in store-and-grow IC for double values.

R=jkummerow@chromium.org
BUG=chromium:113924
TEST=test/mjsunit/regress/regress-113924.js

Review URL: https://chromiumcodereview.appspot.com/9365055

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10706 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 579ca743
...@@ -3905,6 +3905,7 @@ void KeyedStoreStubCompiler::GenerateStoreFastDoubleElement( ...@@ -3905,6 +3905,7 @@ void KeyedStoreStubCompiler::GenerateStoreFastDoubleElement(
} else { } else {
// Check that the key is within bounds. // Check that the key is within bounds.
__ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset)); // smis. __ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset)); // smis.
__ j(above_equal, &miss_force_generic);
} }
__ bind(&finish_store); __ bind(&finish_store);
...@@ -3970,6 +3971,7 @@ void KeyedStoreStubCompiler::GenerateStoreFastDoubleElement( ...@@ -3970,6 +3971,7 @@ void KeyedStoreStubCompiler::GenerateStoreFastDoubleElement(
// Increment the length of the array. // Increment the length of the array.
__ add(FieldOperand(edx, JSArray::kLengthOffset), __ add(FieldOperand(edx, JSArray::kLengthOffset),
Immediate(Smi::FromInt(1))); Immediate(Smi::FromInt(1)));
__ mov(edi, FieldOperand(edx, JSObject::kElementsOffset));
__ jmp(&finish_store); __ jmp(&finish_store);
__ bind(&check_capacity); __ bind(&check_capacity);
......
...@@ -8680,23 +8680,25 @@ MaybeObject* JSObject::SetFastDoubleElementsCapacityAndLength( ...@@ -8680,23 +8680,25 @@ MaybeObject* JSObject::SetFastDoubleElementsCapacityAndLength(
FixedArrayBase* old_elements = elements(); FixedArrayBase* old_elements = elements();
ElementsKind elements_kind(GetElementsKind()); ElementsKind elements_kind(GetElementsKind());
AssertNoAllocation no_gc; AssertNoAllocation no_gc;
switch (elements_kind) { if (old_elements->length() != 0) {
case FAST_SMI_ONLY_ELEMENTS: switch (elements_kind) {
case FAST_ELEMENTS: { case FAST_SMI_ONLY_ELEMENTS:
elems->Initialize(FixedArray::cast(old_elements)); case FAST_ELEMENTS: {
break; elems->Initialize(FixedArray::cast(old_elements));
} break;
case FAST_DOUBLE_ELEMENTS: { }
elems->Initialize(FixedDoubleArray::cast(old_elements)); case FAST_DOUBLE_ELEMENTS: {
break; elems->Initialize(FixedDoubleArray::cast(old_elements));
} break;
case DICTIONARY_ELEMENTS: { }
elems->Initialize(SeededNumberDictionary::cast(old_elements)); case DICTIONARY_ELEMENTS: {
break; elems->Initialize(SeededNumberDictionary::cast(old_elements));
break;
}
default:
UNREACHABLE();
break;
} }
default:
UNREACHABLE();
break;
} }
if (FLAG_trace_elements_transitions) { if (FLAG_trace_elements_transitions) {
...@@ -9640,13 +9642,14 @@ MUST_USE_RESULT MaybeObject* JSObject::SetFastDoubleElement( ...@@ -9640,13 +9642,14 @@ MUST_USE_RESULT MaybeObject* JSObject::SetFastDoubleElement(
bool check_prototype) { bool check_prototype) {
ASSERT(HasFastDoubleElements()); ASSERT(HasFastDoubleElements());
FixedDoubleArray* elms = FixedDoubleArray::cast(elements()); FixedArrayBase* base_elms = FixedArrayBase::cast(elements());
uint32_t elms_length = static_cast<uint32_t>(elms->length()); uint32_t elms_length = static_cast<uint32_t>(base_elms->length());
// If storing to an element that isn't in the array, pass the store request // If storing to an element that isn't in the array, pass the store request
// up the prototype chain before storing in the receiver's elements. // up the prototype chain before storing in the receiver's elements.
if (check_prototype && if (check_prototype &&
(index >= elms_length || elms->is_the_hole(index))) { (index >= elms_length ||
FixedDoubleArray::cast(base_elms)->is_the_hole(index))) {
bool found; bool found;
MaybeObject* result = SetElementWithCallbackSetterInPrototypes(index, MaybeObject* result = SetElementWithCallbackSetterInPrototypes(index,
value, value,
...@@ -9681,6 +9684,7 @@ MUST_USE_RESULT MaybeObject* JSObject::SetFastDoubleElement( ...@@ -9681,6 +9684,7 @@ MUST_USE_RESULT MaybeObject* JSObject::SetFastDoubleElement(
// Check whether there is extra space in the fixed array. // Check whether there is extra space in the fixed array.
if (index < elms_length) { if (index < elms_length) {
FixedDoubleArray* elms = FixedDoubleArray::cast(elements());
elms->set(index, double_value); elms->set(index, double_value);
if (IsJSArray()) { if (IsJSArray()) {
// Update the length of the array if needed. // Update the length of the array if needed.
......
// Copyright 2012 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.
var count=12000;
while(count--) {
eval("var a = new Object(10); a[2] += 7;");
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment