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

Unified Diff: src/v8natives.js

Issue 1224523002: Avoid converting key to string for deleting of elements (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime-object.cc ('k') | test/mjsunit/messages.js » ('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 f556c397399332cff46f594dd010492fdacf614d..72cb8caa29c076e01856e9d76c9dc7c516226415 100644
--- a/src/v8natives.js
+++ b/src/v8natives.js
@@ -802,72 +802,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.
- 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 MakeRangeError(kArrayLengthOutOfRange);
- }
- var length_desc = GetOwnPropertyJS(obj, "length");
- if (new_length != length && !length_desc.isWritable()) {
- if (should_throw) {
- throw MakeTypeError(kRedefineDisallowed, p);
- } else {
- return false;
- }
- }
- var threw = false;
-
- var emit_splice = %IsObserved(obj) && new_length !== old_length;
- var removed;
- if (emit_splice) {
- $observeBeginPerformSplice(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;
- }
- }
- threw = !DefineObjectProperty(obj, "length", desc, should_throw) || threw;
- if (emit_splice) {
- $observeEndPerformSplice(obj);
- $observeEnqueueSpliceRecord(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(kRedefineDisallowed, p);
- } else {
- return false;
- }
- }
- return true;
- }
-
- // Step 4 - Special handling for array index.
+ // Step 3 - Special handling for array index.
if (!IS_SYMBOL(p)) {
var index = $toUint32(p);
var emit_splice = false;
« no previous file with comments | « src/runtime/runtime-object.cc ('k') | test/mjsunit/messages.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698