Fix Runtime_ArrayConcat to handle FAST_DOUBLE_ELEMENTS

TEST=mjsunit/elements-kind.js; stanford-crypto-sha256-iterative in debug mode

Review URL: http://codereview.chromium.org/8334028

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9880 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 29445458
...@@ -9694,6 +9694,7 @@ static uint32_t EstimateElementCount(Handle<JSArray> array) { ...@@ -9694,6 +9694,7 @@ static uint32_t EstimateElementCount(Handle<JSArray> array) {
uint32_t length = static_cast<uint32_t>(array->length()->Number()); uint32_t length = static_cast<uint32_t>(array->length()->Number());
int element_count = 0; int element_count = 0;
switch (array->GetElementsKind()) { switch (array->GetElementsKind()) {
case FAST_SMI_ONLY_ELEMENTS:
case FAST_ELEMENTS: { case FAST_ELEMENTS: {
// Fast elements can't have lengths that are not representable by // Fast elements can't have lengths that are not representable by
// a 32-bit signed integer. // a 32-bit signed integer.
...@@ -9705,6 +9706,10 @@ static uint32_t EstimateElementCount(Handle<JSArray> array) { ...@@ -9705,6 +9706,10 @@ static uint32_t EstimateElementCount(Handle<JSArray> array) {
} }
break; break;
} }
case FAST_DOUBLE_ELEMENTS:
// TODO(1810): Decide if it's worthwhile to implement this.
UNREACHABLE();
break;
case DICTIONARY_ELEMENTS: { case DICTIONARY_ELEMENTS: {
Handle<NumberDictionary> dictionary( Handle<NumberDictionary> dictionary(
NumberDictionary::cast(array->elements())); NumberDictionary::cast(array->elements()));
...@@ -9717,7 +9722,16 @@ static uint32_t EstimateElementCount(Handle<JSArray> array) { ...@@ -9717,7 +9722,16 @@ static uint32_t EstimateElementCount(Handle<JSArray> array) {
} }
break; break;
} }
default: case NON_STRICT_ARGUMENTS_ELEMENTS:
case EXTERNAL_BYTE_ELEMENTS:
case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
case EXTERNAL_SHORT_ELEMENTS:
case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
case EXTERNAL_INT_ELEMENTS:
case EXTERNAL_UNSIGNED_INT_ELEMENTS:
case EXTERNAL_FLOAT_ELEMENTS:
case EXTERNAL_DOUBLE_ELEMENTS:
case EXTERNAL_PIXEL_ELEMENTS:
// External arrays are always dense. // External arrays are always dense.
return length; return length;
} }
...@@ -9795,6 +9809,11 @@ static void CollectElementIndices(Handle<JSObject> object, ...@@ -9795,6 +9809,11 @@ static void CollectElementIndices(Handle<JSObject> object,
} }
break; break;
} }
case FAST_DOUBLE_ELEMENTS: {
// TODO(1810): Decide if it's worthwhile to implement this.
UNREACHABLE();
break;
}
case DICTIONARY_ELEMENTS: { case DICTIONARY_ELEMENTS: {
Handle<NumberDictionary> dict(NumberDictionary::cast(object->elements())); Handle<NumberDictionary> dict(NumberDictionary::cast(object->elements()));
uint32_t capacity = dict->Capacity(); uint32_t capacity = dict->Capacity();
...@@ -9925,6 +9944,11 @@ static bool IterateElements(Isolate* isolate, ...@@ -9925,6 +9944,11 @@ static bool IterateElements(Isolate* isolate,
} }
break; break;
} }
case FAST_DOUBLE_ELEMENTS: {
// TODO(1810): Decide if it's worthwhile to implement this.
UNREACHABLE();
break;
}
case DICTIONARY_ELEMENTS: { case DICTIONARY_ELEMENTS: {
Handle<NumberDictionary> dict(receiver->element_dictionary()); Handle<NumberDictionary> dict(receiver->element_dictionary());
List<uint32_t> indices(dict->Capacity() / 2); List<uint32_t> indices(dict->Capacity() / 2);
...@@ -10035,6 +10059,13 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayConcat) { ...@@ -10035,6 +10059,13 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayConcat) {
uint32_t element_estimate; uint32_t element_estimate;
if (obj->IsJSArray()) { if (obj->IsJSArray()) {
Handle<JSArray> array(Handle<JSArray>::cast(obj)); Handle<JSArray> array(Handle<JSArray>::cast(obj));
// TODO(1810): Find out if it's worthwhile to properly support
// arbitrary ElementsKinds. For now, pessimistically transition to
// FAST_ELEMENTS.
if (array->HasFastDoubleElements()) {
array = Handle<JSArray>::cast(
TransitionElementsKind(array, FAST_ELEMENTS));
}
length_estimate = length_estimate =
static_cast<uint32_t>(array->length()->Number()); static_cast<uint32_t>(array->length()->Number());
element_estimate = element_estimate =
......
...@@ -305,5 +305,17 @@ if (support_smi_only_arrays) { ...@@ -305,5 +305,17 @@ if (support_smi_only_arrays) {
assertTrue(%HaveSameMap(e, f)); assertTrue(%HaveSameMap(e, f));
} }
// Test if Array.concat() works correctly with DOUBLE elements.
if (support_smi_only_arrays) {
var a = [1, 2];
assertKind(elements_kind.fast_smi_only, a);
var b = [4.5, 5.5];
assertKind(elements_kind.fast_double, b);
var c = a.concat(b);
assertEquals([1, 2, 4.5, 5.5], c);
// TODO(1810): Change implementation so that we get DOUBLE elements here?
assertKind(elements_kind.fast, c);
}
// Throw away type information in the ICs for next stress run. // Throw away type information in the ICs for next stress run.
gc(); gc();
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