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 70003004: Reland "Implement Math.sin, cos and tan using table lookup and spline interpolation." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix 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/x64/full-codegen-x64.cc » ('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 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 5361 matching lines...) Expand 10 before | Expand all | Expand 10 after
5372 CONVERT_ARG_CHECKED(Object, object, 0); 5372 CONVERT_ARG_CHECKED(Object, object, 0);
5373 5373
5374 if (object->IsJSFunction()) { 5374 if (object->IsJSFunction()) {
5375 JSFunction* func = JSFunction::cast(object); 5375 JSFunction* func = JSFunction::cast(object);
5376 func->shared()->set_native(true); 5376 func->shared()->set_native(true);
5377 } 5377 }
5378 return isolate->heap()->undefined_value(); 5378 return isolate->heap()->undefined_value();
5379 } 5379 }
5380 5380
5381 5381
5382 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetInlineBuiltinFlag) {
5383 SealHandleScope shs(isolate);
5384 RUNTIME_ASSERT(args.length() == 1);
5385
5386 Handle<Object> object = args.at<Object>(0);
5387
5388 if (object->IsJSFunction()) {
5389 JSFunction* func = JSFunction::cast(*object);
5390 func->shared()->set_inline_builtin(true);
5391 }
5392 return isolate->heap()->undefined_value();
5393 }
5394
5395
5382 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreArrayLiteralElement) { 5396 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreArrayLiteralElement) {
5383 HandleScope scope(isolate); 5397 HandleScope scope(isolate);
5384 RUNTIME_ASSERT(args.length() == 5); 5398 RUNTIME_ASSERT(args.length() == 5);
5385 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); 5399 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
5386 CONVERT_SMI_ARG_CHECKED(store_index, 1); 5400 CONVERT_SMI_ARG_CHECKED(store_index, 1);
5387 Handle<Object> value = args.at<Object>(2); 5401 Handle<Object> value = args.at<Object>(2);
5388 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 3); 5402 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 3);
5389 CONVERT_SMI_ARG_CHECKED(literal_index, 4); 5403 CONVERT_SMI_ARG_CHECKED(literal_index, 4);
5390 5404
5391 Object* raw_literal_cell = literals->get(literal_index); 5405 Object* raw_literal_cell = literals->get(literal_index);
(...skipping 2403 matching lines...) Expand 10 before | Expand all | Expand 10 after
7795 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_tan) { 7809 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_tan) {
7796 SealHandleScope shs(isolate); 7810 SealHandleScope shs(isolate);
7797 ASSERT(args.length() == 1); 7811 ASSERT(args.length() == 1);
7798 isolate->counters()->math_tan()->Increment(); 7812 isolate->counters()->math_tan()->Increment();
7799 7813
7800 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7814 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7801 return isolate->transcendental_cache()->Get(TranscendentalCache::TAN, x); 7815 return isolate->transcendental_cache()->Get(TranscendentalCache::TAN, x);
7802 } 7816 }
7803 7817
7804 7818
7819 RUNTIME_FUNCTION(MaybeObject*, Runtime_PopulateTrigonometricTable) {
7820 HandleScope scope(isolate);
7821 ASSERT(args.length() == 3);
7822 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sin_table, 0);
7823 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, cos_table, 1);
7824 CONVERT_SMI_ARG_CHECKED(samples, 2);
7825 RUNTIME_ASSERT(sin_table->type() == kExternalDoubleArray);
7826 RUNTIME_ASSERT(cos_table->type() == kExternalDoubleArray);
7827 double* sin_buffer = reinterpret_cast<double*>(
7828 JSArrayBuffer::cast(sin_table->buffer())->backing_store());
7829 double* cos_buffer = reinterpret_cast<double*>(
7830 JSArrayBuffer::cast(cos_table->buffer())->backing_store());
7831
7832 static const double pi_half = 3.1415926535897932 / 2;
7833 double interval = pi_half / samples;
7834 for (int i = 0; i < samples + 1; i++) {
7835 double sample = sin(i * interval);
7836 sin_buffer[i] = sample;
7837 cos_buffer[samples - i] = sample * interval;
7838 }
7839
7840 // Fill this to catch out of bound accesses when calculating Math.sin(pi/2).
7841 sin_buffer[samples + 1] = sin(pi_half + interval);
7842 cos_buffer[samples + 1] = cos(pi_half + interval) * interval;
7843
7844 return isolate->heap()->undefined_value();
7845 }
7846
7847
7805 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) { 7848 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) {
7806 SealHandleScope shs(isolate); 7849 SealHandleScope shs(isolate);
7807 ASSERT(args.length() == 2); 7850 ASSERT(args.length() == 2);
7808 7851
7809 CONVERT_SMI_ARG_CHECKED(year, 0); 7852 CONVERT_SMI_ARG_CHECKED(year, 0);
7810 CONVERT_SMI_ARG_CHECKED(month, 1); 7853 CONVERT_SMI_ARG_CHECKED(month, 1);
7811 7854
7812 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month)); 7855 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month));
7813 } 7856 }
7814 7857
(...skipping 6990 matching lines...) Expand 10 before | Expand all | Expand 10 after
14805 // Handle last resort GC and make sure to allow future allocations 14848 // Handle last resort GC and make sure to allow future allocations
14806 // to grow the heap without causing GCs (if possible). 14849 // to grow the heap without causing GCs (if possible).
14807 isolate->counters()->gc_last_resort_from_js()->Increment(); 14850 isolate->counters()->gc_last_resort_from_js()->Increment();
14808 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14851 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14809 "Runtime::PerformGC"); 14852 "Runtime::PerformGC");
14810 } 14853 }
14811 } 14854 }
14812 14855
14813 14856
14814 } } // namespace v8::internal 14857 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698