Commit 7d4b5893 authored by Jaroslav Sevcik's avatar Jaroslav Sevcik Committed by Commit Bot

Handlify bytecode array accessor's constant getters.

This in in preparation for generic (off-heap/on-heap) bytecode
array accessor.

Bug: v8:7790
Change-Id: Ib419831ba1db95ab938179723ef5f130f01ae0d6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1635895
Commit-Queue: Jaroslav Sevcik <jarin@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62222}
parent b9591a58
...@@ -1333,7 +1333,7 @@ void BytecodeGraphBuilder::VisitLdaSmi() { ...@@ -1333,7 +1333,7 @@ void BytecodeGraphBuilder::VisitLdaSmi() {
void BytecodeGraphBuilder::VisitLdaConstant() { void BytecodeGraphBuilder::VisitLdaConstant() {
Node* node = jsgraph()->Constant( Node* node = jsgraph()->Constant(
handle(bytecode_iterator().GetConstantForIndexOperand(0), isolate())); bytecode_iterator().GetConstantForIndexOperand(0, isolate()));
environment()->BindAccumulator(node); environment()->BindAccumulator(node);
} }
...@@ -1390,8 +1390,8 @@ Node* BytecodeGraphBuilder::BuildLoadGlobal(Handle<Name> name, ...@@ -1390,8 +1390,8 @@ Node* BytecodeGraphBuilder::BuildLoadGlobal(Handle<Name> name,
void BytecodeGraphBuilder::VisitLdaGlobal() { void BytecodeGraphBuilder::VisitLdaGlobal() {
PrepareEagerCheckpoint(); PrepareEagerCheckpoint();
Handle<Name> name( Handle<Name> name = Handle<Name>::cast(
Name::cast(bytecode_iterator().GetConstantForIndexOperand(0)), isolate()); bytecode_iterator().GetConstantForIndexOperand(0, isolate()));
uint32_t feedback_slot_index = bytecode_iterator().GetIndexOperand(1); uint32_t feedback_slot_index = bytecode_iterator().GetIndexOperand(1);
Node* node = Node* node =
BuildLoadGlobal(name, feedback_slot_index, TypeofMode::NOT_INSIDE_TYPEOF); BuildLoadGlobal(name, feedback_slot_index, TypeofMode::NOT_INSIDE_TYPEOF);
...@@ -1400,8 +1400,8 @@ void BytecodeGraphBuilder::VisitLdaGlobal() { ...@@ -1400,8 +1400,8 @@ void BytecodeGraphBuilder::VisitLdaGlobal() {
void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeof() { void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeof() {
PrepareEagerCheckpoint(); PrepareEagerCheckpoint();
Handle<Name> name( Handle<Name> name = Handle<Name>::cast(
Name::cast(bytecode_iterator().GetConstantForIndexOperand(0)), isolate()); bytecode_iterator().GetConstantForIndexOperand(0, isolate()));
uint32_t feedback_slot_index = bytecode_iterator().GetIndexOperand(1); uint32_t feedback_slot_index = bytecode_iterator().GetIndexOperand(1);
Node* node = Node* node =
BuildLoadGlobal(name, feedback_slot_index, TypeofMode::INSIDE_TYPEOF); BuildLoadGlobal(name, feedback_slot_index, TypeofMode::INSIDE_TYPEOF);
...@@ -1410,8 +1410,8 @@ void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeof() { ...@@ -1410,8 +1410,8 @@ void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeof() {
void BytecodeGraphBuilder::VisitStaGlobal() { void BytecodeGraphBuilder::VisitStaGlobal() {
PrepareEagerCheckpoint(); PrepareEagerCheckpoint();
Handle<Name> name( Handle<Name> name = Handle<Name>::cast(
Name::cast(bytecode_iterator().GetConstantForIndexOperand(0)), isolate()); bytecode_iterator().GetConstantForIndexOperand(0, isolate()));
VectorSlotPair feedback = VectorSlotPair feedback =
CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1));
Node* value = environment()->LookupAccumulator(); Node* value = environment()->LookupAccumulator();
...@@ -1537,7 +1537,7 @@ void BytecodeGraphBuilder::VisitStaCurrentContextSlot() { ...@@ -1537,7 +1537,7 @@ void BytecodeGraphBuilder::VisitStaCurrentContextSlot() {
void BytecodeGraphBuilder::BuildLdaLookupSlot(TypeofMode typeof_mode) { void BytecodeGraphBuilder::BuildLdaLookupSlot(TypeofMode typeof_mode) {
PrepareEagerCheckpoint(); PrepareEagerCheckpoint();
Node* name = jsgraph()->Constant( Node* name = jsgraph()->Constant(
handle(bytecode_iterator().GetConstantForIndexOperand(0), isolate())); bytecode_iterator().GetConstantForIndexOperand(0, isolate()));
const Operator* op = const Operator* op =
javascript()->CallRuntime(typeof_mode == TypeofMode::NOT_INSIDE_TYPEOF javascript()->CallRuntime(typeof_mode == TypeofMode::NOT_INSIDE_TYPEOF
? Runtime::kLoadLookupSlot ? Runtime::kLoadLookupSlot
...@@ -1622,7 +1622,7 @@ void BytecodeGraphBuilder::BuildLdaLookupContextSlot(TypeofMode typeof_mode) { ...@@ -1622,7 +1622,7 @@ void BytecodeGraphBuilder::BuildLdaLookupContextSlot(TypeofMode typeof_mode) {
set_environment(slow_environment); set_environment(slow_environment);
{ {
Node* name = jsgraph()->Constant( Node* name = jsgraph()->Constant(
handle(bytecode_iterator().GetConstantForIndexOperand(0), isolate())); bytecode_iterator().GetConstantForIndexOperand(0, isolate()));
const Operator* op = const Operator* op =
javascript()->CallRuntime(typeof_mode == TypeofMode::NOT_INSIDE_TYPEOF javascript()->CallRuntime(typeof_mode == TypeofMode::NOT_INSIDE_TYPEOF
...@@ -1657,9 +1657,8 @@ void BytecodeGraphBuilder::BuildLdaLookupGlobalSlot(TypeofMode typeof_mode) { ...@@ -1657,9 +1657,8 @@ void BytecodeGraphBuilder::BuildLdaLookupGlobalSlot(TypeofMode typeof_mode) {
// Fast path, do a global load. // Fast path, do a global load.
{ {
PrepareEagerCheckpoint(); PrepareEagerCheckpoint();
Handle<Name> name( Handle<Name> name = Handle<Name>::cast(
Name::cast(bytecode_iterator().GetConstantForIndexOperand(0)), bytecode_iterator().GetConstantForIndexOperand(0, isolate()));
isolate());
uint32_t feedback_slot_index = bytecode_iterator().GetIndexOperand(1); uint32_t feedback_slot_index = bytecode_iterator().GetIndexOperand(1);
Node* node = BuildLoadGlobal(name, feedback_slot_index, typeof_mode); Node* node = BuildLoadGlobal(name, feedback_slot_index, typeof_mode);
environment()->BindAccumulator(node, Environment::kAttachFrameState); environment()->BindAccumulator(node, Environment::kAttachFrameState);
...@@ -1675,7 +1674,7 @@ void BytecodeGraphBuilder::BuildLdaLookupGlobalSlot(TypeofMode typeof_mode) { ...@@ -1675,7 +1674,7 @@ void BytecodeGraphBuilder::BuildLdaLookupGlobalSlot(TypeofMode typeof_mode) {
set_environment(slow_environment); set_environment(slow_environment);
{ {
Node* name = jsgraph()->Constant( Node* name = jsgraph()->Constant(
handle(bytecode_iterator().GetConstantForIndexOperand(0), isolate())); bytecode_iterator().GetConstantForIndexOperand(0, isolate()));
const Operator* op = const Operator* op =
javascript()->CallRuntime(typeof_mode == TypeofMode::NOT_INSIDE_TYPEOF javascript()->CallRuntime(typeof_mode == TypeofMode::NOT_INSIDE_TYPEOF
...@@ -1705,7 +1704,7 @@ void BytecodeGraphBuilder::VisitStaLookupSlot() { ...@@ -1705,7 +1704,7 @@ void BytecodeGraphBuilder::VisitStaLookupSlot() {
PrepareEagerCheckpoint(); PrepareEagerCheckpoint();
Node* value = environment()->LookupAccumulator(); Node* value = environment()->LookupAccumulator();
Node* name = jsgraph()->Constant( Node* name = jsgraph()->Constant(
handle(bytecode_iterator().GetConstantForIndexOperand(0), isolate())); bytecode_iterator().GetConstantForIndexOperand(0, isolate()));
int bytecode_flags = bytecode_iterator().GetFlagOperand(1); int bytecode_flags = bytecode_iterator().GetFlagOperand(1);
LanguageMode language_mode = static_cast<LanguageMode>( LanguageMode language_mode = static_cast<LanguageMode>(
interpreter::StoreLookupSlotFlags::LanguageModeBit::decode( interpreter::StoreLookupSlotFlags::LanguageModeBit::decode(
...@@ -1729,8 +1728,8 @@ void BytecodeGraphBuilder::VisitLdaNamedProperty() { ...@@ -1729,8 +1728,8 @@ void BytecodeGraphBuilder::VisitLdaNamedProperty() {
PrepareEagerCheckpoint(); PrepareEagerCheckpoint();
Node* object = Node* object =
environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
Handle<Name> name( Handle<Name> name = Handle<Name>::cast(
Name::cast(bytecode_iterator().GetConstantForIndexOperand(1)), isolate()); bytecode_iterator().GetConstantForIndexOperand(1, isolate()));
VectorSlotPair feedback = VectorSlotPair feedback =
CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2));
const Operator* op = javascript()->LoadNamed(name, feedback); const Operator* op = javascript()->LoadNamed(name, feedback);
...@@ -1753,8 +1752,8 @@ void BytecodeGraphBuilder::VisitLdaNamedPropertyNoFeedback() { ...@@ -1753,8 +1752,8 @@ void BytecodeGraphBuilder::VisitLdaNamedPropertyNoFeedback() {
PrepareEagerCheckpoint(); PrepareEagerCheckpoint();
Node* object = Node* object =
environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
Handle<Name> name( Handle<Name> name = Handle<Name>::cast(
Name::cast(bytecode_iterator().GetConstantForIndexOperand(1)), isolate()); bytecode_iterator().GetConstantForIndexOperand(1, isolate()));
const Operator* op = javascript()->LoadNamed(name, VectorSlotPair()); const Operator* op = javascript()->LoadNamed(name, VectorSlotPair());
Node* node = NewNode(op, object); Node* node = NewNode(op, object);
environment()->BindAccumulator(node, Environment::kAttachFrameState); environment()->BindAccumulator(node, Environment::kAttachFrameState);
...@@ -1788,8 +1787,8 @@ void BytecodeGraphBuilder::BuildNamedStore(StoreMode store_mode) { ...@@ -1788,8 +1787,8 @@ void BytecodeGraphBuilder::BuildNamedStore(StoreMode store_mode) {
Node* value = environment()->LookupAccumulator(); Node* value = environment()->LookupAccumulator();
Node* object = Node* object =
environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
Handle<Name> name( Handle<Name> name = Handle<Name>::cast(
Name::cast(bytecode_iterator().GetConstantForIndexOperand(1)), isolate()); bytecode_iterator().GetConstantForIndexOperand(1, isolate()));
VectorSlotPair feedback = VectorSlotPair feedback =
CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2));
...@@ -1828,8 +1827,8 @@ void BytecodeGraphBuilder::VisitStaNamedPropertyNoFeedback() { ...@@ -1828,8 +1827,8 @@ void BytecodeGraphBuilder::VisitStaNamedPropertyNoFeedback() {
Node* value = environment()->LookupAccumulator(); Node* value = environment()->LookupAccumulator();
Node* object = Node* object =
environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
Handle<Name> name( Handle<Name> name = Handle<Name>::cast(
Name::cast(bytecode_iterator().GetConstantForIndexOperand(1)), isolate()); bytecode_iterator().GetConstantForIndexOperand(1, isolate()));
LanguageMode language_mode = LanguageMode language_mode =
static_cast<LanguageMode>(bytecode_iterator().GetFlagOperand(2)); static_cast<LanguageMode>(bytecode_iterator().GetFlagOperand(2));
const Operator* op = const Operator* op =
...@@ -1902,10 +1901,8 @@ void BytecodeGraphBuilder::VisitPopContext() { ...@@ -1902,10 +1901,8 @@ void BytecodeGraphBuilder::VisitPopContext() {
} }
void BytecodeGraphBuilder::VisitCreateClosure() { void BytecodeGraphBuilder::VisitCreateClosure() {
Handle<SharedFunctionInfo> shared_info( Handle<SharedFunctionInfo> shared_info = Handle<SharedFunctionInfo>::cast(
SharedFunctionInfo::cast( bytecode_iterator().GetConstantForIndexOperand(0, isolate()));
bytecode_iterator().GetConstantForIndexOperand(0)),
isolate());
AllocationType allocation = AllocationType allocation =
interpreter::CreateClosureFlags::PretenuredBit::decode( interpreter::CreateClosureFlags::PretenuredBit::decode(
bytecode_iterator().GetFlagOperand(2)) bytecode_iterator().GetFlagOperand(2))
...@@ -1923,9 +1920,8 @@ void BytecodeGraphBuilder::VisitCreateClosure() { ...@@ -1923,9 +1920,8 @@ void BytecodeGraphBuilder::VisitCreateClosure() {
} }
void BytecodeGraphBuilder::VisitCreateBlockContext() { void BytecodeGraphBuilder::VisitCreateBlockContext() {
Handle<ScopeInfo> scope_info( Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(
ScopeInfo::cast(bytecode_iterator().GetConstantForIndexOperand(0)), bytecode_iterator().GetConstantForIndexOperand(0, isolate()));
isolate());
const Operator* op = javascript()->CreateBlockContext(scope_info); const Operator* op = javascript()->CreateBlockContext(scope_info);
Node* context = NewNode(op); Node* context = NewNode(op);
...@@ -1933,9 +1929,8 @@ void BytecodeGraphBuilder::VisitCreateBlockContext() { ...@@ -1933,9 +1929,8 @@ void BytecodeGraphBuilder::VisitCreateBlockContext() {
} }
void BytecodeGraphBuilder::VisitCreateFunctionContext() { void BytecodeGraphBuilder::VisitCreateFunctionContext() {
Handle<ScopeInfo> scope_info( Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(
ScopeInfo::cast(bytecode_iterator().GetConstantForIndexOperand(0)), bytecode_iterator().GetConstantForIndexOperand(0, isolate()));
isolate());
uint32_t slots = bytecode_iterator().GetUnsignedImmediateOperand(1); uint32_t slots = bytecode_iterator().GetUnsignedImmediateOperand(1);
const Operator* op = const Operator* op =
javascript()->CreateFunctionContext(scope_info, slots, FUNCTION_SCOPE); javascript()->CreateFunctionContext(scope_info, slots, FUNCTION_SCOPE);
...@@ -1944,9 +1939,8 @@ void BytecodeGraphBuilder::VisitCreateFunctionContext() { ...@@ -1944,9 +1939,8 @@ void BytecodeGraphBuilder::VisitCreateFunctionContext() {
} }
void BytecodeGraphBuilder::VisitCreateEvalContext() { void BytecodeGraphBuilder::VisitCreateEvalContext() {
Handle<ScopeInfo> scope_info( Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(
ScopeInfo::cast(bytecode_iterator().GetConstantForIndexOperand(0)), bytecode_iterator().GetConstantForIndexOperand(0, isolate()));
isolate());
uint32_t slots = bytecode_iterator().GetUnsignedImmediateOperand(1); uint32_t slots = bytecode_iterator().GetUnsignedImmediateOperand(1);
const Operator* op = const Operator* op =
javascript()->CreateFunctionContext(scope_info, slots, EVAL_SCOPE); javascript()->CreateFunctionContext(scope_info, slots, EVAL_SCOPE);
...@@ -1957,9 +1951,8 @@ void BytecodeGraphBuilder::VisitCreateEvalContext() { ...@@ -1957,9 +1951,8 @@ void BytecodeGraphBuilder::VisitCreateEvalContext() {
void BytecodeGraphBuilder::VisitCreateCatchContext() { void BytecodeGraphBuilder::VisitCreateCatchContext() {
interpreter::Register reg = bytecode_iterator().GetRegisterOperand(0); interpreter::Register reg = bytecode_iterator().GetRegisterOperand(0);
Node* exception = environment()->LookupRegister(reg); Node* exception = environment()->LookupRegister(reg);
Handle<ScopeInfo> scope_info( Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(
ScopeInfo::cast(bytecode_iterator().GetConstantForIndexOperand(1)), bytecode_iterator().GetConstantForIndexOperand(1, isolate()));
isolate());
const Operator* op = javascript()->CreateCatchContext(scope_info); const Operator* op = javascript()->CreateCatchContext(scope_info);
Node* context = NewNode(op, exception); Node* context = NewNode(op, exception);
...@@ -1969,9 +1962,8 @@ void BytecodeGraphBuilder::VisitCreateCatchContext() { ...@@ -1969,9 +1962,8 @@ void BytecodeGraphBuilder::VisitCreateCatchContext() {
void BytecodeGraphBuilder::VisitCreateWithContext() { void BytecodeGraphBuilder::VisitCreateWithContext() {
Node* object = Node* object =
environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
Handle<ScopeInfo> scope_info( Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(
ScopeInfo::cast(bytecode_iterator().GetConstantForIndexOperand(1)), bytecode_iterator().GetConstantForIndexOperand(1, isolate()));
isolate());
const Operator* op = javascript()->CreateWithContext(scope_info); const Operator* op = javascript()->CreateWithContext(scope_info);
Node* context = NewNode(op, object); Node* context = NewNode(op, object);
...@@ -1997,9 +1989,8 @@ void BytecodeGraphBuilder::VisitCreateRestParameter() { ...@@ -1997,9 +1989,8 @@ void BytecodeGraphBuilder::VisitCreateRestParameter() {
} }
void BytecodeGraphBuilder::VisitCreateRegExpLiteral() { void BytecodeGraphBuilder::VisitCreateRegExpLiteral() {
Handle<String> constant_pattern( Handle<String> constant_pattern = Handle<String>::cast(
String::cast(bytecode_iterator().GetConstantForIndexOperand(0)), bytecode_iterator().GetConstantForIndexOperand(0, isolate()));
isolate());
int const slot_id = bytecode_iterator().GetIndexOperand(1); int const slot_id = bytecode_iterator().GetIndexOperand(1);
VectorSlotPair pair = CreateVectorSlotPair(slot_id); VectorSlotPair pair = CreateVectorSlotPair(slot_id);
int literal_flags = bytecode_iterator().GetFlagOperand(2); int literal_flags = bytecode_iterator().GetFlagOperand(2);
...@@ -2009,10 +2000,9 @@ void BytecodeGraphBuilder::VisitCreateRegExpLiteral() { ...@@ -2009,10 +2000,9 @@ void BytecodeGraphBuilder::VisitCreateRegExpLiteral() {
} }
void BytecodeGraphBuilder::VisitCreateArrayLiteral() { void BytecodeGraphBuilder::VisitCreateArrayLiteral() {
Handle<ArrayBoilerplateDescription> array_boilerplate_description( Handle<ArrayBoilerplateDescription> array_boilerplate_description =
ArrayBoilerplateDescription::cast( Handle<ArrayBoilerplateDescription>::cast(
bytecode_iterator().GetConstantForIndexOperand(0)), bytecode_iterator().GetConstantForIndexOperand(0, isolate()));
isolate());
int const slot_id = bytecode_iterator().GetIndexOperand(1); int const slot_id = bytecode_iterator().GetIndexOperand(1);
VectorSlotPair pair = CreateVectorSlotPair(slot_id); VectorSlotPair pair = CreateVectorSlotPair(slot_id);
int bytecode_flags = bytecode_iterator().GetFlagOperand(2); int bytecode_flags = bytecode_iterator().GetFlagOperand(2);
...@@ -2046,10 +2036,9 @@ void BytecodeGraphBuilder::VisitCreateArrayFromIterable() { ...@@ -2046,10 +2036,9 @@ void BytecodeGraphBuilder::VisitCreateArrayFromIterable() {
} }
void BytecodeGraphBuilder::VisitCreateObjectLiteral() { void BytecodeGraphBuilder::VisitCreateObjectLiteral() {
Handle<ObjectBoilerplateDescription> constant_properties( Handle<ObjectBoilerplateDescription> constant_properties =
ObjectBoilerplateDescription::cast( Handle<ObjectBoilerplateDescription>::cast(
bytecode_iterator().GetConstantForIndexOperand(0)), bytecode_iterator().GetConstantForIndexOperand(0, isolate()));
isolate());
int const slot_id = bytecode_iterator().GetIndexOperand(1); int const slot_id = bytecode_iterator().GetIndexOperand(1);
VectorSlotPair pair = CreateVectorSlotPair(slot_id); VectorSlotPair pair = CreateVectorSlotPair(slot_id);
int bytecode_flags = bytecode_iterator().GetFlagOperand(2); int bytecode_flags = bytecode_iterator().GetFlagOperand(2);
...@@ -2082,10 +2071,9 @@ void BytecodeGraphBuilder::VisitCloneObject() { ...@@ -2082,10 +2071,9 @@ void BytecodeGraphBuilder::VisitCloneObject() {
} }
void BytecodeGraphBuilder::VisitGetTemplateObject() { void BytecodeGraphBuilder::VisitGetTemplateObject() {
Handle<TemplateObjectDescription> description( Handle<TemplateObjectDescription> description =
TemplateObjectDescription::cast( Handle<TemplateObjectDescription>::cast(
bytecode_iterator().GetConstantForIndexOperand(0)), bytecode_iterator().GetConstantForIndexOperand(0, isolate()));
isolate());
FeedbackSlot slot = bytecode_iterator().GetSlotOperand(1); FeedbackSlot slot = bytecode_iterator().GetSlotOperand(1);
FeedbackNexus nexus(feedback_vector(), slot); FeedbackNexus nexus(feedback_vector(), slot);
...@@ -2587,7 +2575,7 @@ void BytecodeGraphBuilder::VisitThrowReferenceErrorIfHole() { ...@@ -2587,7 +2575,7 @@ void BytecodeGraphBuilder::VisitThrowReferenceErrorIfHole() {
Node* check_for_hole = NewNode(simplified()->ReferenceEqual(), accumulator, Node* check_for_hole = NewNode(simplified()->ReferenceEqual(), accumulator,
jsgraph()->TheHoleConstant()); jsgraph()->TheHoleConstant());
Node* name = jsgraph()->Constant( Node* name = jsgraph()->Constant(
handle(bytecode_iterator().GetConstantForIndexOperand(0), isolate())); bytecode_iterator().GetConstantForIndexOperand(0, isolate()));
BuildHoleCheckAndThrow(check_for_hole, BuildHoleCheckAndThrow(check_for_hole,
Runtime::kThrowAccessedUninitializedVariable, name); Runtime::kThrowAccessedUninitializedVariable, name);
} }
......
...@@ -533,7 +533,7 @@ void SerializerForBackgroundCompilation::VisitLdaConstant( ...@@ -533,7 +533,7 @@ void SerializerForBackgroundCompilation::VisitLdaConstant(
BytecodeArrayIterator* iterator) { BytecodeArrayIterator* iterator) {
environment()->accumulator_hints().Clear(); environment()->accumulator_hints().Clear();
environment()->accumulator_hints().AddConstant( environment()->accumulator_hints().AddConstant(
handle(iterator->GetConstantForIndexOperand(0), broker()->isolate())); iterator->GetConstantForIndexOperand(0, broker()->isolate()));
} }
void SerializerForBackgroundCompilation::VisitLdar( void SerializerForBackgroundCompilation::VisitLdar(
...@@ -560,9 +560,8 @@ void SerializerForBackgroundCompilation::VisitMov( ...@@ -560,9 +560,8 @@ void SerializerForBackgroundCompilation::VisitMov(
void SerializerForBackgroundCompilation::VisitCreateClosure( void SerializerForBackgroundCompilation::VisitCreateClosure(
BytecodeArrayIterator* iterator) { BytecodeArrayIterator* iterator) {
Handle<SharedFunctionInfo> shared( Handle<SharedFunctionInfo> shared = Handle<SharedFunctionInfo>::cast(
SharedFunctionInfo::cast(iterator->GetConstantForIndexOperand(0)), iterator->GetConstantForIndexOperand(0, broker()->isolate()));
broker()->isolate());
Handle<FeedbackCell> feedback_cell = Handle<FeedbackCell> feedback_cell =
environment()->function().feedback_vector->GetClosureFeedbackCell( environment()->function().feedback_vector->GetClosureFeedbackCell(
...@@ -1242,8 +1241,8 @@ void SerializerForBackgroundCompilation::ProcessNamedPropertyAccess( ...@@ -1242,8 +1241,8 @@ void SerializerForBackgroundCompilation::ProcessNamedPropertyAccess(
BytecodeArrayIterator* iterator, AccessMode mode) { BytecodeArrayIterator* iterator, AccessMode mode) {
Hints const& receiver = Hints const& receiver =
environment()->register_hints(iterator->GetRegisterOperand(0)); environment()->register_hints(iterator->GetRegisterOperand(0));
Handle<Name> name(Name::cast(iterator->GetConstantForIndexOperand(1)), Handle<Name> name = Handle<Name>::cast(
broker()->isolate()); iterator->GetConstantForIndexOperand(1, broker()->isolate()));
FeedbackSlot slot = iterator->GetSlotOperand(2); FeedbackSlot slot = iterator->GetSlotOperand(2);
ProcessNamedPropertyAccess(receiver, NameRef(broker(), name), slot, mode); ProcessNamedPropertyAccess(receiver, NameRef(broker(), name), slot, mode);
} }
......
...@@ -197,13 +197,22 @@ Runtime::FunctionId BytecodeArrayAccessor::GetIntrinsicIdOperand( ...@@ -197,13 +197,22 @@ Runtime::FunctionId BytecodeArrayAccessor::GetIntrinsicIdOperand(
static_cast<IntrinsicsHelper::IntrinsicId>(raw_id)); static_cast<IntrinsicsHelper::IntrinsicId>(raw_id));
} }
Object BytecodeArrayAccessor::GetConstantAtIndex(int index) const { Handle<Object> BytecodeArrayAccessor::GetConstantAtIndex(
return bytecode_array()->constant_pool().get(index); int index, Isolate* isolate) const {
return handle(bytecode_array()->constant_pool().get(index), isolate);
} }
Object BytecodeArrayAccessor::GetConstantForIndexOperand( bool BytecodeArrayAccessor::IsConstantAtIndexSmi(int index) const {
int operand_index) const { return bytecode_array()->constant_pool().get(index).IsSmi();
return GetConstantAtIndex(GetIndexOperand(operand_index)); }
Smi BytecodeArrayAccessor::GetConstantAtIndexAsSmi(int index) const {
return Smi::cast(bytecode_array()->constant_pool().get(index));
}
Handle<Object> BytecodeArrayAccessor::GetConstantForIndexOperand(
int operand_index, Isolate* isolate) const {
return GetConstantAtIndex(GetIndexOperand(operand_index), isolate);
} }
int BytecodeArrayAccessor::GetJumpTargetOffset() const { int BytecodeArrayAccessor::GetJumpTargetOffset() const {
...@@ -215,7 +224,7 @@ int BytecodeArrayAccessor::GetJumpTargetOffset() const { ...@@ -215,7 +224,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 = GetConstantAtIndexAsSmi(GetIndexOperand(0));
return GetAbsoluteOffset(smi.value()); return GetAbsoluteOffset(smi.value());
} else { } else {
UNREACHABLE(); UNREACHABLE();
...@@ -315,19 +324,16 @@ bool JumpTableTargetOffsets::iterator::operator!=( ...@@ -315,19 +324,16 @@ bool JumpTableTargetOffsets::iterator::operator!=(
} }
void JumpTableTargetOffsets::iterator::UpdateAndAdvanceToValid() { void JumpTableTargetOffsets::iterator::UpdateAndAdvanceToValid() {
if (table_offset_ >= table_end_) return; while (table_offset_ < table_end_ &&
!accessor_->IsConstantAtIndexSmi(table_offset_)) {
Object current = accessor_->GetConstantAtIndex(table_offset_);
while (!current.IsSmi()) {
DCHECK(current.IsTheHole());
++table_offset_; ++table_offset_;
++index_; ++index_;
if (table_offset_ >= table_end_) break;
current = accessor_->GetConstantAtIndex(table_offset_);
} }
// Make sure we haven't reached the end of the table with a hole in current. // Make sure we haven't reached the end of the table with a hole in current.
if (current.IsSmi()) { if (table_offset_ < table_end_) {
current_ = Smi::cast(current); DCHECK(accessor_->IsConstantAtIndexSmi(table_offset_));
current_ = accessor_->GetConstantAtIndexAsSmi(table_offset_);
} }
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef V8_INTERPRETER_BYTECODE_ARRAY_ACCESSOR_H_ #ifndef V8_INTERPRETER_BYTECODE_ARRAY_ACCESSOR_H_
#define V8_INTERPRETER_BYTECODE_ARRAY_ACCESSOR_H_ #define V8_INTERPRETER_BYTECODE_ARRAY_ACCESSOR_H_
#include "src/base/optional.h"
#include "src/common/globals.h" #include "src/common/globals.h"
#include "src/handles/handles.h" #include "src/handles/handles.h"
#include "src/interpreter/bytecode-register.h" #include "src/interpreter/bytecode-register.h"
...@@ -93,8 +94,11 @@ class V8_EXPORT_PRIVATE BytecodeArrayAccessor { ...@@ -93,8 +94,11 @@ 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;
Object GetConstantAtIndex(int offset) const; Handle<Object> GetConstantAtIndex(int offset, Isolate* isolate) const;
Object GetConstantForIndexOperand(int operand_index) const; bool IsConstantAtIndexSmi(int offset) const;
Smi GetConstantAtIndexAsSmi(int offset) const;
Handle<Object> GetConstantForIndexOperand(int operand_index,
Isolate* isolate) 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
......
...@@ -650,7 +650,7 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) { ...@@ -650,7 +650,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, isolate())),
Smi::FromInt(kFarJumpDistance)); Smi::FromInt(kFarJumpDistance));
iterator.Advance(); iterator.Advance();
...@@ -658,7 +658,7 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) { ...@@ -658,7 +658,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, isolate())),
Smi::FromInt(kFarJumpDistance - 5)); Smi::FromInt(kFarJumpDistance - 5));
iterator.Advance(); iterator.Advance();
...@@ -666,7 +666,7 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) { ...@@ -666,7 +666,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, isolate())),
Smi::FromInt(kFarJumpDistance - 10)); Smi::FromInt(kFarJumpDistance - 10));
iterator.Advance(); iterator.Advance();
...@@ -674,7 +674,7 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) { ...@@ -674,7 +674,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, isolate())),
Smi::FromInt(kFarJumpDistance - 15)); Smi::FromInt(kFarJumpDistance - 15));
iterator.Advance(); iterator.Advance();
...@@ -683,7 +683,7 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) { ...@@ -683,7 +683,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, isolate())),
Smi::FromInt(kFarJumpDistance - 20)); Smi::FromInt(kFarJumpDistance - 20));
iterator.Advance(); iterator.Advance();
} }
......
...@@ -81,7 +81,8 @@ TEST_F(BytecodeArrayIteratorTest, IteratesBytecodeArray) { ...@@ -81,7 +81,8 @@ TEST_F(BytecodeArrayIteratorTest, IteratesBytecodeArray) {
EXPECT_EQ(iterator.current_bytecode(), Bytecode::kLdaConstant); EXPECT_EQ(iterator.current_bytecode(), Bytecode::kLdaConstant);
EXPECT_EQ(iterator.current_offset(), offset); EXPECT_EQ(iterator.current_offset(), offset);
EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle);
EXPECT_EQ(iterator.GetConstantForIndexOperand(0).Number(), heap_num_0); EXPECT_EQ(iterator.GetConstantForIndexOperand(0, isolate())->Number(),
heap_num_0);
CHECK(!iterator.done()); CHECK(!iterator.done());
offset += Bytecodes::Size(Bytecode::kLdaConstant, OperandScale::kSingle); offset += Bytecodes::Size(Bytecode::kLdaConstant, OperandScale::kSingle);
iterator.Advance(); iterator.Advance();
...@@ -98,7 +99,8 @@ TEST_F(BytecodeArrayIteratorTest, IteratesBytecodeArray) { ...@@ -98,7 +99,8 @@ TEST_F(BytecodeArrayIteratorTest, IteratesBytecodeArray) {
EXPECT_EQ(iterator.current_bytecode(), Bytecode::kLdaConstant); EXPECT_EQ(iterator.current_bytecode(), Bytecode::kLdaConstant);
EXPECT_EQ(iterator.current_offset(), offset); EXPECT_EQ(iterator.current_offset(), offset);
EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle);
EXPECT_EQ(iterator.GetConstantForIndexOperand(0).Number(), heap_num_1); EXPECT_EQ(iterator.GetConstantForIndexOperand(0, isolate())->Number(),
heap_num_1);
CHECK(!iterator.done()); CHECK(!iterator.done());
offset += Bytecodes::Size(Bytecode::kLdaConstant, OperandScale::kSingle); offset += Bytecodes::Size(Bytecode::kLdaConstant, OperandScale::kSingle);
iterator.Advance(); iterator.Advance();
......
...@@ -184,7 +184,8 @@ TEST_F(BytecodeArrayRandomIteratorTest, AccessesFirst) { ...@@ -184,7 +184,8 @@ TEST_F(BytecodeArrayRandomIteratorTest, AccessesFirst) {
EXPECT_EQ(iterator.current_index(), 0); EXPECT_EQ(iterator.current_index(), 0);
EXPECT_EQ(iterator.current_offset(), 0); EXPECT_EQ(iterator.current_offset(), 0);
EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle);
EXPECT_EQ(iterator.GetConstantForIndexOperand(0).Number(), heap_num_0); EXPECT_EQ(iterator.GetConstantForIndexOperand(0, isolate())->Number(),
heap_num_0);
ASSERT_TRUE(iterator.IsValid()); ASSERT_TRUE(iterator.IsValid());
} }
...@@ -331,7 +332,8 @@ TEST_F(BytecodeArrayRandomIteratorTest, RandomAccessValid) { ...@@ -331,7 +332,8 @@ TEST_F(BytecodeArrayRandomIteratorTest, RandomAccessValid) {
EXPECT_EQ(iterator.current_index(), 2); EXPECT_EQ(iterator.current_index(), 2);
EXPECT_EQ(iterator.current_offset(), offset); EXPECT_EQ(iterator.current_offset(), offset);
EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle);
EXPECT_EQ(iterator.GetConstantForIndexOperand(0).Number(), heap_num_1); EXPECT_EQ(iterator.GetConstantForIndexOperand(0, isolate())->Number(),
heap_num_1);
ASSERT_TRUE(iterator.IsValid()); ASSERT_TRUE(iterator.IsValid());
iterator.GoToIndex(18); iterator.GoToIndex(18);
...@@ -488,7 +490,8 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArray) { ...@@ -488,7 +490,8 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArray) {
EXPECT_EQ(iterator.current_index(), 0); EXPECT_EQ(iterator.current_index(), 0);
EXPECT_EQ(iterator.current_offset(), offset); EXPECT_EQ(iterator.current_offset(), offset);
EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle);
EXPECT_EQ(iterator.GetConstantForIndexOperand(0).Number(), heap_num_0); EXPECT_EQ(iterator.GetConstantForIndexOperand(0, isolate())->Number(),
heap_num_0);
ASSERT_TRUE(iterator.IsValid()); ASSERT_TRUE(iterator.IsValid());
offset += Bytecodes::Size(Bytecode::kLdaConstant, OperandScale::kSingle); offset += Bytecodes::Size(Bytecode::kLdaConstant, OperandScale::kSingle);
++iterator; ++iterator;
...@@ -507,7 +510,8 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArray) { ...@@ -507,7 +510,8 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArray) {
EXPECT_EQ(iterator.current_index(), 2); EXPECT_EQ(iterator.current_index(), 2);
EXPECT_EQ(iterator.current_offset(), offset); EXPECT_EQ(iterator.current_offset(), offset);
EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle);
EXPECT_EQ(iterator.GetConstantForIndexOperand(0).Number(), heap_num_1); EXPECT_EQ(iterator.GetConstantForIndexOperand(0, isolate())->Number(),
heap_num_1);
ASSERT_TRUE(iterator.IsValid()); ASSERT_TRUE(iterator.IsValid());
offset += Bytecodes::Size(Bytecode::kLdaConstant, OperandScale::kSingle); offset += Bytecodes::Size(Bytecode::kLdaConstant, OperandScale::kSingle);
++iterator; ++iterator;
...@@ -968,7 +972,8 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArrayBackwards) { ...@@ -968,7 +972,8 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArrayBackwards) {
EXPECT_EQ(iterator.current_index(), 2); EXPECT_EQ(iterator.current_index(), 2);
EXPECT_EQ(iterator.current_offset(), offset); EXPECT_EQ(iterator.current_offset(), offset);
EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle);
EXPECT_EQ(iterator.GetConstantForIndexOperand(0).Number(), heap_num_1); EXPECT_EQ(iterator.GetConstantForIndexOperand(0, isolate())->Number(),
heap_num_1);
ASSERT_TRUE(iterator.IsValid()); ASSERT_TRUE(iterator.IsValid());
--iterator; --iterator;
...@@ -987,7 +992,8 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArrayBackwards) { ...@@ -987,7 +992,8 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArrayBackwards) {
EXPECT_EQ(iterator.current_index(), 0); EXPECT_EQ(iterator.current_index(), 0);
EXPECT_EQ(iterator.current_offset(), offset); EXPECT_EQ(iterator.current_offset(), offset);
EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle); EXPECT_EQ(iterator.current_operand_scale(), OperandScale::kSingle);
EXPECT_EQ(iterator.GetConstantForIndexOperand(0).Number(), heap_num_0); EXPECT_EQ(iterator.GetConstantForIndexOperand(0, isolate())->Number(),
heap_num_0);
ASSERT_TRUE(iterator.IsValid()); ASSERT_TRUE(iterator.IsValid());
--iterator; --iterator;
ASSERT_FALSE(iterator.IsValid()); ASSERT_FALSE(iterator.IsValid());
......
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