diff --git a/src/ast/ast.h b/src/ast/ast.h index 52a7709377..9d14dac2f8 100644 --- a/src/ast/ast.h +++ b/src/ast/ast.h @@ -1443,18 +1443,11 @@ class ObjectLiteral final : public MaterializedLiteral { BailoutId CreateLiteralId() const { return BailoutId(local_id(0)); } // Return an AST id for a property that is used in simulate instructions. - BailoutId GetIdForPropertyName(int i) { - return BailoutId(local_id(2 * i + 1)); - } - BailoutId GetIdForPropertySet(int i) { - return BailoutId(local_id(2 * i + 2)); - } + BailoutId GetIdForPropertySet(int i) { return BailoutId(local_id(i + 1)); } // Unlike other AST nodes, this number of bailout IDs allocated for an // ObjectLiteral can vary, so num_ids() is not a static method. - int num_ids() const { - return parent_num_ids() + 1 + 2 * properties()->length(); - } + int num_ids() const { return parent_num_ids() + 1 + properties()->length(); } // Object literals need one feedback slot for each non-trivial value, as well // as some slots for home objects. diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc index 5da7af34b1..01c0060352 100644 --- a/src/compiler/ast-graph-builder.cc +++ b/src/compiler/ast-graph-builder.cc @@ -1372,10 +1372,9 @@ void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) { environment()->Push(literal); // Create nodes to store computed values into the literal. - int property_index = 0; AccessorTable accessor_table(local_zone()); - for (; property_index < expr->properties()->length(); property_index++) { - ObjectLiteral::Property* property = expr->properties()->at(property_index); + for (int i = 0; i < expr->properties()->length(); i++) { + ObjectLiteral::Property* property = expr->properties()->at(i); DCHECK(!property->is_computed_name()); if (property->IsCompileTimeValue()) continue; @@ -1433,21 +1432,20 @@ void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) { javascript()->CallRuntime(Runtime::kInternalSetPrototype); Node* set_prototype = NewNode(op, receiver, value); // SetPrototype should not lazy deopt on an object literal. - PrepareFrameState(set_prototype, - expr->GetIdForPropertySet(property_index)); + PrepareFrameState(set_prototype, expr->GetIdForPropertySet(i)); break; } case ObjectLiteral::Property::GETTER: if (property->emit_store()) { AccessorTable::Iterator it = accessor_table.lookup(key); - it->second->bailout_id = expr->GetIdForPropertySet(property_index); + it->second->bailout_id = expr->GetIdForPropertySet(i); it->second->getter = property; } break; case ObjectLiteral::Property::SETTER: if (property->emit_store()) { AccessorTable::Iterator it = accessor_table.lookup(key); - it->second->bailout_id = expr->GetIdForPropertySet(property_index); + it->second->bailout_id = expr->GetIdForPropertySet(i); it->second->setter = property; } break; diff --git a/src/full-codegen/arm/full-codegen-arm.cc b/src/full-codegen/arm/full-codegen-arm.cc index e6de6c82c7..6019eeebf7 100644 --- a/src/full-codegen/arm/full-codegen-arm.cc +++ b/src/full-codegen/arm/full-codegen-arm.cc @@ -1225,10 +1225,9 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { bool result_saved = false; AccessorTable accessor_table(zone()); - int property_index = 0; - for (; property_index < expr->properties()->length(); property_index++) { - ObjectLiteral::Property* property = expr->properties()->at(property_index); - if (property->is_computed_name()) break; + for (int i = 0; i < expr->properties()->length(); i++) { + ObjectLiteral::Property* property = expr->properties()->at(i); + DCHECK(!property->is_computed_name()); if (property->IsCompileTimeValue()) continue; Literal* key = property->key()->AsLiteral(); @@ -1286,21 +1285,21 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { VisitForStackValue(value); DCHECK(property->emit_store()); CallRuntimeWithOperands(Runtime::kInternalSetPrototype); - PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), + PrepareForBailoutForId(expr->GetIdForPropertySet(i), BailoutState::NO_REGISTERS); break; case ObjectLiteral::Property::GETTER: if (property->emit_store()) { AccessorTable::Iterator it = accessor_table.lookup(key); - it->second->bailout_id = expr->GetIdForPropertySet(property_index); + it->second->bailout_id = expr->GetIdForPropertySet(i); it->second->getter = property; } break; case ObjectLiteral::Property::SETTER: if (property->emit_store()) { AccessorTable::Iterator it = accessor_table.lookup(key); - it->second->bailout_id = expr->GetIdForPropertySet(property_index); + it->second->bailout_id = expr->GetIdForPropertySet(i); it->second->setter = property; } break; @@ -1323,62 +1322,6 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { PrepareForBailoutForId(it->second->bailout_id, BailoutState::NO_REGISTERS); } - // Object literals have two parts. The "static" part on the left contains no - // computed property names, and so we can compute its map ahead of time; see - // runtime.cc::CreateObjectLiteralBoilerplate. The second "dynamic" part - // starts with the first computed property name, and continues with all - // properties to its right. All the code from above initializes the static - // component of the object literal, and arranges for the map of the result to - // reflect the static order in which the keys appear. For the dynamic - // properties, we compile them into a series of "SetOwnProperty" runtime - // calls. This will preserve insertion order. - for (; property_index < expr->properties()->length(); property_index++) { - ObjectLiteral::Property* property = expr->properties()->at(property_index); - - Expression* value = property->value(); - if (!result_saved) { - PushOperand(r0); // Save result on the stack - result_saved = true; - } - - __ ldr(r0, MemOperand(sp)); // Duplicate receiver. - PushOperand(r0); - - if (property->kind() == ObjectLiteral::Property::PROTOTYPE) { - DCHECK(!property->is_computed_name()); - VisitForStackValue(value); - DCHECK(property->emit_store()); - CallRuntimeWithOperands(Runtime::kInternalSetPrototype); - PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), - BailoutState::NO_REGISTERS); - } else { - EmitPropertyKey(property, expr->GetIdForPropertyName(property_index)); - VisitForStackValue(value); - if (NeedsHomeObject(value)) { - EmitSetHomeObject(value, 2, property->GetSlot()); - } - - switch (property->kind()) { - case ObjectLiteral::Property::CONSTANT: - case ObjectLiteral::Property::MATERIALIZED_LITERAL: - case ObjectLiteral::Property::COMPUTED: - case ObjectLiteral::Property::PROTOTYPE: - UNREACHABLE(); - break; - - case ObjectLiteral::Property::GETTER: - PushOperand(Smi::FromInt(NONE)); - CallRuntimeWithOperands(Runtime::kDefineGetterPropertyUnchecked); - break; - - case ObjectLiteral::Property::SETTER: - PushOperand(Smi::FromInt(NONE)); - CallRuntimeWithOperands(Runtime::kDefineSetterPropertyUnchecked); - break; - } - } - } - if (result_saved) { context()->PlugTOS(); } else { diff --git a/src/full-codegen/arm64/full-codegen-arm64.cc b/src/full-codegen/arm64/full-codegen-arm64.cc index 43eadc6f90..fe6c699637 100644 --- a/src/full-codegen/arm64/full-codegen-arm64.cc +++ b/src/full-codegen/arm64/full-codegen-arm64.cc @@ -1212,10 +1212,9 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { bool result_saved = false; AccessorTable accessor_table(zone()); - int property_index = 0; - for (; property_index < expr->properties()->length(); property_index++) { - ObjectLiteral::Property* property = expr->properties()->at(property_index); - if (property->is_computed_name()) break; + for (int i = 0; i < expr->properties()->length(); i++) { + ObjectLiteral::Property* property = expr->properties()->at(i); + DCHECK(!property->is_computed_name()); if (property->IsCompileTimeValue()) continue; Literal* key = property->key()->AsLiteral(); @@ -1272,20 +1271,20 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { PushOperand(x0); VisitForStackValue(value); CallRuntimeWithOperands(Runtime::kInternalSetPrototype); - PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), + PrepareForBailoutForId(expr->GetIdForPropertySet(i), BailoutState::NO_REGISTERS); break; case ObjectLiteral::Property::GETTER: if (property->emit_store()) { AccessorTable::Iterator it = accessor_table.lookup(key); - it->second->bailout_id = expr->GetIdForPropertySet(property_index); + it->second->bailout_id = expr->GetIdForPropertySet(i); it->second->getter = property; } break; case ObjectLiteral::Property::SETTER: if (property->emit_store()) { AccessorTable::Iterator it = accessor_table.lookup(key); - it->second->bailout_id = expr->GetIdForPropertySet(property_index); + it->second->bailout_id = expr->GetIdForPropertySet(i); it->second->setter = property; } break; @@ -1308,62 +1307,6 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { PrepareForBailoutForId(it->second->bailout_id, BailoutState::NO_REGISTERS); } - // Object literals have two parts. The "static" part on the left contains no - // computed property names, and so we can compute its map ahead of time; see - // runtime.cc::CreateObjectLiteralBoilerplate. The second "dynamic" part - // starts with the first computed property name, and continues with all - // properties to its right. All the code from above initializes the static - // component of the object literal, and arranges for the map of the result to - // reflect the static order in which the keys appear. For the dynamic - // properties, we compile them into a series of "SetOwnProperty" runtime - // calls. This will preserve insertion order. - for (; property_index < expr->properties()->length(); property_index++) { - ObjectLiteral::Property* property = expr->properties()->at(property_index); - - Expression* value = property->value(); - if (!result_saved) { - PushOperand(x0); // Save result on stack - result_saved = true; - } - - __ Peek(x10, 0); // Duplicate receiver. - PushOperand(x10); - - if (property->kind() == ObjectLiteral::Property::PROTOTYPE) { - DCHECK(!property->is_computed_name()); - VisitForStackValue(value); - DCHECK(property->emit_store()); - CallRuntimeWithOperands(Runtime::kInternalSetPrototype); - PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), - BailoutState::NO_REGISTERS); - } else { - EmitPropertyKey(property, expr->GetIdForPropertyName(property_index)); - VisitForStackValue(value); - if (NeedsHomeObject(value)) { - EmitSetHomeObject(value, 2, property->GetSlot()); - } - - switch (property->kind()) { - case ObjectLiteral::Property::CONSTANT: - case ObjectLiteral::Property::MATERIALIZED_LITERAL: - case ObjectLiteral::Property::COMPUTED: - case ObjectLiteral::Property::PROTOTYPE: - UNREACHABLE(); - break; - - case ObjectLiteral::Property::GETTER: - PushOperand(Smi::FromInt(NONE)); - CallRuntimeWithOperands(Runtime::kDefineGetterPropertyUnchecked); - break; - - case ObjectLiteral::Property::SETTER: - PushOperand(Smi::FromInt(NONE)); - CallRuntimeWithOperands(Runtime::kDefineSetterPropertyUnchecked); - break; - } - } - } - if (result_saved) { context()->PlugTOS(); } else { diff --git a/src/full-codegen/ia32/full-codegen-ia32.cc b/src/full-codegen/ia32/full-codegen-ia32.cc index 7379e81ac7..0b42538fd3 100644 --- a/src/full-codegen/ia32/full-codegen-ia32.cc +++ b/src/full-codegen/ia32/full-codegen-ia32.cc @@ -1156,10 +1156,9 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { bool result_saved = false; AccessorTable accessor_table(zone()); - int property_index = 0; - for (; property_index < expr->properties()->length(); property_index++) { - ObjectLiteral::Property* property = expr->properties()->at(property_index); - if (property->is_computed_name()) break; + for (int i = 0; i < expr->properties()->length(); i++) { + ObjectLiteral::Property* property = expr->properties()->at(i); + DCHECK(!property->is_computed_name()); if (property->IsCompileTimeValue()) continue; Literal* key = property->key()->AsLiteral(); @@ -1211,20 +1210,20 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { VisitForStackValue(value); DCHECK(property->emit_store()); CallRuntimeWithOperands(Runtime::kInternalSetPrototype); - PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), + PrepareForBailoutForId(expr->GetIdForPropertySet(i), BailoutState::NO_REGISTERS); break; case ObjectLiteral::Property::GETTER: if (property->emit_store()) { AccessorTable::Iterator it = accessor_table.lookup(key); - it->second->bailout_id = expr->GetIdForPropertySet(property_index); + it->second->bailout_id = expr->GetIdForPropertySet(i); it->second->getter = property; } break; case ObjectLiteral::Property::SETTER: if (property->emit_store()) { AccessorTable::Iterator it = accessor_table.lookup(key); - it->second->bailout_id = expr->GetIdForPropertySet(property_index); + it->second->bailout_id = expr->GetIdForPropertySet(i); it->second->setter = property; } break; @@ -1247,61 +1246,6 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { PrepareForBailoutForId(it->second->bailout_id, BailoutState::NO_REGISTERS); } - // Object literals have two parts. The "static" part on the left contains no - // computed property names, and so we can compute its map ahead of time; see - // runtime.cc::CreateObjectLiteralBoilerplate. The second "dynamic" part - // starts with the first computed property name, and continues with all - // properties to its right. All the code from above initializes the static - // component of the object literal, and arranges for the map of the result to - // reflect the static order in which the keys appear. For the dynamic - // properties, we compile them into a series of "SetOwnProperty" runtime - // calls. This will preserve insertion order. - for (; property_index < expr->properties()->length(); property_index++) { - ObjectLiteral::Property* property = expr->properties()->at(property_index); - - Expression* value = property->value(); - if (!result_saved) { - PushOperand(eax); // Save result on the stack - result_saved = true; - } - - PushOperand(Operand(esp, 0)); // Duplicate receiver. - - if (property->kind() == ObjectLiteral::Property::PROTOTYPE) { - DCHECK(!property->is_computed_name()); - VisitForStackValue(value); - DCHECK(property->emit_store()); - CallRuntimeWithOperands(Runtime::kInternalSetPrototype); - PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), - BailoutState::NO_REGISTERS); - } else { - EmitPropertyKey(property, expr->GetIdForPropertyName(property_index)); - VisitForStackValue(value); - if (NeedsHomeObject(value)) { - EmitSetHomeObject(value, 2, property->GetSlot()); - } - - switch (property->kind()) { - case ObjectLiteral::Property::CONSTANT: - case ObjectLiteral::Property::MATERIALIZED_LITERAL: - case ObjectLiteral::Property::COMPUTED: - case ObjectLiteral::Property::PROTOTYPE: - UNREACHABLE(); - break; - - case ObjectLiteral::Property::GETTER: - PushOperand(Smi::FromInt(NONE)); - CallRuntimeWithOperands(Runtime::kDefineGetterPropertyUnchecked); - break; - - case ObjectLiteral::Property::SETTER: - PushOperand(Smi::FromInt(NONE)); - CallRuntimeWithOperands(Runtime::kDefineSetterPropertyUnchecked); - break; - } - } - } - if (result_saved) { context()->PlugTOS(); } else { diff --git a/src/full-codegen/mips/full-codegen-mips.cc b/src/full-codegen/mips/full-codegen-mips.cc index 9b6e365325..68b3aa1257 100644 --- a/src/full-codegen/mips/full-codegen-mips.cc +++ b/src/full-codegen/mips/full-codegen-mips.cc @@ -1224,10 +1224,9 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { bool result_saved = false; AccessorTable accessor_table(zone()); - int property_index = 0; - for (; property_index < expr->properties()->length(); property_index++) { - ObjectLiteral::Property* property = expr->properties()->at(property_index); - if (property->is_computed_name()) break; + for (int i = 0; i < expr->properties()->length(); i++) { + ObjectLiteral::Property* property = expr->properties()->at(i); + DCHECK(!property->is_computed_name()); if (property->IsCompileTimeValue()) continue; Literal* key = property->key()->AsLiteral(); @@ -1286,20 +1285,20 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { VisitForStackValue(value); DCHECK(property->emit_store()); CallRuntimeWithOperands(Runtime::kInternalSetPrototype); - PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), + PrepareForBailoutForId(expr->GetIdForPropertySet(i), BailoutState::NO_REGISTERS); break; case ObjectLiteral::Property::GETTER: if (property->emit_store()) { AccessorTable::Iterator it = accessor_table.lookup(key); - it->second->bailout_id = expr->GetIdForPropertySet(property_index); + it->second->bailout_id = expr->GetIdForPropertySet(i); it->second->getter = property; } break; case ObjectLiteral::Property::SETTER: if (property->emit_store()) { AccessorTable::Iterator it = accessor_table.lookup(key); - it->second->bailout_id = expr->GetIdForPropertySet(property_index); + it->second->bailout_id = expr->GetIdForPropertySet(i); it->second->setter = property; } break; @@ -1322,62 +1321,6 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { PrepareForBailoutForId(it->second->bailout_id, BailoutState::NO_REGISTERS); } - // Object literals have two parts. The "static" part on the left contains no - // computed property names, and so we can compute its map ahead of time; see - // runtime.cc::CreateObjectLiteralBoilerplate. The second "dynamic" part - // starts with the first computed property name, and continues with all - // properties to its right. All the code from above initializes the static - // component of the object literal, and arranges for the map of the result to - // reflect the static order in which the keys appear. For the dynamic - // properties, we compile them into a series of "SetOwnProperty" runtime - // calls. This will preserve insertion order. - for (; property_index < expr->properties()->length(); property_index++) { - ObjectLiteral::Property* property = expr->properties()->at(property_index); - - Expression* value = property->value(); - if (!result_saved) { - PushOperand(v0); // Save result on the stack - result_saved = true; - } - - __ lw(a0, MemOperand(sp)); // Duplicate receiver. - PushOperand(a0); - - if (property->kind() == ObjectLiteral::Property::PROTOTYPE) { - DCHECK(!property->is_computed_name()); - VisitForStackValue(value); - DCHECK(property->emit_store()); - CallRuntimeWithOperands(Runtime::kInternalSetPrototype); - PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), - BailoutState::NO_REGISTERS); - } else { - EmitPropertyKey(property, expr->GetIdForPropertyName(property_index)); - VisitForStackValue(value); - if (NeedsHomeObject(value)) { - EmitSetHomeObject(value, 2, property->GetSlot()); - } - - switch (property->kind()) { - case ObjectLiteral::Property::CONSTANT: - case ObjectLiteral::Property::MATERIALIZED_LITERAL: - case ObjectLiteral::Property::COMPUTED: - case ObjectLiteral::Property::PROTOTYPE: - UNREACHABLE(); - break; - - case ObjectLiteral::Property::GETTER: - PushOperand(Smi::FromInt(NONE)); - CallRuntimeWithOperands(Runtime::kDefineGetterPropertyUnchecked); - break; - - case ObjectLiteral::Property::SETTER: - PushOperand(Smi::FromInt(NONE)); - CallRuntimeWithOperands(Runtime::kDefineSetterPropertyUnchecked); - break; - } - } - } - if (result_saved) { context()->PlugTOS(); } else { diff --git a/src/full-codegen/mips64/full-codegen-mips64.cc b/src/full-codegen/mips64/full-codegen-mips64.cc index a43bda5c8e..a509305c2f 100644 --- a/src/full-codegen/mips64/full-codegen-mips64.cc +++ b/src/full-codegen/mips64/full-codegen-mips64.cc @@ -1226,10 +1226,9 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { bool result_saved = false; AccessorTable accessor_table(zone()); - int property_index = 0; - for (; property_index < expr->properties()->length(); property_index++) { - ObjectLiteral::Property* property = expr->properties()->at(property_index); - if (property->is_computed_name()) break; + for (int i = 0; i < expr->properties()->length(); i++) { + ObjectLiteral::Property* property = expr->properties()->at(i); + DCHECK(!property->is_computed_name()); if (property->IsCompileTimeValue()) continue; Literal* key = property->key()->AsLiteral(); @@ -1288,20 +1287,20 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { VisitForStackValue(value); DCHECK(property->emit_store()); CallRuntimeWithOperands(Runtime::kInternalSetPrototype); - PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), + PrepareForBailoutForId(expr->GetIdForPropertySet(i), BailoutState::NO_REGISTERS); break; case ObjectLiteral::Property::GETTER: if (property->emit_store()) { AccessorTable::Iterator it = accessor_table.lookup(key); - it->second->bailout_id = expr->GetIdForPropertySet(property_index); + it->second->bailout_id = expr->GetIdForPropertySet(i); it->second->getter = property; } break; case ObjectLiteral::Property::SETTER: if (property->emit_store()) { AccessorTable::Iterator it = accessor_table.lookup(key); - it->second->bailout_id = expr->GetIdForPropertySet(property_index); + it->second->bailout_id = expr->GetIdForPropertySet(i); it->second->setter = property; } break; @@ -1324,62 +1323,6 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { PrepareForBailoutForId(it->second->bailout_id, BailoutState::NO_REGISTERS); } - // Object literals have two parts. The "static" part on the left contains no - // computed property names, and so we can compute its map ahead of time; see - // runtime.cc::CreateObjectLiteralBoilerplate. The second "dynamic" part - // starts with the first computed property name, and continues with all - // properties to its right. All the code from above initializes the static - // component of the object literal, and arranges for the map of the result to - // reflect the static order in which the keys appear. For the dynamic - // properties, we compile them into a series of "SetOwnProperty" runtime - // calls. This will preserve insertion order. - for (; property_index < expr->properties()->length(); property_index++) { - ObjectLiteral::Property* property = expr->properties()->at(property_index); - - Expression* value = property->value(); - if (!result_saved) { - PushOperand(v0); // Save result on the stack - result_saved = true; - } - - __ ld(a0, MemOperand(sp)); // Duplicate receiver. - PushOperand(a0); - - if (property->kind() == ObjectLiteral::Property::PROTOTYPE) { - DCHECK(!property->is_computed_name()); - VisitForStackValue(value); - DCHECK(property->emit_store()); - CallRuntimeWithOperands(Runtime::kInternalSetPrototype); - PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), - BailoutState::NO_REGISTERS); - } else { - EmitPropertyKey(property, expr->GetIdForPropertyName(property_index)); - VisitForStackValue(value); - if (NeedsHomeObject(value)) { - EmitSetHomeObject(value, 2, property->GetSlot()); - } - - switch (property->kind()) { - case ObjectLiteral::Property::CONSTANT: - case ObjectLiteral::Property::MATERIALIZED_LITERAL: - case ObjectLiteral::Property::COMPUTED: - case ObjectLiteral::Property::PROTOTYPE: - UNREACHABLE(); - break; - - case ObjectLiteral::Property::GETTER: - PushOperand(Smi::FromInt(NONE)); - CallRuntimeWithOperands(Runtime::kDefineGetterPropertyUnchecked); - break; - - case ObjectLiteral::Property::SETTER: - PushOperand(Smi::FromInt(NONE)); - CallRuntimeWithOperands(Runtime::kDefineSetterPropertyUnchecked); - break; - } - } - } - if (result_saved) { context()->PlugTOS(); } else { diff --git a/src/full-codegen/ppc/full-codegen-ppc.cc b/src/full-codegen/ppc/full-codegen-ppc.cc index 86da50619b..6e1e657f65 100644 --- a/src/full-codegen/ppc/full-codegen-ppc.cc +++ b/src/full-codegen/ppc/full-codegen-ppc.cc @@ -1196,10 +1196,9 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { bool result_saved = false; AccessorTable accessor_table(zone()); - int property_index = 0; - for (; property_index < expr->properties()->length(); property_index++) { - ObjectLiteral::Property* property = expr->properties()->at(property_index); - if (property->is_computed_name()) break; + for (int i = 0; i < expr->properties()->length(); i++) { + ObjectLiteral::Property* property = expr->properties()->at(i); + DCHECK(!property->is_computed_name()); if (property->IsCompileTimeValue()) continue; Literal* key = property->key()->AsLiteral(); @@ -1257,20 +1256,20 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { VisitForStackValue(value); DCHECK(property->emit_store()); CallRuntimeWithOperands(Runtime::kInternalSetPrototype); - PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), + PrepareForBailoutForId(expr->GetIdForPropertySet(i), BailoutState::NO_REGISTERS); break; case ObjectLiteral::Property::GETTER: if (property->emit_store()) { AccessorTable::Iterator it = accessor_table.lookup(key); - it->second->bailout_id = expr->GetIdForPropertySet(property_index); + it->second->bailout_id = expr->GetIdForPropertySet(i); it->second->getter = property; } break; case ObjectLiteral::Property::SETTER: if (property->emit_store()) { AccessorTable::Iterator it = accessor_table.lookup(key); - it->second->bailout_id = expr->GetIdForPropertySet(property_index); + it->second->bailout_id = expr->GetIdForPropertySet(i); it->second->setter = property; } break; @@ -1292,62 +1291,6 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { PrepareForBailoutForId(it->second->bailout_id, BailoutState::NO_REGISTERS); } - // Object literals have two parts. The "static" part on the left contains no - // computed property names, and so we can compute its map ahead of time; see - // runtime.cc::CreateObjectLiteralBoilerplate. The second "dynamic" part - // starts with the first computed property name, and continues with all - // properties to its right. All the code from above initializes the static - // component of the object literal, and arranges for the map of the result to - // reflect the static order in which the keys appear. For the dynamic - // properties, we compile them into a series of "SetOwnProperty" runtime - // calls. This will preserve insertion order. - for (; property_index < expr->properties()->length(); property_index++) { - ObjectLiteral::Property* property = expr->properties()->at(property_index); - - Expression* value = property->value(); - if (!result_saved) { - PushOperand(r3); // Save result on the stack - result_saved = true; - } - - __ LoadP(r3, MemOperand(sp)); // Duplicate receiver. - PushOperand(r3); - - if (property->kind() == ObjectLiteral::Property::PROTOTYPE) { - DCHECK(!property->is_computed_name()); - VisitForStackValue(value); - DCHECK(property->emit_store()); - CallRuntimeWithOperands(Runtime::kInternalSetPrototype); - PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), - BailoutState::NO_REGISTERS); - } else { - EmitPropertyKey(property, expr->GetIdForPropertyName(property_index)); - VisitForStackValue(value); - if (NeedsHomeObject(value)) { - EmitSetHomeObject(value, 2, property->GetSlot()); - } - - switch (property->kind()) { - case ObjectLiteral::Property::CONSTANT: - case ObjectLiteral::Property::MATERIALIZED_LITERAL: - case ObjectLiteral::Property::COMPUTED: - case ObjectLiteral::Property::PROTOTYPE: - UNREACHABLE(); - break; - - case ObjectLiteral::Property::GETTER: - PushOperand(Smi::FromInt(NONE)); - CallRuntimeWithOperands(Runtime::kDefineGetterPropertyUnchecked); - break; - - case ObjectLiteral::Property::SETTER: - PushOperand(Smi::FromInt(NONE)); - CallRuntimeWithOperands(Runtime::kDefineSetterPropertyUnchecked); - break; - } - } - } - if (result_saved) { context()->PlugTOS(); } else { diff --git a/src/full-codegen/s390/full-codegen-s390.cc b/src/full-codegen/s390/full-codegen-s390.cc index 578e0b03f7..04155ba42d 100644 --- a/src/full-codegen/s390/full-codegen-s390.cc +++ b/src/full-codegen/s390/full-codegen-s390.cc @@ -1159,10 +1159,9 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { bool result_saved = false; AccessorTable accessor_table(zone()); - int property_index = 0; - for (; property_index < expr->properties()->length(); property_index++) { - ObjectLiteral::Property* property = expr->properties()->at(property_index); - if (property->is_computed_name()) break; + for (int i = 0; i < expr->properties()->length(); i++) { + ObjectLiteral::Property* property = expr->properties()->at(i); + DCHECK(!property->is_computed_name()); if (property->IsCompileTimeValue()) continue; Literal* key = property->key()->AsLiteral(); @@ -1220,20 +1219,20 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { VisitForStackValue(value); DCHECK(property->emit_store()); CallRuntimeWithOperands(Runtime::kInternalSetPrototype); - PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), + PrepareForBailoutForId(expr->GetIdForPropertySet(i), BailoutState::NO_REGISTERS); break; case ObjectLiteral::Property::GETTER: if (property->emit_store()) { AccessorTable::Iterator it = accessor_table.lookup(key); - it->second->bailout_id = expr->GetIdForPropertySet(property_index); + it->second->bailout_id = expr->GetIdForPropertySet(i); it->second->getter = property; } break; case ObjectLiteral::Property::SETTER: if (property->emit_store()) { AccessorTable::Iterator it = accessor_table.lookup(key); - it->second->bailout_id = expr->GetIdForPropertySet(property_index); + it->second->bailout_id = expr->GetIdForPropertySet(i); it->second->setter = property; } break; @@ -1255,62 +1254,6 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { PrepareForBailoutForId(it->second->bailout_id, BailoutState::NO_REGISTERS); } - // Object literals have two parts. The "static" part on the left contains no - // computed property names, and so we can compute its map ahead of time; see - // runtime.cc::CreateObjectLiteralBoilerplate. The second "dynamic" part - // starts with the first computed property name, and continues with all - // properties to its right. All the code from above initializes the static - // component of the object literal, and arranges for the map of the result to - // reflect the static order in which the keys appear. For the dynamic - // properties, we compile them into a series of "SetOwnProperty" runtime - // calls. This will preserve insertion order. - for (; property_index < expr->properties()->length(); property_index++) { - ObjectLiteral::Property* property = expr->properties()->at(property_index); - - Expression* value = property->value(); - if (!result_saved) { - PushOperand(r2); // Save result on the stack - result_saved = true; - } - - __ LoadP(r2, MemOperand(sp)); // Duplicate receiver. - PushOperand(r2); - - if (property->kind() == ObjectLiteral::Property::PROTOTYPE) { - DCHECK(!property->is_computed_name()); - VisitForStackValue(value); - DCHECK(property->emit_store()); - CallRuntimeWithOperands(Runtime::kInternalSetPrototype); - PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), - BailoutState::NO_REGISTERS); - } else { - EmitPropertyKey(property, expr->GetIdForPropertyName(property_index)); - VisitForStackValue(value); - if (NeedsHomeObject(value)) { - EmitSetHomeObject(value, 2, property->GetSlot()); - } - - switch (property->kind()) { - case ObjectLiteral::Property::CONSTANT: - case ObjectLiteral::Property::MATERIALIZED_LITERAL: - case ObjectLiteral::Property::COMPUTED: - case ObjectLiteral::Property::PROTOTYPE: - UNREACHABLE(); - break; - - case ObjectLiteral::Property::GETTER: - PushOperand(Smi::FromInt(NONE)); - CallRuntimeWithOperands(Runtime::kDefineGetterPropertyUnchecked); - break; - - case ObjectLiteral::Property::SETTER: - PushOperand(Smi::FromInt(NONE)); - CallRuntimeWithOperands(Runtime::kDefineSetterPropertyUnchecked); - break; - } - } - } - if (result_saved) { context()->PlugTOS(); } else { diff --git a/src/full-codegen/x64/full-codegen-x64.cc b/src/full-codegen/x64/full-codegen-x64.cc index 42c273bc2f..b17722c994 100644 --- a/src/full-codegen/x64/full-codegen-x64.cc +++ b/src/full-codegen/x64/full-codegen-x64.cc @@ -1185,10 +1185,9 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { bool result_saved = false; AccessorTable accessor_table(zone()); - int property_index = 0; - for (; property_index < expr->properties()->length(); property_index++) { - ObjectLiteral::Property* property = expr->properties()->at(property_index); - if (property->is_computed_name()) break; + for (int i = 0; i < expr->properties()->length(); i++) { + ObjectLiteral::Property* property = expr->properties()->at(i); + DCHECK(!property->is_computed_name()); if (property->IsCompileTimeValue()) continue; Literal* key = property->key()->AsLiteral(); @@ -1241,20 +1240,20 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { VisitForStackValue(value); DCHECK(property->emit_store()); CallRuntimeWithOperands(Runtime::kInternalSetPrototype); - PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), + PrepareForBailoutForId(expr->GetIdForPropertySet(i), BailoutState::NO_REGISTERS); break; case ObjectLiteral::Property::GETTER: if (property->emit_store()) { AccessorTable::Iterator it = accessor_table.lookup(key); - it->second->bailout_id = expr->GetIdForPropertySet(property_index); + it->second->bailout_id = expr->GetIdForPropertySet(i); it->second->getter = property; } break; case ObjectLiteral::Property::SETTER: if (property->emit_store()) { AccessorTable::Iterator it = accessor_table.lookup(key); - it->second->bailout_id = expr->GetIdForPropertySet(property_index); + it->second->bailout_id = expr->GetIdForPropertySet(i); it->second->setter = property; } break; @@ -1275,61 +1274,6 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { PrepareForBailoutForId(it->second->bailout_id, BailoutState::NO_REGISTERS); } - // Object literals have two parts. The "static" part on the left contains no - // computed property names, and so we can compute its map ahead of time; see - // runtime.cc::CreateObjectLiteralBoilerplate. The second "dynamic" part - // starts with the first computed property name, and continues with all - // properties to its right. All the code from above initializes the static - // component of the object literal, and arranges for the map of the result to - // reflect the static order in which the keys appear. For the dynamic - // properties, we compile them into a series of "SetOwnProperty" runtime - // calls. This will preserve insertion order. - for (; property_index < expr->properties()->length(); property_index++) { - ObjectLiteral::Property* property = expr->properties()->at(property_index); - - Expression* value = property->value(); - if (!result_saved) { - PushOperand(rax); // Save result on the stack - result_saved = true; - } - - PushOperand(Operand(rsp, 0)); // Duplicate receiver. - - if (property->kind() == ObjectLiteral::Property::PROTOTYPE) { - DCHECK(!property->is_computed_name()); - VisitForStackValue(value); - DCHECK(property->emit_store()); - CallRuntimeWithOperands(Runtime::kInternalSetPrototype); - PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), - BailoutState::NO_REGISTERS); - } else { - EmitPropertyKey(property, expr->GetIdForPropertyName(property_index)); - VisitForStackValue(value); - if (NeedsHomeObject(value)) { - EmitSetHomeObject(value, 2, property->GetSlot()); - } - - switch (property->kind()) { - case ObjectLiteral::Property::CONSTANT: - case ObjectLiteral::Property::MATERIALIZED_LITERAL: - case ObjectLiteral::Property::COMPUTED: - case ObjectLiteral::Property::PROTOTYPE: - UNREACHABLE(); - break; - - case ObjectLiteral::Property::GETTER: - PushOperand(Smi::FromInt(NONE)); - CallRuntimeWithOperands(Runtime::kDefineGetterPropertyUnchecked); - break; - - case ObjectLiteral::Property::SETTER: - PushOperand(Smi::FromInt(NONE)); - CallRuntimeWithOperands(Runtime::kDefineSetterPropertyUnchecked); - break; - } - } - } - if (result_saved) { context()->PlugTOS(); } else { diff --git a/src/full-codegen/x87/full-codegen-x87.cc b/src/full-codegen/x87/full-codegen-x87.cc index 683ad1c130..11284e4f15 100644 --- a/src/full-codegen/x87/full-codegen-x87.cc +++ b/src/full-codegen/x87/full-codegen-x87.cc @@ -1148,10 +1148,9 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { bool result_saved = false; AccessorTable accessor_table(zone()); - int property_index = 0; - for (; property_index < expr->properties()->length(); property_index++) { - ObjectLiteral::Property* property = expr->properties()->at(property_index); - if (property->is_computed_name()) break; + for (int i = 0; i < expr->properties()->length(); i++) { + ObjectLiteral::Property* property = expr->properties()->at(i); + DCHECK(!property->is_computed_name()); if (property->IsCompileTimeValue()) continue; Literal* key = property->key()->AsLiteral(); @@ -1203,20 +1202,20 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { VisitForStackValue(value); DCHECK(property->emit_store()); CallRuntimeWithOperands(Runtime::kInternalSetPrototype); - PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), + PrepareForBailoutForId(expr->GetIdForPropertySet(i), BailoutState::NO_REGISTERS); break; case ObjectLiteral::Property::GETTER: if (property->emit_store()) { AccessorTable::Iterator it = accessor_table.lookup(key); - it->second->bailout_id = expr->GetIdForPropertySet(property_index); + it->second->bailout_id = expr->GetIdForPropertySet(i); it->second->getter = property; } break; case ObjectLiteral::Property::SETTER: if (property->emit_store()) { AccessorTable::Iterator it = accessor_table.lookup(key); - it->second->bailout_id = expr->GetIdForPropertySet(property_index); + it->second->bailout_id = expr->GetIdForPropertySet(i); it->second->setter = property; } break; @@ -1239,61 +1238,6 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { PrepareForBailoutForId(it->second->bailout_id, BailoutState::NO_REGISTERS); } - // Object literals have two parts. The "static" part on the left contains no - // computed property names, and so we can compute its map ahead of time; see - // runtime.cc::CreateObjectLiteralBoilerplate. The second "dynamic" part - // starts with the first computed property name, and continues with all - // properties to its right. All the code from above initializes the static - // component of the object literal, and arranges for the map of the result to - // reflect the static order in which the keys appear. For the dynamic - // properties, we compile them into a series of "SetOwnProperty" runtime - // calls. This will preserve insertion order. - for (; property_index < expr->properties()->length(); property_index++) { - ObjectLiteral::Property* property = expr->properties()->at(property_index); - - Expression* value = property->value(); - if (!result_saved) { - PushOperand(eax); // Save result on the stack - result_saved = true; - } - - PushOperand(Operand(esp, 0)); // Duplicate receiver. - - if (property->kind() == ObjectLiteral::Property::PROTOTYPE) { - DCHECK(!property->is_computed_name()); - VisitForStackValue(value); - DCHECK(property->emit_store()); - CallRuntimeWithOperands(Runtime::kInternalSetPrototype); - PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), - BailoutState::NO_REGISTERS); - } else { - EmitPropertyKey(property, expr->GetIdForPropertyName(property_index)); - VisitForStackValue(value); - if (NeedsHomeObject(value)) { - EmitSetHomeObject(value, 2, property->GetSlot()); - } - - switch (property->kind()) { - case ObjectLiteral::Property::CONSTANT: - case ObjectLiteral::Property::MATERIALIZED_LITERAL: - case ObjectLiteral::Property::COMPUTED: - case ObjectLiteral::Property::PROTOTYPE: - UNREACHABLE(); - break; - - case ObjectLiteral::Property::GETTER: - PushOperand(Smi::FromInt(NONE)); - CallRuntimeWithOperands(Runtime::kDefineGetterPropertyUnchecked); - break; - - case ObjectLiteral::Property::SETTER: - PushOperand(Smi::FromInt(NONE)); - CallRuntimeWithOperands(Runtime::kDefineSetterPropertyUnchecked); - break; - } - } - } - if (result_saved) { context()->PlugTOS(); } else {