n--;
var value = this[n];
- EnqueueSpliceRecord(this, n, [value], 1, 0);
+ EnqueueSpliceRecord(this, n, [value], 0);
try {
BeginPerformSplice(this);
var n = TO_UINT32(this.length);
var m = %_ArgumentsLength();
- EnqueueSpliceRecord(this, n, [], 0, m);
+ EnqueueSpliceRecord(this, n, [], m);
try {
BeginPerformSplice(this);
function ObservedArrayShift(len) {
var first = this[0];
- EnqueueSpliceRecord(this, 0, [first], 1, 0);
+ EnqueueSpliceRecord(this, 0, [first], 0);
try {
BeginPerformSplice(this);
var len = TO_UINT32(this.length);
var num_arguments = %_ArgumentsLength();
- EnqueueSpliceRecord(this, 0, [], 0, num_arguments);
+ EnqueueSpliceRecord(this, 0, [], num_arguments);
try {
BeginPerformSplice(this);
EnqueueSpliceRecord(this,
start_i,
deleted_elements.slice(),
- deleted_elements.length,
num_elements_to_add);
}
}
EndPerformChange(objectInfo, 'splice');
}
-function EnqueueSpliceRecord(array, index, removed, deleteCount, addedCount) {
+function EnqueueSpliceRecord(array, index, removed, addedCount) {
var objectInfo = objectInfoMap.get(array);
if (IS_UNDEFINED(objectInfo) || objectInfo.changeObservers.length === 0)
return;
addedCount: addedCount
};
- changeRecord.removed.length = deleteCount;
ObjectFreeze(changeRecord);
ObjectFreeze(changeRecord.removed);
EnqueueChangeRecord(changeRecord, objectInfo.changeObservers);
return true;
}
-
-// TODO(rafaelw): Remove |delete_count| argument and rely on the length of
-// of |deleted|.
static void EnqueueSpliceRecord(Handle<JSArray> object,
uint32_t index,
Handle<JSArray> deleted,
- uint32_t delete_count,
uint32_t add_count) {
Isolate* isolate = object->GetIsolate();
HandleScope scope(isolate);
Handle<Object> index_object = isolate->factory()->NewNumberFromUint(index);
- Handle<Object> delete_count_object =
- isolate->factory()->NewNumberFromUint(delete_count);
Handle<Object> add_count_object =
isolate->factory()->NewNumberFromUint(add_count);
Handle<Object> args[] =
- { object, index_object, deleted, delete_count_object, add_count_object };
+ { object, index_object, deleted, add_count_object };
bool threw;
Execution::Call(Handle<JSFunction>(isolate->observers_enqueue_splice()),
uint32_t add_count = new_length > old_length ? new_length - old_length : 0;
uint32_t delete_count = new_length < old_length ? old_length - new_length : 0;
Handle<JSArray> deleted = isolate->factory()->NewJSArray(0);
- if (delete_count) {
+ if (delete_count > 0) {
for (int i = indices.length() - 1; i >= 0; i--) {
JSObject::SetElement(deleted, indices[i] - index, old_values[i], NONE,
kNonStrictMode);
}
+
+ SetProperty(deleted, isolate->factory()->length_string(),
+ isolate->factory()->NewNumberFromUint(delete_count),
+ NONE, kNonStrictMode);
}
- EnqueueSpliceRecord(self, index, deleted, delete_count, add_count);
+ EnqueueSpliceRecord(self, index, deleted, add_count);
return *hresult;
}
old_length_handle);
EndPerformSplice(Handle<JSArray>::cast(self));
Handle<JSArray> deleted = isolate->factory()->NewJSArray(0);
- EnqueueSpliceRecord(Handle<JSArray>::cast(self), old_length, deleted, 0,
+ EnqueueSpliceRecord(Handle<JSArray>::cast(self), old_length, deleted,
new_length - old_length);
} else {
EnqueueChangeRecord(self, "new", name, old_value);
EnqueueSpliceRecord(obj,
new_length < old_length ? new_length : old_length,
removed,
- removed.length,
new_length > old_length ? new_length - old_length : 0);
}
if (threw) {
}
if (emit_splice) {
EndPerformSplice(obj);
- EnqueueSpliceRecord(obj, length, [], 0, index + 1 - length);
+ EnqueueSpliceRecord(obj, length, [], index + 1 - length);
}
return true;
}