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

Unified Diff: src/objects.cc

Issue 10071009: Prepare DefinePropertyAccessor for callback transitions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 8 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') | no next file » | 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 a4f63a1ca2d79698c96e2f7d6cdec554a884dd5f..961876b7d08e0fc1548c390b20b61be837e150c1 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -4410,37 +4410,29 @@ MaybeObject* JSObject::DefineElementAccessor(uint32_t index,
}
-MaybeObject* JSObject::DefinePropertyAccessor(String* name,
- Object* getter,
- Object* setter,
- PropertyAttributes attributes) {
- // Lookup the name.
+MaybeObject* JSObject::CreateAccessorPairFor(String* name) {
LookupResult result(GetHeap()->isolate());
LocalLookupRealNamedProperty(name, &result);
- if (result.IsFound()) {
- if (result.type() == CALLBACKS) {
- ASSERT(!result.IsDontDelete());
- Object* obj = result.GetCallbackObject();
- // Need to preserve old getters/setters.
- if (obj->IsAccessorPair()) {
- AccessorPair* copy;
- { MaybeObject* maybe_copy =
- AccessorPair::cast(obj)->CopyWithoutTransitions();
- if (!maybe_copy->To(&copy)) return maybe_copy;
- }
- copy->SetComponents(getter, setter);
- // Use set to update attributes.
- return SetPropertyCallback(name, copy, attributes);
- }
+ if (result.IsProperty() && result.type() == CALLBACKS) {
+ ASSERT(!result.IsDontDelete());
+ Object* obj = result.GetCallbackObject();
+ if (obj->IsAccessorPair()) {
+ return AccessorPair::cast(obj)->CopyWithoutTransitions();
}
}
+ return GetHeap()->AllocateAccessorPair();
+}
+
+MaybeObject* JSObject::DefinePropertyAccessor(String* name,
+ Object* getter,
+ Object* setter,
+ PropertyAttributes attributes) {
AccessorPair* accessors;
- { MaybeObject* maybe_accessors = GetHeap()->AllocateAccessorPair();
+ { MaybeObject* maybe_accessors = CreateAccessorPairFor(name);
if (!maybe_accessors->To(&accessors)) return maybe_accessors;
}
accessors->SetComponents(getter, setter);
-
return SetPropertyCallback(name, accessors, attributes);
}
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698