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

Side by Side Diff: src/objects.cc

Issue 314603004: Parser: Delay internalizing strings and values. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/interface.cc ('k') | src/parser.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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/accessors.h" 7 #include "src/accessors.h"
8 #include "src/allocation-site-scopes.h" 8 #include "src/allocation-site-scopes.h"
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/arguments.h" 10 #include "src/arguments.h"
(...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after
1709 } 1709 }
1710 break; 1710 break;
1711 default: 1711 default:
1712 PrintF("Unknown type: %d\n", type); 1712 PrintF("Unknown type: %d\n", type);
1713 UNREACHABLE(); 1713 UNREACHABLE();
1714 } 1714 }
1715 } 1715 }
1716 1716
1717 1717
1718 bool HeapNumber::HeapNumberBooleanValue() { 1718 bool HeapNumber::HeapNumberBooleanValue() {
1719 // NaN, +0, and -0 should return the false object 1719 return DoubleToBoolean(value());
1720 #if __BYTE_ORDER == __LITTLE_ENDIAN
1721 union IeeeDoubleLittleEndianArchType u;
1722 #elif __BYTE_ORDER == __BIG_ENDIAN
1723 union IeeeDoubleBigEndianArchType u;
1724 #endif
1725 u.d = value();
1726 if (u.bits.exp == 2047) {
1727 // Detect NaN for IEEE double precision floating point.
1728 if ((u.bits.man_low | u.bits.man_high) != 0) return false;
1729 }
1730 if (u.bits.exp == 0) {
1731 // Detect +0, and -0 for IEEE double precision floating point.
1732 if ((u.bits.man_low | u.bits.man_high) == 0) return false;
1733 }
1734 return true;
1735 } 1720 }
1736 1721
1737 1722
1738 void HeapNumber::HeapNumberPrint(FILE* out) { 1723 void HeapNumber::HeapNumberPrint(FILE* out) {
1739 PrintF(out, "%.16g", Number()); 1724 PrintF(out, "%.16g", Number());
1740 } 1725 }
1741 1726
1742 1727
1743 void HeapNumber::HeapNumberPrint(StringStream* accumulator) { 1728 void HeapNumber::HeapNumberPrint(StringStream* accumulator) {
1744 // The Windows version of vsnprintf can allocate when printing a %g string 1729 // The Windows version of vsnprintf can allocate when printing a %g string
(...skipping 7600 matching lines...) Expand 10 before | Expand all | Expand 10 after
9345 ASSERT(result != 0); // Ensure that the hash value of 0 is never computed. 9330 ASSERT(result != 0); // Ensure that the hash value of 0 is never computed.
9346 return result; 9331 return result;
9347 } 9332 }
9348 9333
9349 9334
9350 bool String::ComputeArrayIndex(uint32_t* index) { 9335 bool String::ComputeArrayIndex(uint32_t* index) {
9351 int length = this->length(); 9336 int length = this->length();
9352 if (length == 0 || length > kMaxArrayIndexSize) return false; 9337 if (length == 0 || length > kMaxArrayIndexSize) return false;
9353 ConsStringIteratorOp op; 9338 ConsStringIteratorOp op;
9354 StringCharacterStream stream(this, &op); 9339 StringCharacterStream stream(this, &op);
9355 uint16_t ch = stream.GetNext(); 9340 return StringToArrayIndex(&stream, index);
9356
9357 // If the string begins with a '0' character, it must only consist
9358 // of it to be a legal array index.
9359 if (ch == '0') {
9360 *index = 0;
9361 return length == 1;
9362 }
9363
9364 // Convert string to uint32 array index; character by character.
9365 int d = ch - '0';
9366 if (d < 0 || d > 9) return false;
9367 uint32_t result = d;
9368 while (stream.HasMore()) {
9369 d = stream.GetNext() - '0';
9370 if (d < 0 || d > 9) return false;
9371 // Check that the new result is below the 32 bit limit.
9372 if (result > 429496729U - ((d > 5) ? 1 : 0)) return false;
9373 result = (result * 10) + d;
9374 }
9375
9376 *index = result;
9377 return true;
9378 } 9341 }
9379 9342
9380 9343
9381 bool String::SlowAsArrayIndex(uint32_t* index) { 9344 bool String::SlowAsArrayIndex(uint32_t* index) {
9382 if (length() <= kMaxCachedArrayIndexLength) { 9345 if (length() <= kMaxCachedArrayIndexLength) {
9383 Hash(); // force computation of hash code 9346 Hash(); // force computation of hash code
9384 uint32_t field = hash_field(); 9347 uint32_t field = hash_field();
9385 if ((field & kIsNotArrayIndexMask) != 0) return false; 9348 if ((field & kIsNotArrayIndexMask) != 0) return false;
9386 // Isolate the array index form the full hash field. 9349 // Isolate the array index form the full hash field.
9387 *index = ArrayIndexValueBits::decode(field); 9350 *index = ArrayIndexValueBits::decode(field);
(...skipping 7603 matching lines...) Expand 10 before | Expand all | Expand 10 after
16991 #define ERROR_MESSAGES_TEXTS(C, T) T, 16954 #define ERROR_MESSAGES_TEXTS(C, T) T,
16992 static const char* error_messages_[] = { 16955 static const char* error_messages_[] = {
16993 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16956 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16994 }; 16957 };
16995 #undef ERROR_MESSAGES_TEXTS 16958 #undef ERROR_MESSAGES_TEXTS
16996 return error_messages_[reason]; 16959 return error_messages_[reason];
16997 } 16960 }
16998 16961
16999 16962
17000 } } // namespace v8::internal 16963 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/interface.cc ('k') | src/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698