Skip to content

Commit c91fd18

Browse files
osa1Commit Queue
authored andcommitted
[dart2wasm] Use native int parsing in JSCM
JSCM (JS compatibility mode) started as an experiment to have a compilation mode that is semantically as close to dart2js as possible, to make migration from dart2js easy. However we've since decided to follow VM semantics in dart2wasm, and JSCM now mainly exists to test JS-backed typed data and string classes. The default mode allocates Wasm-array-backed strings and typed data classes when they are allocated in Dart, so the JS-backed classes are are only tested in JS interop tests in the default mode. In JSCM we only have JS-backed classes so all tests allocate JS-backed typed data and string classes. Integer parsing in JSCM is currently just a `parseInt` JS call, which is not compatible with the VM or dart2js semantics. Since which one to follow does not make any difference in terms of test coverage of dart2wasm standard library, do the simple thing and reuse the default mode's `int` parser. Fixes these tests in JSCM: - co19/LanguageFeatures/Digit-separators/parse_A01_t01 - co19/LanguageFeatures/Digit-separators/parse_A01_t02 - co19/LanguageFeatures/Digit-separators/parse_A01_t03 - co19/LanguageFeatures/Digit-separators/parse_A03_t01 - co19/LanguageFeatures/Digit-separators/parse_A03_t02 - co19/LanguageFeatures/Digit-separators/parse_A03_t03 - co19/LibTest/core/Uri/parseIPv6Address_A02_t01 - co19/LibTest/core/int/parse_A01_t02 - co19/LibTest/core/int/parse_A02_t01 - co19/LibTest/core/int/parse_A03_t02 - co19/LibTest/core/int/parse_A04_t02 - corelib/int_parse_radix_int64_test/02 - corelib/int_parse_radix_test/02 - corelib/int_parse_radix_test/none - corelib/int_parse_with_limited_ints_test - corelib/int_try_parse_test - corelib/integer_parsed_arith_vm_test - corelib/integer_parsed_div_rem_vm_test/01 - corelib/integer_parsed_div_rem_vm_test/none - corelib/integer_parsed_mul_div_vm_test - corelib/num_parse_test/01 - corelib/num_parse_test/none - corelib/num_try_parse_test - corelib/uri_ipv4_test - corelib/uri_test - language/operator/arithmetic_int64_test - language/operator/arithmetic_test - lib/async/stream_controller_test - lib/convert/json_chunk_test - lib/convert/json_test - lib/convert/json_utf8_chunk_test - lib/math/math2_test - lib/math/math_test Fixes #56849. Change-Id: Iea72eeb39a80e00c023b780c185b4fabe549c568 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390860 Reviewed-by: Slava Egorov <[email protected]> Commit-Queue: Ömer Ağacan <[email protected]>
1 parent 9046485 commit c91fd18

File tree

4 files changed

+10
-39
lines changed

4 files changed

+10
-39
lines changed

sdk/lib/_internal/wasm_js_compatibility/lib/int_patch.dart

Lines changed: 0 additions & 36 deletions
This file was deleted.

sdk/lib/_internal/wasm_js_compatibility/lib/string_patch.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import 'dart:_internal' show EfficientLengthIterable, patch;
5+
import 'dart:_internal' show EfficientLengthIterable, patch, unsafeCast;
66
import 'dart:_js_helper' as js;
77
import 'dart:_js_types';
88
import 'dart:_string';
@@ -100,3 +100,10 @@ class String {
100100
WasmI32.fromInt(end - index)));
101101
}
102102
}
103+
104+
extension _StringExt on String {
105+
int firstNonWhitespace() =>
106+
unsafeCast<JSStringImpl>(this).firstNonWhitespace();
107+
108+
int lastNonWhitespace() => unsafeCast<JSStringImpl>(this).lastNonWhitespace();
109+
}

sdk/lib/libraries.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@
207207
"_internal/wasm/lib/core_patch.dart",
208208
"_internal/wasm/lib/date_patch_patch.dart",
209209
"_internal/wasm/lib/int_common_patch.dart",
210+
"_internal/wasm/lib/int_patch.dart",
210211
"_internal/wasm/lib/sync_star_patch.dart",
211212
"_internal/wasm/lib/weak_patch.dart",
212-
"_internal/wasm_js_compatibility/lib/int_patch.dart",
213213
"_internal/wasm_js_compatibility/lib/string_buffer_patch.dart",
214214
"_internal/wasm_js_compatibility/lib/string_patch.dart"
215215
]

sdk/lib/libraries.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ wasm_js_compatibility:
182182
- _internal/wasm/lib/core_patch.dart
183183
- _internal/wasm/lib/date_patch_patch.dart
184184
- _internal/wasm/lib/int_common_patch.dart
185+
- _internal/wasm/lib/int_patch.dart
185186
- _internal/wasm/lib/sync_star_patch.dart
186187
- _internal/wasm/lib/weak_patch.dart
187-
- _internal/wasm_js_compatibility/lib/int_patch.dart
188188
- _internal/wasm_js_compatibility/lib/string_buffer_patch.dart
189189
- _internal/wasm_js_compatibility/lib/string_patch.dart
190190
typed_data:

0 commit comments

Comments
 (0)