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

Unified Diff: src/property-descriptor.cc

Issue 1775973002: Add GetProperty/GetElement to JSReceiver and use it where possible (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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-inl.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/property-descriptor.cc
diff --git a/src/property-descriptor.cc b/src/property-descriptor.cc
index 19844a0502e5853694270e6103c309783cf65fef..31efb413b6a74dc48435fb69323d9553311e41b6 100644
--- a/src/property-descriptor.cc
+++ b/src/property-descriptor.cc
@@ -18,9 +18,9 @@ namespace {
// Helper function for ToPropertyDescriptor. Comments describe steps for
// "enumerable", other properties are handled the same way.
// Returns false if an exception was thrown.
-bool GetPropertyIfPresent(Handle<Object> obj, Handle<String> name,
+bool GetPropertyIfPresent(Handle<JSReceiver> receiver, Handle<String> name,
Handle<Object>* value) {
- LookupIterator it(obj, name);
+ LookupIterator it(receiver, name, receiver);
// 4. Let hasEnumerable be HasProperty(Obj, "enumerable").
Maybe<bool> has_property = JSReceiver::HasProperty(&it);
// 5. ReturnIfAbrupt(hasEnumerable).
@@ -29,7 +29,7 @@ bool GetPropertyIfPresent(Handle<Object> obj, Handle<String> name,
if (has_property.FromJust() == true) {
// 6a. Let enum be ToBoolean(Get(Obj, "enumerable")).
// 6b. ReturnIfAbrupt(enum).
- if (!JSObject::GetProperty(&it).ToHandle(value)) return false;
+ if (!Object::GetProperty(&it).ToHandle(value)) return false;
}
return true;
}
@@ -39,7 +39,7 @@ bool GetPropertyIfPresent(Handle<Object> obj, Handle<String> name,
// objects: nothing on the prototype chain, just own fast data properties.
// Must not have observable side effects, because the slow path will restart
// the entire conversion!
-bool ToPropertyDescriptorFastPath(Isolate* isolate, Handle<Object> obj,
+bool ToPropertyDescriptorFastPath(Isolate* isolate, Handle<JSReceiver> obj,
PropertyDescriptor* desc) {
if (!obj->IsJSObject()) return false;
Map* map = Handle<JSObject>::cast(obj)->map();
@@ -190,14 +190,15 @@ bool PropertyDescriptor::ToPropertyDescriptor(Isolate* isolate,
// 3. Let desc be a new Property Descriptor that initially has no fields.
DCHECK(desc->is_empty());
- if (ToPropertyDescriptorFastPath(isolate, obj, desc)) {
+ Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(obj);
+ if (ToPropertyDescriptorFastPath(isolate, receiver, desc)) {
return true;
}
// enumerable?
Handle<Object> enumerable;
// 4 through 6b.
- if (!GetPropertyIfPresent(obj, isolate->factory()->enumerable_string(),
+ if (!GetPropertyIfPresent(receiver, isolate->factory()->enumerable_string(),
&enumerable)) {
return false;
}
@@ -209,7 +210,7 @@ bool PropertyDescriptor::ToPropertyDescriptor(Isolate* isolate,
// configurable?
Handle<Object> configurable;
// 7 through 9b.
- if (!GetPropertyIfPresent(obj, isolate->factory()->configurable_string(),
+ if (!GetPropertyIfPresent(receiver, isolate->factory()->configurable_string(),
&configurable)) {
return false;
}
@@ -221,7 +222,8 @@ bool PropertyDescriptor::ToPropertyDescriptor(Isolate* isolate,
// value?
Handle<Object> value;
// 10 through 12b.
- if (!GetPropertyIfPresent(obj, isolate->factory()->value_string(), &value)) {
+ if (!GetPropertyIfPresent(receiver, isolate->factory()->value_string(),
+ &value)) {
return false;
}
// 12c. Set the [[Value]] field of desc to value.
@@ -230,7 +232,7 @@ bool PropertyDescriptor::ToPropertyDescriptor(Isolate* isolate,
// writable?
Handle<Object> writable;
// 13 through 15b.
- if (!GetPropertyIfPresent(obj, isolate->factory()->writable_string(),
+ if (!GetPropertyIfPresent(receiver, isolate->factory()->writable_string(),
&writable)) {
return false;
}
@@ -240,7 +242,8 @@ bool PropertyDescriptor::ToPropertyDescriptor(Isolate* isolate,
// getter?
Handle<Object> getter;
// 16 through 18b.
- if (!GetPropertyIfPresent(obj, isolate->factory()->get_string(), &getter)) {
+ if (!GetPropertyIfPresent(receiver, isolate->factory()->get_string(),
+ &getter)) {
return false;
}
if (!getter.is_null()) {
@@ -257,7 +260,8 @@ bool PropertyDescriptor::ToPropertyDescriptor(Isolate* isolate,
// setter?
Handle<Object> setter;
// 19 through 21b.
- if (!GetPropertyIfPresent(obj, isolate->factory()->set_string(), &setter)) {
+ if (!GetPropertyIfPresent(receiver, isolate->factory()->set_string(),
+ &setter)) {
return false;
}
if (!setter.is_null()) {
« no previous file with comments | « src/objects-inl.h ('k') | src/runtime/runtime-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698