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/api-natives.h" | 8 #include "src/api-natives.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/extensions/externalize-string-extension.h" | 10 #include "src/extensions/externalize-string-extension.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 Bootstrapper::Bootstrapper(Isolate* isolate) | 25 Bootstrapper::Bootstrapper(Isolate* isolate) |
26 : isolate_(isolate), | 26 : isolate_(isolate), |
27 nesting_(0), | 27 nesting_(0), |
28 extensions_cache_(Script::TYPE_EXTENSION) {} | 28 extensions_cache_(Script::TYPE_EXTENSION) {} |
29 | 29 |
30 template <class Source> | 30 template <class Source> |
31 Handle<String> Bootstrapper::SourceLookup(int index) { | 31 Handle<String> Bootstrapper::SourceLookup(int index) { |
32 DCHECK(0 <= index && index < Source::GetBuiltinsCount()); | 32 DCHECK(0 <= index && index < Source::GetBuiltinsCount()); |
33 Heap* heap = isolate_->heap(); | 33 Heap* heap = isolate_->heap(); |
34 if (Source::GetSourceCache(heap)->get(index)->IsUndefined()) { | 34 if (Source::GetSourceCache(heap)->get(index)->IsUndefined(isolate_)) { |
35 // We can use external strings for the natives. | 35 // We can use external strings for the natives. |
36 Vector<const char> source = Source::GetScriptSource(index); | 36 Vector<const char> source = Source::GetScriptSource(index); |
37 NativesExternalStringResource* resource = | 37 NativesExternalStringResource* resource = |
38 new NativesExternalStringResource(source.start(), source.length()); | 38 new NativesExternalStringResource(source.start(), source.length()); |
39 Handle<ExternalOneByteString> source_code = | 39 Handle<ExternalOneByteString> source_code = |
40 isolate_->factory()->NewNativeSourceString(resource); | 40 isolate_->factory()->NewNativeSourceString(resource); |
41 // Mark this external string with a special map. | 41 // Mark this external string with a special map. |
42 DCHECK(source_code->is_short()); | 42 DCHECK(source_code->is_short()); |
43 Source::GetSourceCache(heap)->set(index, *source_code); | 43 Source::GetSourceCache(heap)->set(index, *source_code); |
44 } | 44 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 delete trigger_failure_extension_; | 102 delete trigger_failure_extension_; |
103 trigger_failure_extension_ = NULL; | 103 trigger_failure_extension_ = NULL; |
104 delete ignition_statistics_extension_; | 104 delete ignition_statistics_extension_; |
105 ignition_statistics_extension_ = NULL; | 105 ignition_statistics_extension_ = NULL; |
106 } | 106 } |
107 | 107 |
108 | 108 |
109 void DeleteNativeSources(Object* maybe_array) { | 109 void DeleteNativeSources(Object* maybe_array) { |
110 if (maybe_array->IsFixedArray()) { | 110 if (maybe_array->IsFixedArray()) { |
111 FixedArray* array = FixedArray::cast(maybe_array); | 111 FixedArray* array = FixedArray::cast(maybe_array); |
| 112 Isolate* isolate = array->GetIsolate(); |
112 for (int i = 0; i < array->length(); i++) { | 113 for (int i = 0; i < array->length(); i++) { |
113 Object* natives_source = array->get(i); | 114 Object* natives_source = array->get(i); |
114 if (!natives_source->IsUndefined()) { | 115 if (!natives_source->IsUndefined(isolate)) { |
115 const NativesExternalStringResource* resource = | 116 const NativesExternalStringResource* resource = |
116 reinterpret_cast<const NativesExternalStringResource*>( | 117 reinterpret_cast<const NativesExternalStringResource*>( |
117 ExternalOneByteString::cast(natives_source)->resource()); | 118 ExternalOneByteString::cast(natives_source)->resource()); |
118 delete resource; | 119 delete resource; |
119 } | 120 } |
120 } | 121 } |
121 } | 122 } |
122 } | 123 } |
123 | 124 |
124 | 125 |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 | 884 |
884 | 885 |
885 static void AddToWeakNativeContextList(Context* context) { | 886 static void AddToWeakNativeContextList(Context* context) { |
886 DCHECK(context->IsNativeContext()); | 887 DCHECK(context->IsNativeContext()); |
887 Heap* heap = context->GetIsolate()->heap(); | 888 Heap* heap = context->GetIsolate()->heap(); |
888 #ifdef DEBUG | 889 #ifdef DEBUG |
889 { // NOLINT | 890 { // NOLINT |
890 DCHECK(context->next_context_link()->IsUndefined()); | 891 DCHECK(context->next_context_link()->IsUndefined()); |
891 // Check that context is not in the list yet. | 892 // Check that context is not in the list yet. |
892 for (Object* current = heap->native_contexts_list(); | 893 for (Object* current = heap->native_contexts_list(); |
893 !current->IsUndefined(); | 894 !current->IsUndefined(heap->isolate()); |
894 current = Context::cast(current)->next_context_link()) { | 895 current = Context::cast(current)->next_context_link()) { |
895 DCHECK(current != context); | 896 DCHECK(current != context); |
896 } | 897 } |
897 } | 898 } |
898 #endif | 899 #endif |
899 context->set(Context::NEXT_CONTEXT_LINK, heap->native_contexts_list(), | 900 context->set(Context::NEXT_CONTEXT_LINK, heap->native_contexts_list(), |
900 UPDATE_WEAK_WRITE_BARRIER); | 901 UPDATE_WEAK_WRITE_BARRIER); |
901 heap->set_native_contexts_list(context); | 902 heap->set_native_contexts_list(context); |
902 } | 903 } |
903 | 904 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 Handle<ObjectTemplateInfo> js_global_object_template; | 959 Handle<ObjectTemplateInfo> js_global_object_template; |
959 if (!global_proxy_template.IsEmpty()) { | 960 if (!global_proxy_template.IsEmpty()) { |
960 // Get prototype template of the global_proxy_template. | 961 // Get prototype template of the global_proxy_template. |
961 Handle<ObjectTemplateInfo> data = | 962 Handle<ObjectTemplateInfo> data = |
962 v8::Utils::OpenHandle(*global_proxy_template); | 963 v8::Utils::OpenHandle(*global_proxy_template); |
963 Handle<FunctionTemplateInfo> global_constructor = | 964 Handle<FunctionTemplateInfo> global_constructor = |
964 Handle<FunctionTemplateInfo>( | 965 Handle<FunctionTemplateInfo>( |
965 FunctionTemplateInfo::cast(data->constructor())); | 966 FunctionTemplateInfo::cast(data->constructor())); |
966 Handle<Object> proto_template(global_constructor->prototype_template(), | 967 Handle<Object> proto_template(global_constructor->prototype_template(), |
967 isolate()); | 968 isolate()); |
968 if (!proto_template->IsUndefined()) { | 969 if (!proto_template->IsUndefined(isolate())) { |
969 js_global_object_template = | 970 js_global_object_template = |
970 Handle<ObjectTemplateInfo>::cast(proto_template); | 971 Handle<ObjectTemplateInfo>::cast(proto_template); |
971 } | 972 } |
972 } | 973 } |
973 | 974 |
974 if (js_global_object_template.is_null()) { | 975 if (js_global_object_template.is_null()) { |
975 Handle<String> name = Handle<String>(heap()->empty_string()); | 976 Handle<String> name = Handle<String>(heap()->empty_string()); |
976 Handle<Code> code = isolate()->builtins()->Illegal(); | 977 Handle<Code> code = isolate()->builtins()->Illegal(); |
977 Handle<JSObject> prototype = | 978 Handle<JSObject> prototype = |
978 factory()->NewFunctionPrototype(isolate()->object_function()); | 979 factory()->NewFunctionPrototype(isolate()->object_function()); |
(...skipping 2580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3559 DCHECK(raw_key->IsName()); | 3560 DCHECK(raw_key->IsName()); |
3560 // If the property is already there we skip it. | 3561 // If the property is already there we skip it. |
3561 Handle<Name> key(Name::cast(raw_key)); | 3562 Handle<Name> key(Name::cast(raw_key)); |
3562 LookupIterator it(to, key, LookupIterator::OWN_SKIP_INTERCEPTOR); | 3563 LookupIterator it(to, key, LookupIterator::OWN_SKIP_INTERCEPTOR); |
3563 CHECK_NE(LookupIterator::ACCESS_CHECK, it.state()); | 3564 CHECK_NE(LookupIterator::ACCESS_CHECK, it.state()); |
3564 if (it.IsFound()) continue; | 3565 if (it.IsFound()) continue; |
3565 // Set the property. | 3566 // Set the property. |
3566 DCHECK(properties->ValueAt(i)->IsPropertyCell()); | 3567 DCHECK(properties->ValueAt(i)->IsPropertyCell()); |
3567 Handle<PropertyCell> cell(PropertyCell::cast(properties->ValueAt(i))); | 3568 Handle<PropertyCell> cell(PropertyCell::cast(properties->ValueAt(i))); |
3568 Handle<Object> value(cell->value(), isolate()); | 3569 Handle<Object> value(cell->value(), isolate()); |
3569 if (value->IsTheHole()) continue; | 3570 if (value->IsTheHole(isolate())) continue; |
3570 PropertyDetails details = cell->property_details(); | 3571 PropertyDetails details = cell->property_details(); |
3571 DCHECK_EQ(kData, details.kind()); | 3572 DCHECK_EQ(kData, details.kind()); |
3572 JSObject::AddProperty(to, key, value, details.attributes()); | 3573 JSObject::AddProperty(to, key, value, details.attributes()); |
3573 } | 3574 } |
3574 } | 3575 } |
3575 } else { | 3576 } else { |
3576 Handle<NameDictionary> properties = | 3577 Handle<NameDictionary> properties = |
3577 Handle<NameDictionary>(from->property_dictionary()); | 3578 Handle<NameDictionary>(from->property_dictionary()); |
3578 int capacity = properties->Capacity(); | 3579 int capacity = properties->Capacity(); |
3579 for (int i = 0; i < capacity; i++) { | 3580 for (int i = 0; i < capacity; i++) { |
3580 Object* raw_key(properties->KeyAt(i)); | 3581 Object* raw_key(properties->KeyAt(i)); |
3581 if (properties->IsKey(raw_key)) { | 3582 if (properties->IsKey(raw_key)) { |
3582 DCHECK(raw_key->IsName()); | 3583 DCHECK(raw_key->IsName()); |
3583 // If the property is already there we skip it. | 3584 // If the property is already there we skip it. |
3584 Handle<Name> key(Name::cast(raw_key)); | 3585 Handle<Name> key(Name::cast(raw_key)); |
3585 LookupIterator it(to, key, LookupIterator::OWN_SKIP_INTERCEPTOR); | 3586 LookupIterator it(to, key, LookupIterator::OWN_SKIP_INTERCEPTOR); |
3586 CHECK_NE(LookupIterator::ACCESS_CHECK, it.state()); | 3587 CHECK_NE(LookupIterator::ACCESS_CHECK, it.state()); |
3587 if (it.IsFound()) continue; | 3588 if (it.IsFound()) continue; |
3588 // Set the property. | 3589 // Set the property. |
3589 Handle<Object> value = Handle<Object>(properties->ValueAt(i), | 3590 Handle<Object> value = Handle<Object>(properties->ValueAt(i), |
3590 isolate()); | 3591 isolate()); |
3591 DCHECK(!value->IsCell()); | 3592 DCHECK(!value->IsCell()); |
3592 DCHECK(!value->IsTheHole()); | 3593 DCHECK(!value->IsTheHole(isolate())); |
3593 PropertyDetails details = properties->DetailsAt(i); | 3594 PropertyDetails details = properties->DetailsAt(i); |
3594 DCHECK_EQ(kData, details.kind()); | 3595 DCHECK_EQ(kData, details.kind()); |
3595 JSObject::AddProperty(to, key, value, details.attributes()); | 3596 JSObject::AddProperty(to, key, value, details.attributes()); |
3596 } | 3597 } |
3597 } | 3598 } |
3598 } | 3599 } |
3599 } | 3600 } |
3600 | 3601 |
3601 | 3602 |
3602 void Genesis::TransferIndexedProperties(Handle<JSObject> from, | 3603 void Genesis::TransferIndexedProperties(Handle<JSObject> from, |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3802 } | 3803 } |
3803 | 3804 |
3804 | 3805 |
3805 // Called when the top-level V8 mutex is destroyed. | 3806 // Called when the top-level V8 mutex is destroyed. |
3806 void Bootstrapper::FreeThreadResources() { | 3807 void Bootstrapper::FreeThreadResources() { |
3807 DCHECK(!IsActive()); | 3808 DCHECK(!IsActive()); |
3808 } | 3809 } |
3809 | 3810 |
3810 } // namespace internal | 3811 } // namespace internal |
3811 } // namespace v8 | 3812 } // namespace v8 |
OLD | NEW |