Skip to content

Commit

Permalink
Version 3.8.0-87.0.dev
Browse files Browse the repository at this point in the history
Merge 4dd1522 into dev
  • Loading branch information
Dart CI committed Feb 11, 2025
2 parents 42304d2 + 4dd1522 commit 92f696f
Show file tree
Hide file tree
Showing 22 changed files with 199 additions and 84 deletions.
2 changes: 2 additions & 0 deletions pkg/analysis_server_plugin/lib/registry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import 'package:analyzer/error/error.dart';
import 'package:analyzer/src/lint/linter.dart';

abstract class PluginRegistry {
/// Register this fix [generator] for the given lint [code] with the
/// analyzer's rule registry.
void registerFixForRule(LintCode code, ProducerGenerator generator);

/// Register this [rule] with the analyzer's rule registry.
Expand Down
142 changes: 142 additions & 0 deletions pkg/dev_compiler/test/hot_reload_delta_flags_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
// Copyright (c) 2025, 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.

import 'dart:io';

import 'package:path/path.dart' as p;
import 'package:test/test.dart';

const String program1 = '''
class A {
final int i;
const A(this.i);
}
void main() {
final a = A(1);
}
''';

const String program2Valid = '''
class A {
final int i;
const A(this.i);
}
void main() {
final a = A(2);
}
''';

const String program2Error = '''
class A {
const A();
}
void main() {
final a = A();
}
''';

String _resolvePath(String executableRelativePath) {
return Uri.file(Platform.resolvedExecutable)
.resolve(executableRelativePath)
.toFilePath();
}

Future<void> main() async {
group('hot reload flags', () {
late Directory tmp;
late File outputJs;
late File deltaDill;
late File lastAcceptedDill;
setUp(() {
File file(String path) => File.fromUri(tmp.uri.resolve(path));

tmp = Directory.systemTemp.createTempSync('hot_reload_flags_test');
outputJs = file('output.js');
deltaDill = file('delta.dill');
lastAcceptedDill = file('lastAccepted.dill');
});

tearDown(() {
tmp.deleteSync(recursive: true);
});

void runDDC(List<String> flags, String programSource,
{String? expectError}) async {
final sdkPath = p.dirname(Platform.executable);
final dartAotRuntime = p.absolute(sdkPath,
Platform.isWindows ? 'dartaotruntime.exe' : 'dartaotruntime');
final snapshotName = _resolvePath('snapshots/dartdevc_aot.dart.snapshot');
final outlinePath = _resolvePath('../lib/_internal/ddc_outline.dill');

final sourceFile = File.fromUri(tmp.uri.resolve('main.dart'));
sourceFile.writeAsStringSync(programSource);

final args = <String>[
snapshotName,
'--dart-sdk-summary',
outlinePath,
'-o',
outputJs.path,
...flags,
sourceFile.path,
];

final process = Process.runSync(dartAotRuntime, args);
if (expectError != null) {
expect(process.exitCode, isNonNegative);
expect(process.stderr, contains(expectError));
} else {
if (process.exitCode != 0) {
print(process.stdout);
print(process.stderr);
}
expect(process.exitCode, 0);
}
}

test('providing no flag skips inspector', () {
runDDC(const [], program1);
expect(outputJs.existsSync(), isTrue);
expect(outputJs.statSync().size, isNonNegative);
});

test('providing only delta output flag does not error', () {
runDDC(['--reload-delta-kernel=${deltaDill.path}'], program1);
expect(deltaDill.existsSync(), isTrue);
expect(deltaDill.statSync().size, isNonNegative);
expect(outputJs.existsSync(), isTrue);
expect(outputJs.statSync().size, isNonNegative);
});

test('providing delta output and last accepted input flag valid change',
() {
runDDC(['--reload-delta-kernel=${lastAcceptedDill.path}'], program1);
expect(lastAcceptedDill.existsSync(), isTrue);
expect(lastAcceptedDill.statSync().size, isNonNegative);

runDDC([
'--reload-last-accepted-kernel=${lastAcceptedDill.path}',
'--reload-delta-kernel=${deltaDill.path}'
], program2Valid);
expect(lastAcceptedDill.existsSync(), isTrue);
expect(lastAcceptedDill.statSync().size, isNonNegative);
expect(deltaDill.existsSync(), isTrue);
expect(deltaDill.statSync().size, isNonNegative);
expect(outputJs.existsSync(), isTrue);
expect(outputJs.statSync().size, isNonNegative);
});

test('providing delta output and last accepted input flag invalid change',
() {
runDDC(['--reload-delta-kernel=${lastAcceptedDill.path}'], program1);
runDDC([
'--reload-last-accepted-kernel=${lastAcceptedDill.path}',
'--reload-delta-kernel=${deltaDill.path}'
], program2Error, expectError: 'Const class cannot remove fields');
expect(lastAcceptedDill.existsSync(), isTrue);
expect(lastAcceptedDill.statSync().size, isNonNegative);
expect(deltaDill.existsSync(), isFalse);
});
});
}
2 changes: 1 addition & 1 deletion pkg/dev_compiler/test/hot_reload_suite.dart
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ abstract class HotReloadSuiteRunner {
return false;
}
final rejectionMessage = reloadReceipt.rejectionMessage;
if (rejectionMessage != null &&
if (rejectionMessage == null ||
!rejectionMessage.contains(expectedError)) {
_print(
'Generation ${reloadReceipt.generation} was rejected but error '
Expand Down
3 changes: 2 additions & 1 deletion pkg/reload_test/lib/src/_vm_reload_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ extension on ReloadReport {
final notices = this.json?['notices'] as List?;
if (notices != null) {
for (final notice in notices) {
if (notice['type'] == 'ReasonForCancelling') {
if (notice['type'] == 'ReasonForCancelling' ||
notice['type'] == 'ReasonForCancellingReload') {
return notice['message'] as String?;
}
}
Expand Down
6 changes: 5 additions & 1 deletion runtime/vm/compiler/assembler/assembler_arm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -2342,7 +2342,11 @@ class Assembler : public AssemblerBase {
EmitAddSubShiftExtOp(subtract ? SUB : ADD, crd, crn, o, os, set_flags);
} else {
ASSERT(o.type() == Operand::Extended);
ASSERT((rd != ZR) && (rn != ZR));
if (set_flags) {
ASSERT((rd != CSP) && (rn != ZR));
} else {
ASSERT((rd != ZR) && (rn != ZR));
}
EmitAddSubShiftExtOp(subtract ? SUB : ADD, crd, crn, o, os, set_flags);
}
}
Expand Down
25 changes: 25 additions & 0 deletions runtime/vm/compiler/assembler/assembler_arm64_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,31 @@ ASSEMBLER_TEST_RUN(AddExtReg, test) {
"ret\n");
}

ASSEMBLER_TEST_GENERATE(CmpExtReg, assembler) {
Label not_equal;
__ LoadImmediate(R0, 0x100000000);
__ cmp(R0, Operand(R0, SXTW, 0));
__ BranchIf(NOT_EQUAL, &not_equal);
__ LoadImmediate(R0, 1);
__ ret();
__ Bind(&not_equal);
__ LoadImmediate(R0, 2);
__ ret();
}

ASSEMBLER_TEST_RUN(CmpExtReg, test) {
typedef int64_t (*Int64Return)() DART_UNUSED;
EXPECT_EQ(2, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry()));
EXPECT_DISASSEMBLY(
"mov r0, 0x100000000\n"
"cmp r0, r0 sxtw\n"
"bne +12\n"
"movz r0, #0x1\n"
"ret\n"
"movz r0, #0x2\n"
"ret\n");
}

ASSEMBLER_TEST_GENERATE(AddCarryInOut, assembler) {
__ LoadImmediate(R2, -1);
__ LoadImmediate(R1, 1);
Expand Down
10 changes: 5 additions & 5 deletions runtime/vm/isolate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,11 @@ IsolateGroup::IsolateGroup(std::shared_ptr<IsolateGroupSource> source,
}

IsolateGroup::~IsolateGroup() {
#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
RELEASE_ASSERT(group_reload_context_ == nullptr);
RELEASE_ASSERT(program_reload_context_ == nullptr);
#endif // !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)

// Ensure we destroy the heap before the other members.
heap_ = nullptr;
ASSERT(old_marking_stack_ == nullptr);
Expand Down Expand Up @@ -1829,11 +1834,6 @@ Isolate::Isolate(IsolateGroup* isolate_group,
#undef REUSABLE_HANDLE_INITIALIZERS

Isolate::~Isolate() {
#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
// TODO(32796): Re-enable assertion.
// RELEASE_ASSERT(program_reload_context_ == nullptr);
#endif // !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)

#if !defined(PRODUCT)
delete debugger_;
debugger_ = nullptr;
Expand Down
12 changes: 10 additions & 2 deletions runtime/vm/object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23610,10 +23610,18 @@ void TypeParameter::PrintName(NameVisibility name_visibility,

uword TypeParameter::ComputeHash() const {
ASSERT(IsFinalized());
uint32_t result = parameterized_class_id();
result = CombineHashes(result, base());
uint32_t result = base();
result = CombineHashes(result, index());
result = CombineHashes(result, static_cast<uint32_t>(nullability()));
if (IsFunctionTypeParameter()) {
const FunctionType& func =
FunctionType::Handle(parameterized_function_type());
result = CombineHashes(result, func.packed_parameter_counts());
result = CombineHashes(result, func.packed_type_parameter_counts());
} else {
ASSERT(IsClassTypeParameter());
result = CombineHashes(result, parameterized_class_id());
}
result = FinalizeHash(result, kHashBits);
SetHash(result);
return result;
Expand Down
3 changes: 1 addition & 2 deletions tests/hot_reload/change_instance_format6/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"expectedErrors": {
"1": "type parameters have changed"
"1": "Limitation: changing type parameters does not work with hot reload."
}
}

1 change: 0 additions & 1 deletion tests/hot_reload/change_instance_format6/main.0.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// 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.

import 'package:expect/expect.dart';
import 'package:reload_test/reload_test_utils.dart';

// Adapted from:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// 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.

import 'package:expect/expect.dart';
import 'package:reload_test/reload_test_utils.dart';

// Adapted from:
Expand Down
23 changes: 0 additions & 23 deletions tests/hot_reload/change_instance_format7/main.0.dart

This file was deleted.

36 changes: 0 additions & 36 deletions tests/hot_reload/change_instance_format7/main.1.dart

This file was deleted.

6 changes: 4 additions & 2 deletions tests/hot_reload/change_instance_format7_ddc/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"exclude": ["vm"],
"exclude": [
"vm"
],
"expectedErrors": {
"1": "type parameters have changed"
"1": "Limitation: changing type parameters does not work with hot reload."
}
}
1 change: 0 additions & 1 deletion tests/hot_reload/change_instance_format7_ddc/main.0.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// 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.

import 'package:expect/expect.dart';
import 'package:reload_test/reload_test_utils.dart';

// Adapted from:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// 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.

import 'package:expect/expect.dart';
import 'package:reload_test/reload_test_utils.dart';

// Adapted from:
Expand Down
1 change: 0 additions & 1 deletion tests/hot_reload/change_instance_format7_vm/main.0.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// 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.

import 'package:expect/expect.dart';
import 'package:reload_test/reload_test_utils.dart';

// Adapted from:
Expand Down
1 change: 0 additions & 1 deletion tests/hot_reload/change_instance_format7_vm/main.1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// 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.

import 'package:expect/expect.dart';
import 'package:reload_test/reload_test_utils.dart';

// Adapted from:
Expand Down
3 changes: 1 addition & 2 deletions tests/hot_reload/change_instance_format9/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"expectedErrors": {
"1": "type parameters have changed"
"1": "Limitation: changing type parameters does not work with hot reload."
}
}

Loading

0 comments on commit 92f696f

Please sign in to comment.