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

Unified Diff: src/objects.cc

Issue 1199983002: [strong] Implement strong property access semantics (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: add TODOs 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/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 4c72aa9d6c5e60723e931762a8b20804fd6e30b2..f272aa501015889098573bf79142de6dd9a1e7c7 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -127,7 +127,8 @@ bool Object::IsPromise(Handle<Object> object) {
}
-MaybeHandle<Object> Object::GetProperty(LookupIterator* it) {
+MaybeHandle<Object> Object::GetProperty(LookupIterator* it,
+ LanguageMode language_mode) {
for (; it->IsFound(); it->Next()) {
switch (it->state()) {
case LookupIterator::NOT_FOUND:
@@ -149,14 +150,14 @@ MaybeHandle<Object> Object::GetProperty(LookupIterator* it) {
if (it->HasAccess()) break;
return JSObject::GetPropertyWithFailedAccessCheck(it);
case LookupIterator::ACCESSOR:
- return GetPropertyWithAccessor(it);
+ return GetPropertyWithAccessor(it, language_mode);
case LookupIterator::INTEGER_INDEXED_EXOTIC:
- return it->factory()->undefined_value();
+ return ReadAbsentProperty(it, language_mode);
case LookupIterator::DATA:
return it->GetDataValue();
}
}
- return it->factory()->undefined_value();
+ return ReadAbsentProperty(it, language_mode);
}
@@ -304,7 +305,8 @@ MaybeHandle<Object> JSProxy::GetPropertyWithHandler(Handle<JSProxy> proxy,
}
-MaybeHandle<Object> Object::GetPropertyWithAccessor(LookupIterator* it) {
+MaybeHandle<Object> Object::GetPropertyWithAccessor(
+ LookupIterator* it, LanguageMode language_mode) {
Isolate* isolate = it->isolate();
Handle<Object> structure = it->GetAccessors();
Handle<Object> receiver = it->GetReceiver();
@@ -336,7 +338,7 @@ MaybeHandle<Object> Object::GetPropertyWithAccessor(LookupIterator* it) {
args.Call(call_fun, v8::Utils::ToLocal(name));
RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
if (result.IsEmpty()) {
- return isolate->factory()->undefined_value();
+ return ReadAbsentProperty(isolate, receiver, name, language_mode);
}
Handle<Object> return_value = v8::Utils::OpenHandle(*result);
return_value->VerifyApiCallResultType();
@@ -352,7 +354,7 @@ MaybeHandle<Object> Object::GetPropertyWithAccessor(LookupIterator* it) {
receiver, Handle<JSReceiver>::cast(getter));
}
// Getter is not a function.
- return isolate->factory()->undefined_value();
+ return ReadAbsentProperty(isolate, receiver, it->GetName(), language_mode);
}
@@ -492,7 +494,7 @@ MaybeHandle<Object> JSObject::GetPropertyWithFailedAccessCheck(
Handle<JSObject> checked = it->GetHolder<JSObject>();
while (FindAllCanReadHolder(it)) {
if (it->state() == LookupIterator::ACCESSOR) {
- return GetPropertyWithAccessor(it);
+ return GetPropertyWithAccessor(it, SLOPPY);
}
DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state());
bool done;
@@ -3214,6 +3216,31 @@ MaybeHandle<Object> Object::SetSuperProperty(LookupIterator* it,
}
+MaybeHandle<Object> Object::ReadAbsentProperty(LookupIterator* it,
+ LanguageMode language_mode) {
+ if (is_strong(language_mode)) {
+ THROW_NEW_ERROR(it->isolate(),
+ NewTypeError(MessageTemplate::kStrongPropertyAccess,
+ it->GetName(), it->GetReceiver()),
+ Object);
+ }
+ return it->isolate()->factory()->undefined_value();
+}
+
+MaybeHandle<Object> Object::ReadAbsentProperty(Isolate* isolate,
+ Handle<Object> receiver,
+ Handle<Object> name,
+ LanguageMode language_mode) {
+ if (is_strong(language_mode)) {
+ THROW_NEW_ERROR(
+ isolate,
+ NewTypeError(MessageTemplate::kStrongPropertyAccess, name, receiver),
+ Object);
+ }
+ return isolate->factory()->undefined_value();
+}
+
+
MaybeHandle<Object> Object::WriteToReadOnlyProperty(
LookupIterator* it, Handle<Object> value, LanguageMode language_mode) {
return WriteToReadOnlyProperty(it->isolate(), it->GetReceiver(),
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698