| Index: src/ic/ic.cc
|
| diff --git a/src/ic/ic.cc b/src/ic/ic.cc
|
| index 4006f296a10b5503e708c0151866aba8d8756a7b..d199aca7369ec488cc25c0ac3636d5b0e43d885e 100644
|
| --- a/src/ic/ic.cc
|
| +++ b/src/ic/ic.cc
|
| @@ -734,7 +734,7 @@ MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<Name> name) {
|
| LookupIterator it(object, name);
|
| LookupForRead(&it);
|
|
|
| - if (it.IsFound() || !IsUndeclaredGlobal(object)) {
|
| + if (it.IsFound() || !ShouldThrowReferenceError(object)) {
|
| // Update inline cache and stub cache.
|
| if (use_ic) UpdateCaches(&it);
|
|
|
| @@ -745,7 +745,7 @@ MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<Name> name) {
|
| isolate(), result, Object::GetProperty(&it, language_mode()), Object);
|
| if (it.IsFound()) {
|
| return result;
|
| - } else if (!IsUndeclaredGlobal(object)) {
|
| + } else if (!ShouldThrowReferenceError(object)) {
|
| LOG(isolate(), SuspectReadEvent(*name, *object));
|
| return result;
|
| }
|
| @@ -2984,22 +2984,6 @@ RUNTIME_FUNCTION(LoadPropertyWithInterceptorOnly) {
|
| }
|
|
|
|
|
| -static Object* ThrowReferenceError(Isolate* isolate, Name* name) {
|
| - // If the load is non-contextual, just return the undefined result.
|
| - // Note that both keyed and non-keyed loads may end up here.
|
| - HandleScope scope(isolate);
|
| - LoadIC ic(IC::NO_EXTRA_FRAME, isolate, true);
|
| - if (ic.contextual_mode() != CONTEXTUAL) {
|
| - return isolate->heap()->undefined_value();
|
| - }
|
| -
|
| - // Throw a reference error.
|
| - Handle<Name> name_handle(name);
|
| - THROW_NEW_ERROR_RETURN_FAILURE(
|
| - isolate, NewReferenceError(MessageTemplate::kNotDefined, name_handle));
|
| -}
|
| -
|
| -
|
| /**
|
| * Loads a property with an interceptor performing post interceptor
|
| * lookup if interceptor failed.
|
| @@ -3022,7 +3006,16 @@ RUNTIME_FUNCTION(LoadPropertyWithInterceptor) {
|
|
|
| if (it.IsFound()) return *result;
|
|
|
| - return ThrowReferenceError(isolate, Name::cast(args[0]));
|
| + // Return the undefined result if the reference error should not be thrown.
|
| + // Note that both keyed and non-keyed loads may end up here.
|
| + LoadIC ic(IC::NO_EXTRA_FRAME, isolate, true);
|
| + if (!ic.ShouldThrowReferenceError(it.GetReceiver())) {
|
| + return isolate->heap()->undefined_value();
|
| + }
|
| +
|
| + // Throw a reference error.
|
| + THROW_NEW_ERROR_RETURN_FAILURE(
|
| + isolate, NewReferenceError(MessageTemplate::kNotDefined, it.name()));
|
| }
|
|
|
|
|
|
|