Skip to content

Commit c5dd320

Browse files
osa1Commit Queue
authored and
Commit Queue
committed
[dart2wasm] Add inline pragmas to JS typed array classes
Typed array accessors are quite small, and inlining them often leads to avoiding boxing the return values in `operator []` and the set value in `operator []=`. (Native typed array classes already have these inline pragmas) Change-Id: Ib15dda93687b5becd1dfa92d34d9d28a75df2e07 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329100 Commit-Queue: Ömer Ağacan <[email protected]> Reviewed-by: Aske Simon Christensen <[email protected]>
1 parent f8086ed commit c5dd320

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

sdk/lib/_internal/wasm/lib/js_typed_array.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ final class JSIntArrayImpl extends JSArrayBufferViewImpl
230230
JSIntArrayImpl(super._ref);
231231

232232
@override
233+
@pragma("wasm:prefer-inline")
233234
int operator [](int index) {
234235
IndexError.check(index, length);
235236
return js
@@ -238,6 +239,7 @@ final class JSIntArrayImpl extends JSArrayBufferViewImpl
238239
}
239240

240241
@override
242+
@pragma("wasm:prefer-inline")
241243
void operator []=(int index, int value) {
242244
IndexError.check(index, length);
243245
js.JS<void>('(o, i, v) => o[i] = v', toExternRef, index.toDouble(),
@@ -501,6 +503,7 @@ final class JSInt32x4ArrayImpl
501503
int get length => _storage.length ~/ 4;
502504

503505
@override
506+
@pragma("wasm:prefer-inline")
504507
Int32x4 operator [](int index) {
505508
IndexError.check(index, length);
506509
int _x = _storage[(index * 4) + 0];
@@ -511,6 +514,7 @@ final class JSInt32x4ArrayImpl
511514
}
512515

513516
@override
517+
@pragma("wasm:prefer-inline")
514518
void operator []=(int index, Int32x4 value) {
515519
IndexError.check(index, length);
516520
_storage[(index * 4) + 0] = value.x;
@@ -531,12 +535,14 @@ final class JSBigIntArrayImpl extends JSIntArrayImpl {
531535
JSBigIntArrayImpl(super._ref);
532536

533537
@override
538+
@pragma("wasm:prefer-inline")
534539
int operator [](int index) {
535540
IndexError.check(index, length);
536541
return js.JS<int>('(o, i) => o[i]', toExternRef, index.toDouble()).toInt();
537542
}
538543

539544
@override
545+
@pragma("wasm:prefer-inline")
540546
void operator []=(int index, int value) {
541547
IndexError.check(index, length);
542548
js.JS<void>('(o, i, v) => o[i] = v', toExternRef, index.toDouble(), value);
@@ -603,12 +609,14 @@ final class JSFloatArrayImpl extends JSArrayBufferViewImpl
603609
JSFloatArrayImpl(super._ref);
604610

605611
@override
612+
@pragma("wasm:prefer-inline")
606613
double operator [](int index) {
607614
IndexError.check(index, length);
608615
return js.JS<double>('(o, i) => o[i]', toExternRef, index.toDouble());
609616
}
610617

611618
@override
619+
@pragma("wasm:prefer-inline")
612620
void operator []=(int index, double value) {
613621
IndexError.check(index, length);
614622
js.JS<void>('(o, i, v) => o[i] = v', toExternRef, index.toDouble(),
@@ -732,6 +740,7 @@ final class JSFloat32x4ArrayImpl
732740
int get length => _storage.length ~/ 4;
733741

734742
@override
743+
@pragma("wasm:prefer-inline")
735744
Float32x4 operator [](int index) {
736745
IndexError.check(index, length);
737746
double _x = _storage[(index * 4) + 0];
@@ -742,6 +751,7 @@ final class JSFloat32x4ArrayImpl
742751
}
743752

744753
@override
754+
@pragma("wasm:prefer-inline")
745755
void operator []=(int index, Float32x4 value) {
746756
IndexError.check(index, length);
747757
_storage[(index * 4) + 0] = value.x;
@@ -782,6 +792,7 @@ final class JSFloat64x2ArrayImpl
782792
int get length => _storage.length ~/ 2;
783793

784794
@override
795+
@pragma("wasm:prefer-inline")
785796
Float64x2 operator [](int index) {
786797
IndexError.check(index, length);
787798
double _x = _storage[(index * 2) + 0];
@@ -790,6 +801,7 @@ final class JSFloat64x2ArrayImpl
790801
}
791802

792803
@override
804+
@pragma("wasm:prefer-inline")
793805
void operator []=(int index, Float64x2 value) {
794806
IndexError.check(index, length);
795807
_storage[(index * 2) + 0] = value.x;

0 commit comments

Comments
 (0)