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

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

Issue 2770753003: Migrate Object constructor to C++
Patch Set: Manually set ElementsKind 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 static Object* ObjectConstructCommon(Isolate* isolate, Handle<Object> value) {
Benedikt Meurer 2017/03/30 08:33:22 Nit: Instead of static put this into an anonymous
rongjie 2017/03/30 09:08:22 Done.
19 if (value->IsNullOrUndefined(isolate)) {
20 Handle<JSObject> object =
21 isolate->factory()->NewJSObject(isolate->object_function(), TENURED);
Benedikt Meurer 2017/03/30 08:33:22 Don't use TENURED here, just omit the second param
rongjie 2017/03/30 09:08:22 Done.
22 object->map()->set_elements_kind(FAST_ELEMENTS);
Benedikt Meurer 2017/03/30 08:33:22 Remove this line.
rongjie 2017/03/30 09:08:22 Done. That was temp fix for mjsunit/elements-kind.
23 return *object;
24 }
25 RETURN_RESULT_OR_FAILURE(isolate, Object::ToObject(isolate, value));
26 }
27
18 // ----------------------------------------------------------------------------- 28 // -----------------------------------------------------------------------------
19 // ES6 section 19.1 Object Objects 29 // ES6 section 19.1 Object Objects
20 30
31 // ES6 section 19.1.1.1 The Object Constructor for the [[Call]] case.
32 BUILTIN(ObjectConstructor) {
33 HandleScope scope(isolate);
34 return ObjectConstructCommon(isolate, args.atOrUndefined(isolate, 1));
35 }
36
37 // ES6 section 19.1.1.1 The Object Constructor for the [[Construct]] case.
38 BUILTIN(ObjectConstructor_ConstructStub) {
39 HandleScope scope(isolate);
40 Handle<JSFunction> target = args.target();
41 DCHECK(*target == target->native_context()->object_function());
42 Handle<JSReceiver> new_target = Handle<JSReceiver>::cast(args.new_target());
43 if (*new_target != *target) {
44 RETURN_RESULT_OR_FAILURE(isolate, JSObject::New(target, new_target));
45 }
46 return ObjectConstructCommon(isolate, args.atOrUndefined(isolate, 1));
47 }
48
21 // ES6 19.1.2.1 Object.assign 49 // ES6 19.1.2.1 Object.assign
22 BUILTIN(ObjectAssign) { 50 BUILTIN(ObjectAssign) {
23 HandleScope scope(isolate); 51 HandleScope scope(isolate);
24 Handle<Object> target = args.atOrUndefined(isolate, 1); 52 Handle<Object> target = args.atOrUndefined(isolate, 1);
25 53
26 // 1. Let to be ? ToObject(target). 54 // 1. Let to be ? ToObject(target).
27 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, target, 55 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, target,
28 Object::ToObject(isolate, target)); 56 Object::ToObject(isolate, target));
29 Handle<JSReceiver> to = Handle<JSReceiver>::cast(target); 57 Handle<JSReceiver> to = Handle<JSReceiver>::cast(target);
30 // 2. If only one argument was passed, return to. 58 // 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()) { 573 if (object->IsJSReceiver()) {
546 MAYBE_RETURN(JSReceiver::SetIntegrityLevel(Handle<JSReceiver>::cast(object), 574 MAYBE_RETURN(JSReceiver::SetIntegrityLevel(Handle<JSReceiver>::cast(object),
547 SEALED, Object::THROW_ON_ERROR), 575 SEALED, Object::THROW_ON_ERROR),
548 isolate->heap()->exception()); 576 isolate->heap()->exception());
549 } 577 }
550 return *object; 578 return *object;
551 } 579 }
552 580
553 } // namespace internal 581 } // namespace internal
554 } // namespace v8 582 } // 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