| 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 "bootstrapper.h" | 5 #include "bootstrapper.h" |
| 6 | 6 |
| 7 #include "accessors.h" | 7 #include "accessors.h" |
| 8 #include "isolate-inl.h" | 8 #include "isolate-inl.h" |
| 9 #include "natives.h" | 9 #include "natives.h" |
| 10 #include "snapshot.h" | 10 #include "snapshot.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 Handle<String> Bootstrapper::NativesSourceLookup(int index) { | 46 Handle<String> Bootstrapper::NativesSourceLookup(int index) { |
| 47 ASSERT(0 <= index && index < Natives::GetBuiltinsCount()); | 47 ASSERT(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 Handle<String> source_code = | 57 Handle<String> source_code = |
| 57 isolate_->factory()->NewExternalStringFromAscii(resource); | 58 isolate_->factory()->NewExternalStringFromAscii( |
| 58 // We do not expect this to throw an exception. Change this if it does. | 59 resource).ToHandleChecked(); |
| 59 CHECK_NOT_EMPTY_HANDLE(isolate_, source_code); | |
| 60 heap->natives_source_cache()->set(index, *source_code); | 60 heap->natives_source_cache()->set(index, *source_code); |
| 61 } | 61 } |
| 62 Handle<Object> cached_source(heap->natives_source_cache()->get(index), | 62 Handle<Object> cached_source(heap->natives_source_cache()->get(index), |
| 63 isolate_); | 63 isolate_); |
| 64 return Handle<String>::cast(cached_source); | 64 return Handle<String>::cast(cached_source); |
| 65 } | 65 } |
| 66 | 66 |
| 67 | 67 |
| 68 void Bootstrapper::Initialize(bool create_heap_objects) { | 68 void Bootstrapper::Initialize(bool create_heap_objects) { |
| 69 extensions_cache_.Initialize(isolate_, create_heap_objects); | 69 extensions_cache_.Initialize(isolate_, create_heap_objects); |
| (...skipping 2242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2312 extension_states->set_state(current, VISITED); | 2312 extension_states->set_state(current, VISITED); |
| 2313 v8::Extension* extension = current->extension(); | 2313 v8::Extension* extension = current->extension(); |
| 2314 // Install the extension's dependencies | 2314 // Install the extension's dependencies |
| 2315 for (int i = 0; i < extension->dependency_count(); i++) { | 2315 for (int i = 0; i < extension->dependency_count(); i++) { |
| 2316 if (!InstallExtension(isolate, | 2316 if (!InstallExtension(isolate, |
| 2317 extension->dependencies()[i], | 2317 extension->dependencies()[i], |
| 2318 extension_states)) { | 2318 extension_states)) { |
| 2319 return false; | 2319 return false; |
| 2320 } | 2320 } |
| 2321 } | 2321 } |
| 2322 // We do not expect this to throw an exception. Change this if it does. |
| 2322 Handle<String> source_code = | 2323 Handle<String> source_code = |
| 2323 isolate->factory()->NewExternalStringFromAscii(extension->source()); | 2324 isolate->factory()->NewExternalStringFromAscii( |
| 2324 // We do not expect this to throw an exception. Change this if it does. | 2325 extension->source()).ToHandleChecked(); |
| 2325 CHECK_NOT_EMPTY_HANDLE(isolate, source_code); | |
| 2326 bool result = CompileScriptCached(isolate, | 2326 bool result = CompileScriptCached(isolate, |
| 2327 CStrVector(extension->name()), | 2327 CStrVector(extension->name()), |
| 2328 source_code, | 2328 source_code, |
| 2329 isolate->bootstrapper()->extensions_cache(), | 2329 isolate->bootstrapper()->extensions_cache(), |
| 2330 extension, | 2330 extension, |
| 2331 Handle<Context>(isolate->context()), | 2331 Handle<Context>(isolate->context()), |
| 2332 false); | 2332 false); |
| 2333 ASSERT(isolate->has_pending_exception() != result); | 2333 ASSERT(isolate->has_pending_exception() != result); |
| 2334 if (!result) { | 2334 if (!result) { |
| 2335 // We print out the name of the extension that fail to install. | 2335 // We print out the name of the extension that fail to install. |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2721 return from + sizeof(NestingCounterType); | 2721 return from + sizeof(NestingCounterType); |
| 2722 } | 2722 } |
| 2723 | 2723 |
| 2724 | 2724 |
| 2725 // Called when the top-level V8 mutex is destroyed. | 2725 // Called when the top-level V8 mutex is destroyed. |
| 2726 void Bootstrapper::FreeThreadResources() { | 2726 void Bootstrapper::FreeThreadResources() { |
| 2727 ASSERT(!IsActive()); | 2727 ASSERT(!IsActive()); |
| 2728 } | 2728 } |
| 2729 | 2729 |
| 2730 } } // namespace v8::internal | 2730 } } // namespace v8::internal |
| OLD | NEW |