Skip to content

Commit

Permalink
Version 3.6.0-291.0.dev
Browse files Browse the repository at this point in the history
Merge 68552a5 into dev
  • Loading branch information
Dart CI committed Sep 27, 2024
2 parents ee7a0bd + 68552a5 commit 1881c66
Show file tree
Hide file tree
Showing 17 changed files with 281 additions and 76 deletions.
10 changes: 9 additions & 1 deletion pkg/dart2wasm/lib/deferred_loading.dart
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,15 @@ void transformComponentForTestMode(Component component,
invokeMain.function.emittedValueType = const VoidType();

final oldBody = invokeMain.function.body!;
invokeMain.function.body = Block([...loadStatements, oldBody]);

// Add print of 'unittest-suite-wait-for-done' to indicate to test harnesses
// that the test contains async work. Any test using test most must therefore
// also include a concluding 'unittest-suite-done' message. Usually via calls
// to `asyncStart` and `asyncEnd` helpers.
final asyncStart = ExpressionStatement(StaticInvocation(
coreTypes.printProcedure,
Arguments([StringLiteral('unittest-suite-wait-for-done')])));
invokeMain.function.body = Block([asyncStart, ...loadStatements, oldBody]);

// The await transformer runs modularly before this transform so we need to
// rerun it on the transformed `_invokeMain` method.
Expand Down
2 changes: 1 addition & 1 deletion pkg/test_runner/lib/src/browser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ String dart2wasmHtml(String title, String wasmPath, String mjsPath) {
const mjs = await import(mjsPath);
const compiledApp = await mjs.compileStreaming(fetch(wasmPath));
window.loadData = async (relativeToWasmFileUri) => {
const path = '$wasmPath'.slice(0, wasmFilename.lastIndexOf('/'));
const path = '$wasmPath'.slice(0, wasmPath.lastIndexOf('/'));
const response = await fetch(`\${path}/\${relativeToWasmFileUri}`);
return response.arrayBuffer();
};
Expand Down
9 changes: 8 additions & 1 deletion runtime/tests/vm/dart/block_ordering_il_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,14 @@ void matchIL$throwInALoop(FlowGraph graph) {
]),
'loop_inc' <<
match.block('Target', [
'inc_i' << match.BinaryInt64Op('i', match.any),
if (is32BitConfiguration) ...[
'i_32' << match.IntConverter('i', from: 'int64', to: 'int32'),
'inc_i_32' << match.BinaryInt32Op('i_32', match.any),
'inc_i' <<
match.IntConverter('inc_i_32', from: 'int32', to: 'int64'),
] else ...[
'inc_i' << match.BinaryInt64Op('i', match.any),
],
match.Goto('loop_header'),
]),
'return_found' <<
Expand Down
13 changes: 8 additions & 5 deletions runtime/tests/vm/dart/load_indexed_trivial_type_il_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ int forInListOfInt(List<int> list) {
void matchIL$forInListOfInt(FlowGraph graph) {
graph.match([
match.block('Graph', [
'int 0' << match.UnboxedConstant(),
'int 1' << match.UnboxedConstant(),
'int 0' << match.UnboxedConstant(value: 0),
'int 1' << match.UnboxedConstant(value: 1),
]),
match.block('Function', [
'list' << match.Parameter(index: 0),
Expand All @@ -31,17 +31,20 @@ void matchIL$forInListOfInt(FlowGraph graph) {
'B14' <<
match.block('Join', [
'result' << match.Phi('int 0', 'result^e'),
'index' << match.Phi('int 0', 'index+1'),
'index' << match.Phi(match.any, 'index+1'),
match.Branch(match.RelationalOp(match.any, match.any, kind: '>=')),
]),
'B4' << match.block('Target'),
'B10' <<
match.block('Target', [
if (is32BitConfiguration) 'box(index)' << match.BoxInt64('index'),
if (is32BitConfiguration) 'box(index)' << match.BoxInt32('index'),
'e' <<
match.LoadIndexed(
'list.data', is32BitConfiguration ? 'box(index)' : 'index'),
'index+1' << match.BinaryInt64Op('index', 'int 1'),
if (is32BitConfiguration)
'index+1' << match.BinaryInt32Op('index', 'int 1')
else
'index+1' << match.BinaryInt64Op('index', 'int 1'),
'unbox(e)' << match.UnboxInt64('e'),
'result^e' << match.BinaryInt64Op('result', 'unbox(e)'),
match.Goto('B14'),
Expand Down
16 changes: 13 additions & 3 deletions runtime/tests/vm/dart/regress_48764_il_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,15 @@ void matchIL$main_testForIn(FlowGraph graph) {
match.block('Join', [
'v124' << match.Phi(match.any, 'v37'),
match.CheckStackOverflow(),
match.Branch(match.RelationalOp('v124', 'v112', kind: '>='),
ifTrue: 'B4', ifFalse: 'B3'),
if (is32BitConfiguration)
'v124_ext' <<
match.IntConverter('v124', from: 'int32', to: 'int64'),
match.Branch(
match.RelationalOp(
is32BitConfiguration ? 'v124_ext' : 'v124', 'v112',
kind: '>='),
ifTrue: 'B4',
ifFalse: 'B3'),
]),
'B4' <<
match.block('Target', [
Expand All @@ -57,7 +64,10 @@ void matchIL$main_testForIn(FlowGraph graph) {
'B3' <<
match.block('Target', [
match.GenericCheckBound(),
'v37' << match.BinaryInt64Op('v124', match.any),
if (is32BitConfiguration)
'v37' << match.BinaryInt32Op('v124', match.any)
else
'v37' << match.BinaryInt64Op('v124', match.any),
match.Goto('B14'),
]),
]);
Expand Down
16 changes: 13 additions & 3 deletions runtime/tests/vm/dart/regress_51790_il_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,15 @@ void matchIL$sumAll(FlowGraph graph) {
'v5' << match.Phi(match.any, 'v28'),
'v130' << match.Phi(match.any, 'v45'),
match.CheckStackOverflow(),
match.Branch(match.RelationalOp('v130', 'v120', kind: '>='),
ifTrue: 'B4', ifFalse: 'B3'),
if (is32BitConfiguration)
'v130_ext' <<
match.IntConverter('v130', from: 'int32', to: 'int64'),
match.Branch(
match.RelationalOp(
is32BitConfiguration ? 'v130_ext' : 'v130', 'v120',
kind: '>='),
ifTrue: 'B4',
ifFalse: 'B3'),
]),
'B4' <<
match.block('Target', [
Expand All @@ -54,7 +61,10 @@ void matchIL$sumAll(FlowGraph graph) {
match.block('Target', [
match.GenericCheckBound(),
'v135' << match.LoadIndexed('v114', match.any),
'v45' << match.BinaryInt64Op('v130', match.any),
if (is32BitConfiguration)
'v45' << match.BinaryInt32Op('v130', match.any)
else
'v45' << match.BinaryInt64Op('v130', match.any),
'v125' << match.UnboxInt64('v135'),
'v28' << match.BinaryInt64Op('v5', 'v125'),
match.Goto('B16'),
Expand Down
7 changes: 6 additions & 1 deletion runtime/tests/vm/dart/regress_53817_il_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ void matchIL$createAndIterate(FlowGraph graph) {
[
'i' << match.Phi('i+1', match.any),
match.CheckStackOverflow(),
if (is32BitConfiguration)
'i_ext' << match.IntConverter('i', from: 'int32', to: 'int64'),
match.Branch(match.RelationalOp(match.any, match.any, kind: '>='),
ifTrue: 'loop_exit', ifFalse: 'loop_body'),
].withoutWildcards),
Expand All @@ -55,7 +57,10 @@ void matchIL$createAndIterate(FlowGraph graph) {
// related code was entirely eliminated - thus no wildcards
// when matching.
[
'i+1' << match.BinaryInt64Op('i', match.any),
if (is32BitConfiguration)
'i+1' << match.BinaryInt32Op('i', match.any)
else
'i+1' << match.BinaryInt64Op('i', match.any),
match.Goto('loop'),
].withoutWildcards),
]);
Expand Down
80 changes: 80 additions & 0 deletions runtime/tests/vm/dart/regress_56726_il_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Copyright (c) 2024, 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.

// Verify that List bound check is eliminated in a simple for-loop
// over growable list.

import 'package:vm/testing/il_matchers.dart';

@pragma('vm:never-inline')
void myprint(Object o) {
print(o);
}

@pragma('vm:never-inline')
@pragma('vm:testing:print-flow-graph')
useList(List<int> a) {
for (int i = 0; i < a.length; ++i) {
final value = a[i];
myprint(value);
}
}

main() {
useList([]);
useList([100]);
}

void matchIL$useList(FlowGraph graph) {
graph.dump();
graph.match([
match.block('Graph', [
'c_null' << match.Constant(value: null),
'c_zero' << match.UnboxedConstant(value: 0),
'c_one' << match.UnboxedConstant(value: 1),
]),
match.block('Function', [
'a' << match.Parameter(index: 0),
match.CheckStackOverflow(),
match.Goto('B5'),
]),
'B5' <<
match.block('Join', [
'i' << match.Phi('c_zero', 'i+1'),
match.CheckStackOverflow(),
'a.length' <<
match.LoadField('a', slot: 'GrowableObjectArray.length'),
'a.length_unboxed' << match.UnboxInt64('a.length'),
match.Branch(match.RelationalOp('i', 'a.length_unboxed', kind: '<'),
ifTrue: 'B3', ifFalse: 'B4'),
]),
'B3' <<
match.block('Target', [
// No bounds check here.
if (is32BitConfiguration)
'i_boxed' << match.BoxInt64('i', skipUntilMatched: false),
'a.data' <<
match.LoadField('a',
slot: 'GrowableObjectArray.data', skipUntilMatched: false),
'value' <<
match.LoadIndexed(
'a.data', is32BitConfiguration ? 'i_boxed' : 'i',
skipUntilMatched: false),
'value_unboxed' << match.UnboxInt64('value'),
match.StaticCall('value_unboxed'),
if (is32BitConfiguration) ...[
'i_32' << match.IntConverter('i', from: 'int64', to: 'int32'),
'i+1_32' << match.BinaryInt32Op('i_32', 'c_one', op_kind: '+'),
'i+1' << match.IntConverter('i+1_32', from: 'int32', to: 'int64'),
] else ...[
'i+1' << match.BinaryInt64Op('i', 'c_one', op_kind: '+'),
],
match.Goto('B5'),
]),
'B4' <<
match.block('Target', [
match.DartReturn('c_null'),
]),
]);
}
17 changes: 15 additions & 2 deletions runtime/vm/compiler/backend/il.h
Original file line number Diff line number Diff line change
Expand Up @@ -4173,7 +4173,10 @@ class ReachabilityFenceInstr : public TemplateInstruction<1, NoThrow> {

class ConstraintInstr : public TemplateDefinition<1, NoThrow> {
public:
ConstraintInstr(Value* value, Range* constraint) : constraint_(constraint) {
ConstraintInstr(Value* value,
Range* constraint,
Representation representation)
: constraint_(constraint), representation_(representation) {
SetInputAt(0, value);
}

Expand All @@ -4193,6 +4196,11 @@ class ConstraintInstr : public TemplateDefinition<1, NoThrow> {
Value* value() const { return inputs_[0]; }
Range* constraint() const { return constraint_; }

virtual Representation RequiredInputRepresentation(intptr_t idx) const {
return representation_;
}
virtual Representation representation() const { return representation_; }

virtual void InferRange(RangeAnalysis* analysis, Range* range);

// Constraints for branches have their target block stored in order
Expand All @@ -4203,7 +4211,9 @@ class ConstraintInstr : public TemplateDefinition<1, NoThrow> {

PRINT_OPERANDS_TO_SUPPORT

#define FIELD_LIST(F) F(Range*, constraint_)
#define FIELD_LIST(F) \
F(Range*, constraint_) \
F(const Representation, representation_)

DECLARE_INSTRUCTION_SERIALIZABLE_FIELDS(ConstraintInstr,
TemplateDefinition,
Expand Down Expand Up @@ -5352,6 +5362,7 @@ class RelationalOpInstr : public TemplateComparison<2, NoThrow, Pure> {
: TemplateComparison(source, kind, deopt_id),
speculative_mode_(speculative_mode) {
ASSERT(Token::IsRelationalOperator(kind));
ASSERT((cid == kSmiCid) || (cid == kMintCid) || (cid == kDoubleCid));
SetInputAt(0, left);
SetInputAt(1, right);
set_operation_cid(cid);
Expand Down Expand Up @@ -10765,6 +10776,8 @@ class CheckBoundBaseInstr : public TemplateDefinition<2, NoThrow, Pure> {

virtual Definition* Canonicalize(FlowGraph* flow_graph);

virtual void InferRange(RangeAnalysis* analysis, Range* range);

DECLARE_ABSTRACT_INSTRUCTION(CheckBoundBase);

virtual Value* RedefinedValue() const;
Expand Down
Loading

0 comments on commit 1881c66

Please sign in to comment.