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

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

Issue 1185343005: Revert of Revert of [strong] Implement strong mode restrictions on property access (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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') | src/runtime/runtime-debug.cc » ('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 dedff928a79618606824127258f3c9d6930ceffa..95a65f53ad93646d8757a9a1596d4d842cf39efa 100644
--- a/src/runtime/runtime-classes.cc
+++ b/src/runtime/runtime-classes.cc
@@ -120,7 +120,8 @@
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, prototype_parent,
Runtime::GetObjectProperty(isolate, super_class,
- isolate->factory()->prototype_string()));
+ isolate->factory()->prototype_string(),
+ SLOPPY));
if (!prototype_parent->IsNull() && !prototype_parent->IsSpecObject()) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewTypeError(MessageTemplate::kPrototypeParentNotAnObject,
@@ -244,64 +245,87 @@
}
-static Object* LoadFromSuper(Isolate* isolate, Handle<Object> receiver,
- Handle<JSObject> home_object, Handle<Name> name) {
+static MaybeHandle<Object> LoadFromSuper(Isolate* isolate,
+ Handle<Object> receiver,
+ Handle<JSObject> home_object,
+ Handle<Name> name,
+ LanguageMode language_mode) {
if (home_object->IsAccessCheckNeeded() && !isolate->MayAccess(home_object)) {
isolate->ReportFailedAccessCheck(home_object);
- RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
+ RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
}
PrototypeIterator iter(isolate, home_object);
Handle<Object> proto = PrototypeIterator::GetCurrent(iter);
- if (!proto->IsJSReceiver()) return isolate->heap()->undefined_value();
+ if (!proto->IsJSReceiver()) {
+ return Object::ReadAbsentProperty(isolate, proto, name, language_mode);
+ }
LookupIterator it(receiver, name, Handle<JSReceiver>::cast(proto));
Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it));
- return *result;
-}
-
-
-static Object* LoadElementFromSuper(Isolate* isolate, Handle<Object> receiver,
- Handle<JSObject> home_object,
- uint32_t index) {
+ ASSIGN_RETURN_ON_EXCEPTION(isolate, result,
+ Object::GetProperty(&it, language_mode), Object);
+ return result;
+}
+
+
+static MaybeHandle<Object> LoadElementFromSuper(Isolate* isolate,
+ Handle<Object> receiver,
+ Handle<JSObject> home_object,
+ uint32_t index,
+ LanguageMode language_mode) {
if (home_object->IsAccessCheckNeeded() && !isolate->MayAccess(home_object)) {
isolate->ReportFailedAccessCheck(home_object);
- RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
+ RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
}
PrototypeIterator iter(isolate, home_object);
Handle<Object> proto = PrototypeIterator::GetCurrent(iter);
- if (!proto->IsJSReceiver()) return isolate->heap()->undefined_value();
+ if (!proto->IsJSReceiver()) {
+ Handle<Object> name = isolate->factory()->NewNumberFromUint(index);
+ return Object::ReadAbsentProperty(isolate, proto, name, language_mode);
+ }
LookupIterator it(isolate, receiver, index, Handle<JSReceiver>::cast(proto));
Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it));
+ ASSIGN_RETURN_ON_EXCEPTION(isolate, result,
+ Object::GetProperty(&it, language_mode), Object);
+ return result;
+}
+
+
+RUNTIME_FUNCTION(Runtime_LoadFromSuper) {
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 4);
+ CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0);
+ CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1);
+ CONVERT_ARG_HANDLE_CHECKED(Name, name, 2);
+ CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 3);
+
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result,
+ LoadFromSuper(isolate, receiver, home_object, name, language_mode));
return *result;
}
-RUNTIME_FUNCTION(Runtime_LoadFromSuper) {
- HandleScope scope(isolate);
- DCHECK(args.length() == 3);
- CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0);
- CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1);
- CONVERT_ARG_HANDLE_CHECKED(Name, name, 2);
-
- return LoadFromSuper(isolate, receiver, home_object, name);
-}
-
-
RUNTIME_FUNCTION(Runtime_LoadKeyedFromSuper) {
HandleScope scope(isolate);
- DCHECK(args.length() == 3);
+ DCHECK(args.length() == 4);
CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0);
CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1);
CONVERT_ARG_HANDLE_CHECKED(Object, key, 2);
+ CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 3);
uint32_t index = 0;
+ Handle<Object> result;
+
if (key->ToArrayIndex(&index)) {
- return LoadElementFromSuper(isolate, receiver, home_object, index);
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result, LoadElementFromSuper(isolate, receiver, home_object,
+ index, language_mode));
+ return *result;
}
Handle<Name> name;
@@ -309,9 +333,15 @@
Runtime::ToName(isolate, key));
// TODO(verwaest): Unify using LookupIterator.
if (name->AsArrayIndex(&index)) {
- return LoadElementFromSuper(isolate, receiver, home_object, index);
- }
- return LoadFromSuper(isolate, receiver, home_object, name);
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result, LoadElementFromSuper(isolate, receiver, home_object,
+ index, language_mode));
+ return *result;
+ }
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result,
+ LoadFromSuper(isolate, receiver, home_object, name, language_mode));
+ return *result;
}
« no previous file with comments | « src/runtime/runtime.h ('k') | src/runtime/runtime-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698