Commit f67e424d authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[GetIsolate] Return raw object for bytecode constants

Return the raw Object* when accessing the constant pool of bytecode
with the bytecode array accessor, to avoid needing an isolate there.
If the returned value needs to be a handle, we create the handle
later.

Bug: v8:7786
Change-Id: Ifeac2a06f0383230bf7e9bfc1b751d9750ecfb51
Reviewed-on: https://chromium-review.googlesource.com/1102334
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53784}
parent d9a5a48d
This diff is collapsed.
......@@ -184,12 +184,11 @@ Runtime::FunctionId BytecodeArrayAccessor::GetIntrinsicIdOperand(
static_cast<IntrinsicsHelper::IntrinsicId>(raw_id));
}
Handle<Object> BytecodeArrayAccessor::GetConstantAtIndex(int index) const {
return FixedArray::get(bytecode_array()->constant_pool(), index,
bytecode_array()->GetIsolate());
Object* BytecodeArrayAccessor::GetConstantAtIndex(int index) const {
return bytecode_array()->constant_pool()->get(index);
}
Handle<Object> BytecodeArrayAccessor::GetConstantForIndexOperand(
Object* BytecodeArrayAccessor::GetConstantForIndexOperand(
int operand_index) const {
return GetConstantAtIndex(GetIndexOperand(operand_index));
}
......@@ -203,7 +202,7 @@ int BytecodeArrayAccessor::GetJumpTargetOffset() const {
}
return GetAbsoluteOffset(relative_offset);
} else if (interpreter::Bytecodes::IsJumpConstant(bytecode)) {
Smi* smi = Smi::cast(*GetConstantForIndexOperand(0));
Smi* smi = Smi::cast(GetConstantForIndexOperand(0));
return GetAbsoluteOffset(smi->value());
} else {
UNREACHABLE();
......@@ -273,6 +272,7 @@ JumpTableTargetOffsets::iterator::iterator(
int case_value, int table_offset, int table_end,
const BytecodeArrayAccessor* accessor)
: accessor_(accessor),
current_(Smi::kZero),
index_(case_value),
table_offset_(table_offset),
table_end_(table_end) {
......@@ -281,8 +281,7 @@ JumpTableTargetOffsets::iterator::iterator(
JumpTableTargetOffset JumpTableTargetOffsets::iterator::operator*() {
DCHECK_LT(table_offset_, table_end_);
DCHECK(current_->IsSmi());
return {index_, accessor_->GetAbsoluteOffset(Smi::ToInt(*current_))};
return {index_, accessor_->GetAbsoluteOffset(Smi::ToInt(current_))};
}
JumpTableTargetOffsets::iterator& JumpTableTargetOffsets::iterator::
......@@ -305,13 +304,17 @@ bool JumpTableTargetOffsets::iterator::operator!=(
void JumpTableTargetOffsets::iterator::UpdateAndAdvanceToValid() {
if (table_offset_ >= table_end_) return;
current_ = accessor_->GetConstantAtIndex(table_offset_);
Isolate* isolate = accessor_->bytecode_array()->GetIsolate();
while (current_->IsTheHole(isolate)) {
Object* current = accessor_->GetConstantAtIndex(table_offset_);
while (!current->IsSmi()) {
DCHECK(current->IsTheHole());
++table_offset_;
++index_;
if (table_offset_ >= table_end_) break;
current_ = accessor_->GetConstantAtIndex(table_offset_);
current = accessor_->GetConstantAtIndex(table_offset_);
}
// Make sure we haven't reached the end of the table with a hole in current.
if (current->IsSmi()) {
current_ = Smi::cast(current);
}
}
......
......@@ -42,7 +42,7 @@ class V8_EXPORT_PRIVATE JumpTableTargetOffsets final {
void UpdateAndAdvanceToValid();
const BytecodeArrayAccessor* accessor_;
Handle<Object> current_;
Smi* current_;
int index_;
int table_offset_;
int table_end_;
......@@ -90,8 +90,8 @@ class V8_EXPORT_PRIVATE BytecodeArrayAccessor {
Runtime::FunctionId GetRuntimeIdOperand(int operand_index) const;
Runtime::FunctionId GetIntrinsicIdOperand(int operand_index) const;
uint32_t GetNativeContextIndexOperand(int operand_index) const;
Handle<Object> GetConstantAtIndex(int offset) const;
Handle<Object> GetConstantForIndexOperand(int operand_index) const;
Object* GetConstantAtIndex(int offset) const;
Object* GetConstantForIndexOperand(int operand_index) const;
// Returns the absolute offset of the branch target at the current bytecode.
// It is an error to call this method if the bytecode is not for a jump or
......
......@@ -630,7 +630,7 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) {
iterator.Advance();
CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpConstant);
CHECK_EQ(*iterator.GetConstantForIndexOperand(0),
CHECK_EQ(iterator.GetConstantForIndexOperand(0),
Smi::FromInt(kFarJumpDistance));
iterator.Advance();
......@@ -638,7 +638,7 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) {
iterator.Advance();
CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpIfTrueConstant);
CHECK_EQ(*iterator.GetConstantForIndexOperand(0),
CHECK_EQ(iterator.GetConstantForIndexOperand(0),
Smi::FromInt(kFarJumpDistance - 5));
iterator.Advance();
......@@ -646,7 +646,7 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) {
iterator.Advance();
CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpIfFalseConstant);
CHECK_EQ(*iterator.GetConstantForIndexOperand(0),
CHECK_EQ(iterator.GetConstantForIndexOperand(0),
Smi::FromInt(kFarJumpDistance - 10));
iterator.Advance();
......@@ -654,7 +654,7 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) {
iterator.Advance();
CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpIfToBooleanTrueConstant);
CHECK_EQ(*iterator.GetConstantForIndexOperand(0),
CHECK_EQ(iterator.GetConstantForIndexOperand(0),
Smi::FromInt(kFarJumpDistance - 15));
iterator.Advance();
......@@ -663,7 +663,7 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) {
CHECK_EQ(iterator.current_bytecode(),
Bytecode::kJumpIfToBooleanFalseConstant);
CHECK_EQ(*iterator.GetConstantForIndexOperand(0),
CHECK_EQ(iterator.GetConstantForIndexOperand(0),
Smi::FromInt(kFarJumpDistance - 20));
iterator.Advance();
}
......
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