[webkit-changes] [WebKit/WebKit] 481cb6: Support struct.new, struct.get and struct.set.

Dmitry Bezhetskov noreply at github.com
Sat Oct 15 11:20:28 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 481cb6061b396e2de991a7667240e526f3787eb4
      https://github.com/WebKit/WebKit/commit/481cb6061b396e2de991a7667240e526f3787eb4
  Author: Dmitry Bezhetskov <dbezhetskov at igalia.com>
  Date:   2022-10-15 (Sat, 15 Oct 2022)

  Changed paths:
    M JSTests/wasm/gc/structs.js
    M JSTests/wasm/wasm.json
    M Source/JavaScriptCore/CMakeLists.txt
    M Source/JavaScriptCore/DerivedSources-output.xcfilelist
    M Source/JavaScriptCore/DerivedSources.make
    M Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
    M Source/JavaScriptCore/Sources.txt
    M Source/JavaScriptCore/bytecode/BytecodeList.rb
    M Source/JavaScriptCore/heap/Heap.cpp
    M Source/JavaScriptCore/heap/Heap.h
    M Source/JavaScriptCore/heap/HeapSubspaceTypes.h
    M Source/JavaScriptCore/llint/WebAssembly.asm
    M Source/JavaScriptCore/runtime/JSGlobalObject.cpp
    M Source/JavaScriptCore/runtime/JSGlobalObject.h
    M Source/JavaScriptCore/wasm/WasmAirIRGenerator.cpp
    M Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp
    M Source/JavaScriptCore/wasm/WasmFunctionParser.h
    M Source/JavaScriptCore/wasm/WasmLLIntGenerator.cpp
    M Source/JavaScriptCore/wasm/WasmOperations.cpp
    M Source/JavaScriptCore/wasm/WasmOperations.h
    M Source/JavaScriptCore/wasm/WasmSectionParser.cpp
    M Source/JavaScriptCore/wasm/WasmSlowPaths.cpp
    M Source/JavaScriptCore/wasm/WasmSlowPaths.h
    M Source/JavaScriptCore/wasm/WasmTypeDefinition.cpp
    M Source/JavaScriptCore/wasm/WasmTypeDefinition.h
    M Source/JavaScriptCore/wasm/js/JSWebAssemblyHelpers.h
    A Source/JavaScriptCore/wasm/js/JSWebAssemblyStruct.cpp
    A Source/JavaScriptCore/wasm/js/JSWebAssemblyStruct.h
    A Source/JavaScriptCore/wasm/js/WebAssemblyStructConstructor.cpp
    A Source/JavaScriptCore/wasm/js/WebAssemblyStructConstructor.h
    A Source/JavaScriptCore/wasm/js/WebAssemblyStructPrototype.cpp
    A Source/JavaScriptCore/wasm/js/WebAssemblyStructPrototype.h
    M Source/JavaScriptCore/wasm/wasm.json

  Log Message:
  -----------
  Support struct.new, struct.get and struct.set.
https://bugs.webkit.org/show_bug.cgi?id=243208

Reviewed by Yusuke Suzuki.

This patch introduces basic support of all main structs operations - struct.new, struct.get and struct.set
from the Wasm GC proposal (https://github.com/WebAssembly/gc/blob/main/proposals/gc/MVP.md#structures).
In this patch struct is represented as a contiguous memory space with a corresponding JS part.
All operations are implemented via runtime calls so it's not optimal for B3 and Air tiers
but optimization (replacing runtime call to a read/write by known offset) for struct.get/set will be added as a next step.

* JSTests/wasm/gc/structs.js:
(testStructDeclaration):
* JSTests/wasm/wasm.json:
* Source/JavaScriptCore/CMakeLists.txt:
* Source/JavaScriptCore/DerivedSources-output.xcfilelist:
* Source/JavaScriptCore/DerivedSources.make:
* Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj:
* Source/JavaScriptCore/Sources.txt:
* Source/JavaScriptCore/bytecode/BytecodeList.rb:
* Source/JavaScriptCore/heap/Heap.cpp:
(JSC::Heap::Heap):
* Source/JavaScriptCore/heap/Heap.h:
* Source/JavaScriptCore/heap/HeapSubspaceTypes.h:
* Source/JavaScriptCore/llint/WebAssembly.asm:
* Source/JavaScriptCore/runtime/JSGlobalObject.cpp:
* Source/JavaScriptCore/runtime/JSGlobalObject.h:
* Source/JavaScriptCore/wasm/WasmAirIRGenerator.cpp:
(JSC::Wasm::AirIRGenerator::emitWriteBarrierForJSWrapper):
(JSC::Wasm::AirIRGenerator::emitWriteBarrier):
(JSC::Wasm::AirIRGenerator::addStructNew):
(JSC::Wasm::AirIRGenerator::addStructGet):
(JSC::Wasm::AirIRGenerator::addStructSet):
* Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::B3IRGenerator::emitWriteBarrierForJSWrapper):
(JSC::Wasm::B3IRGenerator::emitWriteBarrier):
(JSC::Wasm::B3IRGenerator::emitStructSet):
(JSC::Wasm::B3IRGenerator::addStructNew):
(JSC::Wasm::B3IRGenerator::addStructGet):
(JSC::Wasm::B3IRGenerator::addStructSet):
* Source/JavaScriptCore/wasm/WasmFunctionParser.h:
(JSC::Wasm::FunctionParser<Context>::parseStructTypeIndex):
(JSC::Wasm::FunctionParser<Context>::parseStructFieldIndex):
(JSC::Wasm::FunctionParser<Context>::parseStructTypeIndexAndFieldIndex):
(JSC::Wasm::FunctionParser<Context>::parseStructFieldManipulation):
(JSC::Wasm::FunctionParser<Context>::parseExpression):
(JSC::Wasm::FunctionParser<Context>::parseUnreachableExpression):
* Source/JavaScriptCore/wasm/WasmLLIntGenerator.cpp:
(JSC::Wasm::LLIntGenerator::addStructNew):
(JSC::Wasm::LLIntGenerator::addStructGet):
(JSC::Wasm::LLIntGenerator::addStructSet):
* Source/JavaScriptCore/wasm/WasmOperations.cpp:
(JSC::Wasm::JSC_DEFINE_JIT_OPERATION):
* Source/JavaScriptCore/wasm/WasmOperations.h:
* Source/JavaScriptCore/wasm/WasmSectionParser.cpp:
(JSC::Wasm::SectionParser::parseStructType):
* Source/JavaScriptCore/wasm/WasmSlowPaths.cpp:
(JSC::LLInt::WASM_SLOW_PATH_DECL):
* Source/JavaScriptCore/wasm/WasmSlowPaths.h:
* Source/JavaScriptCore/wasm/WasmTypeDefinition.cpp:
(JSC::Wasm::StructType::StructType):
(JSC::Wasm::TypeDefinition::tryCreateStructType):
(JSC::Wasm::StructParameterTypes::translate):
* Source/JavaScriptCore/wasm/WasmTypeDefinition.h:
(JSC::Wasm::typeKindSizeInBytes):
(JSC::Wasm::StructType::getFieldOffset const):
(JSC::Wasm::StructType::getFieldOffset):
(JSC::Wasm::StructType::instancePayloadSize const):
(JSC::Wasm::TypeDefinition::TypeDefinition):
(JSC::Wasm::TypeDefinition::allocatedStructSize):
(JSC::Wasm::StructType::StructType): Deleted.
* Source/JavaScriptCore/wasm/js/JSWebAssemblyHelpers.h:
(JSC::toJSValue):
* Source/JavaScriptCore/wasm/js/JSWebAssemblyStruct.cpp: Added.
(JSC::JSWebAssemblyStruct::JSWebAssemblyStruct):
(JSC::JSWebAssemblyStruct::tryCreate):
(JSC::JSWebAssemblyStruct::fieldPointer const):
(JSC::JSWebAssemblyStruct::fieldPointer):
(JSC::JSWebAssemblyStruct::get const):
(JSC::JSWebAssemblyStruct::set):
(JSC::JSWebAssemblyStruct::finishCreation):
(JSC::JSWebAssemblyStruct::visitChildrenImpl):
(JSC::JSWebAssemblyStruct::destroy):
* Source/JavaScriptCore/wasm/js/JSWebAssemblyStruct.h: Added.
* Source/JavaScriptCore/wasm/js/WebAssemblyStructConstructor.cpp: Added.
(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::WebAssemblyStructConstructor::create):
(JSC::WebAssemblyStructConstructor::createStructure):
(JSC::WebAssemblyStructConstructor::finishCreation):
(JSC::WebAssemblyStructConstructor::WebAssemblyStructConstructor):
* Source/JavaScriptCore/wasm/js/WebAssemblyStructConstructor.h: Added.
* Source/JavaScriptCore/wasm/js/WebAssemblyStructPrototype.cpp: Added.
(JSC::WebAssemblyStructPrototype::create):
(JSC::WebAssemblyStructPrototype::createStructure):
(JSC::WebAssemblyStructPrototype::finishCreation):
(JSC::WebAssemblyStructPrototype::WebAssemblyStructPrototype):
* Source/JavaScriptCore/wasm/js/WebAssemblyStructPrototype.h: Added.
* Source/JavaScriptCore/wasm/wasm.json:

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




More information about the webkit-changes mailing list