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

Unified Diff: src/runtime.cc

Issue 384963002: ES6 Unscopables (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 28481383a5fbd846a6940deb9a1b08ee64dab56e..6f0488011f278b4b3255c11bbc739ad16501d836 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -9214,6 +9214,58 @@ static Object* ComputeReceiverForNonGlobal(Isolate* isolate,
}
+static ObjectPair LoadWithContextSlot(Isolate* isolate, Handle<String> name,
+ Handle<JSReceiver> object,
+ Handle<Object> receiver_handle) {
+ Handle<JSReceiver> object_receiver = object;
+ Handle<Symbol> unscopables_symbol(
+ isolate->native_context()->unscopables_symbol(), isolate);
+
+ while (true) {
+ PropertyAttributes name_attrs =
+ JSReceiver::GetOwnPropertyAttributes(object, name);
+
+ if (name_attrs != ABSENT) {
+ PropertyAttributes unscopables_attrs =
+ JSReceiver::GetOwnPropertyAttributes(object, unscopables_symbol);
+ PropertyAttributes blocked_attrs = ABSENT;
+ if (unscopables_attrs != ABSENT) {
+ Handle<Object> unscopables_object;
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(
+ isolate, unscopables_object,
+ Object::GetProperty(object, unscopables_symbol),
+ MakePair(isolate->heap()->exception(), NULL));
+
+ if (unscopables_object->IsSpecObject()) {
+ blocked_attrs = JSReceiver::GetOwnPropertyAttributes(
+ Handle<JSReceiver>::cast(unscopables_object), name);
+ }
+ }
+
+ if (blocked_attrs == ABSENT) {
+ Handle<Object> value;
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(
+ isolate, value,
+ Object::GetPropertyWithReceiver(object, object_receiver, name),
+ MakePair(isolate->heap()->exception(), NULL));
+ return MakePair(*value, *receiver_handle);
+ }
+ }
+
+ Object* prototype = object->GetPrototype();
+ if (prototype->IsNull()) {
+ break;
+ }
+ ASSERT(prototype->IsSpecObject());
+ object = handle(JSReceiver::cast(prototype), isolate);
+ }
+
+ // The property doesn't exist - return undefined.
+ return MakePair(isolate->heap()->undefined_value(),
+ isolate->heap()->undefined_value());
+}
+
+
static ObjectPair LoadContextSlotHelper(Arguments args,
Isolate* isolate,
bool throw_error) {
@@ -9288,6 +9340,10 @@ static ObjectPair LoadContextSlotHelper(Arguments args,
: 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;

Powered by Google App Engine
This is Rietveld 408576698