OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 isolate_); | 94 isolate_); |
95 return Handle<String>::cast(cached_source); | 95 return Handle<String>::cast(cached_source); |
96 } | 96 } |
97 | 97 |
98 | 98 |
99 void Bootstrapper::Initialize(bool create_heap_objects) { | 99 void Bootstrapper::Initialize(bool create_heap_objects) { |
100 extensions_cache_.Initialize(isolate_, create_heap_objects); | 100 extensions_cache_.Initialize(isolate_, create_heap_objects); |
101 } | 101 } |
102 | 102 |
103 | 103 |
104 void Bootstrapper::InitializeOncePerProcess() { | 104 static const char* GCFunctionName() { |
105 FreeBufferExtension::Register(); | 105 bool flag_given = FLAG_expose_gc_as != NULL && strlen(FLAG_expose_gc_as) != 0; |
106 GCExtension::Register(); | 106 return flag_given ? FLAG_expose_gc_as : "gc"; |
107 ExternalizeStringExtension::Register(); | |
108 StatisticsExtension::Register(); | |
109 TriggerFailureExtension::Register(); | |
110 } | 107 } |
111 | 108 |
112 | 109 |
| 110 v8::Extension* Bootstrapper::free_buffer_extension_ = NULL; |
| 111 v8::Extension* Bootstrapper::gc_extension_ = NULL; |
| 112 v8::Extension* Bootstrapper::externalize_string_extension_ = NULL; |
| 113 v8::Extension* Bootstrapper::statistics_extension_ = NULL; |
| 114 v8::Extension* Bootstrapper::trigger_failure_extension_ = NULL; |
| 115 |
| 116 |
| 117 void Bootstrapper::InitializeOncePerProcess() { |
| 118 free_buffer_extension_ = new FreeBufferExtension; |
| 119 v8::RegisterExtension(free_buffer_extension_); |
| 120 gc_extension_ = new GCExtension(GCFunctionName()); |
| 121 v8::RegisterExtension(gc_extension_); |
| 122 externalize_string_extension_ = new ExternalizeStringExtension; |
| 123 v8::RegisterExtension(externalize_string_extension_); |
| 124 statistics_extension_ = new StatisticsExtension; |
| 125 v8::RegisterExtension(statistics_extension_); |
| 126 trigger_failure_extension_ = new TriggerFailureExtension; |
| 127 v8::RegisterExtension(trigger_failure_extension_); |
| 128 } |
| 129 |
| 130 |
| 131 void Bootstrapper::TearDownExtensions() { |
| 132 delete free_buffer_extension_; |
| 133 delete gc_extension_; |
| 134 delete externalize_string_extension_; |
| 135 delete statistics_extension_; |
| 136 delete trigger_failure_extension_; |
| 137 } |
| 138 |
| 139 |
113 char* Bootstrapper::AllocateAutoDeletedArray(int bytes) { | 140 char* Bootstrapper::AllocateAutoDeletedArray(int bytes) { |
114 char* memory = new char[bytes]; | 141 char* memory = new char[bytes]; |
115 if (memory != NULL) { | 142 if (memory != NULL) { |
116 if (delete_these_arrays_on_tear_down_ == NULL) { | 143 if (delete_these_arrays_on_tear_down_ == NULL) { |
117 delete_these_arrays_on_tear_down_ = new List<char*>(2); | 144 delete_these_arrays_on_tear_down_ = new List<char*>(2); |
118 } | 145 } |
119 delete_these_arrays_on_tear_down_->Add(memory); | 146 delete_these_arrays_on_tear_down_->Add(memory); |
120 } | 147 } |
121 return memory; | 148 return memory; |
122 } | 149 } |
(...skipping 2581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2704 return from + sizeof(NestingCounterType); | 2731 return from + sizeof(NestingCounterType); |
2705 } | 2732 } |
2706 | 2733 |
2707 | 2734 |
2708 // Called when the top-level V8 mutex is destroyed. | 2735 // Called when the top-level V8 mutex is destroyed. |
2709 void Bootstrapper::FreeThreadResources() { | 2736 void Bootstrapper::FreeThreadResources() { |
2710 ASSERT(!IsActive()); | 2737 ASSERT(!IsActive()); |
2711 } | 2738 } |
2712 | 2739 |
2713 } } // namespace v8::internal | 2740 } } // namespace v8::internal |
OLD | NEW |