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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 7833 matching lines...) Expand 10 before | Expand all | Expand 10 after
7844 isolate->counters()->math_tan()->Increment(); 7844 isolate->counters()->math_tan()->Increment();
7845 7845
7846 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7846 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7847 return isolate->transcendental_cache()->Get(TranscendentalCache::TAN, x); 7847 return isolate->transcendental_cache()->Get(TranscendentalCache::TAN, x);
7848 } 7848 }
7849 7849
7850 7850
7851 RUNTIME_FUNCTION(MaybeObject*, Runtime_PopulateTrigonometricTable) { 7851 RUNTIME_FUNCTION(MaybeObject*, Runtime_PopulateTrigonometricTable) {
7852 HandleScope scope(isolate); 7852 HandleScope scope(isolate);
7853 ASSERT(args.length() == 3); 7853 ASSERT(args.length() == 3);
7854 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sin_table, 0); 7854 CONVERT_ARG_HANDLE_CHECKED(JSArray, sin_table, 0);
7855 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, cos_table, 1); 7855 CONVERT_ARG_HANDLE_CHECKED(JSArray, cos_table, 1);
7856 CONVERT_SMI_ARG_CHECKED(samples, 2); 7856 CONVERT_SMI_ARG_CHECKED(samples, 2);
7857 RUNTIME_ASSERT(sin_table->type() == kExternalDoubleArray); 7857 RUNTIME_ASSERT(sin_table->HasFastDoubleElements());
7858 RUNTIME_ASSERT(cos_table->type() == kExternalDoubleArray); 7858 RUNTIME_ASSERT(cos_table->HasFastDoubleElements());
7859 double* sin_buffer = reinterpret_cast<double*>( 7859 // Run only when bootstrapping.
7860 JSArrayBuffer::cast(sin_table->buffer())->backing_store()); 7860 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive());
7861 double* cos_buffer = reinterpret_cast<double*>( 7861
7862 JSArrayBuffer::cast(cos_table->buffer())->backing_store()); 7862 Handle<FixedDoubleArray> sin_elements(
7863 FixedDoubleArray::cast(sin_table->elements()));
7864 Handle<FixedDoubleArray> cos_elements(
7865 FixedDoubleArray::cast(cos_table->elements()));
7866
7867 RUNTIME_ASSERT(sin_elements->length() >= samples);
7868 RUNTIME_ASSERT(cos_elements->length() >= samples);
7863 7869
7864 static const double pi_half = 3.1415926535897932 / 2; 7870 static const double pi_half = 3.1415926535897932 / 2;
7865 double interval = pi_half / samples; 7871 double interval = pi_half / samples;
7866 for (int i = 0; i < samples + 1; i++) { 7872 for (int i = 0; i < samples + 1; i++) {
7867 double sample = sin(i * interval); 7873 double sample = sin(i * interval);
7868 sin_buffer[i] = sample; 7874 sin_elements->set(i, sample);
7869 cos_buffer[samples - i] = sample * interval; 7875 cos_elements->set(samples - i, sample * interval);
7870 } 7876 }
7871 7877
7872 // Fill this to catch out of bound accesses when calculating Math.sin(pi/2). 7878 // Fill this to catch out of bound accesses when calculating Math.sin(pi/2).
7873 sin_buffer[samples + 1] = sin(pi_half + interval); 7879 sin_elements->set(samples + 1, sin(pi_half + interval));
7874 cos_buffer[samples + 1] = cos(pi_half + interval) * interval; 7880 cos_elements->set(samples + 1, cos(pi_half + interval) * interval);
7875 7881
7876 return isolate->heap()->undefined_value(); 7882 return isolate->heap()->undefined_value();
7877 } 7883 }
7878 7884
7879 7885
7880 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) { 7886 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) {
7881 SealHandleScope shs(isolate); 7887 SealHandleScope shs(isolate);
7882 ASSERT(args.length() == 2); 7888 ASSERT(args.length() == 2);
7883 7889
7884 CONVERT_SMI_ARG_CHECKED(year, 0); 7890 CONVERT_SMI_ARG_CHECKED(year, 0);
(...skipping 7032 matching lines...) Expand 10 before | Expand all | Expand 10 after
14917 // Handle last resort GC and make sure to allow future allocations 14923 // Handle last resort GC and make sure to allow future allocations
14918 // to grow the heap without causing GCs (if possible). 14924 // to grow the heap without causing GCs (if possible).
14919 isolate->counters()->gc_last_resort_from_js()->Increment(); 14925 isolate->counters()->gc_last_resort_from_js()->Increment();
14920 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14926 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14921 "Runtime::PerformGC"); 14927 "Runtime::PerformGC");
14922 } 14928 }
14923 } 14929 }
14924 14930
14925 14931
14926 } } // namespace v8::internal 14932 } } // namespace v8::internal
OLDNEW
« 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