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/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/extensions/externalize-string-extension.h" | 9 #include "src/extensions/externalize-string-extension.h" |
10 #include "src/extensions/free-buffer-extension.h" | 10 #include "src/extensions/free-buffer-extension.h" |
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 | 848 |
849 void Genesis::HookUpInnerGlobal(Handle<GlobalObject> inner_global) { | 849 void Genesis::HookUpInnerGlobal(Handle<GlobalObject> inner_global) { |
850 Handle<GlobalObject> inner_global_from_snapshot( | 850 Handle<GlobalObject> inner_global_from_snapshot( |
851 GlobalObject::cast(native_context()->extension())); | 851 GlobalObject::cast(native_context()->extension())); |
852 Handle<JSBuiltinsObject> builtins_global(native_context()->builtins()); | 852 Handle<JSBuiltinsObject> builtins_global(native_context()->builtins()); |
853 native_context()->set_extension(*inner_global); | 853 native_context()->set_extension(*inner_global); |
854 native_context()->set_global_object(*inner_global); | 854 native_context()->set_global_object(*inner_global); |
855 native_context()->set_security_token(*inner_global); | 855 native_context()->set_security_token(*inner_global); |
856 static const PropertyAttributes attributes = | 856 static const PropertyAttributes attributes = |
857 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); | 857 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); |
858 Runtime::ForceSetObjectProperty(builtins_global, | 858 Runtime::DefineObjectProperty(builtins_global, |
859 factory()->InternalizeOneByteString( | 859 factory()->InternalizeOneByteString( |
860 STATIC_ASCII_VECTOR("global")), | 860 STATIC_ASCII_VECTOR("global")), |
861 inner_global, | 861 inner_global, |
862 attributes).Assert(); | 862 attributes).Assert(); |
863 // Set up the reference from the global object to the builtins object. | 863 // Set up the reference from the global object to the builtins object. |
864 JSGlobalObject::cast(*inner_global)->set_builtins(*builtins_global); | 864 JSGlobalObject::cast(*inner_global)->set_builtins(*builtins_global); |
865 TransferNamedProperties(inner_global_from_snapshot, inner_global); | 865 TransferNamedProperties(inner_global_from_snapshot, inner_global); |
866 TransferIndexedProperties(inner_global_from_snapshot, inner_global); | 866 TransferIndexedProperties(inner_global_from_snapshot, inner_global); |
867 } | 867 } |
868 | 868 |
869 | 869 |
870 // This is only called if we are not using snapshots. The equivalent | 870 // This is only called if we are not using snapshots. The equivalent |
871 // work in the snapshot case is done in HookUpInnerGlobal. | 871 // work in the snapshot case is done in HookUpInnerGlobal. |
872 void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, | 872 void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, |
(...skipping 1790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2663 | 2663 |
2664 do { | 2664 do { |
2665 isolate->random_number_generator()->NextBytes(state, num_bytes); | 2665 isolate->random_number_generator()->NextBytes(state, num_bytes); |
2666 } while (state[0] == 0 || state[1] == 0); | 2666 } while (state[0] == 0 || state[1] == 0); |
2667 | 2667 |
2668 v8::Local<v8::ArrayBuffer> buffer = v8::ArrayBuffer::New( | 2668 v8::Local<v8::ArrayBuffer> buffer = v8::ArrayBuffer::New( |
2669 reinterpret_cast<v8::Isolate*>(isolate), state, num_bytes); | 2669 reinterpret_cast<v8::Isolate*>(isolate), state, num_bytes); |
2670 Utils::OpenHandle(*buffer)->set_should_be_freed(true); | 2670 Utils::OpenHandle(*buffer)->set_should_be_freed(true); |
2671 v8::Local<v8::Uint32Array> ta = v8::Uint32Array::New(buffer, 0, num_elems); | 2671 v8::Local<v8::Uint32Array> ta = v8::Uint32Array::New(buffer, 0, num_elems); |
2672 Handle<JSBuiltinsObject> builtins(native_context()->builtins()); | 2672 Handle<JSBuiltinsObject> builtins(native_context()->builtins()); |
2673 Runtime::ForceSetObjectProperty(builtins, | 2673 Runtime::DefineObjectProperty(builtins, |
2674 factory()->InternalizeOneByteString( | 2674 factory()->InternalizeOneByteString( |
2675 STATIC_ASCII_VECTOR("rngstate")), | 2675 STATIC_ASCII_VECTOR("rngstate")), |
2676 Utils::OpenHandle(*ta), | 2676 Utils::OpenHandle(*ta), |
2677 NONE).Assert(); | 2677 NONE).Assert(); |
2678 | 2678 |
2679 // Initialize trigonometric lookup tables and constants. | 2679 // Initialize trigonometric lookup tables and constants. |
2680 const int table_num_bytes = TrigonometricLookupTable::table_num_bytes(); | 2680 const int table_num_bytes = TrigonometricLookupTable::table_num_bytes(); |
2681 v8::Local<v8::ArrayBuffer> sin_buffer = v8::ArrayBuffer::New( | 2681 v8::Local<v8::ArrayBuffer> sin_buffer = v8::ArrayBuffer::New( |
2682 reinterpret_cast<v8::Isolate*>(isolate), | 2682 reinterpret_cast<v8::Isolate*>(isolate), |
2683 TrigonometricLookupTable::sin_table(), table_num_bytes); | 2683 TrigonometricLookupTable::sin_table(), table_num_bytes); |
2684 v8::Local<v8::ArrayBuffer> cos_buffer = v8::ArrayBuffer::New( | 2684 v8::Local<v8::ArrayBuffer> cos_buffer = v8::ArrayBuffer::New( |
2685 reinterpret_cast<v8::Isolate*>(isolate), | 2685 reinterpret_cast<v8::Isolate*>(isolate), |
2686 TrigonometricLookupTable::cos_x_interval_table(), table_num_bytes); | 2686 TrigonometricLookupTable::cos_x_interval_table(), table_num_bytes); |
2687 v8::Local<v8::Float64Array> sin_table = v8::Float64Array::New( | 2687 v8::Local<v8::Float64Array> sin_table = v8::Float64Array::New( |
2688 sin_buffer, 0, TrigonometricLookupTable::table_size()); | 2688 sin_buffer, 0, TrigonometricLookupTable::table_size()); |
2689 v8::Local<v8::Float64Array> cos_table = v8::Float64Array::New( | 2689 v8::Local<v8::Float64Array> cos_table = v8::Float64Array::New( |
2690 cos_buffer, 0, TrigonometricLookupTable::table_size()); | 2690 cos_buffer, 0, TrigonometricLookupTable::table_size()); |
2691 | 2691 |
2692 Runtime::ForceSetObjectProperty(builtins, | 2692 Runtime::DefineObjectProperty(builtins, |
2693 factory()->InternalizeOneByteString( | 2693 factory()->InternalizeOneByteString( |
2694 STATIC_ASCII_VECTOR("kSinTable")), | 2694 STATIC_ASCII_VECTOR("kSinTable")), |
2695 Utils::OpenHandle(*sin_table), | 2695 Utils::OpenHandle(*sin_table), |
2696 NONE).Assert(); | 2696 NONE).Assert(); |
2697 Runtime::ForceSetObjectProperty( | 2697 Runtime::DefineObjectProperty( |
2698 builtins, | 2698 builtins, |
2699 factory()->InternalizeOneByteString( | 2699 factory()->InternalizeOneByteString( |
2700 STATIC_ASCII_VECTOR("kCosXIntervalTable")), | 2700 STATIC_ASCII_VECTOR("kCosXIntervalTable")), |
2701 Utils::OpenHandle(*cos_table), | 2701 Utils::OpenHandle(*cos_table), |
2702 NONE).Assert(); | 2702 NONE).Assert(); |
2703 Runtime::ForceSetObjectProperty( | 2703 Runtime::DefineObjectProperty( |
2704 builtins, | 2704 builtins, |
2705 factory()->InternalizeOneByteString( | 2705 factory()->InternalizeOneByteString( |
2706 STATIC_ASCII_VECTOR("kSamples")), | 2706 STATIC_ASCII_VECTOR("kSamples")), |
2707 factory()->NewHeapNumber( | 2707 factory()->NewHeapNumber( |
2708 TrigonometricLookupTable::samples()), | 2708 TrigonometricLookupTable::samples()), |
2709 NONE).Assert(); | 2709 NONE).Assert(); |
2710 Runtime::ForceSetObjectProperty( | 2710 Runtime::DefineObjectProperty( |
2711 builtins, | 2711 builtins, |
2712 factory()->InternalizeOneByteString( | 2712 factory()->InternalizeOneByteString( |
2713 STATIC_ASCII_VECTOR("kIndexConvert")), | 2713 STATIC_ASCII_VECTOR("kIndexConvert")), |
2714 factory()->NewHeapNumber( | 2714 factory()->NewHeapNumber( |
2715 TrigonometricLookupTable::samples_over_pi_half()), | 2715 TrigonometricLookupTable::samples_over_pi_half()), |
2716 NONE).Assert(); | 2716 NONE).Assert(); |
2717 } | 2717 } |
2718 | 2718 |
2719 result_ = native_context(); | 2719 result_ = native_context(); |
2720 } | 2720 } |
(...skipping 21 matching lines...) Expand all Loading... |
2742 return from + sizeof(NestingCounterType); | 2742 return from + sizeof(NestingCounterType); |
2743 } | 2743 } |
2744 | 2744 |
2745 | 2745 |
2746 // Called when the top-level V8 mutex is destroyed. | 2746 // Called when the top-level V8 mutex is destroyed. |
2747 void Bootstrapper::FreeThreadResources() { | 2747 void Bootstrapper::FreeThreadResources() { |
2748 ASSERT(!IsActive()); | 2748 ASSERT(!IsActive()); |
2749 } | 2749 } |
2750 | 2750 |
2751 } } // namespace v8::internal | 2751 } } // namespace v8::internal |
OLD | NEW |