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/bootstrapper.h" | 5 #include "src/bootstrapper.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/extensions/externalize-string-extension.h" | 9 #include "src/extensions/externalize-string-extension.h" |
10 #include "src/extensions/free-buffer-extension.h" | 10 #include "src/extensions/free-buffer-extension.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 Bootstrapper::Bootstrapper(Isolate* isolate) | 37 Bootstrapper::Bootstrapper(Isolate* isolate) |
38 : isolate_(isolate), | 38 : isolate_(isolate), |
39 nesting_(0), | 39 nesting_(0), |
40 extensions_cache_(Script::TYPE_EXTENSION), | 40 extensions_cache_(Script::TYPE_EXTENSION), |
41 delete_these_non_arrays_on_tear_down_(NULL), | 41 delete_these_non_arrays_on_tear_down_(NULL), |
42 delete_these_arrays_on_tear_down_(NULL) { | 42 delete_these_arrays_on_tear_down_(NULL) { |
43 } | 43 } |
44 | 44 |
45 | 45 |
46 Handle<String> Bootstrapper::NativesSourceLookup(int index) { | 46 Handle<String> Bootstrapper::NativesSourceLookup(int index) { |
47 ASSERT(0 <= index && index < Natives::GetBuiltinsCount()); | 47 DCHECK(0 <= index && index < Natives::GetBuiltinsCount()); |
48 Heap* heap = isolate_->heap(); | 48 Heap* heap = isolate_->heap(); |
49 if (heap->natives_source_cache()->get(index)->IsUndefined()) { | 49 if (heap->natives_source_cache()->get(index)->IsUndefined()) { |
50 // We can use external strings for the natives. | 50 // We can use external strings for the natives. |
51 Vector<const char> source = Natives::GetRawScriptSource(index); | 51 Vector<const char> source = Natives::GetRawScriptSource(index); |
52 NativesExternalStringResource* resource = | 52 NativesExternalStringResource* resource = |
53 new NativesExternalStringResource(this, | 53 new NativesExternalStringResource(this, |
54 source.start(), | 54 source.start(), |
55 source.length()); | 55 source.length()); |
56 // We do not expect this to throw an exception. Change this if it does. | 56 // We do not expect this to throw an exception. Change this if it does. |
57 Handle<String> source_code = | 57 Handle<String> source_code = |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 114 } |
115 delete_these_arrays_on_tear_down_->Add(memory); | 115 delete_these_arrays_on_tear_down_->Add(memory); |
116 } | 116 } |
117 return memory; | 117 return memory; |
118 } | 118 } |
119 | 119 |
120 | 120 |
121 void Bootstrapper::TearDown() { | 121 void Bootstrapper::TearDown() { |
122 if (delete_these_non_arrays_on_tear_down_ != NULL) { | 122 if (delete_these_non_arrays_on_tear_down_ != NULL) { |
123 int len = delete_these_non_arrays_on_tear_down_->length(); | 123 int len = delete_these_non_arrays_on_tear_down_->length(); |
124 ASSERT(len < 24); // Don't use this mechanism for unbounded allocations. | 124 DCHECK(len < 24); // Don't use this mechanism for unbounded allocations. |
125 for (int i = 0; i < len; i++) { | 125 for (int i = 0; i < len; i++) { |
126 delete delete_these_non_arrays_on_tear_down_->at(i); | 126 delete delete_these_non_arrays_on_tear_down_->at(i); |
127 delete_these_non_arrays_on_tear_down_->at(i) = NULL; | 127 delete_these_non_arrays_on_tear_down_->at(i) = NULL; |
128 } | 128 } |
129 delete delete_these_non_arrays_on_tear_down_; | 129 delete delete_these_non_arrays_on_tear_down_; |
130 delete_these_non_arrays_on_tear_down_ = NULL; | 130 delete_these_non_arrays_on_tear_down_ = NULL; |
131 } | 131 } |
132 | 132 |
133 if (delete_these_arrays_on_tear_down_ != NULL) { | 133 if (delete_these_arrays_on_tear_down_ != NULL) { |
134 int len = delete_these_arrays_on_tear_down_->length(); | 134 int len = delete_these_arrays_on_tear_down_->length(); |
135 ASSERT(len < 1000); // Don't use this mechanism for unbounded allocations. | 135 DCHECK(len < 1000); // Don't use this mechanism for unbounded allocations. |
136 for (int i = 0; i < len; i++) { | 136 for (int i = 0; i < len; i++) { |
137 delete[] delete_these_arrays_on_tear_down_->at(i); | 137 delete[] delete_these_arrays_on_tear_down_->at(i); |
138 delete_these_arrays_on_tear_down_->at(i) = NULL; | 138 delete_these_arrays_on_tear_down_->at(i) = NULL; |
139 } | 139 } |
140 delete delete_these_arrays_on_tear_down_; | 140 delete delete_these_arrays_on_tear_down_; |
141 delete_these_arrays_on_tear_down_ = NULL; | 141 delete_these_arrays_on_tear_down_ = NULL; |
142 } | 142 } |
143 | 143 |
144 extensions_cache_.Initialize(isolate_, false); // Yes, symmetrical | 144 extensions_cache_.Initialize(isolate_, false); // Yes, symmetrical |
145 } | 145 } |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); | 544 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); |
545 PropertyAttributes ro_attribs = | 545 PropertyAttributes ro_attribs = |
546 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 546 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
547 | 547 |
548 // Add length. | 548 // Add length. |
549 if (function_mode == BOUND_FUNCTION) { | 549 if (function_mode == BOUND_FUNCTION) { |
550 Handle<String> length_string = isolate()->factory()->length_string(); | 550 Handle<String> length_string = isolate()->factory()->length_string(); |
551 FieldDescriptor d(length_string, 0, ro_attribs, Representation::Tagged()); | 551 FieldDescriptor d(length_string, 0, ro_attribs, Representation::Tagged()); |
552 map->AppendDescriptor(&d); | 552 map->AppendDescriptor(&d); |
553 } else { | 553 } else { |
554 ASSERT(function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE || | 554 DCHECK(function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE || |
555 function_mode == FUNCTION_WITH_READONLY_PROTOTYPE || | 555 function_mode == FUNCTION_WITH_READONLY_PROTOTYPE || |
556 function_mode == FUNCTION_WITHOUT_PROTOTYPE); | 556 function_mode == FUNCTION_WITHOUT_PROTOTYPE); |
557 Handle<AccessorInfo> length = | 557 Handle<AccessorInfo> length = |
558 Accessors::FunctionLengthInfo(isolate(), ro_attribs); | 558 Accessors::FunctionLengthInfo(isolate(), ro_attribs); |
559 CallbacksDescriptor d(Handle<Name>(Name::cast(length->name())), | 559 CallbacksDescriptor d(Handle<Name>(Name::cast(length->name())), |
560 length, ro_attribs); | 560 length, ro_attribs); |
561 map->AppendDescriptor(&d); | 561 map->AppendDescriptor(&d); |
562 } | 562 } |
563 Handle<AccessorInfo> name = | 563 Handle<AccessorInfo> name = |
564 Accessors::FunctionNameInfo(isolate(), ro_attribs); | 564 Accessors::FunctionNameInfo(isolate(), ro_attribs); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 } | 688 } |
689 | 689 |
690 | 690 |
691 void Genesis::PoisonArgumentsAndCaller(Handle<Map> map) { | 691 void Genesis::PoisonArgumentsAndCaller(Handle<Map> map) { |
692 SetAccessors(map, factory()->arguments_string(), GetStrictPoisonFunction()); | 692 SetAccessors(map, factory()->arguments_string(), GetStrictPoisonFunction()); |
693 SetAccessors(map, factory()->caller_string(), GetStrictPoisonFunction()); | 693 SetAccessors(map, factory()->caller_string(), GetStrictPoisonFunction()); |
694 } | 694 } |
695 | 695 |
696 | 696 |
697 static void AddToWeakNativeContextList(Context* context) { | 697 static void AddToWeakNativeContextList(Context* context) { |
698 ASSERT(context->IsNativeContext()); | 698 DCHECK(context->IsNativeContext()); |
699 Heap* heap = context->GetIsolate()->heap(); | 699 Heap* heap = context->GetIsolate()->heap(); |
700 #ifdef DEBUG | 700 #ifdef DEBUG |
701 { // NOLINT | 701 { // NOLINT |
702 ASSERT(context->get(Context::NEXT_CONTEXT_LINK)->IsUndefined()); | 702 DCHECK(context->get(Context::NEXT_CONTEXT_LINK)->IsUndefined()); |
703 // Check that context is not in the list yet. | 703 // Check that context is not in the list yet. |
704 for (Object* current = heap->native_contexts_list(); | 704 for (Object* current = heap->native_contexts_list(); |
705 !current->IsUndefined(); | 705 !current->IsUndefined(); |
706 current = Context::cast(current)->get(Context::NEXT_CONTEXT_LINK)) { | 706 current = Context::cast(current)->get(Context::NEXT_CONTEXT_LINK)) { |
707 ASSERT(current != context); | 707 DCHECK(current != context); |
708 } | 708 } |
709 } | 709 } |
710 #endif | 710 #endif |
711 context->set(Context::NEXT_CONTEXT_LINK, heap->native_contexts_list()); | 711 context->set(Context::NEXT_CONTEXT_LINK, heap->native_contexts_list()); |
712 heap->set_native_contexts_list(context); | 712 heap->set_native_contexts_list(context); |
713 } | 713 } |
714 | 714 |
715 | 715 |
716 void Genesis::CreateRoots() { | 716 void Genesis::CreateRoots() { |
717 // Allocate the native context FixedArray first and then patch the | 717 // Allocate the native context FixedArray first and then patch the |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin( | 770 Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin( |
771 Builtins::kIllegal)); | 771 Builtins::kIllegal)); |
772 Handle<JSObject> prototype = | 772 Handle<JSObject> prototype = |
773 factory()->NewFunctionPrototype(isolate()->object_function()); | 773 factory()->NewFunctionPrototype(isolate()->object_function()); |
774 js_global_object_function = factory()->NewFunction( | 774 js_global_object_function = factory()->NewFunction( |
775 name, code, prototype, JS_GLOBAL_OBJECT_TYPE, JSGlobalObject::kSize); | 775 name, code, prototype, JS_GLOBAL_OBJECT_TYPE, JSGlobalObject::kSize); |
776 #ifdef DEBUG | 776 #ifdef DEBUG |
777 LookupIterator it(prototype, factory()->constructor_string(), | 777 LookupIterator it(prototype, factory()->constructor_string(), |
778 LookupIterator::CHECK_OWN_REAL); | 778 LookupIterator::CHECK_OWN_REAL); |
779 Handle<Object> value = JSReceiver::GetProperty(&it).ToHandleChecked(); | 779 Handle<Object> value = JSReceiver::GetProperty(&it).ToHandleChecked(); |
780 ASSERT(it.IsFound()); | 780 DCHECK(it.IsFound()); |
781 ASSERT_EQ(*isolate()->object_function(), *value); | 781 DCHECK_EQ(*isolate()->object_function(), *value); |
782 #endif | 782 #endif |
783 } else { | 783 } else { |
784 Handle<FunctionTemplateInfo> js_global_object_constructor( | 784 Handle<FunctionTemplateInfo> js_global_object_constructor( |
785 FunctionTemplateInfo::cast(js_global_object_template->constructor())); | 785 FunctionTemplateInfo::cast(js_global_object_template->constructor())); |
786 js_global_object_function = | 786 js_global_object_function = |
787 factory()->CreateApiFunction(js_global_object_constructor, | 787 factory()->CreateApiFunction(js_global_object_constructor, |
788 factory()->the_hole_value(), | 788 factory()->the_hole_value(), |
789 factory()->GlobalObjectType); | 789 factory()->GlobalObjectType); |
790 } | 790 } |
791 | 791 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 array_function->shared()->set_function_data(Smi::FromInt(kArrayCode)); | 907 array_function->shared()->set_function_data(Smi::FromInt(kArrayCode)); |
908 | 908 |
909 // This seems a bit hackish, but we need to make sure Array.length | 909 // This seems a bit hackish, but we need to make sure Array.length |
910 // is 1. | 910 // is 1. |
911 array_function->shared()->set_length(1); | 911 array_function->shared()->set_length(1); |
912 | 912 |
913 Handle<Map> initial_map(array_function->initial_map()); | 913 Handle<Map> initial_map(array_function->initial_map()); |
914 | 914 |
915 // This assert protects an optimization in | 915 // This assert protects an optimization in |
916 // HGraphBuilder::JSArrayBuilder::EmitMapCode() | 916 // HGraphBuilder::JSArrayBuilder::EmitMapCode() |
917 ASSERT(initial_map->elements_kind() == GetInitialFastElementsKind()); | 917 DCHECK(initial_map->elements_kind() == GetInitialFastElementsKind()); |
918 Map::EnsureDescriptorSlack(initial_map, 1); | 918 Map::EnsureDescriptorSlack(initial_map, 1); |
919 | 919 |
920 PropertyAttributes attribs = static_cast<PropertyAttributes>( | 920 PropertyAttributes attribs = static_cast<PropertyAttributes>( |
921 DONT_ENUM | DONT_DELETE); | 921 DONT_ENUM | DONT_DELETE); |
922 | 922 |
923 Handle<AccessorInfo> array_length = | 923 Handle<AccessorInfo> array_length = |
924 Accessors::ArrayLengthInfo(isolate, attribs); | 924 Accessors::ArrayLengthInfo(isolate, attribs); |
925 { // Add length. | 925 { // Add length. |
926 CallbacksDescriptor d( | 926 CallbacksDescriptor d( |
927 Handle<Name>(Name::cast(array_length->name())), | 927 Handle<Name>(Name::cast(array_length->name())), |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 | 994 |
995 | 995 |
996 { // -- R e g E x p | 996 { // -- R e g E x p |
997 // Builtin functions for RegExp.prototype. | 997 // Builtin functions for RegExp.prototype. |
998 Handle<JSFunction> regexp_fun = | 998 Handle<JSFunction> regexp_fun = |
999 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, | 999 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, |
1000 isolate->initial_object_prototype(), | 1000 isolate->initial_object_prototype(), |
1001 Builtins::kIllegal); | 1001 Builtins::kIllegal); |
1002 native_context()->set_regexp_function(*regexp_fun); | 1002 native_context()->set_regexp_function(*regexp_fun); |
1003 | 1003 |
1004 ASSERT(regexp_fun->has_initial_map()); | 1004 DCHECK(regexp_fun->has_initial_map()); |
1005 Handle<Map> initial_map(regexp_fun->initial_map()); | 1005 Handle<Map> initial_map(regexp_fun->initial_map()); |
1006 | 1006 |
1007 ASSERT_EQ(0, initial_map->inobject_properties()); | 1007 DCHECK_EQ(0, initial_map->inobject_properties()); |
1008 | 1008 |
1009 PropertyAttributes final = | 1009 PropertyAttributes final = |
1010 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 1010 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
1011 Map::EnsureDescriptorSlack(initial_map, 5); | 1011 Map::EnsureDescriptorSlack(initial_map, 5); |
1012 | 1012 |
1013 { | 1013 { |
1014 // ECMA-262, section 15.10.7.1. | 1014 // ECMA-262, section 15.10.7.1. |
1015 FieldDescriptor field(factory->source_string(), | 1015 FieldDescriptor field(factory->source_string(), |
1016 JSRegExp::kSourceFieldIndex, | 1016 JSRegExp::kSourceFieldIndex, |
1017 final, | 1017 final, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 JSRegExp::Flags(0), 0); | 1081 JSRegExp::Flags(0), 0); |
1082 } | 1082 } |
1083 | 1083 |
1084 { // -- J S O N | 1084 { // -- J S O N |
1085 Handle<String> name = factory->InternalizeUtf8String("JSON"); | 1085 Handle<String> name = factory->InternalizeUtf8String("JSON"); |
1086 Handle<JSFunction> cons = factory->NewFunction(name); | 1086 Handle<JSFunction> cons = factory->NewFunction(name); |
1087 JSFunction::SetInstancePrototype(cons, | 1087 JSFunction::SetInstancePrototype(cons, |
1088 Handle<Object>(native_context()->initial_object_prototype(), isolate)); | 1088 Handle<Object>(native_context()->initial_object_prototype(), isolate)); |
1089 cons->SetInstanceClassName(*name); | 1089 cons->SetInstanceClassName(*name); |
1090 Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED); | 1090 Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED); |
1091 ASSERT(json_object->IsJSObject()); | 1091 DCHECK(json_object->IsJSObject()); |
1092 JSObject::AddProperty(global, name, json_object, DONT_ENUM); | 1092 JSObject::AddProperty(global, name, json_object, DONT_ENUM); |
1093 native_context()->set_json_object(*json_object); | 1093 native_context()->set_json_object(*json_object); |
1094 } | 1094 } |
1095 | 1095 |
1096 { // -- A r r a y B u f f e r | 1096 { // -- A r r a y B u f f e r |
1097 Handle<JSFunction> array_buffer_fun = | 1097 Handle<JSFunction> array_buffer_fun = |
1098 InstallFunction( | 1098 InstallFunction( |
1099 global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE, | 1099 global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE, |
1100 JSArrayBuffer::kSizeWithInternalFields, | 1100 JSArrayBuffer::kSizeWithInternalFields, |
1101 isolate->initial_object_prototype(), | 1101 isolate->initial_object_prototype(), |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 DONT_ENUM, Representation::Tagged()); | 1160 DONT_ENUM, Representation::Tagged()); |
1161 map->AppendDescriptor(&d); | 1161 map->AppendDescriptor(&d); |
1162 } | 1162 } |
1163 | 1163 |
1164 map->set_function_with_prototype(true); | 1164 map->set_function_with_prototype(true); |
1165 map->set_prototype(native_context()->object_function()->prototype()); | 1165 map->set_prototype(native_context()->object_function()->prototype()); |
1166 map->set_pre_allocated_property_fields(2); | 1166 map->set_pre_allocated_property_fields(2); |
1167 map->set_inobject_properties(2); | 1167 map->set_inobject_properties(2); |
1168 native_context()->set_sloppy_arguments_map(*map); | 1168 native_context()->set_sloppy_arguments_map(*map); |
1169 | 1169 |
1170 ASSERT(!function->has_initial_map()); | 1170 DCHECK(!function->has_initial_map()); |
1171 function->set_initial_map(*map); | 1171 function->set_initial_map(*map); |
1172 map->set_constructor(*function); | 1172 map->set_constructor(*function); |
1173 | 1173 |
1174 ASSERT(map->inobject_properties() > Heap::kArgumentsCalleeIndex); | 1174 DCHECK(map->inobject_properties() > Heap::kArgumentsCalleeIndex); |
1175 ASSERT(map->inobject_properties() > Heap::kArgumentsLengthIndex); | 1175 DCHECK(map->inobject_properties() > Heap::kArgumentsLengthIndex); |
1176 ASSERT(!map->is_dictionary_map()); | 1176 DCHECK(!map->is_dictionary_map()); |
1177 ASSERT(IsFastObjectElementsKind(map->elements_kind())); | 1177 DCHECK(IsFastObjectElementsKind(map->elements_kind())); |
1178 } | 1178 } |
1179 | 1179 |
1180 { // --- aliased arguments map | 1180 { // --- aliased arguments map |
1181 Handle<Map> map = Map::Copy(isolate->sloppy_arguments_map()); | 1181 Handle<Map> map = Map::Copy(isolate->sloppy_arguments_map()); |
1182 map->set_elements_kind(SLOPPY_ARGUMENTS_ELEMENTS); | 1182 map->set_elements_kind(SLOPPY_ARGUMENTS_ELEMENTS); |
1183 ASSERT_EQ(2, map->pre_allocated_property_fields()); | 1183 DCHECK_EQ(2, map->pre_allocated_property_fields()); |
1184 native_context()->set_aliased_arguments_map(*map); | 1184 native_context()->set_aliased_arguments_map(*map); |
1185 } | 1185 } |
1186 | 1186 |
1187 { // --- strict mode arguments map | 1187 { // --- strict mode arguments map |
1188 const PropertyAttributes attributes = | 1188 const PropertyAttributes attributes = |
1189 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 1189 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
1190 | 1190 |
1191 // Create the ThrowTypeError functions. | 1191 // Create the ThrowTypeError functions. |
1192 Handle<AccessorPair> callee = factory->NewAccessorPair(); | 1192 Handle<AccessorPair> callee = factory->NewAccessorPair(); |
1193 Handle<AccessorPair> caller = factory->NewAccessorPair(); | 1193 Handle<AccessorPair> caller = factory->NewAccessorPair(); |
(...skipping 30 matching lines...) Expand all Loading... |
1224 map->set_prototype(native_context()->object_function()->prototype()); | 1224 map->set_prototype(native_context()->object_function()->prototype()); |
1225 map->set_pre_allocated_property_fields(1); | 1225 map->set_pre_allocated_property_fields(1); |
1226 map->set_inobject_properties(1); | 1226 map->set_inobject_properties(1); |
1227 | 1227 |
1228 // Copy constructor from the sloppy arguments boilerplate. | 1228 // Copy constructor from the sloppy arguments boilerplate. |
1229 map->set_constructor( | 1229 map->set_constructor( |
1230 native_context()->sloppy_arguments_map()->constructor()); | 1230 native_context()->sloppy_arguments_map()->constructor()); |
1231 | 1231 |
1232 native_context()->set_strict_arguments_map(*map); | 1232 native_context()->set_strict_arguments_map(*map); |
1233 | 1233 |
1234 ASSERT(map->inobject_properties() > Heap::kArgumentsLengthIndex); | 1234 DCHECK(map->inobject_properties() > Heap::kArgumentsLengthIndex); |
1235 ASSERT(!map->is_dictionary_map()); | 1235 DCHECK(!map->is_dictionary_map()); |
1236 ASSERT(IsFastObjectElementsKind(map->elements_kind())); | 1236 DCHECK(IsFastObjectElementsKind(map->elements_kind())); |
1237 } | 1237 } |
1238 | 1238 |
1239 { // --- context extension | 1239 { // --- context extension |
1240 // Create a function for the context extension objects. | 1240 // Create a function for the context extension objects. |
1241 Handle<Code> code = Handle<Code>( | 1241 Handle<Code> code = Handle<Code>( |
1242 isolate->builtins()->builtin(Builtins::kIllegal)); | 1242 isolate->builtins()->builtin(Builtins::kIllegal)); |
1243 Handle<JSFunction> context_extension_fun = factory->NewFunction( | 1243 Handle<JSFunction> context_extension_fun = factory->NewFunction( |
1244 factory->empty_string(), code, JS_CONTEXT_EXTENSION_OBJECT_TYPE, | 1244 factory->empty_string(), code, JS_CONTEXT_EXTENSION_OBJECT_TYPE, |
1245 JSObject::kHeaderSize); | 1245 JSObject::kHeaderSize); |
1246 | 1246 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1406 native_context()->set_generator_object_prototype_map( | 1406 native_context()->set_generator_object_prototype_map( |
1407 *generator_object_prototype_map); | 1407 *generator_object_prototype_map); |
1408 } | 1408 } |
1409 | 1409 |
1410 if (FLAG_harmony_collections || FLAG_harmony_generators) { | 1410 if (FLAG_harmony_collections || FLAG_harmony_generators) { |
1411 // Collection forEach uses an iterator result object. | 1411 // Collection forEach uses an iterator result object. |
1412 // Generators return iteraror result objects. | 1412 // Generators return iteraror result objects. |
1413 | 1413 |
1414 STATIC_ASSERT(JSGeneratorObject::kResultPropertyCount == 2); | 1414 STATIC_ASSERT(JSGeneratorObject::kResultPropertyCount == 2); |
1415 Handle<JSFunction> object_function(native_context()->object_function()); | 1415 Handle<JSFunction> object_function(native_context()->object_function()); |
1416 ASSERT(object_function->initial_map()->inobject_properties() == 0); | 1416 DCHECK(object_function->initial_map()->inobject_properties() == 0); |
1417 Handle<Map> iterator_result_map = Map::Create( | 1417 Handle<Map> iterator_result_map = Map::Create( |
1418 object_function, JSGeneratorObject::kResultPropertyCount); | 1418 object_function, JSGeneratorObject::kResultPropertyCount); |
1419 ASSERT(iterator_result_map->inobject_properties() == | 1419 DCHECK(iterator_result_map->inobject_properties() == |
1420 JSGeneratorObject::kResultPropertyCount); | 1420 JSGeneratorObject::kResultPropertyCount); |
1421 Map::EnsureDescriptorSlack( | 1421 Map::EnsureDescriptorSlack( |
1422 iterator_result_map, JSGeneratorObject::kResultPropertyCount); | 1422 iterator_result_map, JSGeneratorObject::kResultPropertyCount); |
1423 | 1423 |
1424 FieldDescriptor value_descr(isolate()->factory()->value_string(), | 1424 FieldDescriptor value_descr(isolate()->factory()->value_string(), |
1425 JSGeneratorObject::kResultValuePropertyIndex, | 1425 JSGeneratorObject::kResultValuePropertyIndex, |
1426 NONE, | 1426 NONE, |
1427 Representation::Tagged()); | 1427 Representation::Tagged()); |
1428 iterator_result_map->AppendDescriptor(&value_descr); | 1428 iterator_result_map->AppendDescriptor(&value_descr); |
1429 | 1429 |
1430 FieldDescriptor done_descr(isolate()->factory()->done_string(), | 1430 FieldDescriptor done_descr(isolate()->factory()->done_string(), |
1431 JSGeneratorObject::kResultDonePropertyIndex, | 1431 JSGeneratorObject::kResultDonePropertyIndex, |
1432 NONE, | 1432 NONE, |
1433 Representation::Tagged()); | 1433 Representation::Tagged()); |
1434 iterator_result_map->AppendDescriptor(&done_descr); | 1434 iterator_result_map->AppendDescriptor(&done_descr); |
1435 | 1435 |
1436 iterator_result_map->set_unused_property_fields(0); | 1436 iterator_result_map->set_unused_property_fields(0); |
1437 ASSERT_EQ(JSGeneratorObject::kResultSize, | 1437 DCHECK_EQ(JSGeneratorObject::kResultSize, |
1438 iterator_result_map->instance_size()); | 1438 iterator_result_map->instance_size()); |
1439 native_context()->set_iterator_result_map(*iterator_result_map); | 1439 native_context()->set_iterator_result_map(*iterator_result_map); |
1440 } | 1440 } |
1441 } | 1441 } |
1442 | 1442 |
1443 | 1443 |
1444 bool Genesis::CompileBuiltin(Isolate* isolate, int index) { | 1444 bool Genesis::CompileBuiltin(Isolate* isolate, int index) { |
1445 Vector<const char> name = Natives::GetScriptName(index); | 1445 Vector<const char> name = Natives::GetScriptName(index); |
1446 Handle<String> source_code = | 1446 Handle<String> source_code = |
1447 isolate->bootstrapper()->NativesSourceLookup(index); | 1447 isolate->bootstrapper()->NativesSourceLookup(index); |
(...skipping 25 matching lines...) Expand all Loading... |
1473 StackLimitCheck check(isolate); | 1473 StackLimitCheck check(isolate); |
1474 if (check.HasOverflowed()) return false; | 1474 if (check.HasOverflowed()) return false; |
1475 | 1475 |
1476 bool result = CompileScriptCached(isolate, | 1476 bool result = CompileScriptCached(isolate, |
1477 name, | 1477 name, |
1478 source, | 1478 source, |
1479 NULL, | 1479 NULL, |
1480 NULL, | 1480 NULL, |
1481 Handle<Context>(isolate->context()), | 1481 Handle<Context>(isolate->context()), |
1482 true); | 1482 true); |
1483 ASSERT(isolate->has_pending_exception() != result); | 1483 DCHECK(isolate->has_pending_exception() != result); |
1484 if (!result) isolate->clear_pending_exception(); | 1484 if (!result) isolate->clear_pending_exception(); |
1485 return result; | 1485 return result; |
1486 } | 1486 } |
1487 | 1487 |
1488 | 1488 |
1489 bool Genesis::CompileScriptCached(Isolate* isolate, | 1489 bool Genesis::CompileScriptCached(Isolate* isolate, |
1490 Vector<const char> name, | 1490 Vector<const char> name, |
1491 Handle<String> source, | 1491 Handle<String> source, |
1492 SourceCodeCache* cache, | 1492 SourceCodeCache* cache, |
1493 v8::Extension* extension, | 1493 v8::Extension* extension, |
1494 Handle<Context> top_context, | 1494 Handle<Context> top_context, |
1495 bool use_runtime_context) { | 1495 bool use_runtime_context) { |
1496 Factory* factory = isolate->factory(); | 1496 Factory* factory = isolate->factory(); |
1497 HandleScope scope(isolate); | 1497 HandleScope scope(isolate); |
1498 Handle<SharedFunctionInfo> function_info; | 1498 Handle<SharedFunctionInfo> function_info; |
1499 | 1499 |
1500 // If we can't find the function in the cache, we compile a new | 1500 // If we can't find the function in the cache, we compile a new |
1501 // function and insert it into the cache. | 1501 // function and insert it into the cache. |
1502 if (cache == NULL || !cache->Lookup(name, &function_info)) { | 1502 if (cache == NULL || !cache->Lookup(name, &function_info)) { |
1503 ASSERT(source->IsOneByteRepresentation()); | 1503 DCHECK(source->IsOneByteRepresentation()); |
1504 Handle<String> script_name = | 1504 Handle<String> script_name = |
1505 factory->NewStringFromUtf8(name).ToHandleChecked(); | 1505 factory->NewStringFromUtf8(name).ToHandleChecked(); |
1506 function_info = Compiler::CompileScript( | 1506 function_info = Compiler::CompileScript( |
1507 source, script_name, 0, 0, false, top_context, extension, NULL, | 1507 source, script_name, 0, 0, false, top_context, extension, NULL, |
1508 ScriptCompiler::kNoCompileOptions, | 1508 ScriptCompiler::kNoCompileOptions, |
1509 use_runtime_context ? NATIVES_CODE : NOT_NATIVES_CODE); | 1509 use_runtime_context ? NATIVES_CODE : NOT_NATIVES_CODE); |
1510 if (function_info.is_null()) return false; | 1510 if (function_info.is_null()) return false; |
1511 if (cache != NULL) cache->Add(name, function_info); | 1511 if (cache != NULL) cache->Add(name, function_info); |
1512 } | 1512 } |
1513 | 1513 |
1514 // Set up the function context. Conceptually, we should clone the | 1514 // Set up the function context. Conceptually, we should clone the |
1515 // function before overwriting the context but since we're in a | 1515 // function before overwriting the context but since we're in a |
1516 // single-threaded environment it is not strictly necessary. | 1516 // single-threaded environment it is not strictly necessary. |
1517 ASSERT(top_context->IsNativeContext()); | 1517 DCHECK(top_context->IsNativeContext()); |
1518 Handle<Context> context = | 1518 Handle<Context> context = |
1519 Handle<Context>(use_runtime_context | 1519 Handle<Context>(use_runtime_context |
1520 ? Handle<Context>(top_context->runtime_context()) | 1520 ? Handle<Context>(top_context->runtime_context()) |
1521 : top_context); | 1521 : top_context); |
1522 Handle<JSFunction> fun = | 1522 Handle<JSFunction> fun = |
1523 factory->NewFunctionFromSharedFunctionInfo(function_info, context); | 1523 factory->NewFunctionFromSharedFunctionInfo(function_info, context); |
1524 | 1524 |
1525 // Call function using either the runtime object or the global | 1525 // Call function using either the runtime object or the global |
1526 // object as the receiver. Provide no parameters. | 1526 // object as the receiver. Provide no parameters. |
1527 Handle<Object> receiver = | 1527 Handle<Object> receiver = |
(...skipping 12 matching lines...) Expand all Loading... |
1540 Factory* factory = isolate->factory(); | 1540 Factory* factory = isolate->factory(); |
1541 Handle<GlobalObject> global(native_context->global_object()); | 1541 Handle<GlobalObject> global(native_context->global_object()); |
1542 const char* period_pos = strchr(holder_expr, '.'); | 1542 const char* period_pos = strchr(holder_expr, '.'); |
1543 if (period_pos == NULL) { | 1543 if (period_pos == NULL) { |
1544 return Handle<JSObject>::cast( | 1544 return Handle<JSObject>::cast( |
1545 Object::GetPropertyOrElement( | 1545 Object::GetPropertyOrElement( |
1546 global, factory->InternalizeUtf8String(holder_expr)) | 1546 global, factory->InternalizeUtf8String(holder_expr)) |
1547 .ToHandleChecked()); | 1547 .ToHandleChecked()); |
1548 } | 1548 } |
1549 const char* inner = period_pos + 1; | 1549 const char* inner = period_pos + 1; |
1550 ASSERT_EQ(NULL, strchr(inner, '.')); | 1550 DCHECK_EQ(NULL, strchr(inner, '.')); |
1551 Vector<const char> property(holder_expr, | 1551 Vector<const char> property(holder_expr, |
1552 static_cast<int>(period_pos - holder_expr)); | 1552 static_cast<int>(period_pos - holder_expr)); |
1553 Handle<String> property_string = factory->InternalizeUtf8String(property); | 1553 Handle<String> property_string = factory->InternalizeUtf8String(property); |
1554 ASSERT(!property_string.is_null()); | 1554 DCHECK(!property_string.is_null()); |
1555 Handle<JSObject> object = Handle<JSObject>::cast( | 1555 Handle<JSObject> object = Handle<JSObject>::cast( |
1556 Object::GetProperty(global, property_string).ToHandleChecked()); | 1556 Object::GetProperty(global, property_string).ToHandleChecked()); |
1557 if (strcmp("prototype", inner) == 0) { | 1557 if (strcmp("prototype", inner) == 0) { |
1558 Handle<JSFunction> function = Handle<JSFunction>::cast(object); | 1558 Handle<JSFunction> function = Handle<JSFunction>::cast(object); |
1559 return Handle<JSObject>(JSObject::cast(function->prototype())); | 1559 return Handle<JSObject>(JSObject::cast(function->prototype())); |
1560 } | 1560 } |
1561 Handle<String> inner_string = factory->InternalizeUtf8String(inner); | 1561 Handle<String> inner_string = factory->InternalizeUtf8String(inner); |
1562 ASSERT(!inner_string.is_null()); | 1562 DCHECK(!inner_string.is_null()); |
1563 Handle<Object> value = | 1563 Handle<Object> value = |
1564 Object::GetProperty(object, inner_string).ToHandleChecked(); | 1564 Object::GetProperty(object, inner_string).ToHandleChecked(); |
1565 return Handle<JSObject>::cast(value); | 1565 return Handle<JSObject>::cast(value); |
1566 } | 1566 } |
1567 | 1567 |
1568 | 1568 |
1569 #define INSTALL_NATIVE(Type, name, var) \ | 1569 #define INSTALL_NATIVE(Type, name, var) \ |
1570 Handle<String> var##_name = \ | 1570 Handle<String> var##_name = \ |
1571 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR(name)); \ | 1571 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR(name)); \ |
1572 Handle<Object> var##_native = Object::GetProperty( \ | 1572 Handle<Object> var##_native = Object::GetProperty( \ |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1744 Handle<String> builtins_string = | 1744 Handle<String> builtins_string = |
1745 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("builtins")); | 1745 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("builtins")); |
1746 JSObject::AddProperty(builtins, builtins_string, builtins, attributes); | 1746 JSObject::AddProperty(builtins, builtins_string, builtins, attributes); |
1747 | 1747 |
1748 // Set up the reference from the global object to the builtins object. | 1748 // Set up the reference from the global object to the builtins object. |
1749 JSGlobalObject::cast(native_context()->global_object())-> | 1749 JSGlobalObject::cast(native_context()->global_object())-> |
1750 set_builtins(*builtins); | 1750 set_builtins(*builtins); |
1751 | 1751 |
1752 // Create a bridge function that has context in the native context. | 1752 // Create a bridge function that has context in the native context. |
1753 Handle<JSFunction> bridge = factory()->NewFunction(factory()->empty_string()); | 1753 Handle<JSFunction> bridge = factory()->NewFunction(factory()->empty_string()); |
1754 ASSERT(bridge->context() == *isolate()->native_context()); | 1754 DCHECK(bridge->context() == *isolate()->native_context()); |
1755 | 1755 |
1756 // Allocate the builtins context. | 1756 // Allocate the builtins context. |
1757 Handle<Context> context = | 1757 Handle<Context> context = |
1758 factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge); | 1758 factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge); |
1759 context->set_global_object(*builtins); // override builtins global object | 1759 context->set_global_object(*builtins); // override builtins global object |
1760 | 1760 |
1761 native_context()->set_runtime_context(*context); | 1761 native_context()->set_runtime_context(*context); |
1762 | 1762 |
1763 { // -- S c r i p t | 1763 { // -- S c r i p t |
1764 // Builtin functions for Script. | 1764 // Builtin functions for Script. |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1942 // functions on the builtins object after compiling and running | 1942 // functions on the builtins object after compiling and running |
1943 // runtime.js. | 1943 // runtime.js. |
1944 if (!InstallJSBuiltins(builtins)) return false; | 1944 if (!InstallJSBuiltins(builtins)) return false; |
1945 } | 1945 } |
1946 | 1946 |
1947 InstallNativeFunctions(); | 1947 InstallNativeFunctions(); |
1948 | 1948 |
1949 // Store the map for the string prototype after the natives has been compiled | 1949 // Store the map for the string prototype after the natives has been compiled |
1950 // and the String function has been set up. | 1950 // and the String function has been set up. |
1951 Handle<JSFunction> string_function(native_context()->string_function()); | 1951 Handle<JSFunction> string_function(native_context()->string_function()); |
1952 ASSERT(JSObject::cast( | 1952 DCHECK(JSObject::cast( |
1953 string_function->initial_map()->prototype())->HasFastProperties()); | 1953 string_function->initial_map()->prototype())->HasFastProperties()); |
1954 native_context()->set_string_function_prototype_map( | 1954 native_context()->set_string_function_prototype_map( |
1955 HeapObject::cast(string_function->initial_map()->prototype())->map()); | 1955 HeapObject::cast(string_function->initial_map()->prototype())->map()); |
1956 | 1956 |
1957 // Install Function.prototype.call and apply. | 1957 // Install Function.prototype.call and apply. |
1958 { Handle<String> key = factory()->function_class_string(); | 1958 { Handle<String> key = factory()->function_class_string(); |
1959 Handle<JSFunction> function = | 1959 Handle<JSFunction> function = |
1960 Handle<JSFunction>::cast(Object::GetProperty( | 1960 Handle<JSFunction>::cast(Object::GetProperty( |
1961 handle(native_context()->global_object()), key).ToHandleChecked()); | 1961 handle(native_context()->global_object()), key).ToHandleChecked()); |
1962 Handle<JSObject> proto = | 1962 Handle<JSObject> proto = |
(...skipping 10 matching lines...) Expand all Loading... |
1973 // Apply embeds an IC, so we need a type vector of size 1 in the shared | 1973 // Apply embeds an IC, so we need a type vector of size 1 in the shared |
1974 // function info. | 1974 // function info. |
1975 Handle<FixedArray> feedback_vector = factory()->NewTypeFeedbackVector(1); | 1975 Handle<FixedArray> feedback_vector = factory()->NewTypeFeedbackVector(1); |
1976 apply->shared()->set_feedback_vector(*feedback_vector); | 1976 apply->shared()->set_feedback_vector(*feedback_vector); |
1977 } | 1977 } |
1978 | 1978 |
1979 // Make sure that Function.prototype.call appears to be compiled. | 1979 // Make sure that Function.prototype.call appears to be compiled. |
1980 // The code will never be called, but inline caching for call will | 1980 // The code will never be called, but inline caching for call will |
1981 // only work if it appears to be compiled. | 1981 // only work if it appears to be compiled. |
1982 call->shared()->DontAdaptArguments(); | 1982 call->shared()->DontAdaptArguments(); |
1983 ASSERT(call->is_compiled()); | 1983 DCHECK(call->is_compiled()); |
1984 | 1984 |
1985 // Set the expected parameters for apply to 2; required by builtin. | 1985 // Set the expected parameters for apply to 2; required by builtin. |
1986 apply->shared()->set_formal_parameter_count(2); | 1986 apply->shared()->set_formal_parameter_count(2); |
1987 | 1987 |
1988 // Set the lengths for the functions to satisfy ECMA-262. | 1988 // Set the lengths for the functions to satisfy ECMA-262. |
1989 call->shared()->set_length(1); | 1989 call->shared()->set_length(1); |
1990 apply->shared()->set_length(2); | 1990 apply->shared()->set_length(2); |
1991 } | 1991 } |
1992 | 1992 |
1993 InstallBuiltinFunctionIds(); | 1993 InstallBuiltinFunctionIds(); |
(...skipping 20 matching lines...) Expand all Loading... |
2014 // Update map with length accessor from Array and add "index" and "input". | 2014 // Update map with length accessor from Array and add "index" and "input". |
2015 Map::EnsureDescriptorSlack(initial_map, 3); | 2015 Map::EnsureDescriptorSlack(initial_map, 3); |
2016 | 2016 |
2017 { | 2017 { |
2018 JSFunction* array_function = native_context()->array_function(); | 2018 JSFunction* array_function = native_context()->array_function(); |
2019 Handle<DescriptorArray> array_descriptors( | 2019 Handle<DescriptorArray> array_descriptors( |
2020 array_function->initial_map()->instance_descriptors()); | 2020 array_function->initial_map()->instance_descriptors()); |
2021 Handle<String> length = factory()->length_string(); | 2021 Handle<String> length = factory()->length_string(); |
2022 int old = array_descriptors->SearchWithCache( | 2022 int old = array_descriptors->SearchWithCache( |
2023 *length, array_function->initial_map()); | 2023 *length, array_function->initial_map()); |
2024 ASSERT(old != DescriptorArray::kNotFound); | 2024 DCHECK(old != DescriptorArray::kNotFound); |
2025 CallbacksDescriptor desc(length, | 2025 CallbacksDescriptor desc(length, |
2026 handle(array_descriptors->GetValue(old), | 2026 handle(array_descriptors->GetValue(old), |
2027 isolate()), | 2027 isolate()), |
2028 array_descriptors->GetDetails(old).attributes()); | 2028 array_descriptors->GetDetails(old).attributes()); |
2029 initial_map->AppendDescriptor(&desc); | 2029 initial_map->AppendDescriptor(&desc); |
2030 } | 2030 } |
2031 { | 2031 { |
2032 FieldDescriptor index_field(factory()->index_string(), | 2032 FieldDescriptor index_field(factory()->index_string(), |
2033 JSRegExpResult::kIndexIndex, | 2033 JSRegExpResult::kIndexIndex, |
2034 NONE, | 2034 NONE, |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2319 HandleScope scope(isolate); | 2319 HandleScope scope(isolate); |
2320 | 2320 |
2321 if (extension_states->get_state(current) == INSTALLED) return true; | 2321 if (extension_states->get_state(current) == INSTALLED) return true; |
2322 // The current node has already been visited so there must be a | 2322 // The current node has already been visited so there must be a |
2323 // cycle in the dependency graph; fail. | 2323 // cycle in the dependency graph; fail. |
2324 if (!Utils::ApiCheck(extension_states->get_state(current) != VISITED, | 2324 if (!Utils::ApiCheck(extension_states->get_state(current) != VISITED, |
2325 "v8::Context::New()", | 2325 "v8::Context::New()", |
2326 "Circular extension dependency")) { | 2326 "Circular extension dependency")) { |
2327 return false; | 2327 return false; |
2328 } | 2328 } |
2329 ASSERT(extension_states->get_state(current) == UNVISITED); | 2329 DCHECK(extension_states->get_state(current) == UNVISITED); |
2330 extension_states->set_state(current, VISITED); | 2330 extension_states->set_state(current, VISITED); |
2331 v8::Extension* extension = current->extension(); | 2331 v8::Extension* extension = current->extension(); |
2332 // Install the extension's dependencies | 2332 // Install the extension's dependencies |
2333 for (int i = 0; i < extension->dependency_count(); i++) { | 2333 for (int i = 0; i < extension->dependency_count(); i++) { |
2334 if (!InstallExtension(isolate, | 2334 if (!InstallExtension(isolate, |
2335 extension->dependencies()[i], | 2335 extension->dependencies()[i], |
2336 extension_states)) { | 2336 extension_states)) { |
2337 return false; | 2337 return false; |
2338 } | 2338 } |
2339 } | 2339 } |
2340 // We do not expect this to throw an exception. Change this if it does. | 2340 // We do not expect this to throw an exception. Change this if it does. |
2341 Handle<String> source_code = | 2341 Handle<String> source_code = |
2342 isolate->factory()->NewExternalStringFromAscii( | 2342 isolate->factory()->NewExternalStringFromAscii( |
2343 extension->source()).ToHandleChecked(); | 2343 extension->source()).ToHandleChecked(); |
2344 bool result = CompileScriptCached(isolate, | 2344 bool result = CompileScriptCached(isolate, |
2345 CStrVector(extension->name()), | 2345 CStrVector(extension->name()), |
2346 source_code, | 2346 source_code, |
2347 isolate->bootstrapper()->extensions_cache(), | 2347 isolate->bootstrapper()->extensions_cache(), |
2348 extension, | 2348 extension, |
2349 Handle<Context>(isolate->context()), | 2349 Handle<Context>(isolate->context()), |
2350 false); | 2350 false); |
2351 ASSERT(isolate->has_pending_exception() != result); | 2351 DCHECK(isolate->has_pending_exception() != result); |
2352 if (!result) { | 2352 if (!result) { |
2353 // We print out the name of the extension that fail to install. | 2353 // We print out the name of the extension that fail to install. |
2354 // When an error is thrown during bootstrapping we automatically print | 2354 // When an error is thrown during bootstrapping we automatically print |
2355 // the line number at which this happened to the console in the isolate | 2355 // the line number at which this happened to the console in the isolate |
2356 // error throwing functionality. | 2356 // error throwing functionality. |
2357 base::OS::PrintError("Error installing extension '%s'.\n", | 2357 base::OS::PrintError("Error installing extension '%s'.\n", |
2358 current->extension()->name()); | 2358 current->extension()->name()); |
2359 isolate->clear_pending_exception(); | 2359 isolate->clear_pending_exception(); |
2360 } | 2360 } |
2361 extension_states->set_state(current, INSTALLED); | 2361 extension_states->set_state(current, INSTALLED); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2412 | 2412 |
2413 native_context()->set_initial_array_prototype( | 2413 native_context()->set_initial_array_prototype( |
2414 JSArray::cast(native_context()->array_function()->prototype())); | 2414 JSArray::cast(native_context()->array_function()->prototype())); |
2415 | 2415 |
2416 return true; | 2416 return true; |
2417 } | 2417 } |
2418 | 2418 |
2419 | 2419 |
2420 bool Genesis::ConfigureApiObject(Handle<JSObject> object, | 2420 bool Genesis::ConfigureApiObject(Handle<JSObject> object, |
2421 Handle<ObjectTemplateInfo> object_template) { | 2421 Handle<ObjectTemplateInfo> object_template) { |
2422 ASSERT(!object_template.is_null()); | 2422 DCHECK(!object_template.is_null()); |
2423 ASSERT(FunctionTemplateInfo::cast(object_template->constructor()) | 2423 DCHECK(FunctionTemplateInfo::cast(object_template->constructor()) |
2424 ->IsTemplateFor(object->map()));; | 2424 ->IsTemplateFor(object->map()));; |
2425 | 2425 |
2426 MaybeHandle<JSObject> maybe_obj = | 2426 MaybeHandle<JSObject> maybe_obj = |
2427 Execution::InstantiateObject(object_template); | 2427 Execution::InstantiateObject(object_template); |
2428 Handle<JSObject> obj; | 2428 Handle<JSObject> obj; |
2429 if (!maybe_obj.ToHandle(&obj)) { | 2429 if (!maybe_obj.ToHandle(&obj)) { |
2430 ASSERT(isolate()->has_pending_exception()); | 2430 DCHECK(isolate()->has_pending_exception()); |
2431 isolate()->clear_pending_exception(); | 2431 isolate()->clear_pending_exception(); |
2432 return false; | 2432 return false; |
2433 } | 2433 } |
2434 TransferObject(obj, object); | 2434 TransferObject(obj, object); |
2435 return true; | 2435 return true; |
2436 } | 2436 } |
2437 | 2437 |
2438 | 2438 |
2439 void Genesis::TransferNamedProperties(Handle<JSObject> from, | 2439 void Genesis::TransferNamedProperties(Handle<JSObject> from, |
2440 Handle<JSObject> to) { | 2440 Handle<JSObject> to) { |
2441 if (from->HasFastProperties()) { | 2441 if (from->HasFastProperties()) { |
2442 Handle<DescriptorArray> descs = | 2442 Handle<DescriptorArray> descs = |
2443 Handle<DescriptorArray>(from->map()->instance_descriptors()); | 2443 Handle<DescriptorArray>(from->map()->instance_descriptors()); |
2444 for (int i = 0; i < from->map()->NumberOfOwnDescriptors(); i++) { | 2444 for (int i = 0; i < from->map()->NumberOfOwnDescriptors(); i++) { |
2445 PropertyDetails details = descs->GetDetails(i); | 2445 PropertyDetails details = descs->GetDetails(i); |
2446 switch (details.type()) { | 2446 switch (details.type()) { |
2447 case FIELD: { | 2447 case FIELD: { |
2448 HandleScope inner(isolate()); | 2448 HandleScope inner(isolate()); |
2449 Handle<Name> key = Handle<Name>(descs->GetKey(i)); | 2449 Handle<Name> key = Handle<Name>(descs->GetKey(i)); |
2450 FieldIndex index = FieldIndex::ForDescriptor(from->map(), i); | 2450 FieldIndex index = FieldIndex::ForDescriptor(from->map(), i); |
2451 ASSERT(!descs->GetDetails(i).representation().IsDouble()); | 2451 DCHECK(!descs->GetDetails(i).representation().IsDouble()); |
2452 Handle<Object> value = Handle<Object>(from->RawFastPropertyAt(index), | 2452 Handle<Object> value = Handle<Object>(from->RawFastPropertyAt(index), |
2453 isolate()); | 2453 isolate()); |
2454 JSObject::AddProperty(to, key, value, details.attributes()); | 2454 JSObject::AddProperty(to, key, value, details.attributes()); |
2455 break; | 2455 break; |
2456 } | 2456 } |
2457 case CONSTANT: { | 2457 case CONSTANT: { |
2458 HandleScope inner(isolate()); | 2458 HandleScope inner(isolate()); |
2459 Handle<Name> key = Handle<Name>(descs->GetKey(i)); | 2459 Handle<Name> key = Handle<Name>(descs->GetKey(i)); |
2460 Handle<Object> constant(descs->GetConstant(i), isolate()); | 2460 Handle<Object> constant(descs->GetConstant(i), isolate()); |
2461 JSObject::AddProperty(to, key, constant, details.attributes()); | 2461 JSObject::AddProperty(to, key, constant, details.attributes()); |
2462 break; | 2462 break; |
2463 } | 2463 } |
2464 case CALLBACKS: { | 2464 case CALLBACKS: { |
2465 LookupResult result(isolate()); | 2465 LookupResult result(isolate()); |
2466 Handle<Name> key(Name::cast(descs->GetKey(i)), isolate()); | 2466 Handle<Name> key(Name::cast(descs->GetKey(i)), isolate()); |
2467 to->LookupOwn(key, &result); | 2467 to->LookupOwn(key, &result); |
2468 // If the property is already there we skip it | 2468 // If the property is already there we skip it |
2469 if (result.IsFound()) continue; | 2469 if (result.IsFound()) continue; |
2470 HandleScope inner(isolate()); | 2470 HandleScope inner(isolate()); |
2471 ASSERT(!to->HasFastProperties()); | 2471 DCHECK(!to->HasFastProperties()); |
2472 // Add to dictionary. | 2472 // Add to dictionary. |
2473 Handle<Object> callbacks(descs->GetCallbacksObject(i), isolate()); | 2473 Handle<Object> callbacks(descs->GetCallbacksObject(i), isolate()); |
2474 PropertyDetails d = PropertyDetails( | 2474 PropertyDetails d = PropertyDetails( |
2475 details.attributes(), CALLBACKS, i + 1); | 2475 details.attributes(), CALLBACKS, i + 1); |
2476 JSObject::SetNormalizedProperty(to, key, callbacks, d); | 2476 JSObject::SetNormalizedProperty(to, key, callbacks, d); |
2477 break; | 2477 break; |
2478 } | 2478 } |
2479 case NORMAL: | 2479 case NORMAL: |
2480 // Do not occur since the from object has fast properties. | 2480 // Do not occur since the from object has fast properties. |
2481 case HANDLER: | 2481 case HANDLER: |
2482 case INTERCEPTOR: | 2482 case INTERCEPTOR: |
2483 case NONEXISTENT: | 2483 case NONEXISTENT: |
2484 // No element in instance descriptors have proxy or interceptor type. | 2484 // No element in instance descriptors have proxy or interceptor type. |
2485 UNREACHABLE(); | 2485 UNREACHABLE(); |
2486 break; | 2486 break; |
2487 } | 2487 } |
2488 } | 2488 } |
2489 } else { | 2489 } else { |
2490 Handle<NameDictionary> properties = | 2490 Handle<NameDictionary> properties = |
2491 Handle<NameDictionary>(from->property_dictionary()); | 2491 Handle<NameDictionary>(from->property_dictionary()); |
2492 int capacity = properties->Capacity(); | 2492 int capacity = properties->Capacity(); |
2493 for (int i = 0; i < capacity; i++) { | 2493 for (int i = 0; i < capacity; i++) { |
2494 Object* raw_key(properties->KeyAt(i)); | 2494 Object* raw_key(properties->KeyAt(i)); |
2495 if (properties->IsKey(raw_key)) { | 2495 if (properties->IsKey(raw_key)) { |
2496 ASSERT(raw_key->IsName()); | 2496 DCHECK(raw_key->IsName()); |
2497 // If the property is already there we skip it. | 2497 // If the property is already there we skip it. |
2498 LookupResult result(isolate()); | 2498 LookupResult result(isolate()); |
2499 Handle<Name> key(Name::cast(raw_key)); | 2499 Handle<Name> key(Name::cast(raw_key)); |
2500 to->LookupOwn(key, &result); | 2500 to->LookupOwn(key, &result); |
2501 if (result.IsFound()) continue; | 2501 if (result.IsFound()) continue; |
2502 // Set the property. | 2502 // Set the property. |
2503 Handle<Object> value = Handle<Object>(properties->ValueAt(i), | 2503 Handle<Object> value = Handle<Object>(properties->ValueAt(i), |
2504 isolate()); | 2504 isolate()); |
2505 ASSERT(!value->IsCell()); | 2505 DCHECK(!value->IsCell()); |
2506 if (value->IsPropertyCell()) { | 2506 if (value->IsPropertyCell()) { |
2507 value = Handle<Object>(PropertyCell::cast(*value)->value(), | 2507 value = Handle<Object>(PropertyCell::cast(*value)->value(), |
2508 isolate()); | 2508 isolate()); |
2509 } | 2509 } |
2510 PropertyDetails details = properties->DetailsAt(i); | 2510 PropertyDetails details = properties->DetailsAt(i); |
2511 JSObject::AddProperty(to, key, value, details.attributes()); | 2511 JSObject::AddProperty(to, key, value, details.attributes()); |
2512 } | 2512 } |
2513 } | 2513 } |
2514 } | 2514 } |
2515 } | 2515 } |
2516 | 2516 |
2517 | 2517 |
2518 void Genesis::TransferIndexedProperties(Handle<JSObject> from, | 2518 void Genesis::TransferIndexedProperties(Handle<JSObject> from, |
2519 Handle<JSObject> to) { | 2519 Handle<JSObject> to) { |
2520 // Cloning the elements array is sufficient. | 2520 // Cloning the elements array is sufficient. |
2521 Handle<FixedArray> from_elements = | 2521 Handle<FixedArray> from_elements = |
2522 Handle<FixedArray>(FixedArray::cast(from->elements())); | 2522 Handle<FixedArray>(FixedArray::cast(from->elements())); |
2523 Handle<FixedArray> to_elements = factory()->CopyFixedArray(from_elements); | 2523 Handle<FixedArray> to_elements = factory()->CopyFixedArray(from_elements); |
2524 to->set_elements(*to_elements); | 2524 to->set_elements(*to_elements); |
2525 } | 2525 } |
2526 | 2526 |
2527 | 2527 |
2528 void Genesis::TransferObject(Handle<JSObject> from, Handle<JSObject> to) { | 2528 void Genesis::TransferObject(Handle<JSObject> from, Handle<JSObject> to) { |
2529 HandleScope outer(isolate()); | 2529 HandleScope outer(isolate()); |
2530 | 2530 |
2531 ASSERT(!from->IsJSArray()); | 2531 DCHECK(!from->IsJSArray()); |
2532 ASSERT(!to->IsJSArray()); | 2532 DCHECK(!to->IsJSArray()); |
2533 | 2533 |
2534 TransferNamedProperties(from, to); | 2534 TransferNamedProperties(from, to); |
2535 TransferIndexedProperties(from, to); | 2535 TransferIndexedProperties(from, to); |
2536 | 2536 |
2537 // Transfer the prototype (new map is needed). | 2537 // Transfer the prototype (new map is needed). |
2538 Handle<Object> proto(from->map()->prototype(), isolate()); | 2538 Handle<Object> proto(from->map()->prototype(), isolate()); |
2539 SetObjectPrototype(to, proto); | 2539 SetObjectPrototype(to, proto); |
2540 } | 2540 } |
2541 | 2541 |
2542 | 2542 |
2543 void Genesis::MakeFunctionInstancePrototypeWritable() { | 2543 void Genesis::MakeFunctionInstancePrototypeWritable() { |
2544 // The maps with writable prototype are created in CreateEmptyFunction | 2544 // The maps with writable prototype are created in CreateEmptyFunction |
2545 // and CreateStrictModeFunctionMaps respectively. Initially the maps are | 2545 // and CreateStrictModeFunctionMaps respectively. Initially the maps are |
2546 // created with read-only prototype for JS builtins processing. | 2546 // created with read-only prototype for JS builtins processing. |
2547 ASSERT(!sloppy_function_map_writable_prototype_.is_null()); | 2547 DCHECK(!sloppy_function_map_writable_prototype_.is_null()); |
2548 ASSERT(!strict_function_map_writable_prototype_.is_null()); | 2548 DCHECK(!strict_function_map_writable_prototype_.is_null()); |
2549 | 2549 |
2550 // Replace function instance maps to make prototype writable. | 2550 // Replace function instance maps to make prototype writable. |
2551 native_context()->set_sloppy_function_map( | 2551 native_context()->set_sloppy_function_map( |
2552 *sloppy_function_map_writable_prototype_); | 2552 *sloppy_function_map_writable_prototype_); |
2553 native_context()->set_strict_function_map( | 2553 native_context()->set_strict_function_map( |
2554 *strict_function_map_writable_prototype_); | 2554 *strict_function_map_writable_prototype_); |
2555 } | 2555 } |
2556 | 2556 |
2557 | 2557 |
2558 class NoTrackDoubleFieldsForSerializerScope { | 2558 class NoTrackDoubleFieldsForSerializerScope { |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2729 | 2729 |
2730 // Restore statics that are thread-local. | 2730 // Restore statics that are thread-local. |
2731 char* Bootstrapper::RestoreState(char* from) { | 2731 char* Bootstrapper::RestoreState(char* from) { |
2732 nesting_ = *reinterpret_cast<NestingCounterType*>(from); | 2732 nesting_ = *reinterpret_cast<NestingCounterType*>(from); |
2733 return from + sizeof(NestingCounterType); | 2733 return from + sizeof(NestingCounterType); |
2734 } | 2734 } |
2735 | 2735 |
2736 | 2736 |
2737 // Called when the top-level V8 mutex is destroyed. | 2737 // Called when the top-level V8 mutex is destroyed. |
2738 void Bootstrapper::FreeThreadResources() { | 2738 void Bootstrapper::FreeThreadResources() { |
2739 ASSERT(!IsActive()); | 2739 DCHECK(!IsActive()); |
2740 } | 2740 } |
2741 | 2741 |
2742 } } // namespace v8::internal | 2742 } } // namespace v8::internal |
OLD | NEW |