From 98e0eac76f3f5f1334fb45b321995de1c13902e1 Mon Sep 17 00:00:00 2001 From: "adamk@chromium.org" Date: Wed, 22 Oct 2014 18:16:35 +0000 Subject: [PATCH] Speed up creation of Objects whose prototype has dictionary elements This speeds up both the case from the bug (using Object.create) but also takes care ofthe "{ __proto__: obj }" syntax, which was previously (and erroneously) being treated the same as setting the prototype dynamically from script using the __proto__ setter or Object.setPrototypeOf. BUG=chromium:422754 LOG=y R=mvstanton@chromium.org Review URL: https://codereview.chromium.org/667253002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24814 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/full-codegen-arm.cc | 2 +- src/arm64/full-codegen-arm64.cc | 2 +- src/compiler/ast-graph-builder.cc | 2 +- src/ia32/full-codegen-ia32.cc | 2 +- src/mips/full-codegen-mips.cc | 2 +- src/mips64/full-codegen-mips64.cc | 2 +- src/objects.cc | 2 +- src/x64/full-codegen-x64.cc | 2 +- src/x87/full-codegen-x87.cc | 2 +- test/mjsunit/fast-prototype.js | 4 ++-- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc index d40833f8ed..01fa5c5698 100644 --- a/src/arm/full-codegen-arm.cc +++ b/src/arm/full-codegen-arm.cc @@ -1760,7 +1760,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { __ push(r0); VisitForStackValue(value); if (property->emit_store()) { - __ CallRuntime(Runtime::kSetPrototype, 2); + __ CallRuntime(Runtime::kInternalSetPrototype, 2); } else { __ Drop(2); } diff --git a/src/arm64/full-codegen-arm64.cc b/src/arm64/full-codegen-arm64.cc index 3d3e5ee0f2..d46183339b 100644 --- a/src/arm64/full-codegen-arm64.cc +++ b/src/arm64/full-codegen-arm64.cc @@ -1741,7 +1741,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { __ Peek(x0, 0); __ Push(x0); VisitForStackValue(value); - __ CallRuntime(Runtime::kSetPrototype, 2); + __ CallRuntime(Runtime::kInternalSetPrototype, 2); } else { VisitForEffect(value); } diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc index 647a00b0bf..50a3720c58 100644 --- a/src/compiler/ast-graph-builder.cc +++ b/src/compiler/ast-graph-builder.cc @@ -942,7 +942,7 @@ void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) { Node* receiver = environment()->Pop(); if (property->emit_store()) { const Operator* op = - javascript()->CallRuntime(Runtime::kSetPrototype, 2); + javascript()->CallRuntime(Runtime::kInternalSetPrototype, 2); NewNode(op, receiver, value); } break; diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc index e2aac7f194..aa9acf3a48 100644 --- a/src/ia32/full-codegen-ia32.cc +++ b/src/ia32/full-codegen-ia32.cc @@ -1686,7 +1686,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { __ push(Operand(esp, 0)); // Duplicate receiver. VisitForStackValue(value); if (property->emit_store()) { - __ CallRuntime(Runtime::kSetPrototype, 2); + __ CallRuntime(Runtime::kInternalSetPrototype, 2); } else { __ Drop(2); } diff --git a/src/mips/full-codegen-mips.cc b/src/mips/full-codegen-mips.cc index 08f021f9ff..c710dcf4b6 100644 --- a/src/mips/full-codegen-mips.cc +++ b/src/mips/full-codegen-mips.cc @@ -1746,7 +1746,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { __ push(a0); VisitForStackValue(value); if (property->emit_store()) { - __ CallRuntime(Runtime::kSetPrototype, 2); + __ CallRuntime(Runtime::kInternalSetPrototype, 2); } else { __ Drop(2); } diff --git a/src/mips64/full-codegen-mips64.cc b/src/mips64/full-codegen-mips64.cc index 30b3fbfd07..b57dbb1dd4 100644 --- a/src/mips64/full-codegen-mips64.cc +++ b/src/mips64/full-codegen-mips64.cc @@ -1743,7 +1743,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { __ push(a0); VisitForStackValue(value); if (property->emit_store()) { - __ CallRuntime(Runtime::kSetPrototype, 2); + __ CallRuntime(Runtime::kInternalSetPrototype, 2); } else { __ Drop(2); } diff --git a/src/objects.cc b/src/objects.cc index 47a61f627b..5d85b13614 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -11796,7 +11796,7 @@ MaybeHandle JSObject::SetPrototype(Handle object, DCHECK(new_map->prototype() == *value); JSObject::MigrateToMap(real_receiver, new_map); - if (!dictionary_elements_in_chain && + if (from_javascript && !dictionary_elements_in_chain && new_map->DictionaryElementsInPrototypeChainOnly()) { // If the prototype chain didn't previously have element callbacks, then // KeyedStoreICs need to be cleared to ensure any that involve this diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc index 90df54995f..e6fecdd342 100644 --- a/src/x64/full-codegen-x64.cc +++ b/src/x64/full-codegen-x64.cc @@ -1720,7 +1720,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { __ Push(Operand(rsp, 0)); // Duplicate receiver. VisitForStackValue(value); if (property->emit_store()) { - __ CallRuntime(Runtime::kSetPrototype, 2); + __ CallRuntime(Runtime::kInternalSetPrototype, 2); } else { __ Drop(2); } diff --git a/src/x87/full-codegen-x87.cc b/src/x87/full-codegen-x87.cc index dac05ea6fd..4b7e997b74 100644 --- a/src/x87/full-codegen-x87.cc +++ b/src/x87/full-codegen-x87.cc @@ -1675,7 +1675,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { __ push(Operand(esp, 0)); // Duplicate receiver. VisitForStackValue(value); if (property->emit_store()) { - __ CallRuntime(Runtime::kSetPrototype, 2); + __ CallRuntime(Runtime::kInternalSetPrototype, 2); } else { __ Drop(2); } diff --git a/test/mjsunit/fast-prototype.js b/test/mjsunit/fast-prototype.js index 98647612f6..c59ec94ef0 100644 --- a/test/mjsunit/fast-prototype.js +++ b/test/mjsunit/fast-prototype.js @@ -114,9 +114,9 @@ for (key in x) { assertTrue(key == 'a'); break; } -assertFalse(%HasFastProperties(x)); +assertTrue(%HasFastProperties(x)); x.d = 4; -assertFalse(%HasFastProperties(x)); +assertTrue(%HasFastProperties(x)); for (key in x) { assertTrue(key == 'a'); break;