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

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

Issue 2770753003: Migrate Object constructor to C++
Patch Set: Ack comments Created 3 years, 8 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/crankshaft/hydrogen.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"
11 #include "src/lookup.h" 11 #include "src/lookup.h"
12 #include "src/objects-inl.h" 12 #include "src/objects-inl.h"
13 #include "src/property-descriptor.h" 13 #include "src/property-descriptor.h"
14 14
15 namespace v8 { 15 namespace v8 {
16 namespace internal { 16 namespace internal {
17 17
18 namespace {
19
20 Object* ObjectConstructCommon(Isolate* isolate, Handle<Object> value) {
21 if (value->IsNullOrUndefined(isolate)) {
22 return *isolate->factory()->NewJSObject(isolate->object_function());
23 }
24 RETURN_RESULT_OR_FAILURE(isolate, Object::ToObject(isolate, value));
25 }
26
27 }
28
18 // ----------------------------------------------------------------------------- 29 // -----------------------------------------------------------------------------
19 // ES6 section 19.1 Object Objects 30 // ES6 section 19.1 Object Objects
20 31
32 // ES6 section 19.1.1.1 The Object Constructor for the [[Call]] case.
33 BUILTIN(ObjectConstructor) {
34 HandleScope scope(isolate);
35 return ObjectConstructCommon(isolate, args.atOrUndefined(isolate, 1));
36 }
37
38 // ES6 section 19.1.1.1 The Object Constructor for the [[Construct]] case.
39 BUILTIN(ObjectConstructor_ConstructStub) {
40 HandleScope scope(isolate);
41 Handle<JSFunction> target = args.target();
42 DCHECK(*target == target->native_context()->object_function());
43 Handle<JSReceiver> new_target = Handle<JSReceiver>::cast(args.new_target());
44 if (*new_target != *target) {
45 RETURN_RESULT_OR_FAILURE(isolate, JSObject::New(target, new_target));
46 }
47 return ObjectConstructCommon(isolate, args.atOrUndefined(isolate, 1));
48 }
49
21 // ES6 19.1.2.1 Object.assign 50 // ES6 19.1.2.1 Object.assign
22 BUILTIN(ObjectAssign) { 51 BUILTIN(ObjectAssign) {
23 HandleScope scope(isolate); 52 HandleScope scope(isolate);
24 Handle<Object> target = args.atOrUndefined(isolate, 1); 53 Handle<Object> target = args.atOrUndefined(isolate, 1);
25 54
26 // 1. Let to be ? ToObject(target). 55 // 1. Let to be ? ToObject(target).
27 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, target, 56 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, target,
28 Object::ToObject(isolate, target)); 57 Object::ToObject(isolate, target));
29 Handle<JSReceiver> to = Handle<JSReceiver>::cast(target); 58 Handle<JSReceiver> to = Handle<JSReceiver>::cast(target);
30 // 2. If only one argument was passed, return to. 59 // 2. If only one argument was passed, return to.
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 if (object->IsJSReceiver()) { 574 if (object->IsJSReceiver()) {
546 MAYBE_RETURN(JSReceiver::SetIntegrityLevel(Handle<JSReceiver>::cast(object), 575 MAYBE_RETURN(JSReceiver::SetIntegrityLevel(Handle<JSReceiver>::cast(object),
547 SEALED, Object::THROW_ON_ERROR), 576 SEALED, Object::THROW_ON_ERROR),
548 isolate->heap()->exception()); 577 isolate->heap()->exception());
549 } 578 }
550 return *object; 579 return *object;
551 } 580 }
552 581
553 } // namespace internal 582 } // namespace internal
554 } // namespace v8 583 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins/builtins-definitions.h ('k') | src/crankshaft/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698