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" |
11 #include "src/extensions/gc-extension.h" | 11 #include "src/extensions/gc-extension.h" |
12 #include "src/extensions/statistics-extension.h" | 12 #include "src/extensions/statistics-extension.h" |
13 #include "src/extensions/trigger-failure-extension.h" | 13 #include "src/extensions/trigger-failure-extension.h" |
14 #include "src/isolate-inl.h" | 14 #include "src/isolate-inl.h" |
15 #include "src/natives.h" | 15 #include "src/natives.h" |
16 #include "src/snapshot.h" | 16 #include "src/snapshot.h" |
17 #include "src/trig-table.h" | 17 #include "third_party/fdlibm/fdlibm.h" |
18 | 18 |
19 namespace v8 { | 19 namespace v8 { |
20 namespace internal { | 20 namespace internal { |
21 | 21 |
22 NativesExternalStringResource::NativesExternalStringResource( | 22 NativesExternalStringResource::NativesExternalStringResource( |
23 Bootstrapper* bootstrapper, | 23 Bootstrapper* bootstrapper, |
24 const char* source, | 24 const char* source, |
25 size_t length) | 25 size_t length) |
26 : data_(source), length_(length) { | 26 : data_(source), length_(length) { |
27 if (bootstrapper->delete_these_non_arrays_on_tear_down_ == NULL) { | 27 if (bootstrapper->delete_these_non_arrays_on_tear_down_ == NULL) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 114 } |
115 delete_these_arrays_on_tear_down_->Add(memory); | 115 delete_these_arrays_on_tear_down_->Add(memory); |
116 } | 116 } |
117 return memory; | 117 return memory; |
118 } | 118 } |
119 | 119 |
120 | 120 |
121 void Bootstrapper::TearDown() { | 121 void Bootstrapper::TearDown() { |
122 if (delete_these_non_arrays_on_tear_down_ != NULL) { | 122 if (delete_these_non_arrays_on_tear_down_ != NULL) { |
123 int len = delete_these_non_arrays_on_tear_down_->length(); | 123 int len = delete_these_non_arrays_on_tear_down_->length(); |
124 DCHECK(len < 24); // Don't use this mechanism for unbounded allocations. | 124 DCHECK(len < 25); // Don't use this mechanism for unbounded allocations. |
125 for (int i = 0; i < len; i++) { | 125 for (int i = 0; i < len; i++) { |
126 delete delete_these_non_arrays_on_tear_down_->at(i); | 126 delete delete_these_non_arrays_on_tear_down_->at(i); |
127 delete_these_non_arrays_on_tear_down_->at(i) = NULL; | 127 delete_these_non_arrays_on_tear_down_->at(i) = NULL; |
128 } | 128 } |
129 delete delete_these_non_arrays_on_tear_down_; | 129 delete delete_these_non_arrays_on_tear_down_; |
130 delete_these_non_arrays_on_tear_down_ = NULL; | 130 delete_these_non_arrays_on_tear_down_ = NULL; |
131 } | 131 } |
132 | 132 |
133 if (delete_these_arrays_on_tear_down_ != NULL) { | 133 if (delete_these_arrays_on_tear_down_ != NULL) { |
134 int len = delete_these_arrays_on_tear_down_->length(); | 134 int len = delete_these_arrays_on_tear_down_->length(); |
(...skipping 2509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2644 Utils::OpenHandle(*buffer)->set_should_be_freed(true); | 2644 Utils::OpenHandle(*buffer)->set_should_be_freed(true); |
2645 v8::Local<v8::Uint32Array> ta = v8::Uint32Array::New(buffer, 0, num_elems); | 2645 v8::Local<v8::Uint32Array> ta = v8::Uint32Array::New(buffer, 0, num_elems); |
2646 Handle<JSBuiltinsObject> builtins(native_context()->builtins()); | 2646 Handle<JSBuiltinsObject> builtins(native_context()->builtins()); |
2647 Runtime::DefineObjectProperty(builtins, | 2647 Runtime::DefineObjectProperty(builtins, |
2648 factory()->InternalizeOneByteString( | 2648 factory()->InternalizeOneByteString( |
2649 STATIC_ASCII_VECTOR("rngstate")), | 2649 STATIC_ASCII_VECTOR("rngstate")), |
2650 Utils::OpenHandle(*ta), | 2650 Utils::OpenHandle(*ta), |
2651 NONE).Assert(); | 2651 NONE).Assert(); |
2652 | 2652 |
2653 // Initialize trigonometric lookup tables and constants. | 2653 // Initialize trigonometric lookup tables and constants. |
2654 const int table_num_bytes = TrigonometricLookupTable::table_num_bytes(); | 2654 const int constants_size = ARRAY_SIZE(TrigonometricConstants::constants); |
2655 v8::Local<v8::ArrayBuffer> sin_buffer = v8::ArrayBuffer::New( | 2655 const int table_num_bytes = constants_size * kDoubleSize; |
| 2656 v8::Local<v8::ArrayBuffer> trig_buffer = v8::ArrayBuffer::New( |
2656 reinterpret_cast<v8::Isolate*>(isolate), | 2657 reinterpret_cast<v8::Isolate*>(isolate), |
2657 TrigonometricLookupTable::sin_table(), table_num_bytes); | 2658 const_cast<double*>(TrigonometricConstants::constants), |
2658 v8::Local<v8::ArrayBuffer> cos_buffer = v8::ArrayBuffer::New( | 2659 table_num_bytes); |
2659 reinterpret_cast<v8::Isolate*>(isolate), | 2660 v8::Local<v8::Float64Array> trig_table = |
2660 TrigonometricLookupTable::cos_x_interval_table(), table_num_bytes); | 2661 v8::Float64Array::New(trig_buffer, 0, constants_size); |
2661 v8::Local<v8::Float64Array> sin_table = v8::Float64Array::New( | |
2662 sin_buffer, 0, TrigonometricLookupTable::table_size()); | |
2663 v8::Local<v8::Float64Array> cos_table = v8::Float64Array::New( | |
2664 cos_buffer, 0, TrigonometricLookupTable::table_size()); | |
2665 | 2662 |
2666 Runtime::DefineObjectProperty(builtins, | |
2667 factory()->InternalizeOneByteString( | |
2668 STATIC_ASCII_VECTOR("kSinTable")), | |
2669 Utils::OpenHandle(*sin_table), | |
2670 NONE).Assert(); | |
2671 Runtime::DefineObjectProperty( | 2663 Runtime::DefineObjectProperty( |
2672 builtins, | 2664 builtins, |
2673 factory()->InternalizeOneByteString( | 2665 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("kTrig")), |
2674 STATIC_ASCII_VECTOR("kCosXIntervalTable")), | 2666 Utils::OpenHandle(*trig_table), NONE).Assert(); |
2675 Utils::OpenHandle(*cos_table), | |
2676 NONE).Assert(); | |
2677 Runtime::DefineObjectProperty( | |
2678 builtins, | |
2679 factory()->InternalizeOneByteString( | |
2680 STATIC_ASCII_VECTOR("kSamples")), | |
2681 factory()->NewHeapNumber( | |
2682 TrigonometricLookupTable::samples()), | |
2683 NONE).Assert(); | |
2684 Runtime::DefineObjectProperty( | |
2685 builtins, | |
2686 factory()->InternalizeOneByteString( | |
2687 STATIC_ASCII_VECTOR("kIndexConvert")), | |
2688 factory()->NewHeapNumber( | |
2689 TrigonometricLookupTable::samples_over_pi_half()), | |
2690 NONE).Assert(); | |
2691 } | 2667 } |
2692 | 2668 |
2693 result_ = native_context(); | 2669 result_ = native_context(); |
2694 } | 2670 } |
2695 | 2671 |
2696 | 2672 |
2697 // Support for thread preemption. | 2673 // Support for thread preemption. |
2698 | 2674 |
2699 // Reserve space for statics needing saving and restoring. | 2675 // Reserve space for statics needing saving and restoring. |
2700 int Bootstrapper::ArchiveSpacePerThread() { | 2676 int Bootstrapper::ArchiveSpacePerThread() { |
(...skipping 15 matching lines...) Expand all Loading... |
2716 return from + sizeof(NestingCounterType); | 2692 return from + sizeof(NestingCounterType); |
2717 } | 2693 } |
2718 | 2694 |
2719 | 2695 |
2720 // Called when the top-level V8 mutex is destroyed. | 2696 // Called when the top-level V8 mutex is destroyed. |
2721 void Bootstrapper::FreeThreadResources() { | 2697 void Bootstrapper::FreeThreadResources() { |
2722 DCHECK(!IsActive()); | 2698 DCHECK(!IsActive()); |
2723 } | 2699 } |
2724 | 2700 |
2725 } } // namespace v8::internal | 2701 } } // namespace v8::internal |
OLD | NEW |