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

Side by Side Diff: src/runtime.cc

Issue 2223003: Fix: make string indexing work with Infinity. (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/runtime.h ('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 5269 matching lines...) Expand 10 before | Expand all | Expand 10 after
5280 CONVERT_DOUBLE_CHECKED(number, args[0]); 5280 CONVERT_DOUBLE_CHECKED(number, args[0]);
5281 5281
5282 // We do not include 0 so that we don't have to treat +0 / -0 cases. 5282 // We do not include 0 so that we don't have to treat +0 / -0 cases.
5283 if (number > 0 && number <= Smi::kMaxValue) { 5283 if (number > 0 && number <= Smi::kMaxValue) {
5284 return Smi::FromInt(static_cast<int>(number)); 5284 return Smi::FromInt(static_cast<int>(number));
5285 } 5285 }
5286 return Heap::NumberFromDouble(DoubleToInteger(number)); 5286 return Heap::NumberFromDouble(DoubleToInteger(number));
5287 } 5287 }
5288 5288
5289 5289
5290 static Object* Runtime_NumberToIntegerMapMinusZero(Arguments args) {
5291 NoHandleAllocation ha;
5292 ASSERT(args.length() == 1);
5293
5294 CONVERT_DOUBLE_CHECKED(number, args[0]);
5295
5296 // We do not include 0 so that we don't have to treat +0 / -0 cases.
5297 if (number > 0 && number <= Smi::kMaxValue) {
5298 return Smi::FromInt(static_cast<int>(number));
5299 }
5300
5301 double double_value = DoubleToInteger(number);
5302 // Map both -0 and +0 to +0.
5303 if (double_value == 0) double_value = 0;
5304
5305 return Heap::NumberFromDouble(double_value);
5306 }
5307
5308
5290 static Object* Runtime_NumberToJSUint32(Arguments args) { 5309 static Object* Runtime_NumberToJSUint32(Arguments args) {
5291 NoHandleAllocation ha; 5310 NoHandleAllocation ha;
5292 ASSERT(args.length() == 1); 5311 ASSERT(args.length() == 1);
5293 5312
5294 CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]); 5313 CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]);
5295 return Heap::NumberFromUint32(number); 5314 return Heap::NumberFromUint32(number);
5296 } 5315 }
5297 5316
5298 5317
5299 static Object* Runtime_NumberToJSInt32(Arguments args) { 5318 static Object* Runtime_NumberToJSInt32(Arguments args) {
(...skipping 4929 matching lines...) Expand 10 before | Expand all | Expand 10 after
10229 } else { 10248 } else {
10230 // Handle last resort GC and make sure to allow future allocations 10249 // Handle last resort GC and make sure to allow future allocations
10231 // to grow the heap without causing GCs (if possible). 10250 // to grow the heap without causing GCs (if possible).
10232 Counters::gc_last_resort_from_js.Increment(); 10251 Counters::gc_last_resort_from_js.Increment();
10233 Heap::CollectAllGarbage(false); 10252 Heap::CollectAllGarbage(false);
10234 } 10253 }
10235 } 10254 }
10236 10255
10237 10256
10238 } } // namespace v8::internal 10257 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/x64/codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698