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

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

Issue 2940883008: [arm, arm64] Implemented unaligned scalar float access. (Closed)
Patch Set: piecewise float64 Created 3 years, 6 months 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);
11 bytes.setUint16(0, 0xABCD); 11 bytes.setUint16(0, 0xABCD, Endianness.HOST_ENDIAN);
12 Expect.equals(0xABCD, bytes.getUint16(0)); 12 Expect.equals(0xABCD, bytes.getUint16(0, Endianness.HOST_ENDIAN));
13 bytes.setUint16(1, 0xBCDE); 13 bytes.setUint16(1, 0xBCDE, Endianness.HOST_ENDIAN);
14 Expect.equals(0xBCDE, bytes.getUint16(1)); 14 Expect.equals(0xBCDE, bytes.getUint16(1, Endianness.HOST_ENDIAN));
15 } 15 }
16 16
17 unalignedInt16() { 17 unalignedInt16() {
18 var bytes = new ByteData(64); 18 var bytes = new ByteData(64);
19 bytes.setInt16(0, -0x1234); 19 bytes.setInt16(0, -0x1234, Endianness.HOST_ENDIAN);
20 Expect.equals(-0x1234, bytes.getInt16(0)); 20 Expect.equals(-0x1234, bytes.getInt16(0, Endianness.HOST_ENDIAN));
21 bytes.setInt16(1, -0x2345); 21 bytes.setInt16(1, -0x2345, Endianness.HOST_ENDIAN);
22 Expect.equals(-0x2345, bytes.getInt16(1)); 22 Expect.equals(-0x2345, bytes.getInt16(1, Endianness.HOST_ENDIAN));
23 } 23 }
24 24
25 unalignedUint32() { 25 unalignedUint32() {
26 var bytes = new ByteData(64); 26 var bytes = new ByteData(64);
27 bytes.setUint32(0, 0xABCDABCD); 27 bytes.setUint32(0, 0xABCDABCD, Endianness.HOST_ENDIAN);
28 Expect.equals(0xABCDABCD, bytes.getUint32(0)); 28 Expect.equals(0xABCDABCD, bytes.getUint32(0, Endianness.HOST_ENDIAN));
29 bytes.setUint32(1, 0xBCDEBCDE); 29 bytes.setUint32(1, 0xBCDEBCDE, Endianness.HOST_ENDIAN);
30 Expect.equals(0xBCDEBCDE, bytes.getUint32(1)); 30 Expect.equals(0xBCDEBCDE, bytes.getUint32(1, Endianness.HOST_ENDIAN));
31 bytes.setUint32(2, 0xABCDABCD); 31 bytes.setUint32(2, 0xABCDABCD, Endianness.HOST_ENDIAN);
32 Expect.equals(0xABCDABCD, bytes.getUint32(2)); 32 Expect.equals(0xABCDABCD, bytes.getUint32(2, Endianness.HOST_ENDIAN));
33 bytes.setUint32(3, 0xBCDEBCDE); 33 bytes.setUint32(3, 0xBCDEBCDE, Endianness.HOST_ENDIAN);
34 Expect.equals(0xBCDEBCDE, bytes.getUint32(3)); 34 Expect.equals(0xBCDEBCDE, bytes.getUint32(3, Endianness.HOST_ENDIAN));
35 } 35 }
36 36
37 unalignedInt32() { 37 unalignedInt32() {
38 var bytes = new ByteData(64); 38 var bytes = new ByteData(64);
39 bytes.setInt32(0, -0x12341234); 39 bytes.setInt32(0, -0x12341234, Endianness.HOST_ENDIAN);
40 Expect.equals(-0x12341234, bytes.getInt32(0)); 40 Expect.equals(-0x12341234, bytes.getInt32(0, Endianness.HOST_ENDIAN));
41 bytes.setInt32(1, -0x23452345); 41 bytes.setInt32(1, -0x23452345, Endianness.HOST_ENDIAN);
42 Expect.equals(-0x23452345, bytes.getInt32(1)); 42 Expect.equals(-0x23452345, bytes.getInt32(1, Endianness.HOST_ENDIAN));
43 bytes.setInt32(2, -0x12341234); 43 bytes.setInt32(2, -0x12341234, Endianness.HOST_ENDIAN);
44 Expect.equals(-0x12341234, bytes.getInt32(2)); 44 Expect.equals(-0x12341234, bytes.getInt32(2, Endianness.HOST_ENDIAN));
45 bytes.setInt32(3, -0x23452345); 45 bytes.setInt32(3, -0x23452345, Endianness.HOST_ENDIAN);
46 Expect.equals(-0x23452345, bytes.getInt32(3)); 46 Expect.equals(-0x23452345, bytes.getInt32(3, Endianness.HOST_ENDIAN));
47 } 47 }
48 48
49 unalignedUint64() { 49 unalignedUint64() {
50 var bytes = new ByteData(64); 50 var bytes = new ByteData(64);
51 bytes.setUint64(0, 0xABCDABCD); 51 bytes.setUint64(0, 0xABCDABCD12345678, Endianness.HOST_ENDIAN);
52 Expect.equals(0xABCDABCD, bytes.getUint64(0)); 52 Expect.equals(0xABCDABCD12345678, bytes.getUint64(0, Endianness.HOST_ENDIAN));
53 bytes.setUint64(1, 0xBCDEBCDE); 53 bytes.setUint64(1, 0xBCDEBCDE12345678, Endianness.HOST_ENDIAN);
54 Expect.equals(0xBCDEBCDE, bytes.getUint64(1)); 54 Expect.equals(0xBCDEBCDE12345678, bytes.getUint64(1, Endianness.HOST_ENDIAN));
55 bytes.setUint64(2, 0xABCDABCD); 55 bytes.setUint64(2, 0xABCDABCD12345678, Endianness.HOST_ENDIAN);
56 Expect.equals(0xABCDABCD, bytes.getUint64(2)); 56 Expect.equals(0xABCDABCD12345678, bytes.getUint64(2, Endianness.HOST_ENDIAN));
57 bytes.setUint64(3, 0xBCDEBCDE); 57 bytes.setUint64(3, 0xBCDEBCDE12345678, Endianness.HOST_ENDIAN);
58 Expect.equals(0xBCDEBCDE, bytes.getUint64(3)); 58 Expect.equals(0xBCDEBCDE12345678, bytes.getUint64(3, Endianness.HOST_ENDIAN));
59 bytes.setUint64(4, 0xABCDABCD); 59 bytes.setUint64(4, 0xABCDABCD12345678, Endianness.HOST_ENDIAN);
60 Expect.equals(0xABCDABCD, bytes.getUint64(4)); 60 Expect.equals(0xABCDABCD12345678, bytes.getUint64(4, Endianness.HOST_ENDIAN));
61 bytes.setUint64(5, 0xBCDEBCDE); 61 bytes.setUint64(5, 0xBCDEBCDE12345678, Endianness.HOST_ENDIAN);
62 Expect.equals(0xBCDEBCDE, bytes.getUint64(5)); 62 Expect.equals(0xBCDEBCDE12345678, bytes.getUint64(5, Endianness.HOST_ENDIAN));
63 bytes.setUint64(6, 0xABCDABCD); 63 bytes.setUint64(6, 0xABCDABCD12345678, Endianness.HOST_ENDIAN);
64 Expect.equals(0xABCDABCD, bytes.getUint64(6)); 64 Expect.equals(0xABCDABCD12345678, bytes.getUint64(6, Endianness.HOST_ENDIAN));
65 bytes.setUint64(7, 0xBCDEBCDE); 65 bytes.setUint64(7, 0xBCDEBCDE12345678, Endianness.HOST_ENDIAN);
66 Expect.equals(0xBCDEBCDE, bytes.getUint64(7)); 66 Expect.equals(0xBCDEBCDE12345678, bytes.getUint64(7, Endianness.HOST_ENDIAN));
67 } 67 }
68 68
69 unalignedInt64() { 69 unalignedInt64() {
70 var bytes = new ByteData(64); 70 var bytes = new ByteData(64);
71 bytes.setInt64(0, -0x12341234); 71 bytes.setInt64(0, -0x12341234ABCDABCD, Endianness.HOST_ENDIAN);
72 Expect.equals(-0x12341234, bytes.getInt64(0)); 72 Expect.equals(-0x12341234ABCDABCD, bytes.getInt64(0, Endianness.HOST_ENDIAN));
73 bytes.setInt64(1, -0x23452345); 73 bytes.setInt64(1, -0x23452345ABCDABCD, Endianness.HOST_ENDIAN);
74 Expect.equals(-0x23452345, bytes.getInt64(1)); 74 Expect.equals(-0x23452345ABCDABCD, bytes.getInt64(1, Endianness.HOST_ENDIAN));
75 bytes.setInt64(2, -0x12341234); 75 bytes.setInt64(2, -0x12341234ABCDABCD, Endianness.HOST_ENDIAN);
76 Expect.equals(-0x12341234, bytes.getInt64(2)); 76 Expect.equals(-0x12341234ABCDABCD, bytes.getInt64(2, Endianness.HOST_ENDIAN));
77 bytes.setInt64(3, -0x23452345); 77 bytes.setInt64(3, -0x23452345ABCDABCD, Endianness.HOST_ENDIAN);
78 Expect.equals(-0x23452345, bytes.getInt64(3)); 78 Expect.equals(-0x23452345ABCDABCD, bytes.getInt64(3, Endianness.HOST_ENDIAN));
79 bytes.setInt64(4, -0x12341234); 79 bytes.setInt64(4, -0x12341234ABCDABCD, Endianness.HOST_ENDIAN);
80 Expect.equals(-0x12341234, bytes.getInt64(4)); 80 Expect.equals(-0x12341234ABCDABCD, bytes.getInt64(4, Endianness.HOST_ENDIAN));
81 bytes.setInt64(5, -0x23452345); 81 bytes.setInt64(5, -0x23452345ABCDABCD, Endianness.HOST_ENDIAN);
82 Expect.equals(-0x23452345, bytes.getInt64(5)); 82 Expect.equals(-0x23452345ABCDABCD, bytes.getInt64(5, Endianness.HOST_ENDIAN));
83 bytes.setInt64(6, -0x12341234); 83 bytes.setInt64(6, -0x12341234ABCDABCD, Endianness.HOST_ENDIAN);
84 Expect.equals(-0x12341234, bytes.getInt64(6)); 84 Expect.equals(-0x12341234ABCDABCD, bytes.getInt64(6, Endianness.HOST_ENDIAN));
85 bytes.setInt64(7, -0x23452345); 85 bytes.setInt64(7, -0x23452345ABCDABCD, Endianness.HOST_ENDIAN);
86 Expect.equals(-0x23452345, bytes.getInt64(7)); 86 Expect.equals(-0x23452345ABCDABCD, bytes.getInt64(7, Endianness.HOST_ENDIAN));
87 } 87 }
88 88
89 main() { 89 main() {
90 for (var i = 0; i < 20; i++) { 90 for (var i = 0; i < 20; i++) {
91 unalignedUint16(); 91 unalignedUint16();
92 unalignedInt16(); 92 unalignedInt16();
93 unalignedUint32(); 93 unalignedUint32();
94 unalignedInt32(); 94 unalignedInt32();
95 unalignedUint64(); 95 unalignedUint64();
96 unalignedInt64(); 96 unalignedInt64();
97 } 97 }
98 } 98 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698