Remove redudant deleted_count argument from EnqueueSpliceRecord
R=rossberg@chromium.org BUG= Review URL: https://codereview.chromium.org/16438010 Patch from Rafael Weinstein <rafaelw@chromium.org>. git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14989 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
72f7abb4c9
commit
0df3857005
@ -399,7 +399,7 @@ function ObservedArrayPop(n) {
|
||||
n--;
|
||||
var value = this[n];
|
||||
|
||||
EnqueueSpliceRecord(this, n, [value], 1, 0);
|
||||
EnqueueSpliceRecord(this, n, [value], 0);
|
||||
|
||||
try {
|
||||
BeginPerformSplice(this);
|
||||
@ -441,7 +441,7 @@ function ObservedArrayPush() {
|
||||
var n = TO_UINT32(this.length);
|
||||
var m = %_ArgumentsLength();
|
||||
|
||||
EnqueueSpliceRecord(this, n, [], 0, m);
|
||||
EnqueueSpliceRecord(this, n, [], m);
|
||||
|
||||
try {
|
||||
BeginPerformSplice(this);
|
||||
@ -581,7 +581,7 @@ function ArrayReverse() {
|
||||
function ObservedArrayShift(len) {
|
||||
var first = this[0];
|
||||
|
||||
EnqueueSpliceRecord(this, 0, [first], 1, 0);
|
||||
EnqueueSpliceRecord(this, 0, [first], 0);
|
||||
|
||||
try {
|
||||
BeginPerformSplice(this);
|
||||
@ -627,7 +627,7 @@ function ObservedArrayUnshift() {
|
||||
var len = TO_UINT32(this.length);
|
||||
var num_arguments = %_ArgumentsLength();
|
||||
|
||||
EnqueueSpliceRecord(this, 0, [], 0, num_arguments);
|
||||
EnqueueSpliceRecord(this, 0, [], num_arguments);
|
||||
|
||||
try {
|
||||
BeginPerformSplice(this);
|
||||
@ -779,7 +779,6 @@ function ObservedArraySplice(start, delete_count) {
|
||||
EnqueueSpliceRecord(this,
|
||||
start_i,
|
||||
deleted_elements.slice(),
|
||||
deleted_elements.length,
|
||||
num_elements_to_add);
|
||||
}
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ function EndPerformSplice(array) {
|
||||
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;
|
||||
@ -307,7 +307,6 @@ function EnqueueSpliceRecord(array, index, removed, deleteCount, addedCount) {
|
||||
addedCount: addedCount
|
||||
};
|
||||
|
||||
changeRecord.removed.length = deleteCount;
|
||||
ObjectFreeze(changeRecord);
|
||||
ObjectFreeze(changeRecord.removed);
|
||||
EnqueueChangeRecord(changeRecord, objectInfo.changeObservers);
|
||||
|
@ -10875,24 +10875,18 @@ static bool GetOldValue(Isolate* isolate,
|
||||
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()),
|
||||
@ -10996,14 +10990,18 @@ MaybeObject* JSArray::SetElementsLength(Object* len) {
|
||||
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;
|
||||
}
|
||||
@ -12069,7 +12067,7 @@ MaybeObject* JSObject::SetElement(uint32_t index,
|
||||
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);
|
||||
|
@ -928,7 +928,6 @@ function DefineArrayProperty(obj, p, desc, should_throw) {
|
||||
EnqueueSpliceRecord(obj,
|
||||
new_length < old_length ? new_length : old_length,
|
||||
removed,
|
||||
removed.length,
|
||||
new_length > old_length ? new_length - old_length : 0);
|
||||
}
|
||||
if (threw) {
|
||||
@ -967,7 +966,7 @@ function DefineArrayProperty(obj, p, desc, should_throw) {
|
||||
}
|
||||
if (emit_splice) {
|
||||
EndPerformSplice(obj);
|
||||
EnqueueSpliceRecord(obj, length, [], 0, index + 1 - length);
|
||||
EnqueueSpliceRecord(obj, length, [], index + 1 - length);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user