Chromium Code Reviews

Unified Diff: src/v8natives.js

Issue 791243002: Stop sending Object.observe notifications for API accessor properties (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « src/objects.cc ('k') | test/cctest/test-object-observe.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/v8natives.js
diff --git a/src/v8natives.js b/src/v8natives.js
index 44ad6de622fc73e7687259b23e7b0a388537b993..6121d311323687bda3179d15e4f017c9fe63e08c 100644
--- a/src/v8natives.js
+++ b/src/v8natives.js
@@ -840,81 +840,7 @@ function DefineObjectProperty(obj, p, desc, should_throw) {
// ES5 section 15.4.5.1.
function DefineArrayProperty(obj, p, desc, should_throw) {
- // Note that the length of an array is not actually stored as part of the
- // property, hence we use generated code throughout this function instead of
- // DefineObjectProperty() to modify its value.
-
- // Step 3 - Special handling for length property.
Jakob Kummerow 2014/12/11 11:41:40 Some of this code was ~3 years old and seems unrel
adamk 2014/12/11 16:47:26 Arg, you're right, test262 not being in make check
- if (p === "length") {
- var length = obj.length;
- var old_length = length;
- if (!desc.hasValue()) {
- return DefineObjectProperty(obj, "length", desc, should_throw);
- }
- var new_length = ToUint32(desc.getValue());
- if (new_length != ToNumber(desc.getValue())) {
- throw new $RangeError('defineProperty() array length out of range');
- }
- var length_desc = GetOwnPropertyJS(obj, "length");
- if (new_length != length && !length_desc.isWritable()) {
- if (should_throw) {
- throw MakeTypeError("redefine_disallowed", [p]);
- } else {
- return false;
- }
- }
- var threw = false;
-
- var emit_splice = %IsObserved(obj) && new_length !== old_length;
- var removed;
- if (emit_splice) {
- BeginPerformSplice(obj);
- removed = [];
- if (new_length < old_length)
- removed.length = old_length - new_length;
- }
-
- while (new_length < length--) {
- var index = ToString(length);
- if (emit_splice) {
- var deletedDesc = GetOwnPropertyJS(obj, index);
- if (deletedDesc && deletedDesc.hasValue())
- removed[length - new_length] = deletedDesc.getValue();
- }
- if (!Delete(obj, index, false)) {
- new_length = length + 1;
- threw = true;
- break;
- }
- }
- // Make sure the below call to DefineObjectProperty() doesn't overwrite
- // any magic "length" property by removing the value.
- // TODO(mstarzinger): This hack should be removed once we have addressed the
- // respective TODO in Runtime_DefineDataPropertyUnchecked.
- // For the time being, we need a hack to prevent Object.observe from
- // generating two change records.
- obj.length = new_length;
- desc.value_ = UNDEFINED;
- desc.hasValue_ = false;
- threw = !DefineObjectProperty(obj, "length", desc, should_throw) || threw;
- if (emit_splice) {
- EndPerformSplice(obj);
- EnqueueSpliceRecord(obj,
- new_length < old_length ? new_length : old_length,
- removed,
- new_length > old_length ? new_length - old_length : 0);
- }
- if (threw) {
- if (should_throw) {
- throw MakeTypeError("redefine_disallowed", [p]);
- } else {
- return false;
- }
- }
- return true;
- }
-
- // Step 4 - Special handling for array index.
+ // Special handling for array index.
if (!IS_SYMBOL(p)) {
var index = ToUint32(p);
var emit_splice = false;
@@ -947,7 +873,7 @@ function DefineArrayProperty(obj, p, desc, should_throw) {
}
}
- // Step 5 - Fallback to default implementation.
+ // Fallback to default implementation.
return DefineObjectProperty(obj, p, desc, should_throw);
}
« no previous file with comments | « src/objects.cc ('k') | test/cctest/test-object-observe.cc » ('j') | no next file with comments »

Powered by Google App Engine