| 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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 FunctionTemplateInfo::cast(data->constructor())); | 536 FunctionTemplateInfo::cast(data->constructor())); |
| 537 Handle<SharedFunctionInfo> shared = | 537 Handle<SharedFunctionInfo> shared = |
| 538 FunctionTemplateInfo::GetOrCreateSharedFunctionInfo(isolate, constructor); | 538 FunctionTemplateInfo::GetOrCreateSharedFunctionInfo(isolate, constructor); |
| 539 Handle<Map> initial_map = isolate->factory()->CreateSloppyFunctionMap( | 539 Handle<Map> initial_map = isolate->factory()->CreateSloppyFunctionMap( |
| 540 FUNCTION_WITH_WRITEABLE_PROTOTYPE); | 540 FUNCTION_WITH_WRITEABLE_PROTOTYPE); |
| 541 Handle<JSFunction> object_function = | 541 Handle<JSFunction> object_function = |
| 542 isolate->factory()->NewFunctionFromSharedFunctionInfo( | 542 isolate->factory()->NewFunctionFromSharedFunctionInfo( |
| 543 initial_map, shared, isolate->factory()->undefined_value()); | 543 initial_map, shared, isolate->factory()->undefined_value()); |
| 544 Handle<Map> object_map = isolate->factory()->NewMap( | 544 Handle<Map> object_map = isolate->factory()->NewMap( |
| 545 JS_SPECIAL_API_OBJECT_TYPE, | 545 JS_SPECIAL_API_OBJECT_TYPE, |
| 546 JSObject::kHeaderSize + data->internal_field_count() * kPointerSize, | 546 JSObject::kHeaderSize + data->embedder_field_count() * kPointerSize, |
| 547 FAST_HOLEY_SMI_ELEMENTS); | 547 FAST_HOLEY_SMI_ELEMENTS); |
| 548 JSFunction::SetInitialMap(object_function, object_map, | 548 JSFunction::SetInitialMap(object_function, object_map, |
| 549 isolate->factory()->null_value()); | 549 isolate->factory()->null_value()); |
| 550 object_map->set_is_access_check_needed(true); | 550 object_map->set_is_access_check_needed(true); |
| 551 | 551 |
| 552 Handle<JSObject> object = isolate->factory()->NewJSObject(object_function); | 552 Handle<JSObject> object = isolate->factory()->NewJSObject(object_function); |
| 553 JSObject::ForceSetPrototype(object, isolate->factory()->null_value()); | 553 JSObject::ForceSetPrototype(object, isolate->factory()->null_value()); |
| 554 | 554 |
| 555 return object; | 555 return object; |
| 556 } | 556 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 } | 632 } |
| 633 | 633 |
| 634 if (prototype->IsTheHole(isolate)) { | 634 if (prototype->IsTheHole(isolate)) { |
| 635 prototype = isolate->factory()->NewFunctionPrototype(result); | 635 prototype = isolate->factory()->NewFunctionPrototype(result); |
| 636 } else if (obj->prototype_provider_template()->IsUndefined(isolate)) { | 636 } else if (obj->prototype_provider_template()->IsUndefined(isolate)) { |
| 637 JSObject::AddProperty(Handle<JSObject>::cast(prototype), | 637 JSObject::AddProperty(Handle<JSObject>::cast(prototype), |
| 638 isolate->factory()->constructor_string(), result, | 638 isolate->factory()->constructor_string(), result, |
| 639 DONT_ENUM); | 639 DONT_ENUM); |
| 640 } | 640 } |
| 641 | 641 |
| 642 int internal_field_count = 0; | 642 int embedder_field_count = 0; |
| 643 bool immutable_proto = false; | 643 bool immutable_proto = false; |
| 644 if (!obj->instance_template()->IsUndefined(isolate)) { | 644 if (!obj->instance_template()->IsUndefined(isolate)) { |
| 645 Handle<ObjectTemplateInfo> instance_template = Handle<ObjectTemplateInfo>( | 645 Handle<ObjectTemplateInfo> instance_template = Handle<ObjectTemplateInfo>( |
| 646 ObjectTemplateInfo::cast(obj->instance_template())); | 646 ObjectTemplateInfo::cast(obj->instance_template())); |
| 647 internal_field_count = instance_template->internal_field_count(); | 647 embedder_field_count = instance_template->embedder_field_count(); |
| 648 immutable_proto = instance_template->immutable_proto(); | 648 immutable_proto = instance_template->immutable_proto(); |
| 649 } | 649 } |
| 650 | 650 |
| 651 // TODO(svenpanne) Kill ApiInstanceType and refactor things by generalizing | 651 // TODO(svenpanne) Kill ApiInstanceType and refactor things by generalizing |
| 652 // JSObject::GetHeaderSize. | 652 // JSObject::GetHeaderSize. |
| 653 int instance_size = kPointerSize * internal_field_count; | 653 int instance_size = kPointerSize * embedder_field_count; |
| 654 InstanceType type; | 654 InstanceType type; |
| 655 switch (instance_type) { | 655 switch (instance_type) { |
| 656 case JavaScriptObjectType: | 656 case JavaScriptObjectType: |
| 657 if (!obj->needs_access_check() && | 657 if (!obj->needs_access_check() && |
| 658 obj->named_property_handler()->IsUndefined(isolate) && | 658 obj->named_property_handler()->IsUndefined(isolate) && |
| 659 obj->indexed_property_handler()->IsUndefined(isolate)) { | 659 obj->indexed_property_handler()->IsUndefined(isolate)) { |
| 660 type = JS_API_OBJECT_TYPE; | 660 type = JS_API_OBJECT_TYPE; |
| 661 } else { | 661 } else { |
| 662 type = JS_SPECIAL_API_OBJECT_TYPE; | 662 type = JS_SPECIAL_API_OBJECT_TYPE; |
| 663 } | 663 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 map->set_is_constructor(true); | 711 map->set_is_constructor(true); |
| 712 } | 712 } |
| 713 | 713 |
| 714 if (immutable_proto) map->set_immutable_proto(true); | 714 if (immutable_proto) map->set_immutable_proto(true); |
| 715 | 715 |
| 716 return result; | 716 return result; |
| 717 } | 717 } |
| 718 | 718 |
| 719 } // namespace internal | 719 } // namespace internal |
| 720 } // namespace v8 | 720 } // namespace v8 |
| OLD | NEW |