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

Side by Side Diff: src/objects.cc

Issue 1994183002: [json] handle proxies in BasicJsonSerializer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: address comments Created 4 years, 7 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/objects.h ('k') | test/mjsunit/es6/proxies-json.js » ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 // 3. If Type(obj) is not Object, throw a TypeError exception. 712 // 3. If Type(obj) is not Object, throw a TypeError exception.
713 if (!object->IsJSReceiver()) { 713 if (!object->IsJSReceiver()) {
714 THROW_NEW_ERROR(isolate, 714 THROW_NEW_ERROR(isolate,
715 NewTypeError(MessageTemplate::kCalledOnNonObject, 715 NewTypeError(MessageTemplate::kCalledOnNonObject,
716 isolate->factory()->NewStringFromAsciiChecked( 716 isolate->factory()->NewStringFromAsciiChecked(
717 "CreateListFromArrayLike")), 717 "CreateListFromArrayLike")),
718 FixedArray); 718 FixedArray);
719 } 719 }
720 // 4. Let len be ? ToLength(? Get(obj, "length")). 720 // 4. Let len be ? ToLength(? Get(obj, "length")).
721 Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(object); 721 Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(object);
722 Handle<Object> raw_length_obj;
723 ASSIGN_RETURN_ON_EXCEPTION(
724 isolate, raw_length_obj,
725 JSReceiver::GetProperty(receiver, isolate->factory()->length_string()),
726 FixedArray);
727 Handle<Object> raw_length_number; 722 Handle<Object> raw_length_number;
728 ASSIGN_RETURN_ON_EXCEPTION(isolate, raw_length_number, 723 ASSIGN_RETURN_ON_EXCEPTION(isolate, raw_length_number,
729 Object::ToLength(isolate, raw_length_obj), 724 Object::GetLengthFromArrayLike(isolate, receiver),
730 FixedArray); 725 FixedArray);
731 uint32_t len; 726 uint32_t len;
732 if (!raw_length_number->ToUint32(&len) || 727 if (!raw_length_number->ToUint32(&len) ||
733 len > static_cast<uint32_t>(FixedArray::kMaxLength)) { 728 len > static_cast<uint32_t>(FixedArray::kMaxLength)) {
734 THROW_NEW_ERROR(isolate, 729 THROW_NEW_ERROR(isolate,
735 NewRangeError(MessageTemplate::kInvalidArrayLength), 730 NewRangeError(MessageTemplate::kInvalidArrayLength),
736 FixedArray); 731 FixedArray);
737 } 732 }
738 // 5. Let list be an empty List. 733 // 5. Let list be an empty List.
739 Handle<FixedArray> list = isolate->factory()->NewFixedArray(len); 734 Handle<FixedArray> list = isolate->factory()->NewFixedArray(len);
(...skipping 26 matching lines...) Expand all
766 } 761 }
767 list->set(index, *next); 762 list->set(index, *next);
768 // 7e. Set index to index + 1. (See loop header.) 763 // 7e. Set index to index + 1. (See loop header.)
769 } 764 }
770 // 8. Return list. 765 // 8. Return list.
771 return list; 766 return list;
772 } 767 }
773 768
774 769
775 // static 770 // static
771 MaybeHandle<Object> Object::GetLengthFromArrayLike(Isolate* isolate,
772 Handle<Object> object) {
773 Handle<Object> val;
774 Handle<Object> key = isolate->factory()->length_string();
775 ASSIGN_RETURN_ON_EXCEPTION(
776 isolate, val, Runtime::GetObjectProperty(isolate, object, key), Object);
777 return Object::ToLength(isolate, val);
778 }
779
780 // static
776 Maybe<bool> JSReceiver::HasProperty(LookupIterator* it) { 781 Maybe<bool> JSReceiver::HasProperty(LookupIterator* it) {
777 for (; it->IsFound(); it->Next()) { 782 for (; it->IsFound(); it->Next()) {
778 switch (it->state()) { 783 switch (it->state()) {
779 case LookupIterator::NOT_FOUND: 784 case LookupIterator::NOT_FOUND:
780 case LookupIterator::TRANSITION: 785 case LookupIterator::TRANSITION:
781 UNREACHABLE(); 786 UNREACHABLE();
782 case LookupIterator::JSPROXY: 787 case LookupIterator::JSPROXY:
783 return JSProxy::HasProperty(it->isolate(), it->GetHolder<JSProxy>(), 788 return JSProxy::HasProperty(it->isolate(), it->GetHolder<JSProxy>(),
784 it->GetName()); 789 it->GetName());
785 case LookupIterator::INTERCEPTOR: { 790 case LookupIterator::INTERCEPTOR: {
(...skipping 17602 matching lines...) Expand 10 before | Expand all | Expand 10 after
18388 if (cell->value() != *new_value) { 18393 if (cell->value() != *new_value) {
18389 cell->set_value(*new_value); 18394 cell->set_value(*new_value);
18390 Isolate* isolate = cell->GetIsolate(); 18395 Isolate* isolate = cell->GetIsolate();
18391 cell->dependent_code()->DeoptimizeDependentCodeGroup( 18396 cell->dependent_code()->DeoptimizeDependentCodeGroup(
18392 isolate, DependentCode::kPropertyCellChangedGroup); 18397 isolate, DependentCode::kPropertyCellChangedGroup);
18393 } 18398 }
18394 } 18399 }
18395 18400
18396 } // namespace internal 18401 } // namespace internal
18397 } // namespace v8 18402 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | test/mjsunit/es6/proxies-json.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698