Index: src/runtime.cc |
diff --git a/src/runtime.cc b/src/runtime.cc |
index aa453e1104d0c8b80d87a1a2ac9873786c8d7e02..274bc52ce7d401896bafc8391b5efb812bc912b9 100644 |
--- a/src/runtime.cc |
+++ b/src/runtime.cc |
@@ -41,6 +41,7 @@ |
#include "src/smart-pointers.h" |
#include "src/string-search.h" |
#include "src/stub-cache.h" |
+#include "src/unscopables.h" |
#include "src/uri.h" |
#include "src/v8threads.h" |
#include "src/vm-state-inl.h" |
@@ -9107,6 +9108,31 @@ static Object* ComputeReceiverForNonGlobal(Isolate* isolate, |
} |
+static ObjectPair LoadWithContextSlot(Isolate* isolate, Handle<String> name, |
+ Handle<JSReceiver> object, |
+ Handle<Object> receiver_handle) { |
+ bool ok; |
+ Handle<JSReceiver> holder; |
+ PropertyAttributes attrs = |
+ UnscopableLookup(isolate, object, name, &holder, &ok); |
+ if (!ok) { |
+ return MakePair(isolate->heap()->exception(), NULL); |
+ } |
+ if (attrs != ABSENT) { |
+ LookupIterator it(object, name, holder, LookupIterator::CHECK_OWN); |
+ Handle<Object> value; |
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
+ isolate, value, Object::GetPropertyForUnscopables(&it), |
+ MakePair(isolate->heap()->exception(), NULL)); |
+ |
+ return MakePair(*value, *receiver_handle); |
+ } |
+ |
+ return MakePair(isolate->heap()->undefined_value(), |
+ isolate->heap()->undefined_value()); |
+} |
+ |
+ |
static ObjectPair LoadLookupSlotHelper(Arguments args, Isolate* isolate, |
bool throw_error) { |
HandleScope scope(isolate); |
@@ -9180,6 +9206,10 @@ static ObjectPair LoadLookupSlotHelper(Arguments args, Isolate* isolate, |
: ComputeReceiverForNonGlobal(isolate, JSObject::cast(*object)), |
isolate); |
+ if (FLAG_harmony_unscopables && context->IsWithContext()) { |
+ return LoadWithContextSlot(isolate, name, object, receiver_handle); |
+ } |
+ |
// No need to unhole the value here. This is taken care of by the |
// GetProperty function. |
Handle<Object> value; |