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

Side by Side Diff: src/runtime.cc

Issue 78873006: Embed trigonometric lookup table. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: tiny fixes 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
« no previous file with comments | « src/runtime.h ('k') | src/trig-table.h » ('j') | src/trig-table.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7830 matching lines...) Expand 10 before | Expand all | Expand 10 after
7841 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_tan) { 7841 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_tan) {
7842 SealHandleScope shs(isolate); 7842 SealHandleScope shs(isolate);
7843 ASSERT(args.length() == 1); 7843 ASSERT(args.length() == 1);
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) {
7852 HandleScope scope(isolate);
7853 ASSERT(args.length() == 3);
7854 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sin_table, 0);
7855 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, cos_table, 1);
7856 CONVERT_SMI_ARG_CHECKED(samples, 2);
7857 RUNTIME_ASSERT(sin_table->type() == kExternalDoubleArray);
7858 RUNTIME_ASSERT(cos_table->type() == kExternalDoubleArray);
7859 double* sin_buffer = reinterpret_cast<double*>(
7860 JSArrayBuffer::cast(sin_table->buffer())->backing_store());
7861 double* cos_buffer = reinterpret_cast<double*>(
7862 JSArrayBuffer::cast(cos_table->buffer())->backing_store());
7863
7864 static const double pi_half = 3.1415926535897932 / 2;
7865 double interval = pi_half / samples;
7866 for (int i = 0; i < samples + 1; i++) {
7867 double sample = sin(i * interval);
7868 sin_buffer[i] = sample;
7869 cos_buffer[samples - i] = sample * interval;
7870 }
7871
7872 // Fill this to catch out of bound accesses when calculating Math.sin(pi/2).
7873 sin_buffer[samples + 1] = sin(pi_half + interval);
7874 cos_buffer[samples + 1] = cos(pi_half + interval) * interval;
7875
7876 return isolate->heap()->undefined_value();
7877 }
7878
7879
7880 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) { 7851 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) {
7881 SealHandleScope shs(isolate); 7852 SealHandleScope shs(isolate);
7882 ASSERT(args.length() == 2); 7853 ASSERT(args.length() == 2);
7883 7854
7884 CONVERT_SMI_ARG_CHECKED(year, 0); 7855 CONVERT_SMI_ARG_CHECKED(year, 0);
7885 CONVERT_SMI_ARG_CHECKED(month, 1); 7856 CONVERT_SMI_ARG_CHECKED(month, 1);
7886 7857
7887 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month)); 7858 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month));
7888 } 7859 }
7889 7860
(...skipping 7027 matching lines...) Expand 10 before | Expand all | Expand 10 after
14917 // Handle last resort GC and make sure to allow future allocations 14888 // Handle last resort GC and make sure to allow future allocations
14918 // to grow the heap without causing GCs (if possible). 14889 // to grow the heap without causing GCs (if possible).
14919 isolate->counters()->gc_last_resort_from_js()->Increment(); 14890 isolate->counters()->gc_last_resort_from_js()->Increment();
14920 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14891 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14921 "Runtime::PerformGC"); 14892 "Runtime::PerformGC");
14922 } 14893 }
14923 } 14894 }
14924 14895
14925 14896
14926 } } // namespace v8::internal 14897 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/trig-table.h » ('j') | src/trig-table.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698