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 2593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2621 Utils::OpenHandle(*buffer)->set_should_be_freed(true); | 2621 Utils::OpenHandle(*buffer)->set_should_be_freed(true); |
2622 v8::Local<v8::Uint32Array> ta = v8::Uint32Array::New(buffer, 0, num_elems); | 2622 v8::Local<v8::Uint32Array> ta = v8::Uint32Array::New(buffer, 0, num_elems); |
2623 Handle<JSBuiltinsObject> builtins(native_context()->builtins()); | 2623 Handle<JSBuiltinsObject> builtins(native_context()->builtins()); |
2624 Runtime::DefineObjectProperty(builtins, | 2624 Runtime::DefineObjectProperty(builtins, |
2625 factory()->InternalizeOneByteString( | 2625 factory()->InternalizeOneByteString( |
2626 STATIC_ASCII_VECTOR("rngstate")), | 2626 STATIC_ASCII_VECTOR("rngstate")), |
2627 Utils::OpenHandle(*ta), | 2627 Utils::OpenHandle(*ta), |
2628 NONE).Assert(); | 2628 NONE).Assert(); |
2629 | 2629 |
2630 // Initialize trigonometric lookup tables and constants. | 2630 // Initialize trigonometric lookup tables and constants. |
2631 const int table_num_bytes = TrigonometricLookupTable::table_num_bytes(); | 2631 const int constants_size = ARRAY_SIZE(TrigonometricConstants::constants); |
2632 v8::Local<v8::ArrayBuffer> sin_buffer = v8::ArrayBuffer::New( | 2632 const int table_num_bytes = constants_size * kDoubleSize; |
| 2633 v8::Local<v8::ArrayBuffer> trig_buffer = v8::ArrayBuffer::New( |
2633 reinterpret_cast<v8::Isolate*>(isolate), | 2634 reinterpret_cast<v8::Isolate*>(isolate), |
2634 TrigonometricLookupTable::sin_table(), table_num_bytes); | 2635 const_cast<double*>(TrigonometricConstants::constants), |
2635 v8::Local<v8::ArrayBuffer> cos_buffer = v8::ArrayBuffer::New( | 2636 table_num_bytes); |
2636 reinterpret_cast<v8::Isolate*>(isolate), | 2637 v8::Local<v8::Float64Array> trig_table = |
2637 TrigonometricLookupTable::cos_x_interval_table(), table_num_bytes); | 2638 v8::Float64Array::New(trig_buffer, 0, constants_size); |
2638 v8::Local<v8::Float64Array> sin_table = v8::Float64Array::New( | |
2639 sin_buffer, 0, TrigonometricLookupTable::table_size()); | |
2640 v8::Local<v8::Float64Array> cos_table = v8::Float64Array::New( | |
2641 cos_buffer, 0, TrigonometricLookupTable::table_size()); | |
2642 | 2639 |
2643 Runtime::DefineObjectProperty(builtins, | |
2644 factory()->InternalizeOneByteString( | |
2645 STATIC_ASCII_VECTOR("kSinTable")), | |
2646 Utils::OpenHandle(*sin_table), | |
2647 NONE).Assert(); | |
2648 Runtime::DefineObjectProperty( | 2640 Runtime::DefineObjectProperty( |
2649 builtins, | 2641 builtins, |
2650 factory()->InternalizeOneByteString( | 2642 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("kTrig")), |
2651 STATIC_ASCII_VECTOR("kCosXIntervalTable")), | 2643 Utils::OpenHandle(*trig_table), NONE).Assert(); |
2652 Utils::OpenHandle(*cos_table), | |
2653 NONE).Assert(); | |
2654 Runtime::DefineObjectProperty( | |
2655 builtins, | |
2656 factory()->InternalizeOneByteString( | |
2657 STATIC_ASCII_VECTOR("kSamples")), | |
2658 factory()->NewHeapNumber( | |
2659 TrigonometricLookupTable::samples()), | |
2660 NONE).Assert(); | |
2661 Runtime::DefineObjectProperty( | |
2662 builtins, | |
2663 factory()->InternalizeOneByteString( | |
2664 STATIC_ASCII_VECTOR("kIndexConvert")), | |
2665 factory()->NewHeapNumber( | |
2666 TrigonometricLookupTable::samples_over_pi_half()), | |
2667 NONE).Assert(); | |
2668 } | 2644 } |
2669 | 2645 |
2670 result_ = native_context(); | 2646 result_ = native_context(); |
2671 } | 2647 } |
2672 | 2648 |
2673 | 2649 |
2674 // Support for thread preemption. | 2650 // Support for thread preemption. |
2675 | 2651 |
2676 // Reserve space for statics needing saving and restoring. | 2652 // Reserve space for statics needing saving and restoring. |
2677 int Bootstrapper::ArchiveSpacePerThread() { | 2653 int Bootstrapper::ArchiveSpacePerThread() { |
(...skipping 15 matching lines...) Expand all Loading... |
2693 return from + sizeof(NestingCounterType); | 2669 return from + sizeof(NestingCounterType); |
2694 } | 2670 } |
2695 | 2671 |
2696 | 2672 |
2697 // Called when the top-level V8 mutex is destroyed. | 2673 // Called when the top-level V8 mutex is destroyed. |
2698 void Bootstrapper::FreeThreadResources() { | 2674 void Bootstrapper::FreeThreadResources() { |
2699 ASSERT(!IsActive()); | 2675 ASSERT(!IsActive()); |
2700 } | 2676 } |
2701 | 2677 |
2702 } } // namespace v8::internal | 2678 } } // namespace v8::internal |
OLD | NEW |