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

Side by Side Diff: tests/language/vm/unaligned_integer_access_register_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
« no previous file with comments | « tests/language/vm/unaligned_integer_access_literal_index_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 } 47 }
48 48
49 unalignedInt64() { 49 unalignedInt64() {
50 var bytes = new ByteData(64); 50 var bytes = new ByteData(64);
51 for (var i = 0; i < 8; i++) { 51 for (var i = 0; i < 8; i++) {
52 bytes.setInt64(i, -0x12341234); 52 bytes.setInt64(i, -0x12341234);
53 Expect.equals(-0x12341234, bytes.getInt64(i)); 53 Expect.equals(-0x12341234, bytes.getInt64(i));
54 } 54 }
55 } 55 }
56 56
57 unalignedFloat32() {
58 var bytes = new ByteData(64);
59 for (var i = 0; i < 4; i++) {
60 bytes.setFloat32(i, 16.25);
61 Expect.equals(16.25, bytes.getFloat32(i));
62 }
63 }
64
65 unalignedFloat64() {
66 var bytes = new ByteData(64);
67 for (var i = 0; i < 8; i++) {
68 bytes.setFloat64(i, 16.25);
69 Expect.equals(16.25, bytes.getFloat64(i));
70 }
71 }
72
73 main() { 57 main() {
74 for (var i = 0; i < 20; i++) { 58 for (var i = 0; i < 20; i++) {
75 unalignedUint16(); 59 unalignedUint16();
76 unalignedInt16(); 60 unalignedInt16();
77 unalignedUint32(); 61 unalignedUint32();
78 unalignedInt32(); 62 unalignedInt32();
79 unalignedUint64(); 63 unalignedUint64();
80 unalignedInt64(); 64 unalignedInt64();
81 unalignedFloat32();
82 unalignedFloat64();
83 } 65 }
84 } 66 }
OLDNEW
« no previous file with comments | « tests/language/vm/unaligned_integer_access_literal_index_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698