-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[vm] Add support for real unboxed floating point fields in AOT
Non-nullable floating point fields (double, Float32x4, Float64x2) are fully unboxed in their classes. A bitmap for each class was added to the shared class table in order to keep track of the pointers of the classes. Since all classes in Flutter Gallery have less than 64 fields, the bitmap is represented by a 64 bit integer and fields whose offset is more than 64 words are not unboxed. The instance sizes and field offsets might change between target and host in cross-compilation, since the number of words used to store unboxed fields may differ. dart-aot Xeon SplayLatency -4.62% SplayHarderLatency -4.17% NavierStokes -2.20% Tracer 8.72% ParticleSystemPaint 2.90% NBodySIMD 8.35% NBody 25.59% With hack TFA to make doubles in Rect/Offset/Size classes in flutter non-nullable: flutter arm-v8: gallery total size: -1% matrix_utils_transform_rect_perspective -16.70% (less is better) matrix_utils_transform_rect_affine -31.82% (less is better) matrix_utils_transform_point_perspective -24.90% (less is better) matrix_utils_transform_point_affine) -27.26% (less is better) rrect_contains_bench -4.719% (less is better) Change-Id: I9ae09c9c3167d99f9efd071a92937aa51093fd1d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131824 Commit-Queue: Victor Agnez Lima <victoragnez@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Samir Jindel <sjindel@google.com>
- Loading branch information
1 parent
7248e98
commit 9eb531b
Showing
46 changed files
with
3,632 additions
and
535 deletions.
There are no files selected for viewing
151 changes: 151 additions & 0 deletions
151
runtime/observatory/tests/service/dominator_tree_vm_with_double_field_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
// 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. | ||
// VMOptions= | ||
// VMOptions=--use_compactor | ||
// VMOptions=--use_compactor --force_evacuation | ||
|
||
import 'dart:typed_data'; | ||
|
||
import 'package:observatory/service_io.dart'; | ||
import 'package:unittest/unittest.dart'; | ||
import 'test_helper.dart'; | ||
|
||
double getDoubleWithHeapObjectTag() { | ||
final bd = ByteData(8); | ||
bd.setUint64(0, 0x8000000000000001, Endian.host); | ||
final double v = bd.getFloat64(0, Endian.host); | ||
return v; | ||
} | ||
|
||
// small example from [Lenguaer & Tarjan 1979] | ||
class R { | ||
final double fld = getDoubleWithHeapObjectTag(); | ||
var x; | ||
var y; | ||
var z; | ||
} | ||
|
||
class A { | ||
var x; | ||
} | ||
|
||
class B { | ||
var x; | ||
var y; | ||
var z; | ||
} | ||
|
||
class C { | ||
var x; | ||
var y; | ||
} | ||
|
||
class D { | ||
var x; | ||
} | ||
|
||
class E { | ||
var x; | ||
} | ||
|
||
class F { | ||
var x; | ||
} | ||
|
||
class G { | ||
var x; | ||
var y; | ||
} | ||
|
||
class H { | ||
var x; | ||
var y; | ||
} | ||
|
||
class I { | ||
var x; | ||
} | ||
|
||
class J { | ||
var x; | ||
} | ||
|
||
class K { | ||
var x; | ||
var y; | ||
} | ||
|
||
class L { | ||
var x; | ||
} | ||
|
||
var r; | ||
|
||
buildGraph() { | ||
r = new R(); | ||
var a = new A(); | ||
var b = new B(); | ||
var c = new C(); | ||
var d = new D(); | ||
var e = new E(); | ||
var f = new F(); | ||
var g = new G(); | ||
var h = new H(); | ||
var i = new I(); | ||
var j = new J(); | ||
var k = new K(); | ||
var l = new L(); | ||
|
||
r.x = a; | ||
r.y = b; | ||
r.z = c; | ||
a.x = d; | ||
b.x = a; | ||
b.y = d; | ||
b.z = e; | ||
c.x = f; | ||
c.y = g; | ||
d.x = l; | ||
e.x = h; | ||
f.x = i; | ||
g.x = i; | ||
g.y = j; | ||
h.x = e; | ||
h.y = k; | ||
i.x = k; | ||
j.x = i; | ||
k.x = i; | ||
k.y = r; | ||
l.x = h; | ||
|
||
expect(r.fld, getDoubleWithHeapObjectTag()); | ||
} | ||
|
||
var tests = <IsolateTest>[ | ||
(Isolate isolate) async { | ||
final graph = await isolate.fetchHeapSnapshot().done; | ||
|
||
node(String className) { | ||
return graph.objects.singleWhere((v) => v.klass.name == className); | ||
} | ||
|
||
expect(node('I').parent, equals(node('R'))); | ||
expect(node('K').parent, equals(node('R'))); | ||
expect(node('C').parent, equals(node('R'))); | ||
expect(node('H').parent, equals(node('R'))); | ||
expect(node('E').parent, equals(node('R'))); | ||
expect(node('A').parent, equals(node('R'))); | ||
expect(node('D').parent, equals(node('R'))); | ||
expect(node('B').parent, equals(node('R'))); | ||
|
||
expect(node('F').parent, equals(node('C'))); | ||
expect(node('G').parent, equals(node('C'))); | ||
expect(node('J').parent, equals(node('G'))); | ||
expect(node('L').parent, equals(node('D'))); | ||
|
||
expect(node('R'), isNotNull); // The field. | ||
}, | ||
]; | ||
|
||
main(args) => runIsolateTests(args, tests, testeeBefore: buildGraph); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// 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. | ||
|
||
import 'dart:typed_data'; | ||
import 'dart:async'; | ||
import 'dart:isolate'; | ||
|
||
import "package:expect/expect.dart"; | ||
|
||
double getDoubleWithHeapObjectTag() { | ||
final bd = ByteData(8); | ||
bd.setUint64(0, 0x8000000000000001, Endian.host); | ||
final double v = bd.getFloat64(0, Endian.host); | ||
return v; | ||
} | ||
|
||
class Foo { | ||
final String clazz = "foo"; | ||
final double x = getDoubleWithHeapObjectTag(); | ||
} | ||
|
||
// Here we ensure to have a GC pointer and a non-GC pointer field, and then a | ||
// type argument vector, so the offset in number of words for the type arguments | ||
// will be different between host and target when compiling from 64-bit to | ||
// 32-bit architectures. | ||
class Bar<T> extends Foo { | ||
final String clazz = "bar"; | ||
final double y = getDoubleWithHeapObjectTag(); | ||
final T value; | ||
Bar(T val) : value = val; | ||
} | ||
|
||
main() async { | ||
final receivePort = new ReceivePort(); | ||
receivePort.sendPort.send(Foo()); | ||
receivePort.sendPort.send(Bar<String>("StringBar")); | ||
receivePort.sendPort.send(Bar<double>(4.2)); | ||
final it = StreamIterator(receivePort); | ||
|
||
Expect.isTrue(await it.moveNext()); | ||
final foo = it.current as Foo; | ||
|
||
Expect.isTrue(await it.moveNext()); | ||
final string_bar = it.current as Bar<String>; | ||
|
||
Expect.isTrue(await it.moveNext()); | ||
final double_bar = it.current as Bar<double>; | ||
|
||
Expect.equals(string_bar.value, "StringBar"); | ||
Expect.equals(string_bar.clazz, "bar"); | ||
Expect.equals(string_bar.y, getDoubleWithHeapObjectTag()); | ||
Expect.equals(string_bar.x, getDoubleWithHeapObjectTag()); | ||
Expect.equals(double_bar.value, 4.2); | ||
Expect.equals(foo.clazz, "foo"); | ||
Expect.equals(foo.x, getDoubleWithHeapObjectTag()); | ||
|
||
await it.cancel(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.