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" |
11 #include "src/extensions/free-buffer-extension.h" | 11 #include "src/extensions/free-buffer-extension.h" |
12 #include "src/extensions/gc-extension.h" | 12 #include "src/extensions/gc-extension.h" |
| 13 #include "src/extensions/ignition-statistics-extension.h" |
13 #include "src/extensions/statistics-extension.h" | 14 #include "src/extensions/statistics-extension.h" |
14 #include "src/extensions/trigger-failure-extension.h" | 15 #include "src/extensions/trigger-failure-extension.h" |
15 #include "src/heap/heap.h" | 16 #include "src/heap/heap.h" |
16 #include "src/isolate-inl.h" | 17 #include "src/isolate-inl.h" |
17 #include "src/snapshot/natives.h" | 18 #include "src/snapshot/natives.h" |
18 #include "src/snapshot/snapshot.h" | 19 #include "src/snapshot/snapshot.h" |
19 #include "src/wasm/wasm-js.h" | 20 #include "src/wasm/wasm-js.h" |
20 | 21 |
21 namespace v8 { | 22 namespace v8 { |
22 namespace internal { | 23 namespace internal { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 bool flag_given = FLAG_expose_gc_as != NULL && strlen(FLAG_expose_gc_as) != 0; | 67 bool flag_given = FLAG_expose_gc_as != NULL && strlen(FLAG_expose_gc_as) != 0; |
67 return flag_given ? FLAG_expose_gc_as : "gc"; | 68 return flag_given ? FLAG_expose_gc_as : "gc"; |
68 } | 69 } |
69 | 70 |
70 | 71 |
71 v8::Extension* Bootstrapper::free_buffer_extension_ = NULL; | 72 v8::Extension* Bootstrapper::free_buffer_extension_ = NULL; |
72 v8::Extension* Bootstrapper::gc_extension_ = NULL; | 73 v8::Extension* Bootstrapper::gc_extension_ = NULL; |
73 v8::Extension* Bootstrapper::externalize_string_extension_ = NULL; | 74 v8::Extension* Bootstrapper::externalize_string_extension_ = NULL; |
74 v8::Extension* Bootstrapper::statistics_extension_ = NULL; | 75 v8::Extension* Bootstrapper::statistics_extension_ = NULL; |
75 v8::Extension* Bootstrapper::trigger_failure_extension_ = NULL; | 76 v8::Extension* Bootstrapper::trigger_failure_extension_ = NULL; |
76 | 77 v8::Extension* Bootstrapper::ignition_statistics_extension_ = NULL; |
77 | 78 |
78 void Bootstrapper::InitializeOncePerProcess() { | 79 void Bootstrapper::InitializeOncePerProcess() { |
79 free_buffer_extension_ = new FreeBufferExtension; | 80 free_buffer_extension_ = new FreeBufferExtension; |
80 v8::RegisterExtension(free_buffer_extension_); | 81 v8::RegisterExtension(free_buffer_extension_); |
81 gc_extension_ = new GCExtension(GCFunctionName()); | 82 gc_extension_ = new GCExtension(GCFunctionName()); |
82 v8::RegisterExtension(gc_extension_); | 83 v8::RegisterExtension(gc_extension_); |
83 externalize_string_extension_ = new ExternalizeStringExtension; | 84 externalize_string_extension_ = new ExternalizeStringExtension; |
84 v8::RegisterExtension(externalize_string_extension_); | 85 v8::RegisterExtension(externalize_string_extension_); |
85 statistics_extension_ = new StatisticsExtension; | 86 statistics_extension_ = new StatisticsExtension; |
86 v8::RegisterExtension(statistics_extension_); | 87 v8::RegisterExtension(statistics_extension_); |
87 trigger_failure_extension_ = new TriggerFailureExtension; | 88 trigger_failure_extension_ = new TriggerFailureExtension; |
88 v8::RegisterExtension(trigger_failure_extension_); | 89 v8::RegisterExtension(trigger_failure_extension_); |
| 90 ignition_statistics_extension_ = new IgnitionStatisticsExtension; |
| 91 v8::RegisterExtension(ignition_statistics_extension_); |
89 } | 92 } |
90 | 93 |
91 | 94 |
92 void Bootstrapper::TearDownExtensions() { | 95 void Bootstrapper::TearDownExtensions() { |
93 delete free_buffer_extension_; | 96 delete free_buffer_extension_; |
94 free_buffer_extension_ = NULL; | 97 free_buffer_extension_ = NULL; |
95 delete gc_extension_; | 98 delete gc_extension_; |
96 gc_extension_ = NULL; | 99 gc_extension_ = NULL; |
97 delete externalize_string_extension_; | 100 delete externalize_string_extension_; |
98 externalize_string_extension_ = NULL; | 101 externalize_string_extension_ = NULL; |
99 delete statistics_extension_; | 102 delete statistics_extension_; |
100 statistics_extension_ = NULL; | 103 statistics_extension_ = NULL; |
101 delete trigger_failure_extension_; | 104 delete trigger_failure_extension_; |
102 trigger_failure_extension_ = NULL; | 105 trigger_failure_extension_ = NULL; |
| 106 delete ignition_statistics_extension_; |
| 107 ignition_statistics_extension_ = NULL; |
103 } | 108 } |
104 | 109 |
105 | 110 |
106 void DeleteNativeSources(Object* maybe_array) { | 111 void DeleteNativeSources(Object* maybe_array) { |
107 if (maybe_array->IsFixedArray()) { | 112 if (maybe_array->IsFixedArray()) { |
108 FixedArray* array = FixedArray::cast(maybe_array); | 113 FixedArray* array = FixedArray::cast(maybe_array); |
109 for (int i = 0; i < array->length(); i++) { | 114 for (int i = 0; i < array->length(); i++) { |
110 Object* natives_source = array->get(i); | 115 Object* natives_source = array->get(i); |
111 if (!natives_source->IsUndefined()) { | 116 if (!natives_source->IsUndefined()) { |
112 const NativesExternalStringResource* resource = | 117 const NativesExternalStringResource* resource = |
(...skipping 3068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3181 map_.LookupOrInsert(extension, Hash(extension))->value = | 3186 map_.LookupOrInsert(extension, Hash(extension))->value = |
3182 reinterpret_cast<void*>(static_cast<intptr_t>(state)); | 3187 reinterpret_cast<void*>(static_cast<intptr_t>(state)); |
3183 } | 3188 } |
3184 | 3189 |
3185 | 3190 |
3186 bool Genesis::InstallExtensions(Handle<Context> native_context, | 3191 bool Genesis::InstallExtensions(Handle<Context> native_context, |
3187 v8::ExtensionConfiguration* extensions) { | 3192 v8::ExtensionConfiguration* extensions) { |
3188 Isolate* isolate = native_context->GetIsolate(); | 3193 Isolate* isolate = native_context->GetIsolate(); |
3189 ExtensionStates extension_states; // All extensions have state UNVISITED. | 3194 ExtensionStates extension_states; // All extensions have state UNVISITED. |
3190 return InstallAutoExtensions(isolate, &extension_states) && | 3195 return InstallAutoExtensions(isolate, &extension_states) && |
3191 (!FLAG_expose_free_buffer || | 3196 (!FLAG_expose_free_buffer || |
3192 InstallExtension(isolate, "v8/free-buffer", &extension_states)) && | 3197 InstallExtension(isolate, "v8/free-buffer", &extension_states)) && |
3193 (!FLAG_expose_gc || | 3198 (!FLAG_expose_gc || |
3194 InstallExtension(isolate, "v8/gc", &extension_states)) && | 3199 InstallExtension(isolate, "v8/gc", &extension_states)) && |
3195 (!FLAG_expose_externalize_string || | 3200 (!FLAG_expose_externalize_string || |
3196 InstallExtension(isolate, "v8/externalize", &extension_states)) && | 3201 InstallExtension(isolate, "v8/externalize", &extension_states)) && |
3197 (!FLAG_track_gc_object_stats || | 3202 (!FLAG_track_gc_object_stats || |
3198 InstallExtension(isolate, "v8/statistics", &extension_states)) && | 3203 InstallExtension(isolate, "v8/statistics", &extension_states)) && |
3199 (!FLAG_expose_trigger_failure || | 3204 (!FLAG_expose_trigger_failure || |
3200 InstallExtension(isolate, "v8/trigger-failure", &extension_states)) && | 3205 InstallExtension(isolate, "v8/trigger-failure", &extension_states)) && |
3201 InstallRequestedExtensions(isolate, extensions, &extension_states); | 3206 (!(FLAG_ignition && FLAG_trace_ignition_dispatches) || |
| 3207 InstallExtension(isolate, "v8/ignition-statistics", |
| 3208 &extension_states)) && |
| 3209 InstallRequestedExtensions(isolate, extensions, &extension_states); |
3202 } | 3210 } |
3203 | 3211 |
3204 | 3212 |
3205 bool Genesis::InstallAutoExtensions(Isolate* isolate, | 3213 bool Genesis::InstallAutoExtensions(Isolate* isolate, |
3206 ExtensionStates* extension_states) { | 3214 ExtensionStates* extension_states) { |
3207 for (v8::RegisteredExtension* it = v8::RegisteredExtension::first_extension(); | 3215 for (v8::RegisteredExtension* it = v8::RegisteredExtension::first_extension(); |
3208 it != NULL; | 3216 it != NULL; |
3209 it = it->next()) { | 3217 it = it->next()) { |
3210 if (it->extension()->auto_enable() && | 3218 if (it->extension()->auto_enable() && |
3211 !InstallExtension(isolate, it, extension_states)) { | 3219 !InstallExtension(isolate, it, extension_states)) { |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3644 } | 3652 } |
3645 | 3653 |
3646 | 3654 |
3647 // Called when the top-level V8 mutex is destroyed. | 3655 // Called when the top-level V8 mutex is destroyed. |
3648 void Bootstrapper::FreeThreadResources() { | 3656 void Bootstrapper::FreeThreadResources() { |
3649 DCHECK(!IsActive()); | 3657 DCHECK(!IsActive()); |
3650 } | 3658 } |
3651 | 3659 |
3652 } // namespace internal | 3660 } // namespace internal |
3653 } // namespace v8 | 3661 } // namespace v8 |
OLD | NEW |