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

Unified Diff: src/objects.cc

Issue 9600013: Use an enum for indicating the component of an AccessorPair instead of a boolean flag. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Incorporated review comments. Created 8 years, 10 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/runtime.cc » ('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 a27cc67ce3d6850053cfbb96d00ba3d29ebc33a4..9e93b28127b69ba1520362623e8fa8ec394c57ac 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -4367,7 +4367,7 @@ void JSObject::LookupCallback(String* name, LookupResult* result) {
static bool UpdateGetterSetterInDictionary(
SeededNumberDictionary* dictionary,
uint32_t index,
- bool is_getter,
+ AccessorComponent component,
Object* fun,
PropertyAttributes attributes) {
int entry = dictionary->FindEntry(index);
@@ -4381,7 +4381,7 @@ static bool UpdateGetterSetterInDictionary(
dictionary->DetailsAtPut(entry,
PropertyDetails(attributes, CALLBACKS, index));
}
- AccessorPair::cast(result)->set(is_getter, fun);
+ AccessorPair::cast(result)->set(component, fun);
return true;
}
}
@@ -4390,7 +4390,7 @@ static bool UpdateGetterSetterInDictionary(
MaybeObject* JSObject::DefineElementAccessor(uint32_t index,
- bool is_getter,
+ AccessorComponent component,
Object* fun,
PropertyAttributes attributes) {
switch (GetElementsKind()) {
@@ -4412,7 +4412,7 @@ MaybeObject* JSObject::DefineElementAccessor(uint32_t index,
case DICTIONARY_ELEMENTS:
if (UpdateGetterSetterInDictionary(element_dictionary(),
index,
- is_getter,
+ component,
fun,
attributes)) {
return GetHeap()->undefined_value();
@@ -4433,7 +4433,7 @@ MaybeObject* JSObject::DefineElementAccessor(uint32_t index,
SeededNumberDictionary::cast(arguments);
if (UpdateGetterSetterInDictionary(dictionary,
index,
- is_getter,
+ component,
fun,
attributes)) {
return GetHeap()->undefined_value();
@@ -4448,14 +4448,14 @@ MaybeObject* JSObject::DefineElementAccessor(uint32_t index,
{ MaybeObject* maybe_accessors = GetHeap()->AllocateAccessorPair();
if (!maybe_accessors->To(&accessors)) return maybe_accessors;
}
- accessors->set(is_getter, fun);
+ accessors->set(component, fun);
return SetElementCallback(index, accessors, attributes);
}
MaybeObject* JSObject::DefinePropertyAccessor(String* name,
- bool is_getter,
+ AccessorComponent component,
Object* fun,
PropertyAttributes attributes) {
// Lookup the name.
@@ -4473,7 +4473,7 @@ MaybeObject* JSObject::DefinePropertyAccessor(String* name,
AccessorPair::cast(obj)->CopyWithoutTransitions();
if (!maybe_copy->To(&copy)) return maybe_copy;
}
- copy->set(is_getter, fun);
+ copy->set(component, fun);
// Use set to update attributes.
return SetPropertyCallback(name, copy, attributes);
}
@@ -4484,7 +4484,7 @@ MaybeObject* JSObject::DefinePropertyAccessor(String* name,
{ MaybeObject* maybe_accessors = GetHeap()->AllocateAccessorPair();
if (!maybe_accessors->To(&accessors)) return maybe_accessors;
}
- accessors->set(is_getter, fun);
+ accessors->set(component, fun);
return SetPropertyCallback(name, accessors, attributes);
}
@@ -4593,7 +4593,7 @@ MaybeObject* JSObject::SetPropertyCallback(String* name,
}
MaybeObject* JSObject::DefineAccessor(String* name,
- bool is_getter,
+ AccessorComponent component,
Object* fun,
PropertyAttributes attributes) {
ASSERT(fun->IsSpecFunction() || fun->IsUndefined());
@@ -4609,7 +4609,7 @@ MaybeObject* JSObject::DefineAccessor(String* name,
Object* proto = GetPrototype();
if (proto->IsNull()) return this;
ASSERT(proto->IsJSGlobalObject());
- return JSObject::cast(proto)->DefineAccessor(name, is_getter,
+ return JSObject::cast(proto)->DefineAccessor(name, component,
fun, attributes);
}
@@ -4624,8 +4624,8 @@ MaybeObject* JSObject::DefineAccessor(String* name,
uint32_t index = 0;
return name->AsArrayIndex(&index) ?
- DefineElementAccessor(index, is_getter, fun, attributes) :
- DefinePropertyAccessor(name, is_getter, fun, attributes);
+ DefineElementAccessor(index, component, fun, attributes) :
+ DefinePropertyAccessor(name, component, fun, attributes);
}
@@ -4711,7 +4711,7 @@ MaybeObject* JSObject::DefineAccessor(AccessorInfo* info) {
}
-Object* JSObject::LookupAccessor(String* name, bool is_getter) {
+Object* JSObject::LookupAccessor(String* name, AccessorComponent component) {
Heap* heap = GetHeap();
// Make sure that the top context does not change when doing callbacks or
@@ -4737,12 +4737,9 @@ Object* JSObject::LookupAccessor(String* name, bool is_getter) {
int entry = dictionary->FindEntry(index);
if (entry != SeededNumberDictionary::kNotFound) {
Object* element = dictionary->ValueAt(entry);
- PropertyDetails details = dictionary->DetailsAt(entry);
- if (details.type() == CALLBACKS) {
- if (element->IsAccessorPair()) {
- AccessorPair* accessors = AccessorPair::cast(element);
- return is_getter ? accessors->getter() : accessors->setter();
- }
+ if (dictionary->DetailsAt(entry).type() == CALLBACKS &&
+ element->IsAccessorPair()) {
+ return AccessorPair::cast(element)->get(component);
}
}
}
@@ -4758,8 +4755,7 @@ Object* JSObject::LookupAccessor(String* name, bool is_getter) {
if (result.type() == CALLBACKS) {
Object* obj = result.GetCallbackObject();
if (obj->IsAccessorPair()) {
- AccessorPair* accessors = AccessorPair::cast(obj);
- return is_getter ? accessors->getter() : accessors->setter();
+ return AccessorPair::cast(obj)->get(component);
}
}
}
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698