Commit 50c5ac57 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[deoptimizer] Fix Deoptimizer::GetDeoptInfo for last entry.

This fixes the corner-case where the method in question failed to lookup
the very last deoptimization bailout without subsequent entries within
the relocation info. Also enable a test covering this.

R=tebbi@chromium.org
TEST=cctest/test-cpu-profiler/CollectDeoptEvents

Review-Url: https://codereview.chromium.org/2565733002
Cr-Commit-Position: refs/heads/master@{#41623}
parent 89e10055
...@@ -2714,6 +2714,7 @@ DeoptimizedFrameInfo::DeoptimizedFrameInfo(TranslatedState* state, ...@@ -2714,6 +2714,7 @@ DeoptimizedFrameInfo::DeoptimizedFrameInfo(TranslatedState* state,
Deoptimizer::DeoptInfo Deoptimizer::GetDeoptInfo(Code* code, Address pc) { Deoptimizer::DeoptInfo Deoptimizer::GetDeoptInfo(Code* code, Address pc) {
CHECK(code->instruction_start() <= pc && pc <= code->instruction_end());
SourcePosition last_position = SourcePosition::Unknown(); SourcePosition last_position = SourcePosition::Unknown();
DeoptimizeReason last_reason = DeoptimizeReason::kNoReason; DeoptimizeReason last_reason = DeoptimizeReason::kNoReason;
int last_deopt_id = kNoDeoptimizationId; int last_deopt_id = kNoDeoptimizationId;
...@@ -2723,9 +2724,7 @@ Deoptimizer::DeoptInfo Deoptimizer::GetDeoptInfo(Code* code, Address pc) { ...@@ -2723,9 +2724,7 @@ Deoptimizer::DeoptInfo Deoptimizer::GetDeoptInfo(Code* code, Address pc) {
RelocInfo::ModeMask(RelocInfo::DEOPT_INLINING_ID); RelocInfo::ModeMask(RelocInfo::DEOPT_INLINING_ID);
for (RelocIterator it(code, mask); !it.done(); it.next()) { for (RelocIterator it(code, mask); !it.done(); it.next()) {
RelocInfo* info = it.rinfo(); RelocInfo* info = it.rinfo();
if (info->pc() >= pc) { if (info->pc() >= pc) break;
return DeoptInfo(last_position, last_reason, last_deopt_id);
}
if (info->rmode() == RelocInfo::DEOPT_SCRIPT_OFFSET) { if (info->rmode() == RelocInfo::DEOPT_SCRIPT_OFFSET) {
int script_offset = static_cast<int>(info->data()); int script_offset = static_cast<int>(info->data());
it.next(); it.next();
...@@ -2738,7 +2737,7 @@ Deoptimizer::DeoptInfo Deoptimizer::GetDeoptInfo(Code* code, Address pc) { ...@@ -2738,7 +2737,7 @@ Deoptimizer::DeoptInfo Deoptimizer::GetDeoptInfo(Code* code, Address pc) {
last_reason = static_cast<DeoptimizeReason>(info->data()); last_reason = static_cast<DeoptimizeReason>(info->data());
} }
} }
return DeoptInfo(SourcePosition::Unknown(), DeoptimizeReason::kNoReason, -1); return DeoptInfo(last_position, last_reason, last_deopt_id);
} }
......
...@@ -332,9 +332,6 @@ ...@@ -332,9 +332,6 @@
############################################################################## ##############################################################################
['variant == turbofan or variant == ignition_turbofan', { ['variant == turbofan or variant == ignition_turbofan', {
# BUG(4751). Deopts with kNotASmi instead of expected deopt reason.
'test-cpu-profiler/CollectDeoptEvents': [SKIP],
# BUG(4751). Flaky with Ignition. # BUG(4751). Flaky with Ignition.
'test-cpu-profiler/JsNativeJsSample': [SKIP], 'test-cpu-profiler/JsNativeJsSample': [SKIP],
......
...@@ -1872,15 +1872,20 @@ TEST(CollectDeoptEvents) { ...@@ -1872,15 +1872,20 @@ TEST(CollectDeoptEvents) {
{ {
const char* branch[] = {"", "opt_function0", "opt_function0"}; const char* branch[] = {"", "opt_function0", "opt_function0"};
CHECK_EQ(reason(i::DeoptimizeReason::kNotAHeapNumber), const char* deopt_reason =
GetBranchDeoptReason(env, iprofile, branch, arraysize(branch))); GetBranchDeoptReason(env, iprofile, branch, arraysize(branch));
if (deopt_reason != reason(i::DeoptimizeReason::kNotAHeapNumber) &&
deopt_reason != reason(i::DeoptimizeReason::kNotASmi)) {
FATAL(deopt_reason);
}
} }
{ {
const char* branch[] = {"", "opt_function1", "opt_function1"}; const char* branch[] = {"", "opt_function1", "opt_function1"};
const char* deopt_reason = const char* deopt_reason =
GetBranchDeoptReason(env, iprofile, branch, arraysize(branch)); GetBranchDeoptReason(env, iprofile, branch, arraysize(branch));
if (deopt_reason != reason(i::DeoptimizeReason::kNaN) && if (deopt_reason != reason(i::DeoptimizeReason::kNaN) &&
deopt_reason != reason(i::DeoptimizeReason::kLostPrecisionOrNaN)) { deopt_reason != reason(i::DeoptimizeReason::kLostPrecisionOrNaN) &&
deopt_reason != reason(i::DeoptimizeReason::kNotASmi)) {
FATAL(deopt_reason); FATAL(deopt_reason);
} }
} }
......
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