[webkit-changes] [WebKit/WebKit] 70ccbd: Add WASM opcode counter

EWS noreply at github.com
Mon Jan 9 11:47:41 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 70ccbd9daaa2db326dfed9a1d84f7be4ffdddaa7
      https://github.com/WebKit/WebKit/commit/70ccbd9daaa2db326dfed9a1d84f7be4ffdddaa7
  Author: Yijia Huang <yijia_huang at apple.com>
  Date:   2023-01-09 (Mon, 09 Jan 2023)

  Changed paths:
    A JSTests/stress/atob-btoa.js
    M Source/JavaScriptCore/Sources.txt
    M Source/JavaScriptCore/jsc.cpp
    M Source/JavaScriptCore/runtime/OptionsList.h
    M Source/JavaScriptCore/wasm/WasmFunctionParser.h
    A Source/JavaScriptCore/wasm/WasmOpcodeCounter.cpp
    A Source/JavaScriptCore/wasm/WasmOpcodeCounter.h
    M Source/JavaScriptCore/wasm/WasmTypeDefinition.h

  Log Message:
  -----------
  Add WASM opcode counter
https://bugs.webkit.org/show_bug.cgi?id=250213
rdar://103956646

Reviewed by Justin Michaud.

This patch includes three things:

a) Added `atob` and `btoa` to jsc shell as helpers for loading tfjs pre-trained models.

b) Skipped JetStream3 tests UniPoker and bigint-paillier, since UniPoker
   fails on browser with error messages and bigint-paillier hangs with
   `deterministicRandom` is true.

c) Added a WASM opcode counter. Use `dumpWasmOpcodeStatistics=1` to enable
   opcode collection. And use `notifyutil -v -p com.apple.WebKit.wasm.op.stat`
   to dump statistics sorted by counts in descending order for all WASM opcodes.
   An example of dumped statistics:

      <WASM.OP.STAT><92428> Registering callback for wasm opcode statistics.
      <WASM.OP.STAT><92428> Use `notifyutil -v -p com.apple.WebKit.wasm.op.stat` to dump statistics.
      <WASM.EXT.SIMD.OP.STAT><92428> wasm extended SIMD opcode use coverage 32.63%.
      <WASM.EXT.SIMD.OP.STAT><92428>    V128Load: 4588
      <WASM.EXT.SIMD.OP.STAT><92428>    F32x4Add: 2522
      ...
      <WASM.EXT.ATOMIC.OP.STAT><92428> wasm extended atomic opcode use coverage 0.00%.
      <WASM.EXT.ATOMIC.OP.STAT><92428>    MemoryAtomicNotify: 0
      <WASM.EXT.ATOMIC.OP.STAT><92428>    MemoryAtomicWait32: 0
      ...
      <WASM.GC.OP.STAT><92428> wasm GC opcode use coverage 0.00%.
      <WASM.GC.OP.STAT><92428>    StructNewCanon: 0
      <WASM.GC.OP.STAT><92428>    StructGet: 0
      ...
      <WASM.BASE.OP.STAT><92428> wasm base opcode use coverage 74.49%.
      <WASM.BASE.OP.STAT><92428>    GetLocal: 80967
      <WASM.BASE.OP.STAT><92428>    I32Const: 28805
      ...

* JSTests/stress/atob-btoa.js: Added.
(assert):
(shouldThrow):
* Source/JavaScriptCore/Sources.txt:
* Source/JavaScriptCore/jsc.cpp:
(JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/OptionsList.h:
* Source/JavaScriptCore/wasm/WasmFunctionParser.h:
(JSC::Wasm::FunctionParser<Context>::parseBody):
(JSC::Wasm::FunctionParser<Context>::parseExpression):
(JSC::Wasm::FunctionParser<Context>::parseUnreachableExpression):
* Source/JavaScriptCore/wasm/WasmOpcodeCounter.cpp: Added.
(JSC::Wasm::WasmOpcodeCounter::singleton):
(JSC::Wasm::WasmOpcodeCounter::dump):
(JSC::Wasm::WasmOpcodeCounter::registerDispatch):
(JSC::Wasm::WasmOpcodeCounter::increment):
* Source/JavaScriptCore/wasm/WasmOpcodeCounter.h: Added.
* Source/JavaScriptCore/wasm/WasmTypeDefinition.h:
(JSC::Wasm::countNumberOfWasmExtendedSIMDOpcodes):
(JSC::Wasm::isRegisteredWasmExtendedSIMDOpcode):
(JSC::Wasm::dumpExtSIMDOpType):
(JSC::Wasm::countNumberOfWasmExtendedAtomicOpcodes):
(JSC::Wasm::isRegisteredExtenedAtomicOpcode):
(JSC::Wasm::dumpExtAtomicOpType):
(JSC::Wasm::countNumberOfWasmGCOpcodes):
(JSC::Wasm::isRegisteredGCOpcode):
(JSC::Wasm::dumpGCOpType):
(JSC::Wasm::countNumberOfWasmBaseOpcodes):
(JSC::Wasm::isRegisteredBaseOpcode):
(JSC::Wasm::dumpOpType):

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




More information about the webkit-changes mailing list