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

Unified Diff: src/runtime/runtime-classes.cc

Issue 2329703002: Private fields
Patch Set: some comments Created 4 years, 3 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
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/interpreter/bytecode_expectations/ForOf.golden » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-classes.cc
diff --git a/src/runtime/runtime-classes.cc b/src/runtime/runtime-classes.cc
index 5448159513bda41508a1c8cd1f72e859be74197a..532c88edda5e49aa6b973d6fbbf49f6781435c90 100644
--- a/src/runtime/runtime-classes.cc
+++ b/src/runtime/runtime-classes.cc
@@ -75,6 +75,27 @@ RUNTIME_FUNCTION(Runtime_ThrowIfStaticPrototype) {
return *name;
}
+RUNTIME_FUNCTION(Runtime_ThrowIfMissingPrivateField) {
+ // TODO(bakkot) it would be better if this were done as part of the property
+ // lookup, instead of prior to it.
+ // Currently the parser emits code which looks like
+ // %ThrowIfMissingPrivateField(x, field)[field]
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 2);
+ CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Symbol, name, 1);
+ DCHECK(name->is_private());
+
+ if (!object->IsJSReceiver() ||
+ !JSReceiver::HasOwnProperty(Handle<JSReceiver>::cast(object), name)
+ .FromMaybe(false)) { // Note that this does not trigger proxy traps
+ // when name is a private symbol.
+ THROW_NEW_ERROR_RETURN_FAILURE(
+ isolate, NewTypeError(MessageTemplate::kMissingPrivateField));
+ }
+ return *object; // This is used; after calling this method the field is
+ // immediately accessed.
+}
RUNTIME_FUNCTION(Runtime_HomeObjectSymbol) {
DCHECK(args.length() == 0);
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/interpreter/bytecode_expectations/ForOf.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698