Commit a09fb95b authored by bbudge's avatar bbudge Committed by Commit bot

[deoptimizer] Support float registers and slots.

LOG=N
BUG=v8:4124

Review-Url: https://codereview.chromium.org/2031873002
Cr-Commit-Position: refs/heads/master@{#36715}
parent 976a62ac
......@@ -31,6 +31,10 @@ class InstructionOperandConverter {
return ToRegister(instr_->InputAt(index));
}
FloatRegister InputFloatRegister(size_t index) {
return ToFloatRegister(instr_->InputAt(index));
}
DoubleRegister InputDoubleRegister(size_t index) {
return ToDoubleRegister(instr_->InputAt(index));
}
......@@ -89,6 +93,10 @@ class InstructionOperandConverter {
return ToRegister(instr_->TempAt(index));
}
FloatRegister OutputFloatRegister() {
return ToFloatRegister(instr_->Output());
}
DoubleRegister OutputDoubleRegister() {
return ToDoubleRegister(instr_->Output());
}
......@@ -111,6 +119,10 @@ class InstructionOperandConverter {
return LocationOperand::cast(op)->GetDoubleRegister();
}
FloatRegister ToFloatRegister(InstructionOperand* op) {
return LocationOperand::cast(op)->GetFloatRegister();
}
Constant ToConstant(InstructionOperand* op) {
if (op->IsImmediate()) {
return gen_->code()->GetImmediate(ImmediateOperand::cast(op));
......
......@@ -716,8 +716,12 @@ void CodeGenerator::AddTranslationForOperand(Translation* translation,
CHECK(false);
}
} else if (op->IsFPStackSlot()) {
DCHECK(IsFloatingPoint(type.representation()));
translation->StoreDoubleStackSlot(LocationOperand::cast(op)->index());
if (type.representation() == MachineRepresentation::kFloat64) {
translation->StoreDoubleStackSlot(LocationOperand::cast(op)->index());
} else {
DCHECK_EQ(MachineRepresentation::kFloat32, type.representation());
translation->StoreFloatStackSlot(LocationOperand::cast(op)->index());
}
} else if (op->IsRegister()) {
InstructionOperandConverter converter(this, instr);
if (type.representation() == MachineRepresentation::kBit) {
......@@ -734,9 +738,13 @@ void CodeGenerator::AddTranslationForOperand(Translation* translation,
CHECK(false);
}
} else if (op->IsFPRegister()) {
DCHECK(IsFloatingPoint(type.representation()));
InstructionOperandConverter converter(this, instr);
translation->StoreDoubleRegister(converter.ToDoubleRegister(op));
if (type.representation() == MachineRepresentation::kFloat64) {
translation->StoreDoubleRegister(converter.ToDoubleRegister(op));
} else {
DCHECK_EQ(MachineRepresentation::kFloat32, type.representation());
translation->StoreFloatRegister(converter.ToFloatRegister(op));
}
} else if (op->IsImmediate()) {
InstructionOperandConverter converter(this, instr);
Constant constant = converter.ToConstant(op);
......
......@@ -2451,6 +2451,10 @@ void Translation::StoreBoolRegister(Register reg) {
buffer_->Add(reg.code(), zone());
}
void Translation::StoreFloatRegister(FloatRegister reg) {
buffer_->Add(FLOAT_REGISTER, zone());
buffer_->Add(reg.code(), zone());
}
void Translation::StoreDoubleRegister(DoubleRegister reg) {
buffer_->Add(DOUBLE_REGISTER, zone());
......@@ -2481,6 +2485,10 @@ void Translation::StoreBoolStackSlot(int index) {
buffer_->Add(index, zone());
}
void Translation::StoreFloatStackSlot(int index) {
buffer_->Add(FLOAT_STACK_SLOT, zone());
buffer_->Add(index, zone());
}
void Translation::StoreDoubleStackSlot(int index) {
buffer_->Add(DOUBLE_STACK_SLOT, zone());
......@@ -2521,11 +2529,13 @@ int Translation::NumberOfOperandsFor(Opcode opcode) {
case INT32_REGISTER:
case UINT32_REGISTER:
case BOOL_REGISTER:
case FLOAT_REGISTER:
case DOUBLE_REGISTER:
case STACK_SLOT:
case INT32_STACK_SLOT:
case UINT32_STACK_SLOT:
case BOOL_STACK_SLOT:
case FLOAT_STACK_SLOT:
case DOUBLE_STACK_SLOT:
case LITERAL:
case COMPILED_STUB_FRAME:
......@@ -2815,6 +2825,14 @@ TranslatedValue TranslatedValue::NewDuplicateObject(TranslatedState* container,
}
// static
TranslatedValue TranslatedValue::NewFloat(TranslatedState* container,
float value) {
TranslatedValue slot(container, kFloat);
slot.float_value_ = value;
return slot;
}
// static
TranslatedValue TranslatedValue::NewDouble(TranslatedState* container,
double value) {
......@@ -2886,6 +2904,10 @@ uint32_t TranslatedValue::uint32_value() const {
return uint32_value_;
}
float TranslatedValue::float_value() const {
DCHECK_EQ(kFloat, kind());
return float_value_;
}
double TranslatedValue::double_value() const {
DCHECK_EQ(kDouble, kind());
......@@ -2964,6 +2986,7 @@ Handle<Object> TranslatedValue::GetValue() {
case TranslatedValue::kInt32:
case TranslatedValue::kUInt32:
case TranslatedValue::kBoolBit:
case TranslatedValue::kFloat:
case TranslatedValue::kDouble: {
MaterializeSimple();
return value_.ToHandleChecked();
......@@ -3005,6 +3028,10 @@ void TranslatedValue::MaterializeSimple() {
value_ = Handle<Object>(isolate()->factory()->NewNumber(uint32_value()));
return;
case kFloat:
value_ = Handle<Object>(isolate()->factory()->NewNumber(float_value()));
return;
case kDouble:
value_ = Handle<Object>(isolate()->factory()->NewNumber(double_value()));
return;
......@@ -3281,11 +3308,13 @@ TranslatedFrame TranslatedState::CreateNextTranslatedFrame(
case Translation::INT32_REGISTER:
case Translation::UINT32_REGISTER:
case Translation::BOOL_REGISTER:
case Translation::FLOAT_REGISTER:
case Translation::DOUBLE_REGISTER:
case Translation::STACK_SLOT:
case Translation::INT32_STACK_SLOT:
case Translation::UINT32_STACK_SLOT:
case Translation::BOOL_STACK_SLOT:
case Translation::FLOAT_STACK_SLOT:
case Translation::DOUBLE_STACK_SLOT:
case Translation::LITERAL:
break;
......@@ -3412,12 +3441,23 @@ TranslatedValue TranslatedState::CreateNextTranslatedValue(
return TranslatedValue::NewBool(this, static_cast<uint32_t>(value));
}
case Translation::FLOAT_REGISTER: {
int input_reg = iterator->Next();
if (registers == nullptr) return TranslatedValue::NewInvalid(this);
float value = registers->GetFloatRegister(input_reg);
if (trace_file != nullptr) {
PrintF(trace_file, "%e ; %s (float)", value,
FloatRegister::from_code(input_reg).ToString());
}
return TranslatedValue::NewFloat(this, value);
}
case Translation::DOUBLE_REGISTER: {
int input_reg = iterator->Next();
if (registers == nullptr) return TranslatedValue::NewInvalid(this);
double value = registers->GetDoubleRegister(input_reg);
if (trace_file != nullptr) {
PrintF(trace_file, "%e ; %s (bool)", value,
PrintF(trace_file, "%e ; %s (double)", value,
DoubleRegister::from_code(input_reg).ToString());
}
return TranslatedValue::NewDouble(this, value);
......@@ -3469,6 +3509,17 @@ TranslatedValue TranslatedState::CreateNextTranslatedValue(
return TranslatedValue::NewBool(this, value);
}
case Translation::FLOAT_STACK_SLOT: {
int slot_offset =
OptimizedFrame::StackSlotOffsetRelativeToFp(iterator->Next());
float value = ReadFloatValue(fp + slot_offset);
if (trace_file != nullptr) {
PrintF(trace_file, "%e ; (float) [fp %c %d] ", value,
slot_offset < 0 ? '-' : '+', std::abs(slot_offset));
}
return TranslatedValue::NewFloat(this, value);
}
case Translation::DOUBLE_STACK_SLOT: {
int slot_offset =
OptimizedFrame::StackSlotOffsetRelativeToFp(iterator->Next());
......@@ -3616,6 +3667,7 @@ Handle<Object> TranslatedState::MaterializeAt(int frame_index,
case TranslatedValue::kInt32:
case TranslatedValue::kUInt32:
case TranslatedValue::kBoolBit:
case TranslatedValue::kFloat:
case TranslatedValue::kDouble: {
slot->MaterializeSimple();
Handle<Object> value = slot->GetValue();
......
......@@ -39,6 +39,7 @@ class TranslatedValue {
kInt32,
kUInt32,
kBoolBit,
kFloat,
kDouble,
kCapturedObject, // Object captured by the escape analysis.
// The number of nested objects can be obtained
......@@ -61,6 +62,7 @@ class TranslatedValue {
static TranslatedValue NewDeferredObject(TranslatedState* container,
int length, int object_index);
static TranslatedValue NewDuplicateObject(TranslatedState* container, int id);
static TranslatedValue NewFloat(TranslatedState* container, float value);
static TranslatedValue NewDouble(TranslatedState* container, double value);
static TranslatedValue NewInt32(TranslatedState* container, int32_t value);
static TranslatedValue NewUInt32(TranslatedState* container, uint32_t value);
......@@ -93,6 +95,8 @@ class TranslatedValue {
uint32_t uint32_value_;
// kind is kInt32.
int32_t int32_value_;
// kind is kFloat
float float_value_;
// kind is kDouble
double double_value_;
// kind is kDuplicatedObject or kArgumentsObject or kCapturedObject.
......@@ -103,6 +107,7 @@ class TranslatedValue {
Object* raw_literal() const;
int32_t int32_value() const;
uint32_t uint32_value() const;
float float_value() const;
double double_value() const;
int object_length() const;
int object_index() const;
......@@ -738,6 +743,11 @@ class RegisterValues {
return registers_[n];
}
float GetFloatRegister(unsigned n) const {
DCHECK(n < arraysize(float_registers_));
return float_registers_[n];
}
double GetDoubleRegister(unsigned n) const {
DCHECK(n < arraysize(double_registers_));
return double_registers_[n];
......@@ -748,12 +758,18 @@ class RegisterValues {
registers_[n] = value;
}
void SetFloatRegister(unsigned n, float value) {
DCHECK(n < arraysize(float_registers_));
float_registers_[n] = value;
}
void SetDoubleRegister(unsigned n, double value) {
DCHECK(n < arraysize(double_registers_));
double_registers_[n] = value;
}
intptr_t registers_[Register::kNumRegisters];
float float_registers_[FloatRegister::kMaxNumRegisters];
double double_registers_[DoubleRegister::kMaxNumRegisters];
};
......@@ -977,11 +993,13 @@ class TranslationIterator BASE_EMBEDDED {
V(INT32_REGISTER) \
V(UINT32_REGISTER) \
V(BOOL_REGISTER) \
V(FLOAT_REGISTER) \
V(DOUBLE_REGISTER) \
V(STACK_SLOT) \
V(INT32_STACK_SLOT) \
V(UINT32_STACK_SLOT) \
V(BOOL_STACK_SLOT) \
V(FLOAT_STACK_SLOT) \
V(DOUBLE_STACK_SLOT) \
V(LITERAL)
......@@ -1023,11 +1041,13 @@ class Translation BASE_EMBEDDED {
void StoreInt32Register(Register reg);
void StoreUint32Register(Register reg);
void StoreBoolRegister(Register reg);
void StoreFloatRegister(FloatRegister reg);
void StoreDoubleRegister(DoubleRegister reg);
void StoreStackSlot(int index);
void StoreInt32StackSlot(int index);
void StoreUint32StackSlot(int index);
void StoreBoolStackSlot(int index);
void StoreFloatStackSlot(int index);
void StoreDoubleStackSlot(int index);
void StoreLiteral(int literal_id);
void StoreArgumentsObject(bool args_known, int args_index, int args_length);
......
......@@ -13974,6 +13974,13 @@ void DeoptimizationInputData::DeoptimizationInputDataPrint(
break;
}
case Translation::FLOAT_REGISTER: {
int reg_code = iterator.Next();
os << "{input=" << FloatRegister::from_code(reg_code).ToString()
<< "}";
break;
}
case Translation::DOUBLE_REGISTER: {
int reg_code = iterator.Next();
os << "{input=" << DoubleRegister::from_code(reg_code).ToString()
......@@ -14005,6 +14012,7 @@ void DeoptimizationInputData::DeoptimizationInputDataPrint(
break;
}
case Translation::FLOAT_STACK_SLOT:
case Translation::DOUBLE_STACK_SLOT: {
int input_slot_index = iterator.Next();
os << "{input=" << input_slot_index << "}";
......
......@@ -1524,6 +1524,10 @@ static inline void WriteUnalignedValue(void* p, V value) {
#endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
}
static inline double ReadFloatValue(const void* p) {
return ReadUnalignedValue<float>(p);
}
static inline double ReadDoubleValue(const void* p) {
return ReadUnalignedValue<double>(p);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment