Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: tests/language/vm/unaligned_integer_access_literal_index_test.dart

Issue 2473553002: Fix unaligned access to TypedData from native code. (Closed)
Patch Set: . Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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=--optimization_counter_threshold=10 --no-background_compilation 4 // VMOptions=--optimization_counter_threshold=10 --no-background_compilation
5 5
6 import 'dart:typed_data'; 6 import 'dart:typed_data';
7 import 'package:expect/expect.dart'; 7 import 'package:expect/expect.dart';
8 8
9 unalignedUint16() { 9 unalignedUint16() {
10 var bytes = new ByteData(64); 10 var bytes = new ByteData(64);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 bytes.setInt64(4, -0x12341234); 79 bytes.setInt64(4, -0x12341234);
80 Expect.equals(-0x12341234, bytes.getInt64(4)); 80 Expect.equals(-0x12341234, bytes.getInt64(4));
81 bytes.setInt64(5, -0x23452345); 81 bytes.setInt64(5, -0x23452345);
82 Expect.equals(-0x23452345, bytes.getInt64(5)); 82 Expect.equals(-0x23452345, bytes.getInt64(5));
83 bytes.setInt64(6, -0x12341234); 83 bytes.setInt64(6, -0x12341234);
84 Expect.equals(-0x12341234, bytes.getInt64(6)); 84 Expect.equals(-0x12341234, bytes.getInt64(6));
85 bytes.setInt64(7, -0x23452345); 85 bytes.setInt64(7, -0x23452345);
86 Expect.equals(-0x23452345, bytes.getInt64(7)); 86 Expect.equals(-0x23452345, bytes.getInt64(7));
87 } 87 }
88 88
89 unalignedFloat32() {
90 var bytes = new ByteData(64);
91 bytes.setFloat32(0, 16.25);
92 Expect.equals(16.25, bytes.getFloat32(0));
93 bytes.setFloat32(1, 32.125);
94 Expect.equals(32.125, bytes.getFloat32(1));
95 bytes.setFloat32(2, 16.25);
96 Expect.equals(16.25, bytes.getFloat32(2));
97 bytes.setFloat32(3, 32.125);
98 Expect.equals(32.125, bytes.getFloat32(3));
99 }
100
101 unalignedFloat64() {
102 var bytes = new ByteData(64);
103 bytes.setFloat64(0, 16.25);
104 Expect.equals(16.25, bytes.getFloat64(0));
105 bytes.setFloat64(1, 32.125);
106 Expect.equals(32.125, bytes.getFloat64(1));
107 bytes.setFloat64(2, 16.25);
108 Expect.equals(16.25, bytes.getFloat64(2));
109 bytes.setFloat64(3, 32.125);
110 Expect.equals(32.125, bytes.getFloat64(3));
111 bytes.setFloat64(4, 16.25);
112 Expect.equals(16.25, bytes.getFloat64(4));
113 bytes.setFloat64(5, 32.125);
114 Expect.equals(32.125, bytes.getFloat64(5));
115 bytes.setFloat64(6, 16.25);
116 Expect.equals(16.25, bytes.getFloat64(6));
117 bytes.setFloat64(7, 32.125);
118 Expect.equals(32.125, bytes.getFloat64(7));
119 }
120
121 main() { 89 main() {
122 for (var i = 0; i < 20; i++) { 90 for (var i = 0; i < 20; i++) {
123 unalignedUint16(); 91 unalignedUint16();
124 unalignedInt16(); 92 unalignedInt16();
125 unalignedUint32(); 93 unalignedUint32();
126 unalignedInt32(); 94 unalignedInt32();
127 unalignedUint64(); 95 unalignedUint64();
128 unalignedInt64(); 96 unalignedInt64();
129 unalignedFloat32();
130 unalignedFloat64();
131 } 97 }
132 } 98 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698