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

Side by Side Diff: src/preparser.cc

Issue 7754014: Fix bug in collector. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 3 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/preparser.h ('k') | src/utils.h » ('j') | src/utils.h » ('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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after
1550 1550
1551 int DuplicateFinder::AddUC16Symbol(i::Vector<const uint16_t> key, int value) { 1551 int DuplicateFinder::AddUC16Symbol(i::Vector<const uint16_t> key, int value) {
1552 return AddSymbol(i::Vector<const byte>::cast(key), false, value); 1552 return AddSymbol(i::Vector<const byte>::cast(key), false, value);
1553 } 1553 }
1554 1554
1555 int DuplicateFinder::AddSymbol(i::Vector<const byte> key, 1555 int DuplicateFinder::AddSymbol(i::Vector<const byte> key,
1556 bool is_ascii, 1556 bool is_ascii,
1557 int value) { 1557 int value) {
1558 uint32_t hash = Hash(key, is_ascii); 1558 uint32_t hash = Hash(key, is_ascii);
1559 byte* encoding = BackupKey(key, is_ascii); 1559 byte* encoding = BackupKey(key, is_ascii);
1560 i::HashMap::Entry* entry = map_->Lookup(encoding, hash, true); 1560 i::HashMap::Entry* entry = map_.Lookup(encoding, hash, true);
1561 int old_value = static_cast<int>(reinterpret_cast<intptr_t>(entry->value)); 1561 int old_value = static_cast<int>(reinterpret_cast<intptr_t>(entry->value));
1562 entry->value = 1562 entry->value =
1563 reinterpret_cast<void*>(static_cast<intptr_t>(value | old_value)); 1563 reinterpret_cast<void*>(static_cast<intptr_t>(value | old_value));
1564 return old_value; 1564 return old_value;
1565 } 1565 }
1566 1566
1567 1567
1568 int DuplicateFinder::AddNumber(i::Vector<const char> key, int value) { 1568 int DuplicateFinder::AddNumber(i::Vector<const char> key, int value) {
1569 ASSERT(key.length() > 0); 1569 ASSERT(key.length() > 0);
1570 // Quick check for already being in canonical form. 1570 // Quick check for already being in canonical form.
1571 if (IsNumberCanonical(key)) { 1571 if (IsNumberCanonical(key)) {
1572 return AddAsciiSymbol(key, value); 1572 return AddAsciiSymbol(key, value);
1573 } 1573 }
1574 1574
1575 int flags = i::ALLOW_HEX | i::ALLOW_OCTALS; 1575 int flags = i::ALLOW_HEX | i::ALLOW_OCTALS;
1576 double double_value = StringToDouble(unicode_constants_, key, flags, 0.0); 1576 double double_value = StringToDouble(unicode_constants_, key, flags, 0.0);
1577 int length; 1577 int length;
1578 const char* string; 1578 const char* string;
1579 if (!isfinite(double_value)) { 1579 if (!isfinite(double_value)) {
1580 string = "Infinity"; 1580 string = "Infinity";
1581 length = 8; // strlen("Infinity"); 1581 length = 8; // strlen("Infinity");
1582 } else { 1582 } else {
1583 string = DoubleToCString(double_value, 1583 string = DoubleToCString(double_value,
1584 i::Vector<char>(number_buffer_, kBufferSize)); 1584 i::Vector<char>(number_buffer_, kBufferSize));
1585 length = i::StrLength(string); 1585 length = i::StrLength(string);
1586 } 1586 }
1587 return AddAsciiSymbol(i::Vector<const char>(string, length), value); 1587 return AddSymbol(i::Vector<const byte>(reinterpret_cast<const byte*>(string),
1588 length), true, value);
1588 } 1589 }
1589 1590
1590 1591
1591 bool DuplicateFinder::IsNumberCanonical(i::Vector<const char> number) { 1592 bool DuplicateFinder::IsNumberCanonical(i::Vector<const char> number) {
1592 // Test for a safe approximation of number literals that are already 1593 // Test for a safe approximation of number literals that are already
1593 // in canonical form: max 15 digits, no leading zeroes, except an 1594 // in canonical form: max 15 digits, no leading zeroes, except an
1594 // integer part that is a single zero, and no trailing zeros below 1595 // integer part that is a single zero, and no trailing zeros below
1595 // the decimal point. 1596 // the decimal point.
1596 int pos = 0; 1597 int pos = 0;
1597 int length = number.length(); 1598 int length = number.length();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1669 backing_store_.Add(static_cast<byte>((ascii_length >> 14) | 0x80u)); 1670 backing_store_.Add(static_cast<byte>((ascii_length >> 14) | 0x80u));
1670 } 1671 }
1671 backing_store_.Add(static_cast<byte>((ascii_length >> 7) | 0x80u)); 1672 backing_store_.Add(static_cast<byte>((ascii_length >> 7) | 0x80u));
1672 } 1673 }
1673 backing_store_.Add(static_cast<byte>(ascii_length & 0x7f)); 1674 backing_store_.Add(static_cast<byte>(ascii_length & 0x7f));
1674 1675
1675 backing_store_.AddBlock(bytes); 1676 backing_store_.AddBlock(bytes);
1676 return backing_store_.EndSequence().start(); 1677 return backing_store_.EndSequence().start();
1677 } 1678 }
1678 } } // v8::preparser 1679 } } // v8::preparser
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | src/utils.h » ('j') | src/utils.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698