Reviewers: rossberg,
Description:
Fix evaluation order problems in Object.observe hooks.
[email protected]
TEST=gcmole
Please review this at https://codereview.chromium.org/14493012/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/objects.cc
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index
bc05dd5e6dd7853c6251ac2cac1569cd6289ebbb..b51b24f3f31688fe70979146ae1a4abec0a3b012
100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -3278,9 +3278,11 @@ MaybeObject*
JSObject::SetPropertyForResult(LookupResult* lookup,
} else {
LookupResult new_lookup(isolate);
self->LocalLookup(*name, &new_lookup, true);
- if (new_lookup.IsDataProperty() &&
- !Object::GetProperty(self, name)->SameValue(*old_value)) {
- EnqueueChangeRecord(self, "updated", name, old_value);
+ if (new_lookup.IsDataProperty()) {
+ Handle<Object> new_value = Object::GetProperty(self, name);
+ if (!new_value->SameValue(*old_value)) {
+ EnqueueChangeRecord(self, "updated", name, old_value);
+ }
}
}
}
@@ -3430,8 +3432,11 @@ MaybeObject*
JSObject::SetLocalPropertyIgnoreAttributes(
} else {
LookupResult new_lookup(isolate);
self->LocalLookup(*name, &new_lookup, true);
- bool value_changed = new_lookup.IsDataProperty() &&
- !old_value->SameValue(*Object::GetProperty(self, name));
+ bool value_changed = false;
+ if (new_lookup.IsDataProperty()) {
+ Handle<Object> new_value = Object::GetProperty(self, name);
+ value_changed = !old_value->SameValue(*new_value);
+ }
if (new_lookup.GetAttributes() != old_attributes) {
if (!value_changed) old_value =
isolate->factory()->the_hole_value();
EnqueueChangeRecord(self, "reconfigured", name, old_value);
@@ -10974,8 +10979,8 @@ MaybeObject* JSObject::SetElement(uint32_t index,
} else if (old_value->IsTheHole()) {
EnqueueChangeRecord(self, "reconfigured", name, old_value);
} else {
- bool value_changed =
- !old_value->SameValue(*Object::GetElement(self, index));
+ Handle<Object> new_value = Object::GetElement(self, index);
+ bool value_changed = !old_value->SameValue(*new_value);
if (old_attributes != new_attributes) {
if (!value_changed) old_value = isolate->factory()->the_hole_value();
EnqueueChangeRecord(self, "reconfigured", name, old_value);
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.