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 "third_party/fdlibm/fdlibm.h" | 17 #include "src/trig-table.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 < 25); // Don't use this mechanism for unbounded allocations. | 124 DCHECK(len < 24); // 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 constants_size = ARRAY_SIZE(TrigonometricConstants::constants); | 2654 const int table_num_bytes = TrigonometricLookupTable::table_num_bytes(); |
2655 const int table_num_bytes = constants_size * kDoubleSize; | 2655 v8::Local<v8::ArrayBuffer> sin_buffer = v8::ArrayBuffer::New( |
2656 v8::Local<v8::ArrayBuffer> trig_buffer = v8::ArrayBuffer::New( | |
2657 reinterpret_cast<v8::Isolate*>(isolate), | 2656 reinterpret_cast<v8::Isolate*>(isolate), |
2658 const_cast<double*>(TrigonometricConstants::constants), | 2657 TrigonometricLookupTable::sin_table(), table_num_bytes); |
2659 table_num_bytes); | 2658 v8::Local<v8::ArrayBuffer> cos_buffer = v8::ArrayBuffer::New( |
2660 v8::Local<v8::Float64Array> trig_table = | 2659 reinterpret_cast<v8::Isolate*>(isolate), |
2661 v8::Float64Array::New(trig_buffer, 0, constants_size); | 2660 TrigonometricLookupTable::cos_x_interval_table(), table_num_bytes); |
| 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()); |
2662 | 2665 |
| 2666 Runtime::DefineObjectProperty(builtins, |
| 2667 factory()->InternalizeOneByteString( |
| 2668 STATIC_ASCII_VECTOR("kSinTable")), |
| 2669 Utils::OpenHandle(*sin_table), |
| 2670 NONE).Assert(); |
2663 Runtime::DefineObjectProperty( | 2671 Runtime::DefineObjectProperty( |
2664 builtins, | 2672 builtins, |
2665 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("kTrig")), | 2673 factory()->InternalizeOneByteString( |
2666 Utils::OpenHandle(*trig_table), NONE).Assert(); | 2674 STATIC_ASCII_VECTOR("kCosXIntervalTable")), |
| 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(); |
2667 } | 2691 } |
2668 | 2692 |
2669 result_ = native_context(); | 2693 result_ = native_context(); |
2670 } | 2694 } |
2671 | 2695 |
2672 | 2696 |
2673 // Support for thread preemption. | 2697 // Support for thread preemption. |
2674 | 2698 |
2675 // Reserve space for statics needing saving and restoring. | 2699 // Reserve space for statics needing saving and restoring. |
2676 int Bootstrapper::ArchiveSpacePerThread() { | 2700 int Bootstrapper::ArchiveSpacePerThread() { |
(...skipping 15 matching lines...) Expand all Loading... |
2692 return from + sizeof(NestingCounterType); | 2716 return from + sizeof(NestingCounterType); |
2693 } | 2717 } |
2694 | 2718 |
2695 | 2719 |
2696 // Called when the top-level V8 mutex is destroyed. | 2720 // Called when the top-level V8 mutex is destroyed. |
2697 void Bootstrapper::FreeThreadResources() { | 2721 void Bootstrapper::FreeThreadResources() { |
2698 DCHECK(!IsActive()); | 2722 DCHECK(!IsActive()); |
2699 } | 2723 } |
2700 | 2724 |
2701 } } // namespace v8::internal | 2725 } } // namespace v8::internal |
OLD | NEW |