Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1069)

Unified Diff: src/builtins.cc

Issue 1697533002: [builtins] Remove superfluous fixed array allocation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins.cc
diff --git a/src/builtins.cc b/src/builtins.cc
index 083eb0ebdbe2a1307158225f47b3bde4795b9ffd..1c596503ef86e95bf3b6e3054ade3c484ae4a661 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -1852,24 +1852,22 @@ BUILTIN(ObjectKeys) {
Handle<FixedArray> keys;
int enum_length = receiver->map()->EnumLength();
- if (enum_length != kInvalidEnumCacheSentinel) {
+ if (enum_length != kInvalidEnumCacheSentinel &&
+ JSObject::cast(*receiver)->elements() ==
+ isolate->heap()->empty_fixed_array()) {
Camillo Bruni 2016/02/12 13:04:21 Maybe add a HasNoElements helper at some point?
DCHECK(receiver->IsJSObject());
- Handle<JSObject> js_object = Handle<JSObject>::cast(receiver);
- DCHECK(!js_object->HasNamedInterceptor());
- DCHECK(!js_object->IsAccessCheckNeeded());
- DCHECK(!js_object->map()->has_hidden_prototype());
- DCHECK(js_object->HasFastProperties());
- if (js_object->elements() == isolate->heap()->empty_fixed_array()) {
- keys = isolate->factory()->NewFixedArray(enum_length);
- if (enum_length != 0) {
- Handle<FixedArray> cache(
- js_object->map()->instance_descriptors()->GetEnumCache());
- keys = isolate->factory()->CopyFixedArrayUpTo(cache, enum_length);
- }
+ DCHECK(!JSObject::cast(*receiver)->HasNamedInterceptor());
+ DCHECK(!JSObject::cast(*receiver)->IsAccessCheckNeeded());
+ DCHECK(!receiver->map()->has_hidden_prototype());
+ DCHECK(JSObject::cast(*receiver)->HasFastProperties());
+ if (enum_length == 0) {
+ keys = isolate->factory()->empty_fixed_array();
+ } else {
+ Handle<FixedArray> cache(
+ receiver->map()->instance_descriptors()->GetEnumCache());
+ keys = isolate->factory()->CopyFixedArrayUpTo(cache, enum_length);
Camillo Bruni 2016/02/12 13:04:21 This pattern probably as well... GetEnumCacheCopy
}
- }
-
- if (keys.is_null()) {
+ } else {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, keys,
JSReceiver::GetKeys(receiver, OWN_ONLY, ENUMERABLE_STRINGS,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698