Commit 0fbe943e authored by verwaest's avatar verwaest Committed by Commit bot

Track whether the Object.assign source is stable with a bool rather than...

Track whether the Object.assign source is stable with a bool rather than map-check on each iteration.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#34153}
parent d2187182
...@@ -1609,11 +1609,13 @@ MUST_USE_RESULT Maybe<bool> FastAssign(Handle<JSReceiver> to, ...@@ -1609,11 +1609,13 @@ MUST_USE_RESULT Maybe<bool> FastAssign(Handle<JSReceiver> to,
Handle<DescriptorArray> descriptors(map->instance_descriptors(), isolate); Handle<DescriptorArray> descriptors(map->instance_descriptors(), isolate);
int length = map->NumberOfOwnDescriptors(); int length = map->NumberOfOwnDescriptors();
bool stable = true;
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
Handle<Name> next_key(descriptors->GetKey(i), isolate); Handle<Name> next_key(descriptors->GetKey(i), isolate);
Handle<Object> prop_value; Handle<Object> prop_value;
// Directly decode from the descriptor array if |from| did not change shape. // Directly decode from the descriptor array if |from| did not change shape.
if (from->map() == *map) { if (stable) {
PropertyDetails details = descriptors->GetDetails(i); PropertyDetails details = descriptors->GetDetails(i);
if (!details.IsEnumerable()) continue; if (!details.IsEnumerable()) continue;
if (details.kind() == kData) { if (details.kind() == kData) {
...@@ -1628,6 +1630,7 @@ MUST_USE_RESULT Maybe<bool> FastAssign(Handle<JSReceiver> to, ...@@ -1628,6 +1630,7 @@ MUST_USE_RESULT Maybe<bool> FastAssign(Handle<JSReceiver> to,
ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, prop_value, ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, prop_value,
Object::GetProperty(from, next_key), Object::GetProperty(from, next_key),
Nothing<bool>()); Nothing<bool>());
stable = from->map() == *map;
} }
} else { } else {
// If the map did change, do a slower lookup. We are still guaranteed that // If the map did change, do a slower lookup. We are still guaranteed that
...@@ -1640,12 +1643,12 @@ MUST_USE_RESULT Maybe<bool> FastAssign(Handle<JSReceiver> to, ...@@ -1640,12 +1643,12 @@ MUST_USE_RESULT Maybe<bool> FastAssign(Handle<JSReceiver> to,
ASSIGN_RETURN_ON_EXCEPTION_VALUE( ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, prop_value, Object::GetProperty(&it), Nothing<bool>()); isolate, prop_value, Object::GetProperty(&it), Nothing<bool>());
} }
Handle<Object> status; LookupIterator it(to, next_key);
ASSIGN_RETURN_ON_EXCEPTION_VALUE( bool call_to_js = it.IsFound() && it.state() != LookupIterator::DATA;
isolate, status, Maybe<bool> result = Object::SetProperty(
Object::SetProperty(to, next_key, prop_value, STRICT, &it, prop_value, STRICT, Object::CERTAINLY_NOT_STORE_FROM_KEYED);
Object::CERTAINLY_NOT_STORE_FROM_KEYED), if (result.IsNothing()) return result;
Nothing<bool>()); if (stable && call_to_js) stable = from->map() == *map;
} }
return Just(true); return Just(true);
......
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