Version 2.13.0-204.0.dev
Merge commit 'a6ffc74a4a6b75e20968b42ad2d19fc07a5b1e82' into 'dev'
diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json
index f0139e4..1f1e5dc 100644
--- a/.dart_tool/package_config.json
+++ b/.dart_tool/package_config.json
@@ -11,7 +11,7 @@
"constraint, update this by running tools/generate_package_config.dart."
],
"configVersion": 2,
- "generated": "2021-03-29T21:48:35.411283",
+ "generated": "2021-04-05T08:58:24.237896",
"generator": "tools/generate_package_config.dart",
"packages": [
{
@@ -443,12 +443,6 @@
"languageVersion": "2.2"
},
{
- "name": "mustache",
- "rootUri": "../third_party/pkg/mustache",
- "packageUri": "lib/",
- "languageVersion": "2.0"
- },
- {
"name": "native_stack_traces",
"rootUri": "../pkg/native_stack_traces",
"packageUri": "lib/",
diff --git a/DEPS b/DEPS
index 8c93fae..f2572e7 100644
--- a/DEPS
+++ b/DEPS
@@ -102,7 +102,7 @@
"chromedriver_tag": "83.0.4103.39",
"browser_launcher_rev": "12ab9f351a44ac803de9bc17bb2180bb312a9dd7",
- "dartdoc_rev" : "e2d010ed74059be942a78ced5f35f1b8d667ed16",
+ "dartdoc_rev" : "505f163f7cb48e917503e4a23fbff1227e08b263",
"ffi_rev": "f3346299c55669cc0db48afae85b8110088bf8da",
"fixnum_rev": "16d3890c6dc82ca629659da1934e412292508bba",
"file_rev": "0e09370f581ab6388d46fda4cdab66638c0171a1",
@@ -126,7 +126,6 @@
"matcher_rev": "1f7b6f0cb15eb6659a1de0513571575a5c8a51d0",
"mime_rev": "c931f4bed87221beaece356494b43731445ce7b8",
"mockito_rev": "d39ac507483b9891165e422ec98d9fb480037c8b",
- "mustache_rev": "664737ecad027e6b96d0d1e627257efa0e46fcb1",
"oauth2_rev": "7cd3284049fe5badbec9f2bea2afc41d14c01057",
"package_config_rev": "a84c0d45401f215fbe9384df923a38f4022a3c45",
"path_rev": "407ab76187fade41c31e39c745b39661b710106c",
@@ -379,10 +378,6 @@
Var("dart_git") + "mime.git" + "@" + Var("mime_rev"),
Var("dart_root") + "/third_party/pkg/mockito":
Var("dart_git") + "mockito.git" + "@" + Var("mockito_rev"),
- Var("dart_root") + "/third_party/pkg/mustache":
- Var("dart_git")
- + "external/github.com/xxgreg/mustache"
- + "@" + Var("mustache_rev"),
Var("dart_root") + "/third_party/pkg/oauth2":
Var("dart_git") + "oauth2.git" + "@" + Var("oauth2_rev"),
Var("dart_root") + "/third_party/pkg_tested/package_config":
diff --git a/pkg/analysis_server/lib/plugin/edit/fix/fix_dart.dart b/pkg/analysis_server/lib/plugin/edit/fix/fix_dart.dart
index 50658b4..4792bed 100644
--- a/pkg/analysis_server/lib/plugin/edit/fix/fix_dart.dart
+++ b/pkg/analysis_server/lib/plugin/edit/fix/fix_dart.dart
@@ -2,8 +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.
-// @dart = 2.9
-
import 'package:analysis_server/plugin/edit/fix/fix_core.dart';
import 'package:analysis_server/src/services/correction/fix/dart/top_level_declarations.dart';
import 'package:analyzer/dart/analysis/results.dart';
diff --git a/pkg/analysis_server/lib/src/lsp/client_configuration.dart b/pkg/analysis_server/lib/src/lsp/client_configuration.dart
index fb2fa13..26ad2d0 100644
--- a/pkg/analysis_server/lib/src/lsp/client_configuration.dart
+++ b/pkg/analysis_server/lib/src/lsp/client_configuration.dart
@@ -2,8 +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.
-// @dart = 2.9
-
/// Wraps the client (editor) configuration to provide stronger typing and
/// handling of default values where a setting has not been supplied.
class LspClientConfiguration {
diff --git a/pkg/analysis_server/lib/src/lsp/dartdoc.dart b/pkg/analysis_server/lib/src/lsp/dartdoc.dart
index cc8f07f..fb84180 100644
--- a/pkg/analysis_server/lib/src/lsp/dartdoc.dart
+++ b/pkg/analysis_server/lib/src/lsp/dartdoc.dart
@@ -2,13 +2,11 @@
// 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.
-// @dart = 2.9
-
final _dartdocCodeBlockSections = RegExp(r'(```\w+) +\w+');
final _dartdocDirectives =
RegExp(r'(\n *{@.*?}$)|(^{@.*?}\n)', multiLine: true);
-String cleanDartdoc(String doc) {
+String? cleanDartdoc(String? doc) {
if (doc == null) {
return null;
}
@@ -19,7 +17,7 @@
// docs contain.
doc = doc.replaceAllMapped(
_dartdocCodeBlockSections,
- (match) => match.group(1),
+ (match) => match.group(1)!,
);
return doc;
diff --git a/pkg/analysis_server/lib/src/lsp/json_parsing.dart b/pkg/analysis_server/lib/src/lsp/json_parsing.dart
index 412c96c..f396dde 100644
--- a/pkg/analysis_server/lib/src/lsp/json_parsing.dart
+++ b/pkg/analysis_server/lib/src/lsp/json_parsing.dart
@@ -2,8 +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.
-// @dart = 2.9
-
import 'dart:collection';
final nullLspJsonReporter = _NullLspJsonReporter();
@@ -18,13 +16,13 @@
/// being validated.
final ListQueue<String> path = ListQueue<String>();
- LspJsonReporter([String initialField]) {
+ LspJsonReporter([String? initialField]) {
if (initialField != null) {
path.add(initialField);
}
}
- /// Pops the last field off the stack to become the current gield.
+ /// Pops the last field off the stack to become the current field.
void pop() => path.removeLast();
/// Pushes the current field onto a stack to allow reporting errors in child
diff --git a/pkg/analysis_server/lib/src/server/crash_reporting_attachments.dart b/pkg/analysis_server/lib/src/server/crash_reporting_attachments.dart
index 790ccab..0648968 100644
--- a/pkg/analysis_server/lib/src/server/crash_reporting_attachments.dart
+++ b/pkg/analysis_server/lib/src/server/crash_reporting_attachments.dart
@@ -2,8 +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.
-// @dart = 2.9
-
import 'package:analyzer/instrumentation/service.dart';
import 'package:analyzer/src/dart/analysis/driver.dart' show ExceptionResult;
diff --git a/pkg/analysis_server/lib/src/server/diagnostic_server.dart b/pkg/analysis_server/lib/src/server/diagnostic_server.dart
index 7d5586a..4a0a27a0 100644
--- a/pkg/analysis_server/lib/src/server/diagnostic_server.dart
+++ b/pkg/analysis_server/lib/src/server/diagnostic_server.dart
@@ -2,8 +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.
-// @dart = 2.9
-
/// A handle to start, and return the current port of, a diagnostic server.
abstract class DiagnosticServer {
/// Return the port of the diagnostic web server. If the server is not running
diff --git a/pkg/analysis_server/lib/src/server/features.dart b/pkg/analysis_server/lib/src/server/features.dart
index 65668bd..fd02aa1 100644
--- a/pkg/analysis_server/lib/src/server/features.dart
+++ b/pkg/analysis_server/lib/src/server/features.dart
@@ -2,8 +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.
-// @dart = 2.9
-
/// The set of features enabled in a server session.
///
/// When some features are not enabled, the server might avoid doing work
diff --git a/pkg/analysis_server/lib/src/server/sdk_configuration.dart b/pkg/analysis_server/lib/src/server/sdk_configuration.dart
index b2ac8bf..c296772 100644
--- a/pkg/analysis_server/lib/src/server/sdk_configuration.dart
+++ b/pkg/analysis_server/lib/src/server/sdk_configuration.dart
@@ -2,8 +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.
-// @dart = 2.9
-
import 'dart:convert';
import 'dart:io';
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/relevance_tables.g.dart b/pkg/analysis_server/lib/src/services/completion/dart/relevance_tables.g.dart
index 22f1ab7..d3b69d7 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/relevance_tables.g.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/relevance_tables.g.dart
@@ -2,8 +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.
-// @dart = 2.9
-//
// This file has been automatically generated. Please do not edit it manually.
// To regenerate the file, use the script
// "pkg/analysis_server/tool/completion_metrics/relevance_table_generator.dart",
diff --git a/pkg/analysis_server/lib/src/services/completion/filtering/fuzzy_matcher.dart b/pkg/analysis_server/lib/src/services/completion/filtering/fuzzy_matcher.dart
index 765c39a..3b3b71d 100644
--- a/pkg/analysis_server/lib/src/services/completion/filtering/fuzzy_matcher.dart
+++ b/pkg/analysis_server/lib/src/services/completion/filtering/fuzzy_matcher.dart
@@ -2,8 +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.
-// @dart = 2.9
-
import 'dart:math' as math;
/// Character role in a candidate string.
@@ -85,10 +83,12 @@
MatchStyle matchStyle;
/// The lowercase version of the pattern.
- String patternLower;
+ // Initialized in the constructor.
+ String patternLower = '';
/// The first three characters of the lowercase version of the pattern.
- String patternShort;
+ // Initialized in the constructor.
+ String patternShort = '';
/// The length of the last matched candidate.
int lastCandidateLen = 0;
@@ -109,24 +109,27 @@
///
/// The zero bit of the score value keeps track of where we came from (1 if
/// the previous character matched, and 0 otherwise).
- List<List<int>> table;
+ List<List<int>> table = [];
/// The offset of the "previous symbol matched" table on the pattern axis.
- int matchesLayerOffset;
+ // Initialized in the constructor.
+ int matchesLayerOffset = 0;
/// Pre-allocated memory for storing the role of each character in the
/// candidate string.
List<CharRole> candidateRoles = List.filled(maxInputSize, CharRole.NONE);
/// The role of each character in the pattern.
- List<CharRole> patternRoles;
+ List<CharRole> patternRoles = [];
/// A flag indicating whether scoring should be case-sensitive. Mix-case
/// patterns turn on case-sensitive scoring.
- bool caseSensitive;
+ // Initialized in the constructor.
+ bool caseSensitive = false;
/// Normalizes scores for the pattern length.
- double scoreScale;
+ // Initialized in the constructor.
+ double scoreScale = 0.0;
/// Initialize a newly created matcher to match the [pattern] using the given
/// [matchStyle].
@@ -143,7 +146,6 @@
}
matchesLayerOffset = pattern.length + 1;
- table = [];
for (var i = 0; i <= maxInputSize; i++) {
table.add(List.filled(2 * matchesLayerOffset, 0));
}
diff --git a/pkg/analysis_server/test/integration/analysis/navigation_test.dart b/pkg/analysis_server/test/integration/analysis/navigation_test.dart
index 7d217d2..23f6e7c 100644
--- a/pkg/analysis_server/test/integration/analysis/navigation_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/navigation_test.dart
@@ -116,7 +116,7 @@
checkLocal('function(() => localVariable.field)',
'function(FunctionTypeAlias parameter)', ElementKind.FUNCTION);
checkLocal('FunctionTypeAlias parameter', 'FunctionTypeAlias();',
- ElementKind.FUNCTION_TYPE_ALIAS);
+ ElementKind.TYPE_ALIAS);
checkLocal('field)', 'field = (', ElementKind.GETTER);
checkRemote("'dart:async'", r'async\.dart$', ElementKind.LIBRARY);
checkLocal(
diff --git a/pkg/analysis_server/test/integration/coverage_test.dart b/pkg/analysis_server/test/integration/coverage_test.dart
index db49f18..73caa7a 100644
--- a/pkg/analysis_server/test/integration/coverage_test.dart
+++ b/pkg/analysis_server/test/integration/coverage_test.dart
@@ -2,8 +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.
-// @dart = 2.9
-
import 'dart:io';
import 'package:analyzer_plugin/src/utilities/string_utilities.dart';
diff --git a/pkg/analysis_server/test/integration/execution/delete_context_test.dart b/pkg/analysis_server/test/integration/execution/delete_context_test.dart
index 4087c06..121ba2e 100644
--- a/pkg/analysis_server/test/integration/execution/delete_context_test.dart
+++ b/pkg/analysis_server/test/integration/execution/delete_context_test.dart
@@ -18,13 +18,12 @@
Future<void> test_delete() async {
var pathname = sourcePath('lib/main.dart');
writeFile(pathname, '// dummy');
- writeFile(sourcePath('.packages'), 'foo:lib/');
standardAnalysisSetup();
var contextId = (await sendExecutionCreateContext(sourceDirectory.path)).id;
var result =
- await sendExecutionMapUri(contextId, uri: 'package:foo/main.dart');
+ await sendExecutionMapUri(contextId, uri: 'package:test/main.dart');
expect(result.file, pathname);
expect(await sendExecutionDeleteContext(contextId), isNull);
@@ -32,7 +31,7 @@
// After the delete, expect this to fail.
try {
result =
- await sendExecutionMapUri(contextId, uri: 'package:foo/main.dart');
+ await sendExecutionMapUri(contextId, uri: 'package:test/main.dart');
fail('expected exception after context delete');
} on ServerErrorMessage catch (message) {
expect(message.error['code'], 'INVALID_PARAMETER');
diff --git a/pkg/analysis_server/test/integration/execution/map_uri_test.dart b/pkg/analysis_server/test/integration/execution/map_uri_test.dart
index a5a200b..e98032f 100644
--- a/pkg/analysis_server/test/integration/execution/map_uri_test.dart
+++ b/pkg/analysis_server/test/integration/execution/map_uri_test.dart
@@ -18,20 +18,19 @@
Future<void> test_mapUri() async {
var pathname = sourcePath('lib/main.dart');
writeFile(pathname, '// dummy');
- writeFile(sourcePath('.packages'), 'foo:lib/');
standardAnalysisSetup();
var contextId = (await sendExecutionCreateContext(sourceDirectory.path)).id;
{
var result =
- await sendExecutionMapUri(contextId, uri: 'package:foo/main.dart');
+ await sendExecutionMapUri(contextId, uri: 'package:test/main.dart');
expect(result.file, pathname);
}
{
var result = await sendExecutionMapUri(contextId, file: pathname);
- expect(result.uri, 'package:foo/main.dart');
+ expect(result.uri, 'package:test/main.dart');
}
}
}
diff --git a/pkg/analysis_server/test/integration/kythe/get_kythe_entries_test.dart b/pkg/analysis_server/test/integration/kythe/get_kythe_entries_test.dart
index a4a3a5f..00719b3 100644
--- a/pkg/analysis_server/test/integration/kythe/get_kythe_entries_test.dart
+++ b/pkg/analysis_server/test/integration/kythe/get_kythe_entries_test.dart
@@ -2,8 +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.
-// @dart = 2.9
-
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
diff --git a/pkg/analysis_server/test/integration/kythe/test_all.dart b/pkg/analysis_server/test/integration/kythe/test_all.dart
index f63a340..c50b940 100644
--- a/pkg/analysis_server/test/integration/kythe/test_all.dart
+++ b/pkg/analysis_server/test/integration/kythe/test_all.dart
@@ -2,8 +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.
-// @dart = 2.9
-
import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'get_kythe_entries_test.dart' as get_kythe_entries_test;
diff --git a/pkg/analysis_server/test/integration/support/integration_tests.dart b/pkg/analysis_server/test/integration/support/integration_tests.dart
index b135280..5b1c58d 100644
--- a/pkg/analysis_server/test/integration/support/integration_tests.dart
+++ b/pkg/analysis_server/test/integration/support/integration_tests.dart
@@ -9,8 +9,10 @@
import 'package:analysis_server/protocol/protocol_constants.dart';
import 'package:analysis_server/protocol/protocol_generated.dart';
+import 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart';
import 'package:path/path.dart';
+import 'package:path/path.dart' as pkg_path;
import 'package:test/test.dart';
import 'integration_test_methods.dart';
@@ -167,6 +169,7 @@
sourceDirectory = Directory(Directory.systemTemp
.createTempSync('analysisServer')
.resolveSymbolicLinksSync());
+ writeTestPackageConfig();
onAnalysisErrors.listen((AnalysisErrorsParams params) {
currentAnalysisErrors[params.file] = params.errors;
@@ -256,6 +259,40 @@
file.writeAsStringSync(contents);
return file.resolveSymbolicLinksSync();
}
+
+ void writePackageConfig(
+ String path, {
+ required PackageConfigFileBuilder config,
+ }) {
+ writeFile(
+ path,
+ config.toContent(
+ toUriStr: (path) => '${pkg_path.toUri(path)}',
+ ),
+ );
+ }
+
+ void writeTestPackageConfig({
+ PackageConfigFileBuilder? config,
+ String? languageVersion,
+ }) {
+ if (config == null) {
+ config = PackageConfigFileBuilder();
+ } else {
+ config = config.copy();
+ }
+
+ config.add(
+ name: 'test',
+ rootPath: sourceDirectory.path,
+ languageVersion: languageVersion,
+ );
+
+ writePackageConfig(
+ sourcePath('.dart_tool/package_config.json'),
+ config: config,
+ );
+ }
}
/// Wrapper class for Matcher which doesn't create the underlying Matcher object
diff --git a/pkg/analysis_server/test/tool/lsp_spec/markdown_test.dart b/pkg/analysis_server/test/tool/lsp_spec/markdown_test.dart
index 6589b50..bf968e7 100644
--- a/pkg/analysis_server/test/tool/lsp_spec/markdown_test.dart
+++ b/pkg/analysis_server/test/tool/lsp_spec/markdown_test.dart
@@ -2,8 +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.
-// @dart = 2.9
-
import 'package:test/test.dart';
import '../../../tool/lsp_spec/markdown.dart';
diff --git a/pkg/analysis_server/tool/code_completion/relevance_table_generator.dart b/pkg/analysis_server/tool/code_completion/relevance_table_generator.dart
index 856594d..004c776 100644
--- a/pkg/analysis_server/tool/code_completion/relevance_table_generator.dart
+++ b/pkg/analysis_server/tool/code_completion/relevance_table_generator.dart
@@ -1595,8 +1595,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.
-// @dart = 2.9
-//
// This file has been automatically generated. Please do not edit it manually.
// To regenerate the file, use the script
// "pkg/analysis_server/tool/completion_metrics/relevance_table_generator.dart",
diff --git a/pkg/analysis_server/tool/lsp_spec/markdown.dart b/pkg/analysis_server/tool/lsp_spec/markdown.dart
index 70582e0..cf56d33 100644
--- a/pkg/analysis_server/tool/lsp_spec/markdown.dart
+++ b/pkg/analysis_server/tool/lsp_spec/markdown.dart
@@ -2,8 +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.
-// @dart = 2.9
-
final _methodNamesPattern = RegExp(
r'''_(?:Notification|Request):?_:?(?:\r?\n)+\* method: ['`](.*?)[`'],?\r?\n''',
multiLine: true);
@@ -13,7 +11,7 @@
List<String> extractMethodNames(String spec) {
return _methodNamesPattern
.allMatches(spec)
- .map((m) => m.group(1).trim())
+ .map((m) => m.group(1)!.trim())
.toList();
}
@@ -22,6 +20,6 @@
List<String> extractTypeScriptBlocks(String text) {
return _typeScriptBlockPattern
.allMatches(text)
- .map((m) => m.group(1).trim())
+ .map((m) => m.group(1)!.trim())
.toList();
}
diff --git a/pkg/analysis_server_client/test/all.dart b/pkg/analysis_server_client/test/all.dart
index d510ab2..bd97ea7 100644
--- a/pkg/analysis_server_client/test/all.dart
+++ b/pkg/analysis_server_client/test/all.dart
@@ -2,8 +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.
-// @dart = 2.9
-
import 'live_test.dart' as live;
import 'server_test.dart' as server;
import 'verify_sorted_test.dart' as verify_sorted;
diff --git a/pkg/analysis_server_client/test/verify_sorted_test.dart b/pkg/analysis_server_client/test/verify_sorted_test.dart
index 6841a86..5a19d51 100644
--- a/pkg/analysis_server_client/test/verify_sorted_test.dart
+++ b/pkg/analysis_server_client/test/verify_sorted_test.dart
@@ -2,8 +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.
-// @dart = 2.9
-
import 'package:analysis_server/src/services/correction/sort_members.dart';
import 'package:analyzer/dart/analysis/analysis_context_collection.dart';
import 'package:analyzer/dart/analysis/results.dart';
diff --git a/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_shared.dart b/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_shared.dart
new file mode 100644
index 0000000..9ae2415
--- /dev/null
+++ b/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_shared.dart
@@ -0,0 +1,966 @@
+// Copyright (c) 2021, 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.
+
+// @dart = 2.9
+
+library dev_compiler.test.expression_compiler;
+
+import 'package:test/test.dart';
+import 'expression_compiler_e2e_suite.dart';
+
+const simpleClassSource = '''
+extension NumberParsing on String {
+ int parseInt() {
+ return int.parse(this) + 1;
+ }
+}
+
+class C {
+ static int staticField = 1;
+ static int _staticField = 2;
+ static int _unusedStaticField = 3;
+ int field;
+ int _field;
+ int _unusedField = 4;
+
+ C(this.field, this._field) {
+ int y = 1;
+ // Breakpoint: constructorBP
+ var nop;
+ }
+
+ int methodFieldAccess(int x) {
+ // Breakpoint: methodBP
+ var inScope = 1;
+ {
+ var innerInScope = global + staticField + field;
+ // Breakpoint: innerScopeBP
+ var innerNotInScope = 2;
+ }
+ var notInScope = 3;
+ return x + _field + _staticField;
+ }
+
+ Future<int> asyncMethod(int x) async {
+ return x + _field + _staticField;
+ }
+}
+
+int global = 42;
+
+main() {
+ int x = 15;
+ var c = C(5, 6);
+ // Breakpoint: globalFunctionBP
+ c.methodFieldAccess(10);
+}
+''';
+
+void runSharedTests(SetupCompilerOptions setup, TestDriver driver) {
+ group('Expression compiler scope collection tests', () {
+ var source = simpleClassSource;
+
+ setUpAll(() async {
+ await driver.initSource(setup, source);
+ });
+
+ tearDownAll(() async {
+ await driver.cleanupTest();
+ });
+
+ test('local in scope', () async {
+ await driver.check(
+ breakpointId: 'innerScopeBP',
+ expression: 'inScope',
+ expectedResult: '1');
+ });
+
+ test('local in inner scope', () async {
+ await driver.check(
+ breakpointId: 'innerScopeBP',
+ expression: 'innerInScope',
+ expectedResult: '48');
+ });
+
+ test('global in scope', () async {
+ await driver.check(
+ breakpointId: 'innerScopeBP',
+ expression: 'global',
+ expectedResult: '42');
+ });
+
+ test('static field in scope', () async {
+ await driver.check(
+ breakpointId: 'innerScopeBP',
+ expression: 'staticField',
+ expectedResult: '1');
+ });
+
+ test('field in scope', () async {
+ await driver.check(
+ breakpointId: 'innerScopeBP',
+ expression: 'field',
+ expectedResult: '5');
+ });
+
+ test('parameter in scope', () async {
+ await driver.check(
+ breakpointId: 'innerScopeBP', expression: 'x', expectedResult: '10');
+ });
+
+ test('local not in scope', () async {
+ await driver.check(
+ breakpointId: 'innerScopeBP',
+ expression: 'notInScope',
+ expectedError: "Error: The getter 'notInScope' isn't defined for the"
+ " class 'C'.");
+ });
+
+ test('local not in inner scope', () async {
+ await driver.check(
+ breakpointId: 'innerScopeBP',
+ expression: 'innerNotInScope',
+ expectedError:
+ "Error: The getter 'innerNotInScope' isn't defined for the"
+ " class 'C'.");
+ });
+ });
+
+ group('Expression compiler extension symbols tests', () {
+ var source = '''
+ main() {
+ List<int> list = [];
+ list.add(0);
+ // Breakpoint: bp
+ }
+ ''';
+
+ setUpAll(() async {
+ await driver.initSource(setup, source);
+ });
+
+ tearDownAll(() async {
+ await driver.cleanupTest();
+ });
+
+ test('extension symbol used only in expression compilation', () async {
+ await driver.check(
+ breakpointId: 'bp', expression: 'list.first', expectedResult: '0');
+ });
+
+ test('extension symbol used in original compilation', () async {
+ await driver.check(
+ breakpointId: 'bp',
+ expression: '() { list.add(1); return list.last; }()',
+ expectedResult: '1');
+ });
+ });
+
+ group('Expression compiler tests in extension method:', () {
+ var source = '''
+ extension NumberParsing on String {
+ int parseInt() {
+ var ret = int.parse(this);
+ // Breakpoint: bp
+ return ret;
+ }
+ }
+ main() => "1234".parseInt();
+ ''';
+
+ setUpAll(() async {
+ await driver.initSource(setup, source);
+ });
+
+ tearDownAll(() {
+ driver.cleanupTest();
+ });
+
+ test('compilation error', () async {
+ await driver.check(
+ breakpointId: 'bp',
+ expression: 'typo',
+ expectedError: "Error: Getter not found: 'typo'");
+ });
+
+ test('local (trimmed scope)', () async {
+ await driver.check(
+ breakpointId: 'bp', expression: 'ret', expectedResult: '1234');
+ });
+
+ test('this (full scope)', () async {
+ // Note: this currently fails due to
+ // - incremental compiler not mapping 'this' from user input to '#this'
+ // - incremental compiler not allowing #this as a parameter name
+ await driver.check(
+ breakpointId: 'bp',
+ expression: 'this',
+ expectedError: "Error: Expected identifier, but got 'this'");
+ });
+ });
+
+ group('Expression compiler tests in static function:', () {
+ var source = '''
+ int foo(int x, {int y: 0}) {
+ int z = 3;
+ // Breakpoint: bp
+ return x + y + z;
+ }
+
+ main() => foo(1, y: 2);
+ ''';
+
+ setUpAll(() async {
+ await driver.initSource(setup, source);
+ });
+
+ tearDownAll(() {
+ driver.cleanupTest();
+ });
+
+ test('compilation error', () async {
+ await driver.check(
+ breakpointId: 'bp',
+ expression: 'typo',
+ expectedError: "Getter not found: \'typo\'");
+ });
+
+ test('local', () async {
+ await driver.check(
+ breakpointId: 'bp', expression: 'x', expectedResult: '1');
+ });
+
+ test('formal', () async {
+ await driver.check(
+ breakpointId: 'bp', expression: 'y', expectedResult: '2');
+ });
+
+ test('named formal', () async {
+ await driver.check(
+ breakpointId: 'bp', expression: 'z', expectedResult: '3');
+ });
+
+ test('function', () async {
+ await driver
+ .check(breakpointId: 'bp', expression: 'main', expectedResult: '''
+ function main() {
+ return test.foo(1, {y: 2});
+ }''');
+ });
+ });
+
+ group('Expression compiler tests in method:', () {
+ var source = simpleClassSource;
+
+ setUpAll(() async {
+ await driver.initSource(setup, source);
+ });
+
+ tearDownAll(() {
+ driver.cleanupTest();
+ });
+
+ test('compilation error', () async {
+ await driver.check(
+ breakpointId: 'methodBP',
+ expression: 'typo',
+ expectedError: "The getter 'typo' isn't defined for the class 'C'");
+ });
+
+ test('local', () async {
+ await driver.check(
+ breakpointId: 'methodBP', expression: 'x', expectedResult: '10');
+ });
+
+ test('this', () async {
+ await driver.check(
+ breakpointId: 'methodBP',
+ expression: 'this',
+ expectedResult:
+ 'test.C.new {Symbol(_unusedField): 4, Symbol(C.field): 5,'
+ ' Symbol(_field): 6}');
+ });
+
+ test('expression using locals', () async {
+ await driver.check(
+ breakpointId: 'methodBP', expression: 'x + 1', expectedResult: '11');
+ });
+
+ test('expression using static fields', () async {
+ await driver.check(
+ breakpointId: 'methodBP',
+ expression: 'x + staticField',
+ expectedResult: '11');
+ });
+
+ test('expression using private static fields', () async {
+ await driver.check(
+ breakpointId: 'methodBP',
+ expression: 'x + _staticField',
+ expectedResult: '12');
+ });
+
+ test('expression using fields', () async {
+ await driver.check(
+ breakpointId: 'methodBP',
+ expression: 'x + field',
+ expectedResult: '15');
+ });
+
+ test('expression using private fields', () async {
+ await driver.check(
+ breakpointId: 'methodBP',
+ expression: 'x + _field',
+ expectedResult: '16');
+ });
+
+ test('expression using globals', () async {
+ await driver.check(
+ breakpointId: 'methodBP',
+ expression: 'x + global',
+ expectedResult: '52');
+ });
+
+ test('expression using fields not referred to in the original code',
+ () async {
+ await driver.check(
+ breakpointId: 'methodBP',
+ expression: '_unusedField + _unusedStaticField',
+ expectedResult: '7');
+ });
+
+ test('private field modification', () async {
+ await driver.check(
+ breakpointId: 'methodBP',
+ expression: '_field = 2',
+ expectedResult: '2');
+ });
+
+ test('field modification', () async {
+ await driver.check(
+ breakpointId: 'methodBP',
+ expression: 'field = 3',
+ expectedResult: '3');
+ });
+
+ test('private static field modification', () async {
+ await driver.check(
+ breakpointId: 'methodBP',
+ expression: '_staticField = 4',
+ expectedResult: '4');
+ });
+
+ test('static field modification', () async {
+ await driver.check(
+ breakpointId: 'methodBP',
+ expression: 'staticField = 5',
+ expectedResult: '5');
+ });
+ });
+
+ group('Expression compiler tests in global function:', () {
+ var source = simpleClassSource;
+
+ setUpAll(() async {
+ await driver.initSource(setup, source);
+ });
+
+ tearDownAll(() {
+ driver.cleanupTest();
+ });
+
+ test('compilation error', () async {
+ await driver.check(
+ breakpointId: 'globalFunctionBP',
+ expression: 'typo',
+ expectedError: "Getter not found: 'typo'.");
+ });
+
+ test('local with primitive type', () async {
+ await driver.check(
+ breakpointId: 'globalFunctionBP',
+ expression: 'x',
+ expectedResult: '15');
+ });
+
+ test('local object', () async {
+ await driver.check(
+ breakpointId: 'globalFunctionBP',
+ expression: 'c',
+ expectedResult:
+ 'test.C.new {Symbol(_unusedField): 4, Symbol(C.field): 5, '
+ 'Symbol(_field): 6}');
+ });
+
+ test('create new object', () async {
+ await driver.check(
+ breakpointId: 'globalFunctionBP',
+ expression: 'C(3, 4)',
+ expectedResult:
+ 'test.C.new {Symbol(_unusedField): 4, Symbol(C.field): 3, '
+ 'Symbol(_field): 4}');
+ });
+
+ test('access field of new object', () async {
+ await driver.check(
+ breakpointId: 'globalFunctionBP',
+ expression: 'C(3, 4)._field',
+ expectedResult: '4');
+ });
+
+ test('access static field', () async {
+ await driver.check(
+ breakpointId: 'globalFunctionBP',
+ expression: 'C.staticField',
+ expectedResult: '1');
+ });
+
+ test('expression using private static fields', () async {
+ await driver.check(
+ breakpointId: 'globalFunctionBP',
+ expression: 'C._staticField',
+ expectedError: "Error: Getter not found: '_staticField'.");
+ });
+
+ test('access field', () async {
+ await driver.check(
+ breakpointId: 'globalFunctionBP',
+ expression: 'c.field',
+ expectedResult: '5');
+ });
+
+ test('access private field', () async {
+ await driver.check(
+ breakpointId: 'globalFunctionBP',
+ expression: 'c._field',
+ expectedResult: '6');
+ });
+
+ test('method call', () async {
+ await driver.check(
+ breakpointId: 'globalFunctionBP',
+ expression: 'c.methodFieldAccess(2)',
+ expectedResult: '10');
+ });
+
+ test('async method call', () async {
+ await driver.check(
+ breakpointId: 'globalFunctionBP',
+ expression: 'c.asyncMethod(2)',
+ expectedResult: '_Future.new {Symbol(_state): 1, '
+ 'Symbol(_resultOrListeners): null, '
+ 'Symbol(_zone): _RootZone {}');
+ });
+
+ test('extension method call', () async {
+ await driver.check(
+ breakpointId: 'globalFunctionBP',
+ expression: '"1234".parseInt()',
+ expectedResult: '1235');
+ });
+
+ test('private field modification', () async {
+ await driver.check(
+ breakpointId: 'globalFunctionBP',
+ expression: 'c._field = 10',
+ expectedResult: '10');
+ });
+
+ test('field modification', () async {
+ await driver.check(
+ breakpointId: 'globalFunctionBP',
+ expression: 'c._field = 11',
+ expectedResult: '11');
+ });
+
+ test('private static field modification', () async {
+ await driver.check(
+ breakpointId: 'globalFunctionBP',
+ expression: 'C._staticField = 2',
+ expectedError: "Setter not found: '_staticField'.");
+ });
+
+ test('static field modification', () async {
+ await driver.check(
+ breakpointId: 'globalFunctionBP',
+ expression: 'C.staticField = 20',
+ expectedResult: '20');
+ });
+
+ test('call global function from core library', () async {
+ await driver.check(
+ breakpointId: 'globalFunctionBP',
+ expression: 'identical(1, 1)',
+ expectedResult: 'true');
+ });
+ });
+
+ group('Expression compiler tests in constructor:', () {
+ var source = simpleClassSource;
+
+ setUpAll(() async {
+ await driver.initSource(setup, source);
+ });
+
+ tearDownAll(() {
+ driver.cleanupTest();
+ });
+
+ test('compilation error', () async {
+ await driver.check(
+ breakpointId: 'constructorBP',
+ expression: 'typo',
+ expectedError: "The getter 'typo' isn't defined for the class 'C'");
+ });
+
+ test('local', () async {
+ await driver.check(
+ breakpointId: 'constructorBP', expression: 'y', expectedResult: '1');
+ });
+
+ test('this', () async {
+ await driver.check(
+ breakpointId: 'constructorBP',
+ expression: 'this',
+ expectedResult:
+ 'test.C.new {Symbol(_unusedField): 4, Symbol(C.field): 5,'
+ ' Symbol(_field): 6}');
+ });
+
+ test('expression using locals', () async {
+ await driver.check(
+ breakpointId: 'constructorBP',
+ expression: 'y + 1',
+ expectedResult: '2');
+ });
+
+ test('expression using static fields', () async {
+ await driver.check(
+ breakpointId: 'constructorBP',
+ expression: 'y + staticField',
+ expectedResult: '2');
+ });
+
+ test('expression using private static fields', () async {
+ await driver.check(
+ breakpointId: 'constructorBP',
+ expression: 'y + _staticField',
+ expectedResult: '3');
+ });
+
+ test('expression using fields', () async {
+ await driver.check(
+ breakpointId: 'constructorBP',
+ expression: 'y + field',
+ expectedResult: '6');
+ });
+
+ test('expression using private fields', () async {
+ await driver.check(
+ breakpointId: 'constructorBP',
+ expression: 'y + _field',
+ expectedResult: '7');
+ });
+
+ test('expression using globals', () async {
+ await driver.check(
+ breakpointId: 'constructorBP',
+ expression: 'y + global',
+ expectedResult: '43');
+ });
+
+ test('method call', () async {
+ await driver.check(
+ breakpointId: 'constructorBP',
+ expression: 'methodFieldAccess(2)',
+ expectedResult: '10');
+ });
+
+ test('async method call', () async {
+ await driver.check(
+ breakpointId: 'constructorBP',
+ expression: 'asyncMethod(2)',
+ expectedResult: '_Future.new {Symbol(_state): 1, '
+ 'Symbol(_resultOrListeners): null, '
+ 'Symbol(_zone): _RootZone {}');
+ });
+
+ test('extension method call', () async {
+ await driver.check(
+ breakpointId: 'constructorBP',
+ expression: '"1234".parseInt()',
+ expectedResult: '1235');
+ });
+
+ test('private field modification', () async {
+ await driver.check(
+ breakpointId: 'constructorBP',
+ expression: '_field = 2',
+ expectedResult: '2');
+ });
+
+ test('field modification', () async {
+ await driver.check(
+ breakpointId: 'constructorBP',
+ expression: 'field = 2',
+ expectedResult: '2');
+ });
+
+ test('private static field modification', () async {
+ await driver.check(
+ breakpointId: 'constructorBP',
+ expression: '_staticField = 2',
+ expectedResult: '2');
+ });
+
+ test('static field modification', () async {
+ await driver.check(
+ breakpointId: 'constructorBP',
+ expression: 'staticField = 2',
+ expectedResult: '2');
+ });
+ });
+
+ group('Expression compiler tests in async method:', () {
+ var source = '''
+ class C {
+ static int staticField = 1;
+ static int _staticField = 2;
+ int _field;
+ int field;
+
+ C(this.field, this._field);
+ Future<int> asyncMethod(int x) async {
+ // Breakpoint: bp
+ return x + global + _field + field + staticField + _staticField;
+ }
+ }
+
+ Future<int> entrypoint() async {
+ var c = C(5, 7);
+ // Breakpoint: bp1
+ return await c.asyncMethod(1);
+ }
+
+ int global = 42;
+ void main() async {
+ await entrypoint();
+ }
+ ''';
+
+ setUpAll(() async {
+ await driver.initSource(setup, source);
+ });
+
+ tearDownAll(() {
+ driver.cleanupTest();
+ });
+
+ test('compilation error', () async {
+ await driver.check(
+ breakpointId: 'bp',
+ expression: 'typo',
+ expectedError: "The getter 'typo' isn't defined for the class 'C'");
+ });
+
+ test('local', () async {
+ await driver.check(
+ breakpointId: 'bp', expression: 'x', expectedResult: '1');
+ });
+
+ test('this', () async {
+ await driver.check(
+ breakpointId: 'bp',
+ expression: 'this',
+ expectedResult: 'test.C.new {Symbol(C.field): 5, Symbol(_field): 7}');
+ });
+
+ test('awaited method call', () async {
+ await driver.check(
+ breakpointId: 'bp1',
+ expression: 'c.asyncMethod(1)',
+ expectedResult: '_Future.new {Symbol(_state): 1, '
+ 'Symbol(_resultOrListeners): null, '
+ 'Symbol(_zone): _RootZone {}');
+ }, skip: "'await' is not yet supported in expression evaluation.");
+
+ test('awaited method call', () async {
+ await driver.check(
+ breakpointId: 'bp1',
+ expression: 'await c.asyncMethod(1)',
+ expectedResult: '58');
+ }, skip: "'await' is not yet supported in expression evaluation.");
+ });
+
+ group('Expression compiler tests in closures:', () {
+ var source = '''
+ void globalFunction() {
+ int x = 15;
+
+ var outerClosure = (int y) {
+ var closureCaptureInner = (int z) {
+ // Breakpoint: bp
+ var temp = x + y + z;
+ return;
+ };
+ closureCaptureInner(0);
+ };
+
+ outerClosure(3);
+ return;
+ }
+
+ main() => globalFunction();
+ ''';
+
+ setUpAll(() async {
+ await driver.initSource(setup, source);
+ });
+
+ tearDownAll(() {
+ driver.cleanupTest();
+ });
+
+ test('compilation error', () async {
+ await driver.check(
+ breakpointId: 'bp',
+ expression: 'typo',
+ expectedError: "Getter not found: 'typo'.");
+ });
+
+ test('expression using captured variables', () async {
+ await driver.check(
+ breakpointId: 'bp', expression: r"'$y+$z'", expectedResult: '3+0');
+ });
+
+ test('expression using uncaptured variables', () async {
+ await driver.check(
+ breakpointId: 'bp',
+ expression: r"'$x+$y+$z'",
+ expectedResult: '15+3+0');
+ });
+ });
+
+ group('Expression compiler tests in method with no type use:', () {
+ var source = '''
+ abstract class Key {
+ const factory Key(String value) = ValueKey;
+ const Key.empty();
+ }
+
+ abstract class LocalKey extends Key {
+ const LocalKey() : super.empty();
+ }
+
+ class ValueKey implements LocalKey {
+ const ValueKey(this.value);
+ final String value;
+ }
+
+ class MyClass {
+ const MyClass(this._t);
+ final int _t;
+ }
+
+ int bar(int p) {
+ return p;
+ }
+
+ String baz(String t) {
+ return t;
+ }
+
+ String main() {
+ var k = Key('t');
+ MyClass c = MyClass(0);
+ int p = 1;
+ const t = 1;
+
+ // Breakpoint: bp
+ return '\$c, \$k, \$t';
+ }
+ ''';
+
+ setUpAll(() async {
+ await driver.initSource(setup, source);
+ });
+
+ tearDownAll(() {
+ driver.cleanupTest();
+ });
+
+ test('call function not using type', () async {
+ await driver.check(
+ breakpointId: 'bp', expression: 'bar(p)', expectedResult: '1');
+ });
+
+ test('call function using type', () async {
+ await driver.check(
+ breakpointId: 'bp', expression: "baz('\$p')", expectedResult: '1');
+ });
+
+ test('evaluate new const expression', () async {
+ await driver.check(
+ breakpointId: 'bp',
+ expression: 'const MyClass(1)',
+ expectedResult: 'MyClass {Symbol(MyClass._t): 1}');
+ });
+
+ test('evaluate optimized const expression', () async {
+ await driver.check(
+ breakpointId: 'bp', expression: 't', expectedResult: '1');
+ },
+ skip: 'Cannot compile constants optimized away by the frontend. '
+ 'Issue: https://github.com/dart-lang/sdk/issues/41999');
+
+ test('evaluate factory constructor call', () async {
+ await driver.check(
+ breakpointId: 'bp',
+ expression: "Key('t')",
+ expectedResult: 'test.ValueKey.new {Symbol(ValueKey.value): t}');
+ });
+
+ test('evaluate const factory constructor call', () async {
+ await driver.check(
+ breakpointId: 'bp',
+ expression: "const Key('t')",
+ expectedResult: 'ValueKey {Symbol(ValueKey.value): t}');
+ });
+ });
+
+ group('Expression compiler tests in simple loops:', () {
+ var source = '''
+ void globalFunction() {
+ int x = 15;
+ for(int i = 0; i < 10; i++) {
+ // Breakpoint: bp
+ var calculation = '\$i+\$x';
+ };
+ }
+
+ main() => globalFunction();
+ ''';
+
+ setUpAll(() async {
+ await driver.initSource(setup, source);
+ });
+
+ tearDownAll(() {
+ driver.cleanupTest();
+ });
+
+ test('expression using local', () async {
+ await driver.check(
+ breakpointId: 'bp', expression: 'x', expectedResult: '15');
+ });
+
+ test('expression using loop variable', () async {
+ await driver.check(
+ breakpointId: 'bp', expression: 'i', expectedResult: '0');
+ });
+ });
+
+ group('Expression compiler tests in conditional:', () {
+ var source = '''
+ int globalFunction(int x) {
+ if (x == 1) {
+ int y = 3;
+ // Breakpoint: thenBP
+ var calculation = '\$y+\$x';
+ } else {
+ int z = 4;
+ // Breakpoint: elseBP
+ var calculation = '\$z+\$x';
+ }
+ // Breakpoint: postBP
+ return 0;
+ }
+
+ void main() {
+ globalFunction(1);
+ globalFunction(2);
+ }
+ ''';
+
+ setUpAll(() async {
+ await driver.initSource(setup, source);
+ });
+
+ tearDownAll(() {
+ driver.cleanupTest();
+ });
+
+ test('(then) expression using local', () async {
+ await driver.check(
+ breakpointId: 'thenBP', expression: 'y', expectedResult: '3');
+ });
+
+ test('(then) expression using local out of scope', () async {
+ await driver.check(
+ breakpointId: 'thenBP',
+ expression: 'z',
+ expectedError: "Error: Getter not found: 'z'");
+ });
+
+ test('(else) expression using local', () async {
+ await driver.check(
+ breakpointId: 'elseBP', expression: 'z', expectedResult: '4');
+ });
+
+ test('(else) expression using local out of scope', () async {
+ await driver.check(
+ breakpointId: 'elseBP',
+ expression: 'y',
+ expectedError: "Error: Getter not found: 'y'");
+ });
+
+ test('(post) expression using local', () async {
+ await driver.check(
+ breakpointId: 'postBP', expression: 'x', expectedResult: '1');
+ });
+
+ test('(post) expression using local out of scope', () async {
+ await driver.check(
+ breakpointId: 'postBP',
+ expression: 'z',
+ expectedError: "Error: Getter not found: 'z'");
+ });
+
+ test('(post) expression using local out of scope', () async {
+ await driver.check(
+ breakpointId: 'postBP',
+ expression: 'y',
+ expectedError: "Error: Getter not found: 'y'");
+ });
+ });
+
+ group('Expression compiler tests in iterator loops:', () {
+ var source = '''
+ int globalFunction() {
+ var l = <String>['1', '2', '3'];
+
+ for (var e in l) {
+ // Breakpoint: bp
+ var calculation = '\$e';
+ };
+ return 0;
+ }
+
+ main() => globalFunction();
+ ''';
+
+ setUpAll(() async {
+ await driver.initSource(setup, source);
+ });
+
+ tearDownAll(() {
+ driver.cleanupTest();
+ });
+
+ test('expression loop variable', () async {
+ await driver.check(
+ breakpointId: 'bp', expression: 'e', expectedResult: '1');
+ });
+ });
+}
diff --git a/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_sound_test.dart b/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_sound_test.dart
new file mode 100644
index 0000000..f67ae6a9
--- /dev/null
+++ b/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_sound_test.dart
@@ -0,0 +1,24 @@
+// Copyright (c) 2021, 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.
+
+// @dart = 2.9
+
+library dev_compiler.test.expression_compiler;
+
+import 'package:test/test.dart';
+import 'expression_compiler_e2e_shared.dart';
+import 'expression_compiler_e2e_suite.dart';
+
+void main() async {
+ var driver = await TestDriver.init();
+ var setup = SetupCompilerOptions(soundNullSafety: true);
+
+ group('(Sound null safety)', () {
+ tearDownAll(() {
+ driver.finish();
+ });
+
+ runSharedTests(setup, driver);
+ });
+}
diff --git a/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_suite.dart b/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_suite.dart
new file mode 100644
index 0000000..25f75c3
--- /dev/null
+++ b/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_suite.dart
@@ -0,0 +1,603 @@
+// Copyright (c) 2021, 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.
+
+// @dart = 2.9
+
+library dev_compiler.test.expression_compiler;
+
+import 'dart:async';
+import 'dart:convert';
+import 'dart:io' show Directory, File, Platform;
+
+import 'package:browser_launcher/browser_launcher.dart' as browser;
+import 'package:cli_util/cli_util.dart';
+import 'package:dev_compiler/dev_compiler.dart';
+import 'package:dev_compiler/src/compiler/module_builder.dart';
+import 'package:dev_compiler/src/kernel/module_metadata.dart';
+import 'package:front_end/src/api_unstable/ddc.dart' as fe;
+import 'package:front_end/src/compute_platform_binaries_location.dart' as fe;
+import 'package:front_end/src/fasta/incremental_serializer.dart' as fe;
+import 'package:kernel/ast.dart' show Component, Library;
+import 'package:kernel/target/targets.dart';
+import 'package:path/path.dart' as p;
+import 'package:source_maps/parser.dart' as source_maps;
+import 'package:source_maps/source_maps.dart' as source_maps;
+import 'package:test/test.dart';
+import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'
+ as wip;
+
+class DevelopmentIncrementalCompiler extends fe.IncrementalCompiler {
+ Uri entryPoint;
+
+ DevelopmentIncrementalCompiler(fe.CompilerOptions options, this.entryPoint,
+ [Uri initializeFrom,
+ bool outlineOnly,
+ fe.IncrementalSerializer incrementalSerializer])
+ : super(
+ fe.CompilerContext(
+ fe.ProcessedOptions(options: options, inputs: [entryPoint])),
+ initializeFrom,
+ outlineOnly,
+ incrementalSerializer);
+
+ DevelopmentIncrementalCompiler.fromComponent(fe.CompilerOptions options,
+ this.entryPoint, Component componentToInitializeFrom,
+ [bool outlineOnly, fe.IncrementalSerializer incrementalSerializer])
+ : super.fromComponent(
+ fe.CompilerContext(
+ fe.ProcessedOptions(options: options, inputs: [entryPoint])),
+ componentToInitializeFrom,
+ outlineOnly,
+ incrementalSerializer);
+}
+
+class SetupCompilerOptions {
+ static final sdkRoot = fe.computePlatformBinariesLocation();
+ static final sdkUnsoundSummaryPath =
+ p.join(sdkRoot.toFilePath(), 'ddc_sdk.dill');
+ static final sdkSoundSummaryPath =
+ p.join(sdkRoot.toFilePath(), 'ddc_outline_sound.dill');
+ static final librariesSpecificationUri =
+ p.join(p.dirname(p.dirname(getSdkPath())), 'libraries.json');
+ static final String dartUnsoundComment = '// @dart = 2.9';
+ static final String dartSoundComment = '//';
+
+ final String dartLangComment;
+ final List<String> errors = [];
+ final List<String> diagnosticMessages = [];
+ final ModuleFormat moduleFormat;
+ final fe.CompilerOptions options;
+ final bool soundNullSafety;
+
+ static fe.CompilerOptions _getOptions(bool soundNullSafety) {
+ var options = fe.CompilerOptions()
+ ..verbose = false // set to true for debugging
+ ..sdkRoot = sdkRoot
+ ..target = DevCompilerTarget(TargetFlags())
+ ..librariesSpecificationUri = p.toUri('sdk/lib/libraries.json')
+ ..omitPlatform = true
+ ..sdkSummary =
+ p.toUri(soundNullSafety ? sdkSoundSummaryPath : sdkUnsoundSummaryPath)
+ ..environmentDefines = const {}
+ ..nnbdMode = soundNullSafety ? fe.NnbdMode.Strong : fe.NnbdMode.Weak;
+ return options;
+ }
+
+ SetupCompilerOptions(
+ {this.soundNullSafety = true, this.moduleFormat = ModuleFormat.amd})
+ : options = _getOptions(soundNullSafety),
+ dartLangComment =
+ soundNullSafety ? dartSoundComment : dartUnsoundComment {
+ options.onDiagnostic = (fe.DiagnosticMessage m) {
+ diagnosticMessages.addAll(m.plainTextFormatted);
+ if (m.severity == fe.Severity.error) {
+ errors.addAll(m.plainTextFormatted);
+ }
+ };
+ }
+}
+
+class TestCompilationResult {
+ final String result;
+ final bool isSuccess;
+
+ TestCompilationResult(this.result, this.isSuccess);
+}
+
+class TestCompiler {
+ final SetupCompilerOptions setup;
+ Component component;
+ ExpressionCompiler evaluator;
+ ModuleMetadata metadata;
+ source_maps.SingleMapping sourceMap;
+
+ TestCompiler(this.setup);
+
+ Future<TestCompiler> init({Uri input, Uri output, Uri packages}) async {
+ // Initialize the incremental compiler and module component.
+ // TODO: extend this for multi-module compilations by storing separate
+ // compilers/components/names per module.
+ setup.options.packagesFileUri = packages;
+ var compiler = DevelopmentIncrementalCompiler(setup.options, input);
+ component = await compiler.computeDelta();
+ component.computeCanonicalNames();
+
+ // Initialize DDC.
+ var moduleName = '${p.basenameWithoutExtension(output.toFilePath())}';
+
+ var classHierarchy = compiler.getClassHierarchy();
+ var compilerOptions = SharedCompilerOptions(
+ replCompile: true,
+ moduleName: moduleName,
+ soundNullSafety: setup.soundNullSafety);
+ var coreTypes = compiler.getCoreTypes();
+
+ final importToSummary = Map<Library, Component>.identity();
+ final summaryToModule = Map<Component, String>.identity();
+ for (var lib in component.libraries) {
+ importToSummary[lib] = component;
+ }
+ summaryToModule[component] = moduleName;
+
+ var kernel2jsCompiler = ProgramCompiler(component, classHierarchy,
+ compilerOptions, importToSummary, summaryToModule,
+ coreTypes: coreTypes);
+ var module = kernel2jsCompiler.emitModule(component);
+
+ // Perform a full compile, writing the compiled JS + sourcemap.
+ var code = jsProgramToCode(
+ module,
+ setup.moduleFormat,
+ inlineSourceMap: true,
+ buildSourceMap: true,
+ emitDebugMetadata: true,
+ jsUrl: '$output',
+ mapUrl: '$output.map',
+ component: component,
+ );
+ metadata = code.metadata;
+ sourceMap = source_maps.SingleMapping.fromJson(code.sourceMap);
+ var codeBytes = utf8.encode(code.code);
+ var sourceMapBytes = utf8.encode(json.encode(code.sourceMap));
+
+ File('${output.toFilePath()}').writeAsBytesSync(codeBytes);
+ File('${output.toFilePath()}.map').writeAsBytesSync(sourceMapBytes);
+
+ // Save the expression evaluator for future evaluations.
+ evaluator = ExpressionCompiler(
+ setup.options,
+ setup.moduleFormat,
+ setup.errors,
+ compiler,
+ kernel2jsCompiler,
+ component,
+ );
+
+ if (setup.errors.isNotEmpty) {
+ throw Exception('Compilation failed with: ${setup.errors}');
+ }
+ setup.diagnosticMessages.clear();
+
+ return this;
+ }
+
+ Future<TestCompilationResult> compileExpression(
+ {Uri input,
+ int line,
+ int column,
+ Map<String, String> scope,
+ String expression}) async {
+ var libraryUri = metadataForLibraryUri(input);
+ var jsExpression = await evaluator.compileExpressionToJs(
+ libraryUri.importUri, line, column, scope, expression);
+ if (setup.errors.isNotEmpty) {
+ jsExpression = setup.errors.toString().replaceAll(
+ RegExp(
+ r'org-dartlang-debug:synthetic_debug_expression:[0-9]*:[0-9]*:'),
+ '');
+
+ return TestCompilationResult(jsExpression, false);
+ }
+
+ return TestCompilationResult(jsExpression, true);
+ }
+
+ LibraryMetadata metadataForLibraryUri(Uri libraryUri) =>
+ metadata.libraries.entries
+ .firstWhere((entry) => entry.value.fileUri == '$libraryUri')
+ .value;
+}
+
+class TestDriver {
+ SetupCompilerOptions setup;
+ String source;
+ Directory chromeDir;
+ Directory testDir;
+ String moduleFormatString;
+ Uri htmlBootstrapper;
+ Uri input;
+ Uri output;
+ Uri packagesFile;
+ browser.Chrome chrome;
+ wip.WipDebugger debugger;
+ wip.WipConnection connection;
+ TestCompiler compiler;
+
+ TestDriver._();
+
+ static Future<TestDriver> init() async {
+ var driver = TestDriver._();
+ await driver.initChrome();
+ return driver;
+ }
+
+ /// Initializes a Chrome browser instance, tab connection, and debugger.
+ ///
+ /// Should be called once after creating TestDriver.
+ Future<void> initChrome() async {
+ // Create a temporary directory for holding Chrome tests.
+ var systemTempDir = Directory.systemTemp;
+ chromeDir = await systemTempDir.createTemp('ddc_eval_test_anchor');
+
+ // Start Chrome on an empty page with a single empty tab.
+ chrome = await browser.Chrome.startWithDebugPort(['about:blank'],
+ userDataDir: chromeDir.uri.toFilePath(), headless: true);
+
+ // Connect to the first 'normal' tab.
+ var tab = await chrome.chromeConnection
+ .getTab((tab) => !tab.isBackgroundPage && !tab.isChromeExtension);
+ connection = await tab.connect();
+ debugger = connection.debugger;
+ }
+
+ /// Must be called when testing a new Dart program.
+ ///
+ /// Depends on SDK artifacts (such as the sound and unsound dart_sdk.js
+ /// files) generated from the 'dartdevc_test' target.
+ Future<void> initSource(SetupCompilerOptions setup, String source) async {
+ // Prepend Dart nullability comment.
+ source = '${setup.dartLangComment}\n\n$source';
+ this.setup = setup;
+ this.source = source;
+ testDir = await chromeDir.createTemp('ddc_eval_test');
+ var buildDir = p.dirname(p.dirname(p.dirname(Platform.resolvedExecutable)));
+ var scriptPath = Platform.script.normalizePath().toFilePath();
+ var ddcPath = p.dirname(p.dirname(p.dirname(scriptPath)));
+ output = testDir.uri.resolve('test.js');
+ input = testDir.uri.resolve('test.dart');
+ File(input.toFilePath())
+ ..createSync()
+ ..writeAsStringSync(source);
+
+ packagesFile = testDir.uri.resolve('package_config.json');
+ File(packagesFile.toFilePath())
+ ..createSync()
+ ..writeAsStringSync('''
+ {
+ "configVersion": 2,
+ "packages": [
+ {
+ "name": "eval_test",
+ "rootUri": "./",
+ "packageUri": "./"
+ }
+ ]
+ }
+ ''');
+
+ // Initialize DDC and the incremental compiler, then perform a full compile.
+ compiler = await TestCompiler(setup)
+ .init(input: input, output: output, packages: packagesFile);
+
+ htmlBootstrapper = testDir.uri.resolve('bootstrapper.html');
+ var bootstrapFile = File(htmlBootstrapper.toFilePath())..createSync();
+ var moduleName = compiler.metadata.name;
+ var mainLibraryName = compiler.metadataForLibraryUri(input).name;
+
+ switch (setup.moduleFormat) {
+ case ModuleFormat.ddc:
+ moduleFormatString = 'ddc';
+ var dartSdkPath = escaped(p.join(
+ buildDir,
+ 'gen',
+ 'utils',
+ 'dartdevc',
+ setup.soundNullSafety ? 'sound' : 'kernel',
+ 'legacy',
+ 'dart_sdk.js'));
+ var dartLibraryPath =
+ escaped(p.join(ddcPath, 'lib', 'js', 'legacy', 'dart_library.js'));
+ var outputPath = escaped(output.toFilePath());
+ bootstrapFile.writeAsStringSync('''
+<script src='$dartLibraryPath'></script>
+<script src='$dartSdkPath'></script>
+<script src='$outputPath'></script>
+<script>
+ 'use strict';
+ var sound = ${setup.soundNullSafety};
+ var sdk = dart_library.import('dart_sdk');
+
+ if (!sound) {
+ sdk.dart.weakNullSafetyWarnings(false);
+ sdk.dart.weakNullSafetyErrors(false);
+ }
+ sdk.dart.nonNullAsserts(true);
+ sdk.dart.nativeNonNullAsserts(true);
+ sdk._debugger.registerDevtoolsFormatter();
+ dart_library.start('$moduleName', '$mainLibraryName');
+</script>
+''');
+ break;
+ case ModuleFormat.amd:
+ moduleFormatString = 'amd';
+ var dartSdkPath = escaped(p.join(buildDir, 'gen', 'utils', 'dartdevc',
+ setup.soundNullSafety ? 'sound' : 'kernel', 'amd', 'dart_sdk'));
+ var requirePath = escaped(p.join(buildDir, 'dart-sdk', 'lib',
+ 'dev_compiler', 'kernel', 'amd', 'require.js'));
+ var outputPath = escaped(p.withoutExtension(output.toFilePath()));
+ bootstrapFile.writeAsStringSync('''
+<script src='$requirePath'></script>
+<script>
+ require.config({
+ paths: {
+ 'dart_sdk': '$dartSdkPath',
+ '$moduleName': '$outputPath'
+ },
+ waitSeconds: 15
+ });
+ var sound = ${setup.soundNullSafety};
+
+ require(['dart_sdk', '$moduleName'],
+ function(sdk, app) {
+ 'use strict';
+
+ if (!sound) {
+ sdk.dart.weakNullSafetyWarnings(false);
+ sdk.dart.weakNullSafetyErrors(false);
+ }
+ sdk.dart.nonNullAsserts(true);
+ sdk.dart.nativeNonNullAsserts(true);
+ sdk._debugger.registerDevtoolsFormatter();
+ app.$mainLibraryName.main([]);
+ });
+</script>
+''');
+
+ break;
+ default:
+ throw Exception(
+ 'Unsupported module format for SDK evaluation tests: ${setup.moduleFormat}');
+ }
+
+ await debugger.enable();
+
+ // Pause as soon as the test file loads but before it executes.
+ var urlRegex = '.*${libraryUriToJsIdentifier(output)}.*';
+ await debugger.sendCommand('Debugger.setBreakpointByUrl', params: {
+ 'urlRegex': urlRegex,
+ 'lineNumber': 0,
+ });
+ }
+
+ void finish() async {
+ await chrome?.close();
+ // Chrome takes a while to free its claim on chromeDir, so wait a bit.
+ await Future.delayed(const Duration(milliseconds: 500));
+ chromeDir?.deleteSync(recursive: true);
+ }
+
+ Future<void> cleanupTest() async {
+ setup.diagnosticMessages.clear();
+ setup.errors.clear();
+ await debugger.disable();
+ }
+
+ Future<void> check(
+ {String breakpointId,
+ String expression,
+ String expectedError,
+ String expectedResult}) async {
+ assert(expectedError == null || expectedResult == null,
+ 'Cannot expect both an error and result.');
+
+ // The next two pause events will correspond to:
+ // 1) the initial preemptive breakpoint and
+ // 2) the breakpoint at the specified ID
+ final pauseController = StreamController<wip.DebuggerPausedEvent>();
+ var pauseSub = debugger.onPaused.listen(pauseController.add);
+
+ final scriptController = StreamController<wip.ScriptParsedEvent>();
+ var scriptSub = debugger.onScriptParsed.listen((event) {
+ if ('${event.script.url}' == '$output') {
+ scriptController.add(event);
+ }
+ });
+
+ // Navigate from the empty page and immediately pause on the preemptive
+ // breakpoint.
+ await connection.page.navigate('$htmlBootstrapper');
+
+ // Poll until the script is found, or timeout after a few seconds.
+ var script = (await scriptController.stream.first.timeout(
+ const Duration(seconds: 5),
+ onTimeout: () => throw Exception(
+ 'Unable to find JS script corresponding to test file $output in ${debugger.scripts}.')))
+ .script;
+ await scriptSub.cancel();
+ await scriptController.close();
+
+ // Breakpoint at the first WIP location mapped from its Dart line.
+ var dartLine = _findBreakpointLine(breakpointId);
+ var location = await _jsLocationFromDartLine(script, dartLine);
+ var bp = await debugger.setBreakpoint(location);
+
+ // Continue to the next breakpoint, ignoring the first pause event since it
+ // corresponds to the preemptive URI breakpoint made prior to page
+ // navigation.
+ await debugger.resume();
+ final event = await pauseController.stream
+ .skip(1)
+ .timeout(const Duration(seconds: 5),
+ onTimeout: (event) => throw Exception(
+ 'Unable to find JS preemptive pause event in $output.'))
+ .first
+ .timeout(const Duration(seconds: 5),
+ onTimeout: () => throw Exception(
+ 'Unable to find JS pause event corresponding to line ($dartLine -> $location) in $output.'));
+ await pauseSub.cancel();
+ await pauseController.close();
+
+ // Retrieve the call frame and its scope variables.
+ var frame = event.getCallFrames().first;
+ var scope = await _collectScopeVariables(frame);
+
+ // Perform an incremental compile.
+ var result = await compiler.compileExpression(
+ input: input,
+ line: dartLine,
+ column: 1,
+ scope: scope,
+ expression: expression);
+
+ if (expectedError != null) {
+ expect(
+ result,
+ const TypeMatcher<TestCompilationResult>()
+ .having((_) => result.result, 'result', _matches(expectedError)));
+ setup.diagnosticMessages.clear();
+ setup.errors.clear();
+ return;
+ }
+
+ if (!result.isSuccess) {
+ throw Exception(
+ 'Unexpected expression evaluation failure:\n${result.result}');
+ }
+
+ var evalResult = await debugger.evaluateOnCallFrame(
+ frame.callFrameId, result.result,
+ returnByValue: false);
+
+ await debugger.removeBreakpoint(bp.breakpointId);
+ var value = await stringifyRemoteObject(evalResult);
+
+ expect(
+ result,
+ const TypeMatcher<TestCompilationResult>()
+ .having((_) => '$value', 'result', _matches(expectedResult)));
+ }
+
+ /// Generate simple string representation of a RemoteObject that closely
+ /// resembles Chrome's console output.
+ ///
+ /// Examples:
+ /// Class: t.C.new {Symbol(C.field): 5, Symbol(_field): 7}
+ /// Function: function main() {
+ /// return test.foo(1, {y: 2});
+ /// }
+ Future<String> stringifyRemoteObject(wip.RemoteObject obj) async {
+ String str;
+ switch (obj.type) {
+ case 'function':
+ str = obj.description;
+ break;
+ case 'object':
+ if (obj.subtype == 'null') {
+ return 'null';
+ }
+ var properties =
+ await connection.runtime.getProperties(obj, ownProperties: true);
+ var filteredProps = <String, String>{};
+ for (var prop in properties) {
+ if (prop.value != null && prop.name != '__proto__') {
+ filteredProps[prop.name] = await stringifyRemoteObject(prop.value);
+ }
+ }
+ str = '${obj.description} $filteredProps';
+ break;
+ default:
+ str = '${obj.value}';
+ break;
+ }
+ return str;
+ }
+
+ /// Collects local JS variables visible at a breakpoint during evaluation.
+ ///
+ /// Adapted from webdev/dwds/lib/src/services/expression_evaluator.dart.
+ Future<Map<String, String>> _collectScopeVariables(
+ wip.WipCallFrame frame) async {
+ var jsScope = <String, String>{};
+
+ for (var scope in filterScopes(frame)) {
+ var response = await connection.runtime
+ .getProperties(scope.object, ownProperties: true);
+ for (var prop in response) {
+ var propKey = '${prop.name}';
+ var propValue = '${prop.value.value}';
+ jsScope[propKey] = propValue == 'null' ? propKey : propValue;
+ }
+ }
+ return jsScope;
+ }
+
+ /// Used for matching error text emitted during expression evaluation.
+ Matcher _matches(String text) {
+ var unindented = RegExp.escape(text).replaceAll(RegExp('[ ]+'), '[ ]*');
+ return matches(RegExp(unindented, multiLine: true));
+ }
+
+ /// Finds the line number in [source] matching [breakpointId].
+ ///
+ /// A breakpoint ID is found by looking for a line that ends with a comment
+ /// of exactly this form: `// Breakpoint: <id>`.
+ ///
+ /// Throws if it can't find the matching line.
+ ///
+ /// Adapted from webdev/blob/master/dwds/test/fixtures/context.dart.
+ int _findBreakpointLine(String breakpointId) {
+ var lines = LineSplitter.split(source).toList();
+ var lineNumber =
+ lines.indexWhere((l) => l.endsWith('// Breakpoint: $breakpointId'));
+ if (lineNumber == -1) {
+ throw StateError(
+ 'Unable to find breakpoint in $input with id: $breakpointId');
+ }
+ return lineNumber + 1;
+ }
+
+ /// Finds the corresponding JS WipLocation for a given line in Dart.
+ Future<wip.WipLocation> _jsLocationFromDartLine(
+ wip.WipScript script, int dartLine) async {
+ var inputSourceUrl = input.pathSegments.last;
+ for (var lineEntry in compiler.sourceMap.lines) {
+ for (var entry in lineEntry.entries) {
+ if (entry.sourceUrlId != null &&
+ entry.sourceLine == dartLine &&
+ compiler.sourceMap.urls[entry.sourceUrlId] == inputSourceUrl) {
+ return wip.WipLocation.fromValues(script.scriptId, lineEntry.line);
+ }
+ }
+ }
+ throw StateError(
+ 'Unable to extract WIP Location from ${script.url} for Dart line $dartLine.');
+ }
+}
+
+/// Filters the provided frame scopes to those that are pertinent for Dart
+/// debugging.
+///
+/// Copied from webdev/dwds/lib/src/debugging/dart_scope.dart.
+List<wip.WipScope> filterScopes(wip.WipCallFrame frame) {
+ var scopes = frame.getScopeChain().toList();
+ // Remove outer scopes up to and including the Dart SDK.
+ while (
+ scopes.isNotEmpty && !(scopes.last.name?.startsWith('load__') ?? false)) {
+ scopes.removeLast();
+ }
+ if (scopes.isNotEmpty) scopes.removeLast();
+ return scopes;
+}
+
+String escaped(String path) => path.replaceAll('\\', '\\\\');
diff --git a/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_test.dart b/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_test.dart
deleted file mode 100644
index 95d2fb0..0000000
--- a/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_test.dart
+++ /dev/null
@@ -1,1140 +0,0 @@
-// Copyright (c) 2021, 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.
-
-// @dart = 2.9
-
-library dev_compiler.test.expression_compiler;
-
-import 'dart:async';
-import 'dart:convert';
-import 'dart:io' show Directory, File, Platform;
-
-import 'package:browser_launcher/browser_launcher.dart' as browser;
-import 'package:cli_util/cli_util.dart';
-import 'package:dev_compiler/dev_compiler.dart';
-import 'package:dev_compiler/src/compiler/module_builder.dart';
-import 'package:dev_compiler/src/kernel/module_metadata.dart';
-import 'package:front_end/src/api_unstable/ddc.dart' as fe;
-import 'package:front_end/src/compute_platform_binaries_location.dart' as fe;
-import 'package:front_end/src/fasta/incremental_serializer.dart' as fe;
-import 'package:kernel/ast.dart' show Component, Library;
-import 'package:kernel/target/targets.dart';
-import 'package:path/path.dart' as p;
-import 'package:source_maps/parser.dart' as source_maps;
-import 'package:source_maps/source_maps.dart' as source_maps;
-import 'package:test/test.dart';
-import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'
- as wip;
-
-class DevelopmentIncrementalCompiler extends fe.IncrementalCompiler {
- Uri entryPoint;
-
- DevelopmentIncrementalCompiler(fe.CompilerOptions options, this.entryPoint,
- [Uri initializeFrom,
- bool outlineOnly,
- fe.IncrementalSerializer incrementalSerializer])
- : super(
- fe.CompilerContext(
- fe.ProcessedOptions(options: options, inputs: [entryPoint])),
- initializeFrom,
- outlineOnly,
- incrementalSerializer);
-
- DevelopmentIncrementalCompiler.fromComponent(fe.CompilerOptions options,
- this.entryPoint, Component componentToInitializeFrom,
- [bool outlineOnly, fe.IncrementalSerializer incrementalSerializer])
- : super.fromComponent(
- fe.CompilerContext(
- fe.ProcessedOptions(options: options, inputs: [entryPoint])),
- componentToInitializeFrom,
- outlineOnly,
- incrementalSerializer);
-}
-
-class SetupCompilerOptions {
- static final sdkRoot = fe.computePlatformBinariesLocation();
- static final sdkUnsoundSummaryPath =
- p.join(sdkRoot.toFilePath(), 'ddc_sdk.dill');
- static final sdkSoundSummaryPath =
- p.join(sdkRoot.toFilePath(), 'ddc_outline_sound.dill');
- static final librariesSpecificationUri =
- p.join(p.dirname(p.dirname(getSdkPath())), 'libraries.json');
- static final String dartUnsoundComment = '// @dart = 2.9';
- static final String dartSoundComment = '//';
-
- final String dartLangComment;
- final List<String> errors = [];
- final List<String> diagnosticMessages = [];
- final ModuleFormat moduleFormat;
- final fe.CompilerOptions options;
- final bool soundNullSafety;
-
- static fe.CompilerOptions _getOptions(bool soundNullSafety) {
- var options = fe.CompilerOptions()
- ..verbose = false // set to true for debugging
- ..sdkRoot = sdkRoot
- ..target = DevCompilerTarget(TargetFlags())
- ..librariesSpecificationUri = p.toUri('sdk/lib/libraries.json')
- ..omitPlatform = true
- ..sdkSummary =
- p.toUri(soundNullSafety ? sdkSoundSummaryPath : sdkUnsoundSummaryPath)
- ..environmentDefines = const {}
- ..nnbdMode = soundNullSafety ? fe.NnbdMode.Strong : fe.NnbdMode.Weak;
- return options;
- }
-
- SetupCompilerOptions(
- {this.soundNullSafety = true, this.moduleFormat = ModuleFormat.amd})
- : options = _getOptions(soundNullSafety),
- dartLangComment =
- soundNullSafety ? dartSoundComment : dartUnsoundComment {
- options.onDiagnostic = (fe.DiagnosticMessage m) {
- diagnosticMessages.addAll(m.plainTextFormatted);
- if (m.severity == fe.Severity.error) {
- errors.addAll(m.plainTextFormatted);
- }
- };
- }
-}
-
-class TestCompilationResult {
- final String result;
- final bool isSuccess;
-
- TestCompilationResult(this.result, this.isSuccess);
-}
-
-class TestCompiler {
- final SetupCompilerOptions setup;
- Component component;
- ExpressionCompiler evaluator;
- ModuleMetadata metadata;
- source_maps.SingleMapping sourceMap;
-
- TestCompiler(this.setup);
-
- Future<TestCompiler> init({Uri input, Uri output, Uri packages}) async {
- // Initialize the incremental compiler and module component.
- // TODO: extend this for multi-module compilations by storing separate
- // compilers/components/names per module.
- setup.options.packagesFileUri = packages;
- var compiler = DevelopmentIncrementalCompiler(setup.options, input);
- component = await compiler.computeDelta();
- component.computeCanonicalNames();
-
- // Initialize DDC.
- var moduleName = '${p.basenameWithoutExtension(output.toFilePath())}';
-
- var classHierarchy = compiler.getClassHierarchy();
- var compilerOptions = SharedCompilerOptions(
- replCompile: true,
- moduleName: moduleName,
- soundNullSafety: setup.soundNullSafety);
- var coreTypes = compiler.getCoreTypes();
-
- final importToSummary = Map<Library, Component>.identity();
- final summaryToModule = Map<Component, String>.identity();
- for (var lib in component.libraries) {
- importToSummary[lib] = component;
- }
- summaryToModule[component] = moduleName;
-
- var kernel2jsCompiler = ProgramCompiler(component, classHierarchy,
- compilerOptions, importToSummary, summaryToModule,
- coreTypes: coreTypes);
- var module = kernel2jsCompiler.emitModule(component);
-
- // Perform a full compile, writing the compiled JS + sourcemap.
- var code = jsProgramToCode(
- module,
- setup.moduleFormat,
- inlineSourceMap: true,
- buildSourceMap: true,
- emitDebugMetadata: true,
- jsUrl: '$output',
- mapUrl: '$output.map',
- component: component,
- );
- metadata = code.metadata;
- sourceMap = source_maps.SingleMapping.fromJson(code.sourceMap);
- var codeBytes = utf8.encode(code.code);
- var sourceMapBytes = utf8.encode(json.encode(code.sourceMap));
-
- File('${output.toFilePath()}').writeAsBytesSync(codeBytes);
- File('${output.toFilePath()}.map').writeAsBytesSync(sourceMapBytes);
-
- // Save the expression evaluator for future evaluations.
- evaluator = ExpressionCompiler(
- setup.options,
- setup.moduleFormat,
- setup.errors,
- compiler,
- kernel2jsCompiler,
- component,
- );
-
- if (setup.errors.isNotEmpty) {
- throw Exception('Compilation failed with: ${setup.errors}');
- }
- setup.diagnosticMessages.clear();
-
- return this;
- }
-
- Future<TestCompilationResult> compileExpression(
- {Uri input,
- int line,
- int column,
- Map<String, String> scope,
- String expression}) async {
- var libraryUri = metadataForLibraryUri(input);
- var jsExpression = await evaluator.compileExpressionToJs(
- libraryUri.importUri, line, column, scope, expression);
- if (setup.errors.isNotEmpty) {
- jsExpression = setup.errors.toString().replaceAll(
- RegExp(
- r'org-dartlang-debug:synthetic_debug_expression:[0-9]*:[0-9]*:'),
- '');
-
- return TestCompilationResult(jsExpression, false);
- }
-
- return TestCompilationResult(jsExpression, true);
- }
-
- LibraryMetadata metadataForLibraryUri(Uri libraryUri) =>
- metadata.libraries.entries
- .firstWhere((entry) => entry.value.fileUri == '$libraryUri')
- .value;
-}
-
-class TestDriver {
- SetupCompilerOptions setup;
- String source;
- Directory chromeDir;
- Directory testDir;
- String moduleFormatString;
- Uri htmlBootstrapper;
- Uri input;
- Uri output;
- Uri packagesFile;
- browser.Chrome chrome;
- wip.WipDebugger debugger;
- wip.WipConnection connection;
- TestCompiler compiler;
-
- TestDriver._();
-
- static Future<TestDriver> init(SetupCompilerOptions setup) async {
- var driver = TestDriver._();
- await driver.initChrome();
- return driver;
- }
-
- /// Initializes a Chrome browser instance, tab connection, and debugger.
- ///
- /// Should be called once after creating TestDriver.
- Future<void> initChrome() async {
- // Create a temporary directory for holding Chrome tests.
- var systemTempDir = Directory.systemTemp;
- chromeDir = await systemTempDir.createTemp('ddc_eval_test_anchor');
-
- // Start Chrome on an empty page with a single empty tab.
- chrome = await browser.Chrome.startWithDebugPort(['about:blank'],
- userDataDir: chromeDir.uri.toFilePath(), headless: true);
-
- // Connect to the first 'normal' tab.
- var tab = await chrome.chromeConnection
- .getTab((tab) => !tab.isBackgroundPage && !tab.isChromeExtension);
- connection = await tab.connect();
- debugger = connection.debugger;
- }
-
- /// Must be called when testing a new Dart program.
- ///
- /// Depends on SDK artifacts (such as the sound and unsound dart_sdk.js
- /// files) generated from the 'dartdevc_test' target.
- Future<void> initSource(SetupCompilerOptions setup, String source) async {
- // Prepend Dart nullability comment.
- source = '${setup.dartLangComment}\n\n$source';
- this.setup = setup;
- this.source = source;
- testDir = await chromeDir.createTemp('ddc_eval_test');
- var buildDir = p.dirname(p.dirname(p.dirname(Platform.resolvedExecutable)));
- var scriptPath = Platform.script.normalizePath().toFilePath();
- var ddcPath = p.dirname(p.dirname(p.dirname(scriptPath)));
- output = testDir.uri.resolve('test.js');
- input = testDir.uri.resolve('test.dart');
- File(input.toFilePath())
- ..createSync()
- ..writeAsStringSync(source);
-
- packagesFile = testDir.uri.resolve('package_config.json');
- File(packagesFile.toFilePath())
- ..createSync()
- ..writeAsStringSync('''
- {
- "configVersion": 2,
- "packages": [
- {
- "name": "eval_test",
- "rootUri": "./",
- "packageUri": "./"
- }
- ]
- }
- ''');
-
- // Initialize DDC and the incremental compiler, then perform a full compile.
- compiler = await TestCompiler(setup)
- .init(input: input, output: output, packages: packagesFile);
-
- htmlBootstrapper = testDir.uri.resolve('bootstrapper.html');
- var bootstrapFile = File(htmlBootstrapper.toFilePath())..createSync();
- var moduleName = compiler.metadata.name;
- var mainLibraryName = compiler.metadataForLibraryUri(input).name;
-
- switch (setup.moduleFormat) {
- case ModuleFormat.ddc:
- moduleFormatString = 'ddc';
- var dartSdkPath = escaped(p.join(
- buildDir,
- 'gen',
- 'utils',
- 'dartdevc',
- setup.soundNullSafety ? 'sound' : 'kernel',
- 'legacy',
- 'dart_sdk.js'));
- var dartLibraryPath =
- escaped(p.join(ddcPath, 'lib', 'js', 'legacy', 'dart_library.js'));
- var outputPath = escaped(output.toFilePath());
- bootstrapFile.writeAsStringSync('''
-<script src='$dartLibraryPath'></script>
-<script src='$dartSdkPath'></script>
-<script src='$outputPath'></script>
-<script>
- 'use strict';
- var sound = ${setup.soundNullSafety};
- var sdk = dart_library.import('dart_sdk');
-
- if (!sound) {
- sdk.dart.weakNullSafetyWarnings(false);
- sdk.dart.weakNullSafetyErrors(false);
- }
- sdk.dart.nonNullAsserts(true);
- sdk.dart.nativeNonNullAsserts(true);
- sdk._debugger.registerDevtoolsFormatter();
- dart_library.start('$moduleName', '$mainLibraryName');
-</script>
-''');
- break;
- case ModuleFormat.amd:
- moduleFormatString = 'amd';
- var dartSdkPath = escaped(p.join(buildDir, 'gen', 'utils', 'dartdevc',
- setup.soundNullSafety ? 'sound' : 'kernel', 'amd', 'dart_sdk'));
- var requirePath = escaped(p.join(buildDir, 'dart-sdk', 'lib',
- 'dev_compiler', 'kernel', 'amd', 'require.js'));
- var outputPath = escaped(p.withoutExtension(output.toFilePath()));
- bootstrapFile.writeAsStringSync('''
-<script src='$requirePath'></script>
-<script>
- require.config({
- paths: {
- 'dart_sdk': '$dartSdkPath',
- '$moduleName': '$outputPath'
- },
- waitSeconds: 15
- });
- var sound = ${setup.soundNullSafety};
-
- require(['dart_sdk', '$moduleName'],
- function(sdk, app) {
- 'use strict';
-
- if (!sound) {
- sdk.dart.weakNullSafetyWarnings(false);
- sdk.dart.weakNullSafetyErrors(false);
- }
- sdk.dart.nonNullAsserts(true);
- sdk.dart.nativeNonNullAsserts(true);
- sdk._debugger.registerDevtoolsFormatter();
- app.$mainLibraryName.main([]);
- });
-</script>
-''');
-
- break;
- default:
- throw Exception(
- 'Unsupported module format for SDK evaluation tests: ${setup.moduleFormat}');
- }
-
- await debugger.enable();
-
- // Pause as soon as the test file loads but before it executes.
- var urlRegex = '.*${libraryUriToJsIdentifier(output)}.*';
- await debugger.sendCommand('Debugger.setBreakpointByUrl', params: {
- 'urlRegex': urlRegex,
- 'lineNumber': 0,
- });
- }
-
- void finish() async {
- await chrome?.close();
- // Chrome takes a while to free its claim on chromeDir, so wait a bit.
- await Future.delayed(const Duration(milliseconds: 500));
- chromeDir?.deleteSync(recursive: true);
- }
-
- Future<void> cleanupTest() async {
- setup.diagnosticMessages.clear();
- setup.errors.clear();
- await debugger.disable();
- }
-
- Future<void> check(
- {String breakpointId,
- String expression,
- String expectedError,
- String expectedResult}) async {
- assert(expectedError == null || expectedResult == null,
- 'Cannot expect both an error and result.');
-
- var subs = <StreamSubscription>[];
- final controller = StreamController<wip.DebuggerPausedEvent>();
- subs.add(debugger.onPaused.listen(controller.add));
-
- // Navigate from the empty page and immediately pause on the preemptive
- // breakpoint.
- await connection.page.navigate('$htmlBootstrapper');
- await Future.delayed(const Duration(milliseconds: 500));
-
- // TODO: We use lastWhere since the debugger accumulates scriptIds across
- // tests. We can use firstWhere if we clear debugger.scripts - perhaps by
- // disabling and enabling the debugger.
- final script = debugger.scripts.entries
- .lastWhere((entry) => entry.value.url.endsWith('test.js'),
- orElse: () => throw Exception(
- 'Unable to find JS script corresponding to test file $output in ${debugger.scripts}.'))
- .value;
-
- // Breakpoint at the first WIP location mapped from its Dart line.
- var dartLine = _findBreakpointLine(breakpointId);
- var location = await _jsLocationFromDartLine(script, dartLine);
- var bp = await debugger.setBreakpoint(location);
-
- // Continue to the next breakpoint, ignoring the first pause event since it
- // corresponds to the preemptive URI breakpoint made prior to page
- // navigation.
- await debugger.resume();
- final event = await controller.stream.skip(1).first;
-
- // Retrieve the call frame and its scope variables.
- var frame = event.getCallFrames().first;
- var scope = await _collectScopeVariables(frame);
-
- // Perform an incremental compile.
- var result = await compiler.compileExpression(
- input: input,
- line: dartLine,
- column: 1,
- scope: scope,
- expression: expression);
-
- if (expectedError != null) {
- expect(
- result,
- const TypeMatcher<TestCompilationResult>()
- .having((_) => result.result, 'result', _matches(expectedError)));
- setup.diagnosticMessages.clear();
- setup.errors.clear();
- return;
- }
-
- if (!result.isSuccess) {
- throw Exception(
- 'Unexpected expression evaluation failure:\n${result.result}');
- }
-
- var evalResult = await debugger.evaluateOnCallFrame(
- frame.callFrameId, result.result,
- returnByValue: false);
-
- await debugger.removeBreakpoint(bp.breakpointId);
- var value = await stringifyRemoteObject(evalResult);
-
- expect(
- result,
- const TypeMatcher<TestCompilationResult>()
- .having((_) => '$value', 'result', _matches(expectedResult)));
- }
-
- /// Generate simple string representation of a RemoteObject that closely
- /// resembles Chrome's console output.
- ///
- /// Examples:
- /// Class: t.C.new {Symbol(C.field): 5, Symbol(_field): 7}
- /// Function: function main() {
- /// return test.foo(1, {y: 2});
- /// }
- Future<String> stringifyRemoteObject(wip.RemoteObject obj) async {
- String str;
- switch (obj.type) {
- case 'function':
- str = obj.description;
- break;
- case 'object':
- if (obj.subtype == 'null') {
- return 'null';
- }
- var properties =
- await connection.runtime.getProperties(obj, ownProperties: true);
- var filteredProps = <String, String>{};
- for (var prop in properties) {
- if (prop.value != null && prop.name != '__proto__') {
- filteredProps[prop.name] = await stringifyRemoteObject(prop.value);
- }
- }
- str = '${obj.description} $filteredProps';
- break;
- default:
- str = '${obj.value}';
- break;
- }
- return str;
- }
-
- /// Collects local JS variables visible at a breakpoint during evaluation.
- ///
- /// Adapted from webdev/dwds/lib/src/services/expression_evaluator.dart.
- Future<Map<String, String>> _collectScopeVariables(
- wip.WipCallFrame frame) async {
- var jsScope = <String, String>{};
-
- for (var scope in filterScopes(frame)) {
- var response = await connection.runtime
- .getProperties(scope.object, ownProperties: true);
- for (var prop in response) {
- var propKey = '${prop.name}';
- var propValue = '${prop.value.value}';
- jsScope[propKey] = propValue == 'null' ? propKey : propValue;
- }
- }
- return jsScope;
- }
-
- /// Used for matching error text emitted during expression evaluation.
- Matcher _matches(String text) {
- var unindented = RegExp.escape(text).replaceAll(RegExp('[ ]+'), '[ ]*');
- return matches(RegExp(unindented, multiLine: true));
- }
-
- /// Finds the line number in [source] matching [breakpointId].
- ///
- /// A breakpoint ID is found by looking for a line that ends with a comment
- /// of exactly this form: `// Breakpoint: <id>`.
- ///
- /// Throws if it can't find the matching line.
- ///
- /// Adapted from webdev/blob/master/dwds/test/fixtures/context.dart.
- int _findBreakpointLine(String breakpointId) {
- var lines = LineSplitter.split(source).toList();
- var lineNumber =
- lines.indexWhere((l) => l.endsWith('// Breakpoint: $breakpointId'));
- if (lineNumber == -1) {
- throw StateError(
- 'Unable to find breakpoint in $input with id: $breakpointId');
- }
- return lineNumber + 1;
- }
-
- /// Finds the corresponding JS WipLocation for a given line in Dart.
- Future<wip.WipLocation> _jsLocationFromDartLine(
- wip.WipScript script, int dartLine) async {
- var inputSourceUrl = input.pathSegments.last;
- for (var lineEntry in compiler.sourceMap.lines) {
- for (var entry in lineEntry.entries) {
- if (entry.sourceUrlId != null &&
- entry.sourceLine == dartLine &&
- compiler.sourceMap.urls[entry.sourceUrlId] == inputSourceUrl) {
- return wip.WipLocation.fromValues(script.scriptId, lineEntry.line);
- }
- }
- }
- throw StateError(
- 'Unable to extract WIP Location from ${script.url} for Dart line $dartLine.');
- }
-}
-
-/// Filters the provided frame scopes to those that are pertinent for Dart
-/// debugging.
-///
-/// Copied from webdev/dwds/lib/src/debugging/dart_scope.dart.
-List<wip.WipScope> filterScopes(wip.WipCallFrame frame) {
- var scopes = frame.getScopeChain().toList();
- // Remove outer scopes up to and including the Dart SDK.
- while (
- scopes.isNotEmpty && !(scopes.last.name?.startsWith('load__') ?? false)) {
- scopes.removeLast();
- }
- if (scopes.isNotEmpty) scopes.removeLast();
- return scopes;
-}
-
-String escaped(String path) => path.replaceAll('\\', '\\\\');
-
-void main() async {
- group('Unsound null safety:', () {
- var setup = SetupCompilerOptions(soundNullSafety: false);
- TestDriver driver;
-
- setUpAll(() async {
- driver = await TestDriver.init(setup);
- });
-
- tearDownAll(() {
- driver.finish();
- });
-
- group('Expression compiler extension symbols tests', () {
- var source = '''
- main() {
- List<int> list = [];
- list.add(0);
- // Breakpoint: bp
- }
- ''';
-
- setUpAll(() async {
- await driver.initSource(setup, source);
- });
-
- tearDownAll(() async {
- await driver.cleanupTest();
- });
-
- test('extension symbol used only in expression compilation', () async {
- await driver.check(
- breakpointId: 'bp', expression: 'list.first', expectedResult: '0');
- });
-
- test('extension symbol used in original compilation', () async {
- await driver.check(
- breakpointId: 'bp',
- expression: '() { list.add(1); return list.last; }()',
- expectedResult: '1');
- });
- });
-
- group('Expression compiler scope collection tests', () {
- var source = '''
- class C {
- static int staticField = 0;
- int field;
-
- C(this.field);
-
- void methodFieldAccess(int x) {
- var inScope = 1;
- {
- var innerInScope = global + staticField + field;
- // Breakpoint: bp
- var innerNotInScope = 2;
- }
- var notInScope = 3;
- }
- }
-
- int global = 42;
- main() => C(4).methodFieldAccess(5);
- ''';
-
- setUpAll(() async {
- await driver.initSource(setup, source);
- });
-
- tearDownAll(() async {
- await driver.cleanupTest();
- });
-
- test('local in scope', () async {
- await driver.check(
- breakpointId: 'bp', expression: 'inScope', expectedResult: '1');
- });
-
- test('local in inner scope', () async {
- await driver.check(
- breakpointId: 'bp',
- expression: 'innerInScope',
- expectedResult: '46');
- });
-
- test('global in scope', () async {
- await driver.check(
- breakpointId: 'bp', expression: 'global', expectedResult: '42');
- });
-
- test('static field in scope', () async {
- await driver.check(
- breakpointId: 'bp', expression: 'staticField', expectedResult: '0');
- });
-
- test('field in scope', () async {
- await driver.check(
- breakpointId: 'bp', expression: 'field', expectedResult: '4');
- });
-
- test('parameter in scope', () async {
- await driver.check(
- breakpointId: 'bp', expression: 'x', expectedResult: '5');
- });
-
- test('local not in scope', () async {
- await driver.check(
- breakpointId: 'bp',
- expression: 'notInScope',
- expectedError:
- "Error: The getter 'notInScope' isn't defined for the"
- " class 'C'.");
- });
-
- test('local not in inner scope', () async {
- await driver.check(
- breakpointId: 'bp',
- expression: 'innerNotInScope',
- expectedError:
- "Error: The getter 'innerNotInScope' isn't defined for the"
- " class 'C'.");
- });
- });
-
- group('Expression compiler tests in extension method:', () {
- var source = '''
- extension NumberParsing on String {
- int parseInt() {
- var ret = int.parse(this);
- // Breakpoint: bp
- return ret;
- }
- }
- main() => "1234".parseInt();
- ''';
-
- setUpAll(() async {
- await driver.initSource(setup, source);
- });
-
- tearDownAll(() {
- driver.cleanupTest();
- });
-
- test('compilation error', () async {
- await driver.check(
- breakpointId: 'bp',
- expression: 'typo',
- expectedError: "Error: Getter not found: 'typo'");
- });
-
- test('local (trimmed scope)', () async {
- await driver.check(
- breakpointId: 'bp', expression: 'ret', expectedResult: '1234');
- });
-
- test('this (full scope)', () async {
- // Note: this currently fails due to
- // - incremental compiler not mapping 'this' from user input to '#this'
- // - incremental compiler not allowing #this as a parameter name
- await driver.check(
- breakpointId: 'bp',
- expression: 'this',
- expectedError: "Error: Expected identifier, but got 'this'");
- });
- });
-
- group('Expression compiler tests in static function:', () {
- var source = '''
- int foo(int x, {int y}) {
- int z = 3;
- // Breakpoint: bp
- return x + y + z;
- }
-
- main() => foo(1, y: 2);
- ''';
-
- setUpAll(() async {
- await driver.initSource(setup, source);
- });
-
- tearDownAll(() {
- driver.cleanupTest();
- });
-
- test('compilation error', () async {
- await driver.check(
- breakpointId: 'bp',
- expression: 'typo',
- expectedError: "Getter not found: \'typo\'");
- });
-
- test('local', () async {
- await driver.check(
- breakpointId: 'bp', expression: 'x', expectedResult: '1');
- });
-
- test('formal', () async {
- await driver.check(
- breakpointId: 'bp', expression: 'y', expectedResult: '2');
- });
-
- test('named formal', () async {
- await driver.check(
- breakpointId: 'bp', expression: 'z', expectedResult: '3');
- });
-
- test('function', () async {
- await driver
- .check(breakpointId: 'bp', expression: 'main', expectedResult: '''
- function main() {
- return test.foo(1, {y: 2});
- }''');
- });
- });
-
- group('Expression compiler tests in method:', () {
- var source = '''
- extension NumberParsing on String {
- int parseInt() {
- return int.parse(this) + 1;
- }
- }
-
- class C {
- static int staticField = 1;
- static int _staticField = 2;
- static int _unusedStaticField = 3;
- int field;
- int _field;
- int _unusedField = 4;
-
- C(this.field, this._field);
-
- int methodFieldAccess(int x) {
- // Breakpoint: bp
- return x + _field + _staticField;
- }
- }
-
- void entrypoint() {
- var c = C(5, 7);
- // Breakpoint: bp1
- c.methodFieldAccess(10);
- }
-
- int global = 42;
- main() => entrypoint();
- ''';
-
- setUpAll(() async {
- await driver.initSource(setup, source);
- });
-
- tearDownAll(() {
- driver.cleanupTest();
- });
-
- test('compilation error', () async {
- await driver.check(
- breakpointId: 'bp',
- expression: 'typo',
- expectedError: "The getter 'typo' isn't defined for the class 'C'");
- });
-
- test('local', () async {
- await driver.check(
- breakpointId: 'bp', expression: 'x', expectedResult: '10');
- });
-
- test('this', () async {
- await driver.check(
- breakpointId: 'bp',
- expression: 'this',
- expectedResult:
- 'test.C.new {Symbol(_unusedField): 4, Symbol(C.field): 5,'
- ' Symbol(_field): 7}');
- });
-
- test('expression using locals', () async {
- await driver.check(
- breakpointId: 'bp', expression: 'x + 1', expectedResult: '11');
- });
-
- test('expression using static fields', () async {
- await driver.check(
- breakpointId: 'bp',
- expression: 'x + staticField',
- expectedResult: '11');
- });
-
- test('expression using private static fields', () async {
- await driver.check(
- breakpointId: 'bp',
- expression: 'x + _staticField',
- expectedResult: '12');
- });
-
- test('expression using fields', () async {
- await driver.check(
- breakpointId: 'bp', expression: 'x + field', expectedResult: '15');
- });
-
- test('expression using private fields', () async {
- await driver.check(
- breakpointId: 'bp', expression: 'x + _field', expectedResult: '17');
- });
-
- test('expression using globals', () async {
- await driver.check(
- breakpointId: 'bp', expression: 'x + global', expectedResult: '52');
- });
-
- test('expression using fields not referred to in the original code',
- () async {
- await driver.check(
- breakpointId: 'bp',
- expression: '_unusedField + _unusedStaticField',
- expectedResult: '7');
- });
-
- test('method call', () async {
- await driver.check(
- breakpointId: 'bp1',
- expression: 'c.methodFieldAccess(2)',
- expectedResult: '11');
- });
-
- test('extension method call', () async {
- await driver.check(
- breakpointId: 'bp1',
- expression: '"1234".parseInt()',
- expectedResult: '1235');
- });
-
- test('private field modification', () async {
- await driver.check(
- breakpointId: 'bp',
- expression: '() {_field = 2; return _field;}()',
- expectedResult: '2');
- });
-
- test('field modification', () async {
- await driver.check(
- breakpointId: 'bp',
- expression: '() {field = 3; return field;}()',
- expectedResult: '3');
- });
-
- test('private static field modification', () async {
- await driver.check(
- breakpointId: 'bp',
- expression: '() {_staticField = 4; return _staticField;}()',
- expectedResult: '4');
- });
-
- test('static field modification', () async {
- await driver.check(
- breakpointId: 'bp',
- expression: '() {staticField = 5; return staticField;}()',
- expectedResult: '5');
- });
- });
-
- group('Expression compiler tests in async method:', () {
- var source = '''
- class C {
- static int staticField = 1;
- static int _staticField = 2;
- int _field;
- int field;
-
- C(this.field, this._field);
- Future<int> asyncMethod(int x) async {
- // Breakpoint: bp
- return x + global + _field + field + staticField + _staticField;
- }
- }
-
- void entrypoint() async {
- var c = C(5, 7);
- // Breakpoint: bp1
- var nop;
- await c.asyncMethod(1);
- }
-
- int global = 42;
- main() async => await entrypoint();
- ''';
-
- setUpAll(() async {
- await driver.initSource(setup, source);
- });
-
- tearDownAll(() {
- driver.cleanupTest();
- });
-
- test('compilation error', () async {
- await driver.check(
- breakpointId: 'bp',
- expression: 'typo',
- expectedError: "The getter 'typo' isn't defined for the class 'C'");
- });
-
- test('local', () async {
- await driver.check(
- breakpointId: 'bp', expression: 'x', expectedResult: '1');
- });
-
- test('this', () async {
- await driver.check(
- breakpointId: 'bp',
- expression: 'this',
- expectedResult:
- 'test.C.new {Symbol(C.field): 5, Symbol(_field): 7}');
- });
-
- test('async method call', () async {
- await driver.check(
- breakpointId: 'bp1',
- expression: 'await c.asyncMethod(1)',
- expectedResult: '58');
- }, skip: "'await' is not yet supported in expression evaluation.");
- });
- });
-
- group('Sound null safety:', () {
- var setup = SetupCompilerOptions(soundNullSafety: false);
- TestDriver driver;
-
- setUpAll(() async {
- driver = await TestDriver.init(setup);
- });
-
- tearDownAll(() {
- driver.finish();
- });
-
- group('Expression compiler extension symbols tests', () {
- var source = '''
- main() {
- List<int> list = [];
- list.add(0);
- // Breakpoint: bp
- }
- ''';
-
- setUpAll(() async {
- await driver.initSource(setup, source);
- });
-
- tearDownAll(() async {
- await driver.cleanupTest();
- });
-
- test('extension symbol used only in expression compilation', () async {
- await driver.check(
- breakpointId: 'bp', expression: 'list.first', expectedResult: '0');
- });
-
- test('extension symbol used in original compilation', () async {
- await driver.check(
- breakpointId: 'bp',
- expression: '() { list.add(1); return list.last; }()',
- expectedResult: '1');
- });
- });
-
- group('Expression compiler scope collection tests', () {
- var source = '''
- class C {
- C(this.field);
-
- void methodFieldAccess(int x) {
- var inScope = 1;
- {
- var innerInScope = global + staticField + field;
- // Breakpoint: bp
- var innerNotInScope = 2;
- }
- var notInScope = 3;
- }
-
- static int staticField = 0;
- int field;
- }
-
- int global = 42;
- main() => C(4).methodFieldAccess(5);
- ''';
-
- setUpAll(() async {
- await driver.initSource(setup, source);
- });
-
- tearDownAll(() async {
- await driver.cleanupTest();
- });
-
- test('local in scope', () async {
- await driver.check(
- breakpointId: 'bp', expression: 'inScope', expectedResult: '1');
- });
-
- test('local in inner scope', () async {
- await driver.check(
- breakpointId: 'bp',
- expression: 'innerInScope',
- expectedResult: '46');
- });
-
- test('global in scope', () async {
- await driver.check(
- breakpointId: 'bp', expression: 'global', expectedResult: '42');
- });
-
- test('static field in scope', () async {
- await driver.check(
- breakpointId: 'bp', expression: 'staticField', expectedResult: '0');
- });
-
- test('field in scope', () async {
- await driver.check(
- breakpointId: 'bp', expression: 'field', expectedResult: '4');
- });
-
- test('parameter in scope', () async {
- await driver.check(
- breakpointId: 'bp', expression: 'x', expectedResult: '5');
- });
-
- test('local not in scope', () async {
- await driver.check(
- breakpointId: 'bp',
- expression: 'notInScope',
- expectedError:
- "Error: The getter 'notInScope' isn't defined for the"
- " class 'C'.");
- });
-
- test('local not in inner scope', () async {
- await driver.check(
- breakpointId: 'bp',
- expression: 'innerNotInScope',
- expectedError:
- "Error: The getter 'innerNotInScope' isn't defined for the"
- " class 'C'.");
- });
- });
- });
-}
diff --git a/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_unsound_test.dart b/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_unsound_test.dart
new file mode 100644
index 0000000..7ac4ce7
--- /dev/null
+++ b/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_unsound_test.dart
@@ -0,0 +1,24 @@
+// Copyright (c) 2021, 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.
+
+// @dart = 2.9
+
+library dev_compiler.test.expression_compiler;
+
+import 'package:test/test.dart';
+import 'expression_compiler_e2e_shared.dart';
+import 'expression_compiler_e2e_suite.dart';
+
+void main() async {
+ var driver = await TestDriver.init();
+ var setup = SetupCompilerOptions(soundNullSafety: false);
+
+ group('(Unsound null safety)', () {
+ tearDownAll(() {
+ driver.finish();
+ });
+
+ runSharedTests(setup, driver);
+ });
+}
diff --git a/pkg/dev_compiler/test/expression_compiler/expression_compiler_test.dart b/pkg/dev_compiler/test/expression_compiler/expression_compiler_test.dart
index 588797a..17e60eb 100644
--- a/pkg/dev_compiler/test/expression_compiler/expression_compiler_test.dart
+++ b/pkg/dev_compiler/test/expression_compiler/expression_compiler_test.dart
@@ -461,1127 +461,6 @@
});
});
- group('Expression compiler scope collection tests', () {
- var source = '''
- ${options.dartLangComment}
-
- class C {
- C(int this.field);
-
- int methodFieldAccess(int x) {
- var inScope = 1;
- {
- var innerInScope = global + staticField + field;
- /* evaluation placeholder */
- print(innerInScope);
- var innerNotInScope = 2;
- }
- var notInScope = 3;
- }
-
- static int staticField = 0;
- int field;
- }
-
- int global = 42;
- main() => 0;
- ''';
-
- TestDriver driver;
-
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('local in scope', () async {
- await driver.check(
- scope: <String, String>{'inScope': '1', 'innerInScope': '0'},
- expression: 'inScope',
- expectedResult: '''
- (function(inScope, innerInScope) {
- return inScope;
- }.bind(this)(
- 1,
- 0
- ))
- ''');
- });
-
- test('local in inner scope', () async {
- await driver.check(
- scope: <String, String>{'inScope': '1', 'innerInScope': '0'},
- expression: 'innerInScope',
- expectedResult: '''
- (function(inScope, innerInScope) {
- return innerInScope;
- }.bind(this)(
- 1,
- 0
- ))
- ''');
- });
-
- test('global in scope', () async {
- await driver.check(
- scope: <String, String>{'inScope': '1', 'innerInScope': '0'},
- expression: 'global',
- expectedResult: '''
- (function(inScope, innerInScope) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo.global;
- }.bind(this)(
- 1,
- 0
- ))
- ''');
- });
-
- test('static field in scope', () async {
- await driver.check(
- scope: <String, String>{'inScope': '1', 'innerInScope': '0'},
- expression: 'staticField',
- expectedResult: '''
- (function(inScope, innerInScope) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo.C.staticField;
- }.bind(this)(
- 1,
- 0
- ))
- ''');
- });
-
- test('field in scope', () async {
- await driver.check(
- scope: <String, String>{'inScope': '1', 'innerInScope': '0'},
- expression: 'field',
- expectedResult: '''
- (function(inScope, innerInScope) {
- return this.field;
- }.bind(this)(
- 1,
- 0
- ))
- ''');
- });
-
- test('local not in scope', () async {
- await driver.check(
- scope: <String, String>{'inScope': '1', 'innerInScope': '0'},
- expression: 'notInScope',
- expectedError:
- "Error: The getter 'notInScope' isn't defined for the class 'C'.");
- });
-
- test('local not in inner scope', () async {
- await driver.check(
- scope: <String, String>{'inScope': '1', 'innerInScope': '0'},
- expression: 'innerNotInScope',
- expectedError:
- "Error: The getter 'innerNotInScope' isn't defined for the class 'C'.");
- });
- });
-
- group('Expression compiler tests in extension method:', () {
- var source = '''
- ${options.dartLangComment}
- extension NumberParsing on String {
- int parseInt() {
- var ret = int.parse(this);
- /* evaluation placeholder */
- return ret;
- }
- }
- main() => 0;
- ''';
-
- TestDriver driver;
-
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('compilation error', () async {
- await driver.check(
- scope: <String, String>{'ret': '1234'},
- expression: 'typo',
- expectedError: "Error: Getter not found: 'typo'");
- });
-
- test('local (trimmed scope)', () async {
- // Test that current expression evaluation works in extension methods.
- //
- // Note: the actual scope is {#this, ret}, but #this is effectively
- // removed in the expression compilator because it does not exist
- // in JavaScript code.
- // See (full scope) tests for what will the evaluation will look like
- // when the mapping from dart symbols to JavaScipt symbols is added.
- await driver.check(
- scope: <String, String>{'ret': '1234'},
- expression: 'ret',
- expectedResult: '''
- (function(ret) {
- return ret;
- }(
- 1234
- ))
- ''');
- });
-
- test('local (full scope)', () async {
- // Test evalution in extension methods in the future when the mapping
- // from kernel symbols to dartdevc symbols is added.
- //
- // Note: this currently fails due to
- // - incremental compiler not allowing #this as a parameter name
- await driver.check(
- scope: <String, String>{'ret': '1234', '#this': 'this'},
- expression: 'ret',
- expectedError:
- "Illegal parameter name '#this' found during expression compilation.");
- });
-
- test('this (full scope)', () async {
- // Test evalution in extension methods in the future when the mapping
- // from kernel symbols to dartdevc symbols is added.
- //
- // Note: this currently fails due to
- // - incremental compiler not allowing #this as a parameter name
- // - incremental compiler not mapping 'this' from user input to '#this'
- await driver.check(
- scope: <String, String>{'ret': '1234', '#this': 'this'},
- expression: 'this',
- expectedError:
- "Illegal parameter name '#this' found during expression compilation.");
- });
- });
-
- group('Expression compiler tests in static function:', () {
- var source = '''
- ${options.dartLangComment}
- int foo(int x, {int y}) {
- int z = 0;
- /* evaluation placeholder */
- return x + y + z;
- }
-
- main() => 0;
- ''';
-
- TestDriver driver;
-
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('compilation error', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'y': '2', 'z': '3'},
- expression: 'typo',
- expectedError: "Getter not found: \'typo\'");
- });
-
- test('local', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'y': '2', 'z': '3'},
- expression: 'x',
- expectedResult: '''
- (function(x, y, z) {
- return x;
- }(
- 1,
- 2,
- 3
- ))
- ''');
- });
-
- test('formal', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'y': '2', 'z': '3'},
- expression: 'y',
- expectedResult: '''
- (function(x, y, z) {
- return y;
- }(
- 1,
- 2,
- 3
- ))
- ''');
- });
-
- test('named formal', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'y': '2', 'z': '3'},
- expression: 'z',
- expectedResult: '''
- (function(x, y, z) {
- return z;
- }(
- 1,
- 2,
- 3
- ))
- ''');
- });
-
- test('function', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'y': '2', 'z': '3'},
- expression: 'main',
- expectedResult: '''
- (function(x, y, z) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- var T = {
- VoidTodynamic: () => (T.VoidTodynamic = dart.constFn(dart.fnType(dart.dynamic, [])))()
- };
- const CT = Object.create(null);
- dart.defineLazy(CT, {
- get C0() {
- return C[0] = dart.fn(foo.main, T.VoidTodynamic());
- }
- }, false);
- var C = [void 0];
- return C[0] || CT.C0;
- }(
- 1,
- 2,
- 3
- ))
- ''');
- });
- });
-
- group('Expression compiler tests in method:', () {
- var source = '''
- ${options.dartLangComment}
- extension NumberParsing on String {
- int parseInt() {
- return int.parse(this);
- }
- }
-
- int global = 42;
-
- class C {
- C(int this.field, int this._field);
-
- static int staticField = 0;
- static int _staticField = 1;
-
- int _field;
- int field;
-
- int methodFieldAccess(int x) {
- /* evaluation placeholder */
- return x + _field + _staticField;
- }
-
- Future<int> asyncMethod(int x) async {
- return x;
- }
- }
-
- main() => 0;
- ''';
-
- TestDriver driver;
-
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('compilation error', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'typo',
- expectedError:
- "The getter 'typo' isn't defined for the class 'C'");
- });
-
- test('local', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x',
- expectedResult: '''
- (function(x) {
- return x;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('this', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'this',
- expectedResult: '''
- (function(x) {
- return this;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using locals', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + 1',
- expectedResult: '''
- (function(x) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- return dart.notNull(x) + 1;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using static fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + staticField',
- expectedResult: '''
- (function(x) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return dart.notNull(x) + dart.notNull(foo.C.staticField);
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using private static fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + _staticField',
- expectedResult: '''
- (function(x) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return dart.notNull(x) + dart.notNull(foo.C._staticField);
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + field',
- expectedResult: '''
- (function(x) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- return dart.notNull(x) + dart.notNull(this.field);
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using private fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + _field',
- expectedResult: '''
- (function(x) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- var S = {_field\$1: dart.privateName(foo, "_field")};
- return dart.notNull(x) + dart.notNull(this[S._field\$1]);
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using globals', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + global',
- expectedResult: '''
- (function(x) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return dart.notNull(x) + dart.notNull(foo.global);
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('method call', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'methodFieldAccess(2)',
- expectedResult: '''
- (function(x) {
- return this.methodFieldAccess(2);
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('async method call', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'asyncMethod(2)',
- expectedResult: '''
- (function(x) {
- return this.asyncMethod(2);
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('extension method call', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: '"1234".parseInt()',
- expectedResult: '''
- (function(x) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo['NumberParsing|parseInt']("1234");
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('private field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: '_field = 2',
- expectedResult: '''
- (function(x) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- var S = {_field\$1: dart.privateName(foo, "_field")};
- return this[S._field\$1] = 2;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'field = 2',
- expectedResult: '''
- (function(x) {
- return this.field = 2;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('private static field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: '_staticField = 2',
- expectedResult: '''
- (function(x) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo.C._staticField = 2;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('static field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'staticField = 2',
- expectedResult: '''
- (function(x) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo.C.staticField = 2;
- }.bind(this)(
- 1
- ))
- ''');
- });
- });
-
- group('Expression compiler tests in method with no field access:', () {
- var source = '''
- ${options.dartLangComment}
- extension NumberParsing on String {
- int parseInt() {
- return int.parse(this);
- }
- }
-
- int global = 42;
-
- class C {
- C(int this.field, int this._field);
-
- static int staticField = 0;
- static int _staticField = 1;
-
- int _field;
- int field;
-
- int methodNoFieldAccess(int x) {
- /* evaluation placeholder */
- return x;
- }
-
- Future<int> asyncMethod(int x) async {
- return x;
- }
- }
-
- main() => 0;
- ''';
-
- TestDriver driver;
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('compilation error', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'typo',
- expectedError:
- "The getter 'typo' isn't defined for the class 'C'");
- });
-
- test('expression using static fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + staticField',
- expectedResult: '''
- (function(x) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return dart.notNull(x) + dart.notNull(foo.C.staticField);
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using private static fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + _staticField',
- expectedResult: '''
- (function(x) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return dart.notNull(x) + dart.notNull(foo.C._staticField);
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + field',
- expectedResult: '''
- (function(x) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- return dart.notNull(x) + dart.notNull(this.field);
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using private fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + _field',
- expectedResult: '''
- (function(x) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- var S = {_field\$1: dart.privateName(foo, "_field")};
- return dart.notNull(x) + dart.notNull(this[S._field\$1]);
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('private field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: '_field = 2',
- expectedResult: '''
- (function(x) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- var S = {_field\$1: dart.privateName(foo, "_field")};
- return this[S._field\$1] = 2;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'field = 2',
- expectedResult: '''
- (function(x) {
- return this.field = 2;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('private static field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: '_staticField = 2',
- expectedResult: '''
- (function(x) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo.C._staticField = 2;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('static field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'staticField = 2',
- expectedResult: '''
- (function(x) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo.C.staticField = 2;
- }.bind(this)(
- 1
- ))
- ''');
- });
- });
-
- group('Expression compiler tests in async method:', () {
- var source = '''
- ${options.dartLangComment}
- class C {
- C(int this.field, int this._field);
-
- int _field;
- int field;
-
- Future<int> asyncMethod(int x) async {
- /* evaluation placeholder */
- return x;
- }
- }
-
- main() => 0;
- ''';
-
- TestDriver driver;
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('compilation error', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'typo',
- expectedError:
- "The getter 'typo' isn't defined for the class 'C'");
- });
-
- test('local', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x',
- expectedResult: '''
- (function(x) {
- return x;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('this', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'this',
- expectedResult: '''
- (function(x) {
- return this;
- }.bind(this)(
- 1
- ))
- ''');
- });
- });
-
- group('Expression compiler tests in global function:', () {
- var source = '''
- ${options.dartLangComment}
- extension NumberParsing on String {
- int parseInt() {
- return int.parse(this);
- }
- }
-
- int global = 42;
-
- class C {
- C(int this.field, int this._field);
-
- static int staticField = 0;
- static int _staticField = 1;
-
- int _field;
- int field;
-
- int methodFieldAccess(int x) {
- return (x + _field + _staticField);
- }
- int methodFieldAccess(int x) {
- return (x)
- }
-
- Future<int> asyncMethod(int x) async {
- return x;
- }
- }
-
- int main() {
- int x = 15;
- var c = C(1, 2);
- /* evaluation placeholder */
- return 0;
- }
- ''';
-
- TestDriver driver;
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('compilation error', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'typo',
- expectedError: "Getter not found: 'typo'.");
- });
-
- test('local with primitive type', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'x',
- expectedResult: '''
- (function(x, c) {
- return x;
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('local object', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'c',
- expectedResult: '''
- (function(x, c) {
- return c;
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('create new object', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'C(1,3)',
- expectedResult: '''
- (function(x, c) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return new foo.C.new(1, 3);
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('access field of new object', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'C(1,3)._field',
- expectedResult: '''
- (function(x, c) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- var S = {_field\$1: dart.privateName(foo, "_field")};
- return new foo.C.new(1, 3)[S._field\$1];
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('access static field', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'C.staticField',
- expectedResult: '''
- (function(x, c) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo.C.staticField;
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('expression using private static fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'C._staticField',
- expectedError: "Error: Getter not found: '_staticField'.");
- });
-
- test('access field', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'c.field',
- expectedResult: '''
- (function(x, c) {
- return c.field;
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('access private field', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'c._field',
- expectedResult: '''
- (function(x, c) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- var S = {_field\$1: dart.privateName(foo, "_field")};
- return c[S._field\$1];
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('method call', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'c.methodFieldAccess(2)',
- expectedResult: '''
- (function(x, c) {
- return c.methodFieldAccess(2);
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('async method call', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'c.asyncMethod(2)',
- expectedResult: '''
- (function(x, c) {
- return c.asyncMethod(2);
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('extension method call', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: '"1234".parseInt()',
- expectedResult: '''
- (function(x, c) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo['NumberParsing|parseInt']("1234");
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('private field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'c._field = 2',
- expectedResult: '''
- (function(x, c) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- var S = {_field\$1: dart.privateName(foo, "_field")};
- return c[S._field\$1] = 2;
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'c.field = 2',
- expectedResult: '''
- (function(x, c) {
- return c.field = 2;
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('private static field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'C._staticField = 2',
- expectedError: "Setter not found: '_staticField'.");
- });
-
- test('static field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'C.staticField = 2',
- expectedResult: '''
- (function(x, c) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo.C.staticField = 2;
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('call global function from core library', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'print(x)',
- expectedResult: '''
- (function(x, c) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const core = dart_sdk.core;
- return core.print(x);
- }(
- 1,
- null
- ))
- ''');
- });
- });
-
group('Expression compiler tests in closures:', () {
var source = '''
${options.dartLangComment}
@@ -1669,713 +548,6 @@
});
});
- group('Expression compiler tests in method with no type use:', () {
- var source = '''
- ${options.dartLangComment}
- abstract class Key {
- const factory Key(String value) = ValueKey;
- const Key.empty();
- }
-
- abstract class LocalKey extends Key {
- const LocalKey() : super.empty();
- }
-
- class ValueKey implements LocalKey {
- const ValueKey(this.value);
- final String value;
- }
-
- class MyClass {
- const MyClass(this._t);
- final int _t;
- }
-
- int bar(int p){
- return p;
- }
- int baz(String t){
- return t;
- }
- void main() {
- var k = Key('t');
- MyClass c = MyClass(0);
- int p = 1;
- const t = 1;
-
- /* evaluation placeholder */
- print('\$c, \$k, \$t');
- }
- ''';
-
- TestDriver driver;
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('call function not using type', () async {
- await driver.check(
- scope: <String, String>{'p': '1'},
- expression: 'bar(p)',
- expectedResult: '''
- (function(p) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo.bar(p);
- }(
- 1
- ))
- ''');
- });
-
- test('call function using type', () async {
- await driver.check(
- scope: <String, String>{'p': '0'},
- expression: 'baz(p as String)',
- expectedResult: '''
- (function(p) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const core = dart_sdk.core;
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- var T = {
- StringL: () => (T.StringL = dart.constFn(dart.legacy(core.String)))()
- };
- return foo.baz(T.StringL().as(p));
- }(
- 0
- ))
- ''');
- });
-
- test('evaluate new const expression', () async {
- await driver.check(
- scope: <String, String>{'p': '1'},
- expression: 'const MyClass(1)',
- expectedResult: '''
- (function(p) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- var S = {MyClass__t: dart.privateName(foo, "MyClass._t")};
- const CT = Object.create(null);
- dart.defineLazy(CT, {
- get C0() {
- return C[0] = dart.const({
- __proto__: foo.MyClass.prototype,
- [S.MyClass__t]: 1
- });
- }
- }, false);
- var C = [void 0];
- return C[0] || CT.C0;
- }(
- 1
- ))
- ''');
- });
-
- test('evaluate optimized const expression', () async {
- await driver.check(
- scope: <String, String>{},
- expression: 't',
- expectedResult: '''
- (function() {
- return 1;
- }(
- ))
- ''');
- },
- skip: 'Cannot compile constants optimized away by the frontend. '
- 'Issue: https://github.com/dart-lang/sdk/issues/41999');
-
- test('evaluate factory constructor call', () async {
- await driver.check(
- scope: <String, String>{'p': '1'},
- expression: "Key('t')",
- expectedResult: '''
- (function(p) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return new foo.ValueKey.new("t");
- }(
- 1
- ))
- ''');
- });
-
- test('evaluate const factory constructor call', () async {
- await driver.check(
- scope: <String, String>{'p': '1'},
- expression: "const Key('t')",
- expectedResult: '''
- (function(p) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- var S = {ValueKey_value: dart.privateName(foo, "ValueKey.value")};
- const CT = Object.create(null);
- dart.defineLazy(CT, {
- get C0() {
- return C[0] = dart.const({
- __proto__: foo.ValueKey.prototype,
- [S.ValueKey_value]: "t"
- });
- }
- }, false);
- var C = [void 0];
- return C[0] || CT.C0;
- }(
- 1
- ))
- ''');
- });
- });
-
- group('Expression compiler tests in constructor:', () {
- var source = '''
- ${options.dartLangComment}
- extension NumberParsing on String {
- int parseInt() {
- return int.parse(this);
- }
- }
-
- int global = 42;
-
- class C {
- C(int this.field, int this._field) {
- int x = 1;
- /* evaluation placeholder */
- print(this.field);
- }
-
- static int staticField = 0;
- static int _staticField = 1;
-
- int _field;
- int field;
-
- int methodFieldAccess(int t) {
- return t + _field + _staticField;
- }
-
- Future<int> asyncMethod(int t) async {
- return t;
- }
- }
-
- main() => 0;
- ''';
-
- TestDriver driver;
-
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('compilation error', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'typo',
- expectedError:
- "The getter 'typo' isn't defined for the class 'C'");
- });
-
- test('local', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x',
- expectedResult: '''
- (function(x) {
- return x;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('this', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'this',
- expectedResult: '''
- (function(x) {
- return this;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using locals', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + 1',
- expectedResult: '''
- (function(x) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- return dart.notNull(x) + 1;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using static fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + staticField',
- expectedResult: '''
- (function(x) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return dart.notNull(x) + dart.notNull(foo.C.staticField);
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using private static fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + _staticField',
- expectedResult: '''
- (function(x) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return dart.notNull(x) + dart.notNull(foo.C._staticField);
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + field',
- expectedResult: '''
- (function(x) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- return dart.notNull(x) + dart.notNull(this.field);
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using private fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + _field',
- expectedResult: '''
- (function(x) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- var S = {_field\$1: dart.privateName(foo, "_field")};
- return dart.notNull(x) + dart.notNull(this[S._field\$1]);
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using globals', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + global',
- expectedResult: '''
- (function(x) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return dart.notNull(x) + dart.notNull(foo.global);
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('method call', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'methodFieldAccess(2)',
- expectedResult: '''
- (function(x) {
- return this.methodFieldAccess(2);
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('async method call', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'asyncMethod(2)',
- expectedResult: '''
- (function(x) {
- return this.asyncMethod(2);
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('extension method call', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: '"1234".parseInt()',
- expectedResult: '''
- (function(x) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo['NumberParsing|parseInt']("1234");
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('private field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: '_field = 2',
- expectedResult: '''
- (function(x) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- var S = {_field\$1: dart.privateName(foo, "_field")};
- return this[S._field\$1] = 2;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'field = 2',
- expectedResult: '''
- (function(x) {
- return this.field = 2;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('private static field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: '_staticField = 2',
- expectedResult: '''
- (function(x) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo.C._staticField = 2;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('static field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'staticField = 2',
- expectedResult: '''
- (function(x) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo.C.staticField = 2;
- }.bind(this)(
- 1
- ))
- ''');
- });
- });
-
- group('Expression compiler tests in simple loops:', () {
- var source = '''
- ${options.dartLangComment}
- int globalFunction() {
- int x = 15;
- var c = C(1, 2);
-
- for(int i = 0; i < 10; i++) {
- /* evaluation placeholder */
- print('\$i+\$x');
- };
- return 0;
- }
-
- main() => 0;
- ''';
-
- TestDriver driver;
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('expression using local', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null', 'i': '0'},
- expression: 'x',
- expectedResult: '''
- (function(x, c, i) {
- return x;
- }(
- 1,
- null,
- 0
- ))
- ''');
- });
-
- test('expression using loop variable', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null', 'i': '0'},
- expression: 'i',
- expectedResult: '''
- (function(x, c, i) {
- return i;
- }(
- 1,
- null,
- 0
- ))
- ''');
- });
- });
-
- group('Expression compiler tests in iterator loops:', () {
- var source = '''
- ${options.dartLangComment}
- int globalFunction() {
- var l = <String>['1', '2', '3'];
-
- for(var e in l) {
- /* evaluation placeholder */
- print(e);
- };
- return 0;
- }
-
- main() => 0;
- ''';
-
- TestDriver driver;
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('expression loop variable', () async {
- await driver.check(
- scope: <String, String>{'l': 'null', 'e': '1'},
- expression: 'e',
- expectedResult: '''
- (function(l, e) {
- return e;
- }(
- null,
- 1
- ))
- ''');
- });
- });
-
- group('Expression compiler tests in conditional (then):', () {
- var source = '''
- ${options.dartLangComment}
- int globalFunction() {
- int x = 1;
- var c = C(1, 2);
-
- if (x == 14) {
- int y = 3;
- /* evaluation placeholder */
- print('\$y+\$x');
- } else {
- int z = 3;
- print('\$z+\$x');
- }
- return 0;
- }
-
- main() => 0;
- ''';
-
- TestDriver driver;
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('expression using local', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null', 'y': '3'},
- expression: 'y',
- expectedResult: '''
- (function(x, c, y) {
- return y;
- }(
- 1,
- null,
- 3
- ))
- ''');
- });
-
- test('expression using local out of scope', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null', 'y': '3'},
- expression: 'z',
- expectedError: "Error: Getter not found: 'z'");
- });
- });
-
- group('Expression compiler tests in conditional (else):', () {
- var source = '''
- ${options.dartLangComment}
- int globalFunction() {
- int x = 1;
- var c = C(1, 2);
-
- if (x == 14) {
- int y = 3;
- print('\$y+\$x');
- } else {
- int z = 3;
- /* evaluation placeholder */
- print('\$z+\$x');
- }
- return 0;
- }
-
- main() => 0;
- ''';
-
- TestDriver driver;
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('expression using local', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null', 'z': '3'},
- expression: 'z',
- expectedResult: '''
- (function(x, c, z) {
- return z;
- }(
- 1,
- null,
- 3
- ))
- ''');
- });
-
- test('expression using local out of scope', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null', 'z': '3'},
- expression: 'y',
- expectedError: "Error: Getter not found: 'y'");
- });
- });
-
- group('Expression compiler tests after conditionals:', () {
- var source = '''
- ${options.dartLangComment}
- int globalFunction() {
- int x = 1;
- var c = C(1, 2);
-
- if (x == 14) {
- int y = 3;
- print('\$y+\$x');
- } else {
- int z = 3;
- print('\$z+\$x');
- }
- /* evaluation placeholder */
- return 0;
- }
-
- main() => 0;
- ''';
-
- TestDriver driver;
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('expression using local', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'x',
- expectedResult: '''
- (function(x, c) {
- return x;
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('expression using local out of scope', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'z',
- expectedError: "Error: Getter not found: 'z'");
- });
- });
-
group(
'Expression compiler tests for interactions with module containers:',
() {
@@ -2762,1111 +934,6 @@
});
});
- group('Expression compiler scope collection tests', () {
- var source = '''
- ${options.dartLangComment}
-
- class C {
- C(int this.field);
-
- int methodFieldAccess(int x) {
- var inScope = 1;
- {
- var innerInScope = global + staticField + field;
- /* evaluation placeholder */
- print(innerInScope);
- var innerNotInScope = 2;
- }
- var notInScope = 3;
- }
-
- static int staticField = 0;
- int field;
- }
-
- int global = 42;
- main() => 0;
- ''';
-
- TestDriver driver;
-
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('local in scope', () async {
- await driver.check(
- scope: <String, String>{'inScope': '1', 'innerInScope': '0'},
- expression: 'inScope',
- expectedResult: '''
- (function(inScope, innerInScope) {
- return inScope;
- }.bind(this)(
- 1,
- 0
- ))
- ''');
- });
-
- test('local in inner scope', () async {
- await driver.check(
- scope: <String, String>{'inScope': '1', 'innerInScope': '0'},
- expression: 'innerInScope',
- expectedResult: '''
- (function(inScope, innerInScope) {
- return innerInScope;
- }.bind(this)(
- 1,
- 0
- ))
- ''');
- });
-
- test('global in scope', () async {
- await driver.check(
- scope: <String, String>{'inScope': '1', 'innerInScope': '0'},
- expression: 'global',
- expectedResult: '''
- (function(inScope, innerInScope) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo.global;
- }.bind(this)(
- 1,
- 0
- ))
- ''');
- });
-
- test('static field in scope', () async {
- await driver.check(
- scope: <String, String>{'inScope': '1', 'innerInScope': '0'},
- expression: 'staticField',
- expectedResult: '''
- (function(inScope, innerInScope) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo.C.staticField;
- }.bind(this)(
- 1,
- 0
- ))
- ''');
- });
-
- test('field in scope', () async {
- await driver.check(
- scope: <String, String>{'inScope': '1', 'innerInScope': '0'},
- expression: 'field',
- expectedResult: '''
- (function(inScope, innerInScope) {
- return this.field;
- }.bind(this)(
- 1,
- 0
- ))
- ''');
- });
-
- test('local not in scope', () async {
- await driver.check(
- scope: <String, String>{'inScope': '1', 'innerInScope': '0'},
- expression: 'notInScope',
- expectedError:
- "Error: The getter 'notInScope' isn't defined for the class 'C'.");
- });
-
- test('local not in inner scope', () async {
- await driver.check(
- scope: <String, String>{'inScope': '1', 'innerInScope': '0'},
- expression: 'innerNotInScope',
- expectedError:
- "Error: The getter 'innerNotInScope' isn't defined for the class 'C'.");
- });
- });
-
- group('Expression compiler tests in extension method:', () {
- var source = '''
- ${options.dartLangComment}
- extension NumberParsing on String {
- int parseInt() {
- var ret = int.parse(this);
- /* evaluation placeholder */
- return ret;
- }
- }
- main() => 0;
- ''';
-
- TestDriver driver;
-
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('compilation error', () async {
- await driver.check(
- scope: <String, String>{'ret': '1234'},
- expression: 'typo',
- expectedError: "Error: Getter not found: 'typo'");
- });
-
- test('local (trimmed scope)', () async {
- // Test that current expression evaluation works in extension methods.
- //
- // Note: the actual scope is {#this, ret}, but #this is effectively
- // removed in the expression compilator because it does not exist
- // in JavaScript code.
- // See (full scope) tests for what will the evaluation will look like
- // when the mapping from dart symbols to JavaScipt symbols is added.
- await driver.check(
- scope: <String, String>{'ret': '1234'},
- expression: 'ret',
- expectedResult: '''
- (function(ret) {
- return ret;
- }(
- 1234
- ))
- ''');
- });
-
- test('local (full scope)', () async {
- // Test evalution in extension methods in the future when the mapping
- // from kernel symbols to dartdevc symbols is added.
- //
- // Note: this currently fails due to
- // - incremental compiler not allowing #this as a parameter name
- await driver.check(
- scope: <String, String>{'ret': '1234', '#this': 'this'},
- expression: 'ret',
- expectedError:
- "Illegal parameter name '#this' found during expression compilation.");
- });
-
- test('this (full scope)', () async {
- // Test evalution in extension methods in the future when the mapping
- // from kernel symbols to dartdevc symbols is added.
- //
- // Note: this currently fails due to
- // - incremental compiler not allowing #this as a parameter name
- // - incremental compiler not mapping 'this' from user input to '#this'
- await driver.check(
- scope: <String, String>{'ret': '1234', '#this': 'this'},
- expression: 'this',
- expectedError:
- "Illegal parameter name '#this' found during expression compilation.");
- });
- });
-
- group('Expression compiler tests in static function:', () {
- var source = '''
- ${options.dartLangComment}
- int foo(int x, {int y}) {
- int z = 0;
- /* evaluation placeholder */
- return x + y + z;
- }
-
- main() => 0;
- ''';
-
- TestDriver driver;
-
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('compilation error', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'y': '2', 'z': '3'},
- expression: 'typo',
- expectedError: "Getter not found: \'typo\'");
- });
-
- test('local', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'y': '2', 'z': '3'},
- expression: 'x',
- expectedResult: '''
- (function(x, y, z) {
- return x;
- }(
- 1,
- 2,
- 3
- ))
- ''');
- });
-
- test('formal', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'y': '2', 'z': '3'},
- expression: 'y',
- expectedResult: '''
- (function(x, y, z) {
- return y;
- }(
- 1,
- 2,
- 3
- ))
- ''');
- });
-
- test('named formal', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'y': '2', 'z': '3'},
- expression: 'z',
- expectedResult: '''
- (function(x, y, z) {
- return z;
- }(
- 1,
- 2,
- 3
- ))
- ''');
- });
-
- test('function', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'y': '2', 'z': '3'},
- expression: 'main',
- expectedResult: '''
- (function(x, y, z) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- var T = {
- VoidTodynamic: () => (T.VoidTodynamic = dart.constFn(dart.fnType(dart.dynamic, [])))()
- };
- const CT = Object.create(null);
- dart.defineLazy(CT, {
- get C0() {
- return C[0] = dart.fn(foo.main, T.VoidTodynamic());
- }
- }, false);
- var C = [void 0];
- return C[0] || CT.C0;
- }(
- 1,
- 2,
- 3
- ))
- ''');
- });
- });
-
- group('Expression compiler tests in method:', () {
- var source = '''
- ${options.dartLangComment}
- extension NumberParsing on String {
- int parseInt() {
- return int.parse(this);
- }
- }
-
- int global = 42;
-
- class C {
- C(int this.field, int this._field);
-
- static int staticField = 0;
- static int _staticField = 1;
-
- int _field;
- int field;
-
- int methodFieldAccess(int x) {
- /* evaluation placeholder */
- return x + _field + _staticField;
- }
-
- Future<int> asyncMethod(int x) async {
- return x;
- }
- }
-
- main() => 0;
- ''';
-
- TestDriver driver;
-
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('compilation error', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'typo',
- expectedError:
- "The getter 'typo' isn't defined for the class 'C'");
- });
-
- test('local', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x',
- expectedResult: '''
- (function(x) {
- return x;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('this', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'this',
- expectedResult: '''
- (function(x) {
- return this;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using locals', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + 1',
- expectedResult: '''
- (function(x) {
- return x + 1;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using static fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + staticField',
- expectedResult: '''
- (function(x) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return x + foo.C.staticField;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using private static fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + _staticField',
- expectedResult: '''
- (function(x) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return x + foo.C._staticField;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + field',
- expectedResult: '''
- (function(x) {
- return x + this.field;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using private fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + _field',
- expectedResult: '''
- (function(x) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- var S = {_field\$1: dart.privateName(foo, "_field")};
- return x + this[S._field\$1];
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using globals', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + global',
- expectedResult: '''
- (function(x) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return x + foo.global;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('method call', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'methodFieldAccess(2)',
- expectedResult: '''
- (function(x) {
- return this.methodFieldAccess(2);
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('async method call', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'asyncMethod(2)',
- expectedResult: '''
- (function(x) {
- return this.asyncMethod(2);
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('extension method call', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: '"1234".parseInt()',
- expectedResult: '''
- (function(x) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo['NumberParsing|parseInt']("1234");
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('private field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: '_field = 2',
- expectedResult: '''
- (function(x) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- var S = {_field\$1: dart.privateName(foo, "_field")};
- return this[S._field\$1] = 2;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'field = 2',
- expectedResult: '''
- (function(x) {
- return this.field = 2;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('private static field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: '_staticField = 2',
- expectedResult: '''
- (function(x) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo.C._staticField = 2;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('static field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'staticField = 2',
- expectedResult: '''
- (function(x) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo.C.staticField = 2;
- }.bind(this)(
- 1
- ))
- ''');
- });
- });
-
- group('Expression compiler tests in method with no field access:', () {
- var source = '''
- ${options.dartLangComment}
- extension NumberParsing on String {
- int parseInt() {
- return int.parse(this);
- }
- }
-
- int global = 42;
-
- class C {
- C(int this.field, int this._field);
-
- static int staticField = 0;
- static int _staticField = 1;
-
- int _field;
- int field;
-
- int methodNoFieldAccess(int x) {
- /* evaluation placeholder */
- return x;
- }
-
- Future<int> asyncMethod(int x) async {
- return x;
- }
- }
-
- main() => 0;
- ''';
-
- TestDriver driver;
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('compilation error', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'typo',
- expectedError:
- "The getter 'typo' isn't defined for the class 'C'");
- });
-
- test('expression using static fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + staticField',
- expectedResult: '''
- (function(x) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return x + foo.C.staticField;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using private static fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + _staticField',
- expectedResult: '''
- (function(x) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return x + foo.C._staticField;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + field',
- expectedResult: '''
- (function(x) {
- return x + this.field;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using private fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + _field',
- expectedResult: '''
- (function(x) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- var S = {_field\$1: dart.privateName(foo, "_field")};
- return x + this[S._field\$1];
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('private field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: '_field = 2',
- expectedResult: '''
- (function(x) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- var S = {_field\$1: dart.privateName(foo, "_field")};
- return this[S._field\$1] = 2;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'field = 2',
- expectedResult: '''
- (function(x) {
- return this.field = 2;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('private static field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: '_staticField = 2',
- expectedResult: '''
- (function(x) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo.C._staticField = 2;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('static field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'staticField = 2',
- expectedResult: '''
- (function(x) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo.C.staticField = 2;
- }.bind(this)(
- 1
- ))
- ''');
- });
- });
-
- group('Expression compiler tests in async method:', () {
- var source = '''
- ${options.dartLangComment}
- class C {
- C(int this.field, int this._field);
-
- int _field;
- int field;
-
- Future<int> asyncMethod(int x) async {
- /* evaluation placeholder */
- return x;
- }
- }
-
- main() => 0;
- ''';
-
- TestDriver driver;
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('compilation error', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'typo',
- expectedError:
- "The getter 'typo' isn't defined for the class 'C'");
- });
-
- test('local', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x',
- expectedResult: '''
- (function(x) {
- return x;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('this', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'this',
- expectedResult: '''
- (function(x) {
- return this;
- }.bind(this)(
- 1
- ))
- ''');
- });
- });
-
- group('Expression compiler tests in global function:', () {
- var source = '''
- ${options.dartLangComment}
- extension NumberParsing on String {
- int parseInt() {
- return int.parse(this);
- }
- }
-
- int global = 42;
-
- class C {
- C(int this.field, int this._field);
-
- static int staticField = 0;
- static int _staticField = 1;
-
- int _field;
- int field;
-
- int methodFieldAccess(int x) {
- return (x + _field + _staticField);
- }
- int methodFieldAccess(int x) {
- return (x)
- }
-
- Future<int> asyncMethod(int x) async {
- return x;
- }
- }
-
- int main() {
- int x = 15;
- var c = C(1, 2);
- /* evaluation placeholder */
- return 0;
- }
- ''';
-
- TestDriver driver;
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('compilation error', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'typo',
- expectedError: "Getter not found: 'typo'.");
- });
-
- test('local with primitive type', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'x',
- expectedResult: '''
- (function(x, c) {
- return x;
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('local object', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'c',
- expectedResult: '''
- (function(x, c) {
- return c;
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('create new object', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'C(1,3)',
- expectedResult: '''
- (function(x, c) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return new foo.C.new(1, 3);
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('access field of new object', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'C(1,3)._field',
- expectedResult: '''
- (function(x, c) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- var S = {_field\$1: dart.privateName(foo, "_field")};
- return new foo.C.new(1, 3)[S._field\$1];
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('access static field', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'C.staticField',
- expectedResult: '''
- (function(x, c) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo.C.staticField;
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('expression using private static fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'C._staticField',
- expectedError: "Error: Getter not found: '_staticField'.");
- });
-
- test('access field', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'c.field',
- expectedResult: '''
- (function(x, c) {
- return c.field;
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('access private field', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'c._field',
- expectedResult: '''
- (function(x, c) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- var S = {_field\$1: dart.privateName(foo, "_field")};
- return c[S._field\$1];
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('method call', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'c.methodFieldAccess(2)',
- expectedResult: '''
- (function(x, c) {
- return c.methodFieldAccess(2);
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('async method call', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'c.asyncMethod(2)',
- expectedResult: '''
- (function(x, c) {
- return c.asyncMethod(2);
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('extension method call', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: '"1234".parseInt()',
- expectedResult: '''
- (function(x, c) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo['NumberParsing|parseInt']("1234");
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('private field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'c._field = 2',
- expectedResult: '''
- (function(x, c) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- var S = {_field\$1: dart.privateName(foo, "_field")};
- return c[S._field\$1] = 2;
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'c.field = 2',
- expectedResult: '''
- (function(x, c) {
- return c.field = 2;
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('private static field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'C._staticField = 2',
- expectedError: "Setter not found: '_staticField'.");
- });
-
- test('static field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'C.staticField = 2',
- expectedResult: '''
- (function(x, c) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo.C.staticField = 2;
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('call global function from core library', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'print(x)',
- expectedResult: '''
- (function(x, c) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const core = dart_sdk.core;
- return core.print(x);
- }(
- 1,
- null
- ))
- ''');
- });
- });
-
group('Expression compiler tests in closures:', () {
var source = '''
${options.dartLangComment}
@@ -3954,699 +1021,6 @@
});
});
- group('Expression compiler tests in method with no type use:', () {
- var source = '''
- ${options.dartLangComment}
- abstract class Key {
- const factory Key(String value) = ValueKey;
- const Key.empty();
- }
-
- abstract class LocalKey extends Key {
- const LocalKey() : super.empty();
- }
-
- class ValueKey implements LocalKey {
- const ValueKey(this.value);
- final String value;
- }
-
- class MyClass {
- const MyClass(this._t);
- final int _t;
- }
-
- int bar(int p){
- return p;
- }
- int baz(String t){
- return t;
- }
- void main() {
- var k = Key('t');
- MyClass c = MyClass(0);
- int p = 1;
- const t = 1;
-
- /* evaluation placeholder */
- print('\$c, \$k, \$t');
- }
- ''';
-
- TestDriver driver;
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('call function not using type', () async {
- await driver.check(
- scope: <String, String>{'p': '1'},
- expression: 'bar(p)',
- expectedResult: '''
- (function(p) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo.bar(p);
- }(
- 1
- ))
- ''');
- });
-
- test('call function using type', () async {
- await driver.check(
- scope: <String, String>{'p': '0'},
- expression: 'baz(p as String)',
- expectedResult: '''
- (function(p) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const core = dart_sdk.core;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo.baz(core.String.as(p));
- }(
- 0
- ))
- ''');
- });
-
- test('evaluate new const expression', () async {
- await driver.check(
- scope: <String, String>{'p': '1'},
- expression: 'const MyClass(1)',
- expectedResult: '''
- (function(p) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- var S = {MyClass__t: dart.privateName(foo, "MyClass._t")};
- const CT = Object.create(null);
- dart.defineLazy(CT, {
- get C0() {
- return C[0] = dart.const({
- __proto__: foo.MyClass.prototype,
- [S.MyClass__t]: 1
- });
- }
- }, false);
- var C = [void 0];
- return C[0] || CT.C0;
- }(
- 1
- ))
- ''');
- });
-
- test('evaluate optimized const expression', () async {
- await driver.check(
- scope: <String, String>{},
- expression: 't',
- expectedResult: '''
- (function() {
- return 1;
- }(
- ))
- ''');
- },
- skip: 'Cannot compile constants optimized away by the frontend. '
- 'Issue: https://github.com/dart-lang/sdk/issues/41999');
-
- test('evaluate factory constructor call', () async {
- await driver.check(
- scope: <String, String>{'p': '1'},
- expression: "Key('t')",
- expectedResult: '''
- (function(p) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return new foo.ValueKey.new("t");
- }(
- 1
- ))
- ''');
- });
-
- test('evaluate const factory constructor call', () async {
- await driver.check(
- scope: <String, String>{'p': '1'},
- expression: "const Key('t')",
- expectedResult: '''
- (function(p) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- var S = {ValueKey_value: dart.privateName(foo, "ValueKey.value")};
- const CT = Object.create(null);
- dart.defineLazy(CT, {
- get C0() {
- return C[0] = dart.const({
- __proto__: foo.ValueKey.prototype,
- [S.ValueKey_value]: "t"
- });
- }
- }, false);
- var C = [void 0];
- return C[0] || CT.C0;
- }(
- 1
- ))
- ''');
- });
- });
-
- group('Expression compiler tests in constructor:', () {
- var source = '''
- ${options.dartLangComment}
- extension NumberParsing on String {
- int parseInt() {
- return int.parse(this);
- }
- }
-
- int global = 42;
-
- class C {
- C(int this.field, int this._field) {
- int x = 1;
- /* evaluation placeholder */
- print(this.field);
- }
-
- static int staticField = 0;
- static int _staticField = 1;
-
- int _field;
- int field;
-
- int methodFieldAccess(int t) {
- return t + _field + _staticField;
- }
-
- Future<int> asyncMethod(int t) async {
- return t;
- }
- }
-
- main() => 0;
- ''';
-
- TestDriver driver;
-
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('compilation error', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'typo',
- expectedError:
- "The getter 'typo' isn't defined for the class 'C'");
- });
-
- test('local', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x',
- expectedResult: '''
- (function(x) {
- return x;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('this', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'this',
- expectedResult: '''
- (function(x) {
- return this;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using locals', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + 1',
- expectedResult: '''
- (function(x) {
- return x + 1;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using static fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + staticField',
- expectedResult: '''
- (function(x) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return x + foo.C.staticField;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using private static fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + _staticField',
- expectedResult: '''
- (function(x) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return x + foo.C._staticField;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + field',
- expectedResult: '''
- (function(x) {
- return x + this.field;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using private fields', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + _field',
- expectedResult: '''
- (function(x) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- var S = {_field\$1: dart.privateName(foo, "_field")};
- return x + this[S._field\$1];
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('expression using globals', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'x + global',
- expectedResult: '''
- (function(x) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return x + foo.global;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('method call', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'methodFieldAccess(2)',
- expectedResult: '''
- (function(x) {
- return this.methodFieldAccess(2);
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('async method call', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'asyncMethod(2)',
- expectedResult: '''
- (function(x) {
- return this.asyncMethod(2);
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('extension method call', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: '"1234".parseInt()',
- expectedResult: '''
- (function(x) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo['NumberParsing|parseInt']("1234");
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('private field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: '_field = 2',
- expectedResult: '''
- (function(x) {
- const dart_sdk = ${options.loadModule}('dart_sdk');
- const dart = dart_sdk.dart;
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- var S = {_field\$1: dart.privateName(foo, "_field")};
- return this[S._field\$1] = 2;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'field = 2',
- expectedResult: '''
- (function(x) {
- return this.field = 2;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('private static field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: '_staticField = 2',
- expectedResult: '''
- (function(x) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo.C._staticField = 2;
- }.bind(this)(
- 1
- ))
- ''');
- });
-
- test('static field modification', () async {
- await driver.check(
- scope: <String, String>{'x': '1'},
- expression: 'staticField = 2',
- expectedResult: '''
- (function(x) {
- const foo\$46dart = ${options.loadModule}('foo.dart');
- const foo = foo\$46dart.foo;
- return foo.C.staticField = 2;
- }.bind(this)(
- 1
- ))
- ''');
- });
- });
-
- group('Expression compiler tests in loops:', () {
- var source = '''
- ${options.dartLangComment}
- int globalFunction() {
- int x = 15;
- var c = C(1, 2);
-
- for(int i = 0; i < 10; i++) {
- /* evaluation placeholder */
- print('\$i+\$x');
- };
- return 0;
- }
-
- main() => 0;
- ''';
-
- TestDriver driver;
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('expression using local', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null', 'i': '0'},
- expression: 'x',
- expectedResult: '''
- (function(x, c, i) {
- return x;
- }(
- 1,
- null,
- 0
- ))
- ''');
- });
-
- test('expression using loop variable', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null', 'i': '0'},
- expression: 'i',
- expectedResult: '''
- (function(x, c, i) {
- return i;
- }(
- 1,
- null,
- 0
- ))
- ''');
- });
- });
-
- group('Expression compiler tests in iterator loops:', () {
- var source = '''
- ${options.dartLangComment}
- int globalFunction() {
- var l = <String>['1', '2', '3'];
-
- for(var e in l) {
- /* evaluation placeholder */
- print(e);
- };
- return 0;
- }
-
- main() => 0;
- ''';
-
- TestDriver driver;
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('expression loop variable', () async {
- await driver.check(
- scope: <String, String>{'l': 'null', 'e': '1'},
- expression: 'e',
- expectedResult: '''
- (function(l, e) {
- return e;
- }(
- null,
- 1
- ))
- ''');
- });
- });
-
- group('Expression compiler tests in conditional (then):', () {
- var source = '''
- ${options.dartLangComment}
- int globalFunction() {
- int x = 1;
- var c = C(1, 2);
-
- if (x == 14) {
- int y = 3;
- /* evaluation placeholder */
- print('\$y+\$x');
- } else {
- int z = 3;
- print('\$z+\$x');
- }
- return 0;
- }
-
- main() => 0;
- ''';
-
- TestDriver driver;
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('expression using local', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null', 'y': '3'},
- expression: 'y',
- expectedResult: '''
- (function(x, c, y) {
- return y;
- }(
- 1,
- null,
- 3
- ))
- ''');
- });
-
- test('expression using local out of scope', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null', 'y': '3'},
- expression: 'z',
- expectedError: "Error: Getter not found: 'z'");
- });
- });
-
- group('Expression compiler tests in conditional (else):', () {
- var source = '''
- ${options.dartLangComment}
- int globalFunction() {
- int x = 1;
- var c = C(1, 2);
-
- if (x == 14) {
- int y = 3;
- print('\$y+\$x');
- } else {
- int z = 3;
- /* evaluation placeholder */
- print('\$z+\$x');
- }
- return 0;
- }
-
- main() => 0;
- ''';
-
- TestDriver driver;
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('expression using local', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null', 'z': '3'},
- expression: 'z',
- expectedResult: '''
- (function(x, c, z) {
- return z;
- }(
- 1,
- null,
- 3
- ))
- ''');
- });
-
- test('expression using local out of scope', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null', 'z': '3'},
- expression: 'y',
- expectedError: "Error: Getter not found: 'y'");
- });
- });
-
- group('Expression compiler tests after conditionals:', () {
- var source = '''
- ${options.dartLangComment}
- int globalFunction() {
- int x = 1;
- var c = C(1, 2);
-
- if (x == 14) {
- int y = 3;
- print('\$y+\$x');
- } else {
- int z = 3;
- print('\$z+\$x');
- }
- /* evaluation placeholder */
- return 0;
- }
-
- main() => 0;
- ''';
-
- TestDriver driver;
- setUp(() {
- driver = TestDriver(options, source);
- });
-
- tearDown(() {
- driver.delete();
- });
-
- test('expression using local', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'x',
- expectedResult: '''
- (function(x, c) {
- return x;
- }(
- 1,
- null
- ))
- ''');
- });
-
- test('expression using local out of scope', () async {
- await driver.check(
- scope: <String, String>{'x': '1', 'c': 'null'},
- expression: 'z',
- expectedError: "Error: Getter not found: 'z'");
- });
- });
-
group('Expression compiler tests in generic method:', () {
var source = '''
${options.dartLangComment}
diff --git a/pkg/test_runner/lib/src/command_output.dart b/pkg/test_runner/lib/src/command_output.dart
index 0f9738e..09134bb 100644
--- a/pkg/test_runner/lib/src/command_output.dart
+++ b/pkg/test_runner/lib/src/command_output.dart
@@ -551,18 +551,57 @@
class AnalysisCommandOutput extends CommandOutput with _StaticErrorOutput {
static void parseErrors(String stderr, List<StaticError> errors,
[List<StaticError> warnings]) {
- for (var error in AnalyzerError.parseStderr(stderr)) {
- var staticError = StaticError(ErrorSource.analyzer, error.errorCode,
- line: error.line, column: error.column, length: error.length);
+ var jsonData = json.decode(stderr) as Map<String, dynamic>;
+ var version = jsonData['version'];
+ if (version != 1) {
+ DebugLogger.error('Unexpected analyzer JSON data version: $version');
+ throw UnimplementedError();
+ }
+ for (var diagnostic in jsonData['diagnostics'] as List<dynamic>) {
+ var diagnosticMap = diagnostic as Map<String, dynamic>;
+ var location = diagnosticMap['location'] as Map<String, dynamic>;
+ var file = location['file'] as String;
+ var type = diagnosticMap['type'] as String;
+ var code = (diagnosticMap['code'] as String).toUpperCase();
+ var staticError =
+ _decodeStaticError(ErrorSource.analyzer, '$type.$code', location);
+ var contextMessages = diagnosticMap['contextMessages'] as List<dynamic>;
+ for (var contextMessage in contextMessages ?? const []) {
+ var contextMessageMap = contextMessage as Map<String, dynamic>;
+ var contextLocation =
+ contextMessageMap['location'] as Map<String, dynamic>;
+ if (contextLocation['file'] == file) {
+ staticError.contextMessages.add(_decodeStaticError(
+ ErrorSource.context,
+ contextMessageMap['message'] as String,
+ contextLocation));
+ } else {
+ DebugLogger.warning(
+ "Context messages in other files not currently supported.");
+ }
+ }
- if (error.severity == 'ERROR') {
+ var severity = diagnosticMap['severity'] as String;
+ if (severity == 'ERROR') {
errors.add(staticError);
- } else if (error.severity == 'WARNING') {
+ } else if (severity == 'WARNING') {
warnings?.add(staticError);
}
}
}
+ static StaticError _decodeStaticError(
+ ErrorSource errorSource, String message, Map<String, dynamic> location) {
+ var locationRange = location['range'] as Map<String, dynamic>;
+ var locationRangeStart = locationRange['start'] as Map<String, dynamic>;
+ var locationRangeEnd = locationRange['end'] as Map<String, dynamic>;
+ return StaticError(errorSource, message,
+ line: locationRangeStart['line'] as int,
+ column: locationRangeStart['column'] as int,
+ length: (locationRangeEnd['offset'] as int) -
+ (locationRangeStart['offset'] as int));
+ }
+
AnalysisCommandOutput(
Command command,
int exitCode,
@@ -584,6 +623,23 @@
if (hasTimedOut) return Expectation.timeout;
if (hasNonUtf8) return Expectation.nonUtf8Error;
+ List<StaticError> errors;
+ try {
+ errors = this.errors;
+ } catch (_) {
+ // This can happen in at least two scenarios:
+ // - The analyzer output was too long so it got truncated (so the
+ // resulting output was ill-formed). See also
+ // https://github.com/dart-lang/sdk/issues/44493.
+ // - The analyzer did not find a file to analyze at the specified
+ // location, so it generated the output "No dart files found at
+ // <path>.dart" (which is not valid JSON). See
+ // https://github.com/dart-lang/sdk/issues/45556.
+ // TODO(paulberry,rnystrom): remove this logic once the two above bugs are
+ // fixed.
+ return Expectation.crash;
+ }
+
// If it's a static error test, validate the exact errors.
if (testCase.testFile.isStaticErrorTest) {
return _validateExpectedErrors(testCase);
@@ -628,6 +684,23 @@
if (hasTimedOut) return Expectation.timeout;
if (hasNonUtf8) return Expectation.nonUtf8Error;
+ List<StaticError> errors;
+ try {
+ errors = this.errors;
+ } catch (_) {
+ // This can happen in at least two scenarios:
+ // - The analyzer output was too long so it got truncated (so the
+ // resulting output was ill-formed). See also
+ // https://github.com/dart-lang/sdk/issues/44493.
+ // - The analyzer did not find a file to analyze at the specified
+ // location, so it generated the output "No dart files found at
+ // <path>.dart" (which is not valid JSON). See
+ // https://github.com/dart-lang/sdk/issues/45556.
+ // TODO(paulberry,rnystrom): remove this logic once the two above bugs are
+ // fixed.
+ return Expectation.crash;
+ }
+
// If it's a static error test, validate the exact errors.
if (testCase.testFile.isStaticErrorTest) {
return _validateExpectedErrors(testCase);
@@ -1363,7 +1436,14 @@
// Handle static error test output specially. We don't want to show the raw
// stdout if we can give the user the parsed expectations instead.
if (testCase.testFile.isStaticErrorTest && !hasCrashed && !hasTimedOut) {
- _validateExpectedErrors(testCase, output);
+ try {
+ _validateExpectedErrors(testCase, output);
+ } catch (_) {
+ // In the event of a crash trying to compute errors, go ahead and give
+ // the raw output.
+ super.describe(testCase, progress, output);
+ return;
+ }
}
// Don't show the "raw" output unless something strange happened or the
diff --git a/pkg/test_runner/lib/src/test_suite.dart b/pkg/test_runner/lib/src/test_suite.dart
index c27f66b..1f9253f 100644
--- a/pkg/test_runner/lib/src/test_suite.dart
+++ b/pkg/test_runner/lib/src/test_suite.dart
@@ -980,7 +980,7 @@
}
args.addAll(additionalOptions(testFile.path));
if (configuration.compiler == Compiler.dart2analyzer) {
- args.add('--format=machine');
+ args.add('--format=json');
args.add('--no-hints');
}
diff --git a/pkg/test_runner/tool/update_static_error_tests.dart b/pkg/test_runner/tool/update_static_error_tests.dart
index ed9bad5..9758107 100644
--- a/pkg/test_runner/tool/update_static_error_tests.dart
+++ b/pkg/test_runner/tool/update_static_error_tests.dart
@@ -230,7 +230,7 @@
// mode.
var result = await Process.run(_analyzerPath, [
...options,
- "--format=machine",
+ "--format=json",
path,
]);
diff --git a/runtime/lib/regexp.cc b/runtime/lib/regexp.cc
index 3e0e337..6c10d7d 100644
--- a/runtime/lib/regexp.cc
+++ b/runtime/lib/regexp.cc
@@ -85,7 +85,7 @@
const RegExp& regexp = RegExp::CheckedHandle(zone, arguments->NativeArgAt(0));
ASSERT(!regexp.IsNull());
if (regexp.is_initialized()) {
- return regexp.num_bracket_expressions();
+ return Smi::New(regexp.num_bracket_expressions());
}
const String& pattern = String::Handle(regexp.pattern());
const String& errmsg =
diff --git a/runtime/vm/class_finalizer.cc b/runtime/vm/class_finalizer.cc
index 6073695..9d182ed 100644
--- a/runtime/vm/class_finalizer.cc
+++ b/runtime/vm/class_finalizer.cc
@@ -1432,10 +1432,10 @@
Map(param->untag()->parameterized_class_id_);
} else if (obj->IsType()) {
TypePtr type = Type::RawCast(obj);
- ObjectPtr id = type->untag()->type_class_id_;
+ ObjectPtr id = type->untag()->type_class_id();
if (!id->IsHeapObject()) {
- type->untag()->type_class_id_ =
- Smi::New(Map(Smi::Value(Smi::RawCast(id))));
+ type->untag()->set_type_class_id(
+ Smi::New(Map(Smi::Value(Smi::RawCast(id)))));
}
} else {
intptr_t old_cid = obj->GetClassId();
diff --git a/runtime/vm/clustered_snapshot.cc b/runtime/vm/clustered_snapshot.cc
index 4a63843..a94e18a 100644
--- a/runtime/vm/clustered_snapshot.cc
+++ b/runtime/vm/clustered_snapshot.cc
@@ -3804,12 +3804,12 @@
PushFromTo(type);
- if (type->untag()->type_class_id_->IsHeapObject()) {
+ if (type->untag()->type_class_id()->IsHeapObject()) {
// Type class is still an unresolved class.
UNREACHABLE();
}
- SmiPtr raw_type_class_id = Smi::RawCast(type->untag()->type_class_id_);
+ SmiPtr raw_type_class_id = Smi::RawCast(type->untag()->type_class_id());
ClassPtr type_class =
s->isolate_group()->class_table()->At(Smi::Value(raw_type_class_id));
s->Push(type_class);
@@ -3844,7 +3844,7 @@
// inserted into the canonical_types set.
// Keep in sync with Type::Canonicalize.
virtual bool IsInCanonicalSet(Serializer* s, TypePtr type) {
- SmiPtr raw_type_class_id = Smi::RawCast(type->untag()->type_class_id_);
+ SmiPtr raw_type_class_id = Smi::RawCast(type->untag()->type_class_id());
ClassPtr type_class =
s->isolate_group()->class_table()->At(Smi::Value(raw_type_class_id));
if (type_class->untag()->declaration_type() != type) {
@@ -4627,7 +4627,7 @@
TypedDataPtr data = objects_[i];
s->AssignRef(data);
AutoTraceObject(data);
- const intptr_t length = Smi::Value(data->untag()->length_);
+ const intptr_t length = Smi::Value(data->untag()->length());
s->WriteUnsigned(length);
target_memory_size_ +=
compiler::target::TypedData::InstanceSize(length * element_size);
@@ -4640,7 +4640,7 @@
for (intptr_t i = 0; i < count; i++) {
TypedDataPtr data = objects_[i];
AutoTraceObject(data);
- const intptr_t length = Smi::Value(data->untag()->length_);
+ const intptr_t length = Smi::Value(data->untag()->length());
s->WriteUnsigned(length);
uint8_t* cdata = reinterpret_cast<uint8_t*>(data->untag()->data());
s->WriteBytes(cdata, length * element_size);
@@ -4805,7 +4805,7 @@
for (intptr_t i = 0; i < count; i++) {
ExternalTypedDataPtr data = objects_[i];
AutoTraceObject(data);
- const intptr_t length = Smi::Value(data->untag()->length_);
+ const intptr_t length = Smi::Value(data->untag()->length());
s->WriteUnsigned(length);
uint8_t* cdata = reinterpret_cast<uint8_t*>(data->untag()->data_);
s->Align(ExternalTypedData::kDataSerializationAlignment);
@@ -5296,7 +5296,7 @@
OneByteStringPtr str = objects_[i];
s->AssignRef(str);
AutoTraceObject(str);
- const intptr_t length = Smi::Value(str->untag()->length_);
+ const intptr_t length = Smi::Value(str->untag()->length());
s->WriteUnsigned(length);
target_memory_size_ +=
compiler::target::OneByteString::InstanceSize(length);
@@ -5308,7 +5308,7 @@
for (intptr_t i = 0; i < count; i++) {
OneByteStringPtr str = objects_[i];
AutoTraceObject(str);
- const intptr_t length = Smi::Value(str->untag()->length_);
+ const intptr_t length = Smi::Value(str->untag()->length());
ASSERT(length <= compiler::target::kSmiMax);
s->WriteUnsigned(length);
s->WriteBytes(str->untag()->data(), length);
@@ -5406,7 +5406,7 @@
TwoByteStringPtr str = objects_[i];
s->AssignRef(str);
AutoTraceObject(str);
- const intptr_t length = Smi::Value(str->untag()->length_);
+ const intptr_t length = Smi::Value(str->untag()->length());
s->WriteUnsigned(length);
target_memory_size_ +=
compiler::target::TwoByteString::InstanceSize(length);
@@ -5418,7 +5418,7 @@
for (intptr_t i = 0; i < count; i++) {
TwoByteStringPtr str = objects_[i];
AutoTraceObject(str);
- const intptr_t length = Smi::Value(str->untag()->length_);
+ const intptr_t length = Smi::Value(str->untag()->length());
ASSERT(length <= (compiler::target::kSmiMax / 2));
s->WriteUnsigned(length);
s->WriteBytes(reinterpret_cast<uint8_t*>(str->untag()->data()),
diff --git a/runtime/vm/compiler/asm_intrinsifier_arm64.cc b/runtime/vm/compiler/asm_intrinsifier_arm64.cc
index eede391..91c8e54 100644
--- a/runtime/vm/compiler/asm_intrinsifier_arm64.cc
+++ b/runtime/vm/compiler/asm_intrinsifier_arm64.cc
@@ -1457,7 +1457,7 @@
void AsmIntrinsifier::Type_getHashCode(Assembler* assembler,
Label* normal_ir_body) {
__ ldr(R0, Address(SP, 0 * target::kWordSize));
- __ ldr(R0, FieldAddress(R0, target::Type::hash_offset()));
+ __ LoadCompressed(R0, FieldAddress(R0, target::Type::hash_offset()));
__ cbz(normal_ir_body, R0);
__ ret();
// Hash not yet computed.
@@ -1479,9 +1479,11 @@
__ b(normal_ir_body, NE);
// Check if types are syntactically equal.
- __ ldr(R3, FieldAddress(R1, target::Type::type_class_id_offset()));
+ __ LoadCompressedSmi(R3,
+ FieldAddress(R1, target::Type::type_class_id_offset()));
__ SmiUntag(R3);
- __ ldr(R4, FieldAddress(R2, target::Type::type_class_id_offset()));
+ __ LoadCompressedSmi(R4,
+ FieldAddress(R2, target::Type::type_class_id_offset()));
__ SmiUntag(R4);
EquivalentClassIds(assembler, normal_ir_body, &equiv_cids, ¬_equal, R3, R4,
R0);
@@ -1521,7 +1523,7 @@
void AsmIntrinsifier::FunctionType_getHashCode(Assembler* assembler,
Label* normal_ir_body) {
__ ldr(R0, Address(SP, 0 * target::kWordSize));
- __ ldr(R0, FieldAddress(R0, target::FunctionType::hash_offset()));
+ __ LoadCompressed(R0, FieldAddress(R0, target::FunctionType::hash_offset()));
__ cbz(normal_ir_body, R0);
__ ret();
// Hash not yet computed.
@@ -1572,10 +1574,11 @@
Label* return_true,
Label* return_false) {
__ SmiUntag(R1);
- __ ldr(R8, FieldAddress(R0, target::String::length_offset())); // this.length
+ __ LoadCompressedSmi(
+ R8, FieldAddress(R0, target::String::length_offset())); // this.length
__ SmiUntag(R8);
- __ ldr(R9,
- FieldAddress(R2, target::String::length_offset())); // other.length
+ __ LoadCompressedSmi(
+ R9, FieldAddress(R2, target::String::length_offset())); // other.length
__ SmiUntag(R9);
// if (other.length == 0) return true;
@@ -1682,7 +1685,7 @@
__ ldr(R0, Address(SP, 1 * target::kWordSize)); // String.
__ BranchIfNotSmi(R1, normal_ir_body); // Index is not a Smi.
// Range check.
- __ ldr(R2, FieldAddress(R0, target::String::length_offset()));
+ __ LoadCompressedSmi(R2, FieldAddress(R0, target::String::length_offset()));
__ cmp(R1, Operand(R2));
__ b(normal_ir_body, CS); // Runtime throws exception.
@@ -1719,7 +1722,7 @@
void AsmIntrinsifier::StringBaseIsEmpty(Assembler* assembler,
Label* normal_ir_body) {
__ ldr(R0, Address(SP, 0 * target::kWordSize));
- __ ldr(R0, FieldAddress(R0, target::String::length_offset()));
+ __ LoadCompressedSmi(R0, FieldAddress(R0, target::String::length_offset()));
__ cmp(R0, Operand(target::ToRawSmi(0)), kObjectBytes);
__ LoadObject(R0, CastHandle<Object>(TrueObject()));
__ LoadObject(TMP, CastHandle<Object>(FalseObject()));
@@ -1738,7 +1741,7 @@
__ ret(); // Return if already computed.
__ Bind(&compute_hash);
- __ ldr(R2, FieldAddress(R1, target::String::length_offset()));
+ __ LoadCompressedSmi(R2, FieldAddress(R1, target::String::length_offset()));
__ SmiUntag(R2);
Label done;
@@ -1873,7 +1876,7 @@
}
// Set the length field using the saved length (R6).
- __ StoreIntoObjectNoBarrier(
+ __ StoreCompressedIntoObjectNoBarrier(
R0, FieldAddress(R0, target::String::length_offset()), R6);
__ b(ok);
}
@@ -2008,8 +2011,8 @@
__ b(normal_ir_body, NE);
// Have same length?
- __ ldr(R2, FieldAddress(R0, target::String::length_offset()));
- __ ldr(R3, FieldAddress(R1, target::String::length_offset()));
+ __ LoadCompressedSmi(R2, FieldAddress(R0, target::String::length_offset()));
+ __ LoadCompressedSmi(R3, FieldAddress(R1, target::String::length_offset()));
__ CompareObjectRegisters(R2, R3);
__ b(&is_false, NE);
@@ -2085,9 +2088,13 @@
__ ldr(R1, Address(SP, kStringParamOffset));
__ LoadClassId(R1, R1);
__ AddImmediate(R1, -kOneByteStringCid);
+#if !defined(DART_COMPRESSED_POINTERS)
__ add(R1, R2, Operand(R1, LSL, target::kWordSizeLog2));
- __ ldr(R0, FieldAddress(R1, target::RegExp::function_offset(kOneByteStringCid,
- sticky)));
+#else
+ __ add(R1, R2, Operand(R1, LSL, target::kWordSizeLog2 - 1));
+#endif
+ __ LoadCompressed(R0, FieldAddress(R1, target::RegExp::function_offset(
+ kOneByteStringCid, sticky)));
// Registers are now set up for the lazy compile stub. It expects the function
// in R0, the argument descriptor in R4, and IC-Data in R5.
diff --git a/runtime/vm/compiler/asm_intrinsifier_x64.cc b/runtime/vm/compiler/asm_intrinsifier_x64.cc
index cf4fcb3..c47d307 100644
--- a/runtime/vm/compiler/asm_intrinsifier_x64.cc
+++ b/runtime/vm/compiler/asm_intrinsifier_x64.cc
@@ -1308,7 +1308,7 @@
void AsmIntrinsifier::Type_getHashCode(Assembler* assembler,
Label* normal_ir_body) {
__ movq(RAX, Address(RSP, +1 * target::kWordSize)); // Type object.
- __ movq(RAX, FieldAddress(RAX, target::Type::hash_offset()));
+ __ LoadCompressed(RAX, FieldAddress(RAX, target::Type::hash_offset()));
ASSERT(kSmiTag == 0);
ASSERT(kSmiTagShift == 1);
__ testq(RAX, RAX);
@@ -1334,9 +1334,11 @@
__ j(NOT_EQUAL, normal_ir_body);
// Check if types are syntactically equal.
- __ movq(RDI, FieldAddress(RCX, target::Type::type_class_id_offset()));
+ __ LoadCompressedSmi(RDI,
+ FieldAddress(RCX, target::Type::type_class_id_offset()));
__ SmiUntag(RDI);
- __ movq(RSI, FieldAddress(RDX, target::Type::type_class_id_offset()));
+ __ LoadCompressedSmi(RSI,
+ FieldAddress(RDX, target::Type::type_class_id_offset()));
__ SmiUntag(RSI);
EquivalentClassIds(assembler, normal_ir_body, &equiv_cids, ¬_equal, RDI,
RSI, RAX);
@@ -1374,7 +1376,8 @@
void AsmIntrinsifier::FunctionType_getHashCode(Assembler* assembler,
Label* normal_ir_body) {
__ movq(RAX, Address(RSP, +1 * target::kWordSize)); // FunctionType object.
- __ movq(RAX, FieldAddress(RAX, target::FunctionType::hash_offset()));
+ __ LoadCompressed(RAX,
+ FieldAddress(RAX, target::FunctionType::hash_offset()));
ASSERT(kSmiTag == 0);
ASSERT(kSmiTagShift == 1);
__ testq(RAX, RAX);
@@ -1423,9 +1426,9 @@
Label* return_true,
Label* return_false) {
__ SmiUntag(RBX);
- __ movq(R8, FieldAddress(RAX, target::String::length_offset()));
+ __ LoadCompressedSmi(R8, FieldAddress(RAX, target::String::length_offset()));
__ SmiUntag(R8);
- __ movq(R9, FieldAddress(RCX, target::String::length_offset()));
+ __ LoadCompressedSmi(R9, FieldAddress(RCX, target::String::length_offset()));
__ SmiUntag(R9);
// if (other.length == 0) return true;
@@ -1530,7 +1533,7 @@
__ testq(RCX, Immediate(kSmiTagMask));
__ j(NOT_ZERO, normal_ir_body); // Non-smi index.
// Range check.
- __ cmpq(RCX, FieldAddress(RAX, target::String::length_offset()));
+ __ OBJ(cmp)(RCX, FieldAddress(RAX, target::String::length_offset()));
// Runtime throws exception.
__ j(ABOVE_EQUAL, normal_ir_body);
__ CompareClassId(RAX, kOneByteStringCid);
@@ -1570,7 +1573,7 @@
Label is_true;
// Get length.
__ movq(RAX, Address(RSP, +1 * target::kWordSize)); // String object.
- __ movq(RAX, FieldAddress(RAX, target::String::length_offset()));
+ __ LoadCompressedSmi(RAX, FieldAddress(RAX, target::String::length_offset()));
__ OBJ(cmp)(RAX, Immediate(target::ToRawSmi(0)));
__ j(EQUAL, &is_true, Assembler::kNearJump);
__ LoadObject(RAX, CastHandle<Object>(FalseObject()));
@@ -1594,7 +1597,7 @@
__ Bind(&compute_hash);
// Hash not yet computed, use algorithm of class StringHasher.
- __ movq(RCX, FieldAddress(RBX, target::String::length_offset()));
+ __ LoadCompressedSmi(RCX, FieldAddress(RBX, target::String::length_offset()));
__ SmiUntag(RCX);
__ xorq(RAX, RAX);
__ xorq(RDI, RDI);
@@ -1736,7 +1739,7 @@
// Set the length field.
__ popq(RDI);
- __ StoreIntoObjectNoBarrier(
+ __ StoreCompressedIntoObjectNoBarrier(
RAX, FieldAddress(RAX, target::String::length_offset()), RDI);
__ jmp(ok, Assembler::kNearJump);
@@ -1865,7 +1868,7 @@
__ j(NOT_EQUAL, normal_ir_body, Assembler::kNearJump);
// Have same length?
- __ movq(RDI, FieldAddress(RAX, target::String::length_offset()));
+ __ LoadCompressedSmi(RDI, FieldAddress(RAX, target::String::length_offset()));
__ OBJ(cmp)(RDI, FieldAddress(RCX, target::String::length_offset()));
__ j(NOT_EQUAL, &is_false, Assembler::kNearJump);
@@ -1934,9 +1937,15 @@
__ movq(RDI, Address(RSP, kStringParamOffset));
__ LoadClassId(RDI, RDI);
__ SubImmediate(RDI, Immediate(kOneByteStringCid));
+#if !defined(DART_COMPRESSED_POINTERS)
__ movq(RAX, FieldAddress(
RBX, RDI, TIMES_8,
target::RegExp::function_offset(kOneByteStringCid, sticky)));
+#else
+ __ LoadCompressed(RAX, FieldAddress(RBX, RDI, TIMES_4,
+ target::RegExp::function_offset(
+ kOneByteStringCid, sticky)));
+#endif
// Registers are now set up for the lazy compile stub. It expects the function
// in RAX, the argument descriptor in R10, and IC-Data in RCX.
diff --git a/runtime/vm/compiler/assembler/assembler_arm.h b/runtime/vm/compiler/assembler/assembler_arm.h
index 3a221a5..68bcae0 100644
--- a/runtime/vm/compiler/assembler/assembler_arm.h
+++ b/runtime/vm/compiler/assembler/assembler_arm.h
@@ -389,6 +389,9 @@
void Jump(const Address& address) { Branch(address); }
void LoadField(Register dst, FieldAddress address) { ldr(dst, address); }
+ void LoadCompressedField(Register dst, FieldAddress address) {
+ LoadField(dst, address);
+ }
void LoadMemoryValue(Register dst, Register base, int32_t offset) {
LoadFromOffset(dst, base, offset);
}
@@ -1026,6 +1029,9 @@
void PopNativeCalleeSavedRegisters();
void CompareRegisters(Register rn, Register rm) { cmp(rn, Operand(rm)); }
+ void CompareObjectRegisters(Register rn, Register rm) {
+ CompareRegisters(rn, rm);
+ }
// Branches to the given label if the condition holds.
// [distance] is ignored on ARM.
void BranchIf(Condition condition,
diff --git a/runtime/vm/compiler/assembler/assembler_arm64.cc b/runtime/vm/compiler/assembler/assembler_arm64.cc
index ff0820b..c54c816 100644
--- a/runtime/vm/compiler/assembler/assembler_arm64.cc
+++ b/runtime/vm/compiler/assembler/assembler_arm64.cc
@@ -924,9 +924,7 @@
vmuls(vd, vd, VTMP);
}
-void Assembler::LoadCompressed(Register dest,
- const Address& slot,
- CanBeSmi can_value_be_smi) {
+void Assembler::LoadCompressed(Register dest, const Address& slot) {
#if !defined(DART_COMPRESSED_POINTERS)
ldr(dest, slot);
#else
@@ -935,6 +933,20 @@
#endif
}
+void Assembler::LoadCompressedSmi(Register dest, const Address& slot) {
+#if !defined(DART_COMPRESSED_POINTERS)
+ ldr(dest, slot);
+#else
+ ldr(dest, slot, kUnsignedFourBytes); // Zero-extension.
+#endif
+#if defined(DEBUG)
+ Label done;
+ BranchIfSmi(dest, &done);
+ Stop("Expected Smi");
+ Bind(&done);
+#endif
+}
+
// Preserves object and value registers.
void Assembler::StoreIntoObjectFilter(Register object,
Register value,
@@ -985,10 +997,38 @@
}
}
+void Assembler::StoreCompressedIntoObjectOffset(Register object,
+ int32_t offset,
+ Register value,
+ CanBeSmi value_can_be_smi) {
+ if (Address::CanHoldOffset(offset - kHeapObjectTag)) {
+ StoreCompressedIntoObject(object, FieldAddress(object, offset), value,
+ value_can_be_smi);
+ } else {
+ AddImmediate(TMP, object, offset - kHeapObjectTag);
+ StoreCompressedIntoObject(object, Address(TMP), value, value_can_be_smi);
+ }
+}
+
void Assembler::StoreIntoObject(Register object,
const Address& dest,
Register value,
CanBeSmi can_be_smi) {
+ str(value, dest);
+ StoreBarrier(object, value, can_be_smi);
+}
+
+void Assembler::StoreCompressedIntoObject(Register object,
+ const Address& dest,
+ Register value,
+ CanBeSmi can_be_smi) {
+ str(value, dest, kObjectBytes);
+ StoreBarrier(object, value, can_be_smi);
+}
+
+void Assembler::StoreBarrier(Register object,
+ Register value,
+ CanBeSmi can_be_smi) {
const bool spill_lr = lr_state().LRContainsReturnAddress();
// x.slot = x. Barrier should have be removed at the IL level.
ASSERT(object != value);
@@ -999,8 +1039,6 @@
ASSERT(value != TMP);
ASSERT(value != TMP2);
- str(value, dest);
-
// In parallel, test whether
// - object is old and not remembered and value is new, or
// - object is old and value is old and not marked and concurrent marking is
@@ -1124,6 +1162,25 @@
// No store buffer update.
}
+void Assembler::StoreCompressedIntoObjectNoBarrier(Register object,
+ const Address& dest,
+ Register value) {
+ str(value, dest, kObjectBytes);
+#if defined(DEBUG)
+ Label done;
+ StoreIntoObjectFilter(object, value, &done, kValueCanBeSmi, kJumpToNoUpdate);
+
+ ldr(TMP, FieldAddress(object, target::Object::tags_offset(), kByte),
+ kUnsignedByte);
+ tsti(TMP, Immediate(1 << target::UntaggedObject::kOldAndNotRememberedBit));
+ b(&done, ZERO);
+
+ Stop("Store buffer update is required");
+ Bind(&done);
+#endif // defined(DEBUG)
+ // No store buffer update.
+}
+
void Assembler::StoreIntoObjectOffsetNoBarrier(Register object,
int32_t offset,
Register value) {
@@ -1135,6 +1192,18 @@
}
}
+void Assembler::StoreCompressedIntoObjectOffsetNoBarrier(Register object,
+ int32_t offset,
+ Register value) {
+ if (Address::CanHoldOffset(offset - kHeapObjectTag)) {
+ StoreCompressedIntoObjectNoBarrier(object, FieldAddress(object, offset),
+ value);
+ } else {
+ AddImmediate(TMP, object, offset - kHeapObjectTag);
+ StoreCompressedIntoObjectNoBarrier(object, Address(TMP), value);
+ }
+}
+
void Assembler::StoreIntoObjectNoBarrier(Register object,
const Address& dest,
const Object& value) {
@@ -1149,6 +1218,20 @@
}
}
+void Assembler::StoreCompressedIntoObjectNoBarrier(Register object,
+ const Address& dest,
+ const Object& value) {
+ ASSERT(IsOriginalObject(value));
+ ASSERT(IsNotTemporaryScopedHandle(value));
+ // No store buffer update.
+ if (IsSameObject(compiler::NullObject(), value)) {
+ str(NULL_REG, dest, kObjectBytes);
+ } else {
+ LoadObject(TMP2, value);
+ str(TMP2, dest, kObjectBytes);
+ }
+}
+
void Assembler::StoreIntoObjectOffsetNoBarrier(Register object,
int32_t offset,
const Object& value) {
@@ -1160,6 +1243,18 @@
}
}
+void Assembler::StoreCompressedIntoObjectOffsetNoBarrier(Register object,
+ int32_t offset,
+ const Object& value) {
+ if (Address::CanHoldOffset(offset - kHeapObjectTag)) {
+ StoreCompressedIntoObjectNoBarrier(object, FieldAddress(object, offset),
+ value);
+ } else {
+ AddImmediate(TMP, object, offset - kHeapObjectTag);
+ StoreCompressedIntoObjectNoBarrier(object, Address(TMP), value);
+ }
+}
+
void Assembler::StoreInternalPointer(Register object,
const Address& dest,
Register value) {
diff --git a/runtime/vm/compiler/assembler/assembler_arm64.h b/runtime/vm/compiler/assembler/assembler_arm64.h
index 1682a69..fdfe351 100644
--- a/runtime/vm/compiler/assembler/assembler_arm64.h
+++ b/runtime/vm/compiler/assembler/assembler_arm64.h
@@ -547,6 +547,9 @@
}
void LoadField(Register dst, FieldAddress address) { ldr(dst, address); }
+ void LoadCompressedField(Register dst, FieldAddress address) {
+ LoadCompressed(dst, address);
+ }
void LoadMemoryValue(Register dst, Register base, int32_t offset) {
LoadFromOffset(dst, base, offset, kEightBytes);
}
@@ -1744,9 +1747,8 @@
kValueCanBeSmi,
};
- void LoadCompressed(Register dest,
- const Address& slot,
- CanBeSmi can_value_be_smi = kValueCanBeSmi);
+ void LoadCompressed(Register dest, const Address& slot);
+ void LoadCompressedSmi(Register dest, const Address& slot);
// Store into a heap object and apply the generational and incremental write
// barriers. All stores into heap objects must pass through this function or,
@@ -1757,6 +1759,11 @@
const Address& dest,
Register value,
CanBeSmi can_value_be_smi = kValueCanBeSmi);
+ void StoreCompressedIntoObject(Register object,
+ const Address& dest,
+ Register value,
+ CanBeSmi can_value_be_smi = kValueCanBeSmi);
+ void StoreBarrier(Register object, Register value, CanBeSmi can_value_be_smi);
void StoreIntoArray(Register object,
Register slot,
Register value,
@@ -1766,18 +1773,35 @@
int32_t offset,
Register value,
CanBeSmi can_value_be_smi = kValueCanBeSmi);
+ void StoreCompressedIntoObjectOffset(
+ Register object,
+ int32_t offset,
+ Register value,
+ CanBeSmi can_value_be_smi = kValueCanBeSmi);
void StoreIntoObjectNoBarrier(Register object,
const Address& dest,
Register value);
+ void StoreCompressedIntoObjectNoBarrier(Register object,
+ const Address& dest,
+ Register value);
void StoreIntoObjectOffsetNoBarrier(Register object,
int32_t offset,
Register value);
+ void StoreCompressedIntoObjectOffsetNoBarrier(Register object,
+ int32_t offset,
+ Register value);
void StoreIntoObjectNoBarrier(Register object,
const Address& dest,
const Object& value);
+ void StoreCompressedIntoObjectNoBarrier(Register object,
+ const Address& dest,
+ const Object& value);
void StoreIntoObjectOffsetNoBarrier(Register object,
int32_t offset,
const Object& value);
+ void StoreCompressedIntoObjectOffsetNoBarrier(Register object,
+ int32_t offset,
+ const Object& value);
// Stores a non-tagged value into a heap object.
void StoreInternalPointer(Register object,
diff --git a/runtime/vm/compiler/assembler/assembler_ia32.h b/runtime/vm/compiler/assembler/assembler_ia32.h
index fecfe5a1..a46152c 100644
--- a/runtime/vm/compiler/assembler/assembler_ia32.h
+++ b/runtime/vm/compiler/assembler/assembler_ia32.h
@@ -572,6 +572,9 @@
void Ret() { ret(); }
void CompareRegisters(Register a, Register b);
+ void CompareObjectRegisters(Register a, Register b) {
+ CompareRegisters(a, b);
+ }
void BranchIf(Condition condition,
Label* label,
JumpDistance distance = kFarJump) {
@@ -599,6 +602,9 @@
OperandSize sz = kFourBytes) {
LoadFromOffset(dst, address, sz);
}
+ void LoadCompressedField(Register dst, const FieldAddress& address) {
+ LoadField(dst, address);
+ }
void LoadFieldFromOffset(Register reg,
Register base,
int32_t offset,
@@ -607,9 +613,8 @@
}
void LoadCompressedFieldFromOffset(Register reg,
Register base,
- int32_t offset,
- OperandSize sz = kFourBytes) {
- LoadFieldFromOffset(reg, base, offset, sz);
+ int32_t offset) {
+ LoadFieldFromOffset(reg, base, offset);
}
void LoadIndexedPayload(Register dst,
Register base,
diff --git a/runtime/vm/compiler/assembler/assembler_x64.cc b/runtime/vm/compiler/assembler/assembler_x64.cc
index d1ab4a7..274a5d8 100644
--- a/runtime/vm/compiler/assembler/assembler_x64.cc
+++ b/runtime/vm/compiler/assembler/assembler_x64.cc
@@ -1360,9 +1360,7 @@
}
}
-void Assembler::LoadCompressed(Register dest,
- const Address& slot,
- CanBeSmi can_value_be_smi) {
+void Assembler::LoadCompressed(Register dest, const Address& slot) {
#if !defined(DART_COMPRESSED_POINTERS)
movq(dest, slot);
#else
@@ -1371,6 +1369,20 @@
#endif
}
+void Assembler::LoadCompressedSmi(Register dest, const Address& slot) {
+#if !defined(DART_COMPRESSED_POINTERS)
+ movq(dest, slot);
+#else
+ movl(dest, slot); // Zero-extension.
+#endif
+#if defined(DEBUG)
+ Label done;
+ BranchIfSmi(dest, &done);
+ Stop("Expected Smi");
+ Bind(&done);
+#endif
+}
+
// Destroys the value register.
void Assembler::StoreIntoObjectFilter(Register object,
Register value,
@@ -1413,13 +1425,26 @@
const Address& dest,
Register value,
CanBeSmi can_be_smi) {
+ movq(dest, value);
+ StoreBarrier(object, value, can_be_smi);
+}
+
+void Assembler::StoreCompressedIntoObject(Register object,
+ const Address& dest,
+ Register value,
+ CanBeSmi can_be_smi) {
+ OBJ(mov)(dest, value);
+ StoreBarrier(object, value, can_be_smi);
+}
+
+void Assembler::StoreBarrier(Register object,
+ Register value,
+ CanBeSmi can_be_smi) {
// x.slot = x. Barrier should have be removed at the IL level.
ASSERT(object != value);
ASSERT(object != TMP);
ASSERT(value != TMP);
- movq(dest, value);
-
// In parallel, test whether
// - object is old and not remembered and value is new, or
// - object is old and value is old and not marked and concurrent marking is
@@ -1523,12 +1548,39 @@
// No store buffer update.
}
+void Assembler::StoreCompressedIntoObjectNoBarrier(Register object,
+ const Address& dest,
+ Register value) {
+ OBJ(mov)(dest, value);
+#if defined(DEBUG)
+ Label done;
+ pushq(value);
+ StoreIntoObjectFilter(object, value, &done, kValueCanBeSmi, kJumpToNoUpdate);
+
+ testb(FieldAddress(object, target::Object::tags_offset()),
+ Immediate(1 << target::UntaggedObject::kOldAndNotRememberedBit));
+ j(ZERO, &done, Assembler::kNearJump);
+
+ Stop("Store buffer update is required");
+ Bind(&done);
+ popq(value);
+#endif // defined(DEBUG)
+ // No store buffer update.
+}
+
void Assembler::StoreIntoObjectNoBarrier(Register object,
const Address& dest,
const Object& value) {
StoreObject(dest, value);
}
+void Assembler::StoreCompressedIntoObjectNoBarrier(Register object,
+ const Address& dest,
+ const Object& value) {
+ LoadObject(TMP, value);
+ StoreCompressedIntoObjectNoBarrier(object, dest, TMP);
+}
+
void Assembler::StoreInternalPointer(Register object,
const Address& dest,
Register value) {
@@ -1551,6 +1603,11 @@
movq(dest, zero);
}
+void Assembler::ZeroInitCompressedSmiField(const Address& dest) {
+ Immediate zero(target::ToRawSmi(0));
+ OBJ(mov)(dest, zero);
+}
+
void Assembler::IncrementSmiField(const Address& dest, int64_t increment) {
// Note: FlowGraphCompiler::EdgeCounterIncrementSizeInBytes depends on
// the length of this instruction sequence.
diff --git a/runtime/vm/compiler/assembler/assembler_x64.h b/runtime/vm/compiler/assembler/assembler_x64.h
index a855106..75822c0 100644
--- a/runtime/vm/compiler/assembler/assembler_x64.h
+++ b/runtime/vm/compiler/assembler/assembler_x64.h
@@ -782,9 +782,8 @@
kValueCanBeSmi,
};
- void LoadCompressed(Register dest,
- const Address& slot,
- CanBeSmi can_value_be_smi = kValueCanBeSmi);
+ void LoadCompressed(Register dest, const Address& slot);
+ void LoadCompressedSmi(Register dest, const Address& slot);
// Store into a heap object and apply the generational and incremental write
// barriers. All stores into heap objects must pass through this function or,
@@ -795,6 +794,14 @@
const Address& dest, // Where we are storing into.
Register value, // Value we are storing.
CanBeSmi can_be_smi = kValueCanBeSmi);
+ void StoreCompressedIntoObject(
+ Register object, // Object we are storing into.
+ const Address& dest, // Where we are storing into.
+ Register value, // Value we are storing.
+ CanBeSmi can_be_smi = kValueCanBeSmi);
+ void StoreBarrier(Register object, // Object we are storing into.
+ Register value, // Value we are storing.
+ CanBeSmi can_be_smi);
void StoreIntoArray(Register object, // Object we are storing into.
Register slot, // Where we are storing into.
Register value, // Value we are storing.
@@ -803,9 +810,15 @@
void StoreIntoObjectNoBarrier(Register object,
const Address& dest,
Register value);
+ void StoreCompressedIntoObjectNoBarrier(Register object,
+ const Address& dest,
+ Register value);
void StoreIntoObjectNoBarrier(Register object,
const Address& dest,
const Object& value);
+ void StoreCompressedIntoObjectNoBarrier(Register object,
+ const Address& dest,
+ const Object& value);
// Stores a non-tagged value into a heap object.
void StoreInternalPointer(Register object,
@@ -815,6 +828,7 @@
// Stores a Smi value into a heap object field that always contains a Smi.
void StoreIntoSmiField(const Address& dest, Register value);
void ZeroInitSmiField(const Address& dest);
+ void ZeroInitCompressedSmiField(const Address& dest);
// Increments a Smi field. Leaves flags in same state as an 'addq'.
void IncrementSmiField(const Address& dest, int64_t increment);
@@ -933,6 +947,9 @@
OperandSize sz = kEightBytes) {
LoadFromOffset(dst, address, sz);
}
+ void LoadCompressedField(Register dst, FieldAddress address) {
+ LoadCompressed(dst, address);
+ }
void LoadFieldFromOffset(Register dst,
Register base,
int32_t offset,
diff --git a/runtime/vm/compiler/backend/flow_graph_compiler.cc b/runtime/vm/compiler/backend/flow_graph_compiler.cc
index 0a08391..da51b20 100644
--- a/runtime/vm/compiler/backend/flow_graph_compiler.cc
+++ b/runtime/vm/compiler/backend/flow_graph_compiler.cc
@@ -2543,8 +2543,9 @@
__ LoadCompressedFieldFromOffset(
kScratch1Reg, kScratch1Reg,
compiler::target::Class::super_type_offset());
- __ LoadFieldFromOffset(kScratch1Reg, kScratch1Reg,
- compiler::target::Type::type_class_id_offset());
+ __ LoadCompressedFieldFromOffset(
+ kScratch1Reg, kScratch1Reg,
+ compiler::target::Type::type_class_id_offset());
__ CompareImmediate(kScratch1Reg, Smi::RawValue(type_class.id()));
__ BranchIf(EQUAL, is_instance_lbl);
}
diff --git a/runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc b/runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc
index 0f32cf2..888f4f1 100644
--- a/runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc
+++ b/runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc
@@ -751,7 +751,7 @@
// Stub returns result in flags (result of a cmp, we need Z computed).
__ PopPair(right, left);
} else {
- __ CompareRegisters(left, right);
+ __ CompareObjectRegisters(left, right);
}
return EQ;
}
diff --git a/runtime/vm/compiler/backend/flow_graph_compiler_x64.cc b/runtime/vm/compiler/backend/flow_graph_compiler_x64.cc
index e0b9329..11cfcb6 100644
--- a/runtime/vm/compiler/backend/flow_graph_compiler_x64.cc
+++ b/runtime/vm/compiler/backend/flow_graph_compiler_x64.cc
@@ -744,7 +744,7 @@
__ popq(right);
__ popq(left);
} else {
- __ CompareRegisters(left, right);
+ __ CompareObjectRegisters(left, right);
}
return EQUAL;
}
diff --git a/runtime/vm/compiler/backend/il.cc b/runtime/vm/compiler/backend/il.cc
index 40f38ab..9b15447 100644
--- a/runtime/vm/compiler/backend/il.cc
+++ b/runtime/vm/compiler/backend/il.cc
@@ -5539,10 +5539,11 @@
if (index_cid != kSmiCid) {
__ BranchIfNotSmi(index, slow_path->entry_label());
}
+ __ CompareObjectRegisters(index, length);
} else {
ASSERT(representation() == kUnboxedInt64);
+ __ CompareRegisters(index, length);
}
- __ CompareRegisters(index, length);
__ BranchIf(UNSIGNED_GREATER_EQUAL, slow_path->entry_label());
}
diff --git a/runtime/vm/compiler/backend/il_arm64.cc b/runtime/vm/compiler/backend/il_arm64.cc
index 84bcb80..3bab356 100644
--- a/runtime/vm/compiler/backend/il_arm64.cc
+++ b/runtime/vm/compiler/backend/il_arm64.cc
@@ -1511,7 +1511,8 @@
ASSERT(cid_ == kOneByteStringCid);
const Register str = locs()->in(0).reg();
const Register result = locs()->out(0).reg();
- __ LoadFieldFromOffset(result, str, String::length_offset());
+ __ LoadCompressedSmi(result,
+ compiler::FieldAddress(str, String::length_offset()));
__ ldr(TMP,
compiler::FieldAddress(str, OneByteString::data_offset(),
compiler::kByte),
@@ -2364,7 +2365,7 @@
// offset_reg contains offset already corrected by -kHeapObjectTag that is
// why we use Address instead of FieldAddress.
__ ldr(TMP, compiler::Address(value_reg, offset_reg));
- __ CompareRegisters(length_reg, TMP);
+ __ CompareObjectRegisters(length_reg, TMP);
if (deopt == NULL) {
__ b(&ok, EQ);
@@ -2665,19 +2666,34 @@
__ Bind(&store_pointer);
}
- ASSERT(!slot().is_compressed()); // Unimplemented.
+ const bool compressed = slot().is_compressed();
if (ShouldEmitStoreBarrier()) {
const Register value_reg = locs()->in(1).reg();
- __ StoreIntoObjectOffset(instance_reg, offset_in_bytes, value_reg,
- CanValueBeSmi());
+ if (!compressed) {
+ __ StoreIntoObjectOffset(instance_reg, offset_in_bytes, value_reg,
+ CanValueBeSmi());
+ } else {
+ __ StoreCompressedIntoObjectOffset(instance_reg, offset_in_bytes,
+ value_reg, CanValueBeSmi());
+ }
} else {
if (locs()->in(1).IsConstant()) {
- __ StoreIntoObjectOffsetNoBarrier(instance_reg, offset_in_bytes,
- locs()->in(1).constant());
+ if (!compressed) {
+ __ StoreIntoObjectOffsetNoBarrier(instance_reg, offset_in_bytes,
+ locs()->in(1).constant());
+ } else {
+ __ StoreCompressedIntoObjectOffsetNoBarrier(
+ instance_reg, offset_in_bytes, locs()->in(1).constant());
+ }
} else {
const Register value_reg = locs()->in(1).reg();
- __ StoreIntoObjectOffsetNoBarrier(instance_reg, offset_in_bytes,
- value_reg);
+ if (!compressed) {
+ __ StoreIntoObjectOffsetNoBarrier(instance_reg, offset_in_bytes,
+ value_reg);
+ } else {
+ __ StoreCompressedIntoObjectOffsetNoBarrier(instance_reg,
+ offset_in_bytes, value_reg);
+ }
}
}
__ Bind(&skip_store);
diff --git a/runtime/vm/compiler/backend/il_x64.cc b/runtime/vm/compiler/backend/il_x64.cc
index ed081c7..da435ce3 100644
--- a/runtime/vm/compiler/backend/il_x64.cc
+++ b/runtime/vm/compiler/backend/il_x64.cc
@@ -1391,6 +1391,15 @@
Register char_code = locs()->in(0).reg();
Register result = locs()->out(0).reg();
+#if defined(DART_COMPRESSED_POINTERS)
+ // The upper half of a compressed Smi contains undefined bits, but no x64
+ // addressing mode will ignore these bits. Assume that the index is
+ // non-negative and clear the upper bits, which is shorter than
+ // sign-extension (movsxd). Note: we don't bother to ensure index is a
+ // writable input because any other instructions using it must also not
+ // rely on the upper bits.
+ __ orl(char_code, char_code);
+#endif
__ movq(result,
compiler::Address(THR, Thread::predefined_symbols_address_offset()));
__ movq(result,
@@ -1411,7 +1420,8 @@
Register str = locs()->in(0).reg();
Register result = locs()->out(0).reg();
compiler::Label is_one, done;
- __ movq(result, compiler::FieldAddress(str, String::length_offset()));
+ __ LoadCompressedSmi(result,
+ compiler::FieldAddress(str, String::length_offset()));
__ cmpq(result, compiler::Immediate(Smi::RawValue(1)));
__ j(EQUAL, &is_one, compiler::Assembler::kNearJump);
__ movq(result, compiler::Immediate(Smi::RawValue(-1)));
@@ -2392,7 +2402,8 @@
// value's class matches guarded class id of the field.
// offset_reg contains offset already corrected by -kHeapObjectTag that is
// why we use Address instead of FieldAddress.
- __ cmpq(length_reg, compiler::Address(value_reg, offset_reg, TIMES_1, 0));
+ __ OBJ(cmp)(length_reg,
+ compiler::Address(value_reg, offset_reg, TIMES_1, 0));
if (deopt == NULL) {
__ j(EQUAL, &ok);
@@ -2735,22 +2746,40 @@
__ Bind(&store_pointer);
}
- ASSERT(!slot().is_compressed()); // Unimplemented.
+ const bool compressed = slot().is_compressed();
if (ShouldEmitStoreBarrier()) {
Register value_reg = locs()->in(1).reg();
- __ StoreIntoObject(instance_reg,
- compiler::FieldAddress(instance_reg, offset_in_bytes),
- value_reg, CanValueBeSmi());
+ if (!compressed) {
+ __ StoreIntoObject(instance_reg,
+ compiler::FieldAddress(instance_reg, offset_in_bytes),
+ value_reg, CanValueBeSmi());
+ } else {
+ __ StoreCompressedIntoObject(
+ instance_reg, compiler::FieldAddress(instance_reg, offset_in_bytes),
+ value_reg, CanValueBeSmi());
+ }
} else {
if (locs()->in(1).IsConstant()) {
- __ StoreIntoObjectNoBarrier(
- instance_reg, compiler::FieldAddress(instance_reg, offset_in_bytes),
- locs()->in(1).constant());
+ if (!compressed) {
+ __ StoreIntoObjectNoBarrier(
+ instance_reg, compiler::FieldAddress(instance_reg, offset_in_bytes),
+ locs()->in(1).constant());
+ } else {
+ __ StoreCompressedIntoObjectNoBarrier(
+ instance_reg, compiler::FieldAddress(instance_reg, offset_in_bytes),
+ locs()->in(1).constant());
+ }
} else {
Register value_reg = locs()->in(1).reg();
- __ StoreIntoObjectNoBarrier(
- instance_reg, compiler::FieldAddress(instance_reg, offset_in_bytes),
- value_reg);
+ if (!compressed) {
+ __ StoreIntoObjectNoBarrier(
+ instance_reg, compiler::FieldAddress(instance_reg, offset_in_bytes),
+ value_reg);
+ } else {
+ __ StoreCompressedIntoObjectNoBarrier(
+ instance_reg, compiler::FieldAddress(instance_reg, offset_in_bytes),
+ value_reg);
+ }
}
}
__ Bind(&skip_store);
diff --git a/runtime/vm/compiler/backend/slot.cc b/runtime/vm/compiler/backend/slot.cc
index 7c16944..75fccf8 100644
--- a/runtime/vm/compiler/backend/slot.cc
+++ b/runtime/vm/compiler/backend/slot.cc
@@ -128,6 +128,8 @@
(IsNullableBit::encode(true) | IsImmutableBit::encode(true) | \
IsCompressedBit::encode(true))
#define NULLABLE_FIELD_VAR (IsNullableBit::encode(true))
+#define NULLABLE_FIELD_VAR_COMPRESSED \
+ (IsNullableBit::encode(true) | IsCompressedBit::encode(true))
#define DEFINE_NULLABLE_BOXED_NATIVE_FIELD(ClassName, UnderlyingType, \
FieldName, cid, mutability) \
Slot(Kind::k##ClassName##_##FieldName, NULLABLE_FIELD_##mutability, \
@@ -144,6 +146,7 @@
#define NONNULLABLE_FIELD_FINAL_COMPRESSED \
(Slot::IsImmutableBit::encode(true) | Slot::IsCompressedBit::encode(true))
#define NONNULLABLE_FIELD_VAR (0)
+#define NONNULLABLE_FIELD_VAR_COMPRESSED (Slot::IsCompressedBit::encode(true))
#define DEFINE_NONNULLABLE_BOXED_NATIVE_FIELD(ClassName, UnderlyingType, \
FieldName, cid, mutability) \
Slot(Kind::k##ClassName##_##FieldName, NONNULLABLE_FIELD_##mutability, \
@@ -208,9 +211,10 @@
const Slot& Slot::GetTypeArgumentsSlotAt(Thread* thread, intptr_t offset) {
ASSERT(offset != Class::kNoTypeArguments);
- return SlotCache::Instance(thread).Canonicalize(Slot(
- Kind::kTypeArguments, IsImmutableBit::encode(true), kTypeArgumentsCid,
- offset, ":type_arguments", /*static_type=*/nullptr, kTagged));
+ return SlotCache::Instance(thread).Canonicalize(
+ Slot(Kind::kTypeArguments, IsImmutableBit::encode(true),
+ kTypeArgumentsCid, offset, ":type_arguments",
+ /*static_type=*/nullptr, kTagged));
}
const Slot& Slot::GetTypeArgumentsSlotFor(Thread* thread, const Class& cls) {
diff --git a/runtime/vm/compiler/backend/slot.h b/runtime/vm/compiler/backend/slot.h
index 655b10c..8a776de 100644
--- a/runtime/vm/compiler/backend/slot.h
+++ b/runtime/vm/compiler/backend/slot.h
@@ -60,8 +60,9 @@
V(Closure, UntaggedClosure, function_type_arguments, TypeArguments, FINAL) \
V(ClosureData, UntaggedClosureData, default_type_arguments, TypeArguments, \
FINAL_COMPRESSED) \
- V(Type, UntaggedType, arguments, TypeArguments, FINAL) \
- V(FunctionType, UntaggedFunctionType, type_parameters, TypeArguments, FINAL) \
+ V(Type, UntaggedType, arguments, TypeArguments, FINAL_COMPRESSED) \
+ V(FunctionType, UntaggedFunctionType, type_parameters, TypeArguments, \
+ FINAL_COMPRESSED) \
V(WeakProperty, UntaggedWeakProperty, key, Dynamic, VAR) \
V(WeakProperty, UntaggedWeakProperty, value, Dynamic, VAR)
@@ -84,14 +85,17 @@
V(Closure, UntaggedClosure, context, Context, FINAL) \
V(Closure, UntaggedClosure, hash, Context, VAR) \
V(Function, UntaggedFunction, data, Dynamic, FINAL_COMPRESSED) \
- V(FunctionType, UntaggedFunctionType, parameter_names, Array, FINAL) \
- V(FunctionType, UntaggedFunctionType, parameter_types, Array, FINAL) \
+ V(FunctionType, UntaggedFunctionType, parameter_names, Array, \
+ FINAL_COMPRESSED) \
+ V(FunctionType, UntaggedFunctionType, parameter_types, Array, \
+ FINAL_COMPRESSED) \
V(GrowableObjectArray, UntaggedGrowableObjectArray, length, Smi, VAR) \
V(GrowableObjectArray, UntaggedGrowableObjectArray, data, Array, VAR) \
- V(TypedDataBase, UntaggedTypedDataBase, length, Smi, FINAL) \
- V(TypedDataView, UntaggedTypedDataView, offset_in_bytes, Smi, FINAL) \
- V(TypedDataView, UntaggedTypedDataView, data, Dynamic, FINAL) \
- V(String, UntaggedString, length, Smi, FINAL) \
+ V(TypedDataBase, UntaggedTypedDataBase, length, Smi, FINAL_COMPRESSED) \
+ V(TypedDataView, UntaggedTypedDataView, offset_in_bytes, Smi, \
+ FINAL_COMPRESSED) \
+ V(TypedDataView, UntaggedTypedDataView, data, Dynamic, FINAL_COMPRESSED) \
+ V(String, UntaggedString, length, Smi, FINAL_COMPRESSED) \
V(LinkedHashMap, UntaggedLinkedHashMap, index, TypedDataUint32Array, VAR) \
V(LinkedHashMap, UntaggedLinkedHashMap, data, Array, VAR) \
V(LinkedHashMap, UntaggedLinkedHashMap, hash_mask, Smi, VAR) \
@@ -103,10 +107,12 @@
V(ArgumentsDescriptor, UntaggedArray, size, Smi, FINAL) \
V(PointerBase, UntaggedPointerBase, data_field, Dynamic, FINAL) \
V(TypeArguments, UntaggedTypeArguments, length, Smi, FINAL) \
- V(TypeParameter, UntaggedTypeParameter, bound, Dynamic, FINAL) \
- V(TypeParameter, UntaggedTypeParameter, name, Dynamic, FINAL) \
- V(UnhandledException, UntaggedUnhandledException, exception, Dynamic, FINAL) \
- V(UnhandledException, UntaggedUnhandledException, stacktrace, Dynamic, FINAL)
+ V(TypeParameter, UntaggedTypeParameter, bound, Dynamic, FINAL_COMPRESSED) \
+ V(TypeParameter, UntaggedTypeParameter, name, Dynamic, FINAL_COMPRESSED) \
+ V(UnhandledException, UntaggedUnhandledException, exception, Dynamic, \
+ FINAL_COMPRESSED) \
+ V(UnhandledException, UntaggedUnhandledException, stacktrace, Dynamic, \
+ FINAL_COMPRESSED)
// List of slots that correspond to unboxed fields of native objects in the
// following format:
diff --git a/runtime/vm/compiler/runtime_api.cc b/runtime/vm/compiler/runtime_api.cc
index 63fa7d6..4db6350 100644
--- a/runtime/vm/compiler/runtime_api.cc
+++ b/runtime/vm/compiler/runtime_api.cc
@@ -816,7 +816,13 @@
#endif // defined(TARGET_ARCH_IA32)
word RegExp::function_offset(classid_t cid, bool sticky) {
+#if !defined(DART_COMPRESSED_POINTERS)
return TranslateOffsetInWords(dart::RegExp::function_offset(cid, sticky));
+#else
+ // TODO(rmacnak): TranslateOffsetInWords doesn't account for, say, header
+ // being 1 word and slots being half words.
+ return dart::RegExp::function_offset(cid, sticky);
+#endif
}
const word Symbols::kNumberOfOneCharCodeSymbols =
diff --git a/runtime/vm/compiler/runtime_offsets_extracted.h b/runtime/vm/compiler/runtime_offsets_extracted.h
index 3b346df..0f37245 100644
--- a/runtime/vm/compiler/runtime_offsets_extracted.h
+++ b/runtime/vm/compiler/runtime_offsets_extracted.h
@@ -2540,39 +2540,39 @@
static constexpr dart::compiler::target::word TimelineStream_enabled_offset =
16;
static constexpr dart::compiler::target::word TwoByteString_data_offset = 16;
-static constexpr dart::compiler::target::word Type_arguments_offset = 32;
-static constexpr dart::compiler::target::word Type_hash_offset = 40;
-static constexpr dart::compiler::target::word Type_type_class_id_offset = 24;
-static constexpr dart::compiler::target::word Type_type_state_offset = 48;
-static constexpr dart::compiler::target::word Type_nullability_offset = 49;
-static constexpr dart::compiler::target::word FunctionType_hash_offset = 56;
+static constexpr dart::compiler::target::word Type_arguments_offset = 24;
+static constexpr dart::compiler::target::word Type_hash_offset = 28;
+static constexpr dart::compiler::target::word Type_type_class_id_offset = 20;
+static constexpr dart::compiler::target::word Type_type_state_offset = 32;
+static constexpr dart::compiler::target::word Type_nullability_offset = 33;
+static constexpr dart::compiler::target::word FunctionType_hash_offset = 36;
static constexpr dart::compiler::target::word
- FunctionType_packed_fields_offset = 64;
+ FunctionType_packed_fields_offset = 40;
static constexpr dart::compiler::target::word
- FunctionType_parameter_types_offset = 40;
+ FunctionType_parameter_types_offset = 28;
static constexpr dart::compiler::target::word
- FunctionType_parameter_names_offset = 48;
+ FunctionType_parameter_names_offset = 32;
static constexpr dart::compiler::target::word
- FunctionType_type_parameters_offset = 24;
+ FunctionType_type_parameters_offset = 20;
static constexpr dart::compiler::target::word
- TypeParameter_parameterized_class_id_offset = 56;
-static constexpr dart::compiler::target::word TypeParameter_index_offset = 60;
+ TypeParameter_parameterized_class_id_offset = 36;
+static constexpr dart::compiler::target::word TypeParameter_index_offset = 40;
static constexpr dart::compiler::target::word TypeParameter_nullability_offset =
- 63;
+ 43;
static constexpr dart::compiler::target::word
TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word TypeArguments_length_offset = 16;
static constexpr dart::compiler::target::word TypeArguments_nullability_offset =
32;
static constexpr dart::compiler::target::word TypeArguments_types_offset = 40;
-static constexpr dart::compiler::target::word TypeParameter_bound_offset = 40;
-static constexpr dart::compiler::target::word TypeParameter_flags_offset = 62;
-static constexpr dart::compiler::target::word TypeParameter_name_offset = 24;
-static constexpr dart::compiler::target::word TypeRef_type_offset = 24;
+static constexpr dart::compiler::target::word TypeParameter_bound_offset = 28;
+static constexpr dart::compiler::target::word TypeParameter_flags_offset = 42;
+static constexpr dart::compiler::target::word TypeParameter_name_offset = 20;
+static constexpr dart::compiler::target::word TypeRef_type_offset = 20;
static constexpr dart::compiler::target::word TypedDataBase_length_offset = 16;
-static constexpr dart::compiler::target::word TypedDataView_data_offset = 24;
+static constexpr dart::compiler::target::word TypedDataView_data_offset = 20;
static constexpr dart::compiler::target::word
- TypedDataView_offset_in_bytes_offset = 32;
+ TypedDataView_offset_in_bytes_offset = 24;
static constexpr dart::compiler::target::word TypedData_data_offset = 24;
static constexpr dart::compiler::target::word
UnhandledException_exception_offset = 8;
@@ -2633,7 +2633,7 @@
static constexpr dart::compiler::target::word Float32x4_InstanceSize = 24;
static constexpr dart::compiler::target::word Float64x2_InstanceSize = 24;
static constexpr dart::compiler::target::word Function_InstanceSize = 96;
-static constexpr dart::compiler::target::word FunctionType_InstanceSize = 72;
+static constexpr dart::compiler::target::word FunctionType_InstanceSize = 48;
static constexpr dart::compiler::target::word FutureOr_InstanceSize = 16;
static constexpr dart::compiler::target::word GrowableObjectArray_InstanceSize =
32;
@@ -2649,7 +2649,7 @@
64;
static constexpr dart::compiler::target::word LanguageError_InstanceSize = 32;
static constexpr dart::compiler::target::word Library_InstanceSize = 104;
-static constexpr dart::compiler::target::word LibraryPrefix_InstanceSize = 40;
+static constexpr dart::compiler::target::word LibraryPrefix_InstanceSize = 24;
static constexpr dart::compiler::target::word LinkedHashMap_InstanceSize = 56;
static constexpr dart::compiler::target::word LocalVarDescriptors_InstanceSize =
16;
@@ -2668,14 +2668,14 @@
static constexpr dart::compiler::target::word PatchClass_InstanceSize = 32;
static constexpr dart::compiler::target::word PcDescriptors_HeaderSize = 16;
static constexpr dart::compiler::target::word Pointer_InstanceSize = 24;
-static constexpr dart::compiler::target::word ReceivePort_InstanceSize = 40;
-static constexpr dart::compiler::target::word RegExp_InstanceSize = 120;
+static constexpr dart::compiler::target::word ReceivePort_InstanceSize = 24;
+static constexpr dart::compiler::target::word RegExp_InstanceSize = 80;
static constexpr dart::compiler::target::word Script_InstanceSize = 72;
static constexpr dart::compiler::target::word SendPort_InstanceSize = 24;
static constexpr dart::compiler::target::word SingleTargetCache_InstanceSize =
32;
static constexpr dart::compiler::target::word Smi_InstanceSize = 8;
-static constexpr dart::compiler::target::word StackTrace_InstanceSize = 40;
+static constexpr dart::compiler::target::word StackTrace_InstanceSize = 24;
static constexpr dart::compiler::target::word String_InstanceSize = 16;
static constexpr dart::compiler::target::word SubtypeTestCache_InstanceSize =
16;
@@ -2683,13 +2683,13 @@
static constexpr dart::compiler::target::word
TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word TwoByteString_InstanceSize = 16;
-static constexpr dart::compiler::target::word Type_InstanceSize = 56;
+static constexpr dart::compiler::target::word Type_InstanceSize = 40;
static constexpr dart::compiler::target::word TypeArguments_InstanceSize = 40;
-static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 64;
-static constexpr dart::compiler::target::word TypeRef_InstanceSize = 32;
+static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 48;
+static constexpr dart::compiler::target::word TypeRef_InstanceSize = 24;
static constexpr dart::compiler::target::word TypedData_InstanceSize = 24;
static constexpr dart::compiler::target::word TypedDataBase_InstanceSize = 24;
-static constexpr dart::compiler::target::word TypedDataView_InstanceSize = 40;
+static constexpr dart::compiler::target::word TypedDataView_InstanceSize = 32;
static constexpr dart::compiler::target::word UnhandledException_InstanceSize =
16;
static constexpr dart::compiler::target::word UnlinkedCall_InstanceSize = 32;
@@ -3079,39 +3079,39 @@
static constexpr dart::compiler::target::word TimelineStream_enabled_offset =
16;
static constexpr dart::compiler::target::word TwoByteString_data_offset = 16;
-static constexpr dart::compiler::target::word Type_arguments_offset = 32;
-static constexpr dart::compiler::target::word Type_hash_offset = 40;
-static constexpr dart::compiler::target::word Type_type_class_id_offset = 24;
-static constexpr dart::compiler::target::word Type_type_state_offset = 48;
-static constexpr dart::compiler::target::word Type_nullability_offset = 49;
-static constexpr dart::compiler::target::word FunctionType_hash_offset = 56;
+static constexpr dart::compiler::target::word Type_arguments_offset = 24;
+static constexpr dart::compiler::target::word Type_hash_offset = 28;
+static constexpr dart::compiler::target::word Type_type_class_id_offset = 20;
+static constexpr dart::compiler::target::word Type_type_state_offset = 32;
+static constexpr dart::compiler::target::word Type_nullability_offset = 33;
+static constexpr dart::compiler::target::word FunctionType_hash_offset = 36;
static constexpr dart::compiler::target::word
- FunctionType_packed_fields_offset = 64;
+ FunctionType_packed_fields_offset = 40;
static constexpr dart::compiler::target::word
- FunctionType_parameter_types_offset = 40;
+ FunctionType_parameter_types_offset = 28;
static constexpr dart::compiler::target::word
- FunctionType_parameter_names_offset = 48;
+ FunctionType_parameter_names_offset = 32;
static constexpr dart::compiler::target::word
- FunctionType_type_parameters_offset = 24;
+ FunctionType_type_parameters_offset = 20;
static constexpr dart::compiler::target::word
- TypeParameter_parameterized_class_id_offset = 56;
-static constexpr dart::compiler::target::word TypeParameter_index_offset = 60;
+ TypeParameter_parameterized_class_id_offset = 36;
+static constexpr dart::compiler::target::word TypeParameter_index_offset = 40;
static constexpr dart::compiler::target::word TypeParameter_nullability_offset =
- 63;
+ 43;
static constexpr dart::compiler::target::word
TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word TypeArguments_length_offset = 16;
static constexpr dart::compiler::target::word TypeArguments_nullability_offset =
32;
static constexpr dart::compiler::target::word TypeArguments_types_offset = 40;
-static constexpr dart::compiler::target::word TypeParameter_bound_offset = 40;
-static constexpr dart::compiler::target::word TypeParameter_flags_offset = 62;
-static constexpr dart::compiler::target::word TypeParameter_name_offset = 24;
-static constexpr dart::compiler::target::word TypeRef_type_offset = 24;
+static constexpr dart::compiler::target::word TypeParameter_bound_offset = 28;
+static constexpr dart::compiler::target::word TypeParameter_flags_offset = 42;
+static constexpr dart::compiler::target::word TypeParameter_name_offset = 20;
+static constexpr dart::compiler::target::word TypeRef_type_offset = 20;
static constexpr dart::compiler::target::word TypedDataBase_length_offset = 16;
-static constexpr dart::compiler::target::word TypedDataView_data_offset = 24;
+static constexpr dart::compiler::target::word TypedDataView_data_offset = 20;
static constexpr dart::compiler::target::word
- TypedDataView_offset_in_bytes_offset = 32;
+ TypedDataView_offset_in_bytes_offset = 24;
static constexpr dart::compiler::target::word TypedData_data_offset = 24;
static constexpr dart::compiler::target::word
UnhandledException_exception_offset = 8;
@@ -3173,7 +3173,7 @@
static constexpr dart::compiler::target::word Float32x4_InstanceSize = 24;
static constexpr dart::compiler::target::word Float64x2_InstanceSize = 24;
static constexpr dart::compiler::target::word Function_InstanceSize = 96;
-static constexpr dart::compiler::target::word FunctionType_InstanceSize = 72;
+static constexpr dart::compiler::target::word FunctionType_InstanceSize = 48;
static constexpr dart::compiler::target::word FutureOr_InstanceSize = 16;
static constexpr dart::compiler::target::word GrowableObjectArray_InstanceSize =
32;
@@ -3189,7 +3189,7 @@
64;
static constexpr dart::compiler::target::word LanguageError_InstanceSize = 32;
static constexpr dart::compiler::target::word Library_InstanceSize = 104;
-static constexpr dart::compiler::target::word LibraryPrefix_InstanceSize = 40;
+static constexpr dart::compiler::target::word LibraryPrefix_InstanceSize = 24;
static constexpr dart::compiler::target::word LinkedHashMap_InstanceSize = 56;
static constexpr dart::compiler::target::word LocalVarDescriptors_InstanceSize =
16;
@@ -3208,14 +3208,14 @@
static constexpr dart::compiler::target::word PatchClass_InstanceSize = 32;
static constexpr dart::compiler::target::word PcDescriptors_HeaderSize = 16;
static constexpr dart::compiler::target::word Pointer_InstanceSize = 24;
-static constexpr dart::compiler::target::word ReceivePort_InstanceSize = 40;
-static constexpr dart::compiler::target::word RegExp_InstanceSize = 120;
+static constexpr dart::compiler::target::word ReceivePort_InstanceSize = 24;
+static constexpr dart::compiler::target::word RegExp_InstanceSize = 80;
static constexpr dart::compiler::target::word Script_InstanceSize = 72;
static constexpr dart::compiler::target::word SendPort_InstanceSize = 24;
static constexpr dart::compiler::target::word SingleTargetCache_InstanceSize =
32;
static constexpr dart::compiler::target::word Smi_InstanceSize = 8;
-static constexpr dart::compiler::target::word StackTrace_InstanceSize = 40;
+static constexpr dart::compiler::target::word StackTrace_InstanceSize = 24;
static constexpr dart::compiler::target::word String_InstanceSize = 16;
static constexpr dart::compiler::target::word SubtypeTestCache_InstanceSize =
16;
@@ -3223,13 +3223,13 @@
static constexpr dart::compiler::target::word
TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word TwoByteString_InstanceSize = 16;
-static constexpr dart::compiler::target::word Type_InstanceSize = 56;
+static constexpr dart::compiler::target::word Type_InstanceSize = 40;
static constexpr dart::compiler::target::word TypeArguments_InstanceSize = 40;
-static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 64;
-static constexpr dart::compiler::target::word TypeRef_InstanceSize = 32;
+static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 48;
+static constexpr dart::compiler::target::word TypeRef_InstanceSize = 24;
static constexpr dart::compiler::target::word TypedData_InstanceSize = 24;
static constexpr dart::compiler::target::word TypedDataBase_InstanceSize = 24;
-static constexpr dart::compiler::target::word TypedDataView_InstanceSize = 40;
+static constexpr dart::compiler::target::word TypedDataView_InstanceSize = 32;
static constexpr dart::compiler::target::word UnhandledException_InstanceSize =
16;
static constexpr dart::compiler::target::word UnlinkedCall_InstanceSize = 32;
@@ -5738,39 +5738,39 @@
static constexpr dart::compiler::target::word TimelineStream_enabled_offset =
16;
static constexpr dart::compiler::target::word TwoByteString_data_offset = 16;
-static constexpr dart::compiler::target::word Type_arguments_offset = 32;
-static constexpr dart::compiler::target::word Type_hash_offset = 40;
-static constexpr dart::compiler::target::word Type_type_class_id_offset = 24;
-static constexpr dart::compiler::target::word Type_type_state_offset = 48;
-static constexpr dart::compiler::target::word Type_nullability_offset = 49;
-static constexpr dart::compiler::target::word FunctionType_hash_offset = 56;
+static constexpr dart::compiler::target::word Type_arguments_offset = 24;
+static constexpr dart::compiler::target::word Type_hash_offset = 28;
+static constexpr dart::compiler::target::word Type_type_class_id_offset = 20;
+static constexpr dart::compiler::target::word Type_type_state_offset = 32;
+static constexpr dart::compiler::target::word Type_nullability_offset = 33;
+static constexpr dart::compiler::target::word FunctionType_hash_offset = 36;
static constexpr dart::compiler::target::word
- FunctionType_packed_fields_offset = 64;
+ FunctionType_packed_fields_offset = 40;
static constexpr dart::compiler::target::word
- FunctionType_parameter_types_offset = 40;
+ FunctionType_parameter_types_offset = 28;
static constexpr dart::compiler::target::word
- FunctionType_parameter_names_offset = 48;
+ FunctionType_parameter_names_offset = 32;
static constexpr dart::compiler::target::word
- FunctionType_type_parameters_offset = 24;
+ FunctionType_type_parameters_offset = 20;
static constexpr dart::compiler::target::word
- TypeParameter_parameterized_class_id_offset = 56;
-static constexpr dart::compiler::target::word TypeParameter_index_offset = 60;
+ TypeParameter_parameterized_class_id_offset = 36;
+static constexpr dart::compiler::target::word TypeParameter_index_offset = 40;
static constexpr dart::compiler::target::word TypeParameter_nullability_offset =
- 63;
+ 43;
static constexpr dart::compiler::target::word
TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word TypeArguments_length_offset = 16;
static constexpr dart::compiler::target::word TypeArguments_nullability_offset =
32;
static constexpr dart::compiler::target::word TypeArguments_types_offset = 40;
-static constexpr dart::compiler::target::word TypeParameter_bound_offset = 40;
-static constexpr dart::compiler::target::word TypeParameter_flags_offset = 62;
-static constexpr dart::compiler::target::word TypeParameter_name_offset = 24;
-static constexpr dart::compiler::target::word TypeRef_type_offset = 24;
+static constexpr dart::compiler::target::word TypeParameter_bound_offset = 28;
+static constexpr dart::compiler::target::word TypeParameter_flags_offset = 42;
+static constexpr dart::compiler::target::word TypeParameter_name_offset = 20;
+static constexpr dart::compiler::target::word TypeRef_type_offset = 20;
static constexpr dart::compiler::target::word TypedDataBase_length_offset = 16;
-static constexpr dart::compiler::target::word TypedDataView_data_offset = 24;
+static constexpr dart::compiler::target::word TypedDataView_data_offset = 20;
static constexpr dart::compiler::target::word
- TypedDataView_offset_in_bytes_offset = 32;
+ TypedDataView_offset_in_bytes_offset = 24;
static constexpr dart::compiler::target::word TypedData_data_offset = 24;
static constexpr dart::compiler::target::word
UnhandledException_exception_offset = 8;
@@ -5828,7 +5828,7 @@
static constexpr dart::compiler::target::word Float32x4_InstanceSize = 24;
static constexpr dart::compiler::target::word Float64x2_InstanceSize = 24;
static constexpr dart::compiler::target::word Function_InstanceSize = 96;
-static constexpr dart::compiler::target::word FunctionType_InstanceSize = 72;
+static constexpr dart::compiler::target::word FunctionType_InstanceSize = 48;
static constexpr dart::compiler::target::word FutureOr_InstanceSize = 16;
static constexpr dart::compiler::target::word GrowableObjectArray_InstanceSize =
32;
@@ -5844,7 +5844,7 @@
64;
static constexpr dart::compiler::target::word LanguageError_InstanceSize = 32;
static constexpr dart::compiler::target::word Library_InstanceSize = 104;
-static constexpr dart::compiler::target::word LibraryPrefix_InstanceSize = 40;
+static constexpr dart::compiler::target::word LibraryPrefix_InstanceSize = 24;
static constexpr dart::compiler::target::word LinkedHashMap_InstanceSize = 56;
static constexpr dart::compiler::target::word LocalVarDescriptors_InstanceSize =
16;
@@ -5863,14 +5863,14 @@
static constexpr dart::compiler::target::word PatchClass_InstanceSize = 32;
static constexpr dart::compiler::target::word PcDescriptors_HeaderSize = 16;
static constexpr dart::compiler::target::word Pointer_InstanceSize = 24;
-static constexpr dart::compiler::target::word ReceivePort_InstanceSize = 24;
-static constexpr dart::compiler::target::word RegExp_InstanceSize = 120;
+static constexpr dart::compiler::target::word ReceivePort_InstanceSize = 16;
+static constexpr dart::compiler::target::word RegExp_InstanceSize = 80;
static constexpr dart::compiler::target::word Script_InstanceSize = 64;
static constexpr dart::compiler::target::word SendPort_InstanceSize = 24;
static constexpr dart::compiler::target::word SingleTargetCache_InstanceSize =
32;
static constexpr dart::compiler::target::word Smi_InstanceSize = 8;
-static constexpr dart::compiler::target::word StackTrace_InstanceSize = 40;
+static constexpr dart::compiler::target::word StackTrace_InstanceSize = 24;
static constexpr dart::compiler::target::word String_InstanceSize = 16;
static constexpr dart::compiler::target::word SubtypeTestCache_InstanceSize =
16;
@@ -5878,13 +5878,13 @@
static constexpr dart::compiler::target::word
TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word TwoByteString_InstanceSize = 16;
-static constexpr dart::compiler::target::word Type_InstanceSize = 56;
+static constexpr dart::compiler::target::word Type_InstanceSize = 40;
static constexpr dart::compiler::target::word TypeArguments_InstanceSize = 40;
-static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 64;
-static constexpr dart::compiler::target::word TypeRef_InstanceSize = 32;
+static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 48;
+static constexpr dart::compiler::target::word TypeRef_InstanceSize = 24;
static constexpr dart::compiler::target::word TypedData_InstanceSize = 24;
static constexpr dart::compiler::target::word TypedDataBase_InstanceSize = 24;
-static constexpr dart::compiler::target::word TypedDataView_InstanceSize = 40;
+static constexpr dart::compiler::target::word TypedDataView_InstanceSize = 32;
static constexpr dart::compiler::target::word UnhandledException_InstanceSize =
16;
static constexpr dart::compiler::target::word UnlinkedCall_InstanceSize = 32;
@@ -6271,39 +6271,39 @@
static constexpr dart::compiler::target::word TimelineStream_enabled_offset =
16;
static constexpr dart::compiler::target::word TwoByteString_data_offset = 16;
-static constexpr dart::compiler::target::word Type_arguments_offset = 32;
-static constexpr dart::compiler::target::word Type_hash_offset = 40;
-static constexpr dart::compiler::target::word Type_type_class_id_offset = 24;
-static constexpr dart::compiler::target::word Type_type_state_offset = 48;
-static constexpr dart::compiler::target::word Type_nullability_offset = 49;
-static constexpr dart::compiler::target::word FunctionType_hash_offset = 56;
+static constexpr dart::compiler::target::word Type_arguments_offset = 24;
+static constexpr dart::compiler::target::word Type_hash_offset = 28;
+static constexpr dart::compiler::target::word Type_type_class_id_offset = 20;
+static constexpr dart::compiler::target::word Type_type_state_offset = 32;
+static constexpr dart::compiler::target::word Type_nullability_offset = 33;
+static constexpr dart::compiler::target::word FunctionType_hash_offset = 36;
static constexpr dart::compiler::target::word
- FunctionType_packed_fields_offset = 64;
+ FunctionType_packed_fields_offset = 40;
static constexpr dart::compiler::target::word
- FunctionType_parameter_types_offset = 40;
+ FunctionType_parameter_types_offset = 28;
static constexpr dart::compiler::target::word
- FunctionType_parameter_names_offset = 48;
+ FunctionType_parameter_names_offset = 32;
static constexpr dart::compiler::target::word
- FunctionType_type_parameters_offset = 24;
+ FunctionType_type_parameters_offset = 20;
static constexpr dart::compiler::target::word
- TypeParameter_parameterized_class_id_offset = 56;
-static constexpr dart::compiler::target::word TypeParameter_index_offset = 60;
+ TypeParameter_parameterized_class_id_offset = 36;
+static constexpr dart::compiler::target::word TypeParameter_index_offset = 40;
static constexpr dart::compiler::target::word TypeParameter_nullability_offset =
- 63;
+ 43;
static constexpr dart::compiler::target::word
TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word TypeArguments_length_offset = 16;
static constexpr dart::compiler::target::word TypeArguments_nullability_offset =
32;
static constexpr dart::compiler::target::word TypeArguments_types_offset = 40;
-static constexpr dart::compiler::target::word TypeParameter_bound_offset = 40;
-static constexpr dart::compiler::target::word TypeParameter_flags_offset = 62;
-static constexpr dart::compiler::target::word TypeParameter_name_offset = 24;
-static constexpr dart::compiler::target::word TypeRef_type_offset = 24;
+static constexpr dart::compiler::target::word TypeParameter_bound_offset = 28;
+static constexpr dart::compiler::target::word TypeParameter_flags_offset = 42;
+static constexpr dart::compiler::target::word TypeParameter_name_offset = 20;
+static constexpr dart::compiler::target::word TypeRef_type_offset = 20;
static constexpr dart::compiler::target::word TypedDataBase_length_offset = 16;
-static constexpr dart::compiler::target::word TypedDataView_data_offset = 24;
+static constexpr dart::compiler::target::word TypedDataView_data_offset = 20;
static constexpr dart::compiler::target::word
- TypedDataView_offset_in_bytes_offset = 32;
+ TypedDataView_offset_in_bytes_offset = 24;
static constexpr dart::compiler::target::word TypedData_data_offset = 24;
static constexpr dart::compiler::target::word
UnhandledException_exception_offset = 8;
@@ -6362,7 +6362,7 @@
static constexpr dart::compiler::target::word Float32x4_InstanceSize = 24;
static constexpr dart::compiler::target::word Float64x2_InstanceSize = 24;
static constexpr dart::compiler::target::word Function_InstanceSize = 96;
-static constexpr dart::compiler::target::word FunctionType_InstanceSize = 72;
+static constexpr dart::compiler::target::word FunctionType_InstanceSize = 48;
static constexpr dart::compiler::target::word FutureOr_InstanceSize = 16;
static constexpr dart::compiler::target::word GrowableObjectArray_InstanceSize =
32;
@@ -6378,7 +6378,7 @@
64;
static constexpr dart::compiler::target::word LanguageError_InstanceSize = 32;
static constexpr dart::compiler::target::word Library_InstanceSize = 104;
-static constexpr dart::compiler::target::word LibraryPrefix_InstanceSize = 40;
+static constexpr dart::compiler::target::word LibraryPrefix_InstanceSize = 24;
static constexpr dart::compiler::target::word LinkedHashMap_InstanceSize = 56;
static constexpr dart::compiler::target::word LocalVarDescriptors_InstanceSize =
16;
@@ -6397,14 +6397,14 @@
static constexpr dart::compiler::target::word PatchClass_InstanceSize = 32;
static constexpr dart::compiler::target::word PcDescriptors_HeaderSize = 16;
static constexpr dart::compiler::target::word Pointer_InstanceSize = 24;
-static constexpr dart::compiler::target::word ReceivePort_InstanceSize = 24;
-static constexpr dart::compiler::target::word RegExp_InstanceSize = 120;
+static constexpr dart::compiler::target::word ReceivePort_InstanceSize = 16;
+static constexpr dart::compiler::target::word RegExp_InstanceSize = 80;
static constexpr dart::compiler::target::word Script_InstanceSize = 64;
static constexpr dart::compiler::target::word SendPort_InstanceSize = 24;
static constexpr dart::compiler::target::word SingleTargetCache_InstanceSize =
32;
static constexpr dart::compiler::target::word Smi_InstanceSize = 8;
-static constexpr dart::compiler::target::word StackTrace_InstanceSize = 40;
+static constexpr dart::compiler::target::word StackTrace_InstanceSize = 24;
static constexpr dart::compiler::target::word String_InstanceSize = 16;
static constexpr dart::compiler::target::word SubtypeTestCache_InstanceSize =
16;
@@ -6412,13 +6412,13 @@
static constexpr dart::compiler::target::word
TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word TwoByteString_InstanceSize = 16;
-static constexpr dart::compiler::target::word Type_InstanceSize = 56;
+static constexpr dart::compiler::target::word Type_InstanceSize = 40;
static constexpr dart::compiler::target::word TypeArguments_InstanceSize = 40;
-static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 64;
-static constexpr dart::compiler::target::word TypeRef_InstanceSize = 32;
+static constexpr dart::compiler::target::word TypeParameter_InstanceSize = 48;
+static constexpr dart::compiler::target::word TypeRef_InstanceSize = 24;
static constexpr dart::compiler::target::word TypedData_InstanceSize = 24;
static constexpr dart::compiler::target::word TypedDataBase_InstanceSize = 24;
-static constexpr dart::compiler::target::word TypedDataView_InstanceSize = 40;
+static constexpr dart::compiler::target::word TypedDataView_InstanceSize = 32;
static constexpr dart::compiler::target::word UnhandledException_InstanceSize =
16;
static constexpr dart::compiler::target::word UnlinkedCall_InstanceSize = 32;
@@ -8636,27 +8636,27 @@
AOT_TimelineStream_enabled_offset = 16;
static constexpr dart::compiler::target::word AOT_TwoByteString_data_offset =
16;
-static constexpr dart::compiler::target::word AOT_Type_arguments_offset = 32;
-static constexpr dart::compiler::target::word AOT_Type_hash_offset = 40;
+static constexpr dart::compiler::target::word AOT_Type_arguments_offset = 24;
+static constexpr dart::compiler::target::word AOT_Type_hash_offset = 28;
static constexpr dart::compiler::target::word AOT_Type_type_class_id_offset =
- 24;
-static constexpr dart::compiler::target::word AOT_Type_type_state_offset = 48;
-static constexpr dart::compiler::target::word AOT_Type_nullability_offset = 49;
-static constexpr dart::compiler::target::word AOT_FunctionType_hash_offset = 56;
+ 20;
+static constexpr dart::compiler::target::word AOT_Type_type_state_offset = 32;
+static constexpr dart::compiler::target::word AOT_Type_nullability_offset = 33;
+static constexpr dart::compiler::target::word AOT_FunctionType_hash_offset = 36;
static constexpr dart::compiler::target::word
- AOT_FunctionType_packed_fields_offset = 64;
+ AOT_FunctionType_packed_fields_offset = 40;
static constexpr dart::compiler::target::word
- AOT_FunctionType_parameter_types_offset = 40;
+ AOT_FunctionType_parameter_types_offset = 28;
static constexpr dart::compiler::target::word
- AOT_FunctionType_parameter_names_offset = 48;
+ AOT_FunctionType_parameter_names_offset = 32;
static constexpr dart::compiler::target::word
- AOT_FunctionType_type_parameters_offset = 24;
+ AOT_FunctionType_type_parameters_offset = 20;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_parameterized_class_id_offset = 56;
+ AOT_TypeParameter_parameterized_class_id_offset = 36;
static constexpr dart::compiler::target::word AOT_TypeParameter_index_offset =
- 60;
+ 40;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_nullability_offset = 63;
+ AOT_TypeParameter_nullability_offset = 43;
static constexpr dart::compiler::target::word
AOT_TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word AOT_TypeArguments_length_offset =
@@ -8666,18 +8666,18 @@
static constexpr dart::compiler::target::word AOT_TypeArguments_types_offset =
40;
static constexpr dart::compiler::target::word AOT_TypeParameter_bound_offset =
- 40;
+ 28;
static constexpr dart::compiler::target::word AOT_TypeParameter_flags_offset =
- 62;
+ 42;
static constexpr dart::compiler::target::word AOT_TypeParameter_name_offset =
- 24;
-static constexpr dart::compiler::target::word AOT_TypeRef_type_offset = 24;
+ 20;
+static constexpr dart::compiler::target::word AOT_TypeRef_type_offset = 20;
static constexpr dart::compiler::target::word AOT_TypedDataBase_length_offset =
16;
static constexpr dart::compiler::target::word AOT_TypedDataView_data_offset =
- 24;
+ 20;
static constexpr dart::compiler::target::word
- AOT_TypedDataView_offset_in_bytes_offset = 32;
+ AOT_TypedDataView_offset_in_bytes_offset = 24;
static constexpr dart::compiler::target::word AOT_TypedData_data_offset = 24;
static constexpr dart::compiler::target::word
AOT_UnhandledException_exception_offset = 8;
@@ -8745,7 +8745,7 @@
static constexpr dart::compiler::target::word AOT_Float64x2_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 64;
static constexpr dart::compiler::target::word AOT_FunctionType_InstanceSize =
- 72;
+ 48;
static constexpr dart::compiler::target::word AOT_FutureOr_InstanceSize = 16;
static constexpr dart::compiler::target::word
AOT_GrowableObjectArray_InstanceSize = 32;
@@ -8763,7 +8763,7 @@
32;
static constexpr dart::compiler::target::word AOT_Library_InstanceSize = 96;
static constexpr dart::compiler::target::word AOT_LibraryPrefix_InstanceSize =
- 40;
+ 24;
static constexpr dart::compiler::target::word AOT_LinkedHashMap_InstanceSize =
56;
static constexpr dart::compiler::target::word
@@ -8786,14 +8786,14 @@
static constexpr dart::compiler::target::word AOT_PatchClass_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_PcDescriptors_HeaderSize = 16;
static constexpr dart::compiler::target::word AOT_Pointer_InstanceSize = 24;
-static constexpr dart::compiler::target::word AOT_ReceivePort_InstanceSize = 40;
-static constexpr dart::compiler::target::word AOT_RegExp_InstanceSize = 120;
+static constexpr dart::compiler::target::word AOT_ReceivePort_InstanceSize = 24;
+static constexpr dart::compiler::target::word AOT_RegExp_InstanceSize = 80;
static constexpr dart::compiler::target::word AOT_Script_InstanceSize = 56;
static constexpr dart::compiler::target::word AOT_SendPort_InstanceSize = 24;
static constexpr dart::compiler::target::word
AOT_SingleTargetCache_InstanceSize = 32;
static constexpr dart::compiler::target::word AOT_Smi_InstanceSize = 8;
-static constexpr dart::compiler::target::word AOT_StackTrace_InstanceSize = 40;
+static constexpr dart::compiler::target::word AOT_StackTrace_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_String_InstanceSize = 16;
static constexpr dart::compiler::target::word
AOT_SubtypeTestCache_InstanceSize = 16;
@@ -8802,17 +8802,17 @@
AOT_TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word AOT_TwoByteString_InstanceSize =
16;
-static constexpr dart::compiler::target::word AOT_Type_InstanceSize = 56;
+static constexpr dart::compiler::target::word AOT_Type_InstanceSize = 40;
static constexpr dart::compiler::target::word AOT_TypeArguments_InstanceSize =
40;
static constexpr dart::compiler::target::word AOT_TypeParameter_InstanceSize =
- 64;
-static constexpr dart::compiler::target::word AOT_TypeRef_InstanceSize = 32;
+ 48;
+static constexpr dart::compiler::target::word AOT_TypeRef_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_TypedData_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_TypedDataBase_InstanceSize =
24;
static constexpr dart::compiler::target::word AOT_TypedDataView_InstanceSize =
- 40;
+ 32;
static constexpr dart::compiler::target::word
AOT_UnhandledException_InstanceSize = 16;
static constexpr dart::compiler::target::word AOT_UnlinkedCall_InstanceSize =
@@ -9234,27 +9234,27 @@
AOT_TimelineStream_enabled_offset = 16;
static constexpr dart::compiler::target::word AOT_TwoByteString_data_offset =
16;
-static constexpr dart::compiler::target::word AOT_Type_arguments_offset = 32;
-static constexpr dart::compiler::target::word AOT_Type_hash_offset = 40;
+static constexpr dart::compiler::target::word AOT_Type_arguments_offset = 24;
+static constexpr dart::compiler::target::word AOT_Type_hash_offset = 28;
static constexpr dart::compiler::target::word AOT_Type_type_class_id_offset =
- 24;
-static constexpr dart::compiler::target::word AOT_Type_type_state_offset = 48;
-static constexpr dart::compiler::target::word AOT_Type_nullability_offset = 49;
-static constexpr dart::compiler::target::word AOT_FunctionType_hash_offset = 56;
+ 20;
+static constexpr dart::compiler::target::word AOT_Type_type_state_offset = 32;
+static constexpr dart::compiler::target::word AOT_Type_nullability_offset = 33;
+static constexpr dart::compiler::target::word AOT_FunctionType_hash_offset = 36;
static constexpr dart::compiler::target::word
- AOT_FunctionType_packed_fields_offset = 64;
+ AOT_FunctionType_packed_fields_offset = 40;
static constexpr dart::compiler::target::word
- AOT_FunctionType_parameter_types_offset = 40;
+ AOT_FunctionType_parameter_types_offset = 28;
static constexpr dart::compiler::target::word
- AOT_FunctionType_parameter_names_offset = 48;
+ AOT_FunctionType_parameter_names_offset = 32;
static constexpr dart::compiler::target::word
- AOT_FunctionType_type_parameters_offset = 24;
+ AOT_FunctionType_type_parameters_offset = 20;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_parameterized_class_id_offset = 56;
+ AOT_TypeParameter_parameterized_class_id_offset = 36;
static constexpr dart::compiler::target::word AOT_TypeParameter_index_offset =
- 60;
+ 40;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_nullability_offset = 63;
+ AOT_TypeParameter_nullability_offset = 43;
static constexpr dart::compiler::target::word
AOT_TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word AOT_TypeArguments_length_offset =
@@ -9264,18 +9264,18 @@
static constexpr dart::compiler::target::word AOT_TypeArguments_types_offset =
40;
static constexpr dart::compiler::target::word AOT_TypeParameter_bound_offset =
- 40;
+ 28;
static constexpr dart::compiler::target::word AOT_TypeParameter_flags_offset =
- 62;
+ 42;
static constexpr dart::compiler::target::word AOT_TypeParameter_name_offset =
- 24;
-static constexpr dart::compiler::target::word AOT_TypeRef_type_offset = 24;
+ 20;
+static constexpr dart::compiler::target::word AOT_TypeRef_type_offset = 20;
static constexpr dart::compiler::target::word AOT_TypedDataBase_length_offset =
16;
static constexpr dart::compiler::target::word AOT_TypedDataView_data_offset =
- 24;
+ 20;
static constexpr dart::compiler::target::word
- AOT_TypedDataView_offset_in_bytes_offset = 32;
+ AOT_TypedDataView_offset_in_bytes_offset = 24;
static constexpr dart::compiler::target::word AOT_TypedData_data_offset = 24;
static constexpr dart::compiler::target::word
AOT_UnhandledException_exception_offset = 8;
@@ -9344,7 +9344,7 @@
static constexpr dart::compiler::target::word AOT_Float64x2_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 64;
static constexpr dart::compiler::target::word AOT_FunctionType_InstanceSize =
- 72;
+ 48;
static constexpr dart::compiler::target::word AOT_FutureOr_InstanceSize = 16;
static constexpr dart::compiler::target::word
AOT_GrowableObjectArray_InstanceSize = 32;
@@ -9362,7 +9362,7 @@
32;
static constexpr dart::compiler::target::word AOT_Library_InstanceSize = 96;
static constexpr dart::compiler::target::word AOT_LibraryPrefix_InstanceSize =
- 40;
+ 24;
static constexpr dart::compiler::target::word AOT_LinkedHashMap_InstanceSize =
56;
static constexpr dart::compiler::target::word
@@ -9385,14 +9385,14 @@
static constexpr dart::compiler::target::word AOT_PatchClass_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_PcDescriptors_HeaderSize = 16;
static constexpr dart::compiler::target::word AOT_Pointer_InstanceSize = 24;
-static constexpr dart::compiler::target::word AOT_ReceivePort_InstanceSize = 40;
-static constexpr dart::compiler::target::word AOT_RegExp_InstanceSize = 120;
+static constexpr dart::compiler::target::word AOT_ReceivePort_InstanceSize = 24;
+static constexpr dart::compiler::target::word AOT_RegExp_InstanceSize = 80;
static constexpr dart::compiler::target::word AOT_Script_InstanceSize = 56;
static constexpr dart::compiler::target::word AOT_SendPort_InstanceSize = 24;
static constexpr dart::compiler::target::word
AOT_SingleTargetCache_InstanceSize = 32;
static constexpr dart::compiler::target::word AOT_Smi_InstanceSize = 8;
-static constexpr dart::compiler::target::word AOT_StackTrace_InstanceSize = 40;
+static constexpr dart::compiler::target::word AOT_StackTrace_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_String_InstanceSize = 16;
static constexpr dart::compiler::target::word
AOT_SubtypeTestCache_InstanceSize = 16;
@@ -9401,17 +9401,17 @@
AOT_TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word AOT_TwoByteString_InstanceSize =
16;
-static constexpr dart::compiler::target::word AOT_Type_InstanceSize = 56;
+static constexpr dart::compiler::target::word AOT_Type_InstanceSize = 40;
static constexpr dart::compiler::target::word AOT_TypeArguments_InstanceSize =
40;
static constexpr dart::compiler::target::word AOT_TypeParameter_InstanceSize =
- 64;
-static constexpr dart::compiler::target::word AOT_TypeRef_InstanceSize = 32;
+ 48;
+static constexpr dart::compiler::target::word AOT_TypeRef_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_TypedData_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_TypedDataBase_InstanceSize =
24;
static constexpr dart::compiler::target::word AOT_TypedDataView_InstanceSize =
- 40;
+ 32;
static constexpr dart::compiler::target::word
AOT_UnhandledException_InstanceSize = 16;
static constexpr dart::compiler::target::word AOT_UnlinkedCall_InstanceSize =
@@ -11604,27 +11604,27 @@
AOT_TimelineStream_enabled_offset = 16;
static constexpr dart::compiler::target::word AOT_TwoByteString_data_offset =
16;
-static constexpr dart::compiler::target::word AOT_Type_arguments_offset = 32;
-static constexpr dart::compiler::target::word AOT_Type_hash_offset = 40;
+static constexpr dart::compiler::target::word AOT_Type_arguments_offset = 24;
+static constexpr dart::compiler::target::word AOT_Type_hash_offset = 28;
static constexpr dart::compiler::target::word AOT_Type_type_class_id_offset =
- 24;
-static constexpr dart::compiler::target::word AOT_Type_type_state_offset = 48;
-static constexpr dart::compiler::target::word AOT_Type_nullability_offset = 49;
-static constexpr dart::compiler::target::word AOT_FunctionType_hash_offset = 56;
+ 20;
+static constexpr dart::compiler::target::word AOT_Type_type_state_offset = 32;
+static constexpr dart::compiler::target::word AOT_Type_nullability_offset = 33;
+static constexpr dart::compiler::target::word AOT_FunctionType_hash_offset = 36;
static constexpr dart::compiler::target::word
- AOT_FunctionType_packed_fields_offset = 64;
+ AOT_FunctionType_packed_fields_offset = 40;
static constexpr dart::compiler::target::word
- AOT_FunctionType_parameter_types_offset = 40;
+ AOT_FunctionType_parameter_types_offset = 28;
static constexpr dart::compiler::target::word
- AOT_FunctionType_parameter_names_offset = 48;
+ AOT_FunctionType_parameter_names_offset = 32;
static constexpr dart::compiler::target::word
- AOT_FunctionType_type_parameters_offset = 24;
+ AOT_FunctionType_type_parameters_offset = 20;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_parameterized_class_id_offset = 56;
+ AOT_TypeParameter_parameterized_class_id_offset = 36;
static constexpr dart::compiler::target::word AOT_TypeParameter_index_offset =
- 60;
+ 40;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_nullability_offset = 63;
+ AOT_TypeParameter_nullability_offset = 43;
static constexpr dart::compiler::target::word
AOT_TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word AOT_TypeArguments_length_offset =
@@ -11634,18 +11634,18 @@
static constexpr dart::compiler::target::word AOT_TypeArguments_types_offset =
40;
static constexpr dart::compiler::target::word AOT_TypeParameter_bound_offset =
- 40;
+ 28;
static constexpr dart::compiler::target::word AOT_TypeParameter_flags_offset =
- 62;
+ 42;
static constexpr dart::compiler::target::word AOT_TypeParameter_name_offset =
- 24;
-static constexpr dart::compiler::target::word AOT_TypeRef_type_offset = 24;
+ 20;
+static constexpr dart::compiler::target::word AOT_TypeRef_type_offset = 20;
static constexpr dart::compiler::target::word AOT_TypedDataBase_length_offset =
16;
static constexpr dart::compiler::target::word AOT_TypedDataView_data_offset =
- 24;
+ 20;
static constexpr dart::compiler::target::word
- AOT_TypedDataView_offset_in_bytes_offset = 32;
+ AOT_TypedDataView_offset_in_bytes_offset = 24;
static constexpr dart::compiler::target::word AOT_TypedData_data_offset = 24;
static constexpr dart::compiler::target::word
AOT_UnhandledException_exception_offset = 8;
@@ -11710,7 +11710,7 @@
static constexpr dart::compiler::target::word AOT_Float64x2_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 64;
static constexpr dart::compiler::target::word AOT_FunctionType_InstanceSize =
- 72;
+ 48;
static constexpr dart::compiler::target::word AOT_FutureOr_InstanceSize = 16;
static constexpr dart::compiler::target::word
AOT_GrowableObjectArray_InstanceSize = 32;
@@ -11728,7 +11728,7 @@
32;
static constexpr dart::compiler::target::word AOT_Library_InstanceSize = 96;
static constexpr dart::compiler::target::word AOT_LibraryPrefix_InstanceSize =
- 40;
+ 24;
static constexpr dart::compiler::target::word AOT_LinkedHashMap_InstanceSize =
56;
static constexpr dart::compiler::target::word
@@ -11751,14 +11751,14 @@
static constexpr dart::compiler::target::word AOT_PatchClass_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_PcDescriptors_HeaderSize = 16;
static constexpr dart::compiler::target::word AOT_Pointer_InstanceSize = 24;
-static constexpr dart::compiler::target::word AOT_ReceivePort_InstanceSize = 24;
-static constexpr dart::compiler::target::word AOT_RegExp_InstanceSize = 120;
+static constexpr dart::compiler::target::word AOT_ReceivePort_InstanceSize = 16;
+static constexpr dart::compiler::target::word AOT_RegExp_InstanceSize = 80;
static constexpr dart::compiler::target::word AOT_Script_InstanceSize = 56;
static constexpr dart::compiler::target::word AOT_SendPort_InstanceSize = 24;
static constexpr dart::compiler::target::word
AOT_SingleTargetCache_InstanceSize = 32;
static constexpr dart::compiler::target::word AOT_Smi_InstanceSize = 8;
-static constexpr dart::compiler::target::word AOT_StackTrace_InstanceSize = 40;
+static constexpr dart::compiler::target::word AOT_StackTrace_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_String_InstanceSize = 16;
static constexpr dart::compiler::target::word
AOT_SubtypeTestCache_InstanceSize = 16;
@@ -11767,17 +11767,17 @@
AOT_TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word AOT_TwoByteString_InstanceSize =
16;
-static constexpr dart::compiler::target::word AOT_Type_InstanceSize = 56;
+static constexpr dart::compiler::target::word AOT_Type_InstanceSize = 40;
static constexpr dart::compiler::target::word AOT_TypeArguments_InstanceSize =
40;
static constexpr dart::compiler::target::word AOT_TypeParameter_InstanceSize =
- 64;
-static constexpr dart::compiler::target::word AOT_TypeRef_InstanceSize = 32;
+ 48;
+static constexpr dart::compiler::target::word AOT_TypeRef_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_TypedData_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_TypedDataBase_InstanceSize =
24;
static constexpr dart::compiler::target::word AOT_TypedDataView_InstanceSize =
- 40;
+ 32;
static constexpr dart::compiler::target::word
AOT_UnhandledException_InstanceSize = 16;
static constexpr dart::compiler::target::word AOT_UnlinkedCall_InstanceSize =
@@ -12195,27 +12195,27 @@
AOT_TimelineStream_enabled_offset = 16;
static constexpr dart::compiler::target::word AOT_TwoByteString_data_offset =
16;
-static constexpr dart::compiler::target::word AOT_Type_arguments_offset = 32;
-static constexpr dart::compiler::target::word AOT_Type_hash_offset = 40;
+static constexpr dart::compiler::target::word AOT_Type_arguments_offset = 24;
+static constexpr dart::compiler::target::word AOT_Type_hash_offset = 28;
static constexpr dart::compiler::target::word AOT_Type_type_class_id_offset =
- 24;
-static constexpr dart::compiler::target::word AOT_Type_type_state_offset = 48;
-static constexpr dart::compiler::target::word AOT_Type_nullability_offset = 49;
-static constexpr dart::compiler::target::word AOT_FunctionType_hash_offset = 56;
+ 20;
+static constexpr dart::compiler::target::word AOT_Type_type_state_offset = 32;
+static constexpr dart::compiler::target::word AOT_Type_nullability_offset = 33;
+static constexpr dart::compiler::target::word AOT_FunctionType_hash_offset = 36;
static constexpr dart::compiler::target::word
- AOT_FunctionType_packed_fields_offset = 64;
+ AOT_FunctionType_packed_fields_offset = 40;
static constexpr dart::compiler::target::word
- AOT_FunctionType_parameter_types_offset = 40;
+ AOT_FunctionType_parameter_types_offset = 28;
static constexpr dart::compiler::target::word
- AOT_FunctionType_parameter_names_offset = 48;
+ AOT_FunctionType_parameter_names_offset = 32;
static constexpr dart::compiler::target::word
- AOT_FunctionType_type_parameters_offset = 24;
+ AOT_FunctionType_type_parameters_offset = 20;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_parameterized_class_id_offset = 56;
+ AOT_TypeParameter_parameterized_class_id_offset = 36;
static constexpr dart::compiler::target::word AOT_TypeParameter_index_offset =
- 60;
+ 40;
static constexpr dart::compiler::target::word
- AOT_TypeParameter_nullability_offset = 63;
+ AOT_TypeParameter_nullability_offset = 43;
static constexpr dart::compiler::target::word
AOT_TypeArguments_instantiations_offset = 8;
static constexpr dart::compiler::target::word AOT_TypeArguments_length_offset =
@@ -12225,18 +12225,18 @@
static constexpr dart::compiler::target::word AOT_TypeArguments_types_offset =
40;
static constexpr dart::compiler::target::word AOT_TypeParameter_bound_offset =
- 40;
+ 28;
static constexpr dart::compiler::target::word AOT_TypeParameter_flags_offset =
- 62;
+ 42;
static constexpr dart::compiler::target::word AOT_TypeParameter_name_offset =
- 24;
-static constexpr dart::compiler::target::word AOT_TypeRef_type_offset = 24;
+ 20;
+static constexpr dart::compiler::target::word AOT_TypeRef_type_offset = 20;
static constexpr dart::compiler::target::word AOT_TypedDataBase_length_offset =
16;
static constexpr dart::compiler::target::word AOT_TypedDataView_data_offset =
- 24;
+ 20;
static constexpr dart::compiler::target::word
- AOT_TypedDataView_offset_in_bytes_offset = 32;
+ AOT_TypedDataView_offset_in_bytes_offset = 24;
static constexpr dart::compiler::target::word AOT_TypedData_data_offset = 24;
static constexpr dart::compiler::target::word
AOT_UnhandledException_exception_offset = 8;
@@ -12302,7 +12302,7 @@
static constexpr dart::compiler::target::word AOT_Float64x2_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 64;
static constexpr dart::compiler::target::word AOT_FunctionType_InstanceSize =
- 72;
+ 48;
static constexpr dart::compiler::target::word AOT_FutureOr_InstanceSize = 16;
static constexpr dart::compiler::target::word
AOT_GrowableObjectArray_InstanceSize = 32;
@@ -12320,7 +12320,7 @@
32;
static constexpr dart::compiler::target::word AOT_Library_InstanceSize = 96;
static constexpr dart::compiler::target::word AOT_LibraryPrefix_InstanceSize =
- 40;
+ 24;
static constexpr dart::compiler::target::word AOT_LinkedHashMap_InstanceSize =
56;
static constexpr dart::compiler::target::word
@@ -12343,14 +12343,14 @@
static constexpr dart::compiler::target::word AOT_PatchClass_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_PcDescriptors_HeaderSize = 16;
static constexpr dart::compiler::target::word AOT_Pointer_InstanceSize = 24;
-static constexpr dart::compiler::target::word AOT_ReceivePort_InstanceSize = 24;
-static constexpr dart::compiler::target::word AOT_RegExp_InstanceSize = 120;
+static constexpr dart::compiler::target::word AOT_ReceivePort_InstanceSize = 16;
+static constexpr dart::compiler::target::word AOT_RegExp_InstanceSize = 80;
static constexpr dart::compiler::target::word AOT_Script_InstanceSize = 56;
static constexpr dart::compiler::target::word AOT_SendPort_InstanceSize = 24;
static constexpr dart::compiler::target::word
AOT_SingleTargetCache_InstanceSize = 32;
static constexpr dart::compiler::target::word AOT_Smi_InstanceSize = 8;
-static constexpr dart::compiler::target::word AOT_StackTrace_InstanceSize = 40;
+static constexpr dart::compiler::target::word AOT_StackTrace_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_String_InstanceSize = 16;
static constexpr dart::compiler::target::word
AOT_SubtypeTestCache_InstanceSize = 16;
@@ -12359,17 +12359,17 @@
AOT_TransferableTypedData_InstanceSize = 8;
static constexpr dart::compiler::target::word AOT_TwoByteString_InstanceSize =
16;
-static constexpr dart::compiler::target::word AOT_Type_InstanceSize = 56;
+static constexpr dart::compiler::target::word AOT_Type_InstanceSize = 40;
static constexpr dart::compiler::target::word AOT_TypeArguments_InstanceSize =
40;
static constexpr dart::compiler::target::word AOT_TypeParameter_InstanceSize =
- 64;
-static constexpr dart::compiler::target::word AOT_TypeRef_InstanceSize = 32;
+ 48;
+static constexpr dart::compiler::target::word AOT_TypeRef_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_TypedData_InstanceSize = 24;
static constexpr dart::compiler::target::word AOT_TypedDataBase_InstanceSize =
24;
static constexpr dart::compiler::target::word AOT_TypedDataView_InstanceSize =
- 40;
+ 32;
static constexpr dart::compiler::target::word
AOT_UnhandledException_InstanceSize = 16;
static constexpr dart::compiler::target::word AOT_UnlinkedCall_InstanceSize =
diff --git a/runtime/vm/compiler/stub_code_compiler.cc b/runtime/vm/compiler/stub_code_compiler.cc
index b41e1f9..bbcdc8c 100644
--- a/runtime/vm/compiler/stub_code_compiler.cc
+++ b/runtime/vm/compiler/stub_code_compiler.cc
@@ -321,7 +321,7 @@
// instantiation may result in a top type.
// Function types cannot be top types.
__ BranchIf(NOT_EQUAL, &done);
- __ LoadField(
+ __ LoadCompressedField(
scratch2_reg,
compiler::FieldAddress(scratch1_reg,
compiler::target::Type::type_class_id_offset()));
@@ -351,9 +351,10 @@
__ Ret();
// An uncommon case, so off the main trunk of the function.
__ Bind(&unwrap_future_or);
- __ LoadField(scratch2_reg,
- compiler::FieldAddress(
- scratch1_reg, compiler::target::Type::arguments_offset()));
+ __ LoadCompressedField(
+ scratch2_reg,
+ compiler::FieldAddress(scratch1_reg,
+ compiler::target::Type::arguments_offset()));
__ CompareObject(scratch2_reg, Object::null_object());
// If the arguments are null, then unwrapping gives dynamic, a top type.
__ BranchIf(EQUAL, &is_top_type, compiler::Assembler::kNearJump);
@@ -441,16 +442,17 @@
// FutureOr is a special case because it may have the non-nullable bit set,
// but FutureOr<T> functions as the union of T and Future<T>, so it must be
// unwrapped to see if T is nullable.
- __ LoadField(
+ __ LoadCompressedField(
kScratchReg,
compiler::FieldAddress(kCurrentTypeReg,
compiler::target::Type::type_class_id_offset()));
__ SmiUntag(kScratchReg);
__ CompareImmediate(kScratchReg, kFutureOrCid);
__ BranchIf(NOT_EQUAL, &done);
- __ LoadField(kScratchReg, compiler::FieldAddress(
- kCurrentTypeReg,
- compiler::target::Type::arguments_offset()));
+ __ LoadCompressedField(
+ kScratchReg,
+ compiler::FieldAddress(kCurrentTypeReg,
+ compiler::target::Type::arguments_offset()));
__ CompareObject(kScratchReg, Object::null_object());
// If the arguments are null, then unwrapping gives the dynamic type,
// which can take null.
diff --git a/runtime/vm/compiler/stub_code_compiler_arm64.cc b/runtime/vm/compiler/stub_code_compiler_arm64.cc
index e6f79d9..bc5eb6a 100644
--- a/runtime/vm/compiler/stub_code_compiler_arm64.cc
+++ b/runtime/vm/compiler/stub_code_compiler_arm64.cc
@@ -3638,7 +3638,7 @@
/* R0: new object start as a tagged pointer. */
/* R1: new object end address. */
__ mov(R2, AllocateTypedDataArrayABI::kLengthReg); /* Array length. */
- __ StoreIntoObjectNoBarrier(
+ __ StoreCompressedIntoObjectNoBarrier(
R0, FieldAddress(R0, target::TypedDataBase::length_offset()), R2);
/* Initialize all array elements to 0. */
/* R0: new object start as a tagged pointer. */
diff --git a/runtime/vm/compiler/stub_code_compiler_x64.cc b/runtime/vm/compiler/stub_code_compiler_x64.cc
index a6425ad..8d2987a 100644
--- a/runtime/vm/compiler/stub_code_compiler_x64.cc
+++ b/runtime/vm/compiler/stub_code_compiler_x64.cc
@@ -2380,7 +2380,7 @@
// because we only emit calls to this stub when it is not null.
__ movq(RCX,
FieldAddress(RBX, target::ICData::receivers_static_type_offset()));
- __ movq(RCX, FieldAddress(RCX, target::Type::arguments_offset()));
+ __ LoadCompressed(RCX, FieldAddress(RCX, target::Type::arguments_offset()));
// RAX contains an offset to type arguments in words as a smi,
// hence TIMES_4. RDX is guaranteed to be non-smi because it is expected
// to have type arguments.
@@ -3593,7 +3593,7 @@
/* RAX: new object start as a tagged pointer. */
/* RCX: new object end address. */
__ popq(RDI); /* Array length. */
- __ StoreIntoObjectNoBarrier(
+ __ StoreCompressedIntoObjectNoBarrier(
RAX, FieldAddress(RAX, target::TypedDataBase::length_offset()), RDI);
/* Initialize all array elements to 0. */
/* RAX: new object start as a tagged pointer. */
diff --git a/runtime/vm/heap/compactor.cc b/runtime/vm/heap/compactor.cc
index 7006f3e..462a9d2 100644
--- a/runtime/vm/heap/compactor.cc
+++ b/runtime/vm/heap/compactor.cc
@@ -275,7 +275,7 @@
for (intptr_t i = 0; i < length; ++i) {
auto raw_view = typed_data_views_[i];
const classid_t cid =
- raw_view->untag()->typed_data_->GetClassIdMayBeSmi();
+ raw_view->untag()->typed_data()->GetClassIdMayBeSmi();
// If we have external typed data we can simply return, since the backing
// store lives in C-heap and will not move. Otherwise we have to update
@@ -668,12 +668,12 @@
}
void GCCompactor::VisitTypedDataViewPointers(TypedDataViewPtr view,
- ObjectPtr* first,
- ObjectPtr* last) {
+ CompressedObjectPtr* first,
+ CompressedObjectPtr* last) {
// First we forward all fields of the typed data view.
- ObjectPtr old_backing = view->untag()->typed_data_;
- VisitPointers(first, last);
- ObjectPtr new_backing = view->untag()->typed_data_;
+ ObjectPtr old_backing = view->untag()->typed_data();
+ VisitCompressedPointers(view->heap_base(), first, last);
+ ObjectPtr new_backing = view->untag()->typed_data();
const bool backing_moved = old_backing != new_backing;
if (backing_moved) {
@@ -694,9 +694,9 @@
// The backing store didn't move, we therefore don't need to update the
// inner pointer.
if (view->untag()->data_ == 0) {
- ASSERT(RawSmiValue(view->untag()->offset_in_bytes_) == 0 &&
- RawSmiValue(view->untag()->length_) == 0 &&
- view->untag()->typed_data_ == Object::null());
+ ASSERT(RawSmiValue(view->untag()->offset_in_bytes()) == 0 &&
+ RawSmiValue(view->untag()->length()) == 0 &&
+ view->untag()->typed_data() == Object::null());
}
}
}
diff --git a/runtime/vm/heap/compactor.h b/runtime/vm/heap/compactor.h
index 9dfa96d..164c214 100644
--- a/runtime/vm/heap/compactor.h
+++ b/runtime/vm/heap/compactor.h
@@ -40,8 +40,8 @@
void ForwardPointer(ObjectPtr* ptr);
void ForwardCompressedPointer(uword heap_base, CompressedObjectPtr* ptr);
void VisitTypedDataViewPointers(TypedDataViewPtr view,
- ObjectPtr* first,
- ObjectPtr* last);
+ CompressedObjectPtr* first,
+ CompressedObjectPtr* last);
void VisitPointers(ObjectPtr* first, ObjectPtr* last);
void VisitCompressedPointers(uword heap_base,
CompressedObjectPtr* first,
diff --git a/runtime/vm/heap/scavenger.cc b/runtime/vm/heap/scavenger.cc
index 6f0b4c3..bdc785c 100644
--- a/runtime/vm/heap/scavenger.cc
+++ b/runtime/vm/heap/scavenger.cc
@@ -122,8 +122,8 @@
delayed_weak_properties_(WeakProperty::null()) {}
virtual void VisitTypedDataViewPointers(TypedDataViewPtr view,
- ObjectPtr* first,
- ObjectPtr* last) {
+ CompressedObjectPtr* first,
+ CompressedObjectPtr* last) {
// TypedDataViews require extra processing to update their
// PointerBase::data_ pointer. If the underlying typed data is external, no
// update is needed. If the underlying typed data is internal, the pointer
@@ -140,11 +140,11 @@
view->untag()->data_ != view->untag()->DataFieldForInternalTypedData();
// Forward all fields of the typed data view.
- VisitPointers(first, last);
+ VisitCompressedPointers(view->heap_base(), first, last);
if (view->untag()->data_ == nullptr) {
- ASSERT(RawSmiValue(view->untag()->offset_in_bytes_) == 0 &&
- RawSmiValue(view->untag()->length_) == 0);
+ ASSERT(RawSmiValue(view->untag()->offset_in_bytes()) == 0 &&
+ RawSmiValue(view->untag()->length()) == 0);
ASSERT(is_external);
return;
}
@@ -156,7 +156,7 @@
ASSERT(IsTypedDataViewClassId(view->GetClassIdMayBeSmi()));
// Validate that the backing store is not a forwarding word.
- TypedDataBasePtr td = view->untag()->typed_data_;
+ TypedDataBasePtr td = view->untag()->typed_data();
ASSERT(td->IsHeapObject());
const uword td_header =
*reinterpret_cast<uword*>(UntaggedObject::ToAddr(td));
diff --git a/runtime/vm/image_snapshot.cc b/runtime/vm/image_snapshot.cc
index 25ace1d..f20022e 100644
--- a/runtime/vm/image_snapshot.cc
+++ b/runtime/vm/image_snapshot.cc
@@ -535,9 +535,9 @@
RELEASE_ASSERT(String::GetCachedHash(str.ptr()) != 0);
RELEASE_ASSERT(str.IsOneByteString() || str.IsTwoByteString());
- stream->WriteTargetWord(static_cast<uword>(str.ptr()->untag()->length_));
+ stream->WriteTargetWord(static_cast<uword>(str.ptr()->untag()->length()));
#if !defined(HASH_IN_OBJECT_HEADER)
- stream->WriteTargetWord(static_cast<uword>(str.ptr()->untag()->hash_));
+ stream->WriteTargetWord(static_cast<uword>(str.ptr()->untag()->hash()));
#endif
ASSERT_EQUAL(stream->Position() - object_start,
compiler::target::String::InstanceSize());
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 9cf9ba7..6eff1b4 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -9994,7 +9994,7 @@
FunctionTypePtr FunctionType::New(Heap::Space space) {
ObjectPtr raw =
Object::Allocate(FunctionType::kClassId, FunctionType::InstanceSize(),
- space, /*compressed*/ false);
+ space, /*compressed*/ true);
return static_cast<FunctionTypePtr>(raw);
}
@@ -20616,7 +20616,7 @@
TypePtr Type::New(Heap::Space space) {
ObjectPtr raw = Object::Allocate(Type::kClassId, Type::InstanceSize(), space,
- /*compressed*/ false);
+ /*compressed*/ true);
return static_cast<TypePtr>(raw);
}
@@ -21011,7 +21011,7 @@
TypeRefPtr TypeRef::New() {
ObjectPtr raw = Object::Allocate(TypeRef::kClassId, TypeRef::InstanceSize(),
- Heap::kOld, /*compressed*/ false);
+ Heap::kOld, /*compressed*/ true);
return static_cast<TypeRefPtr>(raw);
}
@@ -21518,7 +21518,7 @@
TypeParameterPtr TypeParameter::New() {
ObjectPtr raw =
Object::Allocate(TypeParameter::kClassId, TypeParameter::InstanceSize(),
- Heap::kOld, /*compressed*/ false);
+ Heap::kOld, /*compressed*/ true);
return static_cast<TypeParameterPtr>(raw);
}
@@ -23190,7 +23190,7 @@
{
ObjectPtr raw = Object::Allocate(OneByteString::kClassId,
OneByteString::InstanceSize(len), space,
- /*compressed*/ false);
+ /*compressed*/ true);
NoSafepointScope no_safepoint;
OneByteStringPtr result = static_cast<OneByteStringPtr>(raw);
result->untag()->set_length(Smi::New(len));
@@ -23398,7 +23398,7 @@
{
ObjectPtr raw = Object::Allocate(TwoByteString::kClassId,
TwoByteString::InstanceSize(len), space,
- /*compressed*/ false);
+ /*compressed*/ true);
NoSafepointScope no_safepoint;
result ^= raw;
result.SetLength(len);
@@ -23555,7 +23555,7 @@
{
ObjectPtr raw = Object::Allocate(ExternalOneByteString::kClassId,
ExternalOneByteString::InstanceSize(),
- space, /*compressed*/ false);
+ space, /*compressed*/ true);
NoSafepointScope no_safepoint;
result ^= raw;
result.SetLength(len);
@@ -23585,7 +23585,7 @@
{
ObjectPtr raw = Object::Allocate(ExternalTwoByteString::kClassId,
ExternalTwoByteString::InstanceSize(),
- space, /*compressed*/ false);
+ space, /*compressed*/ true);
NoSafepointScope no_safepoint;
result ^= raw;
result.SetLength(len);
@@ -24306,7 +24306,7 @@
const intptr_t length_in_bytes = len * ElementSizeInBytes(class_id);
ObjectPtr raw =
Object::Allocate(class_id, TypedData::InstanceSize(length_in_bytes),
- space, /*compressed*/ false);
+ space, /*compressed*/ true);
NoSafepointScope no_safepoint;
result ^= raw;
result.SetLength(len);
@@ -24353,7 +24353,7 @@
{
ObjectPtr raw =
Object::Allocate(class_id, ExternalTypedData::InstanceSize(), space,
- /*compressed*/ false);
+ /*compressed*/ true);
NoSafepointScope no_safepoint;
result ^= raw;
result.SetLength(len);
@@ -24375,7 +24375,7 @@
auto& result = TypedDataView::Handle();
{
ObjectPtr raw = Object::Allocate(class_id, TypedDataView::InstanceSize(),
- space, /*compressed*/ false);
+ space, /*compressed*/ true);
NoSafepointScope no_safepoint;
result ^= raw;
result.Clear();
@@ -24497,7 +24497,7 @@
{
ObjectPtr raw =
Object::Allocate(ReceivePort::kClassId, ReceivePort::InstanceSize(),
- space, /*compressed*/ false);
+ space, /*compressed*/ true);
NoSafepointScope no_safepoint;
result ^= raw;
result.untag()->set_send_port(send_port.ptr());
@@ -24802,7 +24802,7 @@
{
ObjectPtr raw =
Object::Allocate(StackTrace::kClassId, StackTrace::InstanceSize(),
- space, /*compressed*/ false);
+ space, /*compressed*/ true);
NoSafepointScope no_safepoint;
result ^= raw;
}
@@ -24822,7 +24822,7 @@
{
ObjectPtr raw =
Object::Allocate(StackTrace::kClassId, StackTrace::InstanceSize(),
- space, /*compressed*/ false);
+ space, /*compressed*/ true);
NoSafepointScope no_safepoint;
result ^= raw;
}
@@ -25128,7 +25128,29 @@
void RegExp::set_function(intptr_t cid,
bool sticky,
const Function& value) const {
- StorePointer(FunctionAddr(cid, sticky), value.ptr());
+ if (sticky) {
+ switch (cid) {
+ case kOneByteStringCid:
+ return untag()->set_one_byte_sticky(value.ptr());
+ case kTwoByteStringCid:
+ return untag()->set_two_byte_sticky(value.ptr());
+ case kExternalOneByteStringCid:
+ return untag()->set_external_one_byte_sticky(value.ptr());
+ case kExternalTwoByteStringCid:
+ return untag()->set_external_two_byte_sticky(value.ptr());
+ }
+ } else {
+ switch (cid) {
+ case kOneByteStringCid:
+ return untag()->set_one_byte(value.ptr());
+ case kTwoByteStringCid:
+ return untag()->set_two_byte(value.ptr());
+ case kExternalOneByteStringCid:
+ return untag()->set_external_one_byte(value.ptr());
+ case kExternalTwoByteStringCid:
+ return untag()->set_external_two_byte(value.ptr());
+ }
+ }
}
void RegExp::set_bytecode(bool is_one_byte,
@@ -25149,16 +25171,8 @@
}
}
-void RegExp::set_num_bracket_expressions(SmiPtr value) const {
- untag()->set_num_bracket_expressions(value);
-}
-
-void RegExp::set_num_bracket_expressions(const Smi& value) const {
- untag()->set_num_bracket_expressions(value.ptr());
-}
-
void RegExp::set_num_bracket_expressions(intptr_t value) const {
- untag()->set_num_bracket_expressions(Smi::New(value));
+ untag()->num_bracket_expressions_ = value;
}
void RegExp::set_capture_name_map(const Array& array) const {
@@ -25169,11 +25183,12 @@
RegExp& result = RegExp::Handle();
{
ObjectPtr raw = Object::Allocate(RegExp::kClassId, RegExp::InstanceSize(),
- space, /*compressed*/ false);
+ space, /*compressed*/ true);
NoSafepointScope no_safepoint;
result ^= raw;
result.set_type(kUninitialized);
result.set_flags(RegExpFlags());
+ result.set_num_bracket_expressions(-1);
result.set_num_registers(/*is_one_byte=*/false, -1);
result.set_num_registers(/*is_one_byte=*/true, -1);
}
@@ -25299,7 +25314,7 @@
{
ObjectPtr raw = Object::Allocate(MirrorReference::kClassId,
MirrorReference::InstanceSize(), space,
- /*compressed*/ false);
+ /*compressed*/ true);
NoSafepointScope no_safepoint;
result ^= raw;
}
@@ -25337,7 +25352,7 @@
// No tag with label exists, create and register with isolate tag table.
{
ObjectPtr raw = Object::Allocate(UserTag::kClassId, UserTag::InstanceSize(),
- space, /*compressed*/ false);
+ space, /*compressed*/ true);
NoSafepointScope no_safepoint;
result ^= raw;
}
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index 6848241..4f4fb6c 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -10982,18 +10982,18 @@
}
StringPtr pattern() const { return untag()->pattern(); }
- SmiPtr num_bracket_expressions() const {
- return untag()->num_bracket_expressions();
+ intptr_t num_bracket_expressions() const {
+ return untag()->num_bracket_expressions_;
}
ArrayPtr capture_name_map() const { return untag()->capture_name_map(); }
TypedDataPtr bytecode(bool is_one_byte, bool sticky) const {
if (sticky) {
- return TypedData::RawCast(is_one_byte ? untag()->one_byte_sticky_
- : untag()->two_byte_sticky_);
+ return TypedData::RawCast(is_one_byte ? untag()->one_byte_sticky()
+ : untag()->two_byte_sticky());
} else {
- return TypedData::RawCast(is_one_byte ? untag()->one_byte_
- : untag()->two_byte_);
+ return TypedData::RawCast(is_one_byte ? untag()->one_byte()
+ : untag()->two_byte());
}
}
@@ -11026,13 +11026,33 @@
return -1;
}
- FunctionPtr* FunctionAddr(intptr_t cid, bool sticky) const {
- return reinterpret_cast<FunctionPtr*>(
- FieldAddrAtOffset(function_offset(cid, sticky)));
- }
-
FunctionPtr function(intptr_t cid, bool sticky) const {
- return *FunctionAddr(cid, sticky);
+ if (sticky) {
+ switch (cid) {
+ case kOneByteStringCid:
+ return static_cast<FunctionPtr>(untag()->one_byte_sticky());
+ case kTwoByteStringCid:
+ return static_cast<FunctionPtr>(untag()->two_byte_sticky());
+ case kExternalOneByteStringCid:
+ return static_cast<FunctionPtr>(untag()->external_one_byte_sticky());
+ case kExternalTwoByteStringCid:
+ return static_cast<FunctionPtr>(untag()->external_two_byte_sticky());
+ }
+ } else {
+ switch (cid) {
+ case kOneByteStringCid:
+ return static_cast<FunctionPtr>(untag()->one_byte());
+ case kTwoByteStringCid:
+ return static_cast<FunctionPtr>(untag()->two_byte());
+ case kExternalOneByteStringCid:
+ return static_cast<FunctionPtr>(untag()->external_one_byte());
+ case kExternalTwoByteStringCid:
+ return static_cast<FunctionPtr>(untag()->external_two_byte());
+ }
+ }
+
+ UNREACHABLE();
+ return Function::null();
}
void set_pattern(const String& pattern) const;
@@ -11426,7 +11446,7 @@
inline intptr_t FunctionType::Hash() const {
ASSERT(IsFinalized());
- intptr_t result = Smi::Value(untag()->hash_);
+ intptr_t result = Smi::Value(untag()->hash());
if (result != 0) {
return result;
}
diff --git a/runtime/vm/object_graph.cc b/runtime/vm/object_graph.cc
index 4963b07..c9b0bf3 100644
--- a/runtime/vm/object_graph.cc
+++ b/runtime/vm/object_graph.cc
@@ -905,7 +905,7 @@
sizeof(double));
} else if (cid == kOneByteStringCid) {
OneByteStringPtr str = static_cast<OneByteStringPtr>(obj);
- intptr_t len = Smi::Value(str->untag()->length_);
+ intptr_t len = Smi::Value(str->untag()->length());
intptr_t trunc_len = Utils::Minimum(len, kMaxStringElements);
writer_->WriteUnsigned(kLatin1Data);
writer_->WriteUnsigned(len);
@@ -913,7 +913,7 @@
writer_->WriteBytes(&str->untag()->data()[0], trunc_len);
} else if (cid == kExternalOneByteStringCid) {
ExternalOneByteStringPtr str = static_cast<ExternalOneByteStringPtr>(obj);
- intptr_t len = Smi::Value(str->untag()->length_);
+ intptr_t len = Smi::Value(str->untag()->length());
intptr_t trunc_len = Utils::Minimum(len, kMaxStringElements);
writer_->WriteUnsigned(kLatin1Data);
writer_->WriteUnsigned(len);
@@ -921,7 +921,7 @@
writer_->WriteBytes(&str->untag()->external_data_[0], trunc_len);
} else if (cid == kTwoByteStringCid) {
TwoByteStringPtr str = static_cast<TwoByteStringPtr>(obj);
- intptr_t len = Smi::Value(str->untag()->length_);
+ intptr_t len = Smi::Value(str->untag()->length());
intptr_t trunc_len = Utils::Minimum(len, kMaxStringElements);
writer_->WriteUnsigned(kUTF16Data);
writer_->WriteUnsigned(len);
@@ -929,7 +929,7 @@
writer_->WriteBytes(&str->untag()->data()[0], trunc_len * 2);
} else if (cid == kExternalTwoByteStringCid) {
ExternalTwoByteStringPtr str = static_cast<ExternalTwoByteStringPtr>(obj);
- intptr_t len = Smi::Value(str->untag()->length_);
+ intptr_t len = Smi::Value(str->untag()->length());
intptr_t trunc_len = Utils::Minimum(len, kMaxStringElements);
writer_->WriteUnsigned(kUTF16Data);
writer_->WriteUnsigned(len);
@@ -953,11 +953,11 @@
} else if (IsTypedDataClassId(cid)) {
writer_->WriteUnsigned(kLengthData);
writer_->WriteUnsigned(
- Smi::Value(static_cast<TypedDataPtr>(obj)->untag()->length_));
+ Smi::Value(static_cast<TypedDataPtr>(obj)->untag()->length()));
} else if (IsExternalTypedDataClassId(cid)) {
writer_->WriteUnsigned(kLengthData);
- writer_->WriteUnsigned(
- Smi::Value(static_cast<ExternalTypedDataPtr>(obj)->untag()->length_));
+ writer_->WriteUnsigned(Smi::Value(
+ static_cast<ExternalTypedDataPtr>(obj)->untag()->length()));
} else if (cid == kFunctionCid) {
writer_->WriteUnsigned(kNameData);
ScrubAndWriteUtf8(static_cast<FunctionPtr>(obj)->untag()->name());
diff --git a/runtime/vm/raw_object.cc b/runtime/vm/raw_object.cc
index 18db2fd..7fb0ce7 100644
--- a/runtime/vm/raw_object.cc
+++ b/runtime/vm/raw_object.cc
@@ -131,14 +131,14 @@
case kOneByteStringCid: {
const OneByteStringPtr raw_string =
static_cast<const OneByteStringPtr>(this);
- intptr_t string_length = Smi::Value(raw_string->untag()->length_);
+ intptr_t string_length = Smi::Value(raw_string->untag()->length());
instance_size = OneByteString::InstanceSize(string_length);
break;
}
case kTwoByteStringCid: {
const TwoByteStringPtr raw_string =
static_cast<const TwoByteStringPtr>(this);
- intptr_t string_length = Smi::Value(raw_string->untag()->length_);
+ intptr_t string_length = Smi::Value(raw_string->untag()->length());
instance_size = TwoByteString::InstanceSize(string_length);
break;
}
@@ -160,7 +160,7 @@
#define SIZE_FROM_CLASS(clazz) case kTypedData##clazz##Cid:
CLASS_LIST_TYPED_DATA(SIZE_FROM_CLASS) {
const TypedDataPtr raw_obj = static_cast<const TypedDataPtr>(this);
- intptr_t array_len = Smi::Value(raw_obj->untag()->length_);
+ intptr_t array_len = Smi::Value(raw_obj->untag()->length());
intptr_t lengthInBytes =
array_len * TypedData::ElementSizeInBytes(class_id);
instance_size = TypedData::InstanceSize(lengthInBytes);
@@ -460,7 +460,7 @@
Type##Ptr raw_obj, ObjectPointerVisitor* visitor) { \
/* Make sure that we got here with the tagged pointer as this. */ \
ASSERT(raw_obj->IsHeapObject()); \
- ASSERT_UNCOMPRESSED(Type); \
+ ASSERT_COMPRESSED(Type); \
visitor->VisitTypedDataViewPointers(raw_obj, raw_obj->untag()->from(), \
raw_obj->untag()->to()); \
return Type::InstanceSize(); \
@@ -535,13 +535,13 @@
COMPRESSED_VISITOR(Namespace)
COMPRESSED_VISITOR(KernelProgramInfo)
COMPRESSED_VISITOR(WeakSerializationReference)
-REGULAR_VISITOR(Type)
-REGULAR_VISITOR(FunctionType)
-REGULAR_VISITOR(TypeRef)
-REGULAR_VISITOR(TypeParameter)
+COMPRESSED_VISITOR(Type)
+COMPRESSED_VISITOR(FunctionType)
+COMPRESSED_VISITOR(TypeRef)
+COMPRESSED_VISITOR(TypeParameter)
COMPRESSED_VISITOR(Function)
REGULAR_VISITOR(Closure)
-REGULAR_VISITOR(LibraryPrefix)
+COMPRESSED_VISITOR(LibraryPrefix)
REGULAR_VISITOR(SingleTargetCache)
REGULAR_VISITOR(UnlinkedCall)
REGULAR_VISITOR(MonomorphicSmiableCall)
@@ -551,18 +551,18 @@
COMPRESSED_VISITOR(LanguageError)
COMPRESSED_VISITOR(UnhandledException)
COMPRESSED_VISITOR(UnwindError)
-REGULAR_VISITOR(ExternalOneByteString)
-REGULAR_VISITOR(ExternalTwoByteString)
+COMPRESSED_VISITOR(ExternalOneByteString)
+COMPRESSED_VISITOR(ExternalTwoByteString)
REGULAR_VISITOR(GrowableObjectArray)
REGULAR_VISITOR(LinkedHashMap)
-REGULAR_VISITOR(ExternalTypedData)
+COMPRESSED_VISITOR(ExternalTypedData)
TYPED_DATA_VIEW_VISITOR(TypedDataView)
-REGULAR_VISITOR(ReceivePort)
-REGULAR_VISITOR(StackTrace)
-REGULAR_VISITOR(RegExp)
+COMPRESSED_VISITOR(ReceivePort)
+COMPRESSED_VISITOR(StackTrace)
+COMPRESSED_VISITOR(RegExp)
REGULAR_VISITOR(WeakProperty)
-REGULAR_VISITOR(MirrorReference)
-REGULAR_VISITOR(UserTag)
+COMPRESSED_VISITOR(MirrorReference)
+COMPRESSED_VISITOR(UserTag)
REGULAR_VISITOR(SubtypeTestCache)
COMPRESSED_VISITOR(LoadingUnit)
VARIABLE_VISITOR(TypeArguments, Smi::Value(raw_obj->untag()->length_))
@@ -570,9 +570,10 @@
VARIABLE_COMPRESSED_VISITOR(ExceptionHandlers, raw_obj->untag()->num_entries_)
VARIABLE_VISITOR(Context, raw_obj->untag()->num_variables_)
VARIABLE_VISITOR(Array, Smi::Value(raw_obj->untag()->length()))
-VARIABLE_VISITOR(TypedData,
- TypedData::ElementSizeInBytes(raw_obj->GetClassId()) *
- Smi::Value(raw_obj->untag()->length_))
+VARIABLE_COMPRESSED_VISITOR(
+ TypedData,
+ TypedData::ElementSizeInBytes(raw_obj->GetClassId()) *
+ Smi::Value(raw_obj->untag()->length()))
VARIABLE_COMPRESSED_VISITOR(ContextScope, raw_obj->untag()->num_variables_)
NULL_VISITOR(Mint)
NULL_VISITOR(Double)
@@ -583,7 +584,7 @@
NULL_VISITOR(Capability)
NULL_VISITOR(SendPort)
NULL_VISITOR(TransferableTypedData)
-REGULAR_VISITOR(Pointer)
+COMPRESSED_VISITOR(Pointer)
NULL_VISITOR(DynamicLibrary)
VARIABLE_NULL_VISITOR(Instructions, Instructions::Size(raw_obj))
VARIABLE_NULL_VISITOR(InstructionsSection, InstructionsSection::Size(raw_obj))
@@ -591,8 +592,8 @@
VARIABLE_NULL_VISITOR(CodeSourceMap, raw_obj->untag()->length_)
VARIABLE_NULL_VISITOR(CompressedStackMaps,
CompressedStackMaps::PayloadSizeOf(raw_obj))
-VARIABLE_NULL_VISITOR(OneByteString, Smi::Value(raw_obj->untag()->length_))
-VARIABLE_NULL_VISITOR(TwoByteString, Smi::Value(raw_obj->untag()->length_))
+VARIABLE_NULL_VISITOR(OneByteString, Smi::Value(raw_obj->untag()->length()))
+VARIABLE_NULL_VISITOR(TwoByteString, Smi::Value(raw_obj->untag()->length()))
// Abstract types don't have their visitor called.
UNREACHABLE_VISITOR(AbstractType)
UNREACHABLE_VISITOR(CallSiteData)
diff --git a/runtime/vm/raw_object.h b/runtime/vm/raw_object.h
index 5776c38..b24f93e 100644
--- a/runtime/vm/raw_object.h
+++ b/runtime/vm/raw_object.h
@@ -2368,19 +2368,22 @@
class UntaggedLibraryPrefix : public UntaggedInstance {
RAW_HEAP_OBJECT_IMPLEMENTATION(LibraryPrefix);
- VISIT_FROM(ObjectPtr, name)
- POINTER_FIELD(StringPtr, name) // Library prefix name.
- POINTER_FIELD(ArrayPtr, imports) // Libraries imported with this prefix.
- POINTER_FIELD(LibraryPtr, importer) // Library which declares this prefix.
- VISIT_TO(ObjectPtr, importer)
- ObjectPtr* to_snapshot(Snapshot::Kind kind) {
+ VISIT_FROM(CompressedObjectPtr, name)
+ // Library prefix name.
+ COMPRESSED_POINTER_FIELD(StringPtr, name)
+ // Libraries imported with this prefix.
+ COMPRESSED_POINTER_FIELD(ArrayPtr, imports)
+ // Library which declares this prefix.
+ COMPRESSED_POINTER_FIELD(LibraryPtr, importer)
+ VISIT_TO(CompressedObjectPtr, importer)
+ CompressedObjectPtr* to_snapshot(Snapshot::Kind kind) {
switch (kind) {
case Snapshot::kFullAOT:
- return reinterpret_cast<ObjectPtr*>(&imports_);
+ return reinterpret_cast<CompressedObjectPtr*>(&imports_);
case Snapshot::kFull:
case Snapshot::kFullCore:
case Snapshot::kFullJIT:
- return reinterpret_cast<ObjectPtr*>(&importer_);
+ return reinterpret_cast<CompressedObjectPtr*>(&importer_);
case Snapshot::kMessage:
case Snapshot::kNone:
case Snapshot::kInvalid:
@@ -2428,7 +2431,7 @@
static constexpr intptr_t kTypeStateBitSize = 2;
uword type_test_stub_entry_point_; // Accessed from generated code.
- POINTER_FIELD(
+ COMPRESSED_POINTER_FIELD(
CodePtr,
type_test_stub) // Must be the last field, since subclasses use it
// in their VISIT_FROM.
@@ -2444,15 +2447,15 @@
private:
RAW_HEAP_OBJECT_IMPLEMENTATION(Type);
- VISIT_FROM(ObjectPtr, type_test_stub)
- POINTER_FIELD(SmiPtr, type_class_id)
- POINTER_FIELD(TypeArgumentsPtr, arguments)
- POINTER_FIELD(SmiPtr, hash)
- VISIT_TO(ObjectPtr, hash)
+ VISIT_FROM(CompressedObjectPtr, type_test_stub)
+ COMPRESSED_POINTER_FIELD(SmiPtr, type_class_id)
+ COMPRESSED_POINTER_FIELD(TypeArgumentsPtr, arguments)
+ COMPRESSED_POINTER_FIELD(SmiPtr, hash)
+ VISIT_TO(CompressedObjectPtr, hash)
uint8_t type_state_;
uint8_t nullability_;
- ObjectPtr* to_snapshot(Snapshot::Kind kind) { return to(); }
+ CompressedObjectPtr* to_snapshot(Snapshot::Kind kind) { return to(); }
friend class CidRewriteVisitor;
friend class UntaggedTypeArguments;
@@ -2462,13 +2465,14 @@
private:
RAW_HEAP_OBJECT_IMPLEMENTATION(FunctionType);
- VISIT_FROM(ObjectPtr, type_test_stub)
- POINTER_FIELD(TypeArgumentsPtr, type_parameters) // Array of TypeParameter.
- POINTER_FIELD(AbstractTypePtr, result_type)
- POINTER_FIELD(ArrayPtr, parameter_types)
- POINTER_FIELD(ArrayPtr, parameter_names);
- POINTER_FIELD(SmiPtr, hash)
- VISIT_TO(ObjectPtr, hash)
+ VISIT_FROM(CompressedObjectPtr, type_test_stub)
+ // Array of TypeParameter.
+ COMPRESSED_POINTER_FIELD(TypeArgumentsPtr, type_parameters)
+ COMPRESSED_POINTER_FIELD(AbstractTypePtr, result_type)
+ COMPRESSED_POINTER_FIELD(ArrayPtr, parameter_types)
+ COMPRESSED_POINTER_FIELD(ArrayPtr, parameter_names);
+ COMPRESSED_POINTER_FIELD(SmiPtr, hash)
+ VISIT_TO(CompressedObjectPtr, hash)
uint32_t packed_fields_; // Number of parent type args and own parameters.
uint8_t type_state_;
uint8_t nullability_;
@@ -2515,7 +2519,7 @@
"a Smi on the target architecture");
private:
- ObjectPtr* to_snapshot(Snapshot::Kind kind) { return to(); }
+ CompressedObjectPtr* to_snapshot(Snapshot::Kind kind) { return to(); }
friend class Function;
};
@@ -2524,27 +2528,27 @@
private:
RAW_HEAP_OBJECT_IMPLEMENTATION(TypeRef);
- VISIT_FROM(ObjectPtr, type_test_stub)
- POINTER_FIELD(AbstractTypePtr, type) // The referenced type.
- VISIT_TO(ObjectPtr, type)
- ObjectPtr* to_snapshot(Snapshot::Kind kind) { return to(); }
+ VISIT_FROM(CompressedObjectPtr, type_test_stub)
+ COMPRESSED_POINTER_FIELD(AbstractTypePtr, type) // The referenced type.
+ VISIT_TO(CompressedObjectPtr, type)
+ CompressedObjectPtr* to_snapshot(Snapshot::Kind kind) { return to(); }
};
class UntaggedTypeParameter : public UntaggedAbstractType {
private:
RAW_HEAP_OBJECT_IMPLEMENTATION(TypeParameter);
- VISIT_FROM(ObjectPtr, type_test_stub)
- POINTER_FIELD(StringPtr, name)
- POINTER_FIELD(SmiPtr, hash)
- POINTER_FIELD(AbstractTypePtr,
- bound) // ObjectType if no explicit bound specified.
+ VISIT_FROM(CompressedObjectPtr, type_test_stub)
+ COMPRESSED_POINTER_FIELD(StringPtr, name)
+ COMPRESSED_POINTER_FIELD(SmiPtr, hash)
+ // ObjectType if no explicit bound specified.
+ COMPRESSED_POINTER_FIELD(AbstractTypePtr, bound)
// The instantiation to bounds of this parameter as calculated by the CFE.
//
// TODO(dartbug.com/43901): Once a separate TypeParameters class has been
// added, move these there and remove them from TypeParameter objects.
- POINTER_FIELD(AbstractTypePtr, default_argument)
- VISIT_TO(ObjectPtr, default_argument)
+ COMPRESSED_POINTER_FIELD(AbstractTypePtr, default_argument)
+ VISIT_TO(CompressedObjectPtr, default_argument)
ClassIdTagType parameterized_class_id_; // Or kFunctionCid for function tp.
// TODO(regis): Can we use uint8_t twice below? Or keep uint16_t?
// Warning: BuildTypeParameterTypeTestStub assumes uint16_t.
@@ -2562,7 +2566,7 @@
static constexpr intptr_t kFlagsBitSize = GenericCovariantImplBit::kNextBit;
private:
- ObjectPtr* to_snapshot(Snapshot::Kind kind) { return to(); }
+ CompressedObjectPtr* to_snapshot(Snapshot::Kind kind) { return to(); }
friend class CidRewriteVisitor;
};
@@ -2653,13 +2657,13 @@
RAW_HEAP_OBJECT_IMPLEMENTATION(String);
protected:
- VISIT_FROM(ObjectPtr, length)
- SMI_FIELD(SmiPtr, length)
+ VISIT_FROM(CompressedObjectPtr, length)
+ COMPRESSED_SMI_FIELD(SmiPtr, length)
#if !defined(HASH_IN_OBJECT_HEADER)
- SMI_FIELD(SmiPtr, hash)
- VISIT_TO(ObjectPtr, hash)
+ COMPRESSED_SMI_FIELD(SmiPtr, hash)
+ VISIT_TO(CompressedObjectPtr, hash)
#else
- VISIT_TO(ObjectPtr, length)
+ VISIT_TO(CompressedObjectPtr, length)
#endif
private:
@@ -2728,7 +2732,7 @@
protected:
// The length of the view in element sizes (obtainable via
// [TypedDataBase::ElementSizeInBytes]).
- SMI_FIELD(SmiPtr, length);
+ COMPRESSED_SMI_FIELD(SmiPtr, length);
private:
friend class UntaggedTypedDataView;
@@ -2747,8 +2751,8 @@
void RecomputeDataField() { data_ = internal_data(); }
protected:
- VISIT_FROM(ObjectPtr, length)
- VISIT_TO_LENGTH(ObjectPtr, &length_)
+ VISIT_FROM(CompressedObjectPtr, length)
+ VISIT_TO_LENGTH(CompressedObjectPtr, &length_)
// Variable length data follows here.
@@ -2782,7 +2786,7 @@
public:
// Recompute [data_] based on internal/external [typed_data_].
void RecomputeDataField() {
- const intptr_t offset_in_bytes = RawSmiValue(offset_in_bytes_);
+ const intptr_t offset_in_bytes = RawSmiValue(this->offset_in_bytes());
uint8_t* payload = typed_data()->untag()->data_;
data_ = payload + offset_in_bytes;
}
@@ -2798,7 +2802,7 @@
}
uint8_t* DataFieldForInternalTypedData() const {
- const intptr_t offset_in_bytes = RawSmiValue(offset_in_bytes_);
+ const intptr_t offset_in_bytes = RawSmiValue(this->offset_in_bytes());
uint8_t* payload =
reinterpret_cast<uint8_t*>(UntaggedObject::ToAddr(typed_data()) +
UntaggedTypedData::payload_offset());
@@ -2808,12 +2812,12 @@
void ValidateInnerPointer() {
if (typed_data()->untag()->GetClassId() == kNullCid) {
// The view object must have gotten just initialized.
- if (data_ != nullptr || RawSmiValue(offset_in_bytes_) != 0 ||
- RawSmiValue(length_) != 0) {
+ if (data_ != nullptr || RawSmiValue(offset_in_bytes()) != 0 ||
+ RawSmiValue(length()) != 0) {
FATAL("RawTypedDataView has invalid inner pointer.");
}
} else {
- const intptr_t offset_in_bytes = RawSmiValue(offset_in_bytes_);
+ const intptr_t offset_in_bytes = RawSmiValue(this->offset_in_bytes());
uint8_t* payload = typed_data()->untag()->data_;
if ((payload + offset_in_bytes) != data_) {
FATAL("RawTypedDataView has invalid inner pointer.");
@@ -2822,11 +2826,11 @@
}
protected:
- VISIT_FROM(ObjectPtr, length)
- POINTER_FIELD(TypedDataBasePtr, typed_data)
- SMI_FIELD(SmiPtr, offset_in_bytes)
- VISIT_TO(ObjectPtr, offset_in_bytes)
- ObjectPtr* to_snapshot(Snapshot::Kind kind) { return to(); }
+ VISIT_FROM(CompressedObjectPtr, length)
+ COMPRESSED_POINTER_FIELD(TypedDataBasePtr, typed_data)
+ COMPRESSED_SMI_FIELD(SmiPtr, offset_in_bytes)
+ VISIT_TO(CompressedObjectPtr, offset_in_bytes)
+ CompressedObjectPtr* to_snapshot(Snapshot::Kind kind) { return to(); }
friend class Api;
friend class Object;
@@ -3002,16 +3006,16 @@
RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalTypedData);
protected:
- VISIT_FROM(ObjectPtr, length)
- VISIT_TO(ObjectPtr, length)
+ VISIT_FROM(CompressedObjectPtr, length)
+ VISIT_TO(CompressedObjectPtr, length)
};
class UntaggedPointer : public UntaggedPointerBase {
RAW_HEAP_OBJECT_IMPLEMENTATION(Pointer);
- VISIT_FROM(ObjectPtr, type_arguments)
- POINTER_FIELD(TypeArgumentsPtr, type_arguments)
- VISIT_TO(ObjectPtr, type_arguments)
+ VISIT_FROM(CompressedObjectPtr, type_arguments)
+ COMPRESSED_POINTER_FIELD(TypeArgumentsPtr, type_arguments)
+ VISIT_TO(CompressedObjectPtr, type_arguments)
friend class Pointer;
};
@@ -3043,15 +3047,15 @@
class UntaggedReceivePort : public UntaggedInstance {
RAW_HEAP_OBJECT_IMPLEMENTATION(ReceivePort);
- VISIT_FROM(ObjectPtr, send_port)
- POINTER_FIELD(SendPortPtr, send_port)
- POINTER_FIELD(InstancePtr, handler)
+ VISIT_FROM(CompressedObjectPtr, send_port)
+ COMPRESSED_POINTER_FIELD(SendPortPtr, send_port)
+ COMPRESSED_POINTER_FIELD(InstancePtr, handler)
#if !defined(PRODUCT)
- POINTER_FIELD(StringPtr, debug_name)
- POINTER_FIELD(StackTracePtr, allocation_location)
- VISIT_TO(ObjectPtr, allocation_location)
+ COMPRESSED_POINTER_FIELD(StringPtr, debug_name)
+ COMPRESSED_POINTER_FIELD(StackTracePtr, allocation_location)
+ VISIT_TO(CompressedObjectPtr, allocation_location)
#else
- VISIT_TO(ObjectPtr, handler)
+ VISIT_TO(CompressedObjectPtr, handler)
#endif // !defined(PRODUCT)
};
@@ -3067,15 +3071,16 @@
class UntaggedStackTrace : public UntaggedInstance {
RAW_HEAP_OBJECT_IMPLEMENTATION(StackTrace);
- VISIT_FROM(ObjectPtr, async_link)
- POINTER_FIELD(StackTracePtr,
- async_link); // Link to parent async stack trace.
- POINTER_FIELD(ArrayPtr,
- code_array); // Code object for each frame in the stack trace.
- POINTER_FIELD(TypedDataPtr, pc_offset_array); // Offset of PC for each frame.
+ VISIT_FROM(CompressedObjectPtr, async_link)
+ // Link to parent async stack trace.
+ COMPRESSED_POINTER_FIELD(StackTracePtr, async_link);
+ // Code object for each frame in the stack trace.
+ COMPRESSED_POINTER_FIELD(ArrayPtr, code_array);
+ // Offset of PC for each frame.
+ COMPRESSED_POINTER_FIELD(TypedDataPtr, pc_offset_array);
- VISIT_TO(ObjectPtr, pc_offset_array)
- ObjectPtr* to_snapshot(Snapshot::Kind kind) { return to(); }
+ VISIT_TO(CompressedObjectPtr, pc_offset_array)
+ CompressedObjectPtr* to_snapshot(Snapshot::Kind kind) { return to(); }
// False for pre-allocated stack trace (used in OOM and Stack overflow).
bool expand_inlined_;
@@ -3089,20 +3094,22 @@
class UntaggedRegExp : public UntaggedInstance {
RAW_HEAP_OBJECT_IMPLEMENTATION(RegExp);
- VISIT_FROM(ObjectPtr, num_bracket_expressions)
- POINTER_FIELD(SmiPtr, num_bracket_expressions)
- POINTER_FIELD(ArrayPtr, capture_name_map)
- POINTER_FIELD(StringPtr, pattern) // Pattern to be used for matching.
- POINTER_FIELD(ObjectPtr, one_byte) // FunctionPtr or TypedDataPtr
- POINTER_FIELD(ObjectPtr, two_byte)
- POINTER_FIELD(ObjectPtr, external_one_byte)
- POINTER_FIELD(ObjectPtr, external_two_byte)
- POINTER_FIELD(ObjectPtr, one_byte_sticky)
- POINTER_FIELD(ObjectPtr, two_byte_sticky)
- POINTER_FIELD(ObjectPtr, external_one_byte_sticky)
- POINTER_FIELD(ObjectPtr, external_two_byte_sticky)
- VISIT_TO(ObjectPtr, external_two_byte_sticky)
- ObjectPtr* to_snapshot(Snapshot::Kind kind) { return to(); }
+ VISIT_FROM(CompressedObjectPtr, capture_name_map)
+ COMPRESSED_POINTER_FIELD(ArrayPtr, capture_name_map)
+ // Pattern to be used for matching.
+ COMPRESSED_POINTER_FIELD(StringPtr, pattern)
+ COMPRESSED_POINTER_FIELD(ObjectPtr, one_byte) // FunctionPtr or TypedDataPtr
+ COMPRESSED_POINTER_FIELD(ObjectPtr, two_byte)
+ COMPRESSED_POINTER_FIELD(ObjectPtr, external_one_byte)
+ COMPRESSED_POINTER_FIELD(ObjectPtr, external_two_byte)
+ COMPRESSED_POINTER_FIELD(ObjectPtr, one_byte_sticky)
+ COMPRESSED_POINTER_FIELD(ObjectPtr, two_byte_sticky)
+ COMPRESSED_POINTER_FIELD(ObjectPtr, external_one_byte_sticky)
+ COMPRESSED_POINTER_FIELD(ObjectPtr, external_two_byte_sticky)
+ VISIT_TO(CompressedObjectPtr, external_two_byte_sticky)
+ CompressedObjectPtr* to_snapshot(Snapshot::Kind kind) { return to(); }
+
+ intptr_t num_bracket_expressions_;
// The same pattern may use different amount of registers if compiled
// for a one-byte target than a two-byte target. For example, we do not
@@ -3144,18 +3151,18 @@
class UntaggedMirrorReference : public UntaggedInstance {
RAW_HEAP_OBJECT_IMPLEMENTATION(MirrorReference);
- VISIT_FROM(ObjectPtr, referent)
- POINTER_FIELD(ObjectPtr, referent)
- VISIT_TO(ObjectPtr, referent)
+ VISIT_FROM(CompressedObjectPtr, referent)
+ COMPRESSED_POINTER_FIELD(ObjectPtr, referent)
+ VISIT_TO(CompressedObjectPtr, referent)
};
// UserTag are used by the profiler to track Dart script state.
class UntaggedUserTag : public UntaggedInstance {
RAW_HEAP_OBJECT_IMPLEMENTATION(UserTag);
- VISIT_FROM(ObjectPtr, label)
- POINTER_FIELD(StringPtr, label)
- VISIT_TO(ObjectPtr, label)
+ VISIT_FROM(CompressedObjectPtr, label)
+ COMPRESSED_POINTER_FIELD(StringPtr, label)
+ VISIT_TO(CompressedObjectPtr, label)
// Isolate unique tag.
uword tag_;
diff --git a/runtime/vm/raw_object_snapshot.cc b/runtime/vm/raw_object_snapshot.cc
index c6c8955..414430b 100644
--- a/runtime/vm/raw_object_snapshot.cc
+++ b/runtime/vm/raw_object_snapshot.cc
@@ -101,8 +101,8 @@
reader->EnqueueTypePostprocessing(type);
// Set all the object fields.
- READ_OBJECT_FIELDS(type, type.ptr()->untag()->from(),
- type.ptr()->untag()->to(), as_reference);
+ READ_COMPRESSED_OBJECT_FIELDS(type, type.ptr()->untag()->from(),
+ type.ptr()->untag()->to(), as_reference);
// Read in the type class.
(*reader->ClassHandle()) =
@@ -166,7 +166,7 @@
// Write out all the object pointer fields.
ASSERT(type_class_id() != Object::null());
SnapshotWriterVisitor visitor(writer, as_reference);
- visitor.VisitPointers(from(), to());
+ visitor.VisitCompressedPointers(heap_base(), from(), to());
// Write out the type class.
writer->WriteObjectImpl(type_class, as_reference);
@@ -187,8 +187,8 @@
reader->EnqueueTypePostprocessing(type_ref);
// Set all the object fields.
- READ_OBJECT_FIELDS(type_ref, type_ref.ptr()->untag()->from(),
- type_ref.ptr()->untag()->to(), kAsReference);
+ READ_COMPRESSED_OBJECT_FIELDS(type_ref, type_ref.ptr()->untag()->from(),
+ type_ref.ptr()->untag()->to(), kAsReference);
// Fill in the type testing stub.
Code& code = *reader->CodeHandle();
@@ -213,7 +213,7 @@
// Write out all the object pointer fields.
SnapshotWriterVisitor visitor(writer, kAsReference);
- visitor.VisitPointers(from(), to());
+ visitor.VisitCompressedPointers(heap_base(), from(), to());
}
TypeParameterPtr TypeParameter::ReadFrom(SnapshotReader* reader,
@@ -238,8 +238,9 @@
reader->EnqueueTypePostprocessing(type_parameter);
// Set all the object fields.
- READ_OBJECT_FIELDS(type_parameter, type_parameter.ptr()->untag()->from(),
- type_parameter.ptr()->untag()->to(), kAsReference);
+ READ_COMPRESSED_OBJECT_FIELDS(
+ type_parameter, type_parameter.ptr()->untag()->from(),
+ type_parameter.ptr()->untag()->to(), kAsReference);
// Read in the parameterized class.
(*reader->ClassHandle()) =
@@ -287,7 +288,7 @@
// Write out all the object pointer fields.
SnapshotWriterVisitor visitor(writer, kAsReference);
- visitor.VisitPointers(from(), to());
+ visitor.VisitCompressedPointers(heap_base(), from(), to());
// Write out the parameterized class (or Function if cid == kFunctionCid).
ClassPtr param_class =
@@ -1375,7 +1376,7 @@
bool as_reference) {
ASSERT(writer != NULL);
intptr_t cid = this->GetClassId();
- intptr_t length = Smi::Value(length_); // In elements.
+ intptr_t length = Smi::Value(this->length()); // In elements.
intptr_t external_cid;
intptr_t bytes;
switch (cid) {
@@ -1449,7 +1450,7 @@
// Write as external.
writer->WriteIndexedObject(external_cid);
writer->WriteTags(writer->GetObjectTags(this));
- writer->Write<ObjectPtr>(length_);
+ writer->Write<ObjectPtr>(this->length());
uint8_t* data = reinterpret_cast<uint8_t*>(this->data());
void* passed_data = malloc(bytes);
memmove(passed_data, data, bytes);
@@ -1462,7 +1463,7 @@
// Write as internal.
writer->WriteIndexedObject(cid);
writer->WriteTags(writer->GetObjectTags(this));
- writer->Write<ObjectPtr>(length_);
+ writer->Write<ObjectPtr>(this->length());
uint8_t* data = reinterpret_cast<uint8_t*>(this->data());
writer->Align(Zone::kAlignment);
writer->WriteBytes(data, bytes);
@@ -1475,7 +1476,7 @@
bool as_reference) {
ASSERT(writer != NULL);
intptr_t cid = this->GetClassId();
- intptr_t length = Smi::Value(length_); // In elements.
+ intptr_t length = Smi::Value(this->length()); // In elements.
intptr_t bytes;
switch (cid) {
case kExternalTypedDataInt8ArrayCid:
@@ -1531,7 +1532,7 @@
// Write as external.
writer->WriteIndexedObject(cid);
writer->WriteTags(writer->GetObjectTags(this));
- writer->Write<ObjectPtr>(length_);
+ writer->Write<ObjectPtr>(this->length());
uint8_t* data = reinterpret_cast<uint8_t*>(data_);
void* passed_data = malloc(bytes);
memmove(passed_data, data, bytes);
@@ -1547,7 +1548,7 @@
Snapshot::Kind kind,
bool as_reference) {
// Views have always a backing store.
- ASSERT(typed_data_ != Object::null());
+ ASSERT(typed_data() != Object::null());
// Write out the serialization header value for this object.
writer->WriteInlinedObjectHeader(object_id);
@@ -1557,9 +1558,9 @@
writer->WriteTags(writer->GetObjectTags(this));
// Write members.
- writer->Write<ObjectPtr>(offset_in_bytes_);
- writer->Write<ObjectPtr>(length_);
- writer->WriteObjectImpl(typed_data_, as_reference);
+ writer->Write<ObjectPtr>(offset_in_bytes());
+ writer->Write<ObjectPtr>(length());
+ writer->WriteObjectImpl(typed_data(), as_reference);
}
TypedDataViewPtr TypedDataView::ReadFrom(SnapshotReader* reader,
@@ -1713,14 +1714,13 @@
reader->AddBackRef(object_id, ®ex, kIsDeserialized);
// Read and Set all the other fields.
- *reader->SmiHandle() ^= reader->ReadObjectImpl(kAsInlinedObject);
- regex.set_num_bracket_expressions(*reader->SmiHandle());
-
*reader->ArrayHandle() ^= reader->ReadObjectImpl(kAsInlinedObject);
regex.set_capture_name_map(*reader->ArrayHandle());
*reader->StringHandle() ^= reader->ReadObjectImpl(kAsInlinedObject);
regex.set_pattern(*reader->StringHandle());
+ regex.StoreNonPointer(®ex.untag()->num_bracket_expressions_,
+ reader->Read<int32_t>());
regex.StoreNonPointer(®ex.untag()->num_one_byte_registers_,
reader->Read<int32_t>());
regex.StoreNonPointer(®ex.untag()->num_two_byte_registers_,
@@ -1751,9 +1751,9 @@
writer->WriteTags(writer->GetObjectTags(this));
// Write out all the other fields.
- writer->WriteObjectImpl(num_bracket_expressions_, kAsInlinedObject);
- writer->WriteObjectImpl(capture_name_map_, kAsInlinedObject);
- writer->WriteObjectImpl(pattern_, kAsInlinedObject);
+ writer->WriteObjectImpl(capture_name_map(), kAsInlinedObject);
+ writer->WriteObjectImpl(pattern(), kAsInlinedObject);
+ writer->Write<int32_t>(num_bracket_expressions_);
writer->Write<int32_t>(num_one_byte_registers_);
writer->Write<int32_t>(num_two_byte_registers_);
writer->Write<int8_t>(type_flags_);
diff --git a/runtime/vm/regexp_assembler_bytecode.cc b/runtime/vm/regexp_assembler_bytecode.cc
index 4d8841f..708297a 100644
--- a/runtime/vm/regexp_assembler_bytecode.cc
+++ b/runtime/vm/regexp_assembler_bytecode.cc
@@ -465,7 +465,7 @@
ASSERT(regexp.num_registers(is_one_byte) != -1);
return regexp.num_registers(is_one_byte) +
- (Smi::Value(regexp.num_bracket_expressions()) + 1) * 2;
+ (regexp.num_bracket_expressions() + 1) * 2;
}
static IrregexpInterpreter::IrregexpResult ExecRaw(const RegExp& regexp,
@@ -478,12 +478,9 @@
bool is_one_byte =
subject.IsOneByteString() || subject.IsExternalOneByteString();
- ASSERT(regexp.num_bracket_expressions() != Smi::null());
-
// We must have done EnsureCompiledIrregexp, so we can get the number of
// registers.
- int number_of_capture_registers =
- (Smi::Value(regexp.num_bracket_expressions()) + 1) * 2;
+ int number_of_capture_registers = (regexp.num_bracket_expressions() + 1) * 2;
int32_t* raw_output = &output[number_of_capture_registers];
// We do not touch the actual capture result registers until we know there
@@ -533,7 +530,7 @@
required_registers, zone);
if (result == IrregexpInterpreter::RE_SUCCESS) {
- intptr_t capture_count = Smi::Value(regexp.num_bracket_expressions());
+ intptr_t capture_count = regexp.num_bracket_expressions();
intptr_t capture_register_count = (capture_count + 1) * 2;
ASSERT(required_registers >= capture_register_count);
diff --git a/runtime/vm/tagged_pointer.h b/runtime/vm/tagged_pointer.h
index 8c11bf8..b0cb20d 100644
--- a/runtime/vm/tagged_pointer.h
+++ b/runtime/vm/tagged_pointer.h
@@ -191,9 +191,13 @@
ObjectPtr Decompress(uword heap_base) const { return *this; }
ObjectPtr DecompressSmi() const { return *this; }
uword heap_base() const {
+ // TODO(rmacnak): Why does Windows have trouble linking GetClassId used
+ // here?
+#if !defined(HOST_OS_WINDOWS)
ASSERT(IsHeapObject());
ASSERT(!IsInstructions());
ASSERT(!IsInstructionsSection());
+#endif
return tagged_pointer_ & kHeapBaseMask;
}
diff --git a/runtime/vm/visitor.h b/runtime/vm/visitor.h
index 8365418..fd2a78c 100644
--- a/runtime/vm/visitor.h
+++ b/runtime/vm/visitor.h
@@ -28,9 +28,9 @@
//
// Range of pointers to visit 'first' <= pointer <= 'last'.
virtual void VisitTypedDataViewPointers(TypedDataViewPtr view,
- ObjectPtr* first,
- ObjectPtr* last) {
- VisitPointers(first, last);
+ CompressedObjectPtr* first,
+ CompressedObjectPtr* last) {
+ VisitCompressedPointers(view->heap_base(), first, last);
}
// Range of pointers to visit 'first' <= pointer <= 'last'.
diff --git a/tools/VERSION b/tools/VERSION
index 5d714ab..043770a 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 13
PATCH 0
-PRERELEASE 203
+PRERELEASE 204
PRERELEASE_PATCH 0
\ No newline at end of file
diff --git a/tools/bots/test_matrix.json b/tools/bots/test_matrix.json
index c244d73..8527b24 100644
--- a/tools/bots/test_matrix.json
+++ b/tools/bots/test_matrix.json
@@ -3389,7 +3389,8 @@
"name": "build dart",
"script": "tools/build.py",
"arguments": [
- "create_sdk"
+ "create_sdk",
+ "dartdevc_test"
]
},
{