Commit c6a8832e authored by Leszek Swirski's avatar Leszek Swirski Committed by V8 LUCI CQ

[turbofan] DCHECK that lookups have a slow path

LdaLookupGlobal/ContextSlot loop over parent contexts to check for
context extensions. If there aren't any, they can do a fast
context/global load, otherwise they have to call a runtime slow path.

The bytecode graph builder didn't build a slow path in the case where no
context extensions are possible, by depth == 0 or static scope info
information that there are no possible context extensions. However, this
information is already known to the interpreter, so that should already
elide the lookup in these cases. So, get rid of the slow path being
optional in TurboFan, and consider such cases bytecode generation bugs.

Change-Id: Ib69f90e51b0f783306824fed56911d039f7e134e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3872277
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Nico Hartmann <nicohartmann@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82972}
parent 007862bf
......@@ -1831,9 +1831,9 @@ BytecodeGraphBuilder::Environment* BytecodeGraphBuilder::CheckContextExtensions(
}
}
// The depth can be zero, in which case no slow-path checks are built, and
// the slow path environment can be null.
DCHECK_IMPLIES(slow_environment == nullptr, depth == 0);
// There should have been at least one slow path generated, otherwise we could
// have already skipped the lookup in the bytecode.
DCHECK_NOT_NULL(slow_environment);
return slow_environment;
}
......@@ -1864,9 +1864,9 @@ BytecodeGraphBuilder::CheckContextExtensionsSlowPath(uint32_t depth) {
// the fast path.
}
// The depth can be zero, in which case no slow-path checks are built, and
// the slow path environment can be null.
DCHECK_IMPLIES(slow_environment == nullptr, depth == 0);
// There should have been at least one slow path generated, otherwise we could
// have already skipped the lookup in the bytecode.
DCHECK_NOT_NULL(slow_environment);
return slow_environment;
}
......@@ -1884,31 +1884,28 @@ void BytecodeGraphBuilder::BuildLdaLookupContextSlot(TypeofMode typeof_mode) {
environment()->BindAccumulator(NewNode(op));
}
// Only build the slow path if there were any slow-path checks.
if (slow_environment != nullptr) {
// Add a merge to the fast environment.
NewMerge();
Environment* fast_environment = environment();
// Add a merge to the fast environment.
NewMerge();
Environment* fast_environment = environment();
// Slow path, do a runtime load lookup.
set_environment(slow_environment);
{
Node* name = jsgraph()->Constant(MakeRefForConstantForIndexOperand(0));
const Operator* op =
javascript()->CallRuntime(typeof_mode == TypeofMode::kNotInside
? Runtime::kLoadLookupSlot
: Runtime::kLoadLookupSlotInsideTypeof);
Node* value = NewNode(op, name);
environment()->BindAccumulator(value, Environment::kAttachFrameState);
}
// Slow path, do a runtime load lookup.
set_environment(slow_environment);
{
Node* name = jsgraph()->Constant(MakeRefForConstantForIndexOperand(0));
fast_environment->Merge(environment(),
bytecode_analysis().GetOutLivenessFor(
bytecode_iterator().current_offset()));
set_environment(fast_environment);
mark_as_needing_eager_checkpoint(true);
const Operator* op =
javascript()->CallRuntime(typeof_mode == TypeofMode::kNotInside
? Runtime::kLoadLookupSlot
: Runtime::kLoadLookupSlotInsideTypeof);
Node* value = NewNode(op, name);
environment()->BindAccumulator(value, Environment::kAttachFrameState);
}
fast_environment->Merge(environment(),
bytecode_analysis().GetOutLivenessFor(
bytecode_iterator().current_offset()));
set_environment(fast_environment);
mark_as_needing_eager_checkpoint(true);
}
void BytecodeGraphBuilder::VisitLdaLookupContextSlot() {
......@@ -1934,32 +1931,29 @@ void BytecodeGraphBuilder::BuildLdaLookupGlobalSlot(TypeofMode typeof_mode) {
environment()->BindAccumulator(node, Environment::kAttachFrameState);
}
// Only build the slow path if there were any slow-path checks.
if (slow_environment != nullptr) {
// Add a merge to the fast environment.
NewMerge();
Environment* fast_environment = environment();
// Slow path, do a runtime load lookup.
set_environment(slow_environment);
{
Node* name =
jsgraph()->Constant(MakeRefForConstantForIndexOperand<Name>(0));
const Operator* op =
javascript()->CallRuntime(typeof_mode == TypeofMode::kNotInside
? Runtime::kLoadLookupSlot
: Runtime::kLoadLookupSlotInsideTypeof);
Node* value = NewNode(op, name);
environment()->BindAccumulator(value, Environment::kAttachFrameState);
}
// Add a merge to the fast environment.
NewMerge();
Environment* fast_environment = environment();
fast_environment->Merge(environment(),
bytecode_analysis().GetOutLivenessFor(
bytecode_iterator().current_offset()));
set_environment(fast_environment);
mark_as_needing_eager_checkpoint(true);
// Slow path, do a runtime load lookup.
set_environment(slow_environment);
{
Node* name =
jsgraph()->Constant(MakeRefForConstantForIndexOperand<Name>(0));
const Operator* op =
javascript()->CallRuntime(typeof_mode == TypeofMode::kNotInside
? Runtime::kLoadLookupSlot
: Runtime::kLoadLookupSlotInsideTypeof);
Node* value = NewNode(op, name);
environment()->BindAccumulator(value, Environment::kAttachFrameState);
}
fast_environment->Merge(environment(),
bytecode_analysis().GetOutLivenessFor(
bytecode_iterator().current_offset()));
set_environment(fast_environment);
mark_as_needing_eager_checkpoint(true);
}
void BytecodeGraphBuilder::VisitLdaLookupGlobalSlot() {
......
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