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 3089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3202 map_.LookupOrInsert(extension, Hash(extension))->value = | 3207 map_.LookupOrInsert(extension, Hash(extension))->value = |
3203 reinterpret_cast<void*>(static_cast<intptr_t>(state)); | 3208 reinterpret_cast<void*>(static_cast<intptr_t>(state)); |
3204 } | 3209 } |
3205 | 3210 |
3206 | 3211 |
3207 bool Genesis::InstallExtensions(Handle<Context> native_context, | 3212 bool Genesis::InstallExtensions(Handle<Context> native_context, |
3208 v8::ExtensionConfiguration* extensions) { | 3213 v8::ExtensionConfiguration* extensions) { |
3209 Isolate* isolate = native_context->GetIsolate(); | 3214 Isolate* isolate = native_context->GetIsolate(); |
3210 ExtensionStates extension_states; // All extensions have state UNVISITED. | 3215 ExtensionStates extension_states; // All extensions have state UNVISITED. |
3211 return InstallAutoExtensions(isolate, &extension_states) && | 3216 return InstallAutoExtensions(isolate, &extension_states) && |
3212 (!FLAG_expose_free_buffer || | 3217 (!FLAG_expose_free_buffer || |
3213 InstallExtension(isolate, "v8/free-buffer", &extension_states)) && | 3218 InstallExtension(isolate, "v8/free-buffer", &extension_states)) && |
3214 (!FLAG_expose_gc || | 3219 (!FLAG_expose_gc || |
3215 InstallExtension(isolate, "v8/gc", &extension_states)) && | 3220 InstallExtension(isolate, "v8/gc", &extension_states)) && |
3216 (!FLAG_expose_externalize_string || | 3221 (!FLAG_expose_externalize_string || |
3217 InstallExtension(isolate, "v8/externalize", &extension_states)) && | 3222 InstallExtension(isolate, "v8/externalize", &extension_states)) && |
3218 (!FLAG_track_gc_object_stats || | 3223 (!FLAG_track_gc_object_stats || |
3219 InstallExtension(isolate, "v8/statistics", &extension_states)) && | 3224 InstallExtension(isolate, "v8/statistics", &extension_states)) && |
3220 (!FLAG_expose_trigger_failure || | 3225 (!FLAG_expose_trigger_failure || |
3221 InstallExtension(isolate, "v8/trigger-failure", &extension_states)) && | 3226 InstallExtension(isolate, "v8/trigger-failure", &extension_states)) && |
3222 InstallRequestedExtensions(isolate, extensions, &extension_states); | 3227 (!(FLAG_ignition && FLAG_trace_ignition_dispatches) || |
| 3228 InstallExtension(isolate, "v8/ignition-statistics", |
| 3229 &extension_states)) && |
| 3230 InstallRequestedExtensions(isolate, extensions, &extension_states); |
3223 } | 3231 } |
3224 | 3232 |
3225 | 3233 |
3226 bool Genesis::InstallAutoExtensions(Isolate* isolate, | 3234 bool Genesis::InstallAutoExtensions(Isolate* isolate, |
3227 ExtensionStates* extension_states) { | 3235 ExtensionStates* extension_states) { |
3228 for (v8::RegisteredExtension* it = v8::RegisteredExtension::first_extension(); | 3236 for (v8::RegisteredExtension* it = v8::RegisteredExtension::first_extension(); |
3229 it != NULL; | 3237 it != NULL; |
3230 it = it->next()) { | 3238 it = it->next()) { |
3231 if (it->extension()->auto_enable() && | 3239 if (it->extension()->auto_enable() && |
3232 !InstallExtension(isolate, it, extension_states)) { | 3240 !InstallExtension(isolate, it, extension_states)) { |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3665 } | 3673 } |
3666 | 3674 |
3667 | 3675 |
3668 // Called when the top-level V8 mutex is destroyed. | 3676 // Called when the top-level V8 mutex is destroyed. |
3669 void Bootstrapper::FreeThreadResources() { | 3677 void Bootstrapper::FreeThreadResources() { |
3670 DCHECK(!IsActive()); | 3678 DCHECK(!IsActive()); |
3671 } | 3679 } |
3672 | 3680 |
3673 } // namespace internal | 3681 } // namespace internal |
3674 } // namespace v8 | 3682 } // namespace v8 |
OLD | NEW |