OLD | NEW |
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 Loading... |
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 if (super_class->IsJSFunction() && | 97 if (super_class->IsJSFunction() && |
98 Handle<JSFunction>::cast(super_class)->shared()->is_generator()) { | 98 Handle<JSFunction>::cast(super_class)->shared()->is_generator()) { |
99 THROW_NEW_ERROR( | 99 THROW_NEW_ERROR( |
100 isolate, | 100 isolate, |
101 NewTypeError(MessageTemplate::kExtendsValueGenerator, super_class), | 101 NewTypeError(MessageTemplate::kExtendsValueGenerator, super_class), |
(...skipping 19 matching lines...) Expand all Loading... |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 Handle<Map> map = | 124 Handle<Map> map = |
125 isolate->factory()->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); | 125 isolate->factory()->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
126 map->set_is_prototype_map(true); | 126 map->set_is_prototype_map(true); |
127 Map::SetPrototype(map, prototype_parent); | 127 Map::SetPrototype(map, prototype_parent); |
128 map->SetConstructor(*constructor); | 128 map->SetConstructor(*constructor); |
129 Handle<JSObject> prototype = isolate->factory()->NewJSObjectFromMap(map); | 129 Handle<JSObject> prototype = isolate->factory()->NewJSObjectFromMap(map); |
130 | 130 |
131 if (!super_class->IsTheHole()) { | 131 if (!super_class->IsTheHole(isolate)) { |
132 // Derived classes, just like builtins, don't create implicit receivers in | 132 // Derived classes, just like builtins, don't create implicit receivers in |
133 // [[construct]]. Instead they just set up new.target and call into the | 133 // [[construct]]. Instead they just set up new.target and call into the |
134 // constructor. Hence we can reuse the builtins construct stub for derived | 134 // constructor. Hence we can reuse the builtins construct stub for derived |
135 // classes. | 135 // classes. |
136 Handle<Code> stub(isolate->builtins()->JSBuiltinsConstructStubForDerived()); | 136 Handle<Code> stub(isolate->builtins()->JSBuiltinsConstructStubForDerived()); |
137 constructor->shared()->set_construct_stub(*stub); | 137 constructor->shared()->set_construct_stub(*stub); |
138 } | 138 } |
139 | 139 |
140 JSFunction::SetPrototype(constructor, prototype); | 140 JSFunction::SetPrototype(constructor, prototype); |
141 PropertyAttributes attribs = | 141 PropertyAttributes attribs = |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 | 394 |
395 RUNTIME_FUNCTION(Runtime_GetSuperConstructor) { | 395 RUNTIME_FUNCTION(Runtime_GetSuperConstructor) { |
396 SealHandleScope shs(isolate); | 396 SealHandleScope shs(isolate); |
397 DCHECK_EQ(1, args.length()); | 397 DCHECK_EQ(1, args.length()); |
398 CONVERT_ARG_CHECKED(JSFunction, active_function, 0); | 398 CONVERT_ARG_CHECKED(JSFunction, active_function, 0); |
399 return active_function->map()->prototype(); | 399 return active_function->map()->prototype(); |
400 } | 400 } |
401 | 401 |
402 } // namespace internal | 402 } // namespace internal |
403 } // namespace v8 | 403 } // namespace v8 |
OLD | NEW |