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

Side by Side Diff: src/conversions.cc

Issue 992913002: handle the special snowflakes that are Integer Indexed Exotic objects (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix PropertyAccessInfo Created 5 years, 9 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/conversions.h ('k') | src/hydrogen.h » ('j') | src/lookup.cc » ('J')
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 // 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 <limits.h> 5 #include <limits.h>
6 #include <stdarg.h> 6 #include <stdarg.h>
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "src/v8.h" 9 #include "src/v8.h"
10 10
11 #include "src/assert-scope.h" 11 #include "src/assert-scope.h"
12 #include "src/char-predicates-inl.h"
12 #include "src/conversions-inl.h" 13 #include "src/conversions-inl.h"
13 #include "src/conversions.h" 14 #include "src/conversions.h"
14 #include "src/dtoa.h" 15 #include "src/dtoa.h"
15 #include "src/factory.h" 16 #include "src/factory.h"
16 #include "src/list-inl.h" 17 #include "src/list-inl.h"
17 #include "src/strtod.h" 18 #include "src/strtod.h"
18 #include "src/utils.h" 19 #include "src/utils.h"
19 20
20 #ifndef _STLP_VENDOR_CSTD 21 #ifndef _STLP_VENDOR_CSTD
21 // STLPort doesn't import fpclassify into the std namespace. 22 // STLPort doesn't import fpclassify into the std namespace.
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 return StringToDouble(unicode_cache, flat.ToOneByteVector(), flags, 496 return StringToDouble(unicode_cache, flat.ToOneByteVector(), flags,
496 empty_string_val); 497 empty_string_val);
497 } else { 498 } else {
498 return StringToDouble(unicode_cache, flat.ToUC16Vector(), flags, 499 return StringToDouble(unicode_cache, flat.ToUC16Vector(), flags,
499 empty_string_val); 500 empty_string_val);
500 } 501 }
501 } 502 }
502 } 503 }
503 504
504 505
506 bool IsNonArrayIndexInteger(String* string) {
507 const int kBufferSize = 64;
508 const int kUint32MaxChars = 11;
509 uint16_t buffer[kBufferSize];
510 int offset = 0;
511 const int length = string->length();
512 DCHECK_NE(0, length);
513 // First iteration, check for minus, 0 followed by anything else, etc.
514 {
515 int to = std::min(offset + kUint32MaxChars, length);
516 String::WriteToFlat(string, buffer, offset, to);
517 bool negative = false;
518 if (buffer[offset] == '-') {
519 negative = true;
520 ++offset;
521 if (offset == to) return false; // Just '-' is bad.
522 }
523 if (buffer[offset] == '0') {
524 ++offset;
525 return offset == 2 && offset == to; // Match just '-0'.
Toon Verwaest 2015/03/10 14:26:09 Quite some boilerplate pretending to be in a loop
526 }
527 uint64_t acc = 0;
Toon Verwaest 2015/03/10 14:26:10 Wrap the entire "fast-path" into if (!negative) {.
528 for (; offset < to; ++offset) {
529 uint64_t digit = buffer[offset] - '0';
530 if (digit > 9) return false;
531 acc = 10 * acc + digit;
532 }
533 // String is consumed. Evaluate what we have.
534 if (offset == length) {
535 if (negative) return true;
536 return acc > static_cast<uint64_t>(std::numeric_limits<uint32_t>::max());
537 }
538 }
539 // Consume rest of string. If we get here, we're way out of uint32_t bounds.
540 while (offset != length) {
541 int to = std::min(offset + kBufferSize, length);
542 String::WriteToFlat(string, buffer, offset, to);
543 for (; offset < to; ++offset) {
544 if (!IsDecimalDigit(buffer[offset])) return false;
545 }
546 }
547 return true;
548 }
505 } } // namespace v8::internal 549 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/conversions.h ('k') | src/hydrogen.h » ('j') | src/lookup.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698