OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/api-natives.h" | 5 #include "src/api-natives.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/isolate-inl.h" | 8 #include "src/isolate-inl.h" |
9 #include "src/lookup.h" | 9 #include "src/lookup.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 } | 327 } |
328 | 328 |
329 bool IsSimpleInstantiation(Isolate* isolate, ObjectTemplateInfo* info, | 329 bool IsSimpleInstantiation(Isolate* isolate, ObjectTemplateInfo* info, |
330 JSReceiver* new_target) { | 330 JSReceiver* new_target) { |
331 DisallowHeapAllocation no_gc; | 331 DisallowHeapAllocation no_gc; |
332 | 332 |
333 if (!new_target->IsJSFunction()) return false; | 333 if (!new_target->IsJSFunction()) return false; |
334 JSFunction* fun = JSFunction::cast(new_target); | 334 JSFunction* fun = JSFunction::cast(new_target); |
335 if (fun->shared()->function_data() != info->constructor()) return false; | 335 if (fun->shared()->function_data() != info->constructor()) return false; |
336 if (info->immutable_proto()) return false; | 336 if (info->immutable_proto()) return false; |
337 return fun->context()->native_context() != | 337 return fun->context()->native_context() == isolate->raw_native_context(); |
338 isolate->context()->native_context(); | |
339 } | 338 } |
340 | 339 |
341 MaybeHandle<JSObject> InstantiateObject(Isolate* isolate, | 340 MaybeHandle<JSObject> InstantiateObject(Isolate* isolate, |
342 Handle<ObjectTemplateInfo> info, | 341 Handle<ObjectTemplateInfo> info, |
343 Handle<JSReceiver> new_target, | 342 Handle<JSReceiver> new_target, |
344 bool is_hidden_prototype) { | 343 bool is_hidden_prototype) { |
345 Handle<JSFunction> constructor; | 344 Handle<JSFunction> constructor; |
346 int serial_number = Smi::cast(info->serial_number())->value(); | 345 int serial_number = Smi::cast(info->serial_number())->value(); |
347 if (!new_target.is_null()) { | 346 if (!new_target.is_null()) { |
348 if (IsSimpleInstantiation(isolate, *info, *new_target)) { | 347 if (IsSimpleInstantiation(isolate, *info, *new_target)) { |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 if (!obj->instance_call_handler()->IsUndefined(isolate)) { | 682 if (!obj->instance_call_handler()->IsUndefined(isolate)) { |
684 map->set_is_callable(); | 683 map->set_is_callable(); |
685 map->set_is_constructor(true); | 684 map->set_is_constructor(true); |
686 } | 685 } |
687 | 686 |
688 return result; | 687 return result; |
689 } | 688 } |
690 | 689 |
691 } // namespace internal | 690 } // namespace internal |
692 } // namespace v8 | 691 } // namespace v8 |
OLD | NEW |