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

Side by Side Diff: src/runtime/runtime-numbers.cc

Issue 654763003: Flatten the string in StringToDouble function. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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/lookup.cc ('k') | test/mjsunit/regress/regress-425551.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 186
187 // Slower case. 187 // Slower case.
188 int flags = ALLOW_HEX; 188 int flags = ALLOW_HEX;
189 if (FLAG_harmony_numeric_literals) { 189 if (FLAG_harmony_numeric_literals) {
190 // The current spec draft has not updated "ToNumber Applied to the String 190 // The current spec draft has not updated "ToNumber Applied to the String
191 // Type", https://bugs.ecmascript.org/show_bug.cgi?id=1584 191 // Type", https://bugs.ecmascript.org/show_bug.cgi?id=1584
192 flags |= ALLOW_OCTAL | ALLOW_BINARY; 192 flags |= ALLOW_OCTAL | ALLOW_BINARY;
193 } 193 }
194 194
195 return *isolate->factory()->NewNumber( 195 return *isolate->factory()->NewNumber(
196 StringToDouble(isolate->unicode_cache(), *subject, flags)); 196 StringToDouble(isolate->unicode_cache(), subject, flags));
197 } 197 }
198 198
199 199
200 RUNTIME_FUNCTION(Runtime_StringParseInt) { 200 RUNTIME_FUNCTION(Runtime_StringParseInt) {
201 HandleScope handle_scope(isolate); 201 HandleScope handle_scope(isolate);
202 DCHECK(args.length() == 2); 202 DCHECK(args.length() == 2);
203 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); 203 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
204 CONVERT_NUMBER_CHECKED(int, radix, Int32, args[1]); 204 CONVERT_NUMBER_CHECKED(int, radix, Int32, args[1]);
205 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36)); 205 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36));
206 206
(...skipping 15 matching lines...) Expand all
222 222
223 return *isolate->factory()->NewNumber(value); 223 return *isolate->factory()->NewNumber(value);
224 } 224 }
225 225
226 226
227 RUNTIME_FUNCTION(Runtime_StringParseFloat) { 227 RUNTIME_FUNCTION(Runtime_StringParseFloat) {
228 HandleScope shs(isolate); 228 HandleScope shs(isolate);
229 DCHECK(args.length() == 1); 229 DCHECK(args.length() == 1);
230 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); 230 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
231 231
232 subject = String::Flatten(subject); 232 double value = StringToDouble(isolate->unicode_cache(), subject,
233 double value = StringToDouble(isolate->unicode_cache(), *subject,
234 ALLOW_TRAILING_JUNK, base::OS::nan_value()); 233 ALLOW_TRAILING_JUNK, base::OS::nan_value());
235 234
236 return *isolate->factory()->NewNumber(value); 235 return *isolate->factory()->NewNumber(value);
237 } 236 }
238 237
239 238
240 RUNTIME_FUNCTION(Runtime_NumberToStringRT) { 239 RUNTIME_FUNCTION(Runtime_NumberToStringRT) {
241 HandleScope scope(isolate); 240 HandleScope scope(isolate);
242 DCHECK(args.length() == 1); 241 DCHECK(args.length() == 1);
243 CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0); 242 CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0);
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 587
589 RUNTIME_FUNCTION(RuntimeReference_IsNonNegativeSmi) { 588 RUNTIME_FUNCTION(RuntimeReference_IsNonNegativeSmi) {
590 SealHandleScope shs(isolate); 589 SealHandleScope shs(isolate);
591 DCHECK(args.length() == 1); 590 DCHECK(args.length() == 1);
592 CONVERT_ARG_CHECKED(Object, obj, 0); 591 CONVERT_ARG_CHECKED(Object, obj, 0);
593 return isolate->heap()->ToBoolean(obj->IsSmi() && 592 return isolate->heap()->ToBoolean(obj->IsSmi() &&
594 Smi::cast(obj)->value() >= 0); 593 Smi::cast(obj)->value() >= 0);
595 } 594 }
596 } 595 }
597 } // namespace v8::internal 596 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/lookup.cc ('k') | test/mjsunit/regress/regress-425551.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698