Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(810)

Side by Side Diff: src/objects.cc

Issue 213823002: Don't pass the hole to SetElement when creating Array.observe change records (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-356589.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 11389 matching lines...) Expand 10 before | Expand all | Expand 10 after
11400 Handle<Object> hresult = 11400 Handle<Object> hresult =
11401 array->GetElementsAccessor()->SetLength(array, new_length_handle); 11401 array->GetElementsAccessor()->SetLength(array, new_length_handle);
11402 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, hresult, hresult); 11402 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, hresult, hresult);
11403 11403
11404 CHECK(array->length()->ToArrayIndex(&new_length)); 11404 CHECK(array->length()->ToArrayIndex(&new_length));
11405 if (old_length == new_length) return hresult; 11405 if (old_length == new_length) return hresult;
11406 11406
11407 BeginPerformSplice(array); 11407 BeginPerformSplice(array);
11408 11408
11409 for (int i = 0; i < indices.length(); ++i) { 11409 for (int i = 0; i < indices.length(); ++i) {
11410 // For deletions where the property was an accessor, old_values[i]
11411 // will be the hole, which instructs EnqueueChangeRecord to elide
11412 // the "oldValue" property.
11410 JSObject::EnqueueChangeRecord( 11413 JSObject::EnqueueChangeRecord(
11411 array, "delete", isolate->factory()->Uint32ToString(indices[i]), 11414 array, "delete", isolate->factory()->Uint32ToString(indices[i]),
11412 old_values[i]); 11415 old_values[i]);
11413 } 11416 }
11414 JSObject::EnqueueChangeRecord( 11417 JSObject::EnqueueChangeRecord(
11415 array, "update", isolate->factory()->length_string(), 11418 array, "update", isolate->factory()->length_string(),
11416 old_length_handle); 11419 old_length_handle);
11417 11420
11418 EndPerformSplice(array); 11421 EndPerformSplice(array);
11419 11422
11420 uint32_t index = Min(old_length, new_length); 11423 uint32_t index = Min(old_length, new_length);
11421 uint32_t add_count = new_length > old_length ? new_length - old_length : 0; 11424 uint32_t add_count = new_length > old_length ? new_length - old_length : 0;
11422 uint32_t delete_count = new_length < old_length ? old_length - new_length : 0; 11425 uint32_t delete_count = new_length < old_length ? old_length - new_length : 0;
11423 Handle<JSArray> deleted = isolate->factory()->NewJSArray(0); 11426 Handle<JSArray> deleted = isolate->factory()->NewJSArray(0);
11424 if (delete_count > 0) { 11427 if (delete_count > 0) {
11425 for (int i = indices.length() - 1; i >= 0; i--) { 11428 for (int i = indices.length() - 1; i >= 0; i--) {
11429 // Skip deletions where the property was an accessor, leaving holes
11430 // in the array of old values.
11431 if (old_values[i]->IsTheHole()) continue;
11426 JSObject::SetElement(deleted, indices[i] - index, old_values[i], NONE, 11432 JSObject::SetElement(deleted, indices[i] - index, old_values[i], NONE,
11427 SLOPPY); 11433 SLOPPY);
11428 } 11434 }
11429 11435
11430 SetProperty(deleted, isolate->factory()->length_string(), 11436 SetProperty(deleted, isolate->factory()->length_string(),
11431 isolate->factory()->NewNumberFromUint(delete_count), 11437 isolate->factory()->NewNumberFromUint(delete_count),
11432 NONE, SLOPPY); 11438 NONE, SLOPPY);
11433 } 11439 }
11434 11440
11435 EnqueueSpliceRecord(array, index, deleted, add_count); 11441 EnqueueSpliceRecord(array, index, deleted, add_count);
(...skipping 4983 matching lines...) Expand 10 before | Expand all | Expand 10 after
16419 #define ERROR_MESSAGES_TEXTS(C, T) T, 16425 #define ERROR_MESSAGES_TEXTS(C, T) T,
16420 static const char* error_messages_[] = { 16426 static const char* error_messages_[] = {
16421 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16427 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16422 }; 16428 };
16423 #undef ERROR_MESSAGES_TEXTS 16429 #undef ERROR_MESSAGES_TEXTS
16424 return error_messages_[reason]; 16430 return error_messages_[reason];
16425 } 16431 }
16426 16432
16427 16433
16428 } } // namespace v8::internal 16434 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-356589.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698