From 212e49fda60487853de0e34cc6a5d8cd9172c640 Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Mon, 19 Aug 2024 18:12:14 +0000 Subject: [PATCH 01/13] [dds/dap] Treat "Service Connection Disposed" the same as "Client closed with pending request" Should fix https://github.com/flutter/flutter/issues/153473 Change-Id: I77bcf2da01d340412c3dc709a74cc8ed2d80a43f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381181 Reviewed-by: Helin Shiah Reviewed-by: Ben Konyi Commit-Queue: Helin Shiah --- pkg/dds/CHANGELOG.md | 3 +++ pkg/dds/lib/src/dap/adapters/dart.dart | 3 ++- pkg/dds/pubspec.yaml | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/dds/CHANGELOG.md b/pkg/dds/CHANGELOG.md index 8cfa13768a3a..5640f9c6e732 100644 --- a/pkg/dds/CHANGELOG.md +++ b/pkg/dds/CHANGELOG.md @@ -1,3 +1,6 @@ +# 4.2.6 +- [DAP] Fixed an issue where "Service connection disposed" errors may go unhandled during termination/shutdown. + # 4.2.5+1 - Fix issue where `DartDevelopmentServiceException.fromJson` would throw a `StateError` whenever called, except when called to create an `ExistingDartDevelopmentServiceException`. diff --git a/pkg/dds/lib/src/dap/adapters/dart.dart b/pkg/dds/lib/src/dap/adapters/dart.dart index 842fadf89e31..ad6b67699619 100644 --- a/pkg/dds/lib/src/dap/adapters/dart.dart +++ b/pkg/dds/lib/src/dap/adapters/dart.dart @@ -2881,7 +2881,8 @@ abstract class DartDebugAdapter- A library used to spawn the Dart Developer Service, used to communicate with a Dart VM Service instance. From bf8a9c109b7b643128e45aa16f946320f8976890 Mon Sep 17 00:00:00 2001 From: Graciliano Monteiro Passos Date: Mon, 19 Aug 2024 18:19:39 +0000 Subject: [PATCH 02/13] `_Visitor.visitBinaryExpression`: use `const` and avoid `List` allocation. Closes https://github.com/dart-lang/sdk/pull/56451 GitOrigin-RevId: c4a5b5904aced28d482f60340076368209155be5 Change-Id: I2fdbec08261f61a9f4242acf35b92ff15fc74227 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380201 Reviewed-by: Phil Quitslund Commit-Queue: Phil Quitslund --- pkg/linter/lib/src/rules/prefer_contains.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/linter/lib/src/rules/prefer_contains.dart b/pkg/linter/lib/src/rules/prefer_contains.dart index 008b9c2992cf..a2019cc44af1 100644 --- a/pkg/linter/lib/src/rules/prefer_contains.dart +++ b/pkg/linter/lib/src/rules/prefer_contains.dart @@ -69,7 +69,7 @@ class _Visitor extends SimpleAstVisitor { @override void visitBinaryExpression(BinaryExpression node) { // This lint rule is only concerned with these operators. - if (!node.operator.matchesAny([ + if (!node.operator.matchesAny(const [ TokenType.EQ_EQ, TokenType.BANG_EQ, TokenType.GT, From 4e812af6055581d2b045b70199d2fb85a652e39c Mon Sep 17 00:00:00 2001 From: Martin Kustermann Date: Mon, 19 Aug 2024 19:11:40 +0000 Subject: [PATCH 03/13] [dart2wasm] Roll jsc version to newest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The newest JSC version should be much more stable. Local testing shows it now passes most language tests in both optimized (-O1) and non-optimized (-O0) mode. => We can probably add the JSC bot again. Change-Id: If3888eb307c60a08cee1511557df9ba39b317193 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381241 Reviewed-by: Ömer Ağacan Commit-Queue: Martin Kustermann --- DEPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPS b/DEPS index 01d7a5cf8edb..22681e28b77b 100644 --- a/DEPS +++ b/DEPS @@ -73,7 +73,7 @@ vars = { "checkout_javascript_engines": False, "d8_tag": "version:12.9.98", "jsshell_tag": "version:127.0.2", - "jsc_tag": "version:280364", + "jsc_tag": "version:282418", # https://chrome-infra-packages.appspot.com/p/fuchsia/third_party/clang "clang_version": "git_revision:3809e20afc68d7d03821f0ec59b928dcf9befbf4", From dd8ec91e969ba9efc5e2a867c8e565fde1ab60b9 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Mon, 19 Aug 2024 19:43:59 +0000 Subject: [PATCH 04/13] linter: fix omit_local_variable_types for coerced int Fixes https://github.com/dart-lang/linter/issues/5010 Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try Change-Id: Id302aceb24bb9a80f0f13b3ec91b7a57c09a7d52 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381101 Reviewed-by: Phil Quitslund Commit-Queue: Samuel Rawlins --- .../src/rules/omit_local_variable_types.dart | 68 ++++++++++--------- .../rules/omit_local_variable_types_test.dart | 8 +++ 2 files changed, 45 insertions(+), 31 deletions(-) diff --git a/pkg/linter/lib/src/rules/omit_local_variable_types.dart b/pkg/linter/lib/src/rules/omit_local_variable_types.dart index 927b65acc4b6..0aaefdc1c5ed 100644 --- a/pkg/linter/lib/src/rules/omit_local_variable_types.dart +++ b/pkg/linter/lib/src/rules/omit_local_variable_types.dart @@ -6,9 +6,9 @@ import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/ast/visitor.dart'; import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/dart/element/type.dart'; +import 'package:analyzer/dart/element/type_provider.dart'; import '../analyzer.dart'; -import '../extensions.dart'; import '../linter_lint_codes.dart'; const _desc = r'Omit type annotations for local variables.'; @@ -84,7 +84,7 @@ class OmitLocalVariableTypes extends LintRule { @override void registerNodeProcessors( NodeLintRegistry registry, LinterContext context) { - var visitor = _Visitor(this); + var visitor = _Visitor(this, context.typeProvider); registry.addForStatement(this, visitor); registry.addVariableDeclarationStatement(this, visitor); } @@ -93,7 +93,9 @@ class OmitLocalVariableTypes extends LintRule { class _Visitor extends SimpleAstVisitor { final LintRule rule; - _Visitor(this.rule); + final TypeProvider typeProvider; + + _Visitor(this.rule, this.typeProvider); @override void visitForStatement(ForStatement node) { @@ -103,18 +105,16 @@ class _Visitor extends SimpleAstVisitor { } else if (loopParts is ForEachPartsWithDeclaration) { var loopVariableType = loopParts.loopVariable.type; var staticType = loopVariableType?.type; - if (staticType == null || staticType is DynamicType) { - return; - } - var iterableType = loopParts.iterable.staticType; - if (iterableType is InterfaceType) { - // TODO(srawlins): Is `DartType.asInstanceOf` the more correct API here? - var iterableInterfaces = iterableType.implementedInterfaces - .where((type) => type.isDartCoreIterable); - if (iterableInterfaces.length == 1 && - iterableInterfaces.first.typeArguments.first == staticType) { - rule.reportLint(loopVariableType); - } + if (staticType == null || staticType is DynamicType) return; + + var loopType = loopParts.iterable.staticType; + if (loopType is! InterfaceType) return; + + var iterableType = loopType.asInstanceOf(typeProvider.iterableElement); + if (iterableType == null) return; + if (iterableType.typeArguments.isNotEmpty && + iterableType.typeArguments.first == staticType) { + rule.reportLint(loopVariableType); } } } @@ -124,20 +124,6 @@ class _Visitor extends SimpleAstVisitor { _visitVariableDeclarationList(node.variables); } - bool _dependsOnDeclaredTypeForInference(Expression? initializer) { - if (initializer is MethodInvocation) { - if (initializer.typeArguments == null) { - var element = initializer.methodName.staticElement; - if (element is FunctionElement) { - if (element.returnType is TypeParameterType) { - return true; - } - } - } - } - return false; - } - void _visitVariableDeclarationList(VariableDeclarationList node) { var staticType = node.type?.type; if (staticType == null || @@ -147,13 +133,33 @@ class _Visitor extends SimpleAstVisitor { } for (var child in node.variables) { var initializer = child.initializer; - if (initializer?.staticType != staticType) { + if (initializer == null || initializer.staticType != staticType) { return; } - if (_dependsOnDeclaredTypeForInference(initializer)) { + + if (initializer is IntegerLiteral && !staticType.isDartCoreInt) { + // Coerced int. + return; + } + + if (initializer.dependsOnDeclaredTypeForInference) { return; } } rule.reportLint(node.type); } } + +extension on Expression { + bool get dependsOnDeclaredTypeForInference { + if (this case MethodInvocation(:var methodName, typeArguments: null)) { + var element = methodName.staticElement; + if (element is FunctionElement) { + if (element.returnType is TypeParameterType) { + return true; + } + } + } + return false; + } +} diff --git a/pkg/linter/test/rules/omit_local_variable_types_test.dart b/pkg/linter/test/rules/omit_local_variable_types_test.dart index 19229cb27881..d7a0171bac5a 100644 --- a/pkg/linter/test/rules/omit_local_variable_types_test.dart +++ b/pkg/linter/test/rules/omit_local_variable_types_test.dart @@ -201,6 +201,14 @@ f() { '''); } + test_rightSideIsInt_typedWithDouble() async { + await assertNoDiagnostics(r''' +void f() { + double x = 0; +} +'''); + } + test_rightSideIsInt_typedWithDynamic() async { await assertNoDiagnostics(r''' void f() { From 1bed4a84ea5d83f73cd4564c1117da78a71c0582 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Mon, 19 Aug 2024 19:57:25 +0000 Subject: [PATCH 05/13] [deps] rev dartdoc, ecosystem, http, test, tools Revisions updated by `dart tools/rev_sdk_deps.dart`. dartdoc (https://github.com/dart-lang/dartdoc/compare/ce09815..b444974): b4449742 2024-08-14 Sam Rawlins Add a doc-import into template_data.dart to resolve 'GeneratorBackend.write' (dart-lang/dartdoc#3832) 7fb1f3f3 2024-08-14 Sam Rawlins Fix links in sidebar of extension types (dart-lang/dartdoc#3831) 392e2aa3 2024-08-14 Sam Rawlins Simplify some Container fields only used for sidebar logic. (dart-lang/dartdoc#3834) 31e110d6 2024-08-13 Sam Rawlins Add tests supporting the wildcard feature (dart-lang/dartdoc#3835) ecosystem (https://github.com/dart-lang/ecosystem/compare/2719d0c..8626bff): 8626bff 2024-08-16 Jacob MacDonald More concise formatting of github workflow summary comments (dart-lang/ecosystem#288) de7883c 2024-08-14 Moritz Update PR Health install instructions (dart-lang/ecosystem#286) 03bf029 2024-08-14 Moritz Fix linting (dart-lang/ecosystem#287) http (https://github.com/dart-lang/http/compare/76512c4..b97b8dc): b97b8dc 2024-08-16 Anikate De pkgs/ok_http: OkHttpClientConfiguration and configurable timeouts. (dart-lang/http#1289) 4322382 2024-08-13 Brian Quinlan Fix "unintended_html_in_doc_comment" analysis errors (dart-lang/http#1291) test (https://github.com/dart-lang/test/compare/8be3c94..cd3dbd5): cd3dbd51 2024-08-15 Jacob MacDonald require approval from core-package-admins for anything under /pkgs (dart-lang/test#2268) cfc18ee1 2024-08-14 Jacob MacDonald add health check job (dart-lang/test#2266) f3984a72 2024-08-13 Jacob MacDonald update changelogs per https://github.com/dart-lang/test/pull/2262 (dart-lang/test#2267) tools (https://github.com/dart-lang/tools/compare/d563c38..5b15f8b): 5b15f8b 2024-08-14 Nate Bosch Add examples of calling two algorithms to README (dart-lang/tools#293) ece541c 2024-08-14 Nate Bosch Ignore unintended_html_in_doc_comment (dart-lang/tools#294) Change-Id: I23d2f9606e4bfefdfa61e0a4c629f3f05f00c996 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381320 Reviewed-by: Nate Bosch Commit-Queue: Devon Carew --- DEPS | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/DEPS b/DEPS index 22681e28b77b..ceec70bfd2f7 100644 --- a/DEPS +++ b/DEPS @@ -144,14 +144,14 @@ vars = { # # For more details, see https://github.com/dart-lang/sdk/issues/30164. "dart_style_rev": "f7bd4c42ad6015143f08931540631448048f692d", # disable tools/rev_sdk_deps.dart - "dartdoc_rev": "ce098154b16255bbc9ddfa89e3f6141262645513", - "ecosystem_rev": "2719d0c077d76da6fb996820393f3cd96bec6591", + "dartdoc_rev": "b4449742c0f7d7fa0179897cac163388e03236c2", + "ecosystem_rev": "8626bffad30d08792f0acbc813391800838e8207", "file_rev": "855831c242a17c2dee163828d52710d9043c7c8d", "fixnum_rev": "6c19e60366ce3d5edfaed51a7c12c98e7977977e", "flute_rev": "a531c96a8b43d015c6bfbbfe3ab54867b0763b8b", "glob_rev": "8b05be87f84f74d90dc0c15956f3ff95805322e5", "html_rev": "0da420ca1e196cda54ede476d0d8d3ecf55375ef", - "http_rev": "76512c4cbf987361421030349fd1946e63e33359", + "http_rev": "b97b8dc22ea808c4fbd63f73abd7af8ecf694323", "http_multi_server_rev": "8348be1bf8fd17881e2643086e68c9d2b28dd9ce", "http_parser_rev": "ce528cf82f3d26ac761e29b2494a9e0c270d4939", "intl_rev": "5d65e3808ce40e6282e40881492607df4e35669f", @@ -182,11 +182,11 @@ vars = { "sync_http_rev": "91c0dd5ef9a008f0277aadcfd83036f82e572d09", "tar_rev": "32ceb55e673141abff4e84b99483fe5eb881c291", "term_glyph_rev": "38a158f55006cf30942c928171ea601ee5e0308f", - "test_rev": "8be3c948950c2c30e8f9c49d15ef6c04beb47238", + "test_rev": "cd3dbd51fe765f7243ea51783318d82b4031fa7a", "test_descriptor_rev": "90743bc16bc00526a1b9a64f813614be9b2479d9", "test_process_rev": "6223572ca16d7585d5f08d9281de6a5734e45150", "test_reflective_loader_rev": "6e648863b39aab8d0204e769d25805eea9db0ac4", - "tools_rev": "d563c38c7cfb03bbf5d1f9360b49c36ba45b97ef", + "tools_rev": "5b15f8b60bf950a2f06dad3258dee61c153fdb44", "typed_data_rev": "365468a74251c930a463daf5b8f13227e269111a", "vector_math_rev": "2cfbe2c115a57b368ccbc3c89ebd38a06764d3d1", "watcher_rev": "0484625589d8512b36a7ad898a6cc6351d24c556", From 191b216579146da5d1c0a328274b36948cfaf43c Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 19 Aug 2024 20:59:21 +0000 Subject: [PATCH 06/13] Docs: add Risc-V and Wasm to platforms graphic Change-Id: Ic318dc49c1df50c295074ed7589cbf3d902182d6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381304 Reviewed-by: Devon Carew Commit-Queue: Devon Carew Auto-Submit: Kevin Moore --- docs/assets/Dart-platforms.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/assets/Dart-platforms.svg b/docs/assets/Dart-platforms.svg index e35cb8756bc3..c7a51e7da65e 100644 --- a/docs/assets/Dart-platforms.svg +++ b/docs/assets/Dart-platforms.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file From 428e52e00c3d15dbe8096b0c1428d238c46759c3 Mon Sep 17 00:00:00 2001 From: Kenzie Schmoll Date: Mon, 19 Aug 2024 21:12:48 +0000 Subject: [PATCH 07/13] Bump DevTools DEPS and bump the devtools_shared dependency in DDS. Change-Id: I561d0880cb35ca04b3ae3fdefdb4700003db3fd0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381380 Reviewed-by: Ben Konyi Commit-Queue: Kenzie Davisson --- DEPS | 2 +- pkg/dds/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DEPS b/DEPS index ceec70bfd2f7..eb57f2cbb110 100644 --- a/DEPS +++ b/DEPS @@ -102,7 +102,7 @@ vars = { "boringssl_rev": "2db0eb3f96a5756298dcd7f9319e56a98585bd10", "browser-compat-data_tag": "ac8cae697014da1ff7124fba33b0b4245cc6cd1b", # v1.0.22 "cpu_features_rev": "936b9ab5515dead115606559502e3864958f7f6e", - "devtools_rev": "14084d20946268f2d22c5ed55bd53e0176748368", + "devtools_rev": "6390e5ddf69c836c530256891405e0cb3319b604", "icu_rev": "43953f57b037778a1b8005564afabe214834f7bd", "jinja2_rev": "2222b31554f03e62600cd7e383376a7c187967a1", "libcxx_rev": "44079a4cc04cdeffb9cfe8067bfb3c276fb2bab0", diff --git a/pkg/dds/pubspec.yaml b/pkg/dds/pubspec.yaml index bc05d9686e4a..591837d5c20e 100644 --- a/pkg/dds/pubspec.yaml +++ b/pkg/dds/pubspec.yaml @@ -16,7 +16,7 @@ dependencies: dds_service_extensions: ^2.0.0 dap: ^1.3.0 extension_discovery: ^2.0.0 - devtools_shared: ^10.0.0-dev.1 + devtools_shared: ^10.0.2 http_multi_server: ^3.0.0 json_rpc_2: ^3.0.0 meta: ^1.1.8 From 511611f1719c2b984d49678555c44a9731e7075d Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Mon, 19 Aug 2024 21:22:21 +0000 Subject: [PATCH 08/13] Bump crypto to eede7d6918c51159c1422b7449f40dbac660ee57 Changes: ``` > git log --format="%C(auto) %h %s" 1216790..eede7d6 https://dart.googlesource.com/crypto.git/+/eede7d6 Revert wasm using fast path due to dart-lang/sdk/issues/55266 (181) https://dart.googlesource.com/crypto.git/+/3200166 Prepare to release v3.0.4 (178) ``` Diff: https://dart.googlesource.com/crypto.git/+/1216790ba704a0ab194f9cd0da2d65e1767f3342..eede7d6918c51159c1422b7449f40dbac660ee57/ Change-Id: I9e13bd707604831ca18aeb618d45c619b398a39f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381303 Reviewed-by: Kevin Moore Commit-Queue: Devon Carew --- DEPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPS b/DEPS index eb57f2cbb110..0637dd23fcf3 100644 --- a/DEPS +++ b/DEPS @@ -131,7 +131,7 @@ vars = { "clock_rev": "6e43768a0b135a0d36fc886907b70c4bf27117e6", "collection_rev": "0c1f829c29da1d63488be774f430b2035a565d6f", "convert_rev": "9035cafefc1da4315f26058734d0c2a19d5ab56a", - "crypto_rev": "1216790ba704a0ab194f9cd0da2d65e1767f3342", + "crypto_rev": "eede7d6918c51159c1422b7449f40dbac660ee57", "csslib_rev": "192d720f121792ab05ca157ea280edc7e0410e9c", # Note: Updates to dart_style have to be coordinated with the infrastructure # team so that the internal formatter `tools/sdks/dart-sdk/bin/dart format` From 3cced31c13e262285b63b0149441e76d05c7d16e Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Mon, 19 Aug 2024 21:44:20 +0000 Subject: [PATCH 09/13] Update some build documentation. Change-Id: Ib4378c1220b1ab76754b0ac565a0ff464f7b1b63 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381340 Commit-Queue: Ryan Macnak Reviewed-by: Alexander Aprelev --- docs/Building-Dart-SDK-for-ARM-or-RISC-V.md | 39 +++++++++------------ docs/Building-for-Fuchsia.md | 4 ++- docs/Building-the-Dart-VM-for-Android.md | 19 +++------- 3 files changed, 23 insertions(+), 39 deletions(-) diff --git a/docs/Building-Dart-SDK-for-ARM-or-RISC-V.md b/docs/Building-Dart-SDK-for-ARM-or-RISC-V.md index 425a317e9a47..c7a589a9f0d6 100644 --- a/docs/Building-Dart-SDK-for-ARM-or-RISC-V.md +++ b/docs/Building-Dart-SDK-for-ARM-or-RISC-V.md @@ -1,26 +1,21 @@ -> [!IMPORTANT] -> This page was copied from https://github.com/dart-lang/sdk/wiki and needs review. -> Please [contribute](../CONTRIBUTING.md) changes to bring it up-to-date - -> removing this header - or send a CL to delete the file. - ---- - # Introduction The Dart VM runs on a variety of ARM processors on Linux and Android. This document explains how to build the Dart VM and SDK to target these platforms. # Cross-compiling -If you are building natively on the device you will be running on, you can skip this step. The build scripts download a cross-compilation toolchain using clang that supports ia32, x64, arm and arm64, so you do not need to install a cross-compiler yourself unless you want to target riscv. +The build scripts download a Clang toolchain that can target IA32, X64, ARM, ARM64 or RISCV64 and run on an X64 or ARM64 host. For these cases, you do not need to install a cross-compiler yourself. For other cases, like building on a RISCV64 host or targeting RISCV32, you will need to manually install a toolchain. ## Linux If you are running Debian/Ubuntu, you can obtain a cross-compiler by doing the following: -``` -$ sudo apt-get install g++-arm-linux-gnueabihf # For 32-bit ARM (ARMv7) -$ sudo apt-get install g++-aarch64-linux-gnu # For 64-bit ARM (ARMv8) -$ sudo apt-get install g++-riscv64-linux-gnu # For 64-bit RISC-V (RV64GC) +```bash +$ sudo apt-get install g++-i686-linux-gnu # To target ia32 +$ sudo apt-get install g++-x86-64-linux-gnu # To target x64 +$ sudo apt-get install g++-arm-linux-gnueabihf # To target arm +$ sudo apt-get install g++-aarch64-linux-gnu # To target arm64 +$ sudo apt-get install g++-riscv64-linux-gnu # To target riscv64 ``` ## Android @@ -33,21 +28,21 @@ Follow instructions under ["One-time Setup" under Android](Building-the-Dart-VM- With the default Debian/Ubuntu toolchains, simply do: -``` -$ ./tools/build.py --no-rbe --no-clang --mode release --arch arm create_sdk -$ ./tools/build.py --no-rbe --no-clang --mode release --arch arm64 create_sdk -$ ./tools/build.py --no-rbe --no-clang --mode release --arch riscv64 create_sdk +```bash +$ ./tools/build.py --no-clang --mode release --arch arm create_sdk +$ ./tools/build.py --no-clang --mode release --arch arm64 create_sdk +$ ./tools/build.py --no-clang --mode release --arch riscv64 create_sdk ``` You can also produce only a Dart VM runtime, no SDK, by replacing `create_sdk` with `runtime`. This process involves also building a VM that targets ia32/x64, which is used to generate a few parts of the SDK. You can use a different toolchain using the -t switch. For example, if the path to your gcc is /path/to/toolchain/prefix-gcc, then you'd invoke the build script with: -``` -$ ./tools/build.py --no-rbe --no-clang -m release -a arm -t arm=/path/to/toolchain/prefix create_sdk -$ ./tools/build.py --no-rbe --no-clang -m release -a arm64 -t arm64=/path/to/toolchain/prefix create_sdk -$ ./tools/build.py --no-rbe --no-clang -m release -a riscv32 -t riscv32=/path/to/toolchain/prefix create_sdk -$ ./tools/build.py --no-rbe --no-clang -m release -a riscv64 -t riscv64=/path/to/toolchain/prefix create_sdk +```bash +$ ./tools/build.py --no-clang -m release -a arm -t arm=/path/to/toolchain/prefix create_sdk +$ ./tools/build.py --no-clang -m release -a arm64 -t arm64=/path/to/toolchain/prefix create_sdk +$ ./tools/build.py --no-clang -m release -a riscv32 -t riscv32=/path/to/toolchain/prefix create_sdk +$ ./tools/build.py --no-clang -m release -a riscv64 -t riscv64=/path/to/toolchain/prefix create_sdk ``` ## Android @@ -60,8 +55,6 @@ $ ./tools/build.py --mode=release --arch=arm64 --os=android create_sdk $ ./tools/build.py --mode=release --arch=riscv64 --os=android create_sdk ``` -For all of these configurations, the runtime only can be built using the runtime target as above. - ## Debian Packages You can create Debian packages targeting ARM or RISC-V as follows: diff --git a/docs/Building-for-Fuchsia.md b/docs/Building-for-Fuchsia.md index df48e49c24ea..2ec27eda6ebe 100644 --- a/docs/Building-for-Fuchsia.md +++ b/docs/Building-for-Fuchsia.md @@ -2,13 +2,15 @@ Download and install the Dart source tree using the standard instructions for building Dart. -To build for Fuchsia, you must first update your `.gclient file with: +To build for Fuchsia, you must first update your `.gclient` file with: ``` "custom_vars": { "download_fuchsia_deps": True, }, ``` +and re-run `gclient sync`. + # Building ```bash diff --git a/docs/Building-the-Dart-VM-for-Android.md b/docs/Building-the-Dart-VM-for-Android.md index 140748505735..3cae102dfb09 100644 --- a/docs/Building-the-Dart-VM-for-Android.md +++ b/docs/Building-the-Dart-VM-for-Android.md @@ -1,17 +1,10 @@ -> [!IMPORTANT] -> This page was copied from https://github.com/dart-lang/sdk/wiki and needs review. -> Please [contribute](../CONTRIBUTING.md) changes to bring it up-to-date - -> removing this header - or send a CL to delete the file. - ---- - # Introduction -It is possible to build and run the standalone Dart VM for Android devices. This setup is not yet thoroughly tested, but is available for experimentation. +It is possible to build and run the standalone Dart VM for Android devices. ## Limitations -* The host (build) machine must be an x86 Linux machine. +* The host (build) machine must be an x64 Linux machine or a Mac. * The target (Android) device must be a device or emulator that supports the Android NDK. * The resulting Android Dart VM can only be run from the Android command line. * The resulting Android Dart VM only has access to dart:core APIs. It does not have access to the Android C or Java APIs. @@ -33,7 +26,7 @@ Run gclient sync to install the Android NDK and SDK. This may take 10 minutes or Once you've set up your build tree, you can build the Dart VM for Android by using the standard Dart build script with the addition of the --os android build flag: -`$ tools/build.py --no-rbe --arch=arm,arm64,ia32,x64 --os=android runtime` +`$ tools/build.py --arch=arm,arm64,ia32,x64,riscv64 --os=android runtime` # Testing the result @@ -61,7 +54,7 @@ Create a directory on the Android emulator. Copy the Dart VM executable to the Android emulator: -`$ adb push out/android/ReleaseAndroid{ARM,ARM64,IA32,X64}/dart /data/local/tmp/dart/dart` +`$ adb push out/android/ReleaseAndroid{ARM,ARM64,IA32,X64,RISCV64}/dart /data/local/tmp/dart/dart` Create a simple Dart test script: @@ -107,7 +100,3 @@ TA23701VKR device ``` Now, you can copy dart and hello.dart to the device as above. If an emulator is also running, be sure to give adb the -d switch to tell it to use the attached device instead of the emulator. Use the -s switch to give the device ID explicitly. - -# Notes - -The only effect of the `target_os` line in the Dart `.gclient` configuration file is to install the Android tools. Despite what the name `target_os` implies, the target_os line does not affect which OS is targeted. Therefore, once you've installed the Android tools you can (and should) leave the `target_os = ["android"]` line in place even when switching back and forth between building for Android and building for Linux. From 84fd647969f0d74ab63f0994d95b5fc26cac006a Mon Sep 17 00:00:00 2001 From: Alexander Markov Date: Mon, 19 Aug 2024 21:46:26 +0000 Subject: [PATCH 10/13] [vm] Refactor access to Integer value Add methods to provide uniform access to values of Dart integers: Integer::Value() Integer::Value(IntegerPtr) Smi::Value() Smi::Value(SmiPtr) Mint::Value() Mint::Value(MintPtr) Remove AsInt64Value() AsTruncatedInt64Value() AsTruncatedUint32Value() GetInt64Value(IntegerPtr) Also, rename AsDoubleValue() to ToDouble() and remove unused (FitsIntoSmi, AsValidInteger) and value-based methods (IsZero, IsNegative). TEST=ci Change-Id: I28786ec3a14703574b7a192ead42eeefdbd09106 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380586 Reviewed-by: Ryan Macnak Commit-Queue: Alexander Markov --- runtime/lib/date.cc | 4 +- runtime/lib/developer.cc | 6 +- runtime/lib/double.cc | 14 +- runtime/lib/ffi.cc | 2 +- runtime/lib/integers.cc | 14 +- runtime/lib/simd128.cc | 24 +-- runtime/lib/string.cc | 4 +- runtime/lib/timeline.cc | 9 +- .../vm/compiler/aot/aot_call_specializer.cc | 2 +- .../compiler/backend/constant_propagator.cc | 16 +- .../backend/constant_propagator_test.cc | 2 +- runtime/vm/compiler/backend/evaluator.cc | 27 +-- runtime/vm/compiler/backend/flow_graph.cc | 10 +- .../vm/compiler/backend/flow_graph_checker.cc | 2 +- runtime/vm/compiler/backend/il.cc | 25 ++- runtime/vm/compiler/backend/il_arm.cc | 10 +- runtime/vm/compiler/backend/il_arm64.cc | 14 +- runtime/vm/compiler/backend/il_ia32.cc | 10 +- runtime/vm/compiler/backend/il_printer.cc | 2 +- runtime/vm/compiler/backend/il_riscv.cc | 12 +- runtime/vm/compiler/backend/il_serializer.cc | 2 +- runtime/vm/compiler/backend/il_test.cc | 2 +- runtime/vm/compiler/backend/il_x64.cc | 12 +- runtime/vm/compiler/backend/loops.cc | 2 +- runtime/vm/compiler/backend/range_analysis.cc | 10 +- runtime/vm/compiler/ffi/native_type.cc | 4 +- .../frontend/kernel_binary_flowgraph.cc | 8 +- .../frontend/kernel_binary_flowgraph_test.cc | 18 +- runtime/vm/compiler/frontend/kernel_to_il.cc | 10 +- runtime/vm/compiler/runtime_api.cc | 2 +- runtime/vm/compiler_test.cc | 6 +- runtime/vm/dart_api_impl.cc | 22 +-- runtime/vm/debugger_api_impl_test.cc | 2 +- runtime/vm/deferred_objects.cc | 27 ++- runtime/vm/interpreter.cc | 10 +- runtime/vm/json_stream.cc | 2 +- runtime/vm/message_snapshot.cc | 2 +- runtime/vm/native_entry_test.cc | 2 +- runtime/vm/object.cc | 165 +++--------------- runtime/vm/object.h | 57 ++---- runtime/vm/object_test.cc | 33 ++-- runtime/vm/runtime_entry.cc | 4 +- 42 files changed, 225 insertions(+), 386 deletions(-) diff --git a/runtime/lib/date.cc b/runtime/lib/date.cc index 118461f9b5e7..8484092d56e0 100644 --- a/runtime/lib/date.cc +++ b/runtime/lib/date.cc @@ -17,7 +17,7 @@ static int64_t kMaxAllowedSeconds = kMaxInt32; DEFINE_NATIVE_ENTRY(DateTime_timeZoneName, 0, 1) { GET_NON_NULL_NATIVE_ARGUMENT(Integer, dart_seconds, arguments->NativeArgAt(0)); - int64_t seconds = dart_seconds.AsInt64Value(); + int64_t seconds = dart_seconds.Value(); if (llabs(seconds) > kMaxAllowedSeconds) { Exceptions::ThrowArgumentError(dart_seconds); } @@ -28,7 +28,7 @@ DEFINE_NATIVE_ENTRY(DateTime_timeZoneName, 0, 1) { DEFINE_NATIVE_ENTRY(DateTime_timeZoneOffsetInSeconds, 0, 1) { GET_NON_NULL_NATIVE_ARGUMENT(Integer, dart_seconds, arguments->NativeArgAt(0)); - int64_t seconds = dart_seconds.AsInt64Value(); + int64_t seconds = dart_seconds.Value(); if (llabs(seconds) > kMaxAllowedSeconds) { Exceptions::ThrowArgumentError(dart_seconds); } diff --git a/runtime/lib/developer.cc b/runtime/lib/developer.cc index f9d649e1d8dc..7574c73e48de 100644 --- a/runtime/lib/developer.cc +++ b/runtime/lib/developer.cc @@ -58,9 +58,9 @@ DEFINE_NATIVE_ENTRY(Developer_log, 0, 8) { GET_NATIVE_ARGUMENT(Instance, dart_zone, arguments->NativeArgAt(5)); GET_NATIVE_ARGUMENT(Instance, error, arguments->NativeArgAt(6)); GET_NATIVE_ARGUMENT(Instance, stack_trace, arguments->NativeArgAt(7)); - Service::SendLogEvent(isolate, sequence.AsInt64Value(), - timestamp.AsInt64Value(), level.Value(), name, message, - dart_zone, error, stack_trace); + Service::SendLogEvent(isolate, sequence.Value(), timestamp.Value(), + level.Value(), name, message, dart_zone, error, + stack_trace); return Object::null(); #endif // PRODUCT } diff --git a/runtime/lib/double.cc b/runtime/lib/double.cc index c747e2682213..a4027d530894 100644 --- a/runtime/lib/double.cc +++ b/runtime/lib/double.cc @@ -26,7 +26,7 @@ DEFINE_NATIVE_ENTRY(Double_doubleFromInteger, 0, 2) { if (FLAG_trace_intrinsified_natives) { OS::PrintErr("Double_doubleFromInteger %s\n", value.ToCString()); } - return Double::New(value.AsDoubleValue()); + return Double::New(value.ToDouble()); } DEFINE_NATIVE_ENTRY(Double_add, 0, 2) { @@ -83,7 +83,7 @@ DEFINE_NATIVE_ENTRY(Double_greaterThan, 0, 2) { DEFINE_NATIVE_ENTRY(Double_greaterThanFromInteger, 0, 2) { const Double& right = Double::CheckedHandle(zone, arguments->NativeArgAt(0)); GET_NON_NULL_NATIVE_ARGUMENT(Integer, left, arguments->NativeArgAt(1)); - return Bool::Get(left.AsDoubleValue() > right.value()).ptr(); + return Bool::Get(left.ToDouble() > right.value()).ptr(); } DEFINE_NATIVE_ENTRY(Double_equal, 0, 2) { @@ -100,7 +100,7 @@ DEFINE_NATIVE_ENTRY(Double_equal, 0, 2) { DEFINE_NATIVE_ENTRY(Double_equalToInteger, 0, 2) { const Double& left = Double::CheckedHandle(zone, arguments->NativeArgAt(0)); GET_NON_NULL_NATIVE_ARGUMENT(Integer, right, arguments->NativeArgAt(1)); - return Bool::Get(left.value() == right.AsDoubleValue()).ptr(); + return Bool::Get(left.value() == right.ToDouble()).ptr(); } #if defined(DART_HOST_OS_MACOS) @@ -110,11 +110,11 @@ DEFINE_NATIVE_ENTRY(Double_equalToInteger, 0, 2) { DEFINE_NATIVE_ENTRY(Double_parse, 0, 3) { GET_NON_NULL_NATIVE_ARGUMENT(String, value, arguments->NativeArgAt(0)); - GET_NON_NULL_NATIVE_ARGUMENT(Integer, startValue, arguments->NativeArgAt(1)); - GET_NON_NULL_NATIVE_ARGUMENT(Integer, endValue, arguments->NativeArgAt(2)); + GET_NON_NULL_NATIVE_ARGUMENT(Smi, startValue, arguments->NativeArgAt(1)); + GET_NON_NULL_NATIVE_ARGUMENT(Smi, endValue, arguments->NativeArgAt(2)); - const intptr_t start = startValue.AsTruncatedUint32Value(); - const intptr_t end = endValue.AsTruncatedUint32Value(); + const intptr_t start = startValue.Value(); + const intptr_t end = endValue.Value(); const intptr_t len = value.Length(); // Indices should be inside the string, and 0 <= start < end <= len. diff --git a/runtime/lib/ffi.cc b/runtime/lib/ffi.cc index 0d06325ee1e4..ac1ede8e1c9e 100644 --- a/runtime/lib/ffi.cc +++ b/runtime/lib/ffi.cc @@ -54,7 +54,7 @@ DEFINE_NATIVE_ENTRY(Ffi_deleteNativeCallable, 1, 1) { DEFINE_NATIVE_ENTRY(Ffi_updateNativeCallableKeepIsolateAliveCounter, 1, 1) { const int64_t delta = - Integer::CheckedHandle(zone, arguments->NativeArg0()).AsInt64Value(); + Integer::CheckedHandle(zone, arguments->NativeArg0()).Value(); isolate->UpdateNativeCallableKeepIsolateAliveCounter(delta); return Object::null(); } diff --git a/runtime/lib/integers.cc b/runtime/lib/integers.cc index b033b14c2ee1..8df26e4fa940 100644 --- a/runtime/lib/integers.cc +++ b/runtime/lib/integers.cc @@ -24,7 +24,7 @@ namespace dart { static bool CheckInteger(const Integer& i) { if (i.IsMint()) { const Mint& mint = Mint::Cast(i); - return !Smi::IsValid(mint.value()); + return !Smi::IsValid(mint.Value()); } return true; } @@ -113,7 +113,7 @@ DEFINE_NATIVE_ENTRY(Integer_truncDivFromInteger, 0, 2) { GET_NON_NULL_NATIVE_ARGUMENT(Integer, left_int, arguments->NativeArgAt(1)); ASSERT(CheckInteger(right_int)); ASSERT(CheckInteger(left_int)); - ASSERT(!right_int.IsZero()); + ASSERT(right_int.Value() != 0); return left_int.ArithmeticOp(Token::kTRUNCDIV, right_int); } @@ -127,7 +127,7 @@ DEFINE_NATIVE_ENTRY(Integer_moduloFromInteger, 0, 2) { OS::PrintErr("Integer_moduloFromInteger %s mod %s\n", left_int.ToCString(), right_int.ToCString()); } - if (right_int.IsZero()) { + if (right_int.Value() == 0) { // Should have been caught before calling into runtime. UNIMPLEMENTED(); } @@ -206,7 +206,7 @@ DEFINE_NATIVE_ENTRY(Integer_fromEnvironment, 0, 3) { static IntegerPtr ShiftOperationHelper(Token::Kind kind, const Integer& value, const Integer& amount) { - if (amount.AsInt64Value() < 0) { + if (amount.Value() < 0) { Exceptions::ThrowArgumentError(amount); } return value.ShiftOp(kind, amount, Heap::kNew); @@ -266,7 +266,7 @@ DEFINE_NATIVE_ENTRY(Smi_bitLength, 0, 1) { if (FLAG_trace_intrinsified_natives) { OS::PrintErr("Smi_bitLength: %s\n", operand.ToCString()); } - int64_t value = operand.AsInt64Value(); + int64_t value = operand.Value(); intptr_t result = Utils::BitLength(value); ASSERT(Smi::IsValid(result)); return Smi::New(result); @@ -309,7 +309,7 @@ DEFINE_NATIVE_ENTRY(Mint_bitNegate, 0, 1) { if (FLAG_trace_intrinsified_natives) { OS::PrintErr("Mint_bitNegate: %s\n", operand.ToCString()); } - int64_t result = ~operand.value(); + int64_t result = ~operand.Value(); return Integer::New(result); } @@ -319,7 +319,7 @@ DEFINE_NATIVE_ENTRY(Mint_bitLength, 0, 1) { if (FLAG_trace_intrinsified_natives) { OS::PrintErr("Mint_bitLength: %s\n", operand.ToCString()); } - int64_t value = operand.AsInt64Value(); + int64_t value = operand.Value(); intptr_t result = Utils::BitLength(value); ASSERT(Smi::IsValid(result)); return Smi::New(result); diff --git a/runtime/lib/simd128.cc b/runtime/lib/simd128.cc index fe50909e72b0..b62016c52715 100644 --- a/runtime/lib/simd128.cc +++ b/runtime/lib/simd128.cc @@ -265,7 +265,7 @@ DEFINE_NATIVE_ENTRY(Int32x4_getSignMask, 0, 1) { DEFINE_NATIVE_ENTRY(Float32x4_shuffle, 0, 2) { GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); GET_NON_NULL_NATIVE_ARGUMENT(Integer, mask, arguments->NativeArgAt(1)); - int64_t m = mask.AsInt64Value(); + int64_t m = mask.Value(); ThrowMaskRangeException(m); float data[4] = {self.x(), self.y(), self.z(), self.w()}; float _x = data[m & 0x3]; @@ -279,7 +279,7 @@ DEFINE_NATIVE_ENTRY(Float32x4_shuffleMix, 0, 3) { GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, other, arguments->NativeArgAt(1)); GET_NON_NULL_NATIVE_ARGUMENT(Integer, mask, arguments->NativeArgAt(2)); - int64_t m = mask.AsInt64Value(); + int64_t m = mask.Value(); ThrowMaskRangeException(m); float data[4] = {self.x(), self.y(), self.z(), self.w()}; float other_data[4] = {other.x(), other.y(), other.z(), other.w()}; @@ -382,10 +382,10 @@ DEFINE_NATIVE_ENTRY(Int32x4_fromInts, 0, 4) { GET_NON_NULL_NATIVE_ARGUMENT(Integer, y, arguments->NativeArgAt(1)); GET_NON_NULL_NATIVE_ARGUMENT(Integer, z, arguments->NativeArgAt(2)); GET_NON_NULL_NATIVE_ARGUMENT(Integer, w, arguments->NativeArgAt(3)); - int32_t _x = static_cast(x.AsTruncatedUint32Value()); - int32_t _y = static_cast(y.AsTruncatedUint32Value()); - int32_t _z = static_cast(z.AsTruncatedUint32Value()); - int32_t _w = static_cast(w.AsTruncatedUint32Value()); + int32_t _x = static_cast(x.Value() & 0xFFFFFFFF); + int32_t _y = static_cast(y.Value() & 0xFFFFFFFF); + int32_t _z = static_cast(z.Value() & 0xFFFFFFFF); + int32_t _w = static_cast(w.Value() & 0xFFFFFFFF); return Int32x4::New(_x, _y, _z, _w); } @@ -483,7 +483,7 @@ DEFINE_NATIVE_ENTRY(Int32x4_getW, 0, 1) { DEFINE_NATIVE_ENTRY(Int32x4_shuffle, 0, 2) { GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); GET_NON_NULL_NATIVE_ARGUMENT(Integer, mask, arguments->NativeArgAt(1)); - int64_t m = mask.AsInt64Value(); + int64_t m = mask.Value(); ThrowMaskRangeException(m); int32_t data[4] = {self.x(), self.y(), self.z(), self.w()}; int32_t _x = data[m & 0x3]; @@ -497,7 +497,7 @@ DEFINE_NATIVE_ENTRY(Int32x4_shuffleMix, 0, 3) { GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, zw, arguments->NativeArgAt(1)); GET_NON_NULL_NATIVE_ARGUMENT(Integer, mask, arguments->NativeArgAt(2)); - int64_t m = mask.AsInt64Value(); + int64_t m = mask.Value(); ThrowMaskRangeException(m); int32_t data[4] = {self.x(), self.y(), self.z(), self.w()}; int32_t zw_data[4] = {zw.x(), zw.y(), zw.z(), zw.w()}; @@ -511,7 +511,7 @@ DEFINE_NATIVE_ENTRY(Int32x4_shuffleMix, 0, 3) { DEFINE_NATIVE_ENTRY(Int32x4_setX, 0, 2) { GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); GET_NON_NULL_NATIVE_ARGUMENT(Integer, x, arguments->NativeArgAt(1)); - int32_t _x = static_cast(x.AsInt64Value() & 0xFFFFFFFF); + int32_t _x = static_cast(x.Value() & 0xFFFFFFFF); int32_t _y = self.y(); int32_t _z = self.z(); int32_t _w = self.w(); @@ -522,7 +522,7 @@ DEFINE_NATIVE_ENTRY(Int32x4_setY, 0, 2) { GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); GET_NON_NULL_NATIVE_ARGUMENT(Integer, y, arguments->NativeArgAt(1)); int32_t _x = self.x(); - int32_t _y = static_cast(y.AsInt64Value() & 0xFFFFFFFF); + int32_t _y = static_cast(y.Value() & 0xFFFFFFFF); int32_t _z = self.z(); int32_t _w = self.w(); return Int32x4::New(_x, _y, _z, _w); @@ -533,7 +533,7 @@ DEFINE_NATIVE_ENTRY(Int32x4_setZ, 0, 2) { GET_NON_NULL_NATIVE_ARGUMENT(Integer, z, arguments->NativeArgAt(1)); int32_t _x = self.x(); int32_t _y = self.y(); - int32_t _z = static_cast(z.AsInt64Value() & 0xFFFFFFFF); + int32_t _z = static_cast(z.Value() & 0xFFFFFFFF); int32_t _w = self.w(); return Int32x4::New(_x, _y, _z, _w); } @@ -544,7 +544,7 @@ DEFINE_NATIVE_ENTRY(Int32x4_setW, 0, 2) { int32_t _x = self.x(); int32_t _y = self.y(); int32_t _z = self.z(); - int32_t _w = static_cast(w.AsInt64Value() & 0xFFFFFFFF); + int32_t _w = static_cast(w.Value() & 0xFFFFFFFF); return Int32x4::New(_x, _y, _z, _w); } diff --git a/runtime/lib/string.cc b/runtime/lib/string.cc index 71f7c65e523d..e2da443eef06 100644 --- a/runtime/lib/string.cc +++ b/runtime/lib/string.cc @@ -259,7 +259,7 @@ DEFINE_NATIVE_ENTRY(OneByteString_substringUnchecked, 0, 3) { DEFINE_NATIVE_ENTRY(Internal_allocateOneByteString, 0, 1) { GET_NON_NULL_NATIVE_ARGUMENT(Integer, length_obj, arguments->NativeArgAt(0)); - const int64_t length = length_obj.AsInt64Value(); + const int64_t length = length_obj.Value(); if ((length < 0) || (length > OneByteString::kMaxElements)) { // Assume that negative lengths are the result of wrapping in code in // string_patch.dart. @@ -273,7 +273,7 @@ DEFINE_NATIVE_ENTRY(Internal_allocateOneByteString, 0, 1) { DEFINE_NATIVE_ENTRY(Internal_allocateTwoByteString, 0, 1) { GET_NON_NULL_NATIVE_ARGUMENT(Integer, length_obj, arguments->NativeArgAt(0)); - const int64_t length = length_obj.AsInt64Value(); + const int64_t length = length_obj.Value(); if ((length < 0) || (length > TwoByteString::kMaxElements)) { // Assume that negative lengths are the result of wrapping in code in // string_patch.dart. diff --git a/runtime/lib/timeline.cc b/runtime/lib/timeline.cc index 4592e50aba04..d22312da598f 100644 --- a/runtime/lib/timeline.cc +++ b/runtime/lib/timeline.cc @@ -56,15 +56,14 @@ DEFINE_NATIVE_ENTRY(Timeline_reportTaskEvent, 0, 5) { } std::unique_ptr flow_ids; - if (flow_id.AsInt64Value() != TimelineEvent::kNoFlowId) { + if (flow_id.Value() != TimelineEvent::kNoFlowId) { int64_t* flow_ids_internal = new int64_t[1]; - flow_ids_internal[0] = flow_id.AsInt64Value(); + flow_ids_internal[0] = flow_id.Value(); flow_ids = std::unique_ptr(flow_ids_internal); } - intptr_t flow_id_count = - flow_id.AsInt64Value() == TimelineEvent::kNoFlowId ? 0 : 1; + intptr_t flow_id_count = flow_id.Value() == TimelineEvent::kNoFlowId ? 0 : 1; DartTimelineEventHelpers::ReportTaskEvent( - event, id.AsInt64Value(), flow_id_count, flow_ids, type.Value(), + event, id.Value(), flow_id_count, flow_ids, type.Value(), name.ToMallocCString(), args.ToMallocCString()); #endif // SUPPORT_TIMELINE return Object::null(); diff --git a/runtime/vm/compiler/aot/aot_call_specializer.cc b/runtime/vm/compiler/aot/aot_call_specializer.cc index ba64939f8a18..3758ee1b1447 100644 --- a/runtime/vm/compiler/aot/aot_call_specializer.cc +++ b/runtime/vm/compiler/aot/aot_call_specializer.cc @@ -419,7 +419,7 @@ Definition* AotCallSpecializer::TryOptimizeDivisionOperation( } const Object& rhs = right_value->BoundConstant(); - const int64_t value = Integer::Cast(rhs).AsInt64Value(); // smi and mint + const int64_t value = Integer::Cast(rhs).Value(); // smi and mint if (value == kMinInt64) { return nullptr; // The absolute value can't be held in an int64_t. diff --git a/runtime/vm/compiler/backend/constant_propagator.cc b/runtime/vm/compiler/backend/constant_propagator.cc index f1c80aa103d5..0adf29220d22 100644 --- a/runtime/vm/compiler/backend/constant_propagator.cc +++ b/runtime/vm/compiler/backend/constant_propagator.cc @@ -1285,7 +1285,7 @@ static bool IsIntegerOrDouble(const Object& value) { } static double ToDouble(const Object& value) { - return value.IsInteger() ? Integer::Cast(value).AsDoubleValue() + return value.IsInteger() ? Integer::Cast(value).ToDouble() : Double::Cast(value).value(); } @@ -1311,8 +1311,8 @@ void ConstantPropagator::VisitSmiToDouble(SmiToDoubleInstr* instr) { } if (value.IsInteger()) { SetValue(instr, - Double::Handle(Z, Double::New(Integer::Cast(value).AsDoubleValue(), - Heap::kOld))); + Double::Handle( + Z, Double::New(Integer::Cast(value).ToDouble(), Heap::kOld))); } else { SetValue(instr, non_constant_); } @@ -1325,8 +1325,8 @@ void ConstantPropagator::VisitInt64ToDouble(Int64ToDoubleInstr* instr) { } if (value.IsInteger()) { SetValue(instr, - Double::Handle(Z, Double::New(Integer::Cast(value).AsDoubleValue(), - Heap::kOld))); + Double::Handle( + Z, Double::New(Integer::Cast(value).ToDouble(), Heap::kOld))); } else { SetValue(instr, non_constant_); } @@ -1339,8 +1339,8 @@ void ConstantPropagator::VisitInt32ToDouble(Int32ToDoubleInstr* instr) { } if (value.IsInteger()) { SetValue(instr, - Double::Handle(Z, Double::New(Integer::Cast(value).AsDoubleValue(), - Heap::kOld))); + Double::Handle( + Z, Double::New(Integer::Cast(value).ToDouble(), Heap::kOld))); } else { SetValue(instr, non_constant_); } @@ -1464,7 +1464,7 @@ void ConstantPropagator::VisitDoubleTestOp(DoubleTestOpInstr* instr) { result = false; break; case MethodRecognizer::kDouble_getIsNegative: { - result = Integer::Cast(value).IsNegative(); + result = Integer::Cast(value).Value() < 0; break; } default: diff --git a/runtime/vm/compiler/backend/constant_propagator_test.cc b/runtime/vm/compiler/backend/constant_propagator_test.cc index eac043e2a138..c0736b506f4d 100644 --- a/runtime/vm/compiler/backend/constant_propagator_test.cc +++ b/runtime/vm/compiler/backend/constant_propagator_test.cc @@ -214,7 +214,7 @@ static void ConstantPropagatorUnboxedOpTest( EXPECT_PROPERTY(ret_val, it.IsConstant() && it.representation() == kTagged); EXPECT_EQ(expected.result, - Integer::Cast(ret_val->AsConstant()->value()).AsInt64Value()); + Integer::Cast(ret_val->AsConstant()->value()).Value()); } else { EXPECT_PROPERTY(ret_val, it.IsBoxInteger() && it.RequiredInputRepresentation(0) == diff --git a/runtime/vm/compiler/backend/evaluator.cc b/runtime/vm/compiler/backend/evaluator.cc index de4a310bc759..6bd7c3b8ddd4 100644 --- a/runtime/vm/compiler/backend/evaluator.cc +++ b/runtime/vm/compiler/backend/evaluator.cc @@ -14,7 +14,7 @@ static IntegerPtr BinaryIntegerEvaluateRaw(const Integer& left, FALL_THROUGH; case Token::kMOD: // Check right value for zero. - if (right.AsInt64Value() == 0) { + if (right.Value() == 0) { break; // Will throw. } FALL_THROUGH; @@ -29,7 +29,7 @@ static IntegerPtr BinaryIntegerEvaluateRaw(const Integer& left, case Token::kSHR: FALL_THROUGH; case Token::kUSHR: - if (right.AsInt64Value() >= 0) { + if (right.Value() >= 0) { return left.ShiftOp(token_kind, right, Heap::kOld); } break; @@ -56,10 +56,8 @@ static IntegerPtr UnaryIntegerEvaluateRaw(const Integer& value, return value.ArithmeticOp(Token::kMUL, Smi::Handle(zone, Smi::New(-1)), Heap::kOld); case Token::kBIT_NOT: - if (value.IsSmi()) { - return Integer::New(~Smi::Cast(value).Value(), Heap::kOld); - } else if (value.IsMint()) { - return Integer::New(~Mint::Cast(value).value(), Heap::kOld); + if (value.IsInteger()) { + return Integer::New(~value.Value(), Heap::kOld); } break; default: @@ -69,11 +67,8 @@ static IntegerPtr UnaryIntegerEvaluateRaw(const Integer& value, } static IntegerPtr BitLengthEvaluateRaw(const Integer& value, Zone* zone) { - if (value.IsSmi()) { - return Integer::New(Utils::BitLength(Smi::Cast(value).Value()), Heap::kOld); - } else if (value.IsMint()) { - return Integer::New(Utils::BitLength(Mint::Cast(value).value()), - Heap::kOld); + if (value.IsInteger()) { + return Integer::New(Utils::BitLength(value.Value()), Heap::kOld); } return Integer::null(); } @@ -113,8 +108,7 @@ IntegerPtr Evaluator::BinaryIntegerEvaluate(const Object& left, if (!result.IsNull()) { if (is_truncating) { - const int64_t truncated = - TruncateTo(result.AsTruncatedInt64Value(), representation); + const int64_t truncated = TruncateTo(result.Value(), representation); result = Integer::New(truncated, Heap::kOld); ASSERT(FlowGraph::IsConstantRepresentable( result, representation, /*tagged_value_must_be_smi=*/true)); @@ -306,11 +300,8 @@ bool Evaluator::ToIntegerConstant(Value* value, int64_t* result) { const Double& double_constant = Double::Cast(constant); *result = Utils::SafeDoubleToInt(double_constant.value()); return (static_cast(*result) == double_constant.value()); - } else if (constant.IsSmi()) { - *result = Smi::Cast(constant).Value(); - return true; - } else if (constant.IsMint()) { - *result = Mint::Cast(constant).value(); + } else if (constant.IsInteger()) { + *result = Integer::Cast(constant).Value(); return true; } return false; diff --git a/runtime/vm/compiler/backend/flow_graph.cc b/runtime/vm/compiler/backend/flow_graph.cc index cec073201f32..b41237e680ee 100644 --- a/runtime/vm/compiler/backend/flow_graph.cc +++ b/runtime/vm/compiler/backend/flow_graph.cc @@ -211,13 +211,13 @@ bool FlowGraph::IsConstantRepresentable(const Object& value, case kUnboxedInt32: if (value.IsInteger()) { - return Utils::IsInt(32, Integer::Cast(value).AsInt64Value()); + return Utils::IsInt(32, Integer::Cast(value).Value()); } return false; case kUnboxedUint32: if (value.IsInteger()) { - return Utils::IsUint(32, Integer::Cast(value).AsInt64Value()); + return Utils::IsUint(32, Integer::Cast(value).Value()); } return false; @@ -247,9 +247,9 @@ Definition* FlowGraph::TryCreateConstantReplacementFor(Definition* op, (representation == kUnboxedDouble)) && value.IsInteger()) { // Convert the boxed constant from int to float/double. - return GetConstant(Double::Handle(Double::NewCanonical( - Integer::Cast(value).AsDoubleValue())), - representation); + return GetConstant( + Double::Handle(Double::NewCanonical(Integer::Cast(value).ToDouble())), + representation); } return GetConstant(value, representation); diff --git a/runtime/vm/compiler/backend/flow_graph_checker.cc b/runtime/vm/compiler/backend/flow_graph_checker.cc index 1f39a381a8f7..47a134c27ac5 100644 --- a/runtime/vm/compiler/backend/flow_graph_checker.cc +++ b/runtime/vm/compiler/backend/flow_graph_checker.cc @@ -480,7 +480,7 @@ void FlowGraphChecker::VisitConstant(ConstantInstr* constant) { // Range check on smi. const Object& value = constant->value(); if (value.IsSmi()) { - const int64_t smi_value = Integer::Cast(value).AsInt64Value(); + const int64_t smi_value = Integer::Cast(value).Value(); ASSERT(compiler::target::kSmiMin <= smi_value); ASSERT(smi_value <= compiler::target::kSmiMax); } diff --git a/runtime/vm/compiler/backend/il.cc b/runtime/vm/compiler/backend/il.cc index 498734fb2ccc..e3bd002d19ac 100644 --- a/runtime/vm/compiler/backend/il.cc +++ b/runtime/vm/compiler/backend/il.cc @@ -1133,7 +1133,7 @@ ConstantInstr::ConstantInstr(const Object& value, const InstructionSource& source) : TemplateDefinition(source), value_(value), token_pos_(source.token_pos) { // Check that the value is not an incorrect Integer representation. - ASSERT(!value.IsMint() || !Smi::IsValid(Mint::Cast(value).AsInt64Value())); + ASSERT(!value.IsMint() || !Smi::IsValid(Mint::Cast(value).Value())); // Check that clones of fields are not stored as constants. ASSERT(!value.IsField() || Field::Cast(value).IsOriginal()); // Check that all non-Smi objects are heap allocated and in old space. @@ -2117,7 +2117,7 @@ bool BinaryIntegerOpInstr::RightIsNonZero() const { if (right()->BindsToConstant()) { const auto& constant = right()->BoundConstant(); if (!constant.IsInteger()) return false; - return Integer::Cast(constant).AsInt64Value() != 0; + return Integer::Cast(constant).Value() != 0; } return !RangeUtils::CanBeZero(right()->definition()->range()); } @@ -3271,7 +3271,7 @@ Definition* BoxIntegerInstr::Canonicalize(FlowGraph* flow_graph) { // is an integer representation and [v] is representable in [from]. if (auto* const constant = value_defn->AsUnboxedConstant()) { if (RepresentationUtils::IsUnboxedInteger(constant->representation())) { - const int64_t intval = Integer::Cast(constant->value()).AsInt64Value(); + const int64_t intval = Integer::Cast(constant->value()).Value(); if (RepresentationUtils::IsRepresentable(from_representation(), intval)) { return flow_graph->GetConstant(constant->value()); } @@ -3356,7 +3356,7 @@ Definition* UnboxInstr::Canonicalize(FlowGraph* flow_graph) { if (val.IsInteger()) { const Double& double_val = Double::ZoneHandle( flow_graph->zone(), - Double::NewCanonical(Integer::Cast(val).AsDoubleValue())); + Double::NewCanonical(Integer::Cast(val).ToDouble())); return flow_graph->GetConstant(double_val, kUnboxedDouble); } else if (val.IsDouble()) { return flow_graph->GetConstant(val, kUnboxedDouble); @@ -3366,8 +3366,7 @@ Definition* UnboxInstr::Canonicalize(FlowGraph* flow_graph) { if (representation() == kUnboxedFloat && value()->BindsToConstant()) { const Object& val = value()->BoundConstant(); if (val.IsInteger()) { - double narrowed_val = - static_cast(Integer::Cast(val).AsDoubleValue()); + double narrowed_val = static_cast(Integer::Cast(val).ToDouble()); return flow_graph->GetConstant( Double::ZoneHandle(Double::NewCanonical(narrowed_val)), kUnboxedFloat); @@ -3436,7 +3435,7 @@ Definition* UnboxIntegerInstr::Canonicalize(FlowGraph* flow_graph) { if (representation() == kUnboxedInt64) { return flow_graph->GetConstant(obj, representation()); } - const int64_t intval = Integer::Cast(obj).AsInt64Value(); + const int64_t intval = Integer::Cast(obj).Value(); if (RepresentationUtils::IsRepresentable(representation(), intval)) { return flow_graph->GetConstant(obj, representation()); } @@ -3460,7 +3459,7 @@ Definition* IntConverterInstr::Canonicalize(FlowGraph* flow_graph) { if (auto constant = value()->definition()->AsConstant()) { if (from() != kUntagged && to() != kUntagged && constant->representation() == from() && constant->value().IsInteger()) { - const int64_t value = Integer::Cast(constant->value()).AsInt64Value(); + const int64_t value = Integer::Cast(constant->value()).Value(); const int64_t result = Evaluator::TruncateTo(Evaluator::TruncateTo(value, from()), to()); if (is_truncating() || (value == result)) { @@ -7018,8 +7017,7 @@ void MemoryCopyInstr::EmitNativeCode(FlowGraphCompiler* compiler) { const bool constant_length = length_loc.IsConstant(); const Register length_reg = constant_length ? kNoRegister : length_loc.reg(); const intptr_t num_elements = - constant_length ? Integer::Cast(length_loc.constant()).AsInt64Value() - : -1; + constant_length ? Integer::Cast(length_loc.constant()).Value() : -1; // The zero constant case should be handled via canonicalization. ASSERT(!constant_length || num_elements > 0); @@ -8506,9 +8504,8 @@ Definition* SimdOpInstr::Canonicalize(FlowGraph* flow_graph) { const Object& w = InputAt(3)->BoundConstant(); if (x.IsInteger() && y.IsInteger() && z.IsInteger() && w.IsInteger()) { Int32x4& result = Int32x4::Handle(Int32x4::New( - Integer::Cast(x).AsInt64Value(), Integer::Cast(y).AsInt64Value(), - Integer::Cast(z).AsInt64Value(), Integer::Cast(w).AsInt64Value(), - Heap::kOld)); + Integer::Cast(x).Value(), Integer::Cast(y).Value(), + Integer::Cast(z).Value(), Integer::Cast(w).Value(), Heap::kOld)); result ^= result.Canonicalize(Thread::Current()); return flow_graph->GetConstant(result, kUnboxedInt32x4); } @@ -8729,7 +8726,7 @@ void MakePairInstr::EmitNativeCode(FlowGraphCompiler* compiler) { } int64_t TestIntInstr::ComputeImmediateMask() { - int64_t mask = Integer::Cast(locs()->in(1).constant()).AsInt64Value(); + int64_t mask = Integer::Cast(locs()->in(1).constant()).Value(); switch (representation_) { case kTagged: diff --git a/runtime/vm/compiler/backend/il_arm.cc b/runtime/vm/compiler/backend/il_arm.cc index 9a8794e6f4c6..cef4275d39a5 100644 --- a/runtime/vm/compiler/backend/il_arm.cc +++ b/runtime/vm/compiler/backend/il_arm.cc @@ -432,7 +432,7 @@ void MemoryCopyInstr::EmitComputeStartPointer(FlowGraphCompiler* compiler, if (start_loc.IsConstant()) { const auto& constant = start_loc.constant(); ASSERT(constant.IsInteger()); - const int64_t start_value = Integer::Cast(constant).AsInt64Value(); + const int64_t start_value = Integer::Cast(constant).Value(); const intptr_t add_value = Utils::AddWithWrapAround( Utils::MulWithWrapAround(start_value, element_size_), offset); __ AddImmediate(payload_reg, array_reg, add_value); @@ -1281,12 +1281,12 @@ static Condition EmitWordComparisonOp(FlowGraphCompiler* compiler, if (left.IsConstant()) { __ CompareImmediate( right.reg(), - static_cast(Integer::Cast(left.constant()).AsInt64Value())); + static_cast(Integer::Cast(left.constant()).Value())); true_condition = FlipCondition(true_condition); } else if (right.IsConstant()) { __ CompareImmediate( left.reg(), - static_cast(Integer::Cast(right.constant()).AsInt64Value())); + static_cast(Integer::Cast(right.constant()).Value())); } else { __ cmp(left.reg(), compiler::Operand(right.reg())); } @@ -6507,7 +6507,7 @@ static void EmitShiftInt64ByConstant(FlowGraphCompiler* compiler, Register left_lo, Register left_hi, const Object& right) { - const int64_t shift = Integer::Cast(right).AsInt64Value(); + const int64_t shift = Integer::Cast(right).Value(); ASSERT(shift >= 0); switch (op_kind) { @@ -6610,7 +6610,7 @@ static void EmitShiftUint32ByConstant(FlowGraphCompiler* compiler, Register out, Register left, const Object& right) { - const int64_t shift = Integer::Cast(right).AsInt64Value(); + const int64_t shift = Integer::Cast(right).Value(); ASSERT(shift >= 0); if (shift >= 32) { __ LoadImmediate(out, 0); diff --git a/runtime/vm/compiler/backend/il_arm64.cc b/runtime/vm/compiler/backend/il_arm64.cc index 071541edc7c6..92dd19d12253 100644 --- a/runtime/vm/compiler/backend/il_arm64.cc +++ b/runtime/vm/compiler/backend/il_arm64.cc @@ -347,7 +347,7 @@ void MemoryCopyInstr::EmitComputeStartPointer(FlowGraphCompiler* compiler, if (start_loc.IsConstant()) { const auto& constant = start_loc.constant(); ASSERT(constant.IsInteger()); - const int64_t start_value = Integer::Cast(constant).AsInt64Value(); + const int64_t start_value = Integer::Cast(constant).Value(); const intptr_t add_value = Utils::AddWithWrapAround( Utils::MulWithWrapAround(start_value, element_size_), offset); __ AddImmediate(payload_reg, array_reg, add_value); @@ -727,7 +727,7 @@ void ConstantInstr::EmitMoveToLocation(FlowGraphCompiler* compiler, if (representation() == kUnboxedInt32 || representation() == kUnboxedUint32 || representation() == kUnboxedInt64) { - const int64_t value = Integer::Cast(value_).AsInt64Value(); + const int64_t value = Integer::Cast(value_).Value(); __ LoadImmediate(destination.reg(), value); } else { ASSERT(representation() == kTagged); @@ -782,7 +782,7 @@ void ConstantInstr::EmitMoveToLocation(FlowGraphCompiler* compiler, if (representation() == kUnboxedInt32 || representation() == kUnboxedUint32 || representation() == kUnboxedInt64) { - const int64_t value = Integer::Cast(value_).AsInt64Value(); + const int64_t value = Integer::Cast(value_).Value(); if (value == 0) { tmp = ZR; } else { @@ -1276,7 +1276,7 @@ static bool IsSingleBitMask(Location mask, intptr_t* bit) { } uint64_t mask_value = - static_cast(Integer::Cast(mask.constant()).AsInt64Value()); + static_cast(Integer::Cast(mask.constant()).Value()); if (!Utils::IsPowerOfTwo(mask_value)) { return false; } @@ -5488,7 +5488,7 @@ static void EmitInt64ModTruncDiv(FlowGraphCompiler* compiler, // We only consider magic operations under O3. } else if (auto c = instruction->right()->definition()->AsConstant()) { if (c->value().IsInteger()) { - const int64_t divisor = Integer::Cast(c->value()).AsInt64Value(); + const int64_t divisor = Integer::Cast(c->value()).Value(); if (divisor <= -2 || divisor >= 2) { // For x DIV c or x MOD c: use magic operations. compiler::Label pos; @@ -5670,7 +5670,7 @@ static void EmitShiftInt64ByConstant(FlowGraphCompiler* compiler, Register out, Register left, const Object& right) { - const int64_t shift = Integer::Cast(right).AsInt64Value(); + const int64_t shift = Integer::Cast(right).Value(); ASSERT(shift >= 0); switch (op_kind) { case Token::kSHR: { @@ -5721,7 +5721,7 @@ static void EmitShiftUint32ByConstant(FlowGraphCompiler* compiler, Register out, Register left, const Object& right) { - const int64_t shift = Integer::Cast(right).AsInt64Value(); + const int64_t shift = Integer::Cast(right).Value(); ASSERT(shift >= 0); if (shift >= 32) { __ LoadImmediate(out, 0); diff --git a/runtime/vm/compiler/backend/il_ia32.cc b/runtime/vm/compiler/backend/il_ia32.cc index fbe2aca4b268..4eb619e6ec02 100644 --- a/runtime/vm/compiler/backend/il_ia32.cc +++ b/runtime/vm/compiler/backend/il_ia32.cc @@ -225,7 +225,7 @@ void MemoryCopyInstr::EmitComputeStartPointer(FlowGraphCompiler* compiler, if (start_loc.IsConstant()) { const auto& constant = start_loc.constant(); ASSERT(constant.IsInteger()); - const int64_t start_value = Integer::Cast(constant).AsInt64Value(); + const int64_t start_value = Integer::Cast(constant).Value(); const intptr_t add_value = Utils::AddWithWrapAround( Utils::MulWithWrapAround(start_value, element_size_), offset); __ leal(payload_reg, compiler::Address(array_reg, add_value)); @@ -805,12 +805,12 @@ static Condition EmitWordComparisonOp(FlowGraphCompiler* compiler, if (left.IsConstant()) { __ CompareImmediate( right.reg(), - static_cast(Integer::Cast(left.constant()).AsInt64Value())); + static_cast(Integer::Cast(left.constant()).Value())); true_condition = FlipCondition(true_condition); } else if (right.IsConstant()) { __ CompareImmediate( left.reg(), - static_cast(Integer::Cast(right.constant()).AsInt64Value())); + static_cast(Integer::Cast(right.constant()).Value())); } else if (right.IsStackSlot()) { __ cmpl(left.reg(), LocationToStackSlotAddress(right)); } else { @@ -5597,7 +5597,7 @@ static void EmitShiftInt64ByConstant(FlowGraphCompiler* compiler, Register left_lo, Register left_hi, const Object& right) { - const int64_t shift = Integer::Cast(right).AsInt64Value(); + const int64_t shift = Integer::Cast(right).Value(); ASSERT(shift >= 0); switch (op_kind) { case Token::kSHR: { @@ -5709,7 +5709,7 @@ static void EmitShiftUint32ByConstant(FlowGraphCompiler* compiler, Token::Kind op_kind, Register left, const Object& right) { - const int64_t shift = Integer::Cast(right).AsInt64Value(); + const int64_t shift = Integer::Cast(right).Value(); if (shift >= 32) { __ xorl(left, left); } else { diff --git a/runtime/vm/compiler/backend/il_printer.cc b/runtime/vm/compiler/backend/il_printer.cc index f5d2b0d004ce..daa337163490 100644 --- a/runtime/vm/compiler/backend/il_printer.cc +++ b/runtime/vm/compiler/backend/il_printer.cc @@ -252,7 +252,7 @@ class IlTestPrinter : public AllStatic { } else if (obj->IsBool()) { writer_->PrintValueBool(Bool::Cast(*obj).value()); } else if (obj->IsInteger()) { - auto value = Integer::Cast(*obj).AsInt64Value(); + auto value = Integer::Cast(*obj).Value(); // PrintValue64 and PrintValue will check if integer is representable // as a JS number, which is too strict. We don't actually need // such checks because we only load resulting JSON in Dart. diff --git a/runtime/vm/compiler/backend/il_riscv.cc b/runtime/vm/compiler/backend/il_riscv.cc index 2529e6db979e..c703322e721e 100644 --- a/runtime/vm/compiler/backend/il_riscv.cc +++ b/runtime/vm/compiler/backend/il_riscv.cc @@ -424,7 +424,7 @@ void MemoryCopyInstr::EmitComputeStartPointer(FlowGraphCompiler* compiler, if (start_loc.IsConstant()) { const auto& constant = start_loc.constant(); ASSERT(constant.IsInteger()); - const int64_t start_value = Integer::Cast(constant).AsInt64Value(); + const int64_t start_value = Integer::Cast(constant).Value(); const intx_t add_value = Utils::AddWithWrapAround( Utils::MulWithWrapAround(start_value, element_size_), offset); __ AddImmediate(payload_reg, array_reg, add_value); @@ -825,7 +825,7 @@ void ConstantInstr::EmitMoveToLocation(FlowGraphCompiler* compiler, const intptr_t dest_offset = destination.ToStackSlotOffset(); compiler::OperandSize operand_size = compiler::kWordBytes; if (RepresentationUtils::IsUnboxedInteger(representation())) { - int64_t val = Integer::Cast(value_).AsInt64Value(); + int64_t val = Integer::Cast(value_).Value(); #if XLEN == 32 val = pair_index == 0 ? Utils::Low32Bits(val) : Utils::High32Bits(val); #else @@ -1082,7 +1082,7 @@ static Condition EmitWordComparisonOp(FlowGraphCompiler* compiler, } __ CompareImmediate( left.reg(), - static_cast(Integer::Cast(right.constant()).AsInt64Value())); + static_cast(Integer::Cast(right.constant()).Value())); } else { __ CompareRegisters(left.reg(), right.reg()); } @@ -5811,7 +5811,7 @@ static void EmitShiftInt64ByConstant(FlowGraphCompiler* compiler, Register left_lo, Register left_hi, const Object& right) { - const int64_t shift = Integer::Cast(right).AsInt64Value(); + const int64_t shift = Integer::Cast(right).Value(); ASSERT(shift >= 0); switch (op_kind) { @@ -5878,7 +5878,7 @@ static void EmitShiftInt64ByConstant(FlowGraphCompiler* compiler, Register out, Register left, const Object& right) { - const int64_t shift = Integer::Cast(right).AsInt64Value(); + const int64_t shift = Integer::Cast(right).Value(); ASSERT(shift >= 0); switch (op_kind) { case Token::kSHR: { @@ -6011,7 +6011,7 @@ static void EmitShiftUint32ByConstant(FlowGraphCompiler* compiler, Register out, Register left, const Object& right) { - const int64_t shift = Integer::Cast(right).AsInt64Value(); + const int64_t shift = Integer::Cast(right).Value(); ASSERT(shift >= 0); if (shift >= 32) { __ li(out, 0); diff --git a/runtime/vm/compiler/backend/il_serializer.cc b/runtime/vm/compiler/backend/il_serializer.cc index ab6216fd9893..465247fe0f17 100644 --- a/runtime/vm/compiler/backend/il_serializer.cc +++ b/runtime/vm/compiler/backend/il_serializer.cc @@ -1653,7 +1653,7 @@ void FlowGraphSerializer::WriteObjectImpl(const Object& x, } case kMintCid: ASSERT(x.IsCanonical()); - Write(Integer::Cast(x).AsInt64Value()); + Write(Integer::Cast(x).Value()); break; case kNullCid: break; diff --git a/runtime/vm/compiler/backend/il_test.cc b/runtime/vm/compiler/backend/il_test.cc index 4fbc2522cea4..dea44d654fa9 100644 --- a/runtime/vm/compiler/backend/il_test.cc +++ b/runtime/vm/compiler/backend/il_test.cc @@ -757,7 +757,7 @@ ISOLATE_UNIT_TEST_CASE(IRTest_LoadThread) { // Ensure we can successfully invoke the function. invoke_result ^= Invoke(root_library, "myFunction"); - intptr_t result_int = Integer::Cast(invoke_result).AsInt64Value(); + intptr_t result_int = Integer::Cast(invoke_result).Value(); EXPECT_EQ(reinterpret_cast(thread), result_int); } diff --git a/runtime/vm/compiler/backend/il_x64.cc b/runtime/vm/compiler/backend/il_x64.cc index ce7831d4f18d..a3c532db3a70 100644 --- a/runtime/vm/compiler/backend/il_x64.cc +++ b/runtime/vm/compiler/backend/il_x64.cc @@ -321,7 +321,7 @@ void MemoryCopyInstr::EmitComputeStartPointer(FlowGraphCompiler* compiler, if (start_loc.IsConstant()) { const auto& constant = start_loc.constant(); ASSERT(constant.IsInteger()); - const int64_t start_value = Integer::Cast(constant).AsInt64Value(); + const int64_t start_value = Integer::Cast(constant).Value(); const intptr_t add_value = Utils::AddWithWrapAround( Utils::MulWithWrapAround(start_value, element_size_), offset); __ leaq(payload_reg, compiler::Address(array_reg, add_value)); @@ -648,7 +648,7 @@ void ConstantInstr::EmitMoveToLocation(FlowGraphCompiler* compiler, ASSERT(pair_index == 0); // No pair representation needed on 64-bit. if (destination.IsRegister()) { if (RepresentationUtils::IsUnboxedInteger(representation())) { - const int64_t value = Integer::Cast(value_).AsInt64Value(); + const int64_t value = Integer::Cast(value_).Value(); if (value == 0) { __ xorl(destination.reg(), destination.reg()); } else { @@ -702,7 +702,7 @@ void ConstantInstr::EmitMoveToLocation(FlowGraphCompiler* compiler, } else { ASSERT(destination.IsStackSlot()); if (RepresentationUtils::IsUnboxedInteger(representation())) { - const int64_t value = Integer::Cast(value_).AsInt64Value(); + const int64_t value = Integer::Cast(value_).Value(); __ movq(LocationToStackSlotAddress(destination), compiler::Immediate(value)); } else if (representation() == kUnboxedFloat) { @@ -5752,7 +5752,7 @@ static void EmitInt64ModTruncDiv(FlowGraphCompiler* compiler, // to implement the exception. if (auto c = instruction->right()->definition()->AsConstant()) { if (c->value().IsInteger()) { - const int64_t divisor = Integer::Cast(c->value()).AsInt64Value(); + const int64_t divisor = Integer::Cast(c->value()).Value(); if (divisor <= -2 || divisor >= 2) { // For x DIV c or x MOD c: use magic operations. compiler::Label pos; @@ -5986,7 +5986,7 @@ static void EmitShiftInt64ByConstant(FlowGraphCompiler* compiler, Token::Kind op_kind, Register left, const Object& right) { - const int64_t shift = Integer::Cast(right).AsInt64Value(); + const int64_t shift = Integer::Cast(right).Value(); ASSERT(shift >= 0); switch (op_kind) { case Token::kSHR: @@ -6032,7 +6032,7 @@ static void EmitShiftUint32ByConstant(FlowGraphCompiler* compiler, Token::Kind op_kind, Register left, const Object& right) { - const int64_t shift = Integer::Cast(right).AsInt64Value(); + const int64_t shift = Integer::Cast(right).Value(); ASSERT(shift >= 0); if (shift >= 32) { __ xorl(left, left); diff --git a/runtime/vm/compiler/backend/loops.cc b/runtime/vm/compiler/backend/loops.cc index ede12737b248..fcc3cee41736 100644 --- a/runtime/vm/compiler/backend/loops.cc +++ b/runtime/vm/compiler/backend/loops.cc @@ -124,7 +124,7 @@ static bool IsConstant(Definition* def, int64_t* val) { if (def->IsConstant()) { const Object& value = def->AsConstant()->value(); if (value.IsInteger()) { - *val = Integer::Cast(value).AsInt64Value(); // smi and mint + *val = Integer::Cast(value).Value(); // smi and mint return true; } } diff --git a/runtime/vm/compiler/backend/range_analysis.cc b/runtime/vm/compiler/backend/range_analysis.cc index c8886c0db187..591332f3e84c 100644 --- a/runtime/vm/compiler/backend/range_analysis.cc +++ b/runtime/vm/compiler/backend/range_analysis.cc @@ -2791,16 +2791,12 @@ void PhiInstr::InferRange(RangeAnalysis* analysis, Range* range) { } void ConstantInstr::InferRange(RangeAnalysis* analysis, Range* range) { - if (value_.IsSmi()) { - int64_t value = Smi::Cast(value_).Value(); - *range = Range(RangeBoundary::FromConstant(value), - RangeBoundary::FromConstant(value)); - } else if (value_.IsMint()) { - int64_t value = Mint::Cast(value_).value(); + if (value_.IsInteger()) { + int64_t value = Integer::Cast(value_).Value(); *range = Range(RangeBoundary::FromConstant(value), RangeBoundary::FromConstant(value)); } else { - // Only Smi and Mint supported. + // Only integer constants supported. FATAL("Unexpected constant: %s\n", value_.ToCString()); } } diff --git a/runtime/vm/compiler/ffi/native_type.cc b/runtime/vm/compiler/ffi/native_type.cc index b0c86f9bbcbf..c632313bb1c3 100644 --- a/runtime/vm/compiler/ffi/native_type.cc +++ b/runtime/vm/compiler/ffi/native_type.cc @@ -463,7 +463,7 @@ static const NativeType* CompoundFromPragma(Zone* zone, const auto& packed_value = Integer::Handle( zone, Integer::RawCast(struct_layout.GetField(packed_field))); const intptr_t member_packing = - packed_value.IsNull() ? kMaxInt32 : packed_value.AsInt64Value(); + packed_value.IsNull() ? kMaxInt32 : packed_value.Value(); auto& field_instance = Instance::Handle(zone); auto& field_type = AbstractType::Handle(zone); @@ -506,7 +506,7 @@ static const NativeType* CompoundFromPragma(Zone* zone, return nullptr; } const auto field_native_type = - new (zone) NativeArrayType(*element_type, length.AsInt64Value()); + new (zone) NativeArrayType(*element_type, length.Value()); field_native_types.Add(field_native_type); } } diff --git a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc index 46c46cd1e1f6..6e6713ee9f22 100644 --- a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc +++ b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc @@ -5255,8 +5255,8 @@ Fragment StreamingFlowGraphBuilder::BuildBinarySearchSwitch( Fragment lower_branch_instructions(then_entry); Fragment upper_branch_instructions(otherwise_entry); - if (next_expression.integer().AsInt64Value() > - middle_expression.integer().AsInt64Value() + 1) { + if (next_expression.integer().Value() > + middle_expression.integer().Value() + 1) { // The upper branch is not contiguous with the lower branch. // Before continuing in the upper branch we add a bound check. @@ -5347,7 +5347,7 @@ Fragment StreamingFlowGraphBuilder::BuildJumpTableSwitch(SwitchHelper* helper) { current_instructions += LoadLocal(scopes()->switch_variable); - if (!expression_min.IsZero()) { + if (expression_min.Value() != 0) { // Adjust for the range of the jump table, which starts at 0. current_instructions += Constant(expression_min); current_instructions += @@ -5374,7 +5374,7 @@ Fragment StreamingFlowGraphBuilder::BuildJumpTableSwitch(SwitchHelper* helper) { const SwitchExpression& expression = helper->expressions().At(expression_index++); const intptr_t table_offset = - expression.integer().AsInt64Value() - expression_min.AsInt64Value(); + expression.integer().Value() - expression_min.Value(); IndirectEntryInstr* indirect_entry = B->BuildIndirectEntry(table_offset, CurrentTryIndex()); diff --git a/runtime/vm/compiler/frontend/kernel_binary_flowgraph_test.cc b/runtime/vm/compiler/frontend/kernel_binary_flowgraph_test.cc index 1ca391ca360a..81a6e3903a1d 100644 --- a/runtime/vm/compiler/frontend/kernel_binary_flowgraph_test.cc +++ b/runtime/vm/compiler/frontend/kernel_binary_flowgraph_test.cc @@ -98,14 +98,14 @@ ISOLATE_UNIT_TEST_CASE(StreamingFlowGraphBuilder_FlattenNestedStringInterp) { // StoreIndexed(tmp_array, 0, s) EXPECT(store1->index()->BindsToConstant()); EXPECT(store1->index()->BoundConstant().IsInteger()); - EXPECT(Integer::Cast(store1->index()->BoundConstant()).AsInt64Value() == 0); + EXPECT(Integer::Cast(store1->index()->BoundConstant()).Value() == 0); EXPECT(!store1->value()->BindsToConstant()); // StoreIndexed(tmp_array, 1, "de") EXPECT(store2->index()->BindsToConstant()); EXPECT(store2->index()->BoundConstant().IsInteger()); - EXPECT(Integer::Cast(store2->index()->BoundConstant()).AsInt64Value() == 1); + EXPECT(Integer::Cast(store2->index()->BoundConstant()).Value() == 1); EXPECT(store2->value()->BindsToConstant()); EXPECT(store2->value()->BoundConstant().IsString()); @@ -158,7 +158,7 @@ ISOLATE_UNIT_TEST_CASE(StreamingFlowGraphBuilder_DropEmptyStringInterp) { // StoreIndexed(tmp_array, 0, "ab") EXPECT(store1->index()->BindsToConstant()); EXPECT(store1->index()->BoundConstant().IsInteger()); - EXPECT(Integer::Cast(store1->index()->BoundConstant()).AsInt64Value() == 0); + EXPECT(Integer::Cast(store1->index()->BoundConstant()).Value() == 0); EXPECT(store1->value()->BindsToConstant()); EXPECT(store1->value()->BoundConstant().IsString()); @@ -167,14 +167,14 @@ ISOLATE_UNIT_TEST_CASE(StreamingFlowGraphBuilder_DropEmptyStringInterp) { // StoreIndexed(tmp_array, 1, s) EXPECT(store2->index()->BindsToConstant()); EXPECT(store2->index()->BoundConstant().IsInteger()); - EXPECT(Integer::Cast(store2->index()->BoundConstant()).AsInt64Value() == 1); + EXPECT(Integer::Cast(store2->index()->BoundConstant()).Value() == 1); EXPECT(!store2->value()->BindsToConstant()); // StoreIndexed(tmp_array, 2, "b") EXPECT(store3->index()->BindsToConstant()); EXPECT(store3->index()->BoundConstant().IsInteger()); - EXPECT(Integer::Cast(store3->index()->BoundConstant()).AsInt64Value() == 2); + EXPECT(Integer::Cast(store3->index()->BoundConstant()).Value() == 2); EXPECT(store3->value()->BindsToConstant()); EXPECT(store3->value()->BoundConstant().IsString()); @@ -227,7 +227,7 @@ ISOLATE_UNIT_TEST_CASE(StreamingFlowGraphBuilder_ConcatStringLits) { // StoreIndexed(tmp_array, 0, "ab") EXPECT(store1->index()->BindsToConstant()); EXPECT(store1->index()->BoundConstant().IsInteger()); - EXPECT(Integer::Cast(store1->index()->BoundConstant()).AsInt64Value() == 0); + EXPECT(Integer::Cast(store1->index()->BoundConstant()).Value() == 0); EXPECT(store1->value()->BindsToConstant()); EXPECT(store1->value()->BoundConstant().IsString()); @@ -236,14 +236,14 @@ ISOLATE_UNIT_TEST_CASE(StreamingFlowGraphBuilder_ConcatStringLits) { // StoreIndexed(tmp_array, 1, s) EXPECT(store2->index()->BindsToConstant()); EXPECT(store2->index()->BoundConstant().IsInteger()); - EXPECT(Integer::Cast(store2->index()->BoundConstant()).AsInt64Value() == 1); + EXPECT(Integer::Cast(store2->index()->BoundConstant()).Value() == 1); EXPECT(!store2->value()->BindsToConstant()); // StoreIndexed(tmp_array, 2, "cd") EXPECT(store3->index()->BindsToConstant()); EXPECT(store3->index()->BoundConstant().IsInteger()); - EXPECT(Integer::Cast(store3->index()->BoundConstant()).AsInt64Value() == 2); + EXPECT(Integer::Cast(store3->index()->BoundConstant()).Value() == 2); EXPECT(store3->value()->BindsToConstant()); EXPECT(store3->value()->BoundConstant().IsString()); @@ -387,7 +387,7 @@ ISOLATE_UNIT_TEST_CASE( return_instr->value()->definition()->AsConstant(); EXPECT(const_value != nullptr); EXPECT(const_value->value().IsInteger()); - EXPECT_EQ(0xFEEDFEED, Integer::Cast(const_value->value()).AsInt64Value()); + EXPECT_EQ(0xFEEDFEED, Integer::Cast(const_value->value()).Value()); } } // namespace dart diff --git a/runtime/vm/compiler/frontend/kernel_to_il.cc b/runtime/vm/compiler/frontend/kernel_to_il.cc index 87956ccfd71b..80f2ff625cd7 100644 --- a/runtime/vm/compiler/frontend/kernel_to_il.cc +++ b/runtime/vm/compiler/frontend/kernel_to_il.cc @@ -5862,8 +5862,8 @@ SwitchHelper::SwitchHelper(Zone* zone, } int64_t SwitchHelper::ExpressionRange() const { - const int64_t min = expression_min().AsInt64Value(); - const int64_t max = expression_max().AsInt64Value(); + const int64_t min = expression_min().Value(); + const int64_t max = expression_max().Value(); ASSERT(min <= max); const uint64_t diff = static_cast(max) - static_cast(min); // Saturate to avoid overflow. @@ -5875,7 +5875,7 @@ int64_t SwitchHelper::ExpressionRange() const { bool SwitchHelper::RequiresLowerBoundCheck() const { if (is_enum_switch()) { - if (expression_min().IsZero()) { + if (expression_min().Value() == 0) { // Enum indexes are always positive. return false; } @@ -5972,14 +5972,14 @@ SwitchDispatch SwitchHelper::SelectDispatchStrategy() { // If the range starts at zero it directly maps to the jump table // and we don't need to adjust the switch variable before the // jump table. - if (expression_min().AsInt64Value() > 0) { + if (expression_min().Value() > 0) { const intptr_t holes_budget = Utils::Minimum( // Holes still available. max_holes - holes, // Entries left in the jump table. kJumpTableMaxSize - range); - const int64_t required_holes = expression_min().AsInt64Value(); + const int64_t required_holes = expression_min().Value(); if (required_holes <= holes_budget) { expression_min_ = &Object::smi_zero(); } diff --git a/runtime/vm/compiler/runtime_api.cc b/runtime/vm/compiler/runtime_api.cc index 4122bb3dd81c..c5c0c3684f99 100644 --- a/runtime/vm/compiler/runtime_api.cc +++ b/runtime/vm/compiler/runtime_api.cc @@ -238,7 +238,7 @@ const String& AllocateString(const char* buffer) { bool HasIntegerValue(const dart::Object& object, int64_t* value) { if (object.IsInteger()) { - *value = Integer::Cast(object).AsInt64Value(); + *value = Integer::Cast(object).Value(); return true; } return false; diff --git a/runtime/vm/compiler_test.cc b/runtime/vm/compiler_test.cc index 63d57dc36b2d..26f62a4425da 100644 --- a/runtime/vm/compiler_test.cc +++ b/runtime/vm/compiler_test.cc @@ -248,7 +248,7 @@ ISOLATE_UNIT_TEST_CASE(EvalExpressionWithLazyCompile) { EXPECT(!val.IsNull()); EXPECT(!val.IsError()); EXPECT(val.IsInteger()); - EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); + EXPECT_EQ(7, Integer::Cast(val).Value()); } ISOLATE_UNIT_TEST_CASE(EvalExpressionExhaustCIDs) { @@ -267,7 +267,7 @@ ISOLATE_UNIT_TEST_CASE(EvalExpressionExhaustCIDs) { EXPECT(!val.IsNull()); EXPECT(!val.IsError()); EXPECT(val.IsInteger()); - EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); + EXPECT_EQ(7, Integer::Cast(val).Value()); auto class_table = IsolateGroup::Current()->class_table(); @@ -280,7 +280,7 @@ ISOLATE_UNIT_TEST_CASE(EvalExpressionExhaustCIDs) { EXPECT(!val.IsNull()); EXPECT(!val.IsError()); EXPECT(val.IsInteger()); - EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); + EXPECT_EQ(7, Integer::Cast(val).Value()); intptr_t final_class_table_size = class_table->NumCids(); // Eval should not eat into this non-renewable resource. diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc index 79a25b965c33..e39f93b73a53 100644 --- a/runtime/vm/dart_api_impl.cc +++ b/runtime/vm/dart_api_impl.cc @@ -2628,7 +2628,7 @@ DART_EXPORT Dart_Handle Dart_IntegerFitsIntoUint64(Dart_Handle integer, RETURN_TYPE_ERROR(Z, integer, Integer); } ASSERT(int_obj.IsMint()); - *fits = !int_obj.IsNegative(); + *fits = (int_obj.Value() >= 0); return Api::Success(); } @@ -2684,7 +2684,7 @@ DART_EXPORT Dart_Handle Dart_IntegerToInt64(Dart_Handle integer, RETURN_TYPE_ERROR(Z, integer, Integer); } ASSERT(int_obj.IsMint()); - *value = int_obj.AsInt64Value(); + *value = int_obj.Value(); return Api::Success(); } @@ -2708,11 +2708,12 @@ DART_EXPORT Dart_Handle Dart_IntegerToUint64(Dart_Handle integer, RETURN_TYPE_ERROR(Z, integer, Integer); } if (int_obj.IsSmi()) { - ASSERT(int_obj.IsNegative()); + ASSERT(int_obj.Value() < 0); } else { ASSERT(int_obj.IsMint()); - if (!int_obj.IsNegative()) { - *value = int_obj.AsInt64Value(); + const int64_t v = int_obj.Value(); + if (v >= 0) { + *value = v; return Api::Success(); } } @@ -3171,7 +3172,7 @@ DART_EXPORT Dart_Handle Dart_ListLength(Dart_Handle list, intptr_t* len) { *len = Smi::Cast(retval).Value(); return Api::Success(); } else if (retval.IsMint()) { - int64_t mint_value = Mint::Cast(retval).value(); + int64_t mint_value = Mint::Cast(retval).Value(); if (mint_value >= kIntptrMin && mint_value <= kIntptrMax) { *len = static_cast(mint_value); return Api::Success(); @@ -3391,8 +3392,8 @@ static ObjectPtr ThrowArgumentError(const char* exception_message) { T, ThrowArgumentError("List contains non-int elements")); \ } \ const Integer& integer = Integer::Cast(element); \ - native_array[i] = static_cast(integer.AsInt64Value() & 0xff); \ - ASSERT(integer.AsInt64Value() <= 0xff); \ + native_array[i] = static_cast(integer.Value() & 0xff); \ + ASSERT(integer.Value() <= 0xff); \ } \ return Api::Success(); \ } \ @@ -3453,11 +3454,10 @@ DART_EXPORT Dart_Handle Dart_ListGetAsBytes(Dart_Handle list, CURRENT_FUNC); } const Integer& integer_result = Integer::Cast(result); - ASSERT(integer_result.AsInt64Value() <= 0xff); + ASSERT(integer_result.Value() <= 0xff); // TODO(hpayer): value should always be smaller then 0xff. Add error // handling. - native_array[i] = - static_cast(integer_result.AsInt64Value() & 0xff); + native_array[i] = static_cast(integer_result.Value() & 0xff); } return Api::Success(); } diff --git a/runtime/vm/debugger_api_impl_test.cc b/runtime/vm/debugger_api_impl_test.cc index e4fd09869fd5..3bdbdddc5417 100644 --- a/runtime/vm/debugger_api_impl_test.cc +++ b/runtime/vm/debugger_api_impl_test.cc @@ -163,7 +163,7 @@ Dart_Handle Dart_RemoveBreakpoint(Dart_Handle breakpoint_id_in) { Isolate* I = T->isolate(); CHECK_DEBUGGER(I); UNWRAP_AND_CHECK_PARAM(Integer, breakpoint_id, breakpoint_id_in); - I->debugger()->RemoveBreakpoint(breakpoint_id.AsInt64Value()); + I->debugger()->RemoveBreakpoint(breakpoint_id.Value()); return Api::Success(); } diff --git a/runtime/vm/deferred_objects.cc b/runtime/vm/deferred_objects.cc index 2eebb6fe5ee1..94c9dbab3382 100644 --- a/runtime/vm/deferred_objects.cc +++ b/runtime/vm/deferred_objects.cc @@ -356,15 +356,15 @@ void DeferredObject::Fill() { const int kDataIndex = 0; const int kTypeArgIndex = 1; ASSERT(field_count_ == 2); - ASSERT(Smi::Cast(Object::Handle(zone, GetFieldOffset(kDataIndex))) - .AsInt64Value() == PointerBase::data_offset()); + ASSERT( + Smi::Cast(Object::Handle(zone, GetFieldOffset(kDataIndex))).Value() == + PointerBase::data_offset()); ASSERT(Smi::Cast(Object::Handle(zone, GetFieldOffset(kTypeArgIndex))) - .AsInt64Value() == Pointer::type_arguments_offset()); + .Value() == Pointer::type_arguments_offset()); const auto& pointer = Pointer::Cast(*object_); const size_t address = - Integer::Cast(Object::Handle(zone, GetValue(kDataIndex))) - .AsInt64Value(); + Integer::Cast(Object::Handle(zone, GetValue(kDataIndex))).Value(); pointer.SetNativeAddress(address); const auto& type_args = TypeArguments::Handle( zone, IsolateGroup::Current()->object_store()->type_argument_never()); @@ -407,42 +407,41 @@ void DeferredObject::Fill() { case kTypedDataInt8ArrayCid: typed_data.SetInt8( element_offset, - static_cast(Integer::Cast(value).AsInt64Value())); + static_cast(Integer::Cast(value).Value())); break; case kTypedDataUint8ArrayCid: case kTypedDataUint8ClampedArrayCid: typed_data.SetUint8( element_offset, - static_cast(Integer::Cast(value).AsInt64Value())); + static_cast(Integer::Cast(value).Value())); break; case kTypedDataInt16ArrayCid: typed_data.SetInt16( element_offset, - static_cast(Integer::Cast(value).AsInt64Value())); + static_cast(Integer::Cast(value).Value())); break; case kTypedDataUint16ArrayCid: typed_data.SetUint16( element_offset, - static_cast(Integer::Cast(value).AsInt64Value())); + static_cast(Integer::Cast(value).Value())); break; case kTypedDataInt32ArrayCid: typed_data.SetInt32( element_offset, - static_cast(Integer::Cast(value).AsInt64Value())); + static_cast(Integer::Cast(value).Value())); break; case kTypedDataUint32ArrayCid: typed_data.SetUint32( element_offset, - static_cast(Integer::Cast(value).AsInt64Value())); + static_cast(Integer::Cast(value).Value())); break; case kTypedDataInt64ArrayCid: - typed_data.SetInt64(element_offset, - Integer::Cast(value).AsInt64Value()); + typed_data.SetInt64(element_offset, Integer::Cast(value).Value()); break; case kTypedDataUint64ArrayCid: typed_data.SetUint64( element_offset, - static_cast(Integer::Cast(value).AsInt64Value())); + static_cast(Integer::Cast(value).Value())); break; case kTypedDataFloat32ArrayCid: typed_data.SetFloat32( diff --git a/runtime/vm/interpreter.cc b/runtime/vm/interpreter.cc index 551abb11163b..bad840186ab3 100644 --- a/runtime/vm/interpreter.cc +++ b/runtime/vm/interpreter.cc @@ -1007,7 +1007,7 @@ DART_FORCE_INLINE bool Interpreter::InstanceCall(Thread* thread, SP[0] = selector.ptr(); \ goto ThrowNullError; \ } \ - value = Integer::GetInt64Value(Integer::RawCast(obj)); \ + value = Integer::Value(Integer::RawCast(obj)); \ } \ } @@ -1017,7 +1017,7 @@ DART_FORCE_INLINE bool Interpreter::InstanceCall(Thread* thread, } else if (!AllocateMint(thread, result, pc, FP, SP)) { \ HANDLE_EXCEPTION; \ } \ - ASSERT(Integer::GetInt64Value(Integer::RawCast(SP[0])) == result); + ASSERT(Integer::Value(Integer::RawCast(SP[0])) == result); #define UNBOX_DOUBLE(value, obj, selector) \ double value; \ @@ -2204,7 +2204,7 @@ ObjectPtr Interpreter::Call(FunctionPtr function, break; } default: { - int64_t raw_value = Integer::GetInt64Value(Integer::RawCast(value)); + int64_t raw_value = Integer::Value(Integer::RawCast(value)); *reinterpret_cast( reinterpret_cast(instance->untag()) + offset_in_words) = raw_value; @@ -2742,8 +2742,8 @@ ObjectPtr Interpreter::Call(FunctionPtr function, (SP[0] == null_value) || (SP[1] == null_value)) { SP[0] = false_value; } else { - int64_t a = Integer::GetInt64Value(Integer::RawCast(SP[0])); - int64_t b = Integer::GetInt64Value(Integer::RawCast(SP[1])); + int64_t a = Integer::Value(Integer::RawCast(SP[0])); + int64_t b = Integer::Value(Integer::RawCast(SP[1])); SP[0] = (a == b) ? true_value : false_value; } DISPATCH(); diff --git a/runtime/vm/json_stream.cc b/runtime/vm/json_stream.cc index 93df64abbdc4..29a9f1dbfa7a 100644 --- a/runtime/vm/json_stream.cc +++ b/runtime/vm/json_stream.cc @@ -206,7 +206,7 @@ void JSONStream::PostReply() { PrintProperty("id", str.ToCString()); } else if (seq_->IsInteger()) { const Integer& integer = Integer::Cast(*seq_); - PrintProperty64("id", integer.AsInt64Value()); + PrintProperty64("id", integer.Value()); } else if (seq_->IsDouble()) { const Double& dbl = Double::Cast(*seq_); PrintProperty("id", dbl.value()); diff --git a/runtime/vm/message_snapshot.cc b/runtime/vm/message_snapshot.cc index ca5aeaae01fe..61b2e273c954 100644 --- a/runtime/vm/message_snapshot.cc +++ b/runtime/vm/message_snapshot.cc @@ -890,7 +890,7 @@ class MintMessageSerializationCluster : public MessageSerializationCluster { for (intptr_t i = 0; i < count; i++) { Mint* mint = static_cast(objects_[i]); s->AssignRef(mint); - s->Write(mint->value()); + s->Write(mint->Value()); } } diff --git a/runtime/vm/native_entry_test.cc b/runtime/vm/native_entry_test.cc index b3e0b1932163..94a6e3492af5 100644 --- a/runtime/vm/native_entry_test.cc +++ b/runtime/vm/native_entry_test.cc @@ -70,7 +70,7 @@ void TestNonNullSmiSum(Dart_NativeArguments args) { "to be non-null."); } else { EXPECT_VALID(Dart_IntegerToInt64(arg, &arg_value)); - EXPECT_EQ(arg_value, argument.AsInt64Value()); + EXPECT_EQ(arg_value, argument.Value()); // Ignoring overflow in the addition below. result += arg_value; } diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc index 6a6a3ac7b243..bc86018a2188 100644 --- a/runtime/vm/object.cc +++ b/runtime/vm/object.cc @@ -21027,7 +21027,7 @@ void Instance::SetField(const Field& field, const Object& value) const { break; default: StoreNonPointer(reinterpret_cast(FieldAddr(field)), - Integer::Cast(value).AsInt64Value()); + Integer::Cast(value).Value()); break; } } else { @@ -21054,7 +21054,7 @@ void Instance::SetFieldWithoutFieldGuard(const Field& field, break; default: StoreNonPointer(reinterpret_cast(FieldAddr(field)), - Integer::Cast(value).AsInt64Value()); + Integer::Cast(value).Value()); break; } } else { @@ -23587,69 +23587,25 @@ bool Integer::Equals(const Instance& other) const { return false; } -bool Integer::IsZero() const { - // Integer is an abstract class. - UNREACHABLE(); - return false; -} - -bool Integer::IsNegative() const { - // Integer is an abstract class. - UNREACHABLE(); - return false; -} - -double Integer::AsDoubleValue() const { - // Integer is an abstract class. - UNREACHABLE(); - return 0.0; -} - -int64_t Integer::AsInt64Value() const { - // Integer is an abstract class. - UNREACHABLE(); - return 0; -} - -uint32_t Integer::AsTruncatedUint32Value() const { - // Integer is an abstract class. - UNREACHABLE(); - return 0; -} - -bool Integer::FitsIntoSmi() const { - // Integer is an abstract class. - UNREACHABLE(); - return false; -} - int Integer::CompareWith(const Integer& other) const { - // Integer is an abstract class. - UNREACHABLE(); - return 0; + int64_t a = Value(); + int64_t b = other.Value(); + if (a < b) { + return -1; + } else if (a > b) { + return 1; + } else { + return 0; + } } uint32_t Integer::CanonicalizeHash() const { - return Multiply64Hash(AsInt64Value()); -} - -IntegerPtr Integer::AsValidInteger() const { - if (IsSmi()) return ptr(); - if (IsMint()) { - Mint& mint = Mint::Handle(); - mint ^= ptr(); - if (Smi::IsValid(mint.value())) { - return Smi::New(static_cast(mint.value())); - } else { - return ptr(); - } - } - return ptr(); + return Multiply64Hash(Value()); } const char* Integer::ToHexCString(Zone* zone) const { ASSERT(IsSmi() || IsMint()); - int64_t value = AsInt64Value(); + int64_t value = Value(); if (value < 0) { return OS::SCreate(zone, "-0x%" PX64, -static_cast(value)); } else { @@ -23694,8 +23650,8 @@ IntegerPtr Integer::ArithmeticOp(Token::Kind operation, UNIMPLEMENTED(); } } - const int64_t left_value = AsInt64Value(); - const int64_t right_value = other.AsInt64Value(); + const int64_t left_value = Value(); + const int64_t right_value = other.Value(); switch (operation) { case Token::kADD: return Integer::New(Utils::AddWithWrapAround(left_value, right_value), @@ -23762,8 +23718,8 @@ IntegerPtr Integer::BitOp(Token::Kind kind, ASSERT(Smi::IsValid(result)); return Smi::New(result); } else { - int64_t a = AsInt64Value(); - int64_t b = other.AsInt64Value(); + int64_t a = Value(); + int64_t b = other.Value(); switch (kind) { case Token::kBIT_AND: return Integer::New(a & b, space); @@ -23781,8 +23737,8 @@ IntegerPtr Integer::BitOp(Token::Kind kind, IntegerPtr Integer::ShiftOp(Token::Kind kind, const Integer& other, Heap::Space space) const { - int64_t a = AsInt64Value(); - int64_t b = other.AsInt64Value(); + int64_t a = Value(); + int64_t b = other.Value(); ASSERT(b >= 0); switch (kind) { case Token::kSHL: @@ -23805,40 +23761,6 @@ bool Smi::Equals(const Instance& other) const { return (this->Value() == Smi::Cast(other).Value()); } -double Smi::AsDoubleValue() const { - return static_cast(this->Value()); -} - -int64_t Smi::AsInt64Value() const { - return this->Value(); -} - -uint32_t Smi::AsTruncatedUint32Value() const { - return this->Value() & 0xFFFFFFFF; -} - -int Smi::CompareWith(const Integer& other) const { - if (other.IsSmi()) { - const Smi& other_smi = Smi::Cast(other); - if (this->Value() < other_smi.Value()) { - return -1; - } else if (this->Value() > other_smi.Value()) { - return 1; - } else { - return 0; - } - } - ASSERT(!other.FitsIntoSmi()); - if (other.IsMint()) { - if (this->IsNegative() == other.IsNegative()) { - return this->IsNegative() ? 1 : -1; - } - return this->IsNegative() ? -1 : 1; - } - UNREACHABLE(); - return 0; -} - const char* Smi::ToCString() const { return OS::SCreate(Thread::Current()->zone(), "%" Pd "", Value()); } @@ -23876,41 +23798,11 @@ bool Mint::Equals(const Instance& other) const { if (!other.IsMint() || other.IsNull()) { return false; } - return value() == Mint::Cast(other).value(); -} - -double Mint::AsDoubleValue() const { - return static_cast(this->value()); -} - -int64_t Mint::AsInt64Value() const { - return this->value(); -} - -uint32_t Mint::AsTruncatedUint32Value() const { - return this->value() & 0xFFFFFFFF; -} - -bool Mint::FitsIntoSmi() const { - return Smi::IsValid(AsInt64Value()); -} - -int Mint::CompareWith(const Integer& other) const { - ASSERT(!FitsIntoSmi()); - ASSERT(other.IsMint() || other.IsSmi()); - int64_t a = AsInt64Value(); - int64_t b = other.AsInt64Value(); - if (a < b) { - return -1; - } else if (a > b) { - return 1; - } else { - return 0; - } + return Value() == Mint::Cast(other).Value(); } const char* Mint::ToCString() const { - return OS::SCreate(Thread::Current()->zone(), "%" Pd64 "", value()); + return OS::SCreate(Thread::Current()->zone(), "%" Pd64 "", Value()); } void Double::set_value(double value) const { @@ -25619,18 +25511,12 @@ class DefaultHashTraits { if (obj.IsNull()) { return 0; } - // TODO(koda): Ensure VM classes only produce Smi hash codes, and remove - // non-Smi cases once Dart-side implementation is complete. Thread* thread = Thread::Current(); REUSABLE_INSTANCE_HANDLESCOPE(thread); Instance& hash_code = thread->InstanceHandle(); hash_code ^= Instance::Cast(obj).HashCode(); - if (hash_code.IsSmi()) { - // May waste some bits on 64-bit, to ensure consistency with non-Smi case. - return static_cast(Smi::Cast(hash_code).AsTruncatedUint32Value()); - } else if (hash_code.IsInteger()) { - return static_cast( - Integer::Cast(hash_code).AsTruncatedUint32Value()); + if (hash_code.IsInteger()) { + return static_cast(Integer::Cast(hash_code).Value() & 0xFFFFFFFF); } else { return 0; } @@ -26477,14 +26363,15 @@ uword Closure::ComputeHash() const { Instance::Handle(zone, GetImplicitClosureReceiver()); const Integer& receiverHash = Integer::Handle(zone, receiver.IdentityHashCode(thread)); - result = CombineHashes(result, receiverHash.AsTruncatedUint32Value()); + result = + CombineHashes(result, static_cast(receiverHash.Value())); } } else { // Non-implicit closures of non-generic functions are unique, // so identityHashCode of closure object is good enough. const Integer& identityHash = Integer::Handle(zone, this->IdentityHashCode(thread)); - result = identityHash.AsTruncatedUint32Value(); + result = static_cast(identityHash.Value()); } return FinalizeHash(result, String::kHashBits); } diff --git a/runtime/vm/object.h b/runtime/vm/object.h index 23999eb4b256..9e600cb9c4af 100644 --- a/runtime/vm/object.h +++ b/runtime/vm/object.h @@ -10121,25 +10121,17 @@ class Integer : public Number { virtual ObjectPtr HashCode() const { return ptr(); } - virtual bool IsZero() const; - virtual bool IsNegative() const; + int64_t Value() const { return Value(ptr()); } + static int64_t Value(IntegerPtr obj); - virtual double AsDoubleValue() const; - virtual int64_t AsInt64Value() const; - virtual int64_t AsTruncatedInt64Value() const { return AsInt64Value(); } - virtual uint32_t AsTruncatedUint32Value() const; - - virtual bool FitsIntoSmi() const; + double ToDouble() const { return static_cast(Value()); } // Returns 0, -1 or 1. - virtual int CompareWith(const Integer& other) const; + int CompareWith(const Integer& other) const; // Converts integer to hex string. const char* ToHexCString(Zone* zone) const; - // Return the most compact presentation of an integer. - IntegerPtr AsValidInteger() const; - // Returns null to indicate that a bigint operation is required. IntegerPtr ArithmeticOp(Token::Kind operation, const Integer& other, @@ -10151,15 +10143,6 @@ class Integer : public Number { const Integer& other, Heap::Space space = Heap::kNew) const; - static int64_t GetInt64Value(const IntegerPtr obj) { - if (obj->IsSmi()) { - return RawSmiValue(static_cast(obj)); - } else { - ASSERT(obj->IsMint()); - return static_cast(obj)->untag()->value_; - } - } - private: OBJECT_IMPLEMENTATION(Integer, Number); friend class Class; @@ -10174,16 +10157,6 @@ class Smi : public Integer { intptr_t Value() const { return RawSmiValue(ptr()); } virtual bool Equals(const Instance& other) const; - virtual bool IsZero() const { return Value() == 0; } - virtual bool IsNegative() const { return Value() < 0; } - - virtual double AsDoubleValue() const; - virtual int64_t AsInt64Value() const; - virtual uint32_t AsTruncatedUint32Value() const; - - virtual bool FitsIntoSmi() const { return true; } - - virtual int CompareWith(const Integer& other) const; static intptr_t InstanceSize() { return 0; } @@ -10254,23 +10227,13 @@ class Mint : public Integer { static constexpr int64_t kMinValue = static_cast(DART_2PART_UINT64_C(0x80000000, 00000000)); - int64_t value() const { return untag()->value_; } static intptr_t value_offset() { return OFFSET_OF(UntaggedMint, value_); } - static int64_t Value(MintPtr mint) { return mint->untag()->value_; } - virtual bool IsZero() const { return value() == 0; } - virtual bool IsNegative() const { return value() < 0; } + int64_t Value() const { return untag()->value_; } + static int64_t Value(MintPtr mint) { return mint->untag()->value_; } virtual bool Equals(const Instance& other) const; - virtual double AsDoubleValue() const; - virtual int64_t AsInt64Value() const; - virtual uint32_t AsTruncatedUint32Value() const; - - virtual bool FitsIntoSmi() const; - - virtual int CompareWith(const Integer& other) const; - static intptr_t InstanceSize() { return RoundedAllocationSize(sizeof(UntaggedMint)); } @@ -10292,6 +10255,14 @@ class Mint : public Integer { friend class Number; }; +inline int64_t Integer::Value(IntegerPtr obj) { + if (obj->IsSmi()) { + return Smi::Value(Smi::RawCast(obj)); + } else { + return Mint::Value(Mint::RawCast(obj)); + } +} + // Class Double represents class Double in corelib_impl, which implements // abstract class double in corelib. class Double : public Number { diff --git a/runtime/vm/object_test.cc b/runtime/vm/object_test.cc index ec27ee82ca20..ec19a6b96216 100644 --- a/runtime/vm/object_test.cc +++ b/runtime/vm/object_test.cc @@ -398,9 +398,9 @@ ISOLATE_UNIT_TEST_CASE(Smi) { EXPECT(!Smi::IsValid(0xFFFFFFFFu)); #endif - EXPECT_EQ(5, smi.AsInt64Value()); - EXPECT_EQ(5.0, smi.AsDoubleValue()); - EXPECT_EQ(5, Integer::GetInt64Value(smi.ptr())); + EXPECT_EQ(5, smi.Value()); + EXPECT_EQ(5.0, smi.ToDouble()); + EXPECT_EQ(5, Integer::Value(smi.ptr())); Smi& a = Smi::Handle(Smi::New(5)); Smi& b = Smi::Handle(Smi::New(3)); @@ -522,36 +522,35 @@ ISOLATE_UNIT_TEST_CASE(Mint) { EXPECT(med.IsNull()); int64_t v = DART_2PART_UINT64_C(1, 0); med ^= Integer::New(v); - EXPECT_EQ(v, med.value()); + EXPECT_EQ(v, med.Value()); + EXPECT_EQ(v, Integer::Value(med.ptr())); const String& smi_str = String::Handle(String::New("1")); const String& mint1_str = String::Handle(String::New("2147419168")); const String& mint2_str = String::Handle(String::New("-2147419168")); Integer& i = Integer::Handle(Integer::NewCanonical(smi_str)); EXPECT(i.IsSmi()); + EXPECT_EQ(1, i.Value()); i = Integer::NewCanonical(mint1_str); EXPECT(i.IsMint()); - EXPECT(!i.IsZero()); - EXPECT(!i.IsNegative()); + EXPECT_EQ(2147419168, i.Value()); i = Integer::NewCanonical(mint2_str); EXPECT(i.IsMint()); - EXPECT(!i.IsZero()); - EXPECT(i.IsNegative()); + EXPECT_EQ(-2147419168, i.Value()); } Integer& i = Integer::Handle(Integer::New(DART_2PART_UINT64_C(1, 0))); EXPECT(i.IsMint()); EXPECT(i.ptr()->IsMint()); EXPECT(!i.IsSmi()); EXPECT(!i.ptr()->IsSmi()); - EXPECT(!i.IsZero()); - EXPECT(!i.IsNegative()); + EXPECT(i.Value() != 0); Integer& i1 = Integer::Handle(Integer::New(DART_2PART_UINT64_C(1010, 0))); Mint& i2 = Mint::Handle(); i2 ^= Integer::New(DART_2PART_UINT64_C(1010, 0)); EXPECT(i1.Equals(i2)); EXPECT(!i.Equals(i1)); int64_t test = DART_2PART_UINT64_C(1010, 0); - EXPECT_EQ(test, i2.value()); - EXPECT_EQ(test, Integer::GetInt64Value(i2.ptr())); + EXPECT_EQ(test, i2.Value()); + EXPECT_EQ(test, Integer::Value(i2.ptr())); Mint& a = Mint::Handle(); a ^= Integer::New(DART_2PART_UINT64_C(5, 0)); @@ -576,8 +575,8 @@ ISOLATE_UNIT_TEST_CASE(Mint) { mint1 ^= Integer::NewCanonical(mint_string); Mint& mint2 = Mint::Handle(); mint2 ^= Integer::NewCanonical(mint_string); - EXPECT_EQ(mint1.value(), mint_value); - EXPECT_EQ(mint2.value(), mint_value); + EXPECT_EQ(mint1.Value(), mint_value); + EXPECT_EQ(mint2.Value(), mint_value); EXPECT_EQ(mint1.ptr(), mint2.ptr()); #endif } @@ -5735,7 +5734,7 @@ class ToggleBreakpointTask : public ThreadPool::Task { TransitionNativeToVM transition(t); Integer& breakpoint_id_handle = Integer::Handle(); breakpoint_id_handle ^= Api::UnwrapHandle(result); - breakpoint_id = breakpoint_id_handle.AsInt64Value(); + breakpoint_id = breakpoint_id_handle.Value(); } result = Dart_RemoveBreakpoint(Dart_NewInteger(breakpoint_id)); EXPECT_VALID(result); @@ -6478,11 +6477,11 @@ static bool HashCodeEqualsCanonicalizeHash( if (check_hashcode) { hashcode_dart = Integer::Cast(Object::Handle(Api::UnwrapHandle(hashcode_result))) - .AsInt64Value(); + .Value(); } const int64_t identity_hashcode_dart = Integer::Cast(Object::Handle(Api::UnwrapHandle(identity_hashcode_result))) - .AsInt64Value(); + .Value(); if (hashcode_canonicalize_vm == 0) { hashcode_canonicalize_vm = Instance::Cast(value_dart).CanonicalizeHash(); } diff --git a/runtime/vm/runtime_entry.cc b/runtime/vm/runtime_entry.cc index d9f521e31d18..630c2d92e15f 100644 --- a/runtime/vm/runtime_entry.cc +++ b/runtime/vm/runtime_entry.cc @@ -395,7 +395,7 @@ DEFINE_RUNTIME_ENTRY(AllocateArray, 2) { args.SetAt(2, String::Handle(zone, String::New("is not an integer"))); Exceptions::ThrowByType(Exceptions::kArgumentValue, args); } - const int64_t len = Integer::Cast(length).AsInt64Value(); + const int64_t len = Integer::Cast(length).Value(); if (len < 0) { // Throw: new RangeError.range(length, 0, Array::kMaxElements, "length"); Exceptions::ThrowRangeError("length", Integer::Cast(length), 0, @@ -498,7 +498,7 @@ DEFINE_RUNTIME_ENTRY(AllocateTypedData, 2) { args.SetAt(0, length); Exceptions::ThrowByType(Exceptions::kArgument, args); } - const int64_t len = Integer::Cast(length).AsInt64Value(); + const int64_t len = Integer::Cast(length).Value(); const intptr_t max = TypedData::MaxElements(cid); if (len < 0) { Exceptions::ThrowRangeError("length", Integer::Cast(length), 0, max); From 30a720b795c5da14d2d5b4b924de1f00d879e1f2 Mon Sep 17 00:00:00 2001 From: Mayank Patke Date: Mon, 19 Aug 2024 22:07:49 +0000 Subject: [PATCH 11/13] [DEPS] Update chrome_tag to latest beta (128.0.6613.36) Change-Id: Ib1ba532046aea26daf47b3ad51611f347e7334b8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381302 Commit-Queue: Sigmund Cherem Reviewed-by: Sigmund Cherem Auto-Submit: Mayank Patke --- DEPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPS b/DEPS index 0637dd23fcf3..5f360a3856b6 100644 --- a/DEPS +++ b/DEPS @@ -207,7 +207,7 @@ vars = { # meant to be downloaded by users for local testing. You can self-service # update these by following the go/dart-engprod/browsers.md instructions. "download_chrome": False, - "chrome_tag": "128.0.6613.5", + "chrome_tag": "128.0.6613.36", "download_firefox": False, "firefox_tag": "129.0", From 37bda88ce7e9cedbe8e78228f4327e34622981cb Mon Sep 17 00:00:00 2001 From: pq Date: Mon, 19 Aug 2024 22:17:41 +0000 Subject: [PATCH 12/13] [wildcards] organize imports test See: https://github.com/dart-lang/sdk/issues/55681 Change-Id: Iedffc92f6650fc6bd57672bad94c83acd54d26a0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381381 Reviewed-by: Brian Wilkerson Commit-Queue: Phil Quitslund --- .../correction/fix/organize_imports_test.dart | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pkg/analysis_server/test/src/services/correction/fix/organize_imports_test.dart b/pkg/analysis_server/test/src/services/correction/fix/organize_imports_test.dart index cc104b604777..286057a90f66 100644 --- a/pkg/analysis_server/test/src/services/correction/fix/organize_imports_test.dart +++ b/pkg/analysis_server/test/src/services/correction/fix/organize_imports_test.dart @@ -57,6 +57,26 @@ void f(Stream args) { } import 'dart:async'; import 'dart:io'; +void f(Stream args) { } +'''); + } + + Future test_organizeImports_wildcards() async { + await resolveTestCode(''' +//ignore_for_file: unused_import +import 'dart:io' as _; +import 'dart:math' as math; + +import 'dart:async'; + +void f(Stream args) { } +'''); + await assertHasFix(''' +//ignore_for_file: unused_import +import 'dart:async'; +import 'dart:io' as _; +import 'dart:math' as math; + void f(Stream args) { } '''); } From 325c1293b6b2650990186491d6cffcc14ac30b63 Mon Sep 17 00:00:00 2001 From: pq Date: Mon, 19 Aug 2024 22:21:57 +0000 Subject: [PATCH 13/13] [wildcards] inlay hint tests See: https://dart-review.googlesource.com/c/sdk/+/381306 Change-Id: I47c481d7c770d6674687f72478f739a93a6d3e62 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381306 Commit-Queue: Phil Quitslund Reviewed-by: Brian Wilkerson --- .../test/lsp/inlay_hint_test.dart | 158 ++++++++++++++++++ .../test/lsp/server_abstract.dart | 1 + 2 files changed, 159 insertions(+) diff --git a/pkg/analysis_server/test/lsp/inlay_hint_test.dart b/pkg/analysis_server/test/lsp/inlay_hint_test.dart index c9dcf8630e23..fbb2045189b6 100644 --- a/pkg/analysis_server/test/lsp/inlay_hint_test.dart +++ b/pkg/analysis_server/test/lsp/inlay_hint_test.dart @@ -79,6 +79,20 @@ void f([int? a, int? b]) { await _expectHints(content, expected); } + Future test_optionalPositional_wildcards() async { + var content = ''' +void f([int? _, int? _]) { + f(1); +} +'''; + var expected = ''' +void f([int? _, int? _]) { + f((Parameter:_:) 1); +} +'''; + await _expectHints(content, expected); + } + Future test_requiredPositional() async { var content = ''' void f(int a, int b) { @@ -93,6 +107,20 @@ void f(int a, int b) { await _expectHints(content, expected); } + Future test_requiredPositional_wildcards() async { + var content = ''' +void f(int _, int _) { + f(1, 2); +} +'''; + var expected = ''' +void f(int _, int _) { + f((Parameter:_:) 1, (Parameter:_:) 2); +} +'''; + await _expectHints(content, expected); + } + /// Don't try to produce hints for parameters without names. Future test_unnamed() async { var content = ''' @@ -135,6 +163,20 @@ class A { await _expectHints(content, expected); } + Future test_class_field_wildcards() async { + var content = ''' +class A { + final _ = 1; +} +'''; + var expected = ''' +class A { + final (Type:int) _ = 1; +} +'''; + await _expectHints(content, expected); + } + Future test_class_typeArguments() async { var content = ''' class A { @@ -197,6 +239,20 @@ void f() { await _expectHints(content, expected); } + Future test_forElement_wildcards() async { + var content = ''' +void f() { + [for (var _ in [1, 2]) 0]; +} +'''; + var expected = ''' +void f() { + (Type:)[for (var (Type:int) _ in (Type:)[1, 2]) 0]; +} +'''; + await _expectHints(content, expected); + } + Future test_forInLoop() async { var content = ''' void f() { @@ -211,6 +267,20 @@ void f() { await _expectHints(content, expected); } + Future test_forInLoop_wildcards() async { + var content = ''' +void f() { + for (var _ in [1, 2]) {} +} +'''; + var expected = ''' +void f() { + for (var (Type:int) _ in (Type:)[1, 2]) {} +} +'''; + await _expectHints(content, expected); + } + Future test_forLoop() async { var content = ''' void f() { @@ -225,6 +295,20 @@ void f() { await _expectHints(content, expected); } + Future test_forLoop_wildcards() async { + var content = ''' +void f() { + for (var _ = 0; ; ) {} +} +'''; + var expected = ''' +void f() { + for (var (Type:int) _ = 0; ; ) {} +} +'''; + await _expectHints(content, expected); + } + Future test_function_typeArguments() async { var content = ''' void f1(T1 a, T2 b) {} @@ -243,6 +327,24 @@ void f() { await _expectHints(content, expected); } + Future test_function_typeArguments_wildcards() async { + var content = ''' +void f1<_, _>(Object _, Object _) {} + +void f() { + f1('', 1); +} +'''; + var expected = ''' +void f1<_, _>(Object _, Object _) {} + +void f() { + f1(Type:)((Parameter:_:) '', (Parameter:_:) 1); +} +'''; + await _expectHints(content, expected); + } + Future test_getter() async { var content = ''' get f => 1; @@ -253,6 +355,16 @@ get f => 1; await _expectHints(content, expected); } + Future test_getter_wildcard() async { + var content = ''' +get _ => 1; +'''; + var expected = ''' +(Type:dynamic) get _ => 1; +'''; + await _expectHints(content, expected); + } + Future test_leadingAnnotation() async { var content = ''' @deprecated @@ -459,6 +571,28 @@ class B extends A { await _expectHints(content, expected); } + Future test_method_parameters_wildcards() async { + var content = ''' +class A { + void m1(int _, [String? _]) {} +} +class B extends A { + @override + void m1(_, [_]) {} +} +'''; + var expected = ''' +class A { + void m1(int _, [String? _]) {} +} +class B extends A { + @override + void m1((Type:int) _, [(Type:String?) _]) {} +} +'''; + await _expectHints(content, expected); + } + Future test_method_returnType() async { var content = ''' class A { @@ -498,6 +632,30 @@ void f() { await _expectHints(content, expected); } + Future test_method_typeArguments_wildcards() async { + var content = ''' +class A { + void m1<_, _>(String _, int _) {} +} + +void f() { + final a = A(); + a.m1('', 1); +} +'''; + var expected = ''' +class A { + void m1<_, _>(String _, int _) {} +} + +void f() { + final (Type:A) a = A(); + a.m1(Type:)((Parameter:_:) '', (Parameter:_:) 1); +} +'''; + await _expectHints(content, expected); + } + Future test_patterns_destructure() async { var content = ''' void f() { diff --git a/pkg/analysis_server/test/lsp/server_abstract.dart b/pkg/analysis_server/test/lsp/server_abstract.dart index 0144026a5e2d..195284a403eb 100644 --- a/pkg/analysis_server/test/lsp/server_abstract.dart +++ b/pkg/analysis_server/test/lsp/server_abstract.dart @@ -310,6 +310,7 @@ abstract class AbstractLspAnalysisServerTest analyzer: enable-experiment: - macros + - wildcard-variables '''); analysisOptionsUri = pathContext.toUri(analysisOptionsPath);