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

Unified Diff: src/runtime.cc

Issue 78813003: Add trigonometric table to the snapshot. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« src/math.js ('K') | « src/math.js ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index b5a108159ad81bac2a1ef8a7e28a287751e712c0..4a6b0dee2e08b948663f13a2b53b16d4d9985c76 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -7851,27 +7851,33 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_tan) {
RUNTIME_FUNCTION(MaybeObject*, Runtime_PopulateTrigonometricTable) {
HandleScope scope(isolate);
ASSERT(args.length() == 3);
- CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sin_table, 0);
- CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, cos_table, 1);
+ CONVERT_ARG_HANDLE_CHECKED(JSArray, sin_table, 0);
+ CONVERT_ARG_HANDLE_CHECKED(JSArray, cos_table, 1);
CONVERT_SMI_ARG_CHECKED(samples, 2);
- RUNTIME_ASSERT(sin_table->type() == kExternalDoubleArray);
- RUNTIME_ASSERT(cos_table->type() == kExternalDoubleArray);
- double* sin_buffer = reinterpret_cast<double*>(
- JSArrayBuffer::cast(sin_table->buffer())->backing_store());
- double* cos_buffer = reinterpret_cast<double*>(
- JSArrayBuffer::cast(cos_table->buffer())->backing_store());
+ RUNTIME_ASSERT(sin_table->HasFastDoubleElements());
+ RUNTIME_ASSERT(cos_table->HasFastDoubleElements());
+ // Run only when bootstrapping.
+ RUNTIME_ASSERT(isolate->bootstrapper()->IsActive());
+
+ Handle<FixedDoubleArray> sin_elements(
+ FixedDoubleArray::cast(sin_table->elements()));
+ Handle<FixedDoubleArray> cos_elements(
+ FixedDoubleArray::cast(cos_table->elements()));
+
+ RUNTIME_ASSERT(sin_elements->length() >= samples);
+ RUNTIME_ASSERT(cos_elements->length() >= samples);
static const double pi_half = 3.1415926535897932 / 2;
double interval = pi_half / samples;
for (int i = 0; i < samples + 1; i++) {
double sample = sin(i * interval);
- sin_buffer[i] = sample;
- cos_buffer[samples - i] = sample * interval;
+ sin_elements->set(i, sample);
+ cos_elements->set(samples - i, sample * interval);
}
// Fill this to catch out of bound accesses when calculating Math.sin(pi/2).
- sin_buffer[samples + 1] = sin(pi_half + interval);
- cos_buffer[samples + 1] = cos(pi_half + interval) * interval;
+ sin_elements->set(samples + 1, sin(pi_half + interval));
+ cos_elements->set(samples + 1, cos(pi_half + interval) * interval);
return isolate->heap()->undefined_value();
}
« src/math.js ('K') | « src/math.js ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698