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

Side by Side Diff: src/runtime.cc

Issue 7992002: Improve Hydrogen code for accessing undefined/null/Infinity. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « src/hydrogen.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 3920 matching lines...) Expand 10 before | Expand all | Expand 10 after
3931 // Character array used for conversion. 3931 // Character array used for conversion.
3932 static const char kCharTable[] = "0123456789abcdefghijklmnopqrstuvwxyz"; 3932 static const char kCharTable[] = "0123456789abcdefghijklmnopqrstuvwxyz";
3933 return isolate->heap()-> 3933 return isolate->heap()->
3934 LookupSingleCharacterStringFromCode(kCharTable[value]); 3934 LookupSingleCharacterStringFromCode(kCharTable[value]);
3935 } 3935 }
3936 } 3936 }
3937 3937
3938 // Slow case. 3938 // Slow case.
3939 CONVERT_DOUBLE_ARG_CHECKED(value, 0); 3939 CONVERT_DOUBLE_ARG_CHECKED(value, 0);
3940 if (isnan(value)) { 3940 if (isnan(value)) {
3941 return isolate->heap()->AllocateStringFromAscii(CStrVector("NaN")); 3941 return *isolate->factory()->nan_symbol();
3942 } 3942 }
3943 if (isinf(value)) { 3943 if (isinf(value)) {
3944 if (value < 0) { 3944 if (value < 0) {
3945 return isolate->heap()->AllocateStringFromAscii(CStrVector("-Infinity")); 3945 return *isolate->factory()->minus_infinity_symbol();
3946 } 3946 }
3947 return isolate->heap()->AllocateStringFromAscii(CStrVector("Infinity")); 3947 return *isolate->factory()->infinity_symbol();
3948 } 3948 }
3949 char* str = DoubleToRadixCString(value, radix); 3949 char* str = DoubleToRadixCString(value, radix);
3950 MaybeObject* result = 3950 MaybeObject* result =
3951 isolate->heap()->AllocateStringFromAscii(CStrVector(str)); 3951 isolate->heap()->AllocateStringFromAscii(CStrVector(str));
3952 DeleteArray(str); 3952 DeleteArray(str);
3953 return result; 3953 return result;
3954 } 3954 }
3955 3955
3956 3956
3957 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToFixed) { 3957 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToFixed) {
3958 NoHandleAllocation ha; 3958 NoHandleAllocation ha;
3959 ASSERT(args.length() == 2); 3959 ASSERT(args.length() == 2);
3960 3960
3961 CONVERT_DOUBLE_ARG_CHECKED(value, 0); 3961 CONVERT_DOUBLE_ARG_CHECKED(value, 0);
3962 if (isnan(value)) { 3962 if (isnan(value)) {
3963 return isolate->heap()->AllocateStringFromAscii(CStrVector("NaN")); 3963 return *isolate->factory()->nan_symbol();
3964 } 3964 }
3965 if (isinf(value)) { 3965 if (isinf(value)) {
3966 if (value < 0) { 3966 if (value < 0) {
3967 return isolate->heap()->AllocateStringFromAscii(CStrVector("-Infinity")); 3967 return *isolate->factory()->minus_infinity_symbol();
3968 } 3968 }
3969 return isolate->heap()->AllocateStringFromAscii(CStrVector("Infinity")); 3969 return *isolate->factory()->infinity_symbol();
3970 } 3970 }
3971 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); 3971 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1);
3972 int f = FastD2I(f_number); 3972 int f = FastD2I(f_number);
3973 RUNTIME_ASSERT(f >= 0); 3973 RUNTIME_ASSERT(f >= 0);
3974 char* str = DoubleToFixedCString(value, f); 3974 char* str = DoubleToFixedCString(value, f);
3975 MaybeObject* res = 3975 MaybeObject* res =
3976 isolate->heap()->AllocateStringFromAscii(CStrVector(str)); 3976 isolate->heap()->AllocateStringFromAscii(CStrVector(str));
3977 DeleteArray(str); 3977 DeleteArray(str);
3978 return res; 3978 return res;
3979 } 3979 }
3980 3980
3981 3981
3982 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToExponential) { 3982 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToExponential) {
3983 NoHandleAllocation ha; 3983 NoHandleAllocation ha;
3984 ASSERT(args.length() == 2); 3984 ASSERT(args.length() == 2);
3985 3985
3986 CONVERT_DOUBLE_ARG_CHECKED(value, 0); 3986 CONVERT_DOUBLE_ARG_CHECKED(value, 0);
3987 if (isnan(value)) { 3987 if (isnan(value)) {
3988 return isolate->heap()->AllocateStringFromAscii(CStrVector("NaN")); 3988 return *isolate->factory()->nan_symbol();
3989 } 3989 }
3990 if (isinf(value)) { 3990 if (isinf(value)) {
3991 if (value < 0) { 3991 if (value < 0) {
3992 return isolate->heap()->AllocateStringFromAscii(CStrVector("-Infinity")); 3992 return *isolate->factory()->minus_infinity_symbol();
3993 } 3993 }
3994 return isolate->heap()->AllocateStringFromAscii(CStrVector("Infinity")); 3994 return *isolate->factory()->infinity_symbol();
3995 } 3995 }
3996 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); 3996 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1);
3997 int f = FastD2I(f_number); 3997 int f = FastD2I(f_number);
3998 RUNTIME_ASSERT(f >= -1 && f <= 20); 3998 RUNTIME_ASSERT(f >= -1 && f <= 20);
3999 char* str = DoubleToExponentialCString(value, f); 3999 char* str = DoubleToExponentialCString(value, f);
4000 MaybeObject* res = 4000 MaybeObject* res =
4001 isolate->heap()->AllocateStringFromAscii(CStrVector(str)); 4001 isolate->heap()->AllocateStringFromAscii(CStrVector(str));
4002 DeleteArray(str); 4002 DeleteArray(str);
4003 return res; 4003 return res;
4004 } 4004 }
4005 4005
4006 4006
4007 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToPrecision) { 4007 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToPrecision) {
4008 NoHandleAllocation ha; 4008 NoHandleAllocation ha;
4009 ASSERT(args.length() == 2); 4009 ASSERT(args.length() == 2);
4010 4010
4011 CONVERT_DOUBLE_ARG_CHECKED(value, 0); 4011 CONVERT_DOUBLE_ARG_CHECKED(value, 0);
4012 if (isnan(value)) { 4012 if (isnan(value)) {
4013 return isolate->heap()->AllocateStringFromAscii(CStrVector("NaN")); 4013 return *isolate->factory()->nan_symbol();
4014 } 4014 }
4015 if (isinf(value)) { 4015 if (isinf(value)) {
4016 if (value < 0) { 4016 if (value < 0) {
4017 return isolate->heap()->AllocateStringFromAscii(CStrVector("-Infinity")); 4017 return *isolate->factory()->minus_infinity_symbol();
4018 } 4018 }
4019 return isolate->heap()->AllocateStringFromAscii(CStrVector("Infinity")); 4019 return *isolate->factory()->infinity_symbol();
4020 } 4020 }
4021 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); 4021 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1);
4022 int f = FastD2I(f_number); 4022 int f = FastD2I(f_number);
4023 RUNTIME_ASSERT(f >= 1 && f <= 21); 4023 RUNTIME_ASSERT(f >= 1 && f <= 21);
4024 char* str = DoubleToPrecisionCString(value, f); 4024 char* str = DoubleToPrecisionCString(value, f);
4025 MaybeObject* res = 4025 MaybeObject* res =
4026 isolate->heap()->AllocateStringFromAscii(CStrVector(str)); 4026 isolate->heap()->AllocateStringFromAscii(CStrVector(str));
4027 DeleteArray(str); 4027 DeleteArray(str);
4028 return res; 4028 return res;
4029 } 4029 }
(...skipping 9176 matching lines...) Expand 10 before | Expand all | Expand 10 after
13206 } else { 13206 } else {
13207 // Handle last resort GC and make sure to allow future allocations 13207 // Handle last resort GC and make sure to allow future allocations
13208 // to grow the heap without causing GCs (if possible). 13208 // to grow the heap without causing GCs (if possible).
13209 isolate->counters()->gc_last_resort_from_js()->Increment(); 13209 isolate->counters()->gc_last_resort_from_js()->Increment();
13210 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); 13210 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags);
13211 } 13211 }
13212 } 13212 }
13213 13213
13214 13214
13215 } } // namespace v8::internal 13215 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698