OLD | NEW |
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 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 if (position >= source_length_) return Handle<String>::null(); | 583 if (position >= source_length_) return Handle<String>::null(); |
584 c0 = seq_source_->SeqAsciiStringGet(position); | 584 c0 = seq_source_->SeqAsciiStringGet(position); |
585 } while (c0 != '"'); | 585 } while (c0 != '"'); |
586 int length = position - position_; | 586 int length = position - position_; |
587 uint32_t hash = (length <= String::kMaxHashCalcLength) | 587 uint32_t hash = (length <= String::kMaxHashCalcLength) |
588 ? StringHasher::GetHashCore(running_hash) : length; | 588 ? StringHasher::GetHashCore(running_hash) : length; |
589 Vector<const char> string_vector( | 589 Vector<const char> string_vector( |
590 seq_source_->GetChars() + position_, length); | 590 seq_source_->GetChars() + position_, length); |
591 SymbolTable* symbol_table = isolate()->heap()->symbol_table(); | 591 SymbolTable* symbol_table = isolate()->heap()->symbol_table(); |
592 uint32_t capacity = symbol_table->Capacity(); | 592 uint32_t capacity = symbol_table->Capacity(); |
593 uint32_t index = SymbolTable::FirstProbe(hash, capacity); | 593 uint32_t entry = SymbolTable::FirstProbe(hash, capacity); |
594 uint32_t count = 1; | 594 uint32_t count = 1; |
595 while (true) { | 595 while (true) { |
596 Object* element = symbol_table->KeyAt(index); | 596 Object* element = symbol_table->KeyAt(entry); |
597 if (element == isolate()->heap()->raw_unchecked_undefined_value()) { | 597 if (element == isolate()->heap()->raw_unchecked_undefined_value()) { |
598 // Lookup failure. | 598 // Lookup failure. |
599 break; | 599 break; |
600 } | 600 } |
601 if (element != isolate()->heap()->raw_unchecked_the_hole_value() && | 601 if (element != isolate()->heap()->raw_unchecked_the_hole_value() && |
602 String::cast(element)->IsAsciiEqualTo(string_vector)) { | 602 String::cast(element)->IsAsciiEqualTo(string_vector)) { |
603 // Lookup success, update the current position. | 603 // Lookup success, update the current position. |
604 position_ = position; | 604 position_ = position; |
605 // Advance past the last '"'. | 605 // Advance past the last '"'. |
606 AdvanceSkipWhitespace(); | 606 AdvanceSkipWhitespace(); |
607 return Handle<String>(String::cast(element)); | 607 return Handle<String>(String::cast(element)); |
608 } | 608 } |
609 index = SymbolTable::NextProbe(hash, count++, capacity); | 609 entry = SymbolTable::NextProbe(entry, count++, capacity); |
610 } | 610 } |
611 } | 611 } |
612 | 612 |
613 int beg_pos = position_; | 613 int beg_pos = position_; |
614 // Fast case for ASCII only without escape characters. | 614 // Fast case for ASCII only without escape characters. |
615 do { | 615 do { |
616 // Check for control character (0x00-0x1f) or unterminated string (<0). | 616 // Check for control character (0x00-0x1f) or unterminated string (<0). |
617 if (c0_ < 0x20) return Handle<String>::null(); | 617 if (c0_ < 0x20) return Handle<String>::null(); |
618 if (c0_ != '\\') { | 618 if (c0_ != '\\') { |
619 if (seq_ascii || c0_ <= kMaxAsciiCharCode) { | 619 if (seq_ascii || c0_ <= kMaxAsciiCharCode) { |
(...skipping 22 matching lines...) Expand all Loading... |
642 } | 642 } |
643 ASSERT_EQ('"', c0_); | 643 ASSERT_EQ('"', c0_); |
644 // Advance past the last '"'. | 644 // Advance past the last '"'. |
645 AdvanceSkipWhitespace(); | 645 AdvanceSkipWhitespace(); |
646 return result; | 646 return result; |
647 } | 647 } |
648 | 648 |
649 } } // namespace v8::internal | 649 } } // namespace v8::internal |
650 | 650 |
651 #endif // V8_JSON_PARSER_H_ | 651 #endif // V8_JSON_PARSER_H_ |
OLD | NEW |