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

Side by Side Diff: src/objects.cc

Issue 231073002: WIP: Parser: delay string internalization. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: more cleanup 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/list.h ('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 "v8.h" 5 #include "v8.h"
6 6
7 #include "accessors.h" 7 #include "accessors.h"
8 #include "allocation-site-scopes.h" 8 #include "allocation-site-scopes.h"
9 #include "api.h" 9 #include "api.h"
10 #include "arguments.h" 10 #include "arguments.h"
(...skipping 1775 matching lines...) Expand 10 before | Expand all | Expand 10 after
1786 } 1786 }
1787 break; 1787 break;
1788 default: 1788 default:
1789 PrintF("Unknown type: %d\n", type); 1789 PrintF("Unknown type: %d\n", type);
1790 UNREACHABLE(); 1790 UNREACHABLE();
1791 } 1791 }
1792 } 1792 }
1793 1793
1794 1794
1795 bool HeapNumber::HeapNumberBooleanValue() { 1795 bool HeapNumber::HeapNumberBooleanValue() {
1796 // NaN, +0, and -0 should return the false object 1796 return DoubleToBoolean(value());
1797 #if __BYTE_ORDER == __LITTLE_ENDIAN
1798 union IeeeDoubleLittleEndianArchType u;
1799 #elif __BYTE_ORDER == __BIG_ENDIAN
1800 union IeeeDoubleBigEndianArchType u;
1801 #endif
1802 u.d = value();
1803 if (u.bits.exp == 2047) {
1804 // Detect NaN for IEEE double precision floating point.
1805 if ((u.bits.man_low | u.bits.man_high) != 0) return false;
1806 }
1807 if (u.bits.exp == 0) {
1808 // Detect +0, and -0 for IEEE double precision floating point.
1809 if ((u.bits.man_low | u.bits.man_high) == 0) return false;
1810 }
1811 return true;
1812 } 1797 }
1813 1798
1814 1799
1815 void HeapNumber::HeapNumberPrint(FILE* out) { 1800 void HeapNumber::HeapNumberPrint(FILE* out) {
1816 PrintF(out, "%.16g", Number()); 1801 PrintF(out, "%.16g", Number());
1817 } 1802 }
1818 1803
1819 1804
1820 void HeapNumber::HeapNumberPrint(StringStream* accumulator) { 1805 void HeapNumber::HeapNumberPrint(StringStream* accumulator) {
1821 // The Windows version of vsnprintf can allocate when printing a %g string 1806 // The Windows version of vsnprintf can allocate when printing a %g string
(...skipping 7707 matching lines...) Expand 10 before | Expand all | Expand 10 after
9529 ASSERT(result != 0); // Ensure that the hash value of 0 is never computed. 9514 ASSERT(result != 0); // Ensure that the hash value of 0 is never computed.
9530 return result; 9515 return result;
9531 } 9516 }
9532 9517
9533 9518
9534 bool String::ComputeArrayIndex(uint32_t* index) { 9519 bool String::ComputeArrayIndex(uint32_t* index) {
9535 int length = this->length(); 9520 int length = this->length();
9536 if (length == 0 || length > kMaxArrayIndexSize) return false; 9521 if (length == 0 || length > kMaxArrayIndexSize) return false;
9537 ConsStringIteratorOp op; 9522 ConsStringIteratorOp op;
9538 StringCharacterStream stream(this, &op); 9523 StringCharacterStream stream(this, &op);
9539 uint16_t ch = stream.GetNext(); 9524 return StringToArrayIndex(&stream, index);
9540
9541 // If the string begins with a '0' character, it must only consist
9542 // of it to be a legal array index.
9543 if (ch == '0') {
9544 *index = 0;
9545 return length == 1;
9546 }
9547
9548 // Convert string to uint32 array index; character by character.
9549 int d = ch - '0';
9550 if (d < 0 || d > 9) return false;
9551 uint32_t result = d;
9552 while (stream.HasMore()) {
9553 d = stream.GetNext() - '0';
9554 if (d < 0 || d > 9) return false;
9555 // Check that the new result is below the 32 bit limit.
9556 if (result > 429496729U - ((d > 5) ? 1 : 0)) return false;
9557 result = (result * 10) + d;
9558 }
9559
9560 *index = result;
9561 return true;
9562 } 9525 }
9563 9526
9564 9527
9565 bool String::SlowAsArrayIndex(uint32_t* index) { 9528 bool String::SlowAsArrayIndex(uint32_t* index) {
9566 if (length() <= kMaxCachedArrayIndexLength) { 9529 if (length() <= kMaxCachedArrayIndexLength) {
9567 Hash(); // force computation of hash code 9530 Hash(); // force computation of hash code
9568 uint32_t field = hash_field(); 9531 uint32_t field = hash_field();
9569 if ((field & kIsNotArrayIndexMask) != 0) return false; 9532 if ((field & kIsNotArrayIndexMask) != 0) return false;
9570 // Isolate the array index form the full hash field. 9533 // Isolate the array index form the full hash field.
9571 *index = ArrayIndexValueBits::decode(field); 9534 *index = ArrayIndexValueBits::decode(field);
(...skipping 7588 matching lines...) Expand 10 before | Expand all | Expand 10 after
17160 #define ERROR_MESSAGES_TEXTS(C, T) T, 17123 #define ERROR_MESSAGES_TEXTS(C, T) T,
17161 static const char* error_messages_[] = { 17124 static const char* error_messages_[] = {
17162 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 17125 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
17163 }; 17126 };
17164 #undef ERROR_MESSAGES_TEXTS 17127 #undef ERROR_MESSAGES_TEXTS
17165 return error_messages_[reason]; 17128 return error_messages_[reason];
17166 } 17129 }
17167 17130
17168 17131
17169 } } // namespace v8::internal 17132 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/list.h ('k') | src/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698