Commit 13f722ca authored by rafaelw@chromium.org's avatar rafaelw@chromium.org

[Object.observe] rename intrinsic change record types for consitency.

Note the spec now reflects the updated naming:

http://wiki.ecmascript.org/doku.php?id=harmony:observe_spec_changes

R=rossberg@chromium.org, rossberg
BUG=v8:2940

Review URL: https://codereview.chromium.org/46043020

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17520 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent a380ffc3
......@@ -617,7 +617,7 @@ MaybeObject* Accessors::FunctionSetPrototype(Isolate* isolate,
if (is_observed && !old_value->SameValue(*value)) {
JSObject::EnqueueChangeRecord(
function, "updated", isolate->factory()->prototype_string(), old_value);
function, "update", isolate->factory()->prototype_string(), old_value);
}
return *function;
......
......@@ -128,11 +128,11 @@ function TypeMapIsDisjointFrom(typeMap1, typeMap2) {
}
var defaultAcceptTypes = TypeMapCreateFromList([
'new',
'updated',
'deleted',
'prototype',
'reconfigured',
'add',
'update',
'delete',
'setPrototype',
'reconfigure',
'preventExtensions'
]);
......@@ -353,9 +353,9 @@ function ObjectUnobserve(object, callback) {
}
function ArrayObserve(object, callback) {
return ObjectObserve(object, callback, ['new',
'updated',
'deleted',
return ObjectObserve(object, callback, ['add',
'update',
'delete',
'splice']);
}
......
......@@ -2157,7 +2157,7 @@ Handle<Object> JSObject::AddProperty(Handle<JSObject> object,
object->map()->is_observed() &&
*name != isolate->heap()->hidden_string()) {
Handle<Object> old_value = isolate->factory()->the_hole_value();
EnqueueChangeRecord(object, "new", name, old_value);
EnqueueChangeRecord(object, "add", name, old_value);
}
return value;
......@@ -4105,14 +4105,14 @@ Handle<Object> JSObject::SetPropertyForResult(Handle<JSObject> object,
if (is_observed) {
if (lookup->IsTransition()) {
EnqueueChangeRecord(object, "new", name, old_value);
EnqueueChangeRecord(object, "add", name, old_value);
} else {
LookupResult new_lookup(isolate);
object->LocalLookup(*name, &new_lookup, true);
if (new_lookup.IsDataProperty()) {
Handle<Object> new_value = Object::GetProperty(object, name);
if (!new_value->SameValue(*old_value)) {
EnqueueChangeRecord(object, "updated", name, old_value);
EnqueueChangeRecord(object, "update", name, old_value);
}
}
}
......@@ -4222,9 +4222,9 @@ Handle<Object> JSObject::SetLocalPropertyIgnoreAttributes(
if (is_observed) {
if (lookup.IsTransition()) {
EnqueueChangeRecord(object, "new", name, old_value);
EnqueueChangeRecord(object, "add", name, old_value);
} else if (old_value->IsTheHole()) {
EnqueueChangeRecord(object, "reconfigured", name, old_value);
EnqueueChangeRecord(object, "reconfigure", name, old_value);
} else {
LookupResult new_lookup(isolate);
object->LocalLookup(*name, &new_lookup, true);
......@@ -4235,9 +4235,9 @@ Handle<Object> JSObject::SetLocalPropertyIgnoreAttributes(
}
if (new_lookup.GetAttributes() != old_attributes) {
if (!value_changed) old_value = isolate->factory()->the_hole_value();
EnqueueChangeRecord(object, "reconfigured", name, old_value);
EnqueueChangeRecord(object, "reconfigure", name, old_value);
} else if (value_changed) {
EnqueueChangeRecord(object, "updated", name, old_value);
EnqueueChangeRecord(object, "update", name, old_value);
}
}
}
......@@ -5183,7 +5183,7 @@ Handle<Object> JSObject::DeleteElement(Handle<JSObject> object,
if (should_enqueue_change_record && !HasLocalElement(object, index)) {
Handle<String> name = factory->Uint32ToString(index);
EnqueueChangeRecord(object, "deleted", name, old_value);
EnqueueChangeRecord(object, "delete", name, old_value);
}
return result;
......@@ -5259,7 +5259,7 @@ Handle<Object> JSObject::DeleteProperty(Handle<JSObject> object,
}
if (is_observed && !HasLocalProperty(object, name)) {
EnqueueChangeRecord(object, "deleted", name, old_value);
EnqueueChangeRecord(object, "delete", name, old_value);
}
return result;
......@@ -6349,7 +6349,7 @@ void JSObject::DefineAccessor(Handle<JSObject> object,
}
if (is_observed) {
const char* type = preexists ? "reconfigured" : "new";
const char* type = preexists ? "reconfigure" : "add";
EnqueueChangeRecord(object, type, name, old_value);
}
}
......@@ -11453,11 +11453,11 @@ MaybeObject* JSArray::SetElementsLength(Object* len) {
for (int i = 0; i < indices.length(); ++i) {
JSObject::EnqueueChangeRecord(
self, "deleted", isolate->factory()->Uint32ToString(indices[i]),
self, "delete", isolate->factory()->Uint32ToString(indices[i]),
old_values[i]);
}
JSObject::EnqueueChangeRecord(
self, "updated", isolate->factory()->length_string(),
self, "update", isolate->factory()->length_string(),
old_length_handle);
EndPerformSplice(self);
......@@ -12603,26 +12603,26 @@ MaybeObject* JSObject::SetElement(uint32_t index,
CHECK(new_length_handle->ToArrayIndex(&new_length));
BeginPerformSplice(Handle<JSArray>::cast(self));
EnqueueChangeRecord(self, "new", name, old_value);
EnqueueChangeRecord(self, "updated", isolate->factory()->length_string(),
EnqueueChangeRecord(self, "add", name, old_value);
EnqueueChangeRecord(self, "update", isolate->factory()->length_string(),
old_length_handle);
EndPerformSplice(Handle<JSArray>::cast(self));
Handle<JSArray> deleted = isolate->factory()->NewJSArray(0);
EnqueueSpliceRecord(Handle<JSArray>::cast(self), old_length, deleted,
new_length - old_length);
} else {
EnqueueChangeRecord(self, "new", name, old_value);
EnqueueChangeRecord(self, "add", name, old_value);
}
} else if (old_value->IsTheHole()) {
EnqueueChangeRecord(self, "reconfigured", name, old_value);
EnqueueChangeRecord(self, "reconfigure", name, old_value);
} else {
Handle<Object> new_value = Object::GetElement(isolate, 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);
EnqueueChangeRecord(self, "reconfigure", name, old_value);
} else if (value_changed) {
EnqueueChangeRecord(self, "updated", name, old_value);
EnqueueChangeRecord(self, "update", name, old_value);
}
}
......
......@@ -1620,7 +1620,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetPrototype) {
Handle<Object> new_value(
GetPrototypeSkipHiddenPrototypes(isolate, *obj), isolate);
if (!new_value->SameValue(*old_value)) {
JSObject::EnqueueChangeRecord(obj, "prototype",
JSObject::EnqueueChangeRecord(obj, "setPrototype",
isolate->factory()->proto_string(),
old_value);
}
......
......@@ -356,17 +356,17 @@ TEST(APITestBasicMutation) {
CompileRun("void 0");
CHECK_EQ(9, CompileRun("records.length")->Int32Value());
const RecordExpectation expected_records[] = {
{ obj, "new", "foo", Handle<Value>() },
{ obj, "new", "1", Handle<Value>() },
{ obj, "add", "foo", Handle<Value>() },
{ obj, "add", "1", Handle<Value>() },
// Note: use 7 not 1 below, as the latter triggers a nifty VS10 compiler bug
// where instead of 1.0, a garbage value would be passed into Number::New.
{ obj, "updated", "foo", Number::New(7) },
{ obj, "updated", "1", Number::New(2) },
{ obj, "updated", "1", Number::New(4) },
{ obj, "new", "1.1", Handle<Value>() },
{ obj, "deleted", "foo", Number::New(3) },
{ obj, "deleted", "1", Number::New(5) },
{ obj, "deleted", "1.1", Number::New(6) }
{ obj, "update", "foo", Number::New(7) },
{ obj, "update", "1", Number::New(2) },
{ obj, "update", "1", Number::New(4) },
{ obj, "add", "1.1", Handle<Value>() },
{ obj, "delete", "foo", Number::New(3) },
{ obj, "delete", "1", Number::New(5) },
{ obj, "delete", "1.1", Number::New(6) }
};
EXPECT_RECORDS(CompileRun("records"), expected_records);
}
......@@ -391,13 +391,13 @@ TEST(HiddenPrototypeObservation) {
"obj.foo = 41;" // triggers a notification
"proto.foo = 42;"); // does not trigger a notification
const RecordExpectation expected_records[] = {
{ obj, "updated", "foo", Number::New(75) }
{ obj, "update", "foo", Number::New(75) }
};
EXPECT_RECORDS(CompileRun("records"), expected_records);
obj->SetPrototype(Null(isolate.GetIsolate()));
CompileRun("obj.foo = 43");
const RecordExpectation expected_records2[] = {
{ obj, "new", "foo", Handle<Value>() }
{ obj, "add", "foo", Handle<Value>() }
};
EXPECT_RECORDS(CompileRun("records"), expected_records2);
obj->SetPrototype(proto);
......@@ -407,10 +407,10 @@ TEST(HiddenPrototypeObservation) {
"Object.unobserve(obj, observer);"
"obj.foo = 44;");
const RecordExpectation expected_records3[] = {
{ proto, "new", "bar", Handle<Value>() }
{ proto, "add", "bar", Handle<Value>() }
// TODO(adamk): The below record should be emitted since proto is observed
// and has been modified. Not clear if this happens in practice.
// { proto, "updated", "foo", Number::New(43) }
// { proto, "update", "foo", Number::New(43) }
};
EXPECT_RECORDS(CompileRun("records"), expected_records3);
}
......@@ -548,17 +548,17 @@ TEST(NamedAccessCheck) {
"obj.bar = 'baz';"
"objNoCheck.baz = 'quux'");
const RecordExpectation expected_records2[] = {
{ instance, "new", "foo", Handle<Value>() },
{ instance, "updated", "foo", String::New("bar") },
{ instance, "reconfigured", "foo", Number::New(5) },
{ instance, "new", "bar", Handle<Value>() },
{ obj_no_check, "new", "baz", Handle<Value>() },
{ instance, "add", "foo", Handle<Value>() },
{ instance, "update", "foo", String::New("bar") },
{ instance, "reconfigure", "foo", Number::New(5) },
{ instance, "add", "bar", Handle<Value>() },
{ obj_no_check, "add", "baz", Handle<Value>() },
};
EXPECT_RECORDS(CompileRun("records2"), expected_records2);
}
const RecordExpectation expected_records[] = {
{ instance, "new", "bar", Handle<Value>() },
{ obj_no_check, "new", "baz", Handle<Value>() }
{ instance, "add", "bar", Handle<Value>() },
{ obj_no_check, "add", "baz", Handle<Value>() }
};
EXPECT_RECORDS(CompileRun("records"), expected_records);
}
......@@ -595,17 +595,17 @@ TEST(IndexedAccessCheck) {
"obj[8] = 'bar';"
"objNoCheck[42] = 'quux'");
const RecordExpectation expected_records2[] = {
{ instance, "new", "7", Handle<Value>() },
{ instance, "updated", "7", String::New("foo") },
{ instance, "reconfigured", "7", Number::New(5) },
{ instance, "new", "8", Handle<Value>() },
{ obj_no_check, "new", "42", Handle<Value>() }
{ instance, "add", "7", Handle<Value>() },
{ instance, "update", "7", String::New("foo") },
{ instance, "reconfigure", "7", Number::New(5) },
{ instance, "add", "8", Handle<Value>() },
{ obj_no_check, "add", "42", Handle<Value>() }
};
EXPECT_RECORDS(CompileRun("records2"), expected_records2);
}
const RecordExpectation expected_records[] = {
{ instance, "new", "8", Handle<Value>() },
{ obj_no_check, "new", "42", Handle<Value>() }
{ instance, "add", "8", Handle<Value>() },
{ obj_no_check, "add", "42", Handle<Value>() }
};
EXPECT_RECORDS(CompileRun("records"), expected_records);
}
......@@ -681,14 +681,14 @@ TEST(DisallowAllForAccessKeys) {
"obj[5] = 'baz';"
"objNoCheck.baz = 'quux'");
const RecordExpectation expected_records2[] = {
{ instance, "new", "foo", Handle<Value>() },
{ instance, "new", "5", Handle<Value>() },
{ obj_no_check, "new", "baz", Handle<Value>() },
{ instance, "add", "foo", Handle<Value>() },
{ instance, "add", "5", Handle<Value>() },
{ obj_no_check, "add", "baz", Handle<Value>() },
};
EXPECT_RECORDS(CompileRun("records2"), expected_records2);
}
const RecordExpectation expected_records[] = {
{ obj_no_check, "new", "baz", Handle<Value>() }
{ obj_no_check, "add", "baz", Handle<Value>() }
};
EXPECT_RECORDS(CompileRun("records"), expected_records);
}
......@@ -713,8 +713,8 @@ TEST(AccessCheckDisallowApiModifications) {
instance->Set(String::New("foo"), String::New("bar"));
CompileRun(""); // trigger delivery
const RecordExpectation expected_records2[] = {
{ instance, "new", "5", Handle<Value>() },
{ instance, "new", "foo", Handle<Value>() }
{ instance, "add", "5", Handle<Value>() },
{ instance, "add", "foo", Handle<Value>() }
};
EXPECT_RECORDS(CompileRun("records2"), expected_records2);
}
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment