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

Side by Side Diff: src/runtime.cc

Issue 2718007: [Isolates] Moving TranscendentalCache to Isolate. (Closed)
Patch Set: Created 10 years, 6 months 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
« no previous file with comments | « src/isolate.cc ('k') | src/x64/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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 5883 matching lines...) Expand 10 before | Expand all | Expand 10 after
5894 : StringInputBufferCompare(x, y); 5894 : StringInputBufferCompare(x, y);
5895 } 5895 }
5896 5896
5897 5897
5898 static Object* Runtime_Math_acos(Arguments args) { 5898 static Object* Runtime_Math_acos(Arguments args) {
5899 NoHandleAllocation ha; 5899 NoHandleAllocation ha;
5900 ASSERT(args.length() == 1); 5900 ASSERT(args.length() == 1);
5901 Counters::math_acos.Increment(); 5901 Counters::math_acos.Increment();
5902 5902
5903 CONVERT_DOUBLE_CHECKED(x, args[0]); 5903 CONVERT_DOUBLE_CHECKED(x, args[0]);
5904 return TranscendentalCache::Get(TranscendentalCache::ACOS, x); 5904 Isolate* const isolate = Isolate::Current();
5905 return isolate->transcendental_cache()->Get(TranscendentalCache::ACOS, x);
5905 } 5906 }
5906 5907
5907 5908
5908 static Object* Runtime_Math_asin(Arguments args) { 5909 static Object* Runtime_Math_asin(Arguments args) {
5909 NoHandleAllocation ha; 5910 NoHandleAllocation ha;
5910 ASSERT(args.length() == 1); 5911 ASSERT(args.length() == 1);
5911 Counters::math_asin.Increment(); 5912 Counters::math_asin.Increment();
5912 5913
5913 CONVERT_DOUBLE_CHECKED(x, args[0]); 5914 CONVERT_DOUBLE_CHECKED(x, args[0]);
5914 return TranscendentalCache::Get(TranscendentalCache::ASIN, x); 5915 Isolate* const isolate = Isolate::Current();
5916 return isolate->transcendental_cache()->Get(TranscendentalCache::ASIN, x);
5915 } 5917 }
5916 5918
5917 5919
5918 static Object* Runtime_Math_atan(Arguments args) { 5920 static Object* Runtime_Math_atan(Arguments args) {
5919 NoHandleAllocation ha; 5921 NoHandleAllocation ha;
5920 ASSERT(args.length() == 1); 5922 ASSERT(args.length() == 1);
5921 Counters::math_atan.Increment(); 5923 Counters::math_atan.Increment();
5922 5924
5923 CONVERT_DOUBLE_CHECKED(x, args[0]); 5925 CONVERT_DOUBLE_CHECKED(x, args[0]);
5924 return TranscendentalCache::Get(TranscendentalCache::ATAN, x); 5926 Isolate* const isolate = Isolate::Current();
5927 return isolate->transcendental_cache()->Get(TranscendentalCache::ATAN, x);
5925 } 5928 }
5926 5929
5927 5930
5928 static Object* Runtime_Math_atan2(Arguments args) { 5931 static Object* Runtime_Math_atan2(Arguments args) {
5929 NoHandleAllocation ha; 5932 NoHandleAllocation ha;
5930 ASSERT(args.length() == 2); 5933 ASSERT(args.length() == 2);
5931 Counters::math_atan2.Increment(); 5934 Counters::math_atan2.Increment();
5932 5935
5933 CONVERT_DOUBLE_CHECKED(x, args[0]); 5936 CONVERT_DOUBLE_CHECKED(x, args[0]);
5934 CONVERT_DOUBLE_CHECKED(y, args[1]); 5937 CONVERT_DOUBLE_CHECKED(y, args[1]);
(...skipping 23 matching lines...) Expand all
5958 return HEAP->NumberFromDouble(ceiling(x)); 5961 return HEAP->NumberFromDouble(ceiling(x));
5959 } 5962 }
5960 5963
5961 5964
5962 static Object* Runtime_Math_cos(Arguments args) { 5965 static Object* Runtime_Math_cos(Arguments args) {
5963 NoHandleAllocation ha; 5966 NoHandleAllocation ha;
5964 ASSERT(args.length() == 1); 5967 ASSERT(args.length() == 1);
5965 Counters::math_cos.Increment(); 5968 Counters::math_cos.Increment();
5966 5969
5967 CONVERT_DOUBLE_CHECKED(x, args[0]); 5970 CONVERT_DOUBLE_CHECKED(x, args[0]);
5968 return TranscendentalCache::Get(TranscendentalCache::COS, x); 5971 Isolate* const isolate = Isolate::Current();
5972 return isolate->transcendental_cache()->Get(TranscendentalCache::COS, x);
5969 } 5973 }
5970 5974
5971 5975
5972 static Object* Runtime_Math_exp(Arguments args) { 5976 static Object* Runtime_Math_exp(Arguments args) {
5973 NoHandleAllocation ha; 5977 NoHandleAllocation ha;
5974 ASSERT(args.length() == 1); 5978 ASSERT(args.length() == 1);
5975 Counters::math_exp.Increment(); 5979 Counters::math_exp.Increment();
5976 5980
5977 CONVERT_DOUBLE_CHECKED(x, args[0]); 5981 CONVERT_DOUBLE_CHECKED(x, args[0]);
5978 return TranscendentalCache::Get(TranscendentalCache::EXP, x); 5982 Isolate* const isolate = Isolate::Current();
5983 return isolate->transcendental_cache()->Get(TranscendentalCache::EXP, x);
5979 } 5984 }
5980 5985
5981 5986
5982 static Object* Runtime_Math_floor(Arguments args) { 5987 static Object* Runtime_Math_floor(Arguments args) {
5983 NoHandleAllocation ha; 5988 NoHandleAllocation ha;
5984 ASSERT(args.length() == 1); 5989 ASSERT(args.length() == 1);
5985 Counters::math_floor.Increment(); 5990 Counters::math_floor.Increment();
5986 5991
5987 CONVERT_DOUBLE_CHECKED(x, args[0]); 5992 CONVERT_DOUBLE_CHECKED(x, args[0]);
5988 return HEAP->NumberFromDouble(floor(x)); 5993 return HEAP->NumberFromDouble(floor(x));
5989 } 5994 }
5990 5995
5991 5996
5992 static Object* Runtime_Math_log(Arguments args) { 5997 static Object* Runtime_Math_log(Arguments args) {
5993 NoHandleAllocation ha; 5998 NoHandleAllocation ha;
5994 ASSERT(args.length() == 1); 5999 ASSERT(args.length() == 1);
5995 Counters::math_log.Increment(); 6000 Counters::math_log.Increment();
5996 6001
5997 CONVERT_DOUBLE_CHECKED(x, args[0]); 6002 CONVERT_DOUBLE_CHECKED(x, args[0]);
5998 return TranscendentalCache::Get(TranscendentalCache::LOG, x); 6003 Isolate* const isolate = Isolate::Current();
6004 return isolate->transcendental_cache()->Get(TranscendentalCache::LOG, x);
5999 } 6005 }
6000 6006
6001 6007
6002 // Helper function to compute x^y, where y is known to be an 6008 // Helper function to compute x^y, where y is known to be an
6003 // integer. Uses binary decomposition to limit the number of 6009 // integer. Uses binary decomposition to limit the number of
6004 // multiplications; see the discussion in "Hacker's Delight" by Henry 6010 // multiplications; see the discussion in "Hacker's Delight" by Henry
6005 // S. Warren, Jr., figure 11-6, page 213. 6011 // S. Warren, Jr., figure 11-6, page 213.
6006 static double powi(double x, int y) { 6012 static double powi(double x, int y) {
6007 ASSERT(y != kMinInt); 6013 ASSERT(y != kMinInt);
6008 unsigned n = (y < 0) ? -y : y; 6014 unsigned n = (y < 0) ? -y : y;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
6120 return HEAP->AllocateHeapNumber(floor(value + 0.5)); 6126 return HEAP->AllocateHeapNumber(floor(value + 0.5));
6121 } 6127 }
6122 6128
6123 6129
6124 static Object* Runtime_Math_sin(Arguments args) { 6130 static Object* Runtime_Math_sin(Arguments args) {
6125 NoHandleAllocation ha; 6131 NoHandleAllocation ha;
6126 ASSERT(args.length() == 1); 6132 ASSERT(args.length() == 1);
6127 Counters::math_sin.Increment(); 6133 Counters::math_sin.Increment();
6128 6134
6129 CONVERT_DOUBLE_CHECKED(x, args[0]); 6135 CONVERT_DOUBLE_CHECKED(x, args[0]);
6130 return TranscendentalCache::Get(TranscendentalCache::SIN, x); 6136 Isolate* const isolate = Isolate::Current();
6137 return isolate->transcendental_cache()->Get(TranscendentalCache::SIN, x);
6131 } 6138 }
6132 6139
6133 6140
6134 static Object* Runtime_Math_sqrt(Arguments args) { 6141 static Object* Runtime_Math_sqrt(Arguments args) {
6135 NoHandleAllocation ha; 6142 NoHandleAllocation ha;
6136 ASSERT(args.length() == 1); 6143 ASSERT(args.length() == 1);
6137 Counters::math_sqrt.Increment(); 6144 Counters::math_sqrt.Increment();
6138 6145
6139 CONVERT_DOUBLE_CHECKED(x, args[0]); 6146 CONVERT_DOUBLE_CHECKED(x, args[0]);
6140 return HEAP->AllocateHeapNumber(sqrt(x)); 6147 return HEAP->AllocateHeapNumber(sqrt(x));
6141 } 6148 }
6142 6149
6143 6150
6144 static Object* Runtime_Math_tan(Arguments args) { 6151 static Object* Runtime_Math_tan(Arguments args) {
6145 NoHandleAllocation ha; 6152 NoHandleAllocation ha;
6146 ASSERT(args.length() == 1); 6153 ASSERT(args.length() == 1);
6147 Counters::math_tan.Increment(); 6154 Counters::math_tan.Increment();
6148 6155
6149 CONVERT_DOUBLE_CHECKED(x, args[0]); 6156 CONVERT_DOUBLE_CHECKED(x, args[0]);
6150 return TranscendentalCache::Get(TranscendentalCache::TAN, x); 6157 Isolate* const isolate = Isolate::Current();
6158 return isolate->transcendental_cache()->Get(TranscendentalCache::TAN, x);
6151 } 6159 }
6152 6160
6153 6161
6154 static int MakeDay(int year, int month, int day) { 6162 static int MakeDay(int year, int month, int day) {
6155 static const int day_from_month[] = {0, 31, 59, 90, 120, 151, 6163 static const int day_from_month[] = {0, 31, 59, 90, 120, 151,
6156 181, 212, 243, 273, 304, 334}; 6164 181, 212, 243, 273, 304, 334};
6157 static const int day_from_month_leap[] = {0, 31, 60, 91, 121, 152, 6165 static const int day_from_month_leap[] = {0, 31, 60, 91, 121, 152,
6158 182, 213, 244, 274, 305, 335}; 6166 182, 213, 244, 274, 305, 335};
6159 6167
6160 year += month / 12; 6168 year += month / 12;
(...skipping 4170 matching lines...) Expand 10 before | Expand all | Expand 10 after
10331 } else { 10339 } else {
10332 // Handle last resort GC and make sure to allow future allocations 10340 // Handle last resort GC and make sure to allow future allocations
10333 // to grow the heap without causing GCs (if possible). 10341 // to grow the heap without causing GCs (if possible).
10334 Counters::gc_last_resort_from_js.Increment(); 10342 Counters::gc_last_resort_from_js.Increment();
10335 HEAP->CollectAllGarbage(false); 10343 HEAP->CollectAllGarbage(false);
10336 } 10344 }
10337 } 10345 }
10338 10346
10339 10347
10340 } } // namespace v8::internal 10348 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | src/x64/codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698