Skip to content

Commit 0947f85

Browse files
fishythefishCommit Queue
authored andcommitted
[benchmarks] Migrate off package:js
This also allows the BigIntParsePrint benchmark to actually run on dart2wasm. Bug: #61550 Change-Id: I6a6a6964d95195e8e06fcecbcad776045dddc733 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/453682 Reviewed-by: Srujan Gaddam <[email protected]>
1 parent 6536c9d commit 0947f85

File tree

4 files changed

+41
-39
lines changed

4 files changed

+41
-39
lines changed

benchmarks/BigIntParsePrint/dart/BigIntParsePrint.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'package:benchmark_harness/benchmark_harness.dart';
1010
import 'package:fixnum/fixnum.dart';
1111

1212
import 'native_version_dummy.dart'
13-
if (dart.library.js) 'native_version_javascript.dart';
13+
if (dart.library.js_interop) 'native_version_javascript.dart';
1414

1515
// Benchmark BigInt and Int64 formatting and parsing.
1616

benchmarks/BigIntParsePrint/dart/native_version.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
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-
abstract class NativeBigIntMethods {
5+
abstract class NativeBigIntMethods<T> {
66
bool get enabled;
77

8-
Object parse(String string);
9-
String toStringMethod(Object value);
8+
T parse(String string);
9+
String toStringMethod(T value);
1010

11-
Object fromInt(int i);
11+
T fromInt(int i);
1212

13-
Object get one;
14-
Object get eight;
13+
T get one;
14+
T get eight;
1515

16-
int bitLength(Object value);
17-
bool isEven(Object value);
16+
int bitLength(T value);
17+
bool isEven(T value);
1818

19-
Object add(Object left, Object right);
20-
Object shiftLeft(Object value, Object count);
21-
Object shiftRight(Object value, Object count);
22-
Object subtract(Object left, Object right);
19+
T add(T left, T right);
20+
T shiftLeft(T value, T count);
21+
T shiftRight(T value, T count);
22+
T subtract(T left, T right);
2323
}

benchmarks/BigIntParsePrint/dart/native_version_dummy.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'native_version.dart';
66

77
const NativeBigIntMethods nativeBigInt = _DummyMethods();
88

9-
class _DummyMethods implements NativeBigIntMethods {
9+
class _DummyMethods implements NativeBigIntMethods<Object> {
1010
const _DummyMethods();
1111

1212
@override

benchmarks/BigIntParsePrint/dart/native_version_javascript.dart

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,45 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
@JS()
6-
library native_version_javascript;
6+
library;
7+
8+
import 'dart:js_interop';
79

8-
// ignore: deprecated_member_use
9-
import 'package:js/js.dart';
1010
import 'native_version.dart';
1111

1212
const NativeBigIntMethods nativeBigInt = _Methods();
1313

1414
@JS('eval')
15-
external Object _eval(String s);
15+
external JSAny? _eval(String s);
1616

1717
@JS('bigint_parse')
18-
external Object _parse(String s);
18+
external JSBigInt _parse(String s);
1919

2020
@JS('bigint_toString')
21-
external String _toStringMethod(Object o);
21+
external String _toStringMethod(JSBigInt o);
2222

2323
@JS('bigint_bitLength')
24-
external int _bitLength(Object o);
24+
external int _bitLength(JSBigInt o);
2525

2626
@JS('bigint_isEven')
27-
external bool _isEven(Object o);
27+
external bool _isEven(JSBigInt o);
2828

2929
@JS('bigint_add')
30-
external Object _add(Object left, Object right);
30+
external JSBigInt _add(JSBigInt left, JSBigInt right);
3131

3232
@JS('bigint_shiftLeft')
33-
external Object _shiftLeft(Object o, Object i);
33+
external JSBigInt _shiftLeft(JSBigInt o, JSBigInt i);
3434

3535
@JS('bigint_shiftRight')
36-
external Object _shiftRight(Object o, Object i);
36+
external JSBigInt _shiftRight(JSBigInt o, JSBigInt i);
3737

3838
@JS('bigint_subtract')
39-
external Object _subtract(Object left, Object right);
39+
external JSBigInt _subtract(JSBigInt left, JSBigInt right);
4040

4141
@JS('bigint_fromInt')
42-
external Object _fromInt(int i);
42+
external JSBigInt _fromInt(int i);
4343

44-
class _Methods implements NativeBigIntMethods {
44+
class _Methods implements NativeBigIntMethods<JSBigInt> {
4545
static bool _initialized = false;
4646
static bool _enabled = false;
4747

@@ -71,37 +71,39 @@ class _Methods implements NativeBigIntMethods {
7171
}
7272

7373
@override
74-
Object parse(String string) => _parse(string);
74+
JSBigInt parse(String string) => _parse(string);
7575

7676
@override
77-
String toStringMethod(Object value) => _toStringMethod(value);
77+
String toStringMethod(JSBigInt value) => _toStringMethod(value);
7878

7979
@override
80-
Object fromInt(int i) => _fromInt(i);
80+
JSBigInt fromInt(int i) => _fromInt(i);
8181

8282
@override
83-
Object get one => _one;
83+
JSBigInt get one => _one;
8484

8585
@override
86-
Object get eight => _eight;
86+
JSBigInt get eight => _eight;
8787

8888
@override
89-
int bitLength(Object value) => _bitLength(value);
89+
int bitLength(JSBigInt value) => _bitLength(value);
9090

9191
@override
92-
bool isEven(Object value) => _isEven(value);
92+
bool isEven(JSBigInt value) => _isEven(value);
9393

9494
@override
95-
Object add(Object left, Object right) => _add(left, right);
95+
JSBigInt add(JSBigInt left, JSBigInt right) => _add(left, right);
9696

9797
@override
98-
Object shiftLeft(Object value, Object count) => _shiftLeft(value, count);
98+
JSBigInt shiftLeft(JSBigInt value, JSBigInt count) =>
99+
_shiftLeft(value, count);
99100

100101
@override
101-
Object shiftRight(Object value, Object count) => _shiftRight(value, count);
102+
JSBigInt shiftRight(JSBigInt value, JSBigInt count) =>
103+
_shiftRight(value, count);
102104

103105
@override
104-
Object subtract(Object left, Object right) => _subtract(left, right);
106+
JSBigInt subtract(JSBigInt left, JSBigInt right) => _subtract(left, right);
105107
}
106108

107109
void _setup() {

0 commit comments

Comments
 (0)