[webkit-changes] [WebKit/WebKit] f6fd20: [JSC] Don't emit op_get_scope if restoring the sco...

Commit Queue noreply at github.com
Tue Aug 27 00:11:20 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f6fd2039015c4cbd575768f822ac036102dbc79c
      https://github.com/WebKit/WebKit/commit/f6fd2039015c4cbd575768f822ac036102dbc79c
  Author: Alexey Shvayka <ashvayka at apple.com>
  Date:   2024-08-27 (Tue, 27 Aug 2024)

  Changed paths:
    A JSTests/stress/regress-277219.js
    M Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
    M Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
    M Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

  Log Message:
  -----------
  [JSC] Don't emit op_get_scope if restoring the scope register is unnecessary
https://bugs.webkit.org/show_bug.cgi?id=277219
<rdar://problem/132702544>

Reviewed by Yusuke Suzuki.

This change:

1) in try/catch/finally, guards restoreScopeRegister() in `catch` and `finally` blocks to be called
   only if a new scope was created in any of the previous blocks (`try` or `catch`), which happens
   pretty rarely;

2) in for/of, removes restoreScopeRegister() because it's actually unnecessary: `finally` handler
   closes iterator without resolving any symbols; in case of `return` / `throw` completions, the
   function is terminated and clobbered scope is never accessed, while both same-level and nested
   `break` / `continue` completions restore scope on their own.

* JSTests/stress/regress-277219.js: Added.
* Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::pushLocalControlFlowScope):
(JSC::BytecodeGenerator::emitGenericEnumeration):
(JSC::BytecodeGenerator::emitEnumeration):
* Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h:
(JSC::BytecodeGenerator::localScopeCount const):
* Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp:
(JSC::TryNode::emitBytecode):

Canonical link: https://commits.webkit.org/282775@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list