Chromium Code Reviews| 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 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 606 | 606 |
| 607 if (prototype->IsTheHole(isolate)) { | 607 if (prototype->IsTheHole(isolate)) { |
| 608 prototype = isolate->factory()->NewFunctionPrototype(result); | 608 prototype = isolate->factory()->NewFunctionPrototype(result); |
| 609 } else { | 609 } else { |
| 610 JSObject::AddProperty(Handle<JSObject>::cast(prototype), | 610 JSObject::AddProperty(Handle<JSObject>::cast(prototype), |
| 611 isolate->factory()->constructor_string(), result, | 611 isolate->factory()->constructor_string(), result, |
| 612 DONT_ENUM); | 612 DONT_ENUM); |
| 613 } | 613 } |
| 614 | 614 |
| 615 int internal_field_count = 0; | 615 int internal_field_count = 0; |
| 616 bool immutable_proto = false; | |
| 616 if (!obj->instance_template()->IsUndefined(isolate)) { | 617 if (!obj->instance_template()->IsUndefined(isolate)) { |
| 617 Handle<ObjectTemplateInfo> instance_template = Handle<ObjectTemplateInfo>( | 618 Handle<ObjectTemplateInfo> instance_template = Handle<ObjectTemplateInfo>( |
| 618 ObjectTemplateInfo::cast(obj->instance_template())); | 619 ObjectTemplateInfo::cast(obj->instance_template())); |
| 619 internal_field_count = instance_template->internal_field_count(); | 620 internal_field_count = instance_template->internal_field_count(); |
| 621 immutable_proto = instance_template->immutable_proto(); | |
| 620 } | 622 } |
| 621 | 623 |
| 622 // TODO(svenpanne) Kill ApiInstanceType and refactor things by generalizing | 624 // TODO(svenpanne) Kill ApiInstanceType and refactor things by generalizing |
| 623 // JSObject::GetHeaderSize. | 625 // JSObject::GetHeaderSize. |
| 624 int instance_size = kPointerSize * internal_field_count; | 626 int instance_size = kPointerSize * internal_field_count; |
| 625 InstanceType type; | 627 InstanceType type; |
| 626 switch (instance_type) { | 628 switch (instance_type) { |
| 627 case JavaScriptObjectType: | 629 case JavaScriptObjectType: |
| 628 if (!obj->needs_access_check() && | 630 if (!obj->needs_access_check() && |
| 629 obj->named_property_handler()->IsUndefined(isolate) && | 631 obj->named_property_handler()->IsUndefined(isolate) && |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 643 instance_size += JSGlobalProxy::kSize; | 645 instance_size += JSGlobalProxy::kSize; |
| 644 break; | 646 break; |
| 645 default: | 647 default: |
| 646 UNREACHABLE(); | 648 UNREACHABLE(); |
| 647 type = JS_OBJECT_TYPE; // Keep the compiler happy. | 649 type = JS_OBJECT_TYPE; // Keep the compiler happy. |
| 648 break; | 650 break; |
| 649 } | 651 } |
| 650 | 652 |
| 651 Handle<Map> map = | 653 Handle<Map> map = |
| 652 isolate->factory()->NewMap(type, instance_size, FAST_HOLEY_SMI_ELEMENTS); | 654 isolate->factory()->NewMap(type, instance_size, FAST_HOLEY_SMI_ELEMENTS); |
| 655 | |
| 656 if (immutable_proto) map->set_immutable_proto(true); | |
|
adamk
2016/11/04 18:06:12
Please put this down below with all the others (af
| |
| 657 | |
| 653 JSFunction::SetInitialMap(result, map, Handle<JSObject>::cast(prototype)); | 658 JSFunction::SetInitialMap(result, map, Handle<JSObject>::cast(prototype)); |
| 654 | 659 |
| 655 // Mark as undetectable if needed. | 660 // Mark as undetectable if needed. |
| 656 if (obj->undetectable()) { | 661 if (obj->undetectable()) { |
| 657 map->set_is_undetectable(); | 662 map->set_is_undetectable(); |
| 658 } | 663 } |
| 659 | 664 |
| 660 // Mark as needs_access_check if needed. | 665 // Mark as needs_access_check if needed. |
| 661 if (obj->needs_access_check()) { | 666 if (obj->needs_access_check()) { |
| 662 map->set_is_access_check_needed(true); | 667 map->set_is_access_check_needed(true); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 674 if (!obj->instance_call_handler()->IsUndefined(isolate)) { | 679 if (!obj->instance_call_handler()->IsUndefined(isolate)) { |
| 675 map->set_is_callable(); | 680 map->set_is_callable(); |
| 676 map->set_is_constructor(true); | 681 map->set_is_constructor(true); |
| 677 } | 682 } |
| 678 | 683 |
| 679 return result; | 684 return result; |
| 680 } | 685 } |
| 681 | 686 |
| 682 } // namespace internal | 687 } // namespace internal |
| 683 } // namespace v8 | 688 } // namespace v8 |
| OLD | NEW |