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