Skip to content

Commit 6054ba9

Browse files
verwaestV8 LUCI CQ
authored andcommitted
[scopes] Drop dead hidden catch scope code
Change-Id: If38698e5c20dabdbebe5c03aed88452a86588fe8 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6010587 Reviewed-by: Leszek Swirski <[email protected]> Commit-Queue: Toon Verwaest <[email protected]> Auto-Submit: Toon Verwaest <[email protected]> Cr-Commit-Position: refs/heads/main@{#97085}
1 parent e2a8fba commit 6054ba9

File tree

7 files changed

+6
-43
lines changed

7 files changed

+6
-43
lines changed

src/ast/scopes.cc

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2574,7 +2574,6 @@ void ModuleScope::AllocateModuleVariables() {
25742574
// Needs to be kept in sync with ScopeInfo::UniqueIdInScript and
25752575
// SharedFunctionInfo::UniqueIdInScript.
25762576
int Scope::UniqueIdInScript() const {
2577-
DCHECK(!is_hidden_catch_scope());
25782577
// Script scopes start "before" the script to avoid clashing with a scope that
25792578
// starts on character 0.
25802579
if (is_script_scope() || scope_type() == EVAL_SCOPE ||
@@ -2652,17 +2651,14 @@ void Scope::AllocateScopeInfosRecursively(
26522651
DCHECK(scope_info_.is_null());
26532652
MaybeHandle<ScopeInfo> next_outer_scope = outer_scope;
26542653

2655-
auto it = is_hidden_catch_scope()
2656-
? scope_infos_to_reuse.end()
2657-
: scope_infos_to_reuse.find(UniqueIdInScript());
2654+
auto it = scope_infos_to_reuse.find(UniqueIdInScript());
26582655
if (it != scope_infos_to_reuse.end()) {
26592656
scope_info_ = it->second;
26602657
CHECK(NeedsContext());
26612658
// The ScopeInfo chain mirrors the context chain, so we only link to the
26622659
// next outer scope that needs a context.
26632660
next_outer_scope = scope_info_;
26642661
DCHECK(!scope_info_.is_null());
2665-
DCHECK(!is_hidden_catch_scope());
26662662
CHECK_EQ(scope_info_->scope_type(), scope_type_);
26672663
CHECK_EQ(scope_info_->ContextLength(), num_heap_slots_);
26682664
#ifdef DEBUG
@@ -2672,9 +2668,8 @@ void Scope::AllocateScopeInfosRecursively(
26722668
} else if (NeedsScopeInfo()) {
26732669
scope_info_ = ScopeInfo::Create(isolate, zone(), this, outer_scope);
26742670
#ifdef DEBUG
2675-
// Mark this ID as being used. Skip hidden scopes because they are
2676-
// synthetic, unreusable, but hard to make unique.
2677-
if (v8_flags.reuse_scope_infos && !is_hidden_catch_scope()) {
2671+
// Mark this ID as being used.
2672+
if (v8_flags.reuse_scope_infos) {
26782673
scope_infos_to_reuse[UniqueIdInScript()] = {};
26792674
DCHECK_EQ(UniqueIdInScript(), scope_info_->UniqueIdInScript());
26802675
}
@@ -2687,12 +2682,9 @@ void Scope::AllocateScopeInfosRecursively(
26872682
// Allocate ScopeInfos for inner scopes.
26882683
for (Scope* scope = inner_scope_; scope != nullptr; scope = scope->sibling_) {
26892684
#ifdef DEBUG
2690-
if (!scope->is_hidden_catch_scope()) {
2691-
DCHECK_GT(scope->UniqueIdInScript(), UniqueIdInScript());
2692-
DCHECK_IMPLIES(
2693-
scope->sibling_ && !scope->sibling_->is_hidden_catch_scope(),
2694-
scope->sibling_->UniqueIdInScript() != scope->UniqueIdInScript());
2695-
}
2685+
DCHECK_GT(scope->UniqueIdInScript(), UniqueIdInScript());
2686+
DCHECK_IMPLIES(scope->sibling_, scope->sibling_->UniqueIdInScript() !=
2687+
scope->UniqueIdInScript());
26962688
#endif
26972689
if (!scope->is_function_scope() ||
26982690
scope->AsDeclarationScope()->ShouldEagerCompile()) {

src/ast/scopes.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,6 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) {
342342
bool is_hidden() const { return is_hidden_; }
343343
void set_is_hidden() { is_hidden_ = true; }
344344

345-
bool is_hidden_catch_scope() const {
346-
return is_hidden() && scope_type() == CATCH_SCOPE;
347-
}
348-
349345
void ForceContextAllocationForParameters() {
350346
DCHECK(!already_resolved_);
351347
force_context_allocation_for_parameters_ = true;

src/codegen/compiler.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2205,7 +2205,6 @@ class ConstantPoolPointerForwarder {
22052205
template <typename TArray>
22062206
void VisitScopeInfo(Tagged<TArray> constant_pool, int i,
22072207
Tagged<ScopeInfo> scope_info) {
2208-
if (scope_info->IsHiddenCatchScope()) return;
22092208
auto it = scope_infos_to_update_.find(scope_info->UniqueIdInScript());
22102209
// Try to replace the scope info itself with an already existing version.
22112210
if (it != scope_infos_to_update_.end()) {

src/objects/scope-info.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,6 @@ int ScopeInfo::ContextLength() const {
695695
// Needs to be kept in sync with Scope::UniqueIdInScript and
696696
// SharedFunctionInfo::UniqueIdInScript.
697697
int ScopeInfo::UniqueIdInScript() const {
698-
DCHECK(!IsHiddenCatchScope());
699698
// Script scopes start "before" the script to avoid clashing with a scope that
700699
// starts on character 0.
701700
if (is_script_scope() || scope_type() == EVAL_SCOPE ||
@@ -806,10 +805,6 @@ bool ScopeInfo::IsReplModeScope() const {
806805
return scope_type() == REPL_MODE_SCOPE;
807806
}
808807

809-
bool ScopeInfo::IsHiddenCatchScope() const {
810-
return IsHiddenBit::decode(Flags()) && scope_type() == CATCH_SCOPE;
811-
}
812-
813808
bool ScopeInfo::IsWrappedFunctionScope() const {
814809
DCHECK_IMPLIES(IsWrappedFunctionBit::decode(Flags()),
815810
scope_type() == FUNCTION_SCOPE);

src/objects/scope-info.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ class ScopeInfo : public TorqueGeneratedScopeInfo<ScopeInfo, HeapObject> {
114114
// Does this scope belong to a function?
115115
bool HasPositionInfo() const;
116116

117-
bool IsHiddenCatchScope() const;
118-
119117
bool IsWrappedFunctionScope() const;
120118

121119
// Return if contexts are allocated for this scope.

src/parsing/parser.cc

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2987,21 +2987,6 @@ Block* Parser::BuildParameterInitializationBlock(
29872987
return factory()->NewParameterInitializationBlock(init_statements);
29882988
}
29892989

2990-
// TODO(verwaest): Consider building these try/catches in the bytecode generator
2991-
// without hidden scopes.
2992-
Scope* Parser::NewHiddenCatchScope() {
2993-
DCHECK(scope()->is_declaration_scope());
2994-
Scope* catch_scope = NewScopeWithParent(scope(), CATCH_SCOPE);
2995-
catch_scope->set_start_position(position());
2996-
catch_scope->set_end_position(end_position());
2997-
bool was_added;
2998-
catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(),
2999-
VariableMode::kVar, NORMAL_VARIABLE, &was_added);
3000-
DCHECK(was_added);
3001-
catch_scope->set_is_hidden();
3002-
return catch_scope;
3003-
}
3004-
30052990
Expression* Parser::BuildInitialYield(int pos, FunctionKind kind) {
30062991
Expression* yield_result = factory()->NewVariableProxy(
30072992
function_state_->scope()->generator_object_var());

src/parsing/parser.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,6 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
380380

381381
Block* IgnoreCompletion(Statement* statement);
382382

383-
Scope* NewHiddenCatchScope();
384-
385383
bool HasCheckedSyntax() {
386384
return scope()->GetDeclarationScope()->has_checked_syntax();
387385
}

0 commit comments

Comments
 (0)