fix_disable_scope_reuse_associated_dchecks.patch 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Calvin Watford <[email protected]>
  3. Date: Wed, 17 Jul 2024 12:52:10 -0600
  4. Subject: fix: disable scope reuse & associated dchecks
  5. This change was introduced in https://crrev.com/c/5630974 which reuses
  6. scope info objects across allocations. Unfortunately, this change seems
  7. to be not yet fully cooked and causes crashes with normal usage of V8.
  8. In particular, Node.js call's V8's `v8::ScriptCompiler::CompileFunction`
  9. method. This ends up wrapping the source code in a function, which this
  10. code is not yet prepared to handle. The generated function wrapper
  11. (created by V8) has no source position, so it reports being at the start
  12. of the source, which may overlap with other scopes that are in the
  13. original source. This new feature adds a "UniqueIdInScript" concept that
  14. is derived from the source position of a scope, along with the invariant
  15. that inner scopes have a higher ID than outer scopes, which does not
  16. hold for the above situation.
  17. This patch is not intended to remain indefinitely. Once the upstream
  18. feature stabilizes, we can remove this patch. Unfortunately, there is no
  19. public tracking bug for this feature nor the crashes its been causing,
  20. so we'll have to keep an eye on this for the time being.
  21. diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc
  22. index 530a249adde65a47c8e0babf5723b52b8d2a6b1a..fca49d135ad2f23307654e1b0c36e846ca5a6ec6 100644
  23. --- a/src/ast/scopes.cc
  24. +++ b/src/ast/scopes.cc
  25. @@ -2717,9 +2717,9 @@ void Scope::AllocateScopeInfosRecursively(
  26. // Allocate ScopeInfos for inner scopes.
  27. for (Scope* scope = inner_scope_; scope != nullptr; scope = scope->sibling_) {
  28. - DCHECK_GT(scope->UniqueIdInScript(), UniqueIdInScript());
  29. - DCHECK_IMPLIES(scope->sibling_, scope->sibling_->UniqueIdInScript() !=
  30. - scope->UniqueIdInScript());
  31. + // DCHECK_GT(scope->UniqueIdInScript(), UniqueIdInScript());
  32. + // DCHECK_IMPLIES(scope->sibling_, scope->sibling_->UniqueIdInScript() !=
  33. + // scope->UniqueIdInScript());
  34. if (!scope->is_function_scope() ||
  35. scope->AsDeclarationScope()->ShouldEagerCompile()) {
  36. scope->AllocateScopeInfosRecursively(isolate, next_outer_scope,
  37. diff --git a/src/flags/flag-definitions.h b/src/flags/flag-definitions.h
  38. index 657ac0ebd872d6be4e2fa962a17259dd96f047b7..8e413913048d20b57bdd40807bfa4365e9d9ec77 100644
  39. --- a/src/flags/flag-definitions.h
  40. +++ b/src/flags/flag-definitions.h
  41. @@ -993,6 +993,8 @@ DEFINE_BOOL(trace_track_allocation_sites, false,
  42. DEFINE_BOOL(trace_migration, false, "trace object migration")
  43. DEFINE_BOOL(trace_generalization, false, "trace map generalization")
  44. +// ELECTRON: The following flag should remain false by default until we can
  45. +// remove `fix_disable_scope_reuse_associated_dchecks.patch`
  46. DEFINE_BOOL(reuse_scope_infos, false,
  47. "reuse scope infos from previous compiles")