| Index: src/ia32/lithium-ia32.cc
|
| diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc
|
| index bd9524cbc52763c23c551c4fc620ad917fbdc779..a4d2e183420a04f57c27c068eb2f7ab1d0ad8f74 100644
|
| --- a/src/ia32/lithium-ia32.cc
|
| +++ b/src/ia32/lithium-ia32.cc
|
| @@ -386,9 +386,9 @@ void LAccessArgumentsAt::PrintDataTo(StringStream* stream) {
|
| }
|
|
|
|
|
| -int LPlatformChunk::GetNextSpillIndex(bool is_double) {
|
| +int LPlatformChunk::GetNextSpillIndex(RegisterKind kind) {
|
| // Skip a slot if for a double-width slot.
|
| - if (is_double) {
|
| + if (kind == DOUBLE_REGISTERS) {
|
| spill_slot_count_++;
|
| spill_slot_count_ |= 1;
|
| num_double_slots_++;
|
| @@ -397,11 +397,12 @@ int LPlatformChunk::GetNextSpillIndex(bool is_double) {
|
| }
|
|
|
|
|
| -LOperand* LPlatformChunk::GetNextSpillSlot(bool is_double) {
|
| - int index = GetNextSpillIndex(is_double);
|
| - if (is_double) {
|
| +LOperand* LPlatformChunk::GetNextSpillSlot(RegisterKind kind) {
|
| + int index = GetNextSpillIndex(kind);
|
| + if (kind == DOUBLE_REGISTERS) {
|
| return LDoubleStackSlot::Create(index, zone());
|
| } else {
|
| + ASSERT(kind == GENERAL_REGISTERS);
|
| return LStackSlot::Create(index, zone());
|
| }
|
| }
|
| @@ -479,7 +480,7 @@ LPlatformChunk* LChunkBuilder::Build() {
|
|
|
| // Reserve the first spill slot for the state of dynamic alignment.
|
| if (info()->IsOptimizing()) {
|
| - int alignment_state_index = chunk_->GetNextSpillIndex(false);
|
| + int alignment_state_index = chunk_->GetNextSpillIndex(GENERAL_REGISTERS);
|
| ASSERT_EQ(alignment_state_index, 0);
|
| USE(alignment_state_index);
|
| }
|
| @@ -488,7 +489,7 @@ LPlatformChunk* LChunkBuilder::Build() {
|
| // which will be subsumed into this frame.
|
| if (graph()->has_osr()) {
|
| for (int i = graph()->osr()->UnoptimizedFrameSlots(); i > 0; i--) {
|
| - chunk_->GetNextSpillIndex(false);
|
| + chunk_->GetNextSpillIndex(GENERAL_REGISTERS);
|
| }
|
| }
|
|
|
| @@ -908,9 +909,31 @@ void LChunkBuilder::VisitInstruction(HInstruction* current) {
|
| HInstruction* old_current = current_instruction_;
|
| current_instruction_ = current;
|
| if (current->has_position()) position_ = current->position();
|
| - LInstruction* instr = current->CompileToLithium(this);
|
| +
|
| + LInstruction* instr = NULL;
|
| + if (current->CanReplaceWithDummyUses()) {
|
| + HValue* first_operand = current->OperandCount() == 0
|
| + ? graph()->GetConstant1()
|
| + : current->OperandAt(0);
|
| + instr = DefineAsRegister(new(zone()) LDummyUse(UseAny(first_operand)));
|
| + for (int i = 1; i < current->OperandCount(); ++i) {
|
| + LInstruction* dummy =
|
| + new(zone()) LDummyUse(UseAny(current->OperandAt(i)));
|
| + dummy->set_hydrogen_value(current);
|
| + chunk_->AddInstruction(dummy, current_block_);
|
| + }
|
| + } else {
|
| + instr = current->CompileToLithium(this);
|
| + }
|
| +
|
| + argument_count_ += current->argument_delta();
|
| + ASSERT(argument_count_ >= 0);
|
|
|
| if (instr != NULL) {
|
| + // Associate the hydrogen instruction first, since we may need it for
|
| + // the ClobbersRegisters() or ClobbersDoubleRegisters() calls below.
|
| + instr->set_hydrogen_value(current);
|
| +
|
| #if DEBUG
|
| // Make sure that the lithium instruction has either no fixed register
|
| // constraints in temps or the result OR no uses that are only used at
|
| @@ -957,7 +980,6 @@ void LChunkBuilder::VisitInstruction(HInstruction* current) {
|
| clobber->set_hydrogen_value(current);
|
| chunk_->AddInstruction(clobber, current_block_);
|
| }
|
| - instr->set_hydrogen_value(current);
|
| chunk_->AddInstruction(instr, current_block_);
|
| }
|
| current_instruction_ = old_current;
|
| @@ -1054,21 +1076,15 @@ LInstruction* LChunkBuilder::DoGoto(HGoto* instr) {
|
|
|
|
|
| LInstruction* LChunkBuilder::DoBranch(HBranch* instr) {
|
| - HValue* value = instr->value();
|
| - if (value->EmitAtUses()) {
|
| - ASSERT(value->IsConstant());
|
| - ASSERT(!value->representation().IsDouble());
|
| - HBasicBlock* successor = HConstant::cast(value)->BooleanValue()
|
| - ? instr->FirstSuccessor()
|
| - : instr->SecondSuccessor();
|
| - return new(zone()) LGoto(successor);
|
| - }
|
| + LInstruction* goto_instr = CheckElideControlInstruction(instr);
|
| + if (goto_instr != NULL) return goto_instr;
|
|
|
| ToBooleanStub::Types expected = instr->expected_input_types();
|
|
|
| // Tagged values that are not known smis or booleans require a
|
| // deoptimization environment. If the instruction is generic no
|
| // environment is needed since all cases are handled.
|
| + HValue* value = instr->value();
|
| Representation rep = value->representation();
|
| HType type = value->type();
|
| if (!rep.IsTagged() || type.IsSmi() || type.IsBoolean()) {
|
| @@ -1164,7 +1180,6 @@ LInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) {
|
|
|
|
|
| LInstruction* LChunkBuilder::DoPushArgument(HPushArgument* instr) {
|
| - ++argument_count_;
|
| LOperand* argument = UseAny(instr->argument());
|
| return new(zone()) LPushArgument(argument);
|
| }
|
| @@ -1231,7 +1246,6 @@ LInstruction* LChunkBuilder::DoGlobalReceiver(HGlobalReceiver* instr) {
|
|
|
| LInstruction* LChunkBuilder::DoCallConstantFunction(
|
| HCallConstantFunction* instr) {
|
| - argument_count_ -= instr->argument_count();
|
| return MarkAsCall(DefineFixed(new(zone()) LCallConstantFunction, eax), instr);
|
| }
|
|
|
| @@ -1239,7 +1253,6 @@ LInstruction* LChunkBuilder::DoCallConstantFunction(
|
| LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) {
|
| LOperand* context = UseFixed(instr->context(), esi);
|
| LOperand* function = UseFixed(instr->function(), edi);
|
| - argument_count_ -= instr->argument_count();
|
| LInvokeFunction* result = new(zone()) LInvokeFunction(context, function);
|
| return MarkAsCall(DefineFixed(result, eax), instr, CANNOT_DEOPTIMIZE_EAGERLY);
|
| }
|
| @@ -1349,7 +1362,6 @@ LInstruction* LChunkBuilder::DoCallKeyed(HCallKeyed* instr) {
|
| ASSERT(instr->key()->representation().IsTagged());
|
| LOperand* context = UseFixed(instr->context(), esi);
|
| LOperand* key = UseFixed(instr->key(), ecx);
|
| - argument_count_ -= instr->argument_count();
|
| LCallKeyed* result = new(zone()) LCallKeyed(context, key);
|
| return MarkAsCall(DefineFixed(result, eax), instr);
|
| }
|
| @@ -1357,7 +1369,6 @@ LInstruction* LChunkBuilder::DoCallKeyed(HCallKeyed* instr) {
|
|
|
| LInstruction* LChunkBuilder::DoCallNamed(HCallNamed* instr) {
|
| LOperand* context = UseFixed(instr->context(), esi);
|
| - argument_count_ -= instr->argument_count();
|
| LCallNamed* result = new(zone()) LCallNamed(context);
|
| return MarkAsCall(DefineFixed(result, eax), instr);
|
| }
|
| @@ -1365,14 +1376,12 @@ LInstruction* LChunkBuilder::DoCallNamed(HCallNamed* instr) {
|
|
|
| LInstruction* LChunkBuilder::DoCallGlobal(HCallGlobal* instr) {
|
| LOperand* context = UseFixed(instr->context(), esi);
|
| - argument_count_ -= instr->argument_count();
|
| LCallGlobal* result = new(zone()) LCallGlobal(context);
|
| return MarkAsCall(DefineFixed(result, eax), instr);
|
| }
|
|
|
|
|
| LInstruction* LChunkBuilder::DoCallKnownGlobal(HCallKnownGlobal* instr) {
|
| - argument_count_ -= instr->argument_count();
|
| return MarkAsCall(DefineFixed(new(zone()) LCallKnownGlobal, eax), instr);
|
| }
|
|
|
| @@ -1380,7 +1389,6 @@ LInstruction* LChunkBuilder::DoCallKnownGlobal(HCallKnownGlobal* instr) {
|
| LInstruction* LChunkBuilder::DoCallNew(HCallNew* instr) {
|
| LOperand* context = UseFixed(instr->context(), esi);
|
| LOperand* constructor = UseFixed(instr->constructor(), edi);
|
| - argument_count_ -= instr->argument_count();
|
| LCallNew* result = new(zone()) LCallNew(context, constructor);
|
| return MarkAsCall(DefineFixed(result, eax), instr);
|
| }
|
| @@ -1389,7 +1397,6 @@ LInstruction* LChunkBuilder::DoCallNew(HCallNew* instr) {
|
| LInstruction* LChunkBuilder::DoCallNewArray(HCallNewArray* instr) {
|
| LOperand* context = UseFixed(instr->context(), esi);
|
| LOperand* constructor = UseFixed(instr->constructor(), edi);
|
| - argument_count_ -= instr->argument_count();
|
| LCallNewArray* result = new(zone()) LCallNewArray(context, constructor);
|
| return MarkAsCall(DefineFixed(result, eax), instr);
|
| }
|
| @@ -1398,14 +1405,12 @@ LInstruction* LChunkBuilder::DoCallNewArray(HCallNewArray* instr) {
|
| LInstruction* LChunkBuilder::DoCallFunction(HCallFunction* instr) {
|
| LOperand* context = UseFixed(instr->context(), esi);
|
| LOperand* function = UseFixed(instr->function(), edi);
|
| - argument_count_ -= instr->argument_count();
|
| LCallFunction* result = new(zone()) LCallFunction(context, function);
|
| return MarkAsCall(DefineFixed(result, eax), instr);
|
| }
|
|
|
|
|
| LInstruction* LChunkBuilder::DoCallRuntime(HCallRuntime* instr) {
|
| - argument_count_ -= instr->argument_count();
|
| LOperand* context = UseFixed(instr->context(), esi);
|
| return MarkAsCall(DefineFixed(new(zone()) LCallRuntime(context), eax), instr);
|
| }
|
| @@ -1740,6 +1745,8 @@ LInstruction* LChunkBuilder::DoCompareNumericAndBranch(
|
|
|
| LInstruction* LChunkBuilder::DoCompareObjectEqAndBranch(
|
| HCompareObjectEqAndBranch* instr) {
|
| + LInstruction* goto_instr = CheckElideControlInstruction(instr);
|
| + if (goto_instr != NULL) return goto_instr;
|
| LOperand* left = UseRegisterAtStart(instr->left());
|
| LOperand* right = UseOrConstantAtStart(instr->right());
|
| return new(zone()) LCmpObjectEqAndBranch(left, right);
|
| @@ -2415,7 +2422,11 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) {
|
| !(FLAG_track_double_fields && instr->field_representation().IsDouble());
|
|
|
| LOperand* val;
|
| - if (needs_write_barrier) {
|
| + if (instr->field_representation().IsByte()) {
|
| + // mov_b requires a byte register (i.e. any of eax, ebx, ecx, edx).
|
| + // Just force the value to be in eax and we're safe here.
|
| + val = UseFixed(instr->value(), eax);
|
| + } else if (needs_write_barrier) {
|
| val = UseTempRegister(instr->value());
|
| } else if (can_be_constant) {
|
| val = UseRegisterOrConstant(instr->value());
|
| @@ -2562,7 +2573,6 @@ LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) {
|
|
|
| LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) {
|
| LOperand* context = UseFixed(instr->context(), esi);
|
| - argument_count_ -= instr->argument_count();
|
| LCallStub* result = new(zone()) LCallStub(context);
|
| return MarkAsCall(DefineFixed(result, eax), instr);
|
| }
|
| @@ -2691,7 +2701,7 @@ LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) {
|
| if (env->entry()->arguments_pushed()) {
|
| int argument_count = env->arguments_environment()->parameter_count();
|
| pop = new(zone()) LDrop(argument_count);
|
| - argument_count_ -= argument_count;
|
| + ASSERT(instr->argument_delta() == -argument_count);
|
| }
|
|
|
| HEnvironment* outer = current_block_->last_environment()->
|
|
|