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

Side by Side Diff: src/json-parser.h

Issue 12210083: Renamed "symbols" to "internalized strings" throughout the code base, (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 10 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
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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 c0_ = '"'; 338 c0_ = '"';
339 #endif 339 #endif
340 340
341 Handle<String> key = ParseJsonSymbol(); 341 Handle<String> key = ParseJsonSymbol();
342 if (key.is_null() || c0_ != ':') return ReportUnexpectedCharacter(); 342 if (key.is_null() || c0_ != ':') return ReportUnexpectedCharacter();
343 343
344 AdvanceSkipWhitespace(); 344 AdvanceSkipWhitespace();
345 Handle<Object> value = ParseJsonValue(); 345 Handle<Object> value = ParseJsonValue();
346 if (value.is_null()) return ReportUnexpectedCharacter(); 346 if (value.is_null()) return ReportUnexpectedCharacter();
347 347
348 if (key->Equals(isolate()->heap()->Proto_symbol())) { 348 if (key->Equals(isolate()->heap()->proto_string())) {
349 prototype = value; 349 prototype = value;
350 } else { 350 } else {
351 if (JSObject::TryTransitionToField(json_object, key)) { 351 if (JSObject::TryTransitionToField(json_object, key)) {
352 int index = json_object->LastAddedFieldIndex(); 352 int index = json_object->LastAddedFieldIndex();
353 json_object->FastPropertyAtPut(index, *value); 353 json_object->FastPropertyAtPut(index, *value);
354 } else { 354 } else {
355 JSObject::SetLocalPropertyIgnoreAttributes( 355 JSObject::SetLocalPropertyIgnoreAttributes(
356 json_object, key, value, NONE); 356 json_object, key, value, NONE);
357 } 357 }
358 } 358 }
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 } 645 }
646 position++; 646 position++;
647 if (position >= source_length_) return Handle<String>::null(); 647 if (position >= source_length_) return Handle<String>::null();
648 c0 = seq_source_->SeqOneByteStringGet(position); 648 c0 = seq_source_->SeqOneByteStringGet(position);
649 } while (c0 != '"'); 649 } while (c0 != '"');
650 int length = position - position_; 650 int length = position - position_;
651 uint32_t hash = (length <= String::kMaxHashCalcLength) 651 uint32_t hash = (length <= String::kMaxHashCalcLength)
652 ? StringHasher::GetHashCore(running_hash) : length; 652 ? StringHasher::GetHashCore(running_hash) : length;
653 Vector<const uint8_t> string_vector( 653 Vector<const uint8_t> string_vector(
654 seq_source_->GetChars() + position_, length); 654 seq_source_->GetChars() + position_, length);
655 SymbolTable* symbol_table = isolate()->heap()->symbol_table(); 655 StringTable* string_table = isolate()->heap()->string_table();
656 uint32_t capacity = symbol_table->Capacity(); 656 uint32_t capacity = string_table->Capacity();
657 uint32_t entry = SymbolTable::FirstProbe(hash, capacity); 657 uint32_t entry = StringTable::FirstProbe(hash, capacity);
658 uint32_t count = 1; 658 uint32_t count = 1;
659 while (true) { 659 while (true) {
660 Object* element = symbol_table->KeyAt(entry); 660 Object* element = string_table->KeyAt(entry);
661 if (element == isolate()->heap()->undefined_value()) { 661 if (element == isolate()->heap()->undefined_value()) {
662 // Lookup failure. 662 // Lookup failure.
663 break; 663 break;
664 } 664 }
665 if (element != isolate()->heap()->the_hole_value() && 665 if (element != isolate()->heap()->the_hole_value() &&
666 String::cast(element)->IsOneByteEqualTo(string_vector)) { 666 String::cast(element)->IsOneByteEqualTo(string_vector)) {
667 // Lookup success, update the current position. 667 // Lookup success, update the current position.
668 position_ = position; 668 position_ = position;
669 // Advance past the last '"'. 669 // Advance past the last '"'.
670 AdvanceSkipWhitespace(); 670 AdvanceSkipWhitespace();
671 return Handle<String>(String::cast(element), isolate()); 671 return Handle<String>(String::cast(element), isolate());
672 } 672 }
673 entry = SymbolTable::NextProbe(entry, count++, capacity); 673 entry = StringTable::NextProbe(entry, count++, capacity);
674 } 674 }
675 } 675 }
676 676
677 int beg_pos = position_; 677 int beg_pos = position_;
678 // Fast case for ASCII only without escape characters. 678 // Fast case for ASCII only without escape characters.
679 do { 679 do {
680 // Check for control character (0x00-0x1f) or unterminated string (<0). 680 // Check for control character (0x00-0x1f) or unterminated string (<0).
681 if (c0_ < 0x20) return Handle<String>::null(); 681 if (c0_ < 0x20) return Handle<String>::null();
682 if (c0_ != '\\') { 682 if (c0_ != '\\') {
683 if (seq_ascii || c0_ <= String::kMaxOneByteCharCode) { 683 if (seq_ascii || c0_ <= String::kMaxOneByteCharCode) {
684 Advance(); 684 Advance();
685 } else { 685 } else {
686 return SlowScanJsonString<SeqTwoByteString, uc16>(source_, 686 return SlowScanJsonString<SeqTwoByteString, uc16>(source_,
687 beg_pos, 687 beg_pos,
688 position_); 688 position_);
689 } 689 }
690 } else { 690 } else {
691 return SlowScanJsonString<SeqOneByteString, uint8_t>(source_, 691 return SlowScanJsonString<SeqOneByteString, uint8_t>(source_,
692 beg_pos, 692 beg_pos,
693 position_); 693 position_);
694 } 694 }
695 } while (c0_ != '"'); 695 } while (c0_ != '"');
696 int length = position_ - beg_pos; 696 int length = position_ - beg_pos;
697 Handle<String> result; 697 Handle<String> result;
698 if (seq_ascii && is_symbol) { 698 if (seq_ascii && is_symbol) {
699 result = factory()->LookupOneByteSymbol(seq_source_, beg_pos, length); 699 result = factory()->InternalizeOneByteString(seq_source_, beg_pos, length);
700 } else { 700 } else {
701 result = factory()->NewRawOneByteString(length, pretenure_); 701 result = factory()->NewRawOneByteString(length, pretenure_);
702 uint8_t* dest = SeqOneByteString::cast(*result)->GetChars(); 702 uint8_t* dest = SeqOneByteString::cast(*result)->GetChars();
703 String::WriteToFlat(*source_, dest, beg_pos, position_); 703 String::WriteToFlat(*source_, dest, beg_pos, position_);
704 } 704 }
705 ASSERT_EQ('"', c0_); 705 ASSERT_EQ('"', c0_);
706 // Advance past the last '"'. 706 // Advance past the last '"'.
707 AdvanceSkipWhitespace(); 707 AdvanceSkipWhitespace();
708 return result; 708 return result;
709 } 709 }
710 710
711 } } // namespace v8::internal 711 } } // namespace v8::internal
712 712
713 #endif // V8_JSON_PARSER_H_ 713 #endif // V8_JSON_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698