Support fields in optimizing compiler.
- Required support for temporaries, to be only used by baseline compiler.
- Also fixed a few invalid assumptions around locations and instructions
that don't need materialization. These instructions should not have an Out.
Change-Id: Idc4a30dd95dd18015137300d36bec55fc024cf62
diff --git a/compiler/optimizing/code_generator.cc b/compiler/optimizing/code_generator.cc
index b8332ad..b0e6a75 100644
--- a/compiler/optimizing/code_generator.cc
+++ b/compiler/optimizing/code_generator.cc
@@ -39,6 +39,7 @@
DCHECK_EQ(frame_size_, kUninitializedFrameSize);
ComputeFrameSize(GetGraph()->GetMaximumNumberOfOutVRegs()
+ GetGraph()->GetNumberOfVRegs()
+ + GetGraph()->GetNumberOfTemporaries()
+ 1 /* filler */);
GenerateFrameEntry();
@@ -54,6 +55,7 @@
current->Accept(instruction_visitor);
}
}
+ GenerateSlowPaths();
size_t code_size = GetAssembler()->CodeSize();
uint8_t* buffer = allocator->Allocate(code_size);
@@ -79,6 +81,7 @@
current->Accept(instruction_visitor);
}
}
+ GenerateSlowPaths();
size_t code_size = GetAssembler()->CodeSize();
uint8_t* buffer = allocator->Allocate(code_size);
@@ -86,6 +89,12 @@
GetAssembler()->FinalizeInstructions(code);
}
+void CodeGenerator::GenerateSlowPaths() {
+ for (size_t i = 0, e = slow_paths_.Size(); i < e; ++i) {
+ slow_paths_.Get(i)->EmitNativeCode(this);
+ }
+}
+
size_t CodeGenerator::AllocateFreeRegisterInternal(
bool* blocked_registers, size_t number_of_registers) const {
for (size_t regno = 0; regno < number_of_registers; regno++) {
@@ -94,7 +103,6 @@
return regno;
}
}
- LOG(FATAL) << "Unreachable";
return -1;
}
@@ -162,13 +170,6 @@
locations->SetTempAt(i, loc);
}
}
-
- // Make all registers available for the return value.
- for (size_t i = 0, e = GetNumberOfRegisters(); i < e; ++i) {
- blocked_registers_[i] = false;
- }
- SetupBlockedRegisters(blocked_registers_);
-
Location result_location = locations->Out();
if (result_location.IsUnallocated()) {
switch (result_location.GetPolicy()) {
@@ -187,6 +188,12 @@
void CodeGenerator::InitLocations(HInstruction* instruction) {
if (instruction->GetLocations() == nullptr) {
+ if (instruction->IsTemporary()) {
+ HInstruction* previous = instruction->GetPrevious();
+ Location temp_location = GetTemporaryLocation(instruction->AsTemporary());
+ Move(previous, temp_location, instruction);
+ previous->GetLocations()->SetOut(temp_location);
+ }
return;
}
AllocateRegistersLocally(instruction);