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

Side by Side Diff: src/objects.cc

Issue 1497483004: [proxies] Make Array.isArray respect proxies. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comment. Created 5 years 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/array-isarray.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 Object); 604 Object);
605 } 605 }
606 ASSIGN_RETURN_ON_EXCEPTION(isolate, lhs, Object::ToNumber(lhs), Object); 606 ASSIGN_RETURN_ON_EXCEPTION(isolate, lhs, Object::ToNumber(lhs), Object);
607 ASSIGN_RETURN_ON_EXCEPTION(isolate, rhs, Object::ToNumber(rhs), Object); 607 ASSIGN_RETURN_ON_EXCEPTION(isolate, rhs, Object::ToNumber(rhs), Object);
608 } 608 }
609 return isolate->factory()->NewNumberFromInt(NumberToInt32(*lhs) ^ 609 return isolate->factory()->NewNumberFromInt(NumberToInt32(*lhs) ^
610 NumberToInt32(*rhs)); 610 NumberToInt32(*rhs));
611 } 611 }
612 612
613 613
614 Maybe<bool> Object::IsArray(Handle<Object> object) {
615 if (object->IsJSArray()) return Just(true);
616 if (object->IsJSProxy()) {
617 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object);
618 Isolate* isolate = proxy->GetIsolate();
619 if (proxy->IsRevoked()) {
620 isolate->Throw(*isolate->factory()->NewTypeError(
621 MessageTemplate::kProxyRevoked,
622 isolate->factory()->NewStringFromAsciiChecked("IsArray")));
623 return Nothing<bool>();
624 }
625 return Object::IsArray(handle(proxy->target(), isolate));
626 }
627 return Just(false);
628 }
629
630
614 bool Object::IsPromise(Handle<Object> object) { 631 bool Object::IsPromise(Handle<Object> object) {
615 if (!object->IsJSObject()) return false; 632 if (!object->IsJSObject()) return false;
616 auto js_object = Handle<JSObject>::cast(object); 633 auto js_object = Handle<JSObject>::cast(object);
617 // Promises can't have access checks. 634 // Promises can't have access checks.
618 if (js_object->map()->is_access_check_needed()) return false; 635 if (js_object->map()->is_access_check_needed()) return false;
619 auto isolate = js_object->GetIsolate(); 636 auto isolate = js_object->GetIsolate();
620 // TODO(dcarney): this should just be read from the symbol registry so as not 637 // TODO(dcarney): this should just be read from the symbol registry so as not
621 // to be context dependent. 638 // to be context dependent.
622 auto key = isolate->factory()->promise_status_symbol(); 639 auto key = isolate->factory()->promise_status_symbol();
623 // Shouldn't be possible to throw here. 640 // Shouldn't be possible to throw here.
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 THROW_NEW_ERROR(isolate, 993 THROW_NEW_ERROR(isolate,
977 NewTypeError(MessageTemplate::kProxyHandlerTrapMissing, 994 NewTypeError(MessageTemplate::kProxyHandlerTrapMissing,
978 handler, trap_name), 995 handler, trap_name),
979 Object); 996 Object);
980 } 997 }
981 // 13. Return handlerProto. 998 // 13. Return handlerProto.
982 return handler_proto; 999 return handler_proto;
983 } 1000 }
984 1001
985 1002
986 bool JSProxy::IsRevoked() { 1003 bool JSProxy::IsRevoked() const {
987 // TODO(neis): Decide on how to represent revocation. For now, revocation is 1004 // TODO(neis): Decide on how to represent revocation. For now, revocation is
988 // unsupported. 1005 // unsupported.
989 DCHECK(target()->IsJSReceiver()); 1006 DCHECK(target()->IsJSReceiver());
990 DCHECK(handler()->IsJSReceiver()); 1007 DCHECK(handler()->IsJSReceiver());
991 return false; 1008 return false;
992 } 1009 }
993 1010
994 1011
995 MaybeHandle<Object> Object::GetPropertyWithAccessor( 1012 MaybeHandle<Object> Object::GetPropertyWithAccessor(
996 LookupIterator* it, LanguageMode language_mode) { 1013 LookupIterator* it, LanguageMode language_mode) {
(...skipping 18058 matching lines...) Expand 10 before | Expand all | Expand 10 after
19055 if (cell->value() != *new_value) { 19072 if (cell->value() != *new_value) {
19056 cell->set_value(*new_value); 19073 cell->set_value(*new_value);
19057 Isolate* isolate = cell->GetIsolate(); 19074 Isolate* isolate = cell->GetIsolate();
19058 cell->dependent_code()->DeoptimizeDependentCodeGroup( 19075 cell->dependent_code()->DeoptimizeDependentCodeGroup(
19059 isolate, DependentCode::kPropertyCellChangedGroup); 19076 isolate, DependentCode::kPropertyCellChangedGroup);
19060 } 19077 }
19061 } 19078 }
19062 19079
19063 } // namespace internal 19080 } // namespace internal
19064 } // namespace v8 19081 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | test/mjsunit/array-isarray.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698