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

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: 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') | 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 // 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 int to = std::min(offset + kUint32MaxChars, length);
515 {
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 return to == 2 && negative; // Match just '-0'.
525 }
526 // Process positive integers.
527 if (!negative) {
528 uint64_t acc = 0;
529 for (; offset < to; ++offset) {
530 uint64_t digit = buffer[offset] - '0';
531 if (digit > 9) return false;
532 acc = 10 * acc + digit;
533 }
534 // String is consumed. Evaluate what we have.
535 if (offset == length) {
536 return acc >
537 static_cast<uint64_t>(std::numeric_limits<uint32_t>::max());
538 }
539 }
540 }
541 // Consume rest of string. If we get here, we're way out of uint32_t bounds
542 // or negative.
543 int i = offset;
544 while (true) {
545 for (; offset < to; ++offset, ++i) {
546 if (!IsDecimalDigit(buffer[i])) return false;
547 }
548 if (offset == length) break;
549 // Read next chunk.
550 to = std::min(offset + kBufferSize, length);
551 String::WriteToFlat(string, buffer, offset, to);
552 i = 0;
553 }
554 return true;
555 }
505 } } // namespace v8::internal 556 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/conversions.h ('k') | src/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698