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 11465005: Fix spec violations in methods of Number.prototype. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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 | « no previous file | src/v8natives.js » ('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 3789 matching lines...) Expand 10 before | Expand all | Expand 10 after
3800 DeleteArray(str); 3800 DeleteArray(str);
3801 return result; 3801 return result;
3802 } 3802 }
3803 3803
3804 3804
3805 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToFixed) { 3805 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToFixed) {
3806 NoHandleAllocation ha; 3806 NoHandleAllocation ha;
3807 ASSERT(args.length() == 2); 3807 ASSERT(args.length() == 2);
3808 3808
3809 CONVERT_DOUBLE_ARG_CHECKED(value, 0); 3809 CONVERT_DOUBLE_ARG_CHECKED(value, 0);
3810 if (isnan(value)) {
3811 return *isolate->factory()->nan_symbol();
3812 }
3813 if (isinf(value)) {
3814 if (value < 0) {
3815 return *isolate->factory()->minus_infinity_symbol();
3816 }
3817 return *isolate->factory()->infinity_symbol();
3818 }
3819 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); 3810 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1);
3820 int f = FastD2IChecked(f_number); 3811 int f = FastD2IChecked(f_number);
3821 RUNTIME_ASSERT(f >= 0); 3812 RUNTIME_ASSERT(f >= 0);
3822 char* str = DoubleToFixedCString(value, f); 3813 char* str = DoubleToFixedCString(value, f);
3823 MaybeObject* res = 3814 MaybeObject* res =
3824 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); 3815 isolate->heap()->AllocateStringFromOneByte(CStrVector(str));
3825 DeleteArray(str); 3816 DeleteArray(str);
3826 return res; 3817 return res;
3827 } 3818 }
3828 3819
3829 3820
3830 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToExponential) { 3821 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToExponential) {
3831 NoHandleAllocation ha; 3822 NoHandleAllocation ha;
3832 ASSERT(args.length() == 2); 3823 ASSERT(args.length() == 2);
3833 3824
3834 CONVERT_DOUBLE_ARG_CHECKED(value, 0); 3825 CONVERT_DOUBLE_ARG_CHECKED(value, 0);
3835 if (isnan(value)) {
3836 return *isolate->factory()->nan_symbol();
3837 }
3838 if (isinf(value)) {
3839 if (value < 0) {
3840 return *isolate->factory()->minus_infinity_symbol();
3841 }
3842 return *isolate->factory()->infinity_symbol();
3843 }
3844 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); 3826 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1);
3845 int f = FastD2IChecked(f_number); 3827 int f = FastD2IChecked(f_number);
3846 RUNTIME_ASSERT(f >= -1 && f <= 20); 3828 RUNTIME_ASSERT(f >= -1 && f <= 20);
3847 char* str = DoubleToExponentialCString(value, f); 3829 char* str = DoubleToExponentialCString(value, f);
3848 MaybeObject* res = 3830 MaybeObject* res =
3849 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); 3831 isolate->heap()->AllocateStringFromOneByte(CStrVector(str));
3850 DeleteArray(str); 3832 DeleteArray(str);
3851 return res; 3833 return res;
3852 } 3834 }
3853 3835
3854 3836
3855 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToPrecision) { 3837 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToPrecision) {
3856 NoHandleAllocation ha; 3838 NoHandleAllocation ha;
3857 ASSERT(args.length() == 2); 3839 ASSERT(args.length() == 2);
3858 3840
3859 CONVERT_DOUBLE_ARG_CHECKED(value, 0); 3841 CONVERT_DOUBLE_ARG_CHECKED(value, 0);
3860 if (isnan(value)) {
3861 return *isolate->factory()->nan_symbol();
3862 }
3863 if (isinf(value)) {
3864 if (value < 0) {
3865 return *isolate->factory()->minus_infinity_symbol();
3866 }
3867 return *isolate->factory()->infinity_symbol();
3868 }
3869 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); 3842 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1);
3870 int f = FastD2IChecked(f_number); 3843 int f = FastD2IChecked(f_number);
3871 RUNTIME_ASSERT(f >= 1 && f <= 21); 3844 RUNTIME_ASSERT(f >= 1 && f <= 21);
3872 char* str = DoubleToPrecisionCString(value, f); 3845 char* str = DoubleToPrecisionCString(value, f);
3873 MaybeObject* res = 3846 MaybeObject* res =
3874 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); 3847 isolate->heap()->AllocateStringFromOneByte(CStrVector(str));
3875 DeleteArray(str); 3848 DeleteArray(str);
3876 return res; 3849 return res;
3877 } 3850 }
3878 3851
(...skipping 9672 matching lines...) Expand 10 before | Expand all | Expand 10 after
13551 // Handle last resort GC and make sure to allow future allocations 13524 // Handle last resort GC and make sure to allow future allocations
13552 // to grow the heap without causing GCs (if possible). 13525 // to grow the heap without causing GCs (if possible).
13553 isolate->counters()->gc_last_resort_from_js()->Increment(); 13526 isolate->counters()->gc_last_resort_from_js()->Increment();
13554 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13527 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13555 "Runtime::PerformGC"); 13528 "Runtime::PerformGC");
13556 } 13529 }
13557 } 13530 }
13558 13531
13559 13532
13560 } } // namespace v8::internal 13533 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698