Files
sdk/runtime/tests/vm/dart/unboxed_param_test.dart
T
Victor Lima b951498903 [vm/aot] Allow static methods to have unboxed args and return
Static methods and constructors may receive unboxed parameters.
This change adds a bitmap to the RawFunction object indicating
which parameters are unboxed and their types. Also, the stack frame
bitmap was updated to include new bits for those parameters.

The ArgumentsDescriptor object was updated to store not only the number
of arguments, but also their size, since 32-bit platforms would use two
words for each int64 and double value.

In addition, static methods that return non-nullable integers
and doubles may return these values unboxed.

Dart AOT x64:

TypedData.Uint8ClampedListViewVarBench  +11.73%
DeltaBlue                               +9.32%
Meteor (Intel Xeon)                     +4.64%

Flutter release android-armv8:

velocity_tracker_bench                  -2.32% (less is better)

flutter_gallery_readonlydata_size       +0.18%
flutter_gallery_total_size              +0.13%
flutter_gallery_instructions_size       +0.12%

Issue https://github.com/dart-lang/sdk/issues/33549

Change-Id: I97e310f8f30213920af2333fbdedf193d03db5c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135313
Commit-Queue: Victor Agnez Lima <victoragnez@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-03-05 15:17:04 +00:00

45 lines
1.1 KiB
Dart

// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
//
// SharedObjects=ffi_test_functions
import 'package:expect/expect.dart';
import 'dylib_utils.dart';
import 'unboxed_parameter_helper.dart';
class Foo {
int val;
Foo(this.val);
}
var globalFoo;
final dbl2 = getDoubleWithHeapObjectTag();
@pragma('vm:never-inline')
double bar(int i, double k, Foo foo, double j, [int optional = 1]) {
triggerGc();
globalFoo.val = 0;
return (i + 2 + j.toInt() - j.toInt() + globalFoo.val + optional).toDouble();
}
@pragma('vm:never-inline')
createFoo() {
globalFoo = Foo(1);
}
final bool kTrue = int.parse('1') == 1;
main() {
createFoo();
final dbl = getDoubleWithHeapObjectTag();
Expect.equals(4.0,
bar(kTrue ? 1 : 2, kTrue ? 2 * dbl : 0.0, globalFoo, kTrue ? dbl : 1.0));
Expect.equals(
3.0,
bar(kTrue ? 1 : 2, kTrue ? 2 * dbl : 0.0, globalFoo, kTrue ? dbl : 1.0,
0));
}