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

Side by Side Diff: vm/bitmap_test.cc

Issue 9701010: First step towards implementing stack map descriptions for the optimizing compiler. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « vm/bitmap.cc ('k') | vm/object.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
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.
4
5 #include "platform/assert.h"
6 #include "vm/bitmap.h"
7 #include "vm/object.h"
8 #include "vm/unit_test.h"
9
10 namespace dart {
11
12 TEST_CASE(BitmapBuilder) {
13 // Test basic bit map builder operations.
14 BitmapBuilder* bmap1_builder = new BitmapBuilder();
15
16 EXPECT_EQ(-1, bmap1_builder->Maximum());
17 EXPECT_EQ(-1, bmap1_builder->Minimum());
18
19 bool value = true;
20 for (int32_t i = 0; i < 128; i++) {
21 bmap1_builder->Set(i, value);
22 value = !value;
23 }
24 value = true;
25 for (int32_t i = 0; i < 128; i++) {
26 EXPECT_EQ(value, bmap1_builder->Get(i));
27 value = !value;
28 }
29 value = true;
30 for (int32_t i = 0; i < 1024; i++) {
31 bmap1_builder->Set(i, value);
32 value = !value;
33 }
34 value = true;
35 for (int32_t i = 0; i < 1024; i++) {
36 EXPECT_EQ(value, bmap1_builder->Get(i));
37 value = !value;
38 }
39 // Create a Bitmap object from the builder and verify it's contents.
40 const Stackmap& bmap1 = Stackmap::Handle(
41 Stackmap::New(0, Code::Handle(), bmap1_builder));
42 EXPECT_EQ(1022, bmap1_builder->Maximum());
43 EXPECT_EQ(0, bmap1_builder->Minimum());
44 OS::Print("%s\n", bmap1.ToCString());
45 value = true;
46 for (int32_t i = 0; i < 1024; i++) {
47 EXPECT_EQ(value, bmap1.IsObject(i));
48 value = !value;
49 }
50 EXPECT(!bmap1.IsObject(2056)); // Out of range so returns false.
51
52 // Test the SetRange function in the builder.
53 bmap1_builder->SetRange(0, 256, false);
54 bmap1_builder->SetRange(257, 1024, true);
55 bmap1_builder->SetRange(1025, 2048, false);
56 for (int32_t i = 0; i <= 256; i++) {
57 EXPECT(!bmap1_builder->Get(i));
58 }
59 for (int32_t i = 257; i <= 1024; i++) {
60 EXPECT(bmap1_builder->Get(i));
61 }
62 for (int32_t i = 1025; i <= 2048; i++) {
63 EXPECT(!bmap1_builder->Get(i));
64 }
65 const Stackmap& bmap2 = Stackmap::Handle(
66 Stackmap::New(0, Code::Handle(), bmap1_builder));
67 EXPECT_EQ(1024, bmap1_builder->Maximum());
68 EXPECT_EQ(257, bmap1_builder->Minimum());
69 for (int32_t i = 0; i <= 256; i++) {
70 EXPECT(!bmap2.IsObject(i));
71 }
72 for (int32_t i = 257; i <= 1024; i++) {
73 EXPECT(bmap2.IsObject(i));
74 }
75 for (int32_t i = 1025; i <= 2048; i++) {
76 EXPECT(!bmap2.IsObject(i));
77 }
78
79 // Test the functionality to copy a Stackmap object into a builder.
80 BitmapBuilder* bmap2_builder = new BitmapBuilder();
81 bmap2_builder->SetBits(bmap1);
82 EXPECT_EQ(1022, bmap2_builder->Maximum());
83 EXPECT_EQ(0, bmap2_builder->Minimum());
84 value = true;
85 for (int32_t i = 0; i < 1024; i++) {
86 EXPECT_EQ(value, bmap2_builder->Get(i));
87 value = !value;
88 }
89
90 BitmapBuilder* bmap3_builder = new BitmapBuilder();
91 bmap3_builder->SetBits(bmap2);
92 EXPECT_EQ(1024, bmap3_builder->Maximum());
93 EXPECT_EQ(257, bmap3_builder->Minimum());
94 for (int32_t i = 0; i <= 256; i++) {
95 EXPECT(!bmap3_builder->Get(i));
96 }
97 for (int32_t i = 257; i <= 1024; i++) {
98 EXPECT(bmap3_builder->Get(i));
99 }
100 for (int32_t i = 1025; i <= 2048; i++) {
101 EXPECT(!bmap3_builder->Get(i));
102 }
103 }
104
105 } // namespace dart
OLDNEW
« no previous file with comments | « vm/bitmap.cc ('k') | vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698