Commit b1e2d1e4 authored by bmeurer's avatar bmeurer Committed by Commit bot

[deoptimizer] Materialize double values as smis whenever possible.

R=jarin@chromium.org

Review URL: https://codereview.chromium.org/1156393002

Cr-Commit-Position: refs/heads/master@{#28675}
parent b77df027
...@@ -2269,6 +2269,9 @@ void Deoptimizer::DoTranslateObject(TranslationIterator* iterator, ...@@ -2269,6 +2269,9 @@ void Deoptimizer::DoTranslateObject(TranslationIterator* iterator,
case Translation::DOUBLE_REGISTER: { case Translation::DOUBLE_REGISTER: {
int input_reg = iterator->Next(); int input_reg = iterator->Next();
double value = input_->GetDoubleRegister(input_reg); double value = input_->GetDoubleRegister(input_reg);
int int_value = FastD2IChecked(value);
bool is_smi =
!IsMinusZero(value) && value == int_value && Smi::IsValid(int_value);
if (trace_scope_ != NULL) { if (trace_scope_ != NULL) {
PrintF(trace_scope_->file(), PrintF(trace_scope_->file(),
" object @0x%08" V8PRIxPTR ": [field #%d] <- ", " object @0x%08" V8PRIxPTR ": [field #%d] <- ",
...@@ -2278,7 +2281,13 @@ void Deoptimizer::DoTranslateObject(TranslationIterator* iterator, ...@@ -2278,7 +2281,13 @@ void Deoptimizer::DoTranslateObject(TranslationIterator* iterator,
"%e ; %s\n", value, "%e ; %s\n", value,
DoubleRegister::AllocationIndexToString(input_reg)); DoubleRegister::AllocationIndexToString(input_reg));
} }
AddObjectDoubleValue(value); if (is_smi) {
intptr_t tagged_value =
reinterpret_cast<intptr_t>(Smi::FromInt(int_value));
AddObjectTaggedValue(tagged_value);
} else {
AddObjectDoubleValue(value);
}
return; return;
} }
...@@ -2380,6 +2389,9 @@ void Deoptimizer::DoTranslateObject(TranslationIterator* iterator, ...@@ -2380,6 +2389,9 @@ void Deoptimizer::DoTranslateObject(TranslationIterator* iterator,
int input_slot_index = iterator->Next(); int input_slot_index = iterator->Next();
unsigned input_offset = input_->GetOffsetFromSlotIndex(input_slot_index); unsigned input_offset = input_->GetOffsetFromSlotIndex(input_slot_index);
double value = input_->GetDoubleFrameSlot(input_offset); double value = input_->GetDoubleFrameSlot(input_offset);
int int_value = FastD2IChecked(value);
bool is_smi =
!IsMinusZero(value) && value == int_value && Smi::IsValid(int_value);
if (trace_scope_ != NULL) { if (trace_scope_ != NULL) {
PrintF(trace_scope_->file(), PrintF(trace_scope_->file(),
" object @0x%08" V8PRIxPTR ": [field #%d] <- ", " object @0x%08" V8PRIxPTR ": [field #%d] <- ",
...@@ -2388,7 +2400,13 @@ void Deoptimizer::DoTranslateObject(TranslationIterator* iterator, ...@@ -2388,7 +2400,13 @@ void Deoptimizer::DoTranslateObject(TranslationIterator* iterator,
PrintF(trace_scope_->file(), PrintF(trace_scope_->file(),
"%e ; [sp + %d]\n", value, input_offset); "%e ; [sp + %d]\n", value, input_offset);
} }
AddObjectDoubleValue(value); if (is_smi) {
intptr_t tagged_value =
reinterpret_cast<intptr_t>(Smi::FromInt(int_value));
AddObjectTaggedValue(tagged_value);
} else {
AddObjectDoubleValue(value);
}
return; return;
} }
...@@ -2586,18 +2604,25 @@ void Deoptimizer::DoTranslateCommand(TranslationIterator* iterator, ...@@ -2586,18 +2604,25 @@ void Deoptimizer::DoTranslateCommand(TranslationIterator* iterator,
case Translation::DOUBLE_REGISTER: { case Translation::DOUBLE_REGISTER: {
int input_reg = iterator->Next(); int input_reg = iterator->Next();
double value = input_->GetDoubleRegister(input_reg); double value = input_->GetDoubleRegister(input_reg);
int int_value = FastD2IChecked(value);
bool is_smi =
!IsMinusZero(value) && value == int_value && Smi::IsValid(int_value);
if (trace_scope_ != NULL) { if (trace_scope_ != NULL) {
PrintF(trace_scope_->file(), PrintF(trace_scope_->file(),
" 0x%08" V8PRIxPTR ": [top + %d] <- %e ; %s\n", " 0x%08" V8PRIxPTR ": [top + %d] <- %e ; %s\n",
output_[frame_index]->GetTop() + output_offset, output_[frame_index]->GetTop() + output_offset, output_offset,
output_offset, value, DoubleRegister::AllocationIndexToString(input_reg));
value, }
DoubleRegister::AllocationIndexToString(input_reg)); if (is_smi) {
intptr_t tagged_value =
reinterpret_cast<intptr_t>(Smi::FromInt(int_value));
output_[frame_index]->SetFrameSlot(output_offset, tagged_value);
} else {
// We save the untagged value on the side and store a GC-safe
// temporary placeholder in the frame.
AddDoubleValue(output_[frame_index]->GetTop() + output_offset, value);
output_[frame_index]->SetFrameSlot(output_offset, kPlaceholder);
} }
// We save the untagged value on the side and store a GC-safe
// temporary placeholder in the frame.
AddDoubleValue(output_[frame_index]->GetTop() + output_offset, value);
output_[frame_index]->SetFrameSlot(output_offset, kPlaceholder);
return; return;
} }
...@@ -2713,6 +2738,9 @@ void Deoptimizer::DoTranslateCommand(TranslationIterator* iterator, ...@@ -2713,6 +2738,9 @@ void Deoptimizer::DoTranslateCommand(TranslationIterator* iterator,
int input_slot_index = iterator->Next(); int input_slot_index = iterator->Next();
unsigned input_offset = input_->GetOffsetFromSlotIndex(input_slot_index); unsigned input_offset = input_->GetOffsetFromSlotIndex(input_slot_index);
double value = input_->GetDoubleFrameSlot(input_offset); double value = input_->GetDoubleFrameSlot(input_offset);
int int_value = FastD2IChecked(value);
bool is_smi =
!IsMinusZero(value) && value == int_value && Smi::IsValid(int_value);
if (trace_scope_ != NULL) { if (trace_scope_ != NULL) {
PrintF(trace_scope_->file(), PrintF(trace_scope_->file(),
" 0x%08" V8PRIxPTR ": [top + %d] <- %e ; [sp + %d]\n", " 0x%08" V8PRIxPTR ": [top + %d] <- %e ; [sp + %d]\n",
...@@ -2721,10 +2749,16 @@ void Deoptimizer::DoTranslateCommand(TranslationIterator* iterator, ...@@ -2721,10 +2749,16 @@ void Deoptimizer::DoTranslateCommand(TranslationIterator* iterator,
value, value,
input_offset); input_offset);
} }
// We save the untagged value on the side and store a GC-safe if (is_smi) {
// temporary placeholder in the frame. intptr_t tagged_value =
AddDoubleValue(output_[frame_index]->GetTop() + output_offset, value); reinterpret_cast<intptr_t>(Smi::FromInt(int_value));
output_[frame_index]->SetFrameSlot(output_offset, kPlaceholder); output_[frame_index]->SetFrameSlot(output_offset, tagged_value);
} else {
// We save the untagged value on the side and store a GC-safe
// temporary placeholder in the frame.
AddDoubleValue(output_[frame_index]->GetTop() + output_offset, value);
output_[frame_index]->SetFrameSlot(output_offset, kPlaceholder);
}
return; return;
} }
......
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