Commit d49bb69a authored by bmeurer's avatar bmeurer Committed by Commit bot

[runtime] Make elements backing store for arguments non-holey.

Change sloppy and strict arguments objects to FAST_ELEMENTS for their
backing stores, which will allow us to optimize them easier. Also fixes
a bug in the elements accessors that was triggered by this change.

R=verwaest@chromium.org

Review URL: https://codereview.chromium.org/1433133003

Cr-Commit-Position: refs/heads/master@{#31942}
parent 2ebd5fc7
......@@ -1354,8 +1354,8 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
arguments_string, code);
function->shared()->set_instance_class_name(*arguments_string);
Handle<Map> map =
factory->NewMap(JS_OBJECT_TYPE, Heap::kSloppyArgumentsObjectSize);
Handle<Map> map = factory->NewMap(
JS_OBJECT_TYPE, Heap::kSloppyArgumentsObjectSize, FAST_ELEMENTS);
// Create the descriptor array for the arguments object.
Map::EnsureDescriptorSlack(map, 2);
......@@ -1414,8 +1414,8 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
caller->set_setter(*poison);
// Create the map. Allocate one in-object field for length.
Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE,
Heap::kStrictArgumentsObjectSize);
Handle<Map> map = factory->NewMap(
JS_OBJECT_TYPE, Heap::kStrictArgumentsObjectSize, FAST_ELEMENTS);
// Create the descriptor array for the arguments object.
Map::EnsureDescriptorSlack(map, 3);
......
......@@ -942,8 +942,12 @@ class ElementsAccessorBase : public ElementsAccessor {
? index
: kMaxUInt32;
} else {
Smi* smi_length = Smi::cast(JSArray::cast(holder)->length());
uint32_t length = static_cast<uint32_t>(smi_length->value());
uint32_t length =
holder->IsJSArray()
? static_cast<uint32_t>(
Smi::cast(JSArray::cast(holder)->length())->value())
: ElementsAccessorSubclass::GetCapacityImpl(holder,
backing_store);
return index < length ? index : kMaxUInt32;
}
}
......
......@@ -14505,8 +14505,8 @@ int JSObject::GetFastElementsUsage() {
case FAST_SMI_ELEMENTS:
case FAST_DOUBLE_ELEMENTS:
case FAST_ELEMENTS:
// Only JSArray have packed elements.
return Smi::cast(JSArray::cast(this)->length())->value();
return IsJSArray() ? Smi::cast(JSArray::cast(this)->length())->value()
: store->length();
case FAST_SLOPPY_ARGUMENTS_ELEMENTS:
store = FixedArray::cast(FixedArray::cast(store)->get(1));
// Fall through.
......
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