[dart/vm] Fix bug on missed exception in AOT

Rationale:
The regression test in this CL should throw
with a NoSuchMethod on null. However, before
the fix, AOT did not throw at all.

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

Change-Id: I4037b163092caf78d313815624fd3b20c20f88ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/109550
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
Aart Bik
2019-07-19 22:43:31 +00:00
committed by commit-bot@chromium.org
parent 1014272f3b
commit ebc180be95
4 changed files with 61 additions and 27 deletions
+6 -5
View File
@@ -2221,11 +2221,12 @@ class PhiInstr : public Definition {
};
// This instruction represents an incomming parameter for a function entry,
// or incomming value for OSR entry or incomming value for a catch entry.
// When [base_reg] is set to FPREG [index] corresponds to environment
// variable index (0 is the very first parameter, 1 is next and so on).
// When [base_reg] is set to SPREG [index] corresponds to SP relative parameter
// indices (0 is the very last parameter, 1 is next and so on).
// or incoming value for OSR entry or incomming value for a catch entry.
// Value [index] always denotes the position of the parameter. When [base_reg]
// is set to FPREG, value [index] corresponds to environment variable index
// (0 is the very first parameter, 1 is next and so on). When [base_reg] is
// set to SPREG, value [index] needs to be reversed (0 is the very last
// parameter, 1 is next and so on) to get the sp relative position.
class ParameterInstr : public Definition {
public:
ParameterInstr(intptr_t index,
+5 -1
View File
@@ -738,10 +738,14 @@ void FlowGraphAllocator::ProcessInitialDefinition(Definition* defn,
ParameterInstr* param = defn->AsParameter();
intptr_t slot_index = param->index();
ASSERT(slot_index >= 0);
ASSERT((param->base_reg() == FPREG) || (param->base_reg() == SPREG));
if (param->base_reg() == FPREG) {
// Slot index for the rightmost fixed parameter is -1.
slot_index -= flow_graph_.num_direct_parameters();
} else {
// Slot index for a "frameless" parameter is reversed.
ASSERT(param->base_reg() == SPREG);
ASSERT(slot_index < flow_graph_.num_direct_parameters());
slot_index = flow_graph_.num_direct_parameters() - 1 - slot_index;
}
#if defined(TARGET_ARCH_DBC)
+19 -21
View File
@@ -161,8 +161,8 @@ static bool IntrinsifyArrayGetIndexed(FlowGraph* flow_graph,
auto normal_entry = graph_entry->normal_entry();
BlockBuilder builder(flow_graph, normal_entry);
Definition* index = builder.AddParameter(0, /*with_frame=*/false);
Definition* array = builder.AddParameter(1, /*with_frame=*/false);
Definition* array = builder.AddParameter(0, /*with_frame=*/false);
Definition* index = builder.AddParameter(1, /*with_frame=*/false);
index = PrepareIndexedOp(flow_graph, &builder, array, index,
Slot::GetLengthFieldForArrayCid(array_cid));
@@ -269,9 +269,9 @@ static bool IntrinsifyArraySetIndexed(FlowGraph* flow_graph,
auto normal_entry = graph_entry->normal_entry();
BlockBuilder builder(flow_graph, normal_entry);
Definition* value = builder.AddParameter(0, /*with_frame=*/false);
Definition* array = builder.AddParameter(0, /*with_frame=*/false);
Definition* index = builder.AddParameter(1, /*with_frame=*/false);
Definition* array = builder.AddParameter(2, /*with_frame=*/false);
Definition* value = builder.AddParameter(2, /*with_frame=*/false);
index = PrepareIndexedOp(flow_graph, &builder, array, index,
Slot::GetLengthFieldForArrayCid(array_cid));
@@ -473,8 +473,8 @@ static bool BuildCodeUnitAt(FlowGraph* flow_graph, intptr_t cid) {
auto normal_entry = graph_entry->normal_entry();
BlockBuilder builder(flow_graph, normal_entry);
Definition* index = builder.AddParameter(0, /*with_frame=*/false);
Definition* str = builder.AddParameter(1, /*with_frame=*/false);
Definition* str = builder.AddParameter(0, /*with_frame=*/false);
Definition* index = builder.AddParameter(1, /*with_frame=*/false);
index =
PrepareIndexedOp(flow_graph, &builder, str, index, Slot::String_length());
@@ -536,8 +536,8 @@ static bool BuildSimdOp(FlowGraph* flow_graph, intptr_t cid, Token::Kind kind) {
auto normal_entry = graph_entry->normal_entry();
BlockBuilder builder(flow_graph, normal_entry);
Definition* right = builder.AddParameter(0, /*with_frame=*/false);
Definition* left = builder.AddParameter(1, /*with_frame=*/false);
Definition* left = builder.AddParameter(0, /*with_frame=*/false);
Definition* right = builder.AddParameter(1, /*with_frame=*/false);
Cids* value_check = Cids::CreateMonomorphic(zone, cid);
// Check argument. Receiver (left) is known to be a Float32x4.
@@ -676,8 +676,8 @@ bool GraphIntrinsifier::Build_GrowableArrayGetIndexed(FlowGraph* flow_graph) {
auto normal_entry = graph_entry->normal_entry();
BlockBuilder builder(flow_graph, normal_entry);
Definition* index = builder.AddParameter(0, /*with_frame=*/false);
Definition* growable_array = builder.AddParameter(1, /*with_frame=*/false);
Definition* growable_array = builder.AddParameter(0, /*with_frame=*/false);
Definition* index = builder.AddParameter(1, /*with_frame=*/false);
index = PrepareIndexedOp(flow_graph, &builder, growable_array, index,
Slot::GrowableObjectArray_length());
@@ -707,9 +707,9 @@ bool GraphIntrinsifier::Build_ObjectArraySetIndexedUnchecked(
auto normal_entry = graph_entry->normal_entry();
BlockBuilder builder(flow_graph, normal_entry);
Definition* value = builder.AddParameter(0, /*with_frame=*/false);
Definition* array = builder.AddParameter(0, /*with_frame=*/false);
Definition* index = builder.AddParameter(1, /*with_frame=*/false);
Definition* array = builder.AddParameter(2, /*with_frame=*/false);
Definition* value = builder.AddParameter(2, /*with_frame=*/false);
index = PrepareIndexedOp(flow_graph, &builder, array, index,
Slot::Array_length());
@@ -738,9 +738,9 @@ bool GraphIntrinsifier::Build_GrowableArraySetIndexedUnchecked(
auto normal_entry = graph_entry->normal_entry();
BlockBuilder builder(flow_graph, normal_entry);
Definition* value = builder.AddParameter(0, /*with_frame=*/false);
Definition* array = builder.AddParameter(0, /*with_frame=*/false);
Definition* index = builder.AddParameter(1, /*with_frame=*/false);
Definition* array = builder.AddParameter(2, /*with_frame=*/false);
Definition* value = builder.AddParameter(2, /*with_frame=*/false);
index = PrepareIndexedOp(flow_graph, &builder, array, index,
Slot::GrowableObjectArray_length());
@@ -764,8 +764,8 @@ bool GraphIntrinsifier::Build_GrowableArraySetData(FlowGraph* flow_graph) {
auto normal_entry = graph_entry->normal_entry();
BlockBuilder builder(flow_graph, normal_entry);
Definition* data = builder.AddParameter(0, /*with_frame=*/false);
Definition* growable_array = builder.AddParameter(1, /*with_frame=*/false);
Definition* growable_array = builder.AddParameter(0, /*with_frame=*/false);
Definition* data = builder.AddParameter(1, /*with_frame=*/false);
Zone* zone = flow_graph->zone();
Cids* value_check = Cids::CreateMonomorphic(zone, kArrayCid);
@@ -786,8 +786,8 @@ bool GraphIntrinsifier::Build_GrowableArraySetLength(FlowGraph* flow_graph) {
auto normal_entry = graph_entry->normal_entry();
BlockBuilder builder(flow_graph, normal_entry);
Definition* length = builder.AddParameter(0, /*with_frame=*/false);
Definition* growable_array = builder.AddParameter(1, /*with_frame=*/false);
Definition* growable_array = builder.AddParameter(0, /*with_frame=*/false);
Definition* length = builder.AddParameter(1, /*with_frame=*/false);
builder.AddInstruction(
new CheckSmiInstr(new Value(length), DeoptId::kNone, builder.TokenPos()));
@@ -829,9 +829,7 @@ static bool BuildInvokeMathCFunction(BlockBuilder* builder,
new ZoneGrowableArray<Value*>(num_parameters);
for (intptr_t i = 0; i < num_parameters; i++) {
const intptr_t parameter_index = (num_parameters - i - 1);
Definition* value =
builder->AddParameter(parameter_index, /*with_frame=*/false);
Definition* value = builder->AddParameter(i, /*with_frame=*/false);
Definition* unboxed_value =
builder->AddUnboxInstr(kUnboxedDouble, value, /* is_checked = */ false);
args->Add(new Value(unboxed_value));
@@ -0,0 +1,31 @@
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Issue #37408: AOT did not throw.
import "package:expect/expect.dart";
import 'dart:math';
String var0 = '5Zso';
double foo2(String par1) {
return atan2(0.16964141699241508, num.tryParse('\u2665vDil'));
}
class X0 {
void run() {
foo2(var0);
}
}
main() {
bool x = false;
try {
new X0().run();
} catch (exception, stackTrace) {
x = true;
}
Expect.isTrue(x);
}