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

Side by Side Diff: src/runtime.cc

Issue 104203003: Remove unused trigonometric code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comment Created 7 years 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/v8-counters.h » ('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 7637 matching lines...) Expand 10 before | Expand all | Expand 10 after
7648 : StringCharacterStreamCompare(isolate->runtime_state(), x, y); 7648 : StringCharacterStreamCompare(isolate->runtime_state(), x, y);
7649 } 7649 }
7650 7650
7651 7651
7652 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_acos) { 7652 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_acos) {
7653 SealHandleScope shs(isolate); 7653 SealHandleScope shs(isolate);
7654 ASSERT(args.length() == 1); 7654 ASSERT(args.length() == 1);
7655 isolate->counters()->math_acos()->Increment(); 7655 isolate->counters()->math_acos()->Increment();
7656 7656
7657 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7657 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7658 return isolate->transcendental_cache()->Get(TranscendentalCache::ACOS, x); 7658 return isolate->heap()->AllocateHeapNumber(acos(x));
7659 } 7659 }
7660 7660
7661 7661
7662 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_asin) { 7662 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_asin) {
7663 SealHandleScope shs(isolate); 7663 SealHandleScope shs(isolate);
7664 ASSERT(args.length() == 1); 7664 ASSERT(args.length() == 1);
7665 isolate->counters()->math_asin()->Increment(); 7665 isolate->counters()->math_asin()->Increment();
7666 7666
7667 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7667 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7668 return isolate->transcendental_cache()->Get(TranscendentalCache::ASIN, x); 7668 return isolate->heap()->AllocateHeapNumber(asin(x));
7669 } 7669 }
7670 7670
7671 7671
7672 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan) { 7672 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan) {
7673 SealHandleScope shs(isolate); 7673 SealHandleScope shs(isolate);
7674 ASSERT(args.length() == 1); 7674 ASSERT(args.length() == 1);
7675 isolate->counters()->math_atan()->Increment(); 7675 isolate->counters()->math_atan()->Increment();
7676 7676
7677 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7677 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7678 return isolate->transcendental_cache()->Get(TranscendentalCache::ATAN, x); 7678 return isolate->heap()->AllocateHeapNumber(atan(x));
7679 } 7679 }
7680 7680
7681 7681
7682 static const double kPiDividedBy4 = 0.78539816339744830962; 7682 static const double kPiDividedBy4 = 0.78539816339744830962;
7683 7683
7684 7684
7685 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan2) { 7685 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan2) {
7686 SealHandleScope shs(isolate); 7686 SealHandleScope shs(isolate);
7687 ASSERT(args.length() == 2); 7687 ASSERT(args.length() == 2);
7688 isolate->counters()->math_atan2()->Increment(); 7688 isolate->counters()->math_atan2()->Increment();
7689 7689
7690 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7690 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7691 CONVERT_DOUBLE_ARG_CHECKED(y, 1); 7691 CONVERT_DOUBLE_ARG_CHECKED(y, 1);
7692 double result; 7692 double result;
7693 if (std::isinf(x) && std::isinf(y)) { 7693 if (std::isinf(x) && std::isinf(y)) {
7694 // Make sure that the result in case of two infinite arguments 7694 // Make sure that the result in case of two infinite arguments
7695 // is a multiple of Pi / 4. The sign of the result is determined 7695 // is a multiple of Pi / 4. The sign of the result is determined
7696 // by the first argument (x) and the sign of the second argument 7696 // by the first argument (x) and the sign of the second argument
7697 // determines the multiplier: one or three. 7697 // determines the multiplier: one or three.
7698 int multiplier = (x < 0) ? -1 : 1; 7698 int multiplier = (x < 0) ? -1 : 1;
7699 if (y < 0) multiplier *= 3; 7699 if (y < 0) multiplier *= 3;
7700 result = multiplier * kPiDividedBy4; 7700 result = multiplier * kPiDividedBy4;
7701 } else { 7701 } else {
7702 result = atan2(x, y); 7702 result = atan2(x, y);
7703 } 7703 }
7704 return isolate->heap()->AllocateHeapNumber(result); 7704 return isolate->heap()->AllocateHeapNumber(result);
7705 } 7705 }
7706 7706
7707 7707
7708 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_cos) {
7709 SealHandleScope shs(isolate);
7710 ASSERT(args.length() == 1);
7711 isolate->counters()->math_cos()->Increment();
7712
7713 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7714 return isolate->transcendental_cache()->Get(TranscendentalCache::COS, x);
7715 }
7716
7717
7718 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_exp) { 7708 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_exp) {
7719 SealHandleScope shs(isolate); 7709 SealHandleScope shs(isolate);
7720 ASSERT(args.length() == 1); 7710 ASSERT(args.length() == 1);
7721 isolate->counters()->math_exp()->Increment(); 7711 isolate->counters()->math_exp()->Increment();
7722 7712
7723 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7713 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7724 lazily_initialize_fast_exp(); 7714 lazily_initialize_fast_exp();
7725 return isolate->heap()->NumberFromDouble(fast_exp(x)); 7715 return isolate->heap()->NumberFromDouble(fast_exp(x));
7726 } 7716 }
7727 7717
7728 7718
7729 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_floor) { 7719 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_floor) {
7730 SealHandleScope shs(isolate); 7720 SealHandleScope shs(isolate);
7731 ASSERT(args.length() == 1); 7721 ASSERT(args.length() == 1);
7732 isolate->counters()->math_floor()->Increment(); 7722 isolate->counters()->math_floor()->Increment();
7733 7723
7734 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7724 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7735 return isolate->heap()->NumberFromDouble(floor(x)); 7725 return isolate->heap()->NumberFromDouble(floor(x));
7736 } 7726 }
7737 7727
7738 7728
7739 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_log) { 7729 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_log) {
7740 SealHandleScope shs(isolate); 7730 SealHandleScope shs(isolate);
7741 ASSERT(args.length() == 1); 7731 ASSERT(args.length() == 1);
7742 isolate->counters()->math_log()->Increment(); 7732 isolate->counters()->math_log()->Increment();
7743 7733
7744 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7734 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7745 return isolate->transcendental_cache()->Get(TranscendentalCache::LOG, x); 7735 return isolate->heap()->AllocateHeapNumber(fast_log(x));
7746 } 7736 }
7747 7737
7748 7738
7749 // Slow version of Math.pow. We check for fast paths for special cases. 7739 // Slow version of Math.pow. We check for fast paths for special cases.
7750 // Used if SSE2/VFP3 is not available. 7740 // Used if SSE2/VFP3 is not available.
7751 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow) { 7741 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow) {
7752 SealHandleScope shs(isolate); 7742 SealHandleScope shs(isolate);
7753 ASSERT(args.length() == 2); 7743 ASSERT(args.length() == 2);
7754 isolate->counters()->math_pow()->Increment(); 7744 isolate->counters()->math_pow()->Increment();
7755 7745
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
7824 return number; 7814 return number;
7825 } 7815 }
7826 7816
7827 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value(); 7817 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value();
7828 7818
7829 // Do not call NumberFromDouble() to avoid extra checks. 7819 // Do not call NumberFromDouble() to avoid extra checks.
7830 return isolate->heap()->AllocateHeapNumber(floor(value + 0.5)); 7820 return isolate->heap()->AllocateHeapNumber(floor(value + 0.5));
7831 } 7821 }
7832 7822
7833 7823
7834 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sin) {
7835 SealHandleScope shs(isolate);
7836 ASSERT(args.length() == 1);
7837 isolate->counters()->math_sin()->Increment();
7838
7839 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7840 return isolate->transcendental_cache()->Get(TranscendentalCache::SIN, x);
7841 }
7842
7843
7844 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sqrt) { 7824 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sqrt) {
7845 SealHandleScope shs(isolate); 7825 SealHandleScope shs(isolate);
7846 ASSERT(args.length() == 1); 7826 ASSERT(args.length() == 1);
7847 isolate->counters()->math_sqrt()->Increment(); 7827 isolate->counters()->math_sqrt()->Increment();
7848 7828
7849 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7829 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7850 return isolate->heap()->AllocateHeapNumber(fast_sqrt(x)); 7830 return isolate->heap()->AllocateHeapNumber(fast_sqrt(x));
7851 } 7831 }
7852 7832
7853 7833
7854 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_tan) {
7855 SealHandleScope shs(isolate);
7856 ASSERT(args.length() == 1);
7857 isolate->counters()->math_tan()->Increment();
7858
7859 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7860 return isolate->transcendental_cache()->Get(TranscendentalCache::TAN, x);
7861 }
7862
7863
7864 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) { 7834 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) {
7865 SealHandleScope shs(isolate); 7835 SealHandleScope shs(isolate);
7866 ASSERT(args.length() == 2); 7836 ASSERT(args.length() == 2);
7867 7837
7868 CONVERT_SMI_ARG_CHECKED(year, 0); 7838 CONVERT_SMI_ARG_CHECKED(year, 0);
7869 CONVERT_SMI_ARG_CHECKED(month, 1); 7839 CONVERT_SMI_ARG_CHECKED(month, 1);
7870 7840
7871 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month)); 7841 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month));
7872 } 7842 }
7873 7843
(...skipping 7041 matching lines...) Expand 10 before | Expand all | Expand 10 after
14915 // Handle last resort GC and make sure to allow future allocations 14885 // Handle last resort GC and make sure to allow future allocations
14916 // to grow the heap without causing GCs (if possible). 14886 // to grow the heap without causing GCs (if possible).
14917 isolate->counters()->gc_last_resort_from_js()->Increment(); 14887 isolate->counters()->gc_last_resort_from_js()->Increment();
14918 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14888 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14919 "Runtime::PerformGC"); 14889 "Runtime::PerformGC");
14920 } 14890 }
14921 } 14891 }
14922 14892
14923 14893
14924 } } // namespace v8::internal 14894 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/v8-counters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698