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
......@@ -918,8 +918,8 @@ void BytecodeGraphBuilder::VisitLdaSmi() {
}
void BytecodeGraphBuilder::VisitLdaConstant() {
Node* node =
jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0));
Node* node = jsgraph()->Constant(
handle(bytecode_iterator().GetConstantForIndexOperand(0), isolate()));
environment()->BindAccumulator(node);
}
......@@ -976,8 +976,8 @@ Node* BytecodeGraphBuilder::BuildLoadGlobal(Handle<Name> name,
void BytecodeGraphBuilder::VisitLdaGlobal() {
PrepareEagerCheckpoint();
Handle<Name> name =
Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0));
Handle<Name> name(
Name::cast(bytecode_iterator().GetConstantForIndexOperand(0)), isolate());
uint32_t feedback_slot_index = bytecode_iterator().GetIndexOperand(1);
Node* node =
BuildLoadGlobal(name, feedback_slot_index, TypeofMode::NOT_INSIDE_TYPEOF);
......@@ -986,8 +986,8 @@ void BytecodeGraphBuilder::VisitLdaGlobal() {
void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeof() {
PrepareEagerCheckpoint();
Handle<Name> name =
Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0));
Handle<Name> name(
Name::cast(bytecode_iterator().GetConstantForIndexOperand(0)), isolate());
uint32_t feedback_slot_index = bytecode_iterator().GetIndexOperand(1);
Node* node =
BuildLoadGlobal(name, feedback_slot_index, TypeofMode::INSIDE_TYPEOF);
......@@ -996,8 +996,8 @@ void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeof() {
void BytecodeGraphBuilder::VisitStaGlobal() {
PrepareEagerCheckpoint();
Handle<Name> name =
Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0));
Handle<Name> name(
Name::cast(bytecode_iterator().GetConstantForIndexOperand(0)), isolate());
VectorSlotPair feedback =
CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1));
Node* value = environment()->LookupAccumulator();
......@@ -1122,8 +1122,8 @@ void BytecodeGraphBuilder::VisitStaCurrentContextSlot() {
void BytecodeGraphBuilder::BuildLdaLookupSlot(TypeofMode typeof_mode) {
PrepareEagerCheckpoint();
Node* name =
jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0));
Node* name = jsgraph()->Constant(
handle(bytecode_iterator().GetConstantForIndexOperand(0), isolate()));
const Operator* op =
javascript()->CallRuntime(typeof_mode == TypeofMode::NOT_INSIDE_TYPEOF
? Runtime::kLoadLookupSlot
......@@ -1208,7 +1208,7 @@ void BytecodeGraphBuilder::BuildLdaLookupContextSlot(TypeofMode typeof_mode) {
set_environment(slow_environment);
{
Node* name = jsgraph()->Constant(
bytecode_iterator().GetConstantForIndexOperand(0));
handle(bytecode_iterator().GetConstantForIndexOperand(0), isolate()));
const Operator* op =
javascript()->CallRuntime(typeof_mode == TypeofMode::NOT_INSIDE_TYPEOF
......@@ -1243,8 +1243,9 @@ void BytecodeGraphBuilder::BuildLdaLookupGlobalSlot(TypeofMode typeof_mode) {
// Fast path, do a global load.
{
PrepareEagerCheckpoint();
Handle<Name> name =
Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0));
Handle<Name> name(
Name::cast(bytecode_iterator().GetConstantForIndexOperand(0)),
isolate());
uint32_t feedback_slot_index = bytecode_iterator().GetIndexOperand(1);
Node* node = BuildLoadGlobal(name, feedback_slot_index, typeof_mode);
environment()->BindAccumulator(node, Environment::kAttachFrameState);
......@@ -1260,7 +1261,7 @@ void BytecodeGraphBuilder::BuildLdaLookupGlobalSlot(TypeofMode typeof_mode) {
set_environment(slow_environment);
{
Node* name = jsgraph()->Constant(
bytecode_iterator().GetConstantForIndexOperand(0));
handle(bytecode_iterator().GetConstantForIndexOperand(0), isolate()));
const Operator* op =
javascript()->CallRuntime(typeof_mode == TypeofMode::NOT_INSIDE_TYPEOF
......@@ -1289,8 +1290,8 @@ void BytecodeGraphBuilder::VisitLdaLookupGlobalSlotInsideTypeof() {
void BytecodeGraphBuilder::VisitStaLookupSlot() {
PrepareEagerCheckpoint();
Node* value = environment()->LookupAccumulator();
Node* name =
jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0));
Node* name = jsgraph()->Constant(
handle(bytecode_iterator().GetConstantForIndexOperand(0), isolate()));
int bytecode_flags = bytecode_iterator().GetFlagOperand(1);
LanguageMode language_mode = static_cast<LanguageMode>(
interpreter::StoreLookupSlotFlags::LanguageModeBit::decode(
......@@ -1314,8 +1315,8 @@ void BytecodeGraphBuilder::VisitLdaNamedProperty() {
PrepareEagerCheckpoint();
Node* object =
environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
Handle<Name> name =
Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(1));
Handle<Name> name(
Name::cast(bytecode_iterator().GetConstantForIndexOperand(1)), isolate());
VectorSlotPair feedback =
CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2));
const Operator* op = javascript()->LoadNamed(name, feedback);
......@@ -1362,8 +1363,8 @@ void BytecodeGraphBuilder::BuildNamedStore(StoreMode store_mode) {
Node* value = environment()->LookupAccumulator();
Node* object =
environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
Handle<Name> name =
Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(1));
Handle<Name> name(
Name::cast(bytecode_iterator().GetConstantForIndexOperand(1)), isolate());
VectorSlotPair feedback =
CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2));
......@@ -1461,8 +1462,10 @@ void BytecodeGraphBuilder::VisitPopContext() {
}
void BytecodeGraphBuilder::VisitCreateClosure() {
Handle<SharedFunctionInfo> shared_info = Handle<SharedFunctionInfo>::cast(
bytecode_iterator().GetConstantForIndexOperand(0));
Handle<SharedFunctionInfo> shared_info(
SharedFunctionInfo::cast(
bytecode_iterator().GetConstantForIndexOperand(0)),
isolate());
FeedbackSlot slot = bytecode_iterator().GetSlotOperand(1);
FeedbackNexus nexus(feedback_vector(), slot);
PretenureFlag tenured =
......@@ -1480,8 +1483,9 @@ void BytecodeGraphBuilder::VisitCreateClosure() {
}
void BytecodeGraphBuilder::VisitCreateBlockContext() {
Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(
bytecode_iterator().GetConstantForIndexOperand(0));
Handle<ScopeInfo> scope_info(
ScopeInfo::cast(bytecode_iterator().GetConstantForIndexOperand(0)),
isolate());
const Operator* op = javascript()->CreateBlockContext(scope_info);
Node* context = NewNode(op);
......@@ -1489,8 +1493,9 @@ void BytecodeGraphBuilder::VisitCreateBlockContext() {
}
void BytecodeGraphBuilder::VisitCreateFunctionContext() {
Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(
bytecode_iterator().GetConstantForIndexOperand(0));
Handle<ScopeInfo> scope_info(
ScopeInfo::cast(bytecode_iterator().GetConstantForIndexOperand(0)),
isolate());
uint32_t slots = bytecode_iterator().GetUnsignedImmediateOperand(1);
const Operator* op =
javascript()->CreateFunctionContext(scope_info, slots, FUNCTION_SCOPE);
......@@ -1499,8 +1504,9 @@ void BytecodeGraphBuilder::VisitCreateFunctionContext() {
}
void BytecodeGraphBuilder::VisitCreateEvalContext() {
Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(
bytecode_iterator().GetConstantForIndexOperand(0));
Handle<ScopeInfo> scope_info(
ScopeInfo::cast(bytecode_iterator().GetConstantForIndexOperand(0)),
isolate());
uint32_t slots = bytecode_iterator().GetUnsignedImmediateOperand(1);
const Operator* op =
javascript()->CreateFunctionContext(scope_info, slots, EVAL_SCOPE);
......@@ -1511,8 +1517,9 @@ void BytecodeGraphBuilder::VisitCreateEvalContext() {
void BytecodeGraphBuilder::VisitCreateCatchContext() {
interpreter::Register reg = bytecode_iterator().GetRegisterOperand(0);
Node* exception = environment()->LookupRegister(reg);
Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(
bytecode_iterator().GetConstantForIndexOperand(1));
Handle<ScopeInfo> scope_info(
ScopeInfo::cast(bytecode_iterator().GetConstantForIndexOperand(1)),
isolate());
const Operator* op = javascript()->CreateCatchContext(scope_info);
Node* context = NewNode(op, exception);
......@@ -1522,8 +1529,9 @@ void BytecodeGraphBuilder::VisitCreateCatchContext() {
void BytecodeGraphBuilder::VisitCreateWithContext() {
Node* object =
environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(
bytecode_iterator().GetConstantForIndexOperand(1));
Handle<ScopeInfo> scope_info(
ScopeInfo::cast(bytecode_iterator().GetConstantForIndexOperand(1)),
isolate());
const Operator* op = javascript()->CreateWithContext(scope_info);
Node* context = NewNode(op, object);
......@@ -1549,8 +1557,9 @@ void BytecodeGraphBuilder::VisitCreateRestParameter() {
}
void BytecodeGraphBuilder::VisitCreateRegExpLiteral() {
Handle<String> constant_pattern =
Handle<String>::cast(bytecode_iterator().GetConstantForIndexOperand(0));
Handle<String> constant_pattern(
String::cast(bytecode_iterator().GetConstantForIndexOperand(0)),
isolate());
int const slot_id = bytecode_iterator().GetIndexOperand(1);
VectorSlotPair pair = CreateVectorSlotPair(slot_id);
int literal_flags = bytecode_iterator().GetFlagOperand(2);
......@@ -1560,9 +1569,10 @@ void BytecodeGraphBuilder::VisitCreateRegExpLiteral() {
}
void BytecodeGraphBuilder::VisitCreateArrayLiteral() {
Handle<ConstantElementsPair> constant_elements =
Handle<ConstantElementsPair>::cast(
bytecode_iterator().GetConstantForIndexOperand(0));
Handle<ConstantElementsPair> constant_elements(
ConstantElementsPair::cast(
bytecode_iterator().GetConstantForIndexOperand(0)),
isolate());
int const slot_id = bytecode_iterator().GetIndexOperand(1);
VectorSlotPair pair = CreateVectorSlotPair(slot_id);
int bytecode_flags = bytecode_iterator().GetFlagOperand(2);
......@@ -1589,9 +1599,10 @@ void BytecodeGraphBuilder::VisitCreateEmptyArrayLiteral() {
}
void BytecodeGraphBuilder::VisitCreateObjectLiteral() {
Handle<BoilerplateDescription> constant_properties =
Handle<BoilerplateDescription>::cast(
bytecode_iterator().GetConstantForIndexOperand(0));
Handle<BoilerplateDescription> constant_properties(
BoilerplateDescription::cast(
bytecode_iterator().GetConstantForIndexOperand(0)),
isolate());
int const slot_id = bytecode_iterator().GetIndexOperand(1);
VectorSlotPair pair = CreateVectorSlotPair(slot_id);
int bytecode_flags = bytecode_iterator().GetFlagOperand(2);
......@@ -1613,9 +1624,10 @@ void BytecodeGraphBuilder::VisitCreateEmptyObjectLiteral() {
}
void BytecodeGraphBuilder::VisitGetTemplateObject() {
Handle<TemplateObjectDescription> description =
Handle<TemplateObjectDescription>::cast(
bytecode_iterator().GetConstantForIndexOperand(0));
Handle<TemplateObjectDescription> description(
TemplateObjectDescription::cast(
bytecode_iterator().GetConstantForIndexOperand(0)),
isolate());
FeedbackSlot slot = bytecode_iterator().GetSlotOperand(1);
FeedbackNexus nexus(feedback_vector(), slot);
......@@ -2084,8 +2096,8 @@ void BytecodeGraphBuilder::VisitThrowReferenceErrorIfHole() {
Node* accumulator = environment()->LookupAccumulator();
Node* check_for_hole = NewNode(simplified()->ReferenceEqual(), accumulator,
jsgraph()->TheHoleConstant());
Node* name =
jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0));
Node* name = jsgraph()->Constant(
handle(bytecode_iterator().GetConstantForIndexOperand(0), isolate()));
BuildHoleCheckAndThrow(check_for_hole, Runtime::kThrowReferenceError, name);
}
......
......@@ -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