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

Unified Diff: runtime/vm/bitmap_test.cc

Issue 10832410: Give a length field to stack bitmaps. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Incorporated review comments. Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/bitmap.cc ('k') | runtime/vm/code_descriptors.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/bitmap_test.cc
diff --git a/runtime/vm/bitmap_test.cc b/runtime/vm/bitmap_test.cc
index 4e9fc7cdc1c317a172d6126857fe7e4d4cd289a8..d4a39798f7a5260929aaf57a4151a92281755bf1 100644
--- a/runtime/vm/bitmap_test.cc
+++ b/runtime/vm/bitmap_test.cc
@@ -12,15 +12,14 @@ namespace dart {
TEST_CASE(BitmapBuilder) {
// Test basic bit map builder operations.
BitmapBuilder* builder1 = new BitmapBuilder();
-
- EXPECT_EQ(-1, builder1->Maximum());
- EXPECT_EQ(-1, builder1->Minimum());
+ EXPECT_EQ(0, builder1->Length());
bool value = true;
for (int32_t i = 0; i < 128; i++) {
builder1->Set(i, value);
value = !value;
}
+ EXPECT_EQ(128, builder1->Length());
value = true;
for (int32_t i = 0; i < 128; i++) {
EXPECT_EQ(value, builder1->Get(i));
@@ -31,28 +30,29 @@ TEST_CASE(BitmapBuilder) {
builder1->Set(i, value);
value = !value;
}
+ EXPECT_EQ(1024, builder1->Length());
value = true;
for (int32_t i = 0; i < 1024; i++) {
EXPECT_EQ(value, builder1->Get(i));
value = !value;
}
// Create a Stackmap object from the builder and verify its contents.
- const Stackmap& stackmap1 =
- Stackmap::Handle(Stackmap::New(0, 1024, builder1));
- EXPECT_EQ(1022, builder1->Maximum());
- EXPECT_EQ(0, builder1->Minimum());
+ const Stackmap& stackmap1 = Stackmap::Handle(Stackmap::New(0, builder1));
+ EXPECT_EQ(1024, stackmap1.Length());
OS::Print("%s\n", stackmap1.ToCString());
value = true;
for (int32_t i = 0; i < 1024; i++) {
EXPECT_EQ(value, stackmap1.IsObject(i));
value = !value;
}
- EXPECT(!stackmap1.IsObject(2056)); // Out of range so returns false.
// Test the SetRange function in the builder.
builder1->SetRange(0, 256, false);
+ EXPECT_EQ(1024, builder1->Length());
builder1->SetRange(257, 1024, true);
+ EXPECT_EQ(1025, builder1->Length());
builder1->SetRange(1025, 2048, false);
+ EXPECT_EQ(2049, builder1->Length());
for (int32_t i = 0; i <= 256; i++) {
EXPECT(!builder1->Get(i));
}
@@ -62,10 +62,8 @@ TEST_CASE(BitmapBuilder) {
for (int32_t i = 1025; i <= 2048; i++) {
EXPECT(!builder1->Get(i));
}
- const Stackmap& stackmap2 =
- Stackmap::Handle(Stackmap::New(0, 2049, builder1));
- EXPECT_EQ(1024, builder1->Maximum());
- EXPECT_EQ(257, builder1->Minimum());
+ const Stackmap& stackmap2 = Stackmap::Handle(Stackmap::New(0, builder1));
+ EXPECT_EQ(2049, stackmap2.Length());
for (int32_t i = 0; i <= 256; i++) {
EXPECT(!stackmap2.IsObject(i));
}
@@ -75,6 +73,32 @@ TEST_CASE(BitmapBuilder) {
for (int32_t i = 1025; i <= 2048; i++) {
EXPECT(!stackmap2.IsObject(i));
}
+
+ // Test using SetLength to shorten the builder, followed by lengthening.
+ builder1->SetLength(747);
+ EXPECT_EQ(747, builder1->Length());
+ for (int32_t i = 257; i < 747; ++i) {
+ EXPECT(builder1->Get(i));
+ }
+
+ builder1->Set(800, false);
+ EXPECT_EQ(801, builder1->Length());
+ for (int32_t i = 257; i < 747; ++i) {
+ EXPECT(builder1->Get(i));
+ }
+ for (int32_t i = 747; i < 801; ++i) {
+ EXPECT(!builder1->Get(i));
+ }
+
+ builder1->Set(900, true);
+ EXPECT_EQ(901, builder1->Length());
+ for (int32_t i = 257; i < 747; ++i) {
+ EXPECT(builder1->Get(i));
+ }
+ for (int32_t i = 747; i < 900; ++i) {
+ EXPECT(!builder1->Get(i));
+ }
+ EXPECT(builder1->Get(900));
}
} // namespace dart
« no previous file with comments | « runtime/vm/bitmap.cc ('k') | runtime/vm/code_descriptors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698