Remove unnecessary elements type check when allocating array in runtime.
BUG= TEST=--smi-only-arrays should be perf-neutral to allocating big arrays in a tight loop. Review URL: https://chromiumcodereview.appspot.com/9356002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10711 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
941d884af4
commit
b21ada9a98
@ -218,12 +218,13 @@ static MaybeObject* ArrayCodeGenericCommon(Arguments* args,
|
||||
if (obj->IsSmi()) {
|
||||
int len = Smi::cast(obj)->value();
|
||||
if (len >= 0 && len < JSObject::kInitialMaxFastElementArray) {
|
||||
Object* obj;
|
||||
Object* fixed_array;
|
||||
{ MaybeObject* maybe_obj = heap->AllocateFixedArrayWithHoles(len);
|
||||
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
||||
if (!maybe_obj->ToObject(&fixed_array)) return maybe_obj;
|
||||
}
|
||||
MaybeObject* maybe_obj = array->SetContent(FixedArray::cast(obj));
|
||||
if (maybe_obj->IsFailure()) return maybe_obj;
|
||||
// We do not use SetContent to skip the unnecessary elements type check.
|
||||
array->set_elements(FixedArray::cast(fixed_array));
|
||||
array->set_length(Smi::cast(obj));
|
||||
return array;
|
||||
}
|
||||
}
|
||||
|
@ -4361,10 +4361,10 @@ MaybeObject* Heap::AllocateJSArray(
|
||||
Context* global_context = isolate()->context()->global_context();
|
||||
JSFunction* array_function = global_context->array_function();
|
||||
Map* map = array_function->initial_map();
|
||||
if (elements_kind == FAST_ELEMENTS || !FLAG_smi_only_arrays) {
|
||||
map = Map::cast(global_context->object_js_array_map());
|
||||
} else if (elements_kind == FAST_DOUBLE_ELEMENTS) {
|
||||
if (elements_kind == FAST_DOUBLE_ELEMENTS) {
|
||||
map = Map::cast(global_context->double_js_array_map());
|
||||
} else if (elements_kind == FAST_ELEMENTS || !FLAG_smi_only_arrays) {
|
||||
map = Map::cast(global_context->object_js_array_map());
|
||||
} else {
|
||||
ASSERT(elements_kind == FAST_SMI_ONLY_ELEMENTS);
|
||||
ASSERT(map == global_context->smi_js_array_map());
|
||||
|
Loading…
Reference in New Issue
Block a user