Commit 98e0eac7 authored by adamk@chromium.org's avatar adamk@chromium.org

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
parent 04db7c87
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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;
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -11796,7 +11796,7 @@ MaybeHandle<Object> JSObject::SetPrototype(Handle<JSObject> 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
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment