OLD | NEW |
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 <iomanip> | 5 #include <iomanip> |
6 #include <sstream> | 6 #include <sstream> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 MaybeHandle<Object> Object::GetProperty(LookupIterator* it) { | 130 MaybeHandle<Object> Object::GetProperty(LookupIterator* it) { |
131 for (; it->IsFound(); it->Next()) { | 131 for (; it->IsFound(); it->Next()) { |
132 switch (it->state()) { | 132 switch (it->state()) { |
133 case LookupIterator::NOT_FOUND: | 133 case LookupIterator::NOT_FOUND: |
134 case LookupIterator::TRANSITION: | 134 case LookupIterator::TRANSITION: |
135 UNREACHABLE(); | 135 UNREACHABLE(); |
136 case LookupIterator::JSPROXY: | 136 case LookupIterator::JSPROXY: |
137 return JSProxy::GetPropertyWithHandler( | 137 return JSProxy::GetPropertyWithHandler( |
138 it->GetHolder<JSProxy>(), it->GetReceiver(), it->GetName()); | 138 it->GetHolder<JSProxy>(), it->GetReceiver(), it->GetName()); |
139 case LookupIterator::INTERCEPTOR: { | 139 case LookupIterator::INTERCEPTOR: { |
140 MaybeHandle<Object> maybe_result = | 140 bool done; |
141 JSObject::GetPropertyWithInterceptor(it); | 141 Handle<Object> result; |
142 if (!maybe_result.is_null()) return maybe_result; | 142 ASSIGN_RETURN_ON_EXCEPTION( |
143 if (it->isolate()->has_pending_exception()) return maybe_result; | 143 it->isolate(), result, |
| 144 JSObject::GetPropertyWithInterceptor(it, &done), Object); |
| 145 if (done) return result; |
144 break; | 146 break; |
145 } | 147 } |
146 case LookupIterator::ACCESS_CHECK: | 148 case LookupIterator::ACCESS_CHECK: |
147 if (it->HasAccess()) break; | 149 if (it->HasAccess()) break; |
148 return JSObject::GetPropertyWithFailedAccessCheck(it); | 150 return JSObject::GetPropertyWithFailedAccessCheck(it); |
149 case LookupIterator::ACCESSOR: | 151 case LookupIterator::ACCESSOR: |
150 return GetPropertyWithAccessor(it); | 152 return GetPropertyWithAccessor(it); |
151 case LookupIterator::INTEGER_INDEXED_EXOTIC: | 153 case LookupIterator::INTEGER_INDEXED_EXOTIC: |
152 return it->factory()->undefined_value(); | 154 return it->factory()->undefined_value(); |
153 case LookupIterator::DATA: | 155 case LookupIterator::DATA: |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 | 488 |
487 | 489 |
488 MaybeHandle<Object> JSObject::GetPropertyWithFailedAccessCheck( | 490 MaybeHandle<Object> JSObject::GetPropertyWithFailedAccessCheck( |
489 LookupIterator* it) { | 491 LookupIterator* it) { |
490 Handle<JSObject> checked = it->GetHolder<JSObject>(); | 492 Handle<JSObject> checked = it->GetHolder<JSObject>(); |
491 while (FindAllCanReadHolder(it)) { | 493 while (FindAllCanReadHolder(it)) { |
492 if (it->state() == LookupIterator::ACCESSOR) { | 494 if (it->state() == LookupIterator::ACCESSOR) { |
493 return GetPropertyWithAccessor(it); | 495 return GetPropertyWithAccessor(it); |
494 } | 496 } |
495 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state()); | 497 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state()); |
496 auto result = GetPropertyWithInterceptor(it); | 498 bool done; |
497 if (it->isolate()->has_scheduled_exception()) break; | 499 Handle<Object> result; |
498 if (!result.is_null()) return result; | 500 ASSIGN_RETURN_ON_EXCEPTION(it->isolate(), result, |
| 501 GetPropertyWithInterceptor(it, &done), Object); |
| 502 if (done) return result; |
499 } | 503 } |
500 it->isolate()->ReportFailedAccessCheck(checked); | 504 it->isolate()->ReportFailedAccessCheck(checked); |
501 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(it->isolate(), Object); | 505 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(it->isolate(), Object); |
502 return it->factory()->undefined_value(); | 506 return it->factory()->undefined_value(); |
503 } | 507 } |
504 | 508 |
505 | 509 |
506 Maybe<PropertyAttributes> JSObject::GetPropertyAttributesWithFailedAccessCheck( | 510 Maybe<PropertyAttributes> JSObject::GetPropertyAttributesWithFailedAccessCheck( |
507 LookupIterator* it) { | 511 LookupIterator* it) { |
508 Handle<JSObject> checked = it->GetHolder<JSObject>(); | 512 Handle<JSObject> checked = it->GetHolder<JSObject>(); |
(...skipping 12798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13307 InterceptorInfo* JSObject::GetIndexedInterceptor() { | 13311 InterceptorInfo* JSObject::GetIndexedInterceptor() { |
13308 DCHECK(map()->has_indexed_interceptor()); | 13312 DCHECK(map()->has_indexed_interceptor()); |
13309 JSFunction* constructor = JSFunction::cast(map()->GetConstructor()); | 13313 JSFunction* constructor = JSFunction::cast(map()->GetConstructor()); |
13310 DCHECK(constructor->shared()->IsApiFunction()); | 13314 DCHECK(constructor->shared()->IsApiFunction()); |
13311 Object* result = | 13315 Object* result = |
13312 constructor->shared()->get_api_func_data()->indexed_property_handler(); | 13316 constructor->shared()->get_api_func_data()->indexed_property_handler(); |
13313 return InterceptorInfo::cast(result); | 13317 return InterceptorInfo::cast(result); |
13314 } | 13318 } |
13315 | 13319 |
13316 | 13320 |
13317 MaybeHandle<Object> JSObject::GetPropertyWithInterceptor(LookupIterator* it) { | 13321 MaybeHandle<Object> JSObject::GetPropertyWithInterceptor(LookupIterator* it, |
| 13322 bool* done) { |
| 13323 *done = false; |
13318 Isolate* isolate = it->isolate(); | 13324 Isolate* isolate = it->isolate(); |
13319 // Make sure that the top context does not change when doing callbacks or | 13325 // Make sure that the top context does not change when doing callbacks or |
13320 // interceptor calls. | 13326 // interceptor calls. |
13321 AssertNoContextChange ncc(isolate); | 13327 AssertNoContextChange ncc(isolate); |
13322 | 13328 |
13323 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state()); | 13329 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state()); |
13324 Handle<InterceptorInfo> interceptor = it->GetInterceptor(); | 13330 Handle<InterceptorInfo> interceptor = it->GetInterceptor(); |
13325 if (interceptor->getter()->IsUndefined()) return MaybeHandle<Object>(); | 13331 if (interceptor->getter()->IsUndefined()) { |
| 13332 return isolate->factory()->undefined_value(); |
| 13333 } |
13326 | 13334 |
13327 Handle<JSObject> holder = it->GetHolder<JSObject>(); | 13335 Handle<JSObject> holder = it->GetHolder<JSObject>(); |
13328 v8::Handle<v8::Value> result; | 13336 v8::Handle<v8::Value> result; |
13329 PropertyCallbackArguments args(isolate, interceptor->data(), | 13337 PropertyCallbackArguments args(isolate, interceptor->data(), |
13330 *it->GetReceiver(), *holder); | 13338 *it->GetReceiver(), *holder); |
13331 | 13339 |
13332 if (it->IsElement()) { | 13340 if (it->IsElement()) { |
13333 uint32_t index = it->index(); | 13341 uint32_t index = it->index(); |
13334 v8::IndexedPropertyGetterCallback getter = | 13342 v8::IndexedPropertyGetterCallback getter = |
13335 v8::ToCData<v8::IndexedPropertyGetterCallback>(interceptor->getter()); | 13343 v8::ToCData<v8::IndexedPropertyGetterCallback>(interceptor->getter()); |
13336 LOG(isolate, | 13344 LOG(isolate, |
13337 ApiIndexedPropertyAccess("interceptor-indexed-get", *holder, index)); | 13345 ApiIndexedPropertyAccess("interceptor-indexed-get", *holder, index)); |
13338 result = args.Call(getter, index); | 13346 result = args.Call(getter, index); |
13339 } else { | 13347 } else { |
13340 Handle<Name> name = it->name(); | 13348 Handle<Name> name = it->name(); |
13341 | 13349 |
13342 if (name->IsSymbol() && !interceptor->can_intercept_symbols()) { | 13350 if (name->IsSymbol() && !interceptor->can_intercept_symbols()) { |
13343 return MaybeHandle<Object>(); | 13351 return isolate->factory()->undefined_value(); |
13344 } | 13352 } |
13345 | 13353 |
13346 v8::GenericNamedPropertyGetterCallback getter = | 13354 v8::GenericNamedPropertyGetterCallback getter = |
13347 v8::ToCData<v8::GenericNamedPropertyGetterCallback>( | 13355 v8::ToCData<v8::GenericNamedPropertyGetterCallback>( |
13348 interceptor->getter()); | 13356 interceptor->getter()); |
13349 LOG(isolate, | 13357 LOG(isolate, |
13350 ApiNamedPropertyAccess("interceptor-named-get", *holder, *name)); | 13358 ApiNamedPropertyAccess("interceptor-named-get", *holder, *name)); |
13351 result = args.Call(getter, v8::Utils::ToLocal(name)); | 13359 result = args.Call(getter, v8::Utils::ToLocal(name)); |
13352 } | 13360 } |
13353 | 13361 |
13354 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); | 13362 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); |
13355 if (result.IsEmpty()) return MaybeHandle<Object>(); | 13363 if (result.IsEmpty()) return isolate->factory()->undefined_value(); |
13356 Handle<Object> result_internal = v8::Utils::OpenHandle(*result); | 13364 Handle<Object> result_internal = v8::Utils::OpenHandle(*result); |
13357 result_internal->VerifyApiCallResultType(); | 13365 result_internal->VerifyApiCallResultType(); |
| 13366 *done = true; |
13358 // Rebox handle before return | 13367 // Rebox handle before return |
13359 return handle(*result_internal, isolate); | 13368 return handle(*result_internal, isolate); |
13360 } | 13369 } |
13361 | 13370 |
13362 | 13371 |
13363 // Compute the property keys from the interceptor. | 13372 // Compute the property keys from the interceptor. |
13364 MaybeHandle<JSObject> JSObject::GetKeysForNamedInterceptor( | 13373 MaybeHandle<JSObject> JSObject::GetKeysForNamedInterceptor( |
13365 Handle<JSObject> object, Handle<JSReceiver> receiver) { | 13374 Handle<JSObject> object, Handle<JSReceiver> receiver) { |
13366 Isolate* isolate = receiver->GetIsolate(); | 13375 Isolate* isolate = receiver->GetIsolate(); |
13367 Handle<InterceptorInfo> interceptor(object->GetNamedInterceptor()); | 13376 Handle<InterceptorInfo> interceptor(object->GetNamedInterceptor()); |
(...skipping 3264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16632 Handle<Object> new_value) { | 16641 Handle<Object> new_value) { |
16633 if (cell->value() != *new_value) { | 16642 if (cell->value() != *new_value) { |
16634 cell->set_value(*new_value); | 16643 cell->set_value(*new_value); |
16635 Isolate* isolate = cell->GetIsolate(); | 16644 Isolate* isolate = cell->GetIsolate(); |
16636 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 16645 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
16637 isolate, DependentCode::kPropertyCellChangedGroup); | 16646 isolate, DependentCode::kPropertyCellChangedGroup); |
16638 } | 16647 } |
16639 } | 16648 } |
16640 } // namespace internal | 16649 } // namespace internal |
16641 } // namespace v8 | 16650 } // namespace v8 |
OLD | NEW |