Commit eb6d46de authored by verwaest's avatar verwaest Committed by Commit bot

[builtins] Remove superfluous fixed array allocation

Speeds up Object.keys by another ~10-20% :)

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

Cr-Commit-Position: refs/heads/master@{#33945}
parent cca0c545
...@@ -1852,24 +1852,22 @@ BUILTIN(ObjectKeys) { ...@@ -1852,24 +1852,22 @@ BUILTIN(ObjectKeys) {
Handle<FixedArray> keys; Handle<FixedArray> keys;
int enum_length = receiver->map()->EnumLength(); int enum_length = receiver->map()->EnumLength();
if (enum_length != kInvalidEnumCacheSentinel) { if (enum_length != kInvalidEnumCacheSentinel &&
JSObject::cast(*receiver)->elements() ==
isolate->heap()->empty_fixed_array()) {
DCHECK(receiver->IsJSObject()); DCHECK(receiver->IsJSObject());
Handle<JSObject> js_object = Handle<JSObject>::cast(receiver); DCHECK(!JSObject::cast(*receiver)->HasNamedInterceptor());
DCHECK(!js_object->HasNamedInterceptor()); DCHECK(!JSObject::cast(*receiver)->IsAccessCheckNeeded());
DCHECK(!js_object->IsAccessCheckNeeded()); DCHECK(!receiver->map()->has_hidden_prototype());
DCHECK(!js_object->map()->has_hidden_prototype()); DCHECK(JSObject::cast(*receiver)->HasFastProperties());
DCHECK(js_object->HasFastProperties()); if (enum_length == 0) {
if (js_object->elements() == isolate->heap()->empty_fixed_array()) { keys = isolate->factory()->empty_fixed_array();
keys = isolate->factory()->NewFixedArray(enum_length); } else {
if (enum_length != 0) {
Handle<FixedArray> cache( Handle<FixedArray> cache(
js_object->map()->instance_descriptors()->GetEnumCache()); receiver->map()->instance_descriptors()->GetEnumCache());
keys = isolate->factory()->CopyFixedArrayUpTo(cache, enum_length); keys = isolate->factory()->CopyFixedArrayUpTo(cache, enum_length);
} }
} } else {
}
if (keys.is_null()) {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION( ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, keys, isolate, keys,
JSReceiver::GetKeys(receiver, OWN_ONLY, ENUMERABLE_STRINGS, JSReceiver::GetKeys(receiver, OWN_ONLY, ENUMERABLE_STRINGS,
......
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