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

Side by Side Diff: src/builtins/builtins-object.cc

Issue 2853393002: [builtins] Migrate Object.keys to CodeStubAssembler builtin. (Closed)
Patch Set: Really fix the test, meh. Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « src/builtins/builtins-definitions.h ('k') | src/builtins/builtins-object-gen.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/builtins/builtins-utils.h" 5 #include "src/builtins/builtins-utils.h"
6 #include "src/builtins/builtins.h" 6 #include "src/builtins/builtins.h"
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/code-stub-assembler.h" 8 #include "src/code-stub-assembler.h"
9 #include "src/counters.h" 9 #include "src/counters.h"
10 #include "src/keys.h" 10 #include "src/keys.h"
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 HandleScope scope(isolate); 430 HandleScope scope(isolate);
431 Handle<Object> object = args.atOrUndefined(isolate, 1); 431 Handle<Object> object = args.atOrUndefined(isolate, 1);
432 Maybe<bool> result = object->IsJSReceiver() 432 Maybe<bool> result = object->IsJSReceiver()
433 ? JSReceiver::TestIntegrityLevel( 433 ? JSReceiver::TestIntegrityLevel(
434 Handle<JSReceiver>::cast(object), SEALED) 434 Handle<JSReceiver>::cast(object), SEALED)
435 : Just(true); 435 : Just(true);
436 MAYBE_RETURN(result, isolate->heap()->exception()); 436 MAYBE_RETURN(result, isolate->heap()->exception());
437 return isolate->heap()->ToBoolean(result.FromJust()); 437 return isolate->heap()->ToBoolean(result.FromJust());
438 } 438 }
439 439
440 // ES6 section 19.1.2.14 Object.keys ( O )
441 BUILTIN(ObjectKeys) {
442 HandleScope scope(isolate);
443 Handle<Object> object = args.atOrUndefined(isolate, 1);
444 Handle<JSReceiver> receiver;
445 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver,
446 Object::ToObject(isolate, object));
447
448 Handle<FixedArray> keys;
449 int enum_length = receiver->map()->EnumLength();
450 if (enum_length != kInvalidEnumCacheSentinel &&
451 JSObject::cast(*receiver)->elements() ==
452 isolate->heap()->empty_fixed_array()) {
453 DCHECK(receiver->IsJSObject());
454 DCHECK(!JSObject::cast(*receiver)->HasNamedInterceptor());
455 DCHECK(!JSObject::cast(*receiver)->IsAccessCheckNeeded());
456 DCHECK(!receiver->map()->has_hidden_prototype());
457 DCHECK(JSObject::cast(*receiver)->HasFastProperties());
458 if (enum_length == 0) {
459 keys = isolate->factory()->empty_fixed_array();
460 } else {
461 Handle<FixedArray> cache(
462 receiver->map()->instance_descriptors()->GetEnumCache());
463 keys = isolate->factory()->CopyFixedArrayUpTo(cache, enum_length);
464 }
465 } else {
466 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
467 isolate, keys,
468 KeyAccumulator::GetKeys(receiver, KeyCollectionMode::kOwnOnly,
469 ENUMERABLE_STRINGS,
470 GetKeysConversion::kConvertToString));
471 }
472 return *isolate->factory()->NewJSArrayWithElements(keys, FAST_ELEMENTS);
473 }
474
475 BUILTIN(ObjectValues) { 440 BUILTIN(ObjectValues) {
476 HandleScope scope(isolate); 441 HandleScope scope(isolate);
477 Handle<Object> object = args.atOrUndefined(isolate, 1); 442 Handle<Object> object = args.atOrUndefined(isolate, 1);
478 Handle<JSReceiver> receiver; 443 Handle<JSReceiver> receiver;
479 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, 444 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver,
480 Object::ToObject(isolate, object)); 445 Object::ToObject(isolate, object));
481 Handle<FixedArray> values; 446 Handle<FixedArray> values;
482 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 447 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
483 isolate, values, JSReceiver::GetOwnValues(receiver, ENUMERABLE_STRINGS)); 448 isolate, values, JSReceiver::GetOwnValues(receiver, ENUMERABLE_STRINGS));
484 return *isolate->factory()->NewJSArrayWithElements(values); 449 return *isolate->factory()->NewJSArrayWithElements(values);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 if (object->IsJSReceiver()) { 518 if (object->IsJSReceiver()) {
554 MAYBE_RETURN(JSReceiver::SetIntegrityLevel(Handle<JSReceiver>::cast(object), 519 MAYBE_RETURN(JSReceiver::SetIntegrityLevel(Handle<JSReceiver>::cast(object),
555 SEALED, Object::THROW_ON_ERROR), 520 SEALED, Object::THROW_ON_ERROR),
556 isolate->heap()->exception()); 521 isolate->heap()->exception());
557 } 522 }
558 return *object; 523 return *object;
559 } 524 }
560 525
561 } // namespace internal 526 } // namespace internal
562 } // namespace v8 527 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins/builtins-definitions.h ('k') | src/builtins/builtins-object-gen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698