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

Side by Side Diff: src/objects.cc

Issue 1680133002: [proxies] Implement spec change to consistency check in [[SetPrototypeOf]]. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | test/mjsunit/harmony/proxies-set-prototype-of.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 15700 matching lines...) Expand 10 before | Expand all | Expand 10 after
15711 should_throw); 15711 should_throw);
15712 } 15712 }
15713 // 8. Let booleanTrapResult be ToBoolean(? Call(trap, handler, «target, V»)). 15713 // 8. Let booleanTrapResult be ToBoolean(? Call(trap, handler, «target, V»)).
15714 Handle<Object> argv[] = {target, value}; 15714 Handle<Object> argv[] = {target, value};
15715 Handle<Object> trap_result; 15715 Handle<Object> trap_result;
15716 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 15716 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
15717 isolate, trap_result, 15717 isolate, trap_result,
15718 Execution::Call(isolate, trap, handler, arraysize(argv), argv), 15718 Execution::Call(isolate, trap, handler, arraysize(argv), argv),
15719 Nothing<bool>()); 15719 Nothing<bool>());
15720 bool bool_trap_result = trap_result->BooleanValue(); 15720 bool bool_trap_result = trap_result->BooleanValue();
15721 // 9. Let extensibleTarget be ? IsExtensible(target). 15721 // 9. If booleanTrapResult is false, return false.
15722 if (!bool_trap_result) {
15723 RETURN_FAILURE(
15724 isolate, should_throw,
15725 NewTypeError(MessageTemplate::kProxyTrapReturnedFalsish, trap_name));
15726 }
15727 // 10. Let extensibleTarget be ? IsExtensible(target).
15722 Maybe<bool> is_extensible = JSReceiver::IsExtensible(target); 15728 Maybe<bool> is_extensible = JSReceiver::IsExtensible(target);
15723 if (is_extensible.IsNothing()) return Nothing<bool>(); 15729 if (is_extensible.IsNothing()) return Nothing<bool>();
15724 // 10. If extensibleTarget is true, return booleanTrapResult. 15730 // 11. If extensibleTarget is true, return true.
15725 if (is_extensible.FromJust()) { 15731 if (is_extensible.FromJust()) {
15726 if (bool_trap_result) return Just(true); 15732 if (bool_trap_result) return Just(true);
15727 RETURN_FAILURE( 15733 RETURN_FAILURE(
15728 isolate, should_throw, 15734 isolate, should_throw,
15729 NewTypeError(MessageTemplate::kProxyTrapReturnedFalsish, trap_name)); 15735 NewTypeError(MessageTemplate::kProxyTrapReturnedFalsish, trap_name));
15730 } 15736 }
15731 // 11. Let targetProto be ? target.[[GetPrototypeOf]](). 15737 // 12. Let targetProto be ? target.[[GetPrototypeOf]]().
15732 Handle<Object> target_proto; 15738 Handle<Object> target_proto;
15733 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, target_proto, 15739 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, target_proto,
15734 JSReceiver::GetPrototype(isolate, target), 15740 JSReceiver::GetPrototype(isolate, target),
15735 Nothing<bool>()); 15741 Nothing<bool>());
15736 // 12. If booleanTrapResult is true and SameValue(V, targetProto) is false, 15742 // 13. If SameValue(V, targetProto) is false, throw a TypeError exception.
15737 // throw a TypeError exception.
15738 if (bool_trap_result && !value->SameValue(*target_proto)) { 15743 if (bool_trap_result && !value->SameValue(*target_proto)) {
15739 isolate->Throw(*isolate->factory()->NewTypeError( 15744 isolate->Throw(*isolate->factory()->NewTypeError(
15740 MessageTemplate::kProxySetPrototypeOfNonExtensible)); 15745 MessageTemplate::kProxySetPrototypeOfNonExtensible));
15741 return Nothing<bool>(); 15746 return Nothing<bool>();
15742 } 15747 }
15743 // 13. Return booleanTrapResult. 15748 // 14. Return true.
15744 if (bool_trap_result) return Just(true); 15749 return Just(true);
15745 RETURN_FAILURE(
15746 isolate, should_throw,
15747 NewTypeError(MessageTemplate::kProxyTrapReturnedFalsish, trap_name));
15748 } 15750 }
15749 15751
15750 15752
15751 Maybe<bool> JSObject::SetPrototype(Handle<JSObject> object, 15753 Maybe<bool> JSObject::SetPrototype(Handle<JSObject> object,
15752 Handle<Object> value, bool from_javascript, 15754 Handle<Object> value, bool from_javascript,
15753 ShouldThrow should_throw) { 15755 ShouldThrow should_throw) {
15754 Isolate* isolate = object->GetIsolate(); 15756 Isolate* isolate = object->GetIsolate();
15755 15757
15756 const bool observed = from_javascript && object->map()->is_observed(); 15758 const bool observed = from_javascript && object->map()->is_observed();
15757 Handle<Object> old_value; 15759 Handle<Object> old_value;
(...skipping 4172 matching lines...) Expand 10 before | Expand all | Expand 10 after
19930 if (cell->value() != *new_value) { 19932 if (cell->value() != *new_value) {
19931 cell->set_value(*new_value); 19933 cell->set_value(*new_value);
19932 Isolate* isolate = cell->GetIsolate(); 19934 Isolate* isolate = cell->GetIsolate();
19933 cell->dependent_code()->DeoptimizeDependentCodeGroup( 19935 cell->dependent_code()->DeoptimizeDependentCodeGroup(
19934 isolate, DependentCode::kPropertyCellChangedGroup); 19936 isolate, DependentCode::kPropertyCellChangedGroup);
19935 } 19937 }
19936 } 19938 }
19937 19939
19938 } // namespace internal 19940 } // namespace internal
19939 } // namespace v8 19941 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/harmony/proxies-set-prototype-of.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698