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( ...@@ -184,12 +184,11 @@ Runtime::FunctionId BytecodeArrayAccessor::GetIntrinsicIdOperand(
static_cast<IntrinsicsHelper::IntrinsicId>(raw_id)); static_cast<IntrinsicsHelper::IntrinsicId>(raw_id));
} }
Handle<Object> BytecodeArrayAccessor::GetConstantAtIndex(int index) const { Object* BytecodeArrayAccessor::GetConstantAtIndex(int index) const {
return FixedArray::get(bytecode_array()->constant_pool(), index, return bytecode_array()->constant_pool()->get(index);
bytecode_array()->GetIsolate());
} }
Handle<Object> BytecodeArrayAccessor::GetConstantForIndexOperand( Object* BytecodeArrayAccessor::GetConstantForIndexOperand(
int operand_index) const { int operand_index) const {
return GetConstantAtIndex(GetIndexOperand(operand_index)); return GetConstantAtIndex(GetIndexOperand(operand_index));
} }
...@@ -203,7 +202,7 @@ int BytecodeArrayAccessor::GetJumpTargetOffset() const { ...@@ -203,7 +202,7 @@ int BytecodeArrayAccessor::GetJumpTargetOffset() const {
} }
return GetAbsoluteOffset(relative_offset); return GetAbsoluteOffset(relative_offset);
} else if (interpreter::Bytecodes::IsJumpConstant(bytecode)) { } else if (interpreter::Bytecodes::IsJumpConstant(bytecode)) {
Smi* smi = Smi::cast(*GetConstantForIndexOperand(0)); Smi* smi = Smi::cast(GetConstantForIndexOperand(0));
return GetAbsoluteOffset(smi->value()); return GetAbsoluteOffset(smi->value());
} else { } else {
UNREACHABLE(); UNREACHABLE();
...@@ -273,6 +272,7 @@ JumpTableTargetOffsets::iterator::iterator( ...@@ -273,6 +272,7 @@ JumpTableTargetOffsets::iterator::iterator(
int case_value, int table_offset, int table_end, int case_value, int table_offset, int table_end,
const BytecodeArrayAccessor* accessor) const BytecodeArrayAccessor* accessor)
: accessor_(accessor), : accessor_(accessor),
current_(Smi::kZero),
index_(case_value), index_(case_value),
table_offset_(table_offset), table_offset_(table_offset),
table_end_(table_end) { table_end_(table_end) {
...@@ -281,8 +281,7 @@ JumpTableTargetOffsets::iterator::iterator( ...@@ -281,8 +281,7 @@ JumpTableTargetOffsets::iterator::iterator(
JumpTableTargetOffset JumpTableTargetOffsets::iterator::operator*() { JumpTableTargetOffset JumpTableTargetOffsets::iterator::operator*() {
DCHECK_LT(table_offset_, table_end_); 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:: JumpTableTargetOffsets::iterator& JumpTableTargetOffsets::iterator::
...@@ -305,13 +304,17 @@ bool JumpTableTargetOffsets::iterator::operator!=( ...@@ -305,13 +304,17 @@ bool JumpTableTargetOffsets::iterator::operator!=(
void JumpTableTargetOffsets::iterator::UpdateAndAdvanceToValid() { void JumpTableTargetOffsets::iterator::UpdateAndAdvanceToValid() {
if (table_offset_ >= table_end_) return; if (table_offset_ >= table_end_) return;
current_ = accessor_->GetConstantAtIndex(table_offset_); Object* current = accessor_->GetConstantAtIndex(table_offset_);
Isolate* isolate = accessor_->bytecode_array()->GetIsolate(); while (!current->IsSmi()) {
while (current_->IsTheHole(isolate)) { DCHECK(current->IsTheHole());
++table_offset_; ++table_offset_;
++index_; ++index_;
if (table_offset_ >= table_end_) break; 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 { ...@@ -42,7 +42,7 @@ class V8_EXPORT_PRIVATE JumpTableTargetOffsets final {
void UpdateAndAdvanceToValid(); void UpdateAndAdvanceToValid();
const BytecodeArrayAccessor* accessor_; const BytecodeArrayAccessor* accessor_;
Handle<Object> current_; Smi* current_;
int index_; int index_;
int table_offset_; int table_offset_;
int table_end_; int table_end_;
...@@ -90,8 +90,8 @@ class V8_EXPORT_PRIVATE BytecodeArrayAccessor { ...@@ -90,8 +90,8 @@ class V8_EXPORT_PRIVATE BytecodeArrayAccessor {
Runtime::FunctionId GetRuntimeIdOperand(int operand_index) const; Runtime::FunctionId GetRuntimeIdOperand(int operand_index) const;
Runtime::FunctionId GetIntrinsicIdOperand(int operand_index) const; Runtime::FunctionId GetIntrinsicIdOperand(int operand_index) const;
uint32_t GetNativeContextIndexOperand(int operand_index) const; uint32_t GetNativeContextIndexOperand(int operand_index) const;
Handle<Object> GetConstantAtIndex(int offset) const; Object* GetConstantAtIndex(int offset) const;
Handle<Object> GetConstantForIndexOperand(int operand_index) const; Object* GetConstantForIndexOperand(int operand_index) const;
// Returns the absolute offset of the branch target at the current bytecode. // 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 // 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) { ...@@ -630,7 +630,7 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) {
iterator.Advance(); iterator.Advance();
CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpConstant); CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpConstant);
CHECK_EQ(*iterator.GetConstantForIndexOperand(0), CHECK_EQ(iterator.GetConstantForIndexOperand(0),
Smi::FromInt(kFarJumpDistance)); Smi::FromInt(kFarJumpDistance));
iterator.Advance(); iterator.Advance();
...@@ -638,7 +638,7 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) { ...@@ -638,7 +638,7 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) {
iterator.Advance(); iterator.Advance();
CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpIfTrueConstant); CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpIfTrueConstant);
CHECK_EQ(*iterator.GetConstantForIndexOperand(0), CHECK_EQ(iterator.GetConstantForIndexOperand(0),
Smi::FromInt(kFarJumpDistance - 5)); Smi::FromInt(kFarJumpDistance - 5));
iterator.Advance(); iterator.Advance();
...@@ -646,7 +646,7 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) { ...@@ -646,7 +646,7 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) {
iterator.Advance(); iterator.Advance();
CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpIfFalseConstant); CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpIfFalseConstant);
CHECK_EQ(*iterator.GetConstantForIndexOperand(0), CHECK_EQ(iterator.GetConstantForIndexOperand(0),
Smi::FromInt(kFarJumpDistance - 10)); Smi::FromInt(kFarJumpDistance - 10));
iterator.Advance(); iterator.Advance();
...@@ -654,7 +654,7 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) { ...@@ -654,7 +654,7 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) {
iterator.Advance(); iterator.Advance();
CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpIfToBooleanTrueConstant); CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpIfToBooleanTrueConstant);
CHECK_EQ(*iterator.GetConstantForIndexOperand(0), CHECK_EQ(iterator.GetConstantForIndexOperand(0),
Smi::FromInt(kFarJumpDistance - 15)); Smi::FromInt(kFarJumpDistance - 15));
iterator.Advance(); iterator.Advance();
...@@ -663,7 +663,7 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) { ...@@ -663,7 +663,7 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) {
CHECK_EQ(iterator.current_bytecode(), CHECK_EQ(iterator.current_bytecode(),
Bytecode::kJumpIfToBooleanFalseConstant); Bytecode::kJumpIfToBooleanFalseConstant);
CHECK_EQ(*iterator.GetConstantForIndexOperand(0), CHECK_EQ(iterator.GetConstantForIndexOperand(0),
Smi::FromInt(kFarJumpDistance - 20)); Smi::FromInt(kFarJumpDistance - 20));
iterator.Advance(); 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