Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(383)

Side by Side Diff: src/bootstrapper.cc

Issue 411263004: Implement trigonometric functions using a fdlibm port. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « DEPS ('k') | src/math.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 2508 matching lines...) Expand 10 before | Expand all | Expand 10 after
2643 Utils::OpenHandle(*buffer)->set_should_be_freed(true); 2643 Utils::OpenHandle(*buffer)->set_should_be_freed(true);
2644 v8::Local<v8::Uint32Array> ta = v8::Uint32Array::New(buffer, 0, num_elems); 2644 v8::Local<v8::Uint32Array> ta = v8::Uint32Array::New(buffer, 0, num_elems);
2645 Handle<JSBuiltinsObject> builtins(native_context()->builtins()); 2645 Handle<JSBuiltinsObject> builtins(native_context()->builtins());
2646 Runtime::DefineObjectProperty(builtins, 2646 Runtime::DefineObjectProperty(builtins,
2647 factory()->InternalizeOneByteString( 2647 factory()->InternalizeOneByteString(
2648 STATIC_ASCII_VECTOR("rngstate")), 2648 STATIC_ASCII_VECTOR("rngstate")),
2649 Utils::OpenHandle(*ta), 2649 Utils::OpenHandle(*ta),
2650 NONE).Assert(); 2650 NONE).Assert();
2651 2651
2652 // Initialize trigonometric lookup tables and constants. 2652 // Initialize trigonometric lookup tables and constants.
2653 const int table_num_bytes = TrigonometricLookupTable::table_num_bytes(); 2653 const int constants_size = ARRAY_SIZE(TrigonometricConstants::constants);
2654 v8::Local<v8::ArrayBuffer> sin_buffer = v8::ArrayBuffer::New( 2654 const int table_num_bytes = constants_size * kDoubleSize;
2655 v8::Local<v8::ArrayBuffer> trig_buffer = v8::ArrayBuffer::New(
2655 reinterpret_cast<v8::Isolate*>(isolate), 2656 reinterpret_cast<v8::Isolate*>(isolate),
2656 TrigonometricLookupTable::sin_table(), table_num_bytes); 2657 const_cast<double*>(TrigonometricConstants::constants),
2657 v8::Local<v8::ArrayBuffer> cos_buffer = v8::ArrayBuffer::New( 2658 table_num_bytes);
2658 reinterpret_cast<v8::Isolate*>(isolate), 2659 v8::Local<v8::Float64Array> trig_table =
2659 TrigonometricLookupTable::cos_x_interval_table(), table_num_bytes); 2660 v8::Float64Array::New(trig_buffer, 0, constants_size);
2660 v8::Local<v8::Float64Array> sin_table = v8::Float64Array::New(
2661 sin_buffer, 0, TrigonometricLookupTable::table_size());
2662 v8::Local<v8::Float64Array> cos_table = v8::Float64Array::New(
2663 cos_buffer, 0, TrigonometricLookupTable::table_size());
2664 2661
2665 Runtime::DefineObjectProperty(builtins,
2666 factory()->InternalizeOneByteString(
2667 STATIC_ASCII_VECTOR("kSinTable")),
2668 Utils::OpenHandle(*sin_table),
2669 NONE).Assert();
2670 Runtime::DefineObjectProperty( 2662 Runtime::DefineObjectProperty(
2671 builtins, 2663 builtins,
2672 factory()->InternalizeOneByteString( 2664 factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("kTrig")),
2673 STATIC_ASCII_VECTOR("kCosXIntervalTable")), 2665 Utils::OpenHandle(*trig_table), NONE).Assert();
2674 Utils::OpenHandle(*cos_table),
2675 NONE).Assert();
2676 Runtime::DefineObjectProperty(
2677 builtins,
2678 factory()->InternalizeOneByteString(
2679 STATIC_ASCII_VECTOR("kSamples")),
2680 factory()->NewHeapNumber(
2681 TrigonometricLookupTable::samples()),
2682 NONE).Assert();
2683 Runtime::DefineObjectProperty(
2684 builtins,
2685 factory()->InternalizeOneByteString(
2686 STATIC_ASCII_VECTOR("kIndexConvert")),
2687 factory()->NewHeapNumber(
2688 TrigonometricLookupTable::samples_over_pi_half()),
2689 NONE).Assert();
2690 } 2666 }
2691 2667
2692 result_ = native_context(); 2668 result_ = native_context();
2693 } 2669 }
2694 2670
2695 2671
2696 // Support for thread preemption. 2672 // Support for thread preemption.
2697 2673
2698 // Reserve space for statics needing saving and restoring. 2674 // Reserve space for statics needing saving and restoring.
2699 int Bootstrapper::ArchiveSpacePerThread() { 2675 int Bootstrapper::ArchiveSpacePerThread() {
(...skipping 15 matching lines...) Expand all
2715 return from + sizeof(NestingCounterType); 2691 return from + sizeof(NestingCounterType);
2716 } 2692 }
2717 2693
2718 2694
2719 // Called when the top-level V8 mutex is destroyed. 2695 // Called when the top-level V8 mutex is destroyed.
2720 void Bootstrapper::FreeThreadResources() { 2696 void Bootstrapper::FreeThreadResources() {
2721 DCHECK(!IsActive()); 2697 DCHECK(!IsActive());
2722 } 2698 }
2723 2699
2724 } } // namespace v8::internal 2700 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « DEPS ('k') | src/math.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698