OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 // VMOptions=--deoptimization_counter_threshold=1000 | 4 // VMOptions=--deoptimization_counter_threshold=1000 --optimization-counter-thre
shold=10 |
5 | 5 |
6 // Library tag to be able to run in html test framework. | 6 // Library tag to be able to run in html test framework. |
7 library float32x4_unbox_regress_test; | 7 library float32x4_unbox_regress_test; |
8 | 8 |
9 import 'package:expect/expect.dart'; | 9 import 'package:expect/expect.dart'; |
10 import 'dart:typed_data'; | 10 import 'dart:typed_data'; |
11 | 11 |
12 testListStore(array, index, value) { | 12 testListStore(array, index, value) { |
13 array[index] = value; | 13 array[index] = value; |
14 } | 14 } |
15 | 15 |
16 void testListStoreDeopt() { | 16 void testListStoreDeopt() { |
17 var list; | 17 var list; |
18 var value = new Float32x4(1.0, 2.0, 3.0, 4.0); | 18 var value = new Float32x4(1.0, 2.0, 3.0, 4.0); |
19 var smi = 12; | 19 var smi = 12; |
20 list = new Float32x4List(8); | 20 list = new Float32x4List(8); |
21 for (int i = 0; i < 3000; i++) { | 21 for (int i = 0; i < 20; i++) { |
22 testListStore(list, 0, value); | 22 testListStore(list, 0, value); |
23 } | 23 } |
24 | 24 |
25 try { | 25 try { |
26 // Without a proper check for SMI in the Float32x4 unbox instruction | 26 // Without a proper check for SMI in the Float32x4 unbox instruction |
27 // this might trigger a crash. | 27 // this might trigger a crash. |
28 testListStore(list, 0, smi); | 28 testListStore(list, 0, smi); |
29 } catch (_) { } | 29 } catch (_) { } |
30 } | 30 } |
31 | 31 |
32 testAdd(a, b) { | 32 testAdd(a, b) { |
33 var c = a + b; | 33 var c = a + b; |
34 Expect.equals(3.0, c.x); | 34 Expect.equals(3.0, c.x); |
35 Expect.equals(5.0, c.y); | 35 Expect.equals(5.0, c.y); |
36 Expect.equals(7.0, c.z); | 36 Expect.equals(7.0, c.z); |
37 Expect.equals(9.0, c.w); | 37 Expect.equals(9.0, c.w); |
38 } | 38 } |
39 | 39 |
40 void testAddDeopt() { | 40 void testAddDeopt() { |
41 var a = new Float32x4(1.0, 2.0, 3.0, 4.0); | 41 var a = new Float32x4(1.0, 2.0, 3.0, 4.0); |
42 var b = new Float32x4(2.0, 3.0, 4.0, 5.0); | 42 var b = new Float32x4(2.0, 3.0, 4.0, 5.0); |
43 var smi = 12; | 43 var smi = 12; |
44 for (int i = 0; i < 3000; i++) { | 44 for (int i = 0; i < 20; i++) { |
45 testAdd(a, b); | 45 testAdd(a, b); |
46 } | 46 } |
47 | 47 |
48 try { | 48 try { |
49 testAdd(a, smi); | 49 testAdd(a, smi); |
50 } catch (_) {} | 50 } catch (_) {} |
51 } | 51 } |
52 | 52 |
53 | 53 |
54 testGet(a) { | 54 testGet(a) { |
55 var c = a.x + a.y + a.z + a.w; | 55 var c = a.x + a.y + a.z + a.w; |
56 Expect.equals(10.0, c); | 56 Expect.equals(10.0, c); |
57 } | 57 } |
58 | 58 |
59 void testGetDeopt() { | 59 void testGetDeopt() { |
60 var a = new Float32x4(1.0, 2.0, 3.0, 4.0); | 60 var a = new Float32x4(1.0, 2.0, 3.0, 4.0); |
61 var smi = 12; | 61 var smi = 12; |
62 for (int i = 0; i < 3000; i++) { | 62 for (int i = 0; i < 20; i++) { |
63 testGet(a); | 63 testGet(a); |
64 } | 64 } |
65 | 65 |
66 try { | 66 try { |
67 testGet(12); | 67 testGet(12); |
68 } catch (_) { | 68 } catch (_) { |
69 } | 69 } |
70 | 70 |
71 for (int i = 0; i < 3000; i++) { | 71 for (int i = 0; i < 20; i++) { |
72 testGet(a); | 72 testGet(a); |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 void testComparison(a, b) { | 76 void testComparison(a, b) { |
77 Uint32x4 r = a.equal(b); | 77 Uint32x4 r = a.equal(b); |
78 Expect.equals(true, r.flagX); | 78 Expect.equals(true, r.flagX); |
79 Expect.equals(false, r.flagY); | 79 Expect.equals(false, r.flagY); |
80 Expect.equals(false, r.flagZ); | 80 Expect.equals(false, r.flagZ); |
81 Expect.equals(true, r.flagW); | 81 Expect.equals(true, r.flagW); |
82 } | 82 } |
83 | 83 |
84 void testComparisonDeopt() { | 84 void testComparisonDeopt() { |
85 var a = new Float32x4(1.0, 2.0, 3.0, 4.0); | 85 var a = new Float32x4(1.0, 2.0, 3.0, 4.0); |
86 var b = new Float32x4(1.0, 2.1, 3.1, 4.0); | 86 var b = new Float32x4(1.0, 2.1, 3.1, 4.0); |
87 var smi = 12; | 87 var smi = 12; |
88 | 88 |
89 for (int i = 0; i < 2000; i++) { | 89 for (int i = 0; i < 20; i++) { |
90 testComparison(a, b); | 90 testComparison(a, b); |
91 } | 91 } |
92 | 92 |
93 try { | 93 try { |
94 testComparison(a, smi); | 94 testComparison(a, smi); |
95 } catch (_) { | 95 } catch (_) { |
96 } | 96 } |
97 | 97 |
98 for (int i = 0; i < 2000; i++) { | 98 for (int i = 0; i < 20; i++) { |
99 testComparison(a, b); | 99 testComparison(a, b); |
100 } | 100 } |
101 | 101 |
102 try { | 102 try { |
103 testComparison(smi, a); | 103 testComparison(smi, a); |
104 } catch (_) { | 104 } catch (_) { |
105 } | 105 } |
106 | 106 |
107 for (int i = 0; i < 2000; i++) { | 107 for (int i = 0; i < 20; i++) { |
108 testComparison(a, b); | 108 testComparison(a, b); |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
112 main() { | 112 main() { |
113 testListStoreDeopt(); | 113 testListStoreDeopt(); |
114 testAddDeopt(); | 114 testAddDeopt(); |
115 testGetDeopt(); | 115 testGetDeopt(); |
116 testComparisonDeopt(); | 116 testComparisonDeopt(); |
117 } | 117 } |
OLD | NEW |