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

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

Issue 2028983002: Introduce IsUndefined(Isolate*) and IsTheHole(Isolate*) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase master Created 4 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
« no previous file with comments | « src/isolate-inl.h ('k') | src/json-stringifier.cc » ('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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/json-parser.h" 5 #include "src/json-parser.h"
6 6
7 #include "src/char-predicates-inl.h" 7 #include "src/char-predicates-inl.h"
8 #include "src/conversions.h" 8 #include "src/conversions.h"
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/factory.h" 10 #include "src/factory.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 Object); 76 Object);
77 return outer_scope.CloseAndEscape(result); 77 return outer_scope.CloseAndEscape(result);
78 } 78 }
79 79
80 bool JsonParseInternalizer::RecurseAndApply(Handle<JSReceiver> holder, 80 bool JsonParseInternalizer::RecurseAndApply(Handle<JSReceiver> holder,
81 Handle<String> name) { 81 Handle<String> name) {
82 Handle<Object> result; 82 Handle<Object> result;
83 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 83 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
84 isolate_, result, InternalizeJsonProperty(holder, name), false); 84 isolate_, result, InternalizeJsonProperty(holder, name), false);
85 Maybe<bool> change_result = Nothing<bool>(); 85 Maybe<bool> change_result = Nothing<bool>();
86 if (result->IsUndefined()) { 86 if (result->IsUndefined(isolate_)) {
87 change_result = JSReceiver::DeletePropertyOrElement(holder, name, SLOPPY); 87 change_result = JSReceiver::DeletePropertyOrElement(holder, name, SLOPPY);
88 } else { 88 } else {
89 PropertyDescriptor desc; 89 PropertyDescriptor desc;
90 desc.set_value(result); 90 desc.set_value(result);
91 desc.set_configurable(true); 91 desc.set_configurable(true);
92 desc.set_enumerable(true); 92 desc.set_enumerable(true);
93 desc.set_writable(true); 93 desc.set_writable(true);
94 change_result = JSReceiver::DefineOwnProperty(isolate_, holder, name, &desc, 94 change_result = JSReceiver::DefineOwnProperty(isolate_, holder, name, &desc,
95 Object::DONT_THROW); 95 Object::DONT_THROW);
96 } 96 }
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 : static_cast<uint32_t>(length); 744 : static_cast<uint32_t>(length);
745 Vector<const uint8_t> string_vector(seq_source_->GetChars() + position_, 745 Vector<const uint8_t> string_vector(seq_source_->GetChars() + position_,
746 length); 746 length);
747 StringTable* string_table = isolate()->heap()->string_table(); 747 StringTable* string_table = isolate()->heap()->string_table();
748 uint32_t capacity = string_table->Capacity(); 748 uint32_t capacity = string_table->Capacity();
749 uint32_t entry = StringTable::FirstProbe(hash, capacity); 749 uint32_t entry = StringTable::FirstProbe(hash, capacity);
750 uint32_t count = 1; 750 uint32_t count = 1;
751 Handle<String> result; 751 Handle<String> result;
752 while (true) { 752 while (true) {
753 Object* element = string_table->KeyAt(entry); 753 Object* element = string_table->KeyAt(entry);
754 if (element == isolate()->heap()->undefined_value()) { 754 if (element->IsUndefined(isolate())) {
755 // Lookup failure. 755 // Lookup failure.
756 result = 756 result =
757 factory()->InternalizeOneByteString(seq_source_, position_, length); 757 factory()->InternalizeOneByteString(seq_source_, position_, length);
758 break; 758 break;
759 } 759 }
760 if (element != isolate()->heap()->the_hole_value() && 760 if (!element->IsTheHole(isolate()) &&
761 String::cast(element)->IsOneByteEqualTo(string_vector)) { 761 String::cast(element)->IsOneByteEqualTo(string_vector)) {
762 result = Handle<String>(String::cast(element), isolate()); 762 result = Handle<String>(String::cast(element), isolate());
763 #ifdef DEBUG 763 #ifdef DEBUG
764 uint32_t hash_field = 764 uint32_t hash_field =
765 (hash << String::kHashShift) | String::kIsNotArrayIndexMask; 765 (hash << String::kHashShift) | String::kIsNotArrayIndexMask;
766 DCHECK_EQ(static_cast<int>(result->Hash()), 766 DCHECK_EQ(static_cast<int>(result->Hash()),
767 static_cast<int>(hash_field >> String::kHashShift)); 767 static_cast<int>(hash_field >> String::kHashShift));
768 #endif 768 #endif
769 break; 769 break;
770 } 770 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 AdvanceSkipWhitespace(); 804 AdvanceSkipWhitespace();
805 return result; 805 return result;
806 } 806 }
807 807
808 // Explicit instantiation. 808 // Explicit instantiation.
809 template class JsonParser<true>; 809 template class JsonParser<true>;
810 template class JsonParser<false>; 810 template class JsonParser<false>;
811 811
812 } // namespace internal 812 } // namespace internal
813 } // namespace v8 813 } // namespace v8
OLDNEW
« no previous file with comments | « src/isolate-inl.h ('k') | src/json-stringifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698