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

Side by Side Diff: src/runtime/runtime-classes.cc

Issue 2028983002: Introduce IsUndefined(Isolate*) and IsTheHole(Isolate*) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase master Created 4 years, 6 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/runtime/runtime-array.cc ('k') | src/runtime/runtime-collections.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <limits> 8 #include <limits>
9 9
10 #include "src/arguments.h" 10 #include "src/arguments.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 return isolate->heap()->home_object_symbol(); 81 return isolate->heap()->home_object_symbol();
82 } 82 }
83 83
84 static MaybeHandle<Object> DefineClass(Isolate* isolate, 84 static MaybeHandle<Object> DefineClass(Isolate* isolate,
85 Handle<Object> super_class, 85 Handle<Object> super_class,
86 Handle<JSFunction> constructor, 86 Handle<JSFunction> constructor,
87 int start_position, int end_position) { 87 int start_position, int end_position) {
88 Handle<Object> prototype_parent; 88 Handle<Object> prototype_parent;
89 Handle<Object> constructor_parent; 89 Handle<Object> constructor_parent;
90 90
91 if (super_class->IsTheHole()) { 91 if (super_class->IsTheHole(isolate)) {
92 prototype_parent = isolate->initial_object_prototype(); 92 prototype_parent = isolate->initial_object_prototype();
93 } else { 93 } else {
94 if (super_class->IsNull()) { 94 if (super_class->IsNull()) {
95 prototype_parent = isolate->factory()->null_value(); 95 prototype_parent = isolate->factory()->null_value();
96 } else if (super_class->IsConstructor()) { 96 } else if (super_class->IsConstructor()) {
97 DCHECK(!super_class->IsJSFunction() || 97 DCHECK(!super_class->IsJSFunction() ||
98 !Handle<JSFunction>::cast(super_class)->shared()->is_resumable()); 98 !Handle<JSFunction>::cast(super_class)->shared()->is_resumable());
99 ASSIGN_RETURN_ON_EXCEPTION( 99 ASSIGN_RETURN_ON_EXCEPTION(
100 isolate, prototype_parent, 100 isolate, prototype_parent,
101 Runtime::GetObjectProperty(isolate, super_class, 101 Runtime::GetObjectProperty(isolate, super_class,
(...skipping 14 matching lines...) Expand all
116 } 116 }
117 } 117 }
118 118
119 Handle<Map> map = 119 Handle<Map> map =
120 isolate->factory()->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); 120 isolate->factory()->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
121 map->set_is_prototype_map(true); 121 map->set_is_prototype_map(true);
122 Map::SetPrototype(map, prototype_parent); 122 Map::SetPrototype(map, prototype_parent);
123 map->SetConstructor(*constructor); 123 map->SetConstructor(*constructor);
124 Handle<JSObject> prototype = isolate->factory()->NewJSObjectFromMap(map); 124 Handle<JSObject> prototype = isolate->factory()->NewJSObjectFromMap(map);
125 125
126 if (!super_class->IsTheHole()) { 126 if (!super_class->IsTheHole(isolate)) {
127 // Derived classes, just like builtins, don't create implicit receivers in 127 // Derived classes, just like builtins, don't create implicit receivers in
128 // [[construct]]. Instead they just set up new.target and call into the 128 // [[construct]]. Instead they just set up new.target and call into the
129 // constructor. Hence we can reuse the builtins construct stub for derived 129 // constructor. Hence we can reuse the builtins construct stub for derived
130 // classes. 130 // classes.
131 Handle<Code> stub(isolate->builtins()->JSBuiltinsConstructStubForDerived()); 131 Handle<Code> stub(isolate->builtins()->JSBuiltinsConstructStubForDerived());
132 constructor->shared()->set_construct_stub(*stub); 132 constructor->shared()->set_construct_stub(*stub);
133 } 133 }
134 134
135 JSFunction::SetPrototype(constructor, prototype); 135 JSFunction::SetPrototype(constructor, prototype);
136 PropertyAttributes attribs = 136 PropertyAttributes attribs =
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 389
390 RUNTIME_FUNCTION(Runtime_GetSuperConstructor) { 390 RUNTIME_FUNCTION(Runtime_GetSuperConstructor) {
391 SealHandleScope shs(isolate); 391 SealHandleScope shs(isolate);
392 DCHECK_EQ(1, args.length()); 392 DCHECK_EQ(1, args.length());
393 CONVERT_ARG_CHECKED(JSFunction, active_function, 0); 393 CONVERT_ARG_CHECKED(JSFunction, active_function, 0);
394 return active_function->map()->prototype(); 394 return active_function->map()->prototype();
395 } 395 }
396 396
397 } // namespace internal 397 } // namespace internal
398 } // namespace v8 398 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-array.cc ('k') | src/runtime/runtime-collections.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698