| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 isolate_->factory()->NewExternalStringFromAscii(resource); | 91 isolate_->factory()->NewExternalStringFromAscii(resource); |
| 92 heap->natives_source_cache()->set(index, *source_code); | 92 heap->natives_source_cache()->set(index, *source_code); |
| 93 } | 93 } |
| 94 Handle<Object> cached_source(heap->natives_source_cache()->get(index), | 94 Handle<Object> cached_source(heap->natives_source_cache()->get(index), |
| 95 isolate_); | 95 isolate_); |
| 96 return Handle<String>::cast(cached_source); | 96 return Handle<String>::cast(cached_source); |
| 97 } | 97 } |
| 98 | 98 |
| 99 | 99 |
| 100 void Bootstrapper::Initialize(bool create_heap_objects) { | 100 void Bootstrapper::Initialize(bool create_heap_objects) { |
| 101 extensions_cache_.Initialize(create_heap_objects); | 101 extensions_cache_.Initialize(isolate_, create_heap_objects); |
| 102 } | 102 } |
| 103 | 103 |
| 104 | 104 |
| 105 void Bootstrapper::InitializeOncePerProcess() { | 105 void Bootstrapper::InitializeOncePerProcess() { |
| 106 GCExtension::Register(); | 106 GCExtension::Register(); |
| 107 ExternalizeStringExtension::Register(); | 107 ExternalizeStringExtension::Register(); |
| 108 StatisticsExtension::Register(); | 108 StatisticsExtension::Register(); |
| 109 #if defined(V8_I18N_SUPPORT) | 109 #if defined(V8_I18N_SUPPORT) |
| 110 v8_i18n::Extension::Register(); | 110 v8_i18n::Extension::Register(); |
| 111 #endif | 111 #endif |
| (...skipping 28 matching lines...) Expand all Loading... |
| 140 int len = delete_these_arrays_on_tear_down_->length(); | 140 int len = delete_these_arrays_on_tear_down_->length(); |
| 141 ASSERT(len < 1000); // Don't use this mechanism for unbounded allocations. | 141 ASSERT(len < 1000); // Don't use this mechanism for unbounded allocations. |
| 142 for (int i = 0; i < len; i++) { | 142 for (int i = 0; i < len; i++) { |
| 143 delete[] delete_these_arrays_on_tear_down_->at(i); | 143 delete[] delete_these_arrays_on_tear_down_->at(i); |
| 144 delete_these_arrays_on_tear_down_->at(i) = NULL; | 144 delete_these_arrays_on_tear_down_->at(i) = NULL; |
| 145 } | 145 } |
| 146 delete delete_these_arrays_on_tear_down_; | 146 delete delete_these_arrays_on_tear_down_; |
| 147 delete_these_arrays_on_tear_down_ = NULL; | 147 delete_these_arrays_on_tear_down_ = NULL; |
| 148 } | 148 } |
| 149 | 149 |
| 150 extensions_cache_.Initialize(false); // Yes, symmetrical | 150 extensions_cache_.Initialize(isolate_, false); // Yes, symmetrical |
| 151 } | 151 } |
| 152 | 152 |
| 153 | 153 |
| 154 class Genesis BASE_EMBEDDED { | 154 class Genesis BASE_EMBEDDED { |
| 155 public: | 155 public: |
| 156 Genesis(Isolate* isolate, | 156 Genesis(Isolate* isolate, |
| 157 Handle<Object> global_object, | 157 Handle<Object> global_object, |
| 158 v8::Handle<v8::ObjectTemplate> global_template, | 158 v8::Handle<v8::ObjectTemplate> global_template, |
| 159 v8::ExtensionConfiguration* extensions); | 159 v8::ExtensionConfiguration* extensions); |
| 160 ~Genesis() { } | 160 ~Genesis() { } |
| (...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1309 delegate->shared()->DontAdaptArguments(); | 1309 delegate->shared()->DontAdaptArguments(); |
| 1310 } | 1310 } |
| 1311 | 1311 |
| 1312 // Initialize the out of memory slot. | 1312 // Initialize the out of memory slot. |
| 1313 native_context()->set_out_of_memory(heap->false_value()); | 1313 native_context()->set_out_of_memory(heap->false_value()); |
| 1314 | 1314 |
| 1315 // Initialize the embedder data slot. | 1315 // Initialize the embedder data slot. |
| 1316 Handle<FixedArray> embedder_data = factory->NewFixedArray(2); | 1316 Handle<FixedArray> embedder_data = factory->NewFixedArray(2); |
| 1317 native_context()->set_embedder_data(*embedder_data); | 1317 native_context()->set_embedder_data(*embedder_data); |
| 1318 | 1318 |
| 1319 { | 1319 // Allocate the random seed slot. |
| 1320 // Initialize the random seed slot. | 1320 Handle<ByteArray> random_seed = factory->NewByteArray(kRandomStateSize); |
| 1321 Handle<ByteArray> zeroed_byte_array( | 1321 native_context()->set_random_seed(*random_seed); |
| 1322 factory->NewByteArray(kRandomStateSize)); | |
| 1323 native_context()->set_random_seed(*zeroed_byte_array); | |
| 1324 memset(zeroed_byte_array->GetDataStartAddress(), 0, kRandomStateSize); | |
| 1325 } | |
| 1326 } | 1322 } |
| 1327 | 1323 |
| 1328 | 1324 |
| 1329 Handle<JSFunction> Genesis::InstallTypedArray( | 1325 Handle<JSFunction> Genesis::InstallTypedArray( |
| 1330 const char* name, ElementsKind elementsKind) { | 1326 const char* name, ElementsKind elementsKind) { |
| 1331 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); | 1327 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); |
| 1332 Handle<JSFunction> result = InstallFunction(global, name, JS_TYPED_ARRAY_TYPE, | 1328 Handle<JSFunction> result = InstallFunction(global, name, JS_TYPED_ARRAY_TYPE, |
| 1333 JSTypedArray::kSize, isolate()->initial_object_prototype(), | 1329 JSTypedArray::kSize, isolate()->initial_object_prototype(), |
| 1334 Builtins::kIllegal, false, true); | 1330 Builtins::kIllegal, false, true); |
| 1335 | 1331 |
| (...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2642 if (!FLAG_disable_native_files) { | 2638 if (!FLAG_disable_native_files) { |
| 2643 if (!ConfigureGlobalObjects(global_template)) return; | 2639 if (!ConfigureGlobalObjects(global_template)) return; |
| 2644 isolate->counters()->contexts_created_from_scratch()->Increment(); | 2640 isolate->counters()->contexts_created_from_scratch()->Increment(); |
| 2645 } | 2641 } |
| 2646 } | 2642 } |
| 2647 | 2643 |
| 2648 // Initialize experimental globals and install experimental natives. | 2644 // Initialize experimental globals and install experimental natives. |
| 2649 InitializeExperimentalGlobal(); | 2645 InitializeExperimentalGlobal(); |
| 2650 if (!InstallExperimentalNatives()) return; | 2646 if (!InstallExperimentalNatives()) return; |
| 2651 | 2647 |
| 2648 // Initially seed the per-context random number generator |
| 2649 // using the per-isolate random number generator. |
| 2650 uint32_t* state = reinterpret_cast<uint32_t*>( |
| 2651 native_context()->random_seed()->GetDataStartAddress()); |
| 2652 do { |
| 2653 isolate->random_number_generator()->NextBytes(state, kRandomStateSize); |
| 2654 } while (state[0] == 0 || state[1] == 0); |
| 2655 |
| 2652 result_ = native_context(); | 2656 result_ = native_context(); |
| 2653 } | 2657 } |
| 2654 | 2658 |
| 2655 | 2659 |
| 2656 // Support for thread preemption. | 2660 // Support for thread preemption. |
| 2657 | 2661 |
| 2658 // Reserve space for statics needing saving and restoring. | 2662 // Reserve space for statics needing saving and restoring. |
| 2659 int Bootstrapper::ArchiveSpacePerThread() { | 2663 int Bootstrapper::ArchiveSpacePerThread() { |
| 2660 return sizeof(NestingCounterType); | 2664 return sizeof(NestingCounterType); |
| 2661 } | 2665 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2675 return from + sizeof(NestingCounterType); | 2679 return from + sizeof(NestingCounterType); |
| 2676 } | 2680 } |
| 2677 | 2681 |
| 2678 | 2682 |
| 2679 // Called when the top-level V8 mutex is destroyed. | 2683 // Called when the top-level V8 mutex is destroyed. |
| 2680 void Bootstrapper::FreeThreadResources() { | 2684 void Bootstrapper::FreeThreadResources() { |
| 2681 ASSERT(!IsActive()); | 2685 ASSERT(!IsActive()); |
| 2682 } | 2686 } |
| 2683 | 2687 |
| 2684 } } // namespace v8::internal | 2688 } } // namespace v8::internal |
| OLD | NEW |