Commit 1f506030 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[interpreter] Simplify ConstantArrayBuilder interface a bit.

R=oth@chromium.org

Review URL: https://codereview.chromium.org/1608693004

Cr-Commit-Position: refs/heads/master@{#33401}
parent 82716f1c
......@@ -150,13 +150,11 @@ Handle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray() {
int bytecode_size = static_cast<int>(bytecodes_.size());
int register_count = fixed_register_count() + temporary_register_count_;
int frame_size = register_count * kPointerSize;
Factory* factory = isolate_->factory();
Handle<FixedArray> constant_pool =
constant_array_builder()->ToFixedArray(factory);
Handle<FixedArray> constant_pool = constant_array_builder()->ToFixedArray();
Handle<FixedArray> handler_table = handler_table_builder()->ToHandlerTable();
Handle<BytecodeArray> output =
factory->NewBytecodeArray(bytecode_size, &bytecodes_.front(), frame_size,
parameter_count(), constant_pool);
Handle<BytecodeArray> output = isolate_->factory()->NewBytecodeArray(
bytecode_size, &bytecodes_.front(), frame_size, parameter_count(),
constant_pool);
output->set_handler_table(*handler_table);
bytecode_generated_ = true;
return output;
......
......@@ -86,9 +86,9 @@ Handle<Object> ConstantArrayBuilder::At(size_t index) const {
}
Handle<FixedArray> ConstantArrayBuilder::ToFixedArray(Factory* factory) const {
Handle<FixedArray> fixed_array =
factory->NewFixedArray(static_cast<int>(size()), PretenureFlag::TENURED);
Handle<FixedArray> ConstantArrayBuilder::ToFixedArray() const {
Handle<FixedArray> fixed_array = isolate_->factory()->NewFixedArray(
static_cast<int>(size()), PretenureFlag::TENURED);
for (int i = 0; i < fixed_array->length(); i++) {
fixed_array->set(i, *At(static_cast<size_t>(i)));
}
......
......@@ -12,7 +12,6 @@
namespace v8 {
namespace internal {
class Factory;
class Isolate;
namespace interpreter {
......@@ -32,7 +31,7 @@ class ConstantArrayBuilder final : public ZoneObject {
ConstantArrayBuilder(Isolate* isolate, Zone* zone);
// Generate a fixed array of constants based on inserted objects.
Handle<FixedArray> ToFixedArray(Factory* factory) const;
Handle<FixedArray> ToFixedArray() const;
// Returns the object in the constant pool array that at index
// |index|.
......
......@@ -158,8 +158,7 @@ TEST_F(ConstantArrayBuilderTest, ToFixedArray) {
builder.Insert(object);
CHECK(builder.At(i)->SameValue(*object));
}
Handle<FixedArray> constant_array =
builder.ToFixedArray(isolate()->factory());
Handle<FixedArray> constant_array = builder.ToFixedArray();
CHECK_EQ(constant_array->length(), kNumberOfElements);
for (size_t i = 0; i < kNumberOfElements; i++) {
CHECK(constant_array->get(static_cast<int>(i))->SameValue(*builder.At(i)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment