Chromium Code Reviews| Index: src/compiler/code-generator.cc |
| diff --git a/src/compiler/code-generator.cc b/src/compiler/code-generator.cc |
| index e3d2fc9c92b6124e151c1e1b3fa6af4ecfe5e7fa..152c9a469eb22f0494e5da51ba2caf55b2710b93 100644 |
| --- a/src/compiler/code-generator.cc |
| +++ b/src/compiler/code-generator.cc |
| @@ -426,17 +426,20 @@ FrameStateDescriptor* CodeGenerator::GetFrameStateDescriptor( |
| return code()->GetFrameStateDescriptor(state_id); |
| } |
| -struct OperandAndType { |
| - OperandAndType(InstructionOperand* operand, MachineType type) |
| - : operand_(operand), type_(type) {} |
| - InstructionOperand* operand_; |
| - MachineType type_; |
| +namespace { |
| + |
| +struct OperandAndType { |
| + InstructionOperand* const operand; |
| + MachineType const type; |
| }; |
| -static OperandAndType TypedOperandForFrameState( |
| - FrameStateDescriptor* descriptor, Instruction* instr, |
| - size_t frame_state_offset, size_t index, OutputFrameStateCombine combine) { |
| + |
| +OperandAndType TypedOperandForFrameState(FrameStateDescriptor* descriptor, |
| + Instruction* instr, |
| + size_t frame_state_offset, |
| + size_t index, |
| + OutputFrameStateCombine combine) { |
| DCHECK(index < descriptor->GetSize(combine)); |
| switch (combine.kind()) { |
| case OutputFrameStateCombine::kPushOutput: { |
| @@ -445,8 +448,7 @@ static OperandAndType TypedOperandForFrameState( |
| descriptor->GetSize(OutputFrameStateCombine::Ignore()); |
| // If the index is past the existing stack items, return the output. |
| if (index >= size_without_output) { |
| - return OperandAndType(instr->OutputAt(index - size_without_output), |
| - kMachAnyTagged); |
| + return {instr->OutputAt(index - size_without_output), kMachAnyTagged}; |
| } |
| break; |
| } |
| @@ -455,31 +457,35 @@ static OperandAndType TypedOperandForFrameState( |
| descriptor->GetSize(combine) - 1 - combine.GetOffsetToPokeAt(); |
| if (index >= index_from_top && |
| index < index_from_top + instr->OutputCount()) { |
| - return OperandAndType(instr->OutputAt(index - index_from_top), |
| - kMachAnyTagged); |
| + return {instr->OutputAt(index - index_from_top), kMachAnyTagged}; |
| } |
| break; |
| } |
| - return OperandAndType(instr->InputAt(frame_state_offset + index), |
| - descriptor->GetType(index)); |
| + return {instr->InputAt(frame_state_offset + index), |
| + descriptor->GetType(index)}; |
| } |
| +} // namespace |
| + |
| void CodeGenerator::BuildTranslationForFrameStateDescriptor( |
| FrameStateDescriptor* descriptor, Instruction* instr, |
| Translation* translation, size_t frame_state_offset, |
| OutputFrameStateCombine state_combine) { |
| // Outer-most state must be added to translation first. |
| - if (descriptor->outer_state() != NULL) { |
| + if (descriptor->outer_state() != nullptr) { |
| BuildTranslationForFrameStateDescriptor(descriptor->outer_state(), instr, |
| translation, frame_state_offset, |
| OutputFrameStateCombine::Ignore()); |
| } |
| + frame_state_offset += descriptor->outer_state()->GetTotalSize(); |
| + // TODO(bmeurer): Fix this special case here. |
| int id = Translation::kSelfLiteralId; |
| - if (!descriptor->jsfunction().is_null()) { |
| - id = DefineDeoptimizationLiteral( |
| - Handle<Object>::cast(descriptor->jsfunction().ToHandleChecked())); |
| + if (descriptor->outer_state() != nullptr) { |
| + InstructionOperandConverter converter(this, instr); |
| + Handle<HeapObject> function(converter.InputHeapObject(frame_state_offset)); |
| + id = DefineDeoptimizationLiteral(function); |
| } |
| switch (descriptor->type()) { |
| @@ -487,7 +493,7 @@ void CodeGenerator::BuildTranslationForFrameStateDescriptor( |
| translation->BeginJSFrame( |
| descriptor->bailout_id(), id, |
| static_cast<unsigned int>(descriptor->GetSize(state_combine) - |
| - descriptor->parameters_count())); |
| + (1 + descriptor->parameters_count()))); |
|
Jarin
2015/05/15 12:15:14
Maybe we want a TODO explaining the "1 +" here. An
Benedikt Meurer
2015/05/15 12:15:52
Covered by TODO above.
|
| break; |
| case ARGUMENTS_ADAPTOR: |
| translation->BeginArgumentsAdaptorFrame( |
| @@ -495,11 +501,10 @@ void CodeGenerator::BuildTranslationForFrameStateDescriptor( |
| break; |
| } |
| - frame_state_offset += descriptor->outer_state()->GetTotalSize(); |
| - for (size_t i = 0; i < descriptor->GetSize(state_combine); i++) { |
| + for (size_t i = 1; i < descriptor->GetSize(state_combine); i++) { |
| OperandAndType op = TypedOperandForFrameState( |
| descriptor, instr, frame_state_offset, i, state_combine); |
| - AddTranslationForOperand(translation, instr, op.operand_, op.type_); |
| + AddTranslationForOperand(translation, instr, op.operand, op.type); |
| } |
| } |