[vm/compiler] fix missing unbox code

Rationale:
Two safe non-speculative cases were missing,
causing AOT to crash on some fuzzing sessions.
Note fuzzer is regression test here.

https://github.com/dart-lang/sdk/issues/38145

Change-Id: I12c633d66e387c703f1bcf0b6eebd50165bb2970
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115445
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
This commit is contained in:
Aart Bik 2019-09-04 20:40:31 +00:00 committed by commit-bot@chromium.org
parent c0e327ea85
commit 6be60a76e4

View file

@ -1611,6 +1611,7 @@ bool BlockEntryInstr::FindOsrEntryAndRelink(GraphEntryInstr* graph_entry,
auto goto_join = new GotoInstr(AsJoinEntry(),
CompilerState::Current().GetNextDeoptId());
ASSERT(parent != nullptr);
goto_join->CopyDeoptIdFrom(*parent);
osr_entry->LinkTo(goto_join);
@ -3101,7 +3102,7 @@ Definition* BoxInt64Instr::Canonicalize(FlowGraph* flow_graph) {
// Find a more precise box instruction.
if (auto conv = value()->definition()->AsIntConverter()) {
Definition* replacement = this;
Definition* replacement;
switch (conv->from()) {
case kUnboxedInt32:
replacement = new BoxInt32Instr(conv->value()->CopyWithType());
@ -3113,9 +3114,7 @@ Definition* BoxInt64Instr::Canonicalize(FlowGraph* flow_graph) {
UNREACHABLE();
break;
}
if (replacement != this) {
flow_graph->InsertBefore(this, replacement, NULL, FlowGraph::kValue);
}
flow_graph->InsertBefore(this, replacement, NULL, FlowGraph::kValue);
return replacement;
}
@ -5074,6 +5073,10 @@ void UnboxInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
EmitLoadFromBox(compiler);
} else if (CanConvertSmi() && (value_cid == kSmiCid)) {
EmitSmiConversion(compiler);
} else if (representation() == kUnboxedInt32 && value()->Type()->IsInt()) {
EmitLoadInt32FromBoxOrSmi(compiler);
} else if (representation() == kUnboxedInt64 && value()->Type()->IsInt()) {
EmitLoadInt64FromBoxOrSmi(compiler);
} else {
ASSERT(CanDeoptimize());
EmitLoadFromBoxWithDeopt(compiler);