Index: test/unittests/interpreter/constant-array-builder-unittest.cc |
diff --git a/test/unittests/interpreter/constant-array-builder-unittest.cc b/test/unittests/interpreter/constant-array-builder-unittest.cc |
index b3ec5ff6680113e19e076493145daabdf1af3066..37de005d4ecf0f11bf437cac4499448ea45a5222 100644 |
--- a/test/unittests/interpreter/constant-array-builder-unittest.cc |
+++ b/test/unittests/interpreter/constant-array-builder-unittest.cc |
@@ -19,79 +19,77 @@ class ConstantArrayBuilderTest : public TestWithIsolateAndZone { |
ConstantArrayBuilderTest() {} |
~ConstantArrayBuilderTest() override {} |
- static const size_t kLowCapacity = ConstantArrayBuilder::kLowCapacity; |
- static const size_t kMaxCapacity = ConstantArrayBuilder::kMaxCapacity; |
+ static const size_t k8BitCapacity = ConstantArrayBuilder::k8BitCapacity; |
+ static const size_t k16BitCapacity = ConstantArrayBuilder::k16BitCapacity; |
}; |
- |
STATIC_CONST_MEMBER_DEFINITION const size_t |
- ConstantArrayBuilderTest::kMaxCapacity; |
+ ConstantArrayBuilderTest::k16BitCapacity; |
STATIC_CONST_MEMBER_DEFINITION const size_t |
- ConstantArrayBuilderTest::kLowCapacity; |
- |
+ ConstantArrayBuilderTest::k8BitCapacity; |
TEST_F(ConstantArrayBuilderTest, AllocateAllEntries) { |
ConstantArrayBuilder builder(isolate(), zone()); |
- for (size_t i = 0; i < kMaxCapacity; i++) { |
+ for (size_t i = 0; i < k16BitCapacity; i++) { |
builder.Insert(handle(Smi::FromInt(static_cast<int>(i)), isolate())); |
} |
- CHECK_EQ(builder.size(), kMaxCapacity); |
- for (size_t i = 0; i < kMaxCapacity; i++) { |
+ CHECK_EQ(builder.size(), k16BitCapacity); |
+ for (size_t i = 0; i < k16BitCapacity; i++) { |
CHECK_EQ(Handle<Smi>::cast(builder.At(i))->value(), i); |
} |
} |
TEST_F(ConstantArrayBuilderTest, AllocateEntriesWithIdx8Reservations) { |
- for (size_t reserved = 1; reserved < kLowCapacity; reserved *= 3) { |
+ for (size_t reserved = 1; reserved < k8BitCapacity; reserved *= 3) { |
ConstantArrayBuilder builder(isolate(), zone()); |
for (size_t i = 0; i < reserved; i++) { |
OperandSize operand_size = builder.CreateReservedEntry(); |
CHECK(operand_size == OperandSize::kByte); |
} |
- for (size_t i = 0; i < 2 * kLowCapacity; i++) { |
+ for (size_t i = 0; i < 2 * k8BitCapacity; i++) { |
Handle<Object> object = isolate()->factory()->NewNumberFromSize(i); |
builder.Insert(object); |
- if (i + reserved < kLowCapacity) { |
- CHECK_LE(builder.size(), kLowCapacity); |
+ if (i + reserved < k8BitCapacity) { |
+ CHECK_LE(builder.size(), k8BitCapacity); |
CHECK_EQ(builder.size(), i + 1); |
CHECK(builder.At(i)->SameValue(*object)); |
} else { |
- CHECK_GE(builder.size(), kLowCapacity); |
+ CHECK_GE(builder.size(), k8BitCapacity); |
CHECK_EQ(builder.size(), i + reserved + 1); |
CHECK(builder.At(i + reserved)->SameValue(*object)); |
} |
} |
- CHECK_EQ(builder.size(), 2 * kLowCapacity + reserved); |
+ CHECK_EQ(builder.size(), 2 * k8BitCapacity + reserved); |
// Check reserved values represented by the hole. |
for (size_t i = 0; i < reserved; i++) { |
- Handle<Object> empty = builder.At(kLowCapacity - reserved + i); |
+ Handle<Object> empty = builder.At(k8BitCapacity - reserved + i); |
CHECK(empty->SameValue(isolate()->heap()->the_hole_value())); |
} |
// Commmit reserved entries with duplicates and check size does not change. |
- DCHECK_EQ(reserved + 2 * kLowCapacity, builder.size()); |
+ DCHECK_EQ(reserved + 2 * k8BitCapacity, builder.size()); |
size_t duplicates_in_idx8_space = |
- std::min(reserved, kLowCapacity - reserved); |
+ std::min(reserved, k8BitCapacity - reserved); |
for (size_t i = 0; i < duplicates_in_idx8_space; i++) { |
builder.CommitReservedEntry(OperandSize::kByte, |
isolate()->factory()->NewNumberFromSize(i)); |
- DCHECK_EQ(reserved + 2 * kLowCapacity, builder.size()); |
+ DCHECK_EQ(reserved + 2 * k8BitCapacity, builder.size()); |
} |
// Check all committed values match expected (holes where |
// duplicates_in_idx8_space allocated). |
- for (size_t i = 0; i < kLowCapacity - reserved; i++) { |
+ for (size_t i = 0; i < k8BitCapacity - reserved; i++) { |
Smi* smi = Smi::FromInt(static_cast<int>(i)); |
CHECK(Handle<Smi>::cast(builder.At(i))->SameValue(smi)); |
} |
- for (size_t i = kLowCapacity; i < 2 * kLowCapacity + reserved; i++) { |
+ for (size_t i = k8BitCapacity; i < 2 * k8BitCapacity + reserved; i++) { |
Smi* smi = Smi::FromInt(static_cast<int>(i - reserved)); |
CHECK(Handle<Smi>::cast(builder.At(i))->SameValue(smi)); |
} |
for (size_t i = 0; i < reserved; i++) { |
- size_t index = kLowCapacity - reserved + i; |
+ size_t index = k8BitCapacity - reserved + i; |
CHECK(builder.At(index)->IsTheHole()); |
} |
@@ -102,20 +100,20 @@ TEST_F(ConstantArrayBuilderTest, AllocateEntriesWithIdx8Reservations) { |
} |
for (size_t i = 0; i < duplicates_in_idx8_space; i++) { |
Handle<Object> object = |
- isolate()->factory()->NewNumberFromSize(2 * kLowCapacity + i); |
+ isolate()->factory()->NewNumberFromSize(2 * k8BitCapacity + i); |
size_t index = builder.CommitReservedEntry(OperandSize::kByte, object); |
- CHECK_EQ(static_cast<int>(index), kLowCapacity - reserved + i); |
+ CHECK_EQ(static_cast<int>(index), k8BitCapacity - reserved + i); |
CHECK(builder.At(static_cast<int>(index))->SameValue(*object)); |
} |
- CHECK_EQ(builder.size(), 2 * kLowCapacity + reserved); |
+ CHECK_EQ(builder.size(), 2 * k8BitCapacity + reserved); |
} |
} |
TEST_F(ConstantArrayBuilderTest, AllocateEntriesWithIdx16Reservations) { |
- for (size_t reserved = 1; reserved < kLowCapacity; reserved *= 3) { |
+ for (size_t reserved = 1; reserved < k8BitCapacity; reserved *= 3) { |
ConstantArrayBuilder builder(isolate(), zone()); |
- for (size_t i = 0; i < kLowCapacity; i++) { |
+ for (size_t i = 0; i < k8BitCapacity; i++) { |
Handle<Object> object = isolate()->factory()->NewNumberFromSize(i); |
builder.Insert(object); |
CHECK(builder.At(i)->SameValue(*object)); |
@@ -124,20 +122,20 @@ TEST_F(ConstantArrayBuilderTest, AllocateEntriesWithIdx16Reservations) { |
for (size_t i = 0; i < reserved; i++) { |
OperandSize operand_size = builder.CreateReservedEntry(); |
CHECK(operand_size == OperandSize::kShort); |
- CHECK_EQ(builder.size(), kLowCapacity); |
+ CHECK_EQ(builder.size(), k8BitCapacity); |
} |
for (size_t i = 0; i < reserved; i++) { |
builder.DiscardReservedEntry(OperandSize::kShort); |
- CHECK_EQ(builder.size(), kLowCapacity); |
+ CHECK_EQ(builder.size(), k8BitCapacity); |
} |
for (size_t i = 0; i < reserved; i++) { |
OperandSize operand_size = builder.CreateReservedEntry(); |
CHECK(operand_size == OperandSize::kShort); |
Handle<Object> object = isolate()->factory()->NewNumberFromSize(i); |
builder.CommitReservedEntry(operand_size, object); |
- CHECK_EQ(builder.size(), kLowCapacity); |
+ CHECK_EQ(builder.size(), k8BitCapacity); |
} |
- for (size_t i = kLowCapacity; i < kLowCapacity + reserved; i++) { |
+ for (size_t i = k8BitCapacity; i < k8BitCapacity + reserved; i++) { |
OperandSize operand_size = builder.CreateReservedEntry(); |
CHECK(operand_size == OperandSize::kShort); |
Handle<Object> object = isolate()->factory()->NewNumberFromSize(i); |
@@ -166,23 +164,23 @@ TEST_F(ConstantArrayBuilderTest, ToFixedArray) { |
TEST_F(ConstantArrayBuilderTest, GapFilledWhenLowReservationCommitted) { |
ConstantArrayBuilder builder(isolate(), zone()); |
- for (size_t i = 0; i < kLowCapacity; i++) { |
+ for (size_t i = 0; i < k8BitCapacity; i++) { |
OperandSize operand_size = builder.CreateReservedEntry(); |
CHECK(OperandSize::kByte == operand_size); |
CHECK_EQ(builder.size(), 0); |
} |
- for (size_t i = 0; i < kLowCapacity; i++) { |
+ for (size_t i = 0; i < k8BitCapacity; i++) { |
Handle<Object> object = isolate()->factory()->NewNumberFromSize(i); |
builder.Insert(object); |
- CHECK_EQ(builder.size(), i + kLowCapacity + 1); |
+ CHECK_EQ(builder.size(), i + k8BitCapacity + 1); |
} |
- for (size_t i = 0; i < kLowCapacity; i++) { |
+ for (size_t i = 0; i < k8BitCapacity; i++) { |
builder.CommitReservedEntry(OperandSize::kByte, |
- builder.At(i + kLowCapacity)); |
- CHECK_EQ(builder.size(), 2 * kLowCapacity); |
+ builder.At(i + k8BitCapacity)); |
+ CHECK_EQ(builder.size(), 2 * k8BitCapacity); |
} |
- for (size_t i = 0; i < kLowCapacity; i++) { |
- Handle<Object> original = builder.At(kLowCapacity + i); |
+ for (size_t i = 0; i < k8BitCapacity; i++) { |
+ Handle<Object> original = builder.At(k8BitCapacity + i); |
Handle<Object> duplicate = builder.At(i); |
CHECK(original->SameValue(*duplicate)); |
Handle<Object> reference = isolate()->factory()->NewNumberFromSize(i); |
@@ -193,24 +191,24 @@ TEST_F(ConstantArrayBuilderTest, GapFilledWhenLowReservationCommitted) { |
TEST_F(ConstantArrayBuilderTest, GapNotFilledWhenLowReservationDiscarded) { |
ConstantArrayBuilder builder(isolate(), zone()); |
- for (size_t i = 0; i < kLowCapacity; i++) { |
+ for (size_t i = 0; i < k8BitCapacity; i++) { |
OperandSize operand_size = builder.CreateReservedEntry(); |
CHECK(OperandSize::kByte == operand_size); |
CHECK_EQ(builder.size(), 0); |
} |
- for (size_t i = 0; i < kLowCapacity; i++) { |
+ for (size_t i = 0; i < k8BitCapacity; i++) { |
Handle<Object> object = isolate()->factory()->NewNumberFromSize(i); |
builder.Insert(object); |
- CHECK_EQ(builder.size(), i + kLowCapacity + 1); |
+ CHECK_EQ(builder.size(), i + k8BitCapacity + 1); |
} |
- for (size_t i = 0; i < kLowCapacity; i++) { |
+ for (size_t i = 0; i < k8BitCapacity; i++) { |
builder.DiscardReservedEntry(OperandSize::kByte); |
- builder.Insert(builder.At(i + kLowCapacity)); |
- CHECK_EQ(builder.size(), 2 * kLowCapacity); |
+ builder.Insert(builder.At(i + k8BitCapacity)); |
+ CHECK_EQ(builder.size(), 2 * k8BitCapacity); |
} |
- for (size_t i = 0; i < kLowCapacity; i++) { |
+ for (size_t i = 0; i < k8BitCapacity; i++) { |
Handle<Object> reference = isolate()->factory()->NewNumberFromSize(i); |
- Handle<Object> original = builder.At(kLowCapacity + i); |
+ Handle<Object> original = builder.At(k8BitCapacity + i); |
CHECK(original->SameValue(*reference)); |
Handle<Object> duplicate = builder.At(i); |
CHECK(duplicate->SameValue(*isolate()->factory()->the_hole_value())); |