| 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_list_test; | 7 library float32x4_list_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 testLoadStore(array) { | 12 testLoadStore(array) { |
| 13 Expect.equals(8, array.length); | 13 Expect.equals(8, array.length); |
| 14 Expect.isTrue(array is List<Float32x4>); | 14 Expect.isTrue(array is List<Float32x4>); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 33 array[index] = value; | 33 array[index] = value; |
| 34 Expect.equals(value.x, array[index].x); | 34 Expect.equals(value.x, array[index].x); |
| 35 Expect.equals(value.y, array[index].y); | 35 Expect.equals(value.y, array[index].y); |
| 36 Expect.equals(value.z, array[index].z); | 36 Expect.equals(value.z, array[index].z); |
| 37 Expect.equals(value.w, array[index].w); | 37 Expect.equals(value.w, array[index].w); |
| 38 } | 38 } |
| 39 | 39 |
| 40 testLoadStoreDeoptDriver() { | 40 testLoadStoreDeoptDriver() { |
| 41 Float32x4List list = new Float32x4List(4); | 41 Float32x4List list = new Float32x4List(4); |
| 42 Float32x4 value = new Float32x4(1.0, 2.0, 3.0, 4.0); | 42 Float32x4 value = new Float32x4(1.0, 2.0, 3.0, 4.0); |
| 43 for (int i = 0; i < 3000; i++) { | 43 for (int i = 0; i < 20; i++) { |
| 44 testLoadStoreDeopt(list, 0, value); | 44 testLoadStoreDeopt(list, 0, value); |
| 45 } | 45 } |
| 46 try { | 46 try { |
| 47 // Invalid index. | 47 // Invalid index. |
| 48 testLoadStoreDeopt(list, 5, value); | 48 testLoadStoreDeopt(list, 5, value); |
| 49 } catch (_) {} | 49 } catch (_) {} |
| 50 for (int i = 0; i < 3000; i++) { | 50 for (int i = 0; i < 20; i++) { |
| 51 testLoadStoreDeopt(list, 0, value); | 51 testLoadStoreDeopt(list, 0, value); |
| 52 } | 52 } |
| 53 try { | 53 try { |
| 54 // null list. | 54 // null list. |
| 55 testLoadStoreDeopt(null, 0, value); | 55 testLoadStoreDeopt(null, 0, value); |
| 56 } catch (_) {} | 56 } catch (_) {} |
| 57 for (int i = 0; i < 3000; i++) { | 57 for (int i = 0; i < 20; i++) { |
| 58 testLoadStoreDeopt(list, 0, value); | 58 testLoadStoreDeopt(list, 0, value); |
| 59 } | 59 } |
| 60 try { | 60 try { |
| 61 // null value. | 61 // null value. |
| 62 testLoadStoreDeopt(list, 0, null); | 62 testLoadStoreDeopt(list, 0, null); |
| 63 } catch (_) {} | 63 } catch (_) {} |
| 64 for (int i = 0; i < 3000; i++) { | 64 for (int i = 0; i < 20; i++) { |
| 65 testLoadStoreDeopt(list, 0, value); | 65 testLoadStoreDeopt(list, 0, value); |
| 66 } | 66 } |
| 67 try { | 67 try { |
| 68 // non-smi index. | 68 // non-smi index. |
| 69 testLoadStoreDeopt(list, 3.14159, value); | 69 testLoadStoreDeopt(list, 3.14159, value); |
| 70 } catch (_) {} | 70 } catch (_) {} |
| 71 for (int i = 0; i < 3000; i++) { | 71 for (int i = 0; i < 20; i++) { |
| 72 testLoadStoreDeopt(list, 0, value); | 72 testLoadStoreDeopt(list, 0, value); |
| 73 } | 73 } |
| 74 try { | 74 try { |
| 75 // non-Float32x4 value. | 75 // non-Float32x4 value. |
| 76 testLoadStoreDeopt(list, 0, 4.toDouble()); | 76 testLoadStoreDeopt(list, 0, 4.toDouble()); |
| 77 } catch (_) {} | 77 } catch (_) {} |
| 78 for (int i = 0; i < 3000; i++) { | 78 for (int i = 0; i < 20; i++) { |
| 79 testLoadStoreDeopt(list, 0, value); | 79 testLoadStoreDeopt(list, 0, value); |
| 80 } | 80 } |
| 81 try { | 81 try { |
| 82 // non-Float32x4List list. | 82 // non-Float32x4List list. |
| 83 testLoadStoreDeopt([new Float32x4(2.0, 3.0, 4.0, 5.0)], 0, value); | 83 testLoadStoreDeopt([new Float32x4(2.0, 3.0, 4.0, 5.0)], 0, value); |
| 84 } catch (_) {} | 84 } catch (_) {} |
| 85 for (int i = 0; i < 3000; i++) { | 85 for (int i = 0; i < 20; i++) { |
| 86 testLoadStoreDeopt(list, 0, value); | 86 testLoadStoreDeopt(list, 0, value); |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 testListZero() { | 90 testListZero() { |
| 91 Float32x4List list = new Float32x4List(1); | 91 Float32x4List list = new Float32x4List(1); |
| 92 Expect.equals(0.0, list[0].x); | 92 Expect.equals(0.0, list[0].x); |
| 93 Expect.equals(0.0, list[0].y); | 93 Expect.equals(0.0, list[0].y); |
| 94 Expect.equals(0.0, list[0].z); | 94 Expect.equals(0.0, list[0].z); |
| 95 Expect.equals(0.0, list[0].w); | 95 Expect.equals(0.0, list[0].w); |
| 96 } | 96 } |
| 97 | 97 |
| 98 testView(array) { | 98 testView(array) { |
| 99 Expect.equals(8, array.length); | 99 Expect.equals(8, array.length); |
| 100 Expect.isTrue(array is List<Float32x4>); | 100 Expect.isTrue(array is List<Float32x4>); |
| 101 Expect.equals(0.0, array[0].x); | 101 Expect.equals(0.0, array[0].x); |
| 102 Expect.equals(1.0, array[0].y); | 102 Expect.equals(1.0, array[0].y); |
| 103 Expect.equals(2.0, array[0].z); | 103 Expect.equals(2.0, array[0].z); |
| 104 Expect.equals(3.0, array[0].w); | 104 Expect.equals(3.0, array[0].w); |
| 105 Expect.equals(4.0, array[1].x); | 105 Expect.equals(4.0, array[1].x); |
| 106 Expect.equals(5.0, array[1].y); | 106 Expect.equals(5.0, array[1].y); |
| 107 Expect.equals(6.0, array[1].z); | 107 Expect.equals(6.0, array[1].z); |
| 108 Expect.equals(7.0, array[1].w); | 108 Expect.equals(7.0, array[1].w); |
| 109 } | 109 } |
| 110 | 110 |
| 111 main() { | 111 main() { |
| 112 var list; | 112 var list; |
| 113 | 113 |
| 114 list = new Float32x4List(8); | 114 list = new Float32x4List(8); |
| 115 for (int i = 0; i < 3000; i++) { | 115 for (int i = 0; i < 20; i++) { |
| 116 testLoadStore(list); | 116 testLoadStore(list); |
| 117 } | 117 } |
| 118 | 118 |
| 119 Float32List floatList = new Float32List(32); | 119 Float32List floatList = new Float32List(32); |
| 120 for (int i = 0; i < floatList.length; i++) { | 120 for (int i = 0; i < floatList.length; i++) { |
| 121 floatList[i] = i.toDouble(); | 121 floatList[i] = i.toDouble(); |
| 122 } | 122 } |
| 123 list = new Float32x4List.view(floatList); | 123 list = new Float32x4List.view(floatList); |
| 124 for (int i = 0; i < 3000; i++) { | 124 for (int i = 0; i < 20; i++) { |
| 125 testView(list); | 125 testView(list); |
| 126 } | 126 } |
| 127 for (int i = 0; i < 3000; i++) { | 127 for (int i = 0; i < 20; i++) { |
| 128 testLoadStore(list); | 128 testLoadStore(list); |
| 129 } | 129 } |
| 130 for (int i = 0; i < 3000; i++) { | 130 for (int i = 0; i < 20; i++) { |
| 131 testListZero(); | 131 testListZero(); |
| 132 } | 132 } |
| 133 testLoadStoreDeoptDriver(); | 133 testLoadStoreDeoptDriver(); |
| 134 } | 134 } |
| OLD | NEW |