| Index: src/compiler/code-generator.cc
|
| diff --git a/src/compiler/code-generator.cc b/src/compiler/code-generator.cc
|
| index 75eab43118d5c8ec04d1a5878d6c2e014af8d94d..9cfc26d72368e0124cc326124570dc8ad55c8aa6 100644
|
| --- a/src/compiler/code-generator.cc
|
| +++ b/src/compiler/code-generator.cc
|
| @@ -208,8 +208,10 @@ Handle<Code> CodeGenerator::GenerateCode() {
|
|
|
|
|
| bool CodeGenerator::IsNextInAssemblyOrder(RpoNumber block) const {
|
| - return code()->InstructionBlockAt(current_block_)->ao_number().IsNext(
|
| - code()->InstructionBlockAt(block)->ao_number());
|
| + return code()
|
| + ->InstructionBlockAt(current_block_)
|
| + ->ao_number()
|
| + .IsNext(code()->InstructionBlockAt(block)->ao_number());
|
| }
|
|
|
|
|
| @@ -481,46 +483,75 @@ FrameStateDescriptor* CodeGenerator::GetFrameStateDescriptor(
|
| }
|
|
|
|
|
| -namespace {
|
| -
|
| -struct OperandAndType {
|
| - InstructionOperand* const operand;
|
| - MachineType const type;
|
| -};
|
| +// Return number of consumed operands of instr.
|
| +size_t CodeGenerator::TranslateStateValueDescriptor(StateValueDescriptor* desc,
|
| + Translation* translation,
|
| + Instruction* instr,
|
| + size_t frame_state_offset) {
|
| + if (desc->IsRecursive()) {
|
| + size_t entries = 0;
|
| + translation->BeginCapturedObject(static_cast<int>(desc->size()));
|
| + for (size_t index = 0; index < desc->fields().size(); index++) {
|
| + entries +=
|
| + TranslateStateValueDescriptor(&desc->fields()[index], translation,
|
| + instr, frame_state_offset + index);
|
| + }
|
| + return entries;
|
| + } else if (desc->IsDuplicate()) {
|
| + translation->DuplicateObject(static_cast<int>(desc->id()));
|
| + return 0;
|
| + } else {
|
| + DCHECK(desc->IsPlain());
|
| + AddTranslationForOperand(translation, instr,
|
| + instr->InputAt(frame_state_offset), desc->type());
|
| + return 1;
|
| + }
|
| +}
|
|
|
|
|
| -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: {
|
| - DCHECK(combine.GetPushCount() <= instr->OutputCount());
|
| - size_t size_without_output =
|
| - descriptor->GetSize(OutputFrameStateCombine::Ignore());
|
| - // If the index is past the existing stack items, return the output.
|
| - if (index >= size_without_output) {
|
| - return {instr->OutputAt(index - size_without_output), kMachAnyTagged};
|
| +void CodeGenerator::TranslateFrameStateDescriptorOperands(
|
| + FrameStateDescriptor* desc, Instruction* instr, size_t frame_state_offset,
|
| + OutputFrameStateCombine combine, Translation* translation) {
|
| + for (size_t index = 0; index < desc->GetSize(combine); index++) {
|
| + switch (combine.kind()) {
|
| + case OutputFrameStateCombine::kPushOutput: {
|
| + DCHECK(combine.GetPushCount() <= instr->OutputCount());
|
| + size_t size_without_output =
|
| + desc->GetSize(OutputFrameStateCombine::Ignore());
|
| + // If the index is past the existing stack items in values_.
|
| + if (index >= size_without_output) {
|
| + // Materialize the result of the call instruction in this slot.
|
| + AddTranslationForOperand(translation, instr,
|
| + instr->OutputAt(index - size_without_output),
|
| + kMachAnyTagged);
|
| + continue;
|
| + }
|
| + break;
|
| }
|
| - break;
|
| + case OutputFrameStateCombine::kPokeAt:
|
| + // The result of the call should be placed at position
|
| + // [index_from_top] in the stack (overwriting whatever was
|
| + // previously there).
|
| + size_t index_from_top =
|
| + desc->GetSize(combine) - 1 - combine.GetOffsetToPokeAt();
|
| + if (index >= index_from_top &&
|
| + index < index_from_top + instr->OutputCount()) {
|
| + AddTranslationForOperand(translation, instr,
|
| + instr->OutputAt(index - index_from_top),
|
| + kMachAnyTagged);
|
| + continue;
|
| + }
|
| + break;
|
| }
|
| - case OutputFrameStateCombine::kPokeAt:
|
| - size_t index_from_top =
|
| - descriptor->GetSize(combine) - 1 - combine.GetOffsetToPokeAt();
|
| - if (index >= index_from_top &&
|
| - index < index_from_top + instr->OutputCount()) {
|
| - return {instr->OutputAt(index - index_from_top), kMachAnyTagged};
|
| - }
|
| - break;
|
| + // Add the additional fields we read during materialization.
|
| + StateValueDescriptor* value_desc = desc->GetStateValueDescriptor();
|
| + frame_state_offset +=
|
| + TranslateStateValueDescriptor(&value_desc->fields()[index], translation,
|
| + instr, frame_state_offset + index) -
|
| + 1;
|
| }
|
| - return {instr->InputAt(frame_state_offset + index),
|
| - descriptor->GetType(index)};
|
| }
|
|
|
| -} // namespace
|
| -
|
|
|
| void CodeGenerator::BuildTranslationForFrameStateDescriptor(
|
| FrameStateDescriptor* descriptor, Instruction* instr,
|
| @@ -560,11 +591,8 @@ void CodeGenerator::BuildTranslationForFrameStateDescriptor(
|
| break;
|
| }
|
|
|
| - for (size_t i = 0; i < descriptor->GetSize(state_combine); i++) {
|
| - OperandAndType op = TypedOperandForFrameState(
|
| - descriptor, instr, frame_state_offset, i, state_combine);
|
| - AddTranslationForOperand(translation, instr, op.operand, op.type);
|
| - }
|
| + TranslateFrameStateDescriptorOperands(descriptor, instr, frame_state_offset,
|
| + state_combine, translation);
|
| }
|
|
|
|
|
|
|