haikuwebkit/JSTests/wasm/libwabt.js

77 lines
1.1 MiB
JavaScript
Raw Permalink Normal View History

Add support for the Wasm multi-value proposal https://bugs.webkit.org/show_bug.cgi?id=202250 Reviewed by Saam Barati. JSTests: This patch adds a new way to run stress tests via the .wat text format. By attaching an asm.js compiled version of the wabt tool we can easily create wat files programatically and convert them into a wasm blob to compile. To make this easy there is a wabt-wrapper.js module file that exports two useful functions that correspond to WebAssembly.compile and WebAssembly.instantiate. * wasm.yaml: * wasm/function-tests/if-no-else-non-void.js: * wasm/js-api/web-assembly-instantiate.js: (assert.asyncTest.async.test): (assert.asyncTest): * wasm/libwabt.js: Added. (WabtModule): (set get if): * wasm/references/func_ref.js: * wasm/references/validation.js: (assert.throws): * wasm/spec-harness/index.js: * wasm/spec-tests/block.wast.js: * wasm/spec-tests/br.wast.js: * wasm/spec-tests/br_if.wast.js: * wasm/spec-tests/call.wast.js: * wasm/spec-tests/call_indirect.wast.js: * wasm/spec-tests/func.wast.js: * wasm/spec-tests/if.wast.js: * wasm/spec-tests/loop.wast.js: * wasm/spec-tests/type.wast.js: * wasm/stress/js-wasm-call-many-return-types-on-stack-no-args.js: Added. (buildWat): * wasm/stress/js-wasm-js-varying-arities.js: Added. (paramForwarder): * wasm/stress/wasm-js-call-many-return-types-on-stack-no-args.js: Added. (buildWat): * wasm/stress/wasm-js-multi-value-exception-in-iterator.js: Added. (buildWat.throwError): (buildWat.throwErrorInIterator): (buildWat.tooManyValues): (buildWat.tooFewValues): (buildWat): * wasm/stress/wasm-wasm-call-indirect-many-return-types-on-stack.js: Added. (buildWat): * wasm/stress/wasm-wasm-call-many-return-types-on-stack-no-args.js: Added. (buildWat): * wasm/wabt-wrapper.js: Added. (export.compile): * wasm/wast-tests/br-if-at-end-of-block.wasm: Added. * wasm/wast-tests/br-if-at-end-of-block.wast: Added. * wasm/wast-tests/harness.js: (async.runWasmFile): * wasm/wast-tests/single-param-loop-signature.wasm: Added. * wasm/wast-tests/single-param-loop-signature.wast: Added. Source/JavaScriptCore: The wasm multi-value proposal makes two major changes to the spec. The first is that functions may now return more than one value across calls. When calling to/from JS, if there is more than one return type we return/receive a JSArray/Iterable, respectively. In the Wasm calls JS case, if the iteratable object does not vend the exact number of objects expected by the signature an error is thrown. The second major change in the multi-value proposal allows blocks to have any signature type. This works in a backwards compatible way by exploiting the fact that the old value-type thunk signatures (where the block takes no arguments and returns just the value type i.e. [] -> [type]) were always encoded as a negative number. If a block has a function signature, it is encoded as a positive index into the type section. When a block has a function signature type then the values from the enclosing stack are popped off that stack and added to the new block's stack. In the case of a br/br_if to a Loop block the "argument" values should be on the brancher's stack. The biggest change in this patch is stripping down the WasmCallingConventions file into one simpler API that just tells you where the each argument should be located. It also now handles adding or subtracting sizeof(CallerFrameAndPC) depending on whether you are caller or callee. Additionally, when computing locations for the callee it returns a B3::ValueRep that has the offsetFromFP rather than offsetFromSP. Since the code has been cleaned up I tried to also reduce code duplication in the various stubs for wasm code. This patch also removes the Air specific calling convention code and moves that logic into the Air IR generator. Since blocks can now have arbitrary signatures the control entries now use a const signature* rather than just the return type. Additionally, what used to be the result phi is now the phis for all the results for non-loop blocks and the arguments for a loop block. Due to the control flow restrictions of wasm conveniently we don't have to worry about generating non-optimal SSA, thus we can just use phis directly rather than using a variable. Lastly, to help clean up some code in the IR generators new helper methods were added to create call Patchpoints. These helpers do most of the boiler-plate initialization. * JavaScriptCore.xcodeproj/project.pbxproj: * assembler/AbstractMacroAssembler.h: (JSC::AbstractMacroAssembler::ImplicitAddress::ImplicitAddress): * assembler/LinkBuffer.cpp: (JSC::shouldDumpDisassemblyFor): * assembler/LinkBuffer.h: * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::callOperation): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::callOperation): * b3/B3LowerToAir.cpp: * b3/B3PatchpointSpecial.cpp: (JSC::B3::PatchpointSpecial::forEachArg): (JSC::B3::PatchpointSpecial::isValid): (JSC::B3::PatchpointSpecial::admitsStack): (JSC::B3::PatchpointSpecial::generate): * b3/B3Procedure.h: (JSC::B3::Procedure::resultCount const): (JSC::B3::Procedure::typeAtOffset const): (JSC::B3::Procedure::returnCount const): Deleted. * b3/B3StackmapGenerationParams.cpp: (JSC::B3::StackmapGenerationParams::code const): * b3/B3StackmapGenerationParams.h: * b3/B3ValueRep.h: * b3/air/AirHelpers.h: Added. (JSC::B3::Air::moveForType): (JSC::B3::Air::relaxedMoveForType): * jit/AssemblyHelpers.h: (JSC::AssemblyHelpers::store64FromReg): (JSC::AssemblyHelpers::store32FromReg): (JSC::AssemblyHelpers::load64ToReg): (JSC::AssemblyHelpers::load32ToReg): * runtime/JSCConfig.h: * runtime/OptionsList.h: * tools/JSDollarVM.cpp: * tools/VMInspector.cpp: (JSC::VMInspector::dumpValue): * wasm/WasmAirIRGenerator.cpp: (JSC::Wasm::ConstrainedTmp::operator bool const): (JSC::Wasm::TypedTmp::dump const): (JSC::Wasm::AirIRGenerator::ControlData::ControlData): (JSC::Wasm::AirIRGenerator::ControlData::dump const): (JSC::Wasm::AirIRGenerator::ControlData::blockType const): (JSC::Wasm::AirIRGenerator::ControlData::signature const): (JSC::Wasm::AirIRGenerator::ControlData::targetBlockForBranch): (JSC::Wasm::AirIRGenerator::ControlData::convertIfToBlock): (JSC::Wasm::AirIRGenerator::addEndToUnreachable): (JSC::Wasm::AirIRGenerator::emitCallPatchpoint): (JSC::Wasm::AirIRGenerator::validateInst): (JSC::Wasm::AirIRGenerator::tmpsForSignature): (JSC::Wasm::AirIRGenerator::emitPatchpoint): (JSC::Wasm::AirIRGenerator::AirIRGenerator): (JSC::Wasm::AirIRGenerator::toB3ResultType): (JSC::Wasm::AirIRGenerator::addBottom): (JSC::Wasm::AirIRGenerator::emitLoopTierUpCheck): (JSC::Wasm::AirIRGenerator::addTopLevel): (JSC::Wasm::AirIRGenerator::addLoop): (JSC::Wasm::AirIRGenerator::addBlock): (JSC::Wasm::AirIRGenerator::addIf): (JSC::Wasm::AirIRGenerator::addElse): (JSC::Wasm::AirIRGenerator::addElseToUnreachable): (JSC::Wasm::AirIRGenerator::addReturn): (JSC::Wasm::AirIRGenerator::addBranch): (JSC::Wasm::AirIRGenerator::addSwitch): (JSC::Wasm::AirIRGenerator::endBlock): (JSC::Wasm::AirIRGenerator::addCall): (JSC::Wasm::AirIRGenerator::addCallIndirect): (JSC::Wasm::dumpExpressionStack): (JSC::Wasm::AirIRGenerator::dump): (JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncUF64>): (JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncUF32>): (JSC::Wasm::AirIRGenerator::ControlData::type const): Deleted. (JSC::Wasm::AirIRGenerator::ControlData::hasNonVoidSignature const): Deleted. (JSC::Wasm::AirIRGenerator::ControlData::resultForBranch const): Deleted. * wasm/WasmB3IRGenerator.cpp: (JSC::Wasm::B3IRGenerator::ControlData::ControlData): (JSC::Wasm::B3IRGenerator::ControlData::dump const): (JSC::Wasm::B3IRGenerator::ControlData::blockType const): (JSC::Wasm::B3IRGenerator::ControlData::hasNonVoidresult const): (JSC::Wasm::B3IRGenerator::ControlData::targetBlockForBranch): (JSC::Wasm::B3IRGenerator::ControlData::convertIfToBlock): (JSC::Wasm::B3IRGenerator::addEndToUnreachable): (JSC::Wasm::B3IRGenerator::B3IRGenerator): (JSC::Wasm::B3IRGenerator::framePointer): (JSC::Wasm::B3IRGenerator::toB3ResultType): (JSC::Wasm::B3IRGenerator::addArguments): (JSC::Wasm::B3IRGenerator::addGrowMemory): (JSC::Wasm::B3IRGenerator::addLoop): (JSC::Wasm::B3IRGenerator::addTopLevel): (JSC::Wasm::B3IRGenerator::addBlock): (JSC::Wasm::B3IRGenerator::addIf): (JSC::Wasm::B3IRGenerator::addElse): (JSC::Wasm::B3IRGenerator::addElseToUnreachable): (JSC::Wasm::B3IRGenerator::addReturn): (JSC::Wasm::B3IRGenerator::addBranch): (JSC::Wasm::B3IRGenerator::addSwitch): (JSC::Wasm::B3IRGenerator::endBlock): (JSC::Wasm::B3IRGenerator::createCallPatchpoint): (JSC::Wasm::B3IRGenerator::addCall): (JSC::Wasm::B3IRGenerator::addCallIndirect): (JSC::Wasm::B3IRGenerator::ControlData::type const): Deleted. (JSC::Wasm::B3IRGenerator::ControlData::hasNonVoidSignature const): Deleted. (JSC::Wasm::B3IRGenerator::ControlData::resultForBranch const): Deleted. (JSC::Wasm::B3IRGenerator::createStack): Deleted. * wasm/WasmBBQPlan.cpp: (JSC::Wasm::BBQPlan::didReceiveFunctionData): (JSC::Wasm::BBQPlan::parseAndValidateModule): (JSC::Wasm::BBQPlan::complete): * wasm/WasmBBQPlan.h: * wasm/WasmBinding.cpp: (JSC::Wasm::wasmToWasm): * wasm/WasmCallingConvention.cpp: (JSC::Wasm::jsCallingConvention): (JSC::Wasm::wasmCallingConvention): (JSC::Wasm::jscCallingConvention): Deleted. (JSC::Wasm::jscCallingConventionAir): Deleted. (JSC::Wasm::wasmCallingConventionAir): Deleted. * wasm/WasmCallingConvention.h: (JSC::Wasm::CallInformation::CallInformation): (JSC::Wasm::CallInformation::computeResultsOffsetList): (JSC::Wasm::WasmCallingConvention::WasmCallingConvention): (JSC::Wasm::WasmCallingConvention::marshallLocationImpl const): (JSC::Wasm::WasmCallingConvention::marshallLocation const): (JSC::Wasm::WasmCallingConvention::callInformationFor const): (JSC::Wasm::JSCallingConvention::JSCallingConvention): (JSC::Wasm::JSCallingConvention::marshallLocationImpl const): (JSC::Wasm::JSCallingConvention::marshallLocation const): (JSC::Wasm::JSCallingConvention::callInformationFor const): (JSC::Wasm::CallingConvention::CallingConvention): Deleted. (JSC::Wasm::CallingConvention::marshallArgumentImpl const): Deleted. (JSC::Wasm::CallingConvention::marshallArgument const): Deleted. (JSC::Wasm::CallingConvention::headerSizeInBytes): Deleted. (JSC::Wasm::CallingConvention::setupFrameInPrologue const): Deleted. (JSC::Wasm::CallingConvention::loadArguments const): Deleted. (JSC::Wasm::CallingConvention::setupCall const): Deleted. (JSC::Wasm::CallingConventionAir::CallingConventionAir): Deleted. (JSC::Wasm::CallingConventionAir::prologueScratch const): Deleted. (JSC::Wasm::CallingConventionAir::marshallArgumentImpl const): Deleted. (JSC::Wasm::CallingConventionAir::marshallArgument const): Deleted. (JSC::Wasm::CallingConventionAir::headerSizeInBytes): Deleted. (JSC::Wasm::CallingConventionAir::loadArguments const): Deleted. (JSC::Wasm::CallingConventionAir::setupCall const): Deleted. (JSC::Wasm::nextJSCOffset): Deleted. * wasm/WasmFormat.h: * wasm/WasmFunctionParser.h: (JSC::Wasm::splitStack): (JSC::Wasm::FunctionParser::signature const): (JSC::Wasm::FunctionParser<Context>::FunctionParser): (JSC::Wasm::FunctionParser<Context>::parseBody): (JSC::Wasm::FunctionParser<Context>::parseExpression): (JSC::Wasm::FunctionParser<Context>::parseUnreachableExpression): * wasm/WasmInstance.h: * wasm/WasmMemoryInformation.cpp: (JSC::Wasm::getPinnedRegisters): * wasm/WasmOMGForOSREntryPlan.cpp: (JSC::Wasm::OMGForOSREntryPlan::work): * wasm/WasmOMGPlan.cpp: (JSC::Wasm::OMGPlan::work): * wasm/WasmParser.h: (JSC::Wasm::FailureHelper::makeString): (JSC::Wasm::Parser<SuccessType>::Parser): (JSC::Wasm::Parser<SuccessType>::peekInt7): (JSC::Wasm::Parser<SuccessType>::parseBlockSignature): (JSC::Wasm::Parser<SuccessType>::parseValueType): (JSC::Wasm::Parser<SuccessType>::parseResultType): Deleted. * wasm/WasmSectionParser.cpp: (JSC::Wasm::SectionParser::parseType): (JSC::Wasm::SectionParser::parseStart): * wasm/WasmSectionParser.h: * wasm/WasmSignature.cpp: (JSC::Wasm::Signature::toString const): (JSC::Wasm::Signature::dump const): (JSC::Wasm::computeHash): (JSC::Wasm::Signature::hash const): (JSC::Wasm::Signature::tryCreate): (JSC::Wasm::SignatureInformation::SignatureInformation): (JSC::Wasm::ParameterTypes::hash): (JSC::Wasm::ParameterTypes::equal): (JSC::Wasm::ParameterTypes::translate): (JSC::Wasm::SignatureInformation::signatureFor): (JSC::Wasm::SignatureInformation::adopt): Deleted. * wasm/WasmSignature.h: (JSC::Wasm::Signature::Signature): (JSC::Wasm::Signature::allocatedSize): (JSC::Wasm::Signature::returnCount const): (JSC::Wasm::Signature::returnType const): (JSC::Wasm::Signature::returnsVoid const): (JSC::Wasm::Signature::argument const): (JSC::Wasm::Signature::operator== const): (JSC::Wasm::Signature::getReturnType): (JSC::Wasm::Signature::getArgument): (JSC::Wasm::SignatureHash::SignatureHash): (JSC::Wasm::SignatureHash::equal): (JSC::Wasm::SignatureInformation::thunkFor const): (JSC::Wasm::Signature::returnType): Deleted. (JSC::Wasm::Signature::argument): Deleted. * wasm/WasmStreamingParser.cpp: (JSC::Wasm::StreamingParser::parseCodeSectionSize): (JSC::Wasm::StreamingParser::parseFunctionPayload): (JSC::Wasm::StreamingParser::parseSectionPayload): * wasm/WasmStreamingParser.h: (JSC::Wasm::StreamingParserClient::didReceiveSectionData): (JSC::Wasm::StreamingParser::reportError): (JSC::Wasm::StreamingParserClient::didReceiveFunctionData): Deleted. * wasm/WasmThunks.cpp: (JSC::Wasm::throwExceptionFromWasmThunkGenerator): (JSC::Wasm::throwStackOverflowFromWasmThunkGenerator): (JSC::Wasm::triggerOMGEntryTierUpThunkGenerator): * wasm/WasmValidate.cpp: (JSC::Wasm::Validate::ControlData::ControlData): (JSC::Wasm::Validate::ControlData::dump const): (JSC::Wasm::Validate::ControlData::blockType const): (JSC::Wasm::Validate::ControlData::signature const): (JSC::Wasm::Validate::ControlData::branchTargetArity const): (JSC::Wasm::Validate::ControlData::branchTargetType const): (JSC::Wasm::Validate::fail const): (JSC::Wasm::Validate::addTableGet): (JSC::Wasm::Validate::addTableGrow): (JSC::Wasm::Validate::addTableFill): (JSC::Wasm::Validate::addRefIsNull): (JSC::Wasm::Validate::addTopLevel): (JSC::Wasm::splitStack): (JSC::Wasm::Validate::addBlock): (JSC::Wasm::Validate::addLoop): (JSC::Wasm::Validate::addIf): (JSC::Wasm::Validate::addElseToUnreachable): (JSC::Wasm::Validate::addReturn): (JSC::Wasm::Validate::checkBranchTarget): (JSC::Wasm::Validate::addSwitch): (JSC::Wasm::Validate::addGrowMemory): (JSC::Wasm::Validate::addEndToUnreachable): (JSC::Wasm::Validate::addCall): (JSC::Wasm::Validate::addCallIndirect): (JSC::Wasm::Validate::unify): (JSC::Wasm::Validate::ControlData::hasNonVoidSignature const): Deleted. (JSC::Wasm::Validate::ControlData::type const): Deleted. (JSC::Wasm::Validate::ControlData::branchTargetSignature const): Deleted. * wasm/generateWasmOpsHeader.py: * wasm/js/JSToWasm.cpp: (JSC::Wasm::boxWasmResult): (JSC::Wasm::allocateResultsArray): (JSC::Wasm::marshallJSResult): (JSC::Wasm::createJSToWasmWrapper): * wasm/js/JSToWasm.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): * wasm/js/WasmToJS.cpp: (JSC::Wasm::handleBadI64Use): (JSC::Wasm::wasmToJS): * wasm/js/WasmToJS.h: * wasm/js/WebAssemblyFunction.cpp: (JSC::callWebAssemblyFunction): (JSC::WebAssemblyFunction::useTagRegisters const): (JSC::WebAssemblyFunction::jsCallEntrypointSlow): * wasm/js/WebAssemblyModuleRecord.cpp: (JSC::WebAssemblyModuleRecord::link): Tools: * Scripts/run-jsc-stress-tests: Canonical link: https://commits.webkit.org/215930@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250559 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-10-01 16:38:26 +00:00
/*
* Copyright 2016 WebAssembly Community Group participants
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
WebAssembly: update wabt.js https://bugs.webkit.org/show_bug.cgi?id=218876 Patch by Sergey Rubanov <chi187@gmail.com> on 2020-11-13 Reviewed by Yusuke Suzuki. * wasm/libwabt.js: (WabtModule): Deleted. * wasm/regress/llint-callee-saves-with-fast-memory.js: (async test): * wasm/regress/llint-callee-saves-without-fast-memory.js: (async test): * wasm/regress/regression-with-loop.js: (async test): * wasm/regress/stack-consistency.js: (async test): * wasm/stress/js-wasm-call-many-return-types-on-stack-no-args.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/stress/js-wasm-js-varying-arities.js: (async paramForwarder): (async test): (paramForwarder): Deleted. * wasm/stress/local-ref.js: (async test): * wasm/stress/loop-more-args-than-results.js: (async test): * wasm/stress/set-local-enclosed-stack.js: (async test): (assert.eq.instance.exports.foo): Deleted. (assert.eq): Deleted. * wasm/stress/top-most-enclosing-stack.js: (async test): * wasm/stress/trunc-int-min-minus-one.js: (async test): * wasm/stress/wasm-js-call-many-return-types-on-stack-no-args.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/stress/wasm-js-multi-value-exception-in-iterator.js: (async buildWat): (async test): (buildWat.throwError): Deleted. (buildWat.throwErrorInIterator): Deleted. (buildWat.tooManyValues): Deleted. (buildWat.tooFewValues): Deleted. (buildWat): Deleted. * wasm/stress/wasm-wasm-call-indirect-many-return-types-on-stack.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/stress/wasm-wasm-call-many-return-types-on-stack-no-args.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/wabt-wrapper.js: (export.async compile): (export.compile): Deleted. Canonical link: https://commits.webkit.org/231540@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269766 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-11-13 08:36:26 +00:00
// Current version is 1.0.19.
Add support for the Wasm multi-value proposal https://bugs.webkit.org/show_bug.cgi?id=202250 Reviewed by Saam Barati. JSTests: This patch adds a new way to run stress tests via the .wat text format. By attaching an asm.js compiled version of the wabt tool we can easily create wat files programatically and convert them into a wasm blob to compile. To make this easy there is a wabt-wrapper.js module file that exports two useful functions that correspond to WebAssembly.compile and WebAssembly.instantiate. * wasm.yaml: * wasm/function-tests/if-no-else-non-void.js: * wasm/js-api/web-assembly-instantiate.js: (assert.asyncTest.async.test): (assert.asyncTest): * wasm/libwabt.js: Added. (WabtModule): (set get if): * wasm/references/func_ref.js: * wasm/references/validation.js: (assert.throws): * wasm/spec-harness/index.js: * wasm/spec-tests/block.wast.js: * wasm/spec-tests/br.wast.js: * wasm/spec-tests/br_if.wast.js: * wasm/spec-tests/call.wast.js: * wasm/spec-tests/call_indirect.wast.js: * wasm/spec-tests/func.wast.js: * wasm/spec-tests/if.wast.js: * wasm/spec-tests/loop.wast.js: * wasm/spec-tests/type.wast.js: * wasm/stress/js-wasm-call-many-return-types-on-stack-no-args.js: Added. (buildWat): * wasm/stress/js-wasm-js-varying-arities.js: Added. (paramForwarder): * wasm/stress/wasm-js-call-many-return-types-on-stack-no-args.js: Added. (buildWat): * wasm/stress/wasm-js-multi-value-exception-in-iterator.js: Added. (buildWat.throwError): (buildWat.throwErrorInIterator): (buildWat.tooManyValues): (buildWat.tooFewValues): (buildWat): * wasm/stress/wasm-wasm-call-indirect-many-return-types-on-stack.js: Added. (buildWat): * wasm/stress/wasm-wasm-call-many-return-types-on-stack-no-args.js: Added. (buildWat): * wasm/wabt-wrapper.js: Added. (export.compile): * wasm/wast-tests/br-if-at-end-of-block.wasm: Added. * wasm/wast-tests/br-if-at-end-of-block.wast: Added. * wasm/wast-tests/harness.js: (async.runWasmFile): * wasm/wast-tests/single-param-loop-signature.wasm: Added. * wasm/wast-tests/single-param-loop-signature.wast: Added. Source/JavaScriptCore: The wasm multi-value proposal makes two major changes to the spec. The first is that functions may now return more than one value across calls. When calling to/from JS, if there is more than one return type we return/receive a JSArray/Iterable, respectively. In the Wasm calls JS case, if the iteratable object does not vend the exact number of objects expected by the signature an error is thrown. The second major change in the multi-value proposal allows blocks to have any signature type. This works in a backwards compatible way by exploiting the fact that the old value-type thunk signatures (where the block takes no arguments and returns just the value type i.e. [] -> [type]) were always encoded as a negative number. If a block has a function signature, it is encoded as a positive index into the type section. When a block has a function signature type then the values from the enclosing stack are popped off that stack and added to the new block's stack. In the case of a br/br_if to a Loop block the "argument" values should be on the brancher's stack. The biggest change in this patch is stripping down the WasmCallingConventions file into one simpler API that just tells you where the each argument should be located. It also now handles adding or subtracting sizeof(CallerFrameAndPC) depending on whether you are caller or callee. Additionally, when computing locations for the callee it returns a B3::ValueRep that has the offsetFromFP rather than offsetFromSP. Since the code has been cleaned up I tried to also reduce code duplication in the various stubs for wasm code. This patch also removes the Air specific calling convention code and moves that logic into the Air IR generator. Since blocks can now have arbitrary signatures the control entries now use a const signature* rather than just the return type. Additionally, what used to be the result phi is now the phis for all the results for non-loop blocks and the arguments for a loop block. Due to the control flow restrictions of wasm conveniently we don't have to worry about generating non-optimal SSA, thus we can just use phis directly rather than using a variable. Lastly, to help clean up some code in the IR generators new helper methods were added to create call Patchpoints. These helpers do most of the boiler-plate initialization. * JavaScriptCore.xcodeproj/project.pbxproj: * assembler/AbstractMacroAssembler.h: (JSC::AbstractMacroAssembler::ImplicitAddress::ImplicitAddress): * assembler/LinkBuffer.cpp: (JSC::shouldDumpDisassemblyFor): * assembler/LinkBuffer.h: * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::callOperation): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::callOperation): * b3/B3LowerToAir.cpp: * b3/B3PatchpointSpecial.cpp: (JSC::B3::PatchpointSpecial::forEachArg): (JSC::B3::PatchpointSpecial::isValid): (JSC::B3::PatchpointSpecial::admitsStack): (JSC::B3::PatchpointSpecial::generate): * b3/B3Procedure.h: (JSC::B3::Procedure::resultCount const): (JSC::B3::Procedure::typeAtOffset const): (JSC::B3::Procedure::returnCount const): Deleted. * b3/B3StackmapGenerationParams.cpp: (JSC::B3::StackmapGenerationParams::code const): * b3/B3StackmapGenerationParams.h: * b3/B3ValueRep.h: * b3/air/AirHelpers.h: Added. (JSC::B3::Air::moveForType): (JSC::B3::Air::relaxedMoveForType): * jit/AssemblyHelpers.h: (JSC::AssemblyHelpers::store64FromReg): (JSC::AssemblyHelpers::store32FromReg): (JSC::AssemblyHelpers::load64ToReg): (JSC::AssemblyHelpers::load32ToReg): * runtime/JSCConfig.h: * runtime/OptionsList.h: * tools/JSDollarVM.cpp: * tools/VMInspector.cpp: (JSC::VMInspector::dumpValue): * wasm/WasmAirIRGenerator.cpp: (JSC::Wasm::ConstrainedTmp::operator bool const): (JSC::Wasm::TypedTmp::dump const): (JSC::Wasm::AirIRGenerator::ControlData::ControlData): (JSC::Wasm::AirIRGenerator::ControlData::dump const): (JSC::Wasm::AirIRGenerator::ControlData::blockType const): (JSC::Wasm::AirIRGenerator::ControlData::signature const): (JSC::Wasm::AirIRGenerator::ControlData::targetBlockForBranch): (JSC::Wasm::AirIRGenerator::ControlData::convertIfToBlock): (JSC::Wasm::AirIRGenerator::addEndToUnreachable): (JSC::Wasm::AirIRGenerator::emitCallPatchpoint): (JSC::Wasm::AirIRGenerator::validateInst): (JSC::Wasm::AirIRGenerator::tmpsForSignature): (JSC::Wasm::AirIRGenerator::emitPatchpoint): (JSC::Wasm::AirIRGenerator::AirIRGenerator): (JSC::Wasm::AirIRGenerator::toB3ResultType): (JSC::Wasm::AirIRGenerator::addBottom): (JSC::Wasm::AirIRGenerator::emitLoopTierUpCheck): (JSC::Wasm::AirIRGenerator::addTopLevel): (JSC::Wasm::AirIRGenerator::addLoop): (JSC::Wasm::AirIRGenerator::addBlock): (JSC::Wasm::AirIRGenerator::addIf): (JSC::Wasm::AirIRGenerator::addElse): (JSC::Wasm::AirIRGenerator::addElseToUnreachable): (JSC::Wasm::AirIRGenerator::addReturn): (JSC::Wasm::AirIRGenerator::addBranch): (JSC::Wasm::AirIRGenerator::addSwitch): (JSC::Wasm::AirIRGenerator::endBlock): (JSC::Wasm::AirIRGenerator::addCall): (JSC::Wasm::AirIRGenerator::addCallIndirect): (JSC::Wasm::dumpExpressionStack): (JSC::Wasm::AirIRGenerator::dump): (JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncUF64>): (JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncUF32>): (JSC::Wasm::AirIRGenerator::ControlData::type const): Deleted. (JSC::Wasm::AirIRGenerator::ControlData::hasNonVoidSignature const): Deleted. (JSC::Wasm::AirIRGenerator::ControlData::resultForBranch const): Deleted. * wasm/WasmB3IRGenerator.cpp: (JSC::Wasm::B3IRGenerator::ControlData::ControlData): (JSC::Wasm::B3IRGenerator::ControlData::dump const): (JSC::Wasm::B3IRGenerator::ControlData::blockType const): (JSC::Wasm::B3IRGenerator::ControlData::hasNonVoidresult const): (JSC::Wasm::B3IRGenerator::ControlData::targetBlockForBranch): (JSC::Wasm::B3IRGenerator::ControlData::convertIfToBlock): (JSC::Wasm::B3IRGenerator::addEndToUnreachable): (JSC::Wasm::B3IRGenerator::B3IRGenerator): (JSC::Wasm::B3IRGenerator::framePointer): (JSC::Wasm::B3IRGenerator::toB3ResultType): (JSC::Wasm::B3IRGenerator::addArguments): (JSC::Wasm::B3IRGenerator::addGrowMemory): (JSC::Wasm::B3IRGenerator::addLoop): (JSC::Wasm::B3IRGenerator::addTopLevel): (JSC::Wasm::B3IRGenerator::addBlock): (JSC::Wasm::B3IRGenerator::addIf): (JSC::Wasm::B3IRGenerator::addElse): (JSC::Wasm::B3IRGenerator::addElseToUnreachable): (JSC::Wasm::B3IRGenerator::addReturn): (JSC::Wasm::B3IRGenerator::addBranch): (JSC::Wasm::B3IRGenerator::addSwitch): (JSC::Wasm::B3IRGenerator::endBlock): (JSC::Wasm::B3IRGenerator::createCallPatchpoint): (JSC::Wasm::B3IRGenerator::addCall): (JSC::Wasm::B3IRGenerator::addCallIndirect): (JSC::Wasm::B3IRGenerator::ControlData::type const): Deleted. (JSC::Wasm::B3IRGenerator::ControlData::hasNonVoidSignature const): Deleted. (JSC::Wasm::B3IRGenerator::ControlData::resultForBranch const): Deleted. (JSC::Wasm::B3IRGenerator::createStack): Deleted. * wasm/WasmBBQPlan.cpp: (JSC::Wasm::BBQPlan::didReceiveFunctionData): (JSC::Wasm::BBQPlan::parseAndValidateModule): (JSC::Wasm::BBQPlan::complete): * wasm/WasmBBQPlan.h: * wasm/WasmBinding.cpp: (JSC::Wasm::wasmToWasm): * wasm/WasmCallingConvention.cpp: (JSC::Wasm::jsCallingConvention): (JSC::Wasm::wasmCallingConvention): (JSC::Wasm::jscCallingConvention): Deleted. (JSC::Wasm::jscCallingConventionAir): Deleted. (JSC::Wasm::wasmCallingConventionAir): Deleted. * wasm/WasmCallingConvention.h: (JSC::Wasm::CallInformation::CallInformation): (JSC::Wasm::CallInformation::computeResultsOffsetList): (JSC::Wasm::WasmCallingConvention::WasmCallingConvention): (JSC::Wasm::WasmCallingConvention::marshallLocationImpl const): (JSC::Wasm::WasmCallingConvention::marshallLocation const): (JSC::Wasm::WasmCallingConvention::callInformationFor const): (JSC::Wasm::JSCallingConvention::JSCallingConvention): (JSC::Wasm::JSCallingConvention::marshallLocationImpl const): (JSC::Wasm::JSCallingConvention::marshallLocation const): (JSC::Wasm::JSCallingConvention::callInformationFor const): (JSC::Wasm::CallingConvention::CallingConvention): Deleted. (JSC::Wasm::CallingConvention::marshallArgumentImpl const): Deleted. (JSC::Wasm::CallingConvention::marshallArgument const): Deleted. (JSC::Wasm::CallingConvention::headerSizeInBytes): Deleted. (JSC::Wasm::CallingConvention::setupFrameInPrologue const): Deleted. (JSC::Wasm::CallingConvention::loadArguments const): Deleted. (JSC::Wasm::CallingConvention::setupCall const): Deleted. (JSC::Wasm::CallingConventionAir::CallingConventionAir): Deleted. (JSC::Wasm::CallingConventionAir::prologueScratch const): Deleted. (JSC::Wasm::CallingConventionAir::marshallArgumentImpl const): Deleted. (JSC::Wasm::CallingConventionAir::marshallArgument const): Deleted. (JSC::Wasm::CallingConventionAir::headerSizeInBytes): Deleted. (JSC::Wasm::CallingConventionAir::loadArguments const): Deleted. (JSC::Wasm::CallingConventionAir::setupCall const): Deleted. (JSC::Wasm::nextJSCOffset): Deleted. * wasm/WasmFormat.h: * wasm/WasmFunctionParser.h: (JSC::Wasm::splitStack): (JSC::Wasm::FunctionParser::signature const): (JSC::Wasm::FunctionParser<Context>::FunctionParser): (JSC::Wasm::FunctionParser<Context>::parseBody): (JSC::Wasm::FunctionParser<Context>::parseExpression): (JSC::Wasm::FunctionParser<Context>::parseUnreachableExpression): * wasm/WasmInstance.h: * wasm/WasmMemoryInformation.cpp: (JSC::Wasm::getPinnedRegisters): * wasm/WasmOMGForOSREntryPlan.cpp: (JSC::Wasm::OMGForOSREntryPlan::work): * wasm/WasmOMGPlan.cpp: (JSC::Wasm::OMGPlan::work): * wasm/WasmParser.h: (JSC::Wasm::FailureHelper::makeString): (JSC::Wasm::Parser<SuccessType>::Parser): (JSC::Wasm::Parser<SuccessType>::peekInt7): (JSC::Wasm::Parser<SuccessType>::parseBlockSignature): (JSC::Wasm::Parser<SuccessType>::parseValueType): (JSC::Wasm::Parser<SuccessType>::parseResultType): Deleted. * wasm/WasmSectionParser.cpp: (JSC::Wasm::SectionParser::parseType): (JSC::Wasm::SectionParser::parseStart): * wasm/WasmSectionParser.h: * wasm/WasmSignature.cpp: (JSC::Wasm::Signature::toString const): (JSC::Wasm::Signature::dump const): (JSC::Wasm::computeHash): (JSC::Wasm::Signature::hash const): (JSC::Wasm::Signature::tryCreate): (JSC::Wasm::SignatureInformation::SignatureInformation): (JSC::Wasm::ParameterTypes::hash): (JSC::Wasm::ParameterTypes::equal): (JSC::Wasm::ParameterTypes::translate): (JSC::Wasm::SignatureInformation::signatureFor): (JSC::Wasm::SignatureInformation::adopt): Deleted. * wasm/WasmSignature.h: (JSC::Wasm::Signature::Signature): (JSC::Wasm::Signature::allocatedSize): (JSC::Wasm::Signature::returnCount const): (JSC::Wasm::Signature::returnType const): (JSC::Wasm::Signature::returnsVoid const): (JSC::Wasm::Signature::argument const): (JSC::Wasm::Signature::operator== const): (JSC::Wasm::Signature::getReturnType): (JSC::Wasm::Signature::getArgument): (JSC::Wasm::SignatureHash::SignatureHash): (JSC::Wasm::SignatureHash::equal): (JSC::Wasm::SignatureInformation::thunkFor const): (JSC::Wasm::Signature::returnType): Deleted. (JSC::Wasm::Signature::argument): Deleted. * wasm/WasmStreamingParser.cpp: (JSC::Wasm::StreamingParser::parseCodeSectionSize): (JSC::Wasm::StreamingParser::parseFunctionPayload): (JSC::Wasm::StreamingParser::parseSectionPayload): * wasm/WasmStreamingParser.h: (JSC::Wasm::StreamingParserClient::didReceiveSectionData): (JSC::Wasm::StreamingParser::reportError): (JSC::Wasm::StreamingParserClient::didReceiveFunctionData): Deleted. * wasm/WasmThunks.cpp: (JSC::Wasm::throwExceptionFromWasmThunkGenerator): (JSC::Wasm::throwStackOverflowFromWasmThunkGenerator): (JSC::Wasm::triggerOMGEntryTierUpThunkGenerator): * wasm/WasmValidate.cpp: (JSC::Wasm::Validate::ControlData::ControlData): (JSC::Wasm::Validate::ControlData::dump const): (JSC::Wasm::Validate::ControlData::blockType const): (JSC::Wasm::Validate::ControlData::signature const): (JSC::Wasm::Validate::ControlData::branchTargetArity const): (JSC::Wasm::Validate::ControlData::branchTargetType const): (JSC::Wasm::Validate::fail const): (JSC::Wasm::Validate::addTableGet): (JSC::Wasm::Validate::addTableGrow): (JSC::Wasm::Validate::addTableFill): (JSC::Wasm::Validate::addRefIsNull): (JSC::Wasm::Validate::addTopLevel): (JSC::Wasm::splitStack): (JSC::Wasm::Validate::addBlock): (JSC::Wasm::Validate::addLoop): (JSC::Wasm::Validate::addIf): (JSC::Wasm::Validate::addElseToUnreachable): (JSC::Wasm::Validate::addReturn): (JSC::Wasm::Validate::checkBranchTarget): (JSC::Wasm::Validate::addSwitch): (JSC::Wasm::Validate::addGrowMemory): (JSC::Wasm::Validate::addEndToUnreachable): (JSC::Wasm::Validate::addCall): (JSC::Wasm::Validate::addCallIndirect): (JSC::Wasm::Validate::unify): (JSC::Wasm::Validate::ControlData::hasNonVoidSignature const): Deleted. (JSC::Wasm::Validate::ControlData::type const): Deleted. (JSC::Wasm::Validate::ControlData::branchTargetSignature const): Deleted. * wasm/generateWasmOpsHeader.py: * wasm/js/JSToWasm.cpp: (JSC::Wasm::boxWasmResult): (JSC::Wasm::allocateResultsArray): (JSC::Wasm::marshallJSResult): (JSC::Wasm::createJSToWasmWrapper): * wasm/js/JSToWasm.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): * wasm/js/WasmToJS.cpp: (JSC::Wasm::handleBadI64Use): (JSC::Wasm::wasmToJS): * wasm/js/WasmToJS.h: * wasm/js/WebAssemblyFunction.cpp: (JSC::callWebAssemblyFunction): (JSC::WebAssemblyFunction::useTagRegisters const): (JSC::WebAssemblyFunction::jsCallEntrypointSlow): * wasm/js/WebAssemblyModuleRecord.cpp: (JSC::WebAssemblyModuleRecord::link): Tools: * Scripts/run-jsc-stress-tests: Canonical link: https://commits.webkit.org/215930@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250559 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-10-01 16:38:26 +00:00
var WabtModule = (function() {
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
WebAssembly: update wabt.js https://bugs.webkit.org/show_bug.cgi?id=218876 Patch by Sergey Rubanov <chi187@gmail.com> on 2020-11-13 Reviewed by Yusuke Suzuki. * wasm/libwabt.js: (WabtModule): Deleted. * wasm/regress/llint-callee-saves-with-fast-memory.js: (async test): * wasm/regress/llint-callee-saves-without-fast-memory.js: (async test): * wasm/regress/regression-with-loop.js: (async test): * wasm/regress/stack-consistency.js: (async test): * wasm/stress/js-wasm-call-many-return-types-on-stack-no-args.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/stress/js-wasm-js-varying-arities.js: (async paramForwarder): (async test): (paramForwarder): Deleted. * wasm/stress/local-ref.js: (async test): * wasm/stress/loop-more-args-than-results.js: (async test): * wasm/stress/set-local-enclosed-stack.js: (async test): (assert.eq.instance.exports.foo): Deleted. (assert.eq): Deleted. * wasm/stress/top-most-enclosing-stack.js: (async test): * wasm/stress/trunc-int-min-minus-one.js: (async test): * wasm/stress/wasm-js-call-many-return-types-on-stack-no-args.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/stress/wasm-js-multi-value-exception-in-iterator.js: (async buildWat): (async test): (buildWat.throwError): Deleted. (buildWat.throwErrorInIterator): Deleted. (buildWat.tooManyValues): Deleted. (buildWat.tooFewValues): Deleted. (buildWat): Deleted. * wasm/stress/wasm-wasm-call-indirect-many-return-types-on-stack.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/stress/wasm-wasm-call-many-return-types-on-stack-no-args.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/wabt-wrapper.js: (export.async compile): (export.compile): Deleted. Canonical link: https://commits.webkit.org/231540@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269766 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-11-13 08:36:26 +00:00
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
Add support for the Wasm multi-value proposal https://bugs.webkit.org/show_bug.cgi?id=202250 Reviewed by Saam Barati. JSTests: This patch adds a new way to run stress tests via the .wat text format. By attaching an asm.js compiled version of the wabt tool we can easily create wat files programatically and convert them into a wasm blob to compile. To make this easy there is a wabt-wrapper.js module file that exports two useful functions that correspond to WebAssembly.compile and WebAssembly.instantiate. * wasm.yaml: * wasm/function-tests/if-no-else-non-void.js: * wasm/js-api/web-assembly-instantiate.js: (assert.asyncTest.async.test): (assert.asyncTest): * wasm/libwabt.js: Added. (WabtModule): (set get if): * wasm/references/func_ref.js: * wasm/references/validation.js: (assert.throws): * wasm/spec-harness/index.js: * wasm/spec-tests/block.wast.js: * wasm/spec-tests/br.wast.js: * wasm/spec-tests/br_if.wast.js: * wasm/spec-tests/call.wast.js: * wasm/spec-tests/call_indirect.wast.js: * wasm/spec-tests/func.wast.js: * wasm/spec-tests/if.wast.js: * wasm/spec-tests/loop.wast.js: * wasm/spec-tests/type.wast.js: * wasm/stress/js-wasm-call-many-return-types-on-stack-no-args.js: Added. (buildWat): * wasm/stress/js-wasm-js-varying-arities.js: Added. (paramForwarder): * wasm/stress/wasm-js-call-many-return-types-on-stack-no-args.js: Added. (buildWat): * wasm/stress/wasm-js-multi-value-exception-in-iterator.js: Added. (buildWat.throwError): (buildWat.throwErrorInIterator): (buildWat.tooManyValues): (buildWat.tooFewValues): (buildWat): * wasm/stress/wasm-wasm-call-indirect-many-return-types-on-stack.js: Added. (buildWat): * wasm/stress/wasm-wasm-call-many-return-types-on-stack-no-args.js: Added. (buildWat): * wasm/wabt-wrapper.js: Added. (export.compile): * wasm/wast-tests/br-if-at-end-of-block.wasm: Added. * wasm/wast-tests/br-if-at-end-of-block.wast: Added. * wasm/wast-tests/harness.js: (async.runWasmFile): * wasm/wast-tests/single-param-loop-signature.wasm: Added. * wasm/wast-tests/single-param-loop-signature.wast: Added. Source/JavaScriptCore: The wasm multi-value proposal makes two major changes to the spec. The first is that functions may now return more than one value across calls. When calling to/from JS, if there is more than one return type we return/receive a JSArray/Iterable, respectively. In the Wasm calls JS case, if the iteratable object does not vend the exact number of objects expected by the signature an error is thrown. The second major change in the multi-value proposal allows blocks to have any signature type. This works in a backwards compatible way by exploiting the fact that the old value-type thunk signatures (where the block takes no arguments and returns just the value type i.e. [] -> [type]) were always encoded as a negative number. If a block has a function signature, it is encoded as a positive index into the type section. When a block has a function signature type then the values from the enclosing stack are popped off that stack and added to the new block's stack. In the case of a br/br_if to a Loop block the "argument" values should be on the brancher's stack. The biggest change in this patch is stripping down the WasmCallingConventions file into one simpler API that just tells you where the each argument should be located. It also now handles adding or subtracting sizeof(CallerFrameAndPC) depending on whether you are caller or callee. Additionally, when computing locations for the callee it returns a B3::ValueRep that has the offsetFromFP rather than offsetFromSP. Since the code has been cleaned up I tried to also reduce code duplication in the various stubs for wasm code. This patch also removes the Air specific calling convention code and moves that logic into the Air IR generator. Since blocks can now have arbitrary signatures the control entries now use a const signature* rather than just the return type. Additionally, what used to be the result phi is now the phis for all the results for non-loop blocks and the arguments for a loop block. Due to the control flow restrictions of wasm conveniently we don't have to worry about generating non-optimal SSA, thus we can just use phis directly rather than using a variable. Lastly, to help clean up some code in the IR generators new helper methods were added to create call Patchpoints. These helpers do most of the boiler-plate initialization. * JavaScriptCore.xcodeproj/project.pbxproj: * assembler/AbstractMacroAssembler.h: (JSC::AbstractMacroAssembler::ImplicitAddress::ImplicitAddress): * assembler/LinkBuffer.cpp: (JSC::shouldDumpDisassemblyFor): * assembler/LinkBuffer.h: * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::callOperation): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::callOperation): * b3/B3LowerToAir.cpp: * b3/B3PatchpointSpecial.cpp: (JSC::B3::PatchpointSpecial::forEachArg): (JSC::B3::PatchpointSpecial::isValid): (JSC::B3::PatchpointSpecial::admitsStack): (JSC::B3::PatchpointSpecial::generate): * b3/B3Procedure.h: (JSC::B3::Procedure::resultCount const): (JSC::B3::Procedure::typeAtOffset const): (JSC::B3::Procedure::returnCount const): Deleted. * b3/B3StackmapGenerationParams.cpp: (JSC::B3::StackmapGenerationParams::code const): * b3/B3StackmapGenerationParams.h: * b3/B3ValueRep.h: * b3/air/AirHelpers.h: Added. (JSC::B3::Air::moveForType): (JSC::B3::Air::relaxedMoveForType): * jit/AssemblyHelpers.h: (JSC::AssemblyHelpers::store64FromReg): (JSC::AssemblyHelpers::store32FromReg): (JSC::AssemblyHelpers::load64ToReg): (JSC::AssemblyHelpers::load32ToReg): * runtime/JSCConfig.h: * runtime/OptionsList.h: * tools/JSDollarVM.cpp: * tools/VMInspector.cpp: (JSC::VMInspector::dumpValue): * wasm/WasmAirIRGenerator.cpp: (JSC::Wasm::ConstrainedTmp::operator bool const): (JSC::Wasm::TypedTmp::dump const): (JSC::Wasm::AirIRGenerator::ControlData::ControlData): (JSC::Wasm::AirIRGenerator::ControlData::dump const): (JSC::Wasm::AirIRGenerator::ControlData::blockType const): (JSC::Wasm::AirIRGenerator::ControlData::signature const): (JSC::Wasm::AirIRGenerator::ControlData::targetBlockForBranch): (JSC::Wasm::AirIRGenerator::ControlData::convertIfToBlock): (JSC::Wasm::AirIRGenerator::addEndToUnreachable): (JSC::Wasm::AirIRGenerator::emitCallPatchpoint): (JSC::Wasm::AirIRGenerator::validateInst): (JSC::Wasm::AirIRGenerator::tmpsForSignature): (JSC::Wasm::AirIRGenerator::emitPatchpoint): (JSC::Wasm::AirIRGenerator::AirIRGenerator): (JSC::Wasm::AirIRGenerator::toB3ResultType): (JSC::Wasm::AirIRGenerator::addBottom): (JSC::Wasm::AirIRGenerator::emitLoopTierUpCheck): (JSC::Wasm::AirIRGenerator::addTopLevel): (JSC::Wasm::AirIRGenerator::addLoop): (JSC::Wasm::AirIRGenerator::addBlock): (JSC::Wasm::AirIRGenerator::addIf): (JSC::Wasm::AirIRGenerator::addElse): (JSC::Wasm::AirIRGenerator::addElseToUnreachable): (JSC::Wasm::AirIRGenerator::addReturn): (JSC::Wasm::AirIRGenerator::addBranch): (JSC::Wasm::AirIRGenerator::addSwitch): (JSC::Wasm::AirIRGenerator::endBlock): (JSC::Wasm::AirIRGenerator::addCall): (JSC::Wasm::AirIRGenerator::addCallIndirect): (JSC::Wasm::dumpExpressionStack): (JSC::Wasm::AirIRGenerator::dump): (JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncUF64>): (JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncUF32>): (JSC::Wasm::AirIRGenerator::ControlData::type const): Deleted. (JSC::Wasm::AirIRGenerator::ControlData::hasNonVoidSignature const): Deleted. (JSC::Wasm::AirIRGenerator::ControlData::resultForBranch const): Deleted. * wasm/WasmB3IRGenerator.cpp: (JSC::Wasm::B3IRGenerator::ControlData::ControlData): (JSC::Wasm::B3IRGenerator::ControlData::dump const): (JSC::Wasm::B3IRGenerator::ControlData::blockType const): (JSC::Wasm::B3IRGenerator::ControlData::hasNonVoidresult const): (JSC::Wasm::B3IRGenerator::ControlData::targetBlockForBranch): (JSC::Wasm::B3IRGenerator::ControlData::convertIfToBlock): (JSC::Wasm::B3IRGenerator::addEndToUnreachable): (JSC::Wasm::B3IRGenerator::B3IRGenerator): (JSC::Wasm::B3IRGenerator::framePointer): (JSC::Wasm::B3IRGenerator::toB3ResultType): (JSC::Wasm::B3IRGenerator::addArguments): (JSC::Wasm::B3IRGenerator::addGrowMemory): (JSC::Wasm::B3IRGenerator::addLoop): (JSC::Wasm::B3IRGenerator::addTopLevel): (JSC::Wasm::B3IRGenerator::addBlock): (JSC::Wasm::B3IRGenerator::addIf): (JSC::Wasm::B3IRGenerator::addElse): (JSC::Wasm::B3IRGenerator::addElseToUnreachable): (JSC::Wasm::B3IRGenerator::addReturn): (JSC::Wasm::B3IRGenerator::addBranch): (JSC::Wasm::B3IRGenerator::addSwitch): (JSC::Wasm::B3IRGenerator::endBlock): (JSC::Wasm::B3IRGenerator::createCallPatchpoint): (JSC::Wasm::B3IRGenerator::addCall): (JSC::Wasm::B3IRGenerator::addCallIndirect): (JSC::Wasm::B3IRGenerator::ControlData::type const): Deleted. (JSC::Wasm::B3IRGenerator::ControlData::hasNonVoidSignature const): Deleted. (JSC::Wasm::B3IRGenerator::ControlData::resultForBranch const): Deleted. (JSC::Wasm::B3IRGenerator::createStack): Deleted. * wasm/WasmBBQPlan.cpp: (JSC::Wasm::BBQPlan::didReceiveFunctionData): (JSC::Wasm::BBQPlan::parseAndValidateModule): (JSC::Wasm::BBQPlan::complete): * wasm/WasmBBQPlan.h: * wasm/WasmBinding.cpp: (JSC::Wasm::wasmToWasm): * wasm/WasmCallingConvention.cpp: (JSC::Wasm::jsCallingConvention): (JSC::Wasm::wasmCallingConvention): (JSC::Wasm::jscCallingConvention): Deleted. (JSC::Wasm::jscCallingConventionAir): Deleted. (JSC::Wasm::wasmCallingConventionAir): Deleted. * wasm/WasmCallingConvention.h: (JSC::Wasm::CallInformation::CallInformation): (JSC::Wasm::CallInformation::computeResultsOffsetList): (JSC::Wasm::WasmCallingConvention::WasmCallingConvention): (JSC::Wasm::WasmCallingConvention::marshallLocationImpl const): (JSC::Wasm::WasmCallingConvention::marshallLocation const): (JSC::Wasm::WasmCallingConvention::callInformationFor const): (JSC::Wasm::JSCallingConvention::JSCallingConvention): (JSC::Wasm::JSCallingConvention::marshallLocationImpl const): (JSC::Wasm::JSCallingConvention::marshallLocation const): (JSC::Wasm::JSCallingConvention::callInformationFor const): (JSC::Wasm::CallingConvention::CallingConvention): Deleted. (JSC::Wasm::CallingConvention::marshallArgumentImpl const): Deleted. (JSC::Wasm::CallingConvention::marshallArgument const): Deleted. (JSC::Wasm::CallingConvention::headerSizeInBytes): Deleted. (JSC::Wasm::CallingConvention::setupFrameInPrologue const): Deleted. (JSC::Wasm::CallingConvention::loadArguments const): Deleted. (JSC::Wasm::CallingConvention::setupCall const): Deleted. (JSC::Wasm::CallingConventionAir::CallingConventionAir): Deleted. (JSC::Wasm::CallingConventionAir::prologueScratch const): Deleted. (JSC::Wasm::CallingConventionAir::marshallArgumentImpl const): Deleted. (JSC::Wasm::CallingConventionAir::marshallArgument const): Deleted. (JSC::Wasm::CallingConventionAir::headerSizeInBytes): Deleted. (JSC::Wasm::CallingConventionAir::loadArguments const): Deleted. (JSC::Wasm::CallingConventionAir::setupCall const): Deleted. (JSC::Wasm::nextJSCOffset): Deleted. * wasm/WasmFormat.h: * wasm/WasmFunctionParser.h: (JSC::Wasm::splitStack): (JSC::Wasm::FunctionParser::signature const): (JSC::Wasm::FunctionParser<Context>::FunctionParser): (JSC::Wasm::FunctionParser<Context>::parseBody): (JSC::Wasm::FunctionParser<Context>::parseExpression): (JSC::Wasm::FunctionParser<Context>::parseUnreachableExpression): * wasm/WasmInstance.h: * wasm/WasmMemoryInformation.cpp: (JSC::Wasm::getPinnedRegisters): * wasm/WasmOMGForOSREntryPlan.cpp: (JSC::Wasm::OMGForOSREntryPlan::work): * wasm/WasmOMGPlan.cpp: (JSC::Wasm::OMGPlan::work): * wasm/WasmParser.h: (JSC::Wasm::FailureHelper::makeString): (JSC::Wasm::Parser<SuccessType>::Parser): (JSC::Wasm::Parser<SuccessType>::peekInt7): (JSC::Wasm::Parser<SuccessType>::parseBlockSignature): (JSC::Wasm::Parser<SuccessType>::parseValueType): (JSC::Wasm::Parser<SuccessType>::parseResultType): Deleted. * wasm/WasmSectionParser.cpp: (JSC::Wasm::SectionParser::parseType): (JSC::Wasm::SectionParser::parseStart): * wasm/WasmSectionParser.h: * wasm/WasmSignature.cpp: (JSC::Wasm::Signature::toString const): (JSC::Wasm::Signature::dump const): (JSC::Wasm::computeHash): (JSC::Wasm::Signature::hash const): (JSC::Wasm::Signature::tryCreate): (JSC::Wasm::SignatureInformation::SignatureInformation): (JSC::Wasm::ParameterTypes::hash): (JSC::Wasm::ParameterTypes::equal): (JSC::Wasm::ParameterTypes::translate): (JSC::Wasm::SignatureInformation::signatureFor): (JSC::Wasm::SignatureInformation::adopt): Deleted. * wasm/WasmSignature.h: (JSC::Wasm::Signature::Signature): (JSC::Wasm::Signature::allocatedSize): (JSC::Wasm::Signature::returnCount const): (JSC::Wasm::Signature::returnType const): (JSC::Wasm::Signature::returnsVoid const): (JSC::Wasm::Signature::argument const): (JSC::Wasm::Signature::operator== const): (JSC::Wasm::Signature::getReturnType): (JSC::Wasm::Signature::getArgument): (JSC::Wasm::SignatureHash::SignatureHash): (JSC::Wasm::SignatureHash::equal): (JSC::Wasm::SignatureInformation::thunkFor const): (JSC::Wasm::Signature::returnType): Deleted. (JSC::Wasm::Signature::argument): Deleted. * wasm/WasmStreamingParser.cpp: (JSC::Wasm::StreamingParser::parseCodeSectionSize): (JSC::Wasm::StreamingParser::parseFunctionPayload): (JSC::Wasm::StreamingParser::parseSectionPayload): * wasm/WasmStreamingParser.h: (JSC::Wasm::StreamingParserClient::didReceiveSectionData): (JSC::Wasm::StreamingParser::reportError): (JSC::Wasm::StreamingParserClient::didReceiveFunctionData): Deleted. * wasm/WasmThunks.cpp: (JSC::Wasm::throwExceptionFromWasmThunkGenerator): (JSC::Wasm::throwStackOverflowFromWasmThunkGenerator): (JSC::Wasm::triggerOMGEntryTierUpThunkGenerator): * wasm/WasmValidate.cpp: (JSC::Wasm::Validate::ControlData::ControlData): (JSC::Wasm::Validate::ControlData::dump const): (JSC::Wasm::Validate::ControlData::blockType const): (JSC::Wasm::Validate::ControlData::signature const): (JSC::Wasm::Validate::ControlData::branchTargetArity const): (JSC::Wasm::Validate::ControlData::branchTargetType const): (JSC::Wasm::Validate::fail const): (JSC::Wasm::Validate::addTableGet): (JSC::Wasm::Validate::addTableGrow): (JSC::Wasm::Validate::addTableFill): (JSC::Wasm::Validate::addRefIsNull): (JSC::Wasm::Validate::addTopLevel): (JSC::Wasm::splitStack): (JSC::Wasm::Validate::addBlock): (JSC::Wasm::Validate::addLoop): (JSC::Wasm::Validate::addIf): (JSC::Wasm::Validate::addElseToUnreachable): (JSC::Wasm::Validate::addReturn): (JSC::Wasm::Validate::checkBranchTarget): (JSC::Wasm::Validate::addSwitch): (JSC::Wasm::Validate::addGrowMemory): (JSC::Wasm::Validate::addEndToUnreachable): (JSC::Wasm::Validate::addCall): (JSC::Wasm::Validate::addCallIndirect): (JSC::Wasm::Validate::unify): (JSC::Wasm::Validate::ControlData::hasNonVoidSignature const): Deleted. (JSC::Wasm::Validate::ControlData::type const): Deleted. (JSC::Wasm::Validate::ControlData::branchTargetSignature const): Deleted. * wasm/generateWasmOpsHeader.py: * wasm/js/JSToWasm.cpp: (JSC::Wasm::boxWasmResult): (JSC::Wasm::allocateResultsArray): (JSC::Wasm::marshallJSResult): (JSC::Wasm::createJSToWasmWrapper): * wasm/js/JSToWasm.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): * wasm/js/WasmToJS.cpp: (JSC::Wasm::handleBadI64Use): (JSC::Wasm::wasmToJS): * wasm/js/WasmToJS.h: * wasm/js/WebAssemblyFunction.cpp: (JSC::callWebAssemblyFunction): (JSC::WebAssemblyFunction::useTagRegisters const): (JSC::WebAssemblyFunction::jsCallEntrypointSlow): * wasm/js/WebAssemblyModuleRecord.cpp: (JSC::WebAssemblyModuleRecord::link): Tools: * Scripts/run-jsc-stress-tests: Canonical link: https://commits.webkit.org/215930@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250559 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-10-01 16:38:26 +00:00
return (
function(WabtModule) {
WabtModule = WabtModule || {};
WebAssembly: update wabt.js https://bugs.webkit.org/show_bug.cgi?id=218876 Patch by Sergey Rubanov <chi187@gmail.com> on 2020-11-13 Reviewed by Yusuke Suzuki. * wasm/libwabt.js: (WabtModule): Deleted. * wasm/regress/llint-callee-saves-with-fast-memory.js: (async test): * wasm/regress/llint-callee-saves-without-fast-memory.js: (async test): * wasm/regress/regression-with-loop.js: (async test): * wasm/regress/stack-consistency.js: (async test): * wasm/stress/js-wasm-call-many-return-types-on-stack-no-args.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/stress/js-wasm-js-varying-arities.js: (async paramForwarder): (async test): (paramForwarder): Deleted. * wasm/stress/local-ref.js: (async test): * wasm/stress/loop-more-args-than-results.js: (async test): * wasm/stress/set-local-enclosed-stack.js: (async test): (assert.eq.instance.exports.foo): Deleted. (assert.eq): Deleted. * wasm/stress/top-most-enclosing-stack.js: (async test): * wasm/stress/trunc-int-min-minus-one.js: (async test): * wasm/stress/wasm-js-call-many-return-types-on-stack-no-args.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/stress/wasm-js-multi-value-exception-in-iterator.js: (async buildWat): (async test): (buildWat.throwError): Deleted. (buildWat.throwErrorInIterator): Deleted. (buildWat.tooManyValues): Deleted. (buildWat.tooFewValues): Deleted. (buildWat): Deleted. * wasm/stress/wasm-wasm-call-indirect-many-return-types-on-stack.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/stress/wasm-wasm-call-many-return-types-on-stack-no-args.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/wabt-wrapper.js: (export.async compile): (export.compile): Deleted. Canonical link: https://commits.webkit.org/231540@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269766 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-11-13 08:36:26 +00:00
var Module=typeof WabtModule!=="undefined"?WabtModule:{};var readyPromiseResolve,readyPromiseReject;Module["ready"]=new Promise(function(resolve,reject){readyPromiseResolve=resolve;readyPromiseReject=reject});var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var arguments_=[];var thisProgram="./this.program";var quit_=function(status,toThrow){throw toThrow};var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string";ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary,setWindowTitle;var nodeFS;var nodePath;if(ENVIRONMENT_IS_NODE){if(ENVIRONMENT_IS_WORKER){scriptDirectory=require("path").dirname(scriptDirectory)+"/"}else{scriptDirectory=__dirname+"/"}read_=function shell_read(filename,binary){var ret=tryParseAsDataURI(filename);if(ret){return binary?ret:ret.toString()}if(!nodeFS)nodeFS=require("fs");if(!nodePath)nodePath=require("path");filename=nodePath["normalize"](filename);return nodeFS["readFileSync"](filename,binary?null:"utf8")};readBinary=function readBinary(filename){var ret=read_(filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};if(process["argv"].length>1){thisProgram=process["argv"][1].replace(/\\/g,"/")}arguments_=process["argv"].slice(2);process["on"]("uncaughtException",function(ex){if(!(ex instanceof ExitStatus)){throw ex}});process["on"]("unhandledRejection",abort);quit_=function(status){process["exit"](status)};Module["inspect"]=function(){return"[Emscripten Module object]"}}else if(ENVIRONMENT_IS_SHELL){if(typeof read!="undefined"){read_=function shell_read(f){var data=tryParseAsDataURI(f);if(data){return intArrayToString(data)}return read(f)}}readBinary=function readBinary(f){var data;data=tryParseAsDataURI(f);if(data){return data}if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){arguments_=scriptArgs}else if(typeof arguments!="undefined"){arguments_=arguments}if(typeof quit==="function"){quit_=function(status){quit(status)}}if(typeof print!=="undefined"){if(typeof console==="undefined")console={};console.log=print;console.warn=console.error=typeof printErr!=="undefined"?printErr:print}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptDir){scriptDirectory=_scriptDir}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=function shell_read(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText}catch(err){var data=tryParseAsDataURI(url);if(data){return intArrayToString(data)}throw err}};if(ENVIRONMENT_IS_WORKER){readBinary=function readBinary(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}catch(err){var data=tryParseAsDataURI(url);if(data){return data}throw err}}}readAsync=function readAsync(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function xhr_onload(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}var data=tryParseAsDataURI(url);if(data){onload(data.buffer);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=function(title){document.title=title}}else{}var out=Module["print"]||console.log.bind(
// EMSCRIPTEN_START_ASM
function a(asmLibraryArg,wasmMemory,wasmTable){var scratchBuffer=new ArrayBuffer(8);var b=new Int32Array(scratchBuffer);var c=new Float32Array(scratchBuffer);var d=new Float64Array(scratchBuffer);function e(index){return b[index]}function f(index,value){b[index]=value}function g(){return d[0]}function h(value){d[0]=value}function i(){return c[0]}function j(value){c[0]=value}function k(global,env,buffer){var l=env.memory;var m=wasmTable;var n=new global.Int8Array(buffer);var o=new global.Int16Array(buffer);var p=new global.Int32Array(buffer);var q=new global.Uint8Array(buffer);var r=new global.Uint16Array(buffer);var s=new global.Uint32Array(buffer);var t=new global.Float32Array(buffer);var u=new global.Float64Array(buffer);var v=global.Math.imul;var w=global.Math.fround;var x=global.Math.abs;var y=global.Math.clz32;var z=global.Math.min;var A=global.Math.max;var B=global.Math.floor;var C=global.Math.ceil;var D=global.Math.sqrt;var E=env.abort;var F=global.NaN;var G=global.Infinity;var H=env.a;var I=env.b;var J=env.c;var K=env.d;var L=env.e;var M=env.f;var N=env.g;var O=env.h;var P=5614032;var Q=0;
Add support for the Wasm multi-value proposal https://bugs.webkit.org/show_bug.cgi?id=202250 Reviewed by Saam Barati. JSTests: This patch adds a new way to run stress tests via the .wat text format. By attaching an asm.js compiled version of the wabt tool we can easily create wat files programatically and convert them into a wasm blob to compile. To make this easy there is a wabt-wrapper.js module file that exports two useful functions that correspond to WebAssembly.compile and WebAssembly.instantiate. * wasm.yaml: * wasm/function-tests/if-no-else-non-void.js: * wasm/js-api/web-assembly-instantiate.js: (assert.asyncTest.async.test): (assert.asyncTest): * wasm/libwabt.js: Added. (WabtModule): (set get if): * wasm/references/func_ref.js: * wasm/references/validation.js: (assert.throws): * wasm/spec-harness/index.js: * wasm/spec-tests/block.wast.js: * wasm/spec-tests/br.wast.js: * wasm/spec-tests/br_if.wast.js: * wasm/spec-tests/call.wast.js: * wasm/spec-tests/call_indirect.wast.js: * wasm/spec-tests/func.wast.js: * wasm/spec-tests/if.wast.js: * wasm/spec-tests/loop.wast.js: * wasm/spec-tests/type.wast.js: * wasm/stress/js-wasm-call-many-return-types-on-stack-no-args.js: Added. (buildWat): * wasm/stress/js-wasm-js-varying-arities.js: Added. (paramForwarder): * wasm/stress/wasm-js-call-many-return-types-on-stack-no-args.js: Added. (buildWat): * wasm/stress/wasm-js-multi-value-exception-in-iterator.js: Added. (buildWat.throwError): (buildWat.throwErrorInIterator): (buildWat.tooManyValues): (buildWat.tooFewValues): (buildWat): * wasm/stress/wasm-wasm-call-indirect-many-return-types-on-stack.js: Added. (buildWat): * wasm/stress/wasm-wasm-call-many-return-types-on-stack-no-args.js: Added. (buildWat): * wasm/wabt-wrapper.js: Added. (export.compile): * wasm/wast-tests/br-if-at-end-of-block.wasm: Added. * wasm/wast-tests/br-if-at-end-of-block.wast: Added. * wasm/wast-tests/harness.js: (async.runWasmFile): * wasm/wast-tests/single-param-loop-signature.wasm: Added. * wasm/wast-tests/single-param-loop-signature.wast: Added. Source/JavaScriptCore: The wasm multi-value proposal makes two major changes to the spec. The first is that functions may now return more than one value across calls. When calling to/from JS, if there is more than one return type we return/receive a JSArray/Iterable, respectively. In the Wasm calls JS case, if the iteratable object does not vend the exact number of objects expected by the signature an error is thrown. The second major change in the multi-value proposal allows blocks to have any signature type. This works in a backwards compatible way by exploiting the fact that the old value-type thunk signatures (where the block takes no arguments and returns just the value type i.e. [] -> [type]) were always encoded as a negative number. If a block has a function signature, it is encoded as a positive index into the type section. When a block has a function signature type then the values from the enclosing stack are popped off that stack and added to the new block's stack. In the case of a br/br_if to a Loop block the "argument" values should be on the brancher's stack. The biggest change in this patch is stripping down the WasmCallingConventions file into one simpler API that just tells you where the each argument should be located. It also now handles adding or subtracting sizeof(CallerFrameAndPC) depending on whether you are caller or callee. Additionally, when computing locations for the callee it returns a B3::ValueRep that has the offsetFromFP rather than offsetFromSP. Since the code has been cleaned up I tried to also reduce code duplication in the various stubs for wasm code. This patch also removes the Air specific calling convention code and moves that logic into the Air IR generator. Since blocks can now have arbitrary signatures the control entries now use a const signature* rather than just the return type. Additionally, what used to be the result phi is now the phis for all the results for non-loop blocks and the arguments for a loop block. Due to the control flow restrictions of wasm conveniently we don't have to worry about generating non-optimal SSA, thus we can just use phis directly rather than using a variable. Lastly, to help clean up some code in the IR generators new helper methods were added to create call Patchpoints. These helpers do most of the boiler-plate initialization. * JavaScriptCore.xcodeproj/project.pbxproj: * assembler/AbstractMacroAssembler.h: (JSC::AbstractMacroAssembler::ImplicitAddress::ImplicitAddress): * assembler/LinkBuffer.cpp: (JSC::shouldDumpDisassemblyFor): * assembler/LinkBuffer.h: * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::callOperation): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::callOperation): * b3/B3LowerToAir.cpp: * b3/B3PatchpointSpecial.cpp: (JSC::B3::PatchpointSpecial::forEachArg): (JSC::B3::PatchpointSpecial::isValid): (JSC::B3::PatchpointSpecial::admitsStack): (JSC::B3::PatchpointSpecial::generate): * b3/B3Procedure.h: (JSC::B3::Procedure::resultCount const): (JSC::B3::Procedure::typeAtOffset const): (JSC::B3::Procedure::returnCount const): Deleted. * b3/B3StackmapGenerationParams.cpp: (JSC::B3::StackmapGenerationParams::code const): * b3/B3StackmapGenerationParams.h: * b3/B3ValueRep.h: * b3/air/AirHelpers.h: Added. (JSC::B3::Air::moveForType): (JSC::B3::Air::relaxedMoveForType): * jit/AssemblyHelpers.h: (JSC::AssemblyHelpers::store64FromReg): (JSC::AssemblyHelpers::store32FromReg): (JSC::AssemblyHelpers::load64ToReg): (JSC::AssemblyHelpers::load32ToReg): * runtime/JSCConfig.h: * runtime/OptionsList.h: * tools/JSDollarVM.cpp: * tools/VMInspector.cpp: (JSC::VMInspector::dumpValue): * wasm/WasmAirIRGenerator.cpp: (JSC::Wasm::ConstrainedTmp::operator bool const): (JSC::Wasm::TypedTmp::dump const): (JSC::Wasm::AirIRGenerator::ControlData::ControlData): (JSC::Wasm::AirIRGenerator::ControlData::dump const): (JSC::Wasm::AirIRGenerator::ControlData::blockType const): (JSC::Wasm::AirIRGenerator::ControlData::signature const): (JSC::Wasm::AirIRGenerator::ControlData::targetBlockForBranch): (JSC::Wasm::AirIRGenerator::ControlData::convertIfToBlock): (JSC::Wasm::AirIRGenerator::addEndToUnreachable): (JSC::Wasm::AirIRGenerator::emitCallPatchpoint): (JSC::Wasm::AirIRGenerator::validateInst): (JSC::Wasm::AirIRGenerator::tmpsForSignature): (JSC::Wasm::AirIRGenerator::emitPatchpoint): (JSC::Wasm::AirIRGenerator::AirIRGenerator): (JSC::Wasm::AirIRGenerator::toB3ResultType): (JSC::Wasm::AirIRGenerator::addBottom): (JSC::Wasm::AirIRGenerator::emitLoopTierUpCheck): (JSC::Wasm::AirIRGenerator::addTopLevel): (JSC::Wasm::AirIRGenerator::addLoop): (JSC::Wasm::AirIRGenerator::addBlock): (JSC::Wasm::AirIRGenerator::addIf): (JSC::Wasm::AirIRGenerator::addElse): (JSC::Wasm::AirIRGenerator::addElseToUnreachable): (JSC::Wasm::AirIRGenerator::addReturn): (JSC::Wasm::AirIRGenerator::addBranch): (JSC::Wasm::AirIRGenerator::addSwitch): (JSC::Wasm::AirIRGenerator::endBlock): (JSC::Wasm::AirIRGenerator::addCall): (JSC::Wasm::AirIRGenerator::addCallIndirect): (JSC::Wasm::dumpExpressionStack): (JSC::Wasm::AirIRGenerator::dump): (JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncUF64>): (JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncUF32>): (JSC::Wasm::AirIRGenerator::ControlData::type const): Deleted. (JSC::Wasm::AirIRGenerator::ControlData::hasNonVoidSignature const): Deleted. (JSC::Wasm::AirIRGenerator::ControlData::resultForBranch const): Deleted. * wasm/WasmB3IRGenerator.cpp: (JSC::Wasm::B3IRGenerator::ControlData::ControlData): (JSC::Wasm::B3IRGenerator::ControlData::dump const): (JSC::Wasm::B3IRGenerator::ControlData::blockType const): (JSC::Wasm::B3IRGenerator::ControlData::hasNonVoidresult const): (JSC::Wasm::B3IRGenerator::ControlData::targetBlockForBranch): (JSC::Wasm::B3IRGenerator::ControlData::convertIfToBlock): (JSC::Wasm::B3IRGenerator::addEndToUnreachable): (JSC::Wasm::B3IRGenerator::B3IRGenerator): (JSC::Wasm::B3IRGenerator::framePointer): (JSC::Wasm::B3IRGenerator::toB3ResultType): (JSC::Wasm::B3IRGenerator::addArguments): (JSC::Wasm::B3IRGenerator::addGrowMemory): (JSC::Wasm::B3IRGenerator::addLoop): (JSC::Wasm::B3IRGenerator::addTopLevel): (JSC::Wasm::B3IRGenerator::addBlock): (JSC::Wasm::B3IRGenerator::addIf): (JSC::Wasm::B3IRGenerator::addElse): (JSC::Wasm::B3IRGenerator::addElseToUnreachable): (JSC::Wasm::B3IRGenerator::addReturn): (JSC::Wasm::B3IRGenerator::addBranch): (JSC::Wasm::B3IRGenerator::addSwitch): (JSC::Wasm::B3IRGenerator::endBlock): (JSC::Wasm::B3IRGenerator::createCallPatchpoint): (JSC::Wasm::B3IRGenerator::addCall): (JSC::Wasm::B3IRGenerator::addCallIndirect): (JSC::Wasm::B3IRGenerator::ControlData::type const): Deleted. (JSC::Wasm::B3IRGenerator::ControlData::hasNonVoidSignature const): Deleted. (JSC::Wasm::B3IRGenerator::ControlData::resultForBranch const): Deleted. (JSC::Wasm::B3IRGenerator::createStack): Deleted. * wasm/WasmBBQPlan.cpp: (JSC::Wasm::BBQPlan::didReceiveFunctionData): (JSC::Wasm::BBQPlan::parseAndValidateModule): (JSC::Wasm::BBQPlan::complete): * wasm/WasmBBQPlan.h: * wasm/WasmBinding.cpp: (JSC::Wasm::wasmToWasm): * wasm/WasmCallingConvention.cpp: (JSC::Wasm::jsCallingConvention): (JSC::Wasm::wasmCallingConvention): (JSC::Wasm::jscCallingConvention): Deleted. (JSC::Wasm::jscCallingConventionAir): Deleted. (JSC::Wasm::wasmCallingConventionAir): Deleted. * wasm/WasmCallingConvention.h: (JSC::Wasm::CallInformation::CallInformation): (JSC::Wasm::CallInformation::computeResultsOffsetList): (JSC::Wasm::WasmCallingConvention::WasmCallingConvention): (JSC::Wasm::WasmCallingConvention::marshallLocationImpl const): (JSC::Wasm::WasmCallingConvention::marshallLocation const): (JSC::Wasm::WasmCallingConvention::callInformationFor const): (JSC::Wasm::JSCallingConvention::JSCallingConvention): (JSC::Wasm::JSCallingConvention::marshallLocationImpl const): (JSC::Wasm::JSCallingConvention::marshallLocation const): (JSC::Wasm::JSCallingConvention::callInformationFor const): (JSC::Wasm::CallingConvention::CallingConvention): Deleted. (JSC::Wasm::CallingConvention::marshallArgumentImpl const): Deleted. (JSC::Wasm::CallingConvention::marshallArgument const): Deleted. (JSC::Wasm::CallingConvention::headerSizeInBytes): Deleted. (JSC::Wasm::CallingConvention::setupFrameInPrologue const): Deleted. (JSC::Wasm::CallingConvention::loadArguments const): Deleted. (JSC::Wasm::CallingConvention::setupCall const): Deleted. (JSC::Wasm::CallingConventionAir::CallingConventionAir): Deleted. (JSC::Wasm::CallingConventionAir::prologueScratch const): Deleted. (JSC::Wasm::CallingConventionAir::marshallArgumentImpl const): Deleted. (JSC::Wasm::CallingConventionAir::marshallArgument const): Deleted. (JSC::Wasm::CallingConventionAir::headerSizeInBytes): Deleted. (JSC::Wasm::CallingConventionAir::loadArguments const): Deleted. (JSC::Wasm::CallingConventionAir::setupCall const): Deleted. (JSC::Wasm::nextJSCOffset): Deleted. * wasm/WasmFormat.h: * wasm/WasmFunctionParser.h: (JSC::Wasm::splitStack): (JSC::Wasm::FunctionParser::signature const): (JSC::Wasm::FunctionParser<Context>::FunctionParser): (JSC::Wasm::FunctionParser<Context>::parseBody): (JSC::Wasm::FunctionParser<Context>::parseExpression): (JSC::Wasm::FunctionParser<Context>::parseUnreachableExpression): * wasm/WasmInstance.h: * wasm/WasmMemoryInformation.cpp: (JSC::Wasm::getPinnedRegisters): * wasm/WasmOMGForOSREntryPlan.cpp: (JSC::Wasm::OMGForOSREntryPlan::work): * wasm/WasmOMGPlan.cpp: (JSC::Wasm::OMGPlan::work): * wasm/WasmParser.h: (JSC::Wasm::FailureHelper::makeString): (JSC::Wasm::Parser<SuccessType>::Parser): (JSC::Wasm::Parser<SuccessType>::peekInt7): (JSC::Wasm::Parser<SuccessType>::parseBlockSignature): (JSC::Wasm::Parser<SuccessType>::parseValueType): (JSC::Wasm::Parser<SuccessType>::parseResultType): Deleted. * wasm/WasmSectionParser.cpp: (JSC::Wasm::SectionParser::parseType): (JSC::Wasm::SectionParser::parseStart): * wasm/WasmSectionParser.h: * wasm/WasmSignature.cpp: (JSC::Wasm::Signature::toString const): (JSC::Wasm::Signature::dump const): (JSC::Wasm::computeHash): (JSC::Wasm::Signature::hash const): (JSC::Wasm::Signature::tryCreate): (JSC::Wasm::SignatureInformation::SignatureInformation): (JSC::Wasm::ParameterTypes::hash): (JSC::Wasm::ParameterTypes::equal): (JSC::Wasm::ParameterTypes::translate): (JSC::Wasm::SignatureInformation::signatureFor): (JSC::Wasm::SignatureInformation::adopt): Deleted. * wasm/WasmSignature.h: (JSC::Wasm::Signature::Signature): (JSC::Wasm::Signature::allocatedSize): (JSC::Wasm::Signature::returnCount const): (JSC::Wasm::Signature::returnType const): (JSC::Wasm::Signature::returnsVoid const): (JSC::Wasm::Signature::argument const): (JSC::Wasm::Signature::operator== const): (JSC::Wasm::Signature::getReturnType): (JSC::Wasm::Signature::getArgument): (JSC::Wasm::SignatureHash::SignatureHash): (JSC::Wasm::SignatureHash::equal): (JSC::Wasm::SignatureInformation::thunkFor const): (JSC::Wasm::Signature::returnType): Deleted. (JSC::Wasm::Signature::argument): Deleted. * wasm/WasmStreamingParser.cpp: (JSC::Wasm::StreamingParser::parseCodeSectionSize): (JSC::Wasm::StreamingParser::parseFunctionPayload): (JSC::Wasm::StreamingParser::parseSectionPayload): * wasm/WasmStreamingParser.h: (JSC::Wasm::StreamingParserClient::didReceiveSectionData): (JSC::Wasm::StreamingParser::reportError): (JSC::Wasm::StreamingParserClient::didReceiveFunctionData): Deleted. * wasm/WasmThunks.cpp: (JSC::Wasm::throwExceptionFromWasmThunkGenerator): (JSC::Wasm::throwStackOverflowFromWasmThunkGenerator): (JSC::Wasm::triggerOMGEntryTierUpThunkGenerator): * wasm/WasmValidate.cpp: (JSC::Wasm::Validate::ControlData::ControlData): (JSC::Wasm::Validate::ControlData::dump const): (JSC::Wasm::Validate::ControlData::blockType const): (JSC::Wasm::Validate::ControlData::signature const): (JSC::Wasm::Validate::ControlData::branchTargetArity const): (JSC::Wasm::Validate::ControlData::branchTargetType const): (JSC::Wasm::Validate::fail const): (JSC::Wasm::Validate::addTableGet): (JSC::Wasm::Validate::addTableGrow): (JSC::Wasm::Validate::addTableFill): (JSC::Wasm::Validate::addRefIsNull): (JSC::Wasm::Validate::addTopLevel): (JSC::Wasm::splitStack): (JSC::Wasm::Validate::addBlock): (JSC::Wasm::Validate::addLoop): (JSC::Wasm::Validate::addIf): (JSC::Wasm::Validate::addElseToUnreachable): (JSC::Wasm::Validate::addReturn): (JSC::Wasm::Validate::checkBranchTarget): (JSC::Wasm::Validate::addSwitch): (JSC::Wasm::Validate::addGrowMemory): (JSC::Wasm::Validate::addEndToUnreachable): (JSC::Wasm::Validate::addCall): (JSC::Wasm::Validate::addCallIndirect): (JSC::Wasm::Validate::unify): (JSC::Wasm::Validate::ControlData::hasNonVoidSignature const): Deleted. (JSC::Wasm::Validate::ControlData::type const): Deleted. (JSC::Wasm::Validate::ControlData::branchTargetSignature const): Deleted. * wasm/generateWasmOpsHeader.py: * wasm/js/JSToWasm.cpp: (JSC::Wasm::boxWasmResult): (JSC::Wasm::allocateResultsArray): (JSC::Wasm::marshallJSResult): (JSC::Wasm::createJSToWasmWrapper): * wasm/js/JSToWasm.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): * wasm/js/WasmToJS.cpp: (JSC::Wasm::handleBadI64Use): (JSC::Wasm::wasmToJS): * wasm/js/WasmToJS.h: * wasm/js/WebAssemblyFunction.cpp: (JSC::callWebAssemblyFunction): (JSC::WebAssemblyFunction::useTagRegisters const): (JSC::WebAssemblyFunction::jsCallEntrypointSlow): * wasm/js/WebAssemblyModuleRecord.cpp: (JSC::WebAssemblyModuleRecord::link): Tools: * Scripts/run-jsc-stress-tests: Canonical link: https://commits.webkit.org/215930@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250559 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-10-01 16:38:26 +00:00
// EMSCRIPTEN_START_FUNCS
WebAssembly: update wabt.js https://bugs.webkit.org/show_bug.cgi?id=218876 Patch by Sergey Rubanov <chi187@gmail.com> on 2020-11-13 Reviewed by Yusuke Suzuki. * wasm/libwabt.js: (WabtModule): Deleted. * wasm/regress/llint-callee-saves-with-fast-memory.js: (async test): * wasm/regress/llint-callee-saves-without-fast-memory.js: (async test): * wasm/regress/regression-with-loop.js: (async test): * wasm/regress/stack-consistency.js: (async test): * wasm/stress/js-wasm-call-many-return-types-on-stack-no-args.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/stress/js-wasm-js-varying-arities.js: (async paramForwarder): (async test): (paramForwarder): Deleted. * wasm/stress/local-ref.js: (async test): * wasm/stress/loop-more-args-than-results.js: (async test): * wasm/stress/set-local-enclosed-stack.js: (async test): (assert.eq.instance.exports.foo): Deleted. (assert.eq): Deleted. * wasm/stress/top-most-enclosing-stack.js: (async test): * wasm/stress/trunc-int-min-minus-one.js: (async test): * wasm/stress/wasm-js-call-many-return-types-on-stack-no-args.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/stress/wasm-js-multi-value-exception-in-iterator.js: (async buildWat): (async test): (buildWat.throwError): Deleted. (buildWat.throwErrorInIterator): Deleted. (buildWat.tooManyValues): Deleted. (buildWat.tooFewValues): Deleted. (buildWat): Deleted. * wasm/stress/wasm-wasm-call-indirect-many-return-types-on-stack.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/stress/wasm-wasm-call-many-return-types-on-stack-no-args.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/wabt-wrapper.js: (export.async compile): (export.compile): Deleted. Canonical link: https://commits.webkit.org/231540@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269766 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-11-13 08:36:26 +00:00
function Ef(a,b){var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,o=0,r=0;c=P-1536|0;P=c;if(!p[a+88>>2]){Fa(c+1352|0,p[a>>2],a);d=p[a+88>>2];p[a+88>>2]=d+1;e=v(d+p[a+92>>2]&1,36)+a|0;p[e+48>>2]=p[c+1384>>2];f=c+1376|0;d=p[f+4>>2];p[e+40>>2]=p[f>>2];p[e+44>>2]=d;f=c+1368|0;d=p[f+4>>2];p[e+32>>2]=p[f>>2];p[e+36>>2]=d;f=c+1360|0;d=p[f+4>>2];p[e+24>>2]=p[f>>2];p[e+28>>2]=d;d=p[c+1356>>2];p[e+16>>2]=p[c+1352>>2];p[e+20>>2]=d}g=1;i=c+1528|0;d=v(p[a+92>>2]&1,36)+a|0;p[i>>2]=p[d+32>>2];f=p[d+28>>2];j=c+1520|0;e=j;p[e>>2]=p[d+24>>2];p[e+4>>2]=f;f=p[d+20>>2];p[c+1512>>2]=p[d+16>>2];p[c+1516>>2]=f;a:{b:{c:{d:{e:{f:{g:{h:{i:{j:{k:{l:{m:{n:{o:{p:{q:{r:{s:{t:{u:{v:{w:{x:{y:{z:{A:{B:{C:{D:{E:{F:{G:{switch(na(a,0)+ -52|0){case 62:d=v(p[a+92>>2]&1,36)+a|0;p[d+32>>2]=0;p[d+36>>2]=0;p[d+24>>2]=0;p[d+28>>2]=0;p[d+16>>2]=0;p[d+20>>2]=0;p[a+88>>2]=p[a+88>>2]+ -1;p[a+92>>2]=(p[a+92>>2]^-1)&1;a=ha(36);p[a+4>>2]=0;p[a+8>>2]=0;i=p[i>>2];g=p[j>>2];e=p[j+4>>2];f=p[c+1512>>2];d=p[c+1516>>2];p[a+32>>2]=58;p[a+12>>2]=f;p[a+16>>2]=d;p[a+20>>2]=g;p[a+24>>2]=e;p[a+28>>2]=i;p[a>>2]=21916;d=p[b>>2];p[b>>2]=a;if(!d){g=0;break c}m[p[p[d>>2]+4>>2]](d);g=0;break c;case 37:d=v(p[a+92>>2]&1,36)+a|0;p[d+32>>2]=0;p[d+36>>2]=0;p[d+24>>2]=0;p[d+28>>2]=0;p[d+16>>2]=0;p[d+20>>2]=0;p[a+88>>2]=p[a+88>>2]+ -1;p[a+92>>2]=(p[a+92>>2]^-1)&1;a=ha(36);p[a+4>>2]=0;p[a+8>>2]=0;i=p[i>>2];g=p[j>>2];e=p[j+4>>2];f=p[c+1512>>2];d=p[c+1516>>2];p[a+32>>2]=33;p[a+12>>2]=f;p[a+16>>2]=d;p[a+20>>2]=g;p[a+24>>2]=e;p[a+28>>2]=i;p[a>>2]=20828;d=p[b>>2];p[b>>2]=a;if(!d){g=0;break c}m[p[p[d>>2]+4>>2]](d);g=0;break c;case 20:d=v(p[a+92>>2]&1,36)+a|0;p[d+32>>2]=0;p[d+36>>2]=0;p[d+24>>2]=0;p[d+28>>2]=0;p[d+16>>2]=0;p[d+20>>2]=0;p[a+88>>2]=p[a+88>>2]+ -1;p[a+92>>2]=(p[a+92>>2]^-1)&1;a=ha(36);p[a+4>>2]=0;p[a+8>>2]=0;i=p[i>>2];g=p[j>>2];e=p[j+4>>2];f=p[c+1512>>2];d=p[c+1516>>2];p[a+32>>2]=18;p[a+12>>2]=f;p[a+16>>2]=d;p[a+20>>2]=g;p[a+24>>2]=e;p[a+28>>2]=i;p[a>>2]=18040;d=p[b>>2];p[b>>2]=a;if(!d){g=0;break c}m[p[p[d>>2]+4>>2]](d);g=0;break c;case 46:d=v(p[a+92>>2]&1,36)+a|0;p[d+32>>2]=0;p[d+36>>2]=0;p[d+24>>2]=0;p[d+28>>2]=0;p[d+16>>2]=0;p[d+20>>2]=0;p[a+88>>2]=p[a+88>>2]+ -1;p[a+92>>2]=(p[a+92>>2]^-1)&1;p[c+1360>>2]=0;p[c+1352>>2]=0;p[c+1356>>2]=0;H:{I:{if(!q[p[a+12>>2]+9|0]){f=0;break I}f=0;if((na(a,0)|0)!=24){break I}f=0;if((na(a,1)|0)!=35){break I}f=a+16|0;d=f+v(p[a+92>>2]&1,36)|0;p[d>>2]=0;p[d+4>>2]=0;p[d+16>>2]=0;p[d+20>>2]=0;p[d+8>>2]=0;p[d+12>>2]=0;p[a+88>>2]=p[a+88>>2]+ -1;d=(p[a+92>>2]^-1)&1;p[a+92>>2]=d;d=f+v(d,36)|0;p[d>>2]=0;p[d+4>>2]=0;p[d+16>>2]=0;p[d+20>>2]=0;p[d+8>>2]=0;p[d+12>>2]=0;p[a+88>>2]=p[a+88>>2]+ -1;p[a+92>>2]=(p[a+92>>2]^-1)&1;if((Af(a,c+1352|0)|0)==1){break H}if((ra(a,36)|0)==1){break H}l=p[c+1352>>2];f=p[c+1356>>2]}e=ha(48);p[c+1504>>2]=0;p[c+1496>>2]=0;p[c+1500>>2]=0;d=f-l|0;J:{if(!d){g=0;f=0;break J}a=d>>2;if(a>>>0>=1073741824){break b}g=ha(d);p[c+1496>>2]=g;p[c+1500>>2]=g;p[c+1504>>2]=(a<<2)+g;d=c;f=f-l|0;a=g;K:{if((f|0)<1){break K}a=sa(g,l,f)+f|0}f=a;p[d+1500>>2]=f}p[e+4>>2]=0;p[e+8>>2]=0;a=p[c+1516>>2];p[e+12>>2]=p[c+1512>>2];p[e+16>>2]=a;d=c+1520|0;a=p[d+4>>2];p[e+20>>2]=p[d>>2];p[e+24>>2]=a;p[e+28>>2]=p[c+1528>>2];p[e+32>>2]=41;p[e+44>>2]=0;p[e+36>>2]=0;p[e+40>>2]=0;p[e>>2]=21256;d=f-g|0;if(d){a=d>>2;if(a>>>0>=1073741824){break a}d=ha(d);p[e+36>>2]=d;p[e+40>>2]=d;p[e+44>>2]=d+(a<<2);a=e;f=f-g|0;if((f|0)>=1){d=sa(d,g,f)+f|0}p[a+40>>2]=d}a=p[b>>2];p[b>>2]=e;if(a){m[p[p[a>>2]+4>>2]](a);g=p[c+1496>>2]}if(g){p[c+1500>>2]=g;ea(g)}a=p[c+1352>>2];if(a){p[c+1356>>2]=a;ea(a)}g=0;break c}a=p[c+1352>>2];if(!a){break d}p[c+1356>>2]=a;ea(a);break d;case 9:d=v(p[a+92>>2]&1,36)+a|0;p[d+32>>2]=0;p[d+36>>2]=0;p[d+24>>2]=0;p[d+28>>2]=0;p[d+16>>2]=0;p[d+20>>2]=0;p[a+88>>2]=p[a+88>>2]+ -1;p[a+92>>2]=(p[a+92>>2]^-1)&1;p[c+1208>>2]=p[i>>2];d=p[j+4>>2];f=c+1200|0;p[f>>2]=p[j>>2];p[f+4>>2]=d;d=p[c+1516>>2];p[c+1192>>2]=p[c+1512>>2];p[c+1196>>2]=d;p[c+1328>>2]=0;d=c+1320|0;p[d>>2]=0;p[d+4>>2]=0;p[c+1312>>2]=0;p[c+1316>>2]=0;h=pa(c+1352|0,-1,c+1312|0);if((Ja(a,h)|0)==1){break w}a=ha(72);p[a+4>>2]=0;p[a+8>>2]=0;i=p[c+1208>>2];d=c+1200|0;g=p[d>>2];e=p[d+4>>2];f=p[c+1192>>2];d=p[c+1196>>2];p[a+32>>
function By(a,b){var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;c=P-208|0;P=c;d=1;a:{if((ra(a,24)|0)==1){break a}if(!p[a+88>>2]){Fa(c+168|0,p[a>>2],a);d=p[a+88>>2];p[a+88>>2]=d+1;d=v(d+p[a+92>>2]&1,36)+a|0;p[d+48>>2]=p[c+200>>2];e=p[c+196>>2];p[d+40>>2]=p[c+192>>2];p[d+44>>2]=e;e=p[c+188>>2];p[d+32>>2]=p[c+184>>2];p[d+36>>2]=e;e=p[c+180>>2];p[d+24>>2]=p[c+176>>2];p[d+28>>2]=e;e=p[c+172>>2];p[d+16>>2]=p[c+168>>2];p[d+20>>2]=e}e=p[a+92>>2];g=ha(40);d=g;p[d+4>>2]=0;p[d+8>>2]=0;d=1;e=v(e&1,36)+a|0;f=p[e+32>>2];h=p[e+24>>2];i=p[e+28>>2];j=p[e+16>>2];e=p[e+20>>2];p[g+32>>2]=4;p[g+36>>2]=0;p[g+12>>2]=j;p[g+16>>2]=e;p[g+20>>2]=h;p[g+24>>2]=i;p[g+28>>2]=f;p[g>>2]=14124;if((ra(a,42)|0)!=1){p[c+160>>2]=0;p[c+152>>2]=0;p[c+156>>2]=0;if((na(a,0)|0)==120){d=v(p[a+92>>2]&1,36)+a|0;p[d+16>>2]=0;p[d+20>>2]=0;p[d+24>>2]=0;p[d+28>>2]=0;p[d+32>>2]=0;p[d+36>>2]=0;e=p[d+40>>2];d=p[d+44>>2];p[a+88>>2]=p[a+88>>2]+ -1;p[a+92>>2]=(p[a+92>>2]^-1)&1;p[c+64>>2]=e;p[c+68>>2]=d;wa(c+168|0,c- -64|0);if(n[c+163|0]<=-1){ea(p[c+152>>2])}p[c+160>>2]=p[c+176>>2];d=p[c+172>>2];p[c+152>>2]=p[c+168>>2];p[c+156>>2]=d}d=1;b:{if((ra(a,24)|0)==1){break b}if(!p[a+88>>2]){Fa(c+168|0,p[a>>2],a);d=p[a+88>>2];p[a+88>>2]=d+1;d=v(d+p[a+92>>2]&1,36)+a|0;p[d+48>>2]=p[c+200>>2];e=p[c+196>>2];p[d+40>>2]=p[c+192>>2];p[d+44>>2]=e;e=p[c+188>>2];p[d+32>>2]=p[c+184>>2];p[d+36>>2]=e;e=p[c+180>>2];p[d+24>>2]=p[c+176>>2];p[d+28>>2]=e;e=p[c+172>>2];p[d+16>>2]=p[c+168>>2];p[d+20>>2]=e}d=v(p[a+92>>2]&1,36)+a|0;p[c+144>>2]=p[d+32>>2];e=p[d+28>>2];p[c+136>>2]=p[d+24>>2];p[c+140>>2]=e;e=p[d+20>>2];p[c+128>>2]=p[d+16>>2];p[c+132>>2]=e;c:{d:{e:{if((na(a,0)|0)==122){d=v(p[a+92>>2]&1,36)+a|0;p[d+32>>2]=0;p[d+36>>2]=0;p[d+24>>2]=0;p[d+28>>2]=0;p[d+16>>2]=0;p[d+20>>2]=0;p[a+88>>2]=p[a+88>>2]+ -1;p[a+92>>2]=(p[a+92>>2]^-1)&1;e=ha(64);f=p[c+152>>2];h=q[c+163|0];d=h<<24>>24<0;p[c+172>>2]=d?p[c+156>>2]:h;p[c+168>>2]=d?f:c+152|0;d=e;p[d+4>>2]=0;p[d+8>>2]=0;p[d>>2]=14416;p[d+12>>2]=0;p[d+16>>2]=0;p[d+20>>2]=0;wa(d+24|0,c+168|0);p[d+36>>2]=0;p[d+40>>2]=0;p[d+44>>2]=0;p[d>>2]=14344;p[d+48>>2]=0;p[d+52>>2]=0;p[d+56>>2]=0;p[d+60>>2]=0;p[c+112>>2]=0;p[c+116>>2]=0;p[c+104>>2]=0;p[c+108>>2]=0;p[c+120>>2]=1065353216;f:{if((md(a,32,d+40|0,c+104|0,0)|0)==1){break f}if((vb(a,35,e+52|0)|0)==1){break f}n[c+87|0]=6;f=0;d=q[57055]|q[57056]<<8;n[c+80|0]=d;n[c+81|0]=d>>>8;n[c+82|0]=0;n[c+75|0]=5;p[c+64>>2]=q[57045]|q[57046]<<8|(q[57047]<<16|q[57048]<<24);n[c+68|0]=q[57049];n[c+69|0]=0;p[c+76>>2]=q[57051]|q[57052]<<8|(q[57053]<<16|q[57054]<<24);d=ha(24);p[c+88>>2]=d;h=d+24|0;p[c+96>>2]=h;Da(d,c- -64|0);Da(d+12|0,c+76|0);p[c+92>>2]=h;if((na(a,0)|0)==24){f=v(p[a+92>>2]&1,36)+a|0;p[f+32>>2]=0;p[f+36>>2]=0;p[f+24>>2]=0;p[f+28>>2]=0;p[f+16>>2]=0;p[f+20>>2]=0;f=p[a+88>>2]+ -1|0;p[a+88>>2]=f;p[a+92>>2]=(p[a+92>>2]^-1)&1;if(!f){Fa(c+168|0,p[a>>2],a);f=p[a+88>>2];p[a+88>>2]=f+1;f=v(f+p[a+92>>2]&1,36)+a|0;p[f+48>>2]=p[c+200>>2];h=p[c+196>>2];p[f+40>>2]=p[c+192>>2];p[f+44>>2]=h;h=p[c+188>>2];p[f+32>>2]=p[c+184>>2];p[f+36>>2]=h;h=p[c+180>>2];p[f+24>>2]=p[c+176>>2];p[f+28>>2]=h;h=p[c+172>>2];p[f+16>>2]=p[c+168>>2];p[f+20>>2]=h}f=(Qa(a,c+88|0,0)|0)==1}if(n[d+23|0]<=-1){ea(p[d+12>>2])}if(n[d+11|0]<0){ea(p[d>>2])}p[c+92>>2]=d;ea(d);if(n[c+87|0]<0){ea(p[c+76>>2])}if(n[c+75|0]<0){ea(p[c+64>>2])}if(f){break f}d=p[g+36>>2];p[g+36>>2]=e;if(d){m[p[p[d>>2]+4>>2]](d)}d=p[c+112>>2];if(d){while(1){e=p[d>>2];if(n[d+19|0]<=-1){ea(p[d+8>>2])}ea(d);d=e;if(d){continue}break}}d=p[c+104>>2];p[c+104>>2]=0;if(!d){break e}ea(d);break e}a=p[c+112>>2];if(a){while(1){b=p[a>>2];if(n[a+19|0]<=-1){ea(p[a+8>>2])}ea(a);a=b;if(a){continue}break}}a=p[c+104>>2];p[c+104>>2]=0;if(a){ea(a)}m[p[p[e>>2]+4>>2]](e);d=1;break b}if((na(a,0)|0)==39){d=1;e=v(p[a+92>>2]&1,36)+a|0;p[e+32>>2]=0;p[e+36>>2]=0;p[e+24>>2]=0;p[e+28>>2]=0;p[e+16>>2]=0;p[e+20>>2]=0;p[a+88>>2]=p[a+88>>2]+ -1;p[a+92>>2]=(p[a+92>>2]^-1)&1;if(!q[p[a+12>>2]+11|0]){p[c+24>>2]=p[c+144>>2];b=p[c+140>>2];p[c+16>>2]=p[c+136>>2];p[c+20>>2]=b;b=p[c+132>>2];p[c+8>>2]=p[c+128>>2];p[c+12>>2]=b;Aa(a,c+8|0,57058,0);break b}e=ha(52);p[c+168>>2]=0;p[c+172>>2]=0;p[e+20>>2]=0;d=e;p[d+12>>2]=0;p[d+16>>2]=0;p[d+4>>2]=0;p[d+8>>2]=0;p[
function nm(a,b){var c=0,d=0;c=P-96|0;P=c;a:{b:{c:{d:{e:{f:{g:{h:{i:{j:{k:{l:{d=p[b>>2];switch(p[d+32>>2]){case 2:break j;case 1:break k;case 0:break l;case 10:break b;case 9:break c;case 8:break d;case 7:break e;case 6:break f;case 5:break g;case 4:break h;case 3:break i;default:break a}}p[b>>2]=0;p[c+88>>2]=d;Re(a,c+88|0);a=p[c+88>>2];p[c+88>>2]=0;if(!a){break a}m[p[p[a>>2]+4>>2]](a);break a}p[b>>2]=0;p[c+80>>2]=d;Qe(a,c+80|0);a=p[c+80>>2];p[c+80>>2]=0;if(!a){break a}m[p[p[a>>2]+4>>2]](a);break a}p[b>>2]=0;p[c+72>>2]=d;Db(a,c+72|0);a=p[c+72>>2];p[c+72>>2]=0;if(!a){break a}m[p[p[a>>2]+4>>2]](a);break a}p[b>>2]=0;p[c+64>>2]=d;Se(a,c- -64|0);a=p[c+64>>2];p[c+64>>2]=0;if(!a){break a}m[p[p[a>>2]+4>>2]](a);break a}p[b>>2]=0;p[c+56>>2]=d;Ec(a,c+56|0);a=p[c+56>>2];p[c+56>>2]=0;if(!a){break a}m[p[p[a>>2]+4>>2]](a);break a}p[b>>2]=0;p[c+48>>2]=d;Id(a,c+48|0);a=p[c+48>>2];p[c+48>>2]=0;if(!a){break a}m[p[p[a>>2]+4>>2]](a);break a}p[b>>2]=0;p[c+40>>2]=d;Kd(a,c+40|0);a=p[c+40>>2];p[c+40>>2]=0;if(!a){break a}m[p[p[a>>2]+4>>2]](a);break a}p[b>>2]=0;p[c+32>>2]=d;Jd(a,c+32|0);a=p[c+32>>2];p[c+32>>2]=0;if(!a){break a}m[p[p[a>>2]+4>>2]](a);break a}p[b>>2]=0;p[c+24>>2]=d;Ld(a,c+24|0);a=p[c+24>>2];p[c+24>>2]=0;if(!a){break a}m[p[p[a>>2]+4>>2]](a);break a}p[b>>2]=0;p[c+16>>2]=d;Pe(a,c+16|0);a=p[c+16>>2];p[c+16>>2]=0;if(!a){break a}m[p[p[a>>2]+4>>2]](a);break a}p[b>>2]=0;p[c+8>>2]=d;Te(a,c+8|0);a=p[c+8>>2];p[c+8>>2]=0;if(!a){break a}m[p[p[a>>2]+4>>2]](a)}P=c+96|0}function Jf(a,b){var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;c=P-96|0;P=c;a:{b:{g=p[b+24>>2];e=p[b+36>>2];if(g>>>0<=e>>>0){break b}d=e+1|0;p[b+36>>2]=d;if(q[e|0]!=105|d>>>0>=g>>>0){break b}d=e+2|0;p[b+36>>2]=d;if(q[e+1|0]!=110|d>>>0>=g>>>0){break b}d=e+3|0;p[b+36>>2]=d;if(q[e+2|0]!=102){break b}c:{d:{e:{if(d>>>0<g>>>0){e=n[q[d|0]+48545|0]&1;if(e){while(1){d=d+1|0;p[b+36>>2]=d;if((d|0)==(g|0)){break d}if(n[q[d|0]+48545|0]&1){continue}break}}if(e){break e}}j=p[b+8>>2];g=q[b+15|0];k=p[b+4>>2];h=p[b+16>>2];e=p[b+32>>2];f=p[b+28>>2];i=e-f|0;p[c+84>>2]=(i|0)<1?1:i+1|0;f=d-f|0;f=(f|0)<1?1:f+1|0;p[c+88>>2]=f;p[c+16>>2]=f;p[c+80>>2]=h;h=p[c+84>>2];p[c+8>>2]=p[c+80>>2];p[c+12>>2]=h;f=g;g=g<<24>>24<0;p[c+76>>2]=g?j:f;p[c+72>>2]=g?k:b+4|0;p[c- -64>>2]=d-e;p[c+60>>2]=e;p[c+56>>2]=3;b=p[c+76>>2];p[c>>2]=p[c+72>>2];p[c+4>>2]=b;gc(a,c,49,c+56|0);break a}if(!(n[q[d|0]+48545|0]&1)|d>>>0>=g>>>0){break c}while(1){d=d+1|0;p[b+36>>2]=d;if((d|0)==(g|0)){break d}if(n[q[d|0]+48545|0]&1){continue}break}break c}d=g}j=p[b+8>>2];g=q[b+15|0];k=p[b+4>>2];h=p[b+16>>2];e=p[b+32>>2];f=p[b+28>>2];i=e-f|0;p[c+84>>2]=(i|0)<1?1:i+1|0;f=d-f|0;f=(f|0)<1?1:f+1|0;p[c+88>>2]=f;p[c+48>>2]=f;p[c+80>>2]=h;h=p[c+84>>2];p[c+40>>2]=p[c+80>>2];p[c+44>>2]=h;p[c+56>>2]=e;p[c+60>>2]=d-e;d=g<<24>>24<0;p[c+76>>2]=d?j:g;p[c+72>>2]=d?k:b+4|0;b=p[c+60>>2];p[c+24>>2]=p[c+56>>2];p[c+28>>2]=b;b=p[c+76>>2];p[c+32>>2]=p[c+72>>2];p[c+36>>2]=b;ib(a,c+32|0,118,c+24|0);break a}p[b+36>>2]=e;td(a,b)}P=c+96|0}function yd(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=0;d=P-128|0;P=d;p[a>>2]=0;p[a+4>>2]=0;l=a;a:{b:{c:{d:{e:{f:{switch(p[c+72>>2]){case 0:g=Ne(p[b+8>>2],c+24|0);if(!g){Xb(b,c+4|0,46335,0);break c}f=c+60|0;h=q[c+71|0];e=h<<24>>24<0;p[d+104>>2]=e?p[c+60>>2]:f;p[d+108>>2]=e?p[c- -64>>2]:h;e=p[d+108>>2];p[d+72>>2]=p[d+104>>2];p[d+76>>2]=e;e=Pd(g,d+72|0);if(!e){e=d;if(n[c+71|0]<=-1){f=p[c+60>>2]}p[e>>2]=f;Xb(b,c+4|0,46350,d);break c}j=Eb(g,e+16|0);if(!j){break c}g=p[j+52>>2];h=p[j+56>>2]-g>>2;f=p[c+76>>2];e=p[c+80>>2]-f|0;k=(e|0)/60|0;if((h|0)==(k|0)){if(!e){break e}h=k>>>0>1?k:1;while(1){g=p[(i<<2)+g>>2];f=v(i,60)+f|0;e=p[f+20>>2];p[d+120>>2]=e;p[d+112>>2]=g;if((zb(e,g)|0)==1){e=ya(d+120|0);m=d,o=ya(d+112|0),p[m+32>>2]=o;p[d+28>>2]=e;p[d+24>>2]=46441;p[d+16>>2]=46448;p[d+20>>2]=i;Xb(b,f,46457,d+16|0)}i=i+1|0;if((h|0)==(i|0)){break e}g=p[j+52>>2];f=p[c+76>>2];continue}}p[d+52>>2]=k;p[d+56>>2]=h;p[d+48>>2]=k>>>0>h>>>0?46432:46437;Xb(b,c+4|0,46379,d+48|0);break c;case 1:break f;default:break a}}g=Ne(p[b+8>>2],c+24|0);if(!g){Xb(b,c+4|0,46335,0);a=0;break b}e=c+60|0;h=q[c+71|0];f=h<<24>>24<0;p[d+104>>2]=f?p[c+60>>2]:e;p[d+108>>2]=f?p[c- -64>>2]:h
function Vt(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0;e=P-112|0;P=e;d=ha(136);p[d+4>>2]=0;p[d+8>>2]=0;n[d+36|0]=0;p[d>>2]=21144;p[d+20>>2]=0;p[d+24>>2]=0;p[d+12>>2]=0;p[d+16>>2]=0;p[d+28>>2]=0;p[d+32>>2]=40;p[e+48>>2]=0;p[e+40>>2]=0;p[e+44>>2]=0;p[e+32>>2]=0;p[e+36>>2]=0;g=pa(d+40|0,-1,e+32|0);p[d+92>>2]=0;p[d+96>>2]=0;p[d+84>>2]=0;p[d+88>>2]=0;p[d+76>>2]=0;p[d+80>>2]=0;p[e+48>>2]=0;p[e+40>>2]=0;p[e+44>>2]=0;p[e+32>>2]=0;p[e+36>>2]=0;h=pa(d+100|0,-1,e+32|0);p[e+44>>2]=0;p[e+48>>2]=0;f=p[a+36>>2];i=e,j=ma(f),p[i+36>>2]=j;p[e+32>>2]=f;p[e+40>>2]=p[p[a+4>>2]+8>>2];f=pa(e+72|0,b,e+32|0);n[d+36|0]=1;Ia(g,f);b=kb(p[a+12>>2],f);a:{if(!b){break a}g=d+76|0;if((g|0)==(b+40|0)){break a}Oa(g,p[b+40>>2],p[b+44>>2]);Oa(d+88|0,p[b+52>>2],p[b+56>>2])}ia(f);p[e+24>>2]=0;p[e+16>>2]=0;p[e+20>>2]=0;p[e+8>>2]=0;p[e+12>>2]=0;b=pa(e+32|0,c,e+8|0);Ia(h,b);ia(b);b=p[a+36>>2];c=ma(b);f=p[p[a+4>>2]+8>>2];p[d+24>>2]=0;p[d+28>>2]=0;p[d+20>>2]=f;p[d+16>>2]=c;p[d+12>>2]=b;c=p[a+20>>2];f=p[a+24>>2]-c|0;b=(f|0)/12|0;b:{if(f){a=p[(c+v(b,12)|0)+ -8>>2];b=p[a+4>>2];c:{if(b){p[d+8>>2]=b;b=b+4|0;break c}b=a}p[b>>2]=d;p[a+4>>2]=d;p[a+8>>2]=p[a+8>>2]+1;a=0;break b}p[e+4>>2]=b;p[e>>2]=0;Ba(a,15936,e);m[p[p[d>>2]+4>>2]](d);a=1}P=e+112|0;return a|0}function Nu(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0;e=P-112|0;P=e;d=ha(136);p[d+4>>2]=0;p[d+8>>2]=0;n[d+36|0]=0;p[d>>2]=17664;p[d+20>>2]=0;p[d+24>>2]=0;p[d+12>>2]=0;p[d+16>>2]=0;p[d+28>>2]=0;p[d+32>>2]=14;p[e+48>>2]=0;p[e+40>>2]=0;p[e+44>>2]=0;p[e+32>>2]=0;p[e+36>>2]=0;g=pa(d+40|0,-1,e+32|0);p[d+92>>2]=0;p[d+96>>2]=0;p[d+84>>2]=0;p[d+88>>2]=0;p[d+76>>2]=0;p[d+80>>2]=0;p[e+48>>2]=0;p[e+40>>2]=0;p[e+44>>2]=0;p[e+32>>2]=0;p[e+36>>2]=0;h=pa(d+100|0,-1,e+32|0);p[e+44>>2]=0;p[e+48>>2]=0;f=p[a+36>>2];i=e,j=ma(f),p[i+36>>2]=j;p[e+32>>2]=f;p[e+40>>2]=p[p[a+4>>2]+8>>2];f=pa(e+72|0,b,e+32|0);n[d+36|0]=1;Ia(g,f);b=kb(p[a+12>>2],f);a:{if(!b){break a}g=d+76|0;if((g|0)==(b+40|0)){break a}Oa(g,p[b+40>>2],p[b+44>>2]);Oa(d+88|0,p[b+52>>2],p[b+56>>2])}ia(f);p[e+24>>2]=0;p[e+16>>2]=0;p[e+20>>2]=0;p[e+8>>2]=0;p[e+12>>2]=0;b=pa(e+32|0,c,e+8|0);Ia(h,b);ia(b);b=p[a+36>>2];c=ma(b);f=p[p[a+4>>2]+8>>2];p[d+24>>2]=0;p[d+28>>2]=0;p[d+20>>2]=f;p[d+16>>2]=c;p[d+12>>2]=b;c=p[a+20>>2];f=p[a+24>>2]-c|0;b=(f|0)/12|0;b:{if(f){a=p[(c+v(b,12)|0)+ -8>>2];b=p[a+4>>2];c:{if(b){p[d+8>>2]=b;b=b+4|0;break c}b=a}p[b>>2]=d;p[a+4>>2]=d;p[a+8>>2]=p[a+8>>2]+1;a=0;break b}p[e+4>>2]=b;p[e>>2]=0;Ba(a,15936,e);m[p[p[d>>2]+4>>2]](d);a=1}P=e+112|0;return a|0}function jg(a,b,c,d){var e=0,f=0,g=0,h=0,i=0,j=0;e=P-32|0;P=e;if(!(q[a+9|0]|p[a+140>>2]==p[a+136>>2])){g=(xa(a,b,44533,0)|0)==1}g=g|(kg(a,b,d,-1,44556)|0)==1;if(q[d+17|0]){g=(xa(a,b,44562,0)|0)==1|g}a:{if((c|0)==-16){break a}if(!q[a+9|0]){g=(xa(a,b,44587,0)|0)==1|g}b:{switch(c+24|0){case 0:case 7:break a;default:break b}}g=(xa(a,b,44617,0)|0)==1|g}b=p[d+20>>2];p[e+20>>2]=p[d+16>>2];p[e+24>>2]=b;b=p[d+12>>2];p[e+12>>2]=p[d+8>>2];p[e+16>>2]=b;b=p[d+4>>2];p[e+4>>2]=p[d>>2];p[e+8>>2]=b;c:{d:{b=p[a+140>>2];f=p[a+144>>2];e:{if(b>>>0<f>>>0){p[b>>2]=c;c=p[e+4>>2];p[b+4>>2]=p[e>>2];p[b+8>>2]=c;c=p[e+12>>2];p[b+12>>2]=p[e+8>>2];p[b+16>>2]=c;c=p[e+20>>2];p[b+20>>2]=p[e+16>>2];p[b+24>>2]=c;p[b+28>>2]=p[e+24>>2];p[a+140>>2]=b+32;break e}h=p[a+136>>2];i=b-h|0;b=i>>5;d=b+1|0;if(d>>>0>=134217728){break d}j=b<<5;f=f-h|0;b=f>>4;f=f>>5>>>0<67108863?b>>>0<d>>>0?d:b:134217727;b=0;f:{if(!f){break f}if(f>>>0>=134217728){break c}b=ha(f<<5)}d=j+b|0;p[d>>2]=c;c=p[e+4>>2];p[d+4>>2]=p[e>>2];p[d+8>>2]=c;c=p[e+12>>2];p[d+12>>2]=p[e+8>>2];p[d+16>>2]=c;c=p[e+20>>2];p[d+20>>2]=p[e+16>>2];p[d+24>>2]=c;p[d+28>>2]=p[e+24>>2];if((i|0)>=1){sa(b,h,i)}p[a+144>>2]=b+(f<<5);p[a+140>>2]=d+32;p[a+136>>2]=b;if(!h){break e}ea(h)}P=e+32|0;return g}ua();E()}H();E()}function Qu(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;g=P-80|0;P=g;f=ha(84);e=f;p[e+4>>2]=0;p[e+8>>2]=0;p[e+44>>2]=0;p[e+36>>2]=0;p[e+40>>2]=0;p[e>>2]=17452;p[e+20>>2]=0;p[e+24>>2]=0;p[e+12>>2]=0;p[e+16>>2]=0;p[e+28>>2]=0;p[e+32>>2]=12;p[g+56>>2]=0;e=g;p[e+48>>2]=0;p[e+52>>2]=0;p[e+40>>2]=0;p[e+44>>2]=0;h=pa(f+48|0,-1,e+40|0);p[e+32>>2]=0;p[e+24>>2]=0;p[e+28
Add support for the Wasm multi-value proposal https://bugs.webkit.org/show_bug.cgi?id=202250 Reviewed by Saam Barati. JSTests: This patch adds a new way to run stress tests via the .wat text format. By attaching an asm.js compiled version of the wabt tool we can easily create wat files programatically and convert them into a wasm blob to compile. To make this easy there is a wabt-wrapper.js module file that exports two useful functions that correspond to WebAssembly.compile and WebAssembly.instantiate. * wasm.yaml: * wasm/function-tests/if-no-else-non-void.js: * wasm/js-api/web-assembly-instantiate.js: (assert.asyncTest.async.test): (assert.asyncTest): * wasm/libwabt.js: Added. (WabtModule): (set get if): * wasm/references/func_ref.js: * wasm/references/validation.js: (assert.throws): * wasm/spec-harness/index.js: * wasm/spec-tests/block.wast.js: * wasm/spec-tests/br.wast.js: * wasm/spec-tests/br_if.wast.js: * wasm/spec-tests/call.wast.js: * wasm/spec-tests/call_indirect.wast.js: * wasm/spec-tests/func.wast.js: * wasm/spec-tests/if.wast.js: * wasm/spec-tests/loop.wast.js: * wasm/spec-tests/type.wast.js: * wasm/stress/js-wasm-call-many-return-types-on-stack-no-args.js: Added. (buildWat): * wasm/stress/js-wasm-js-varying-arities.js: Added. (paramForwarder): * wasm/stress/wasm-js-call-many-return-types-on-stack-no-args.js: Added. (buildWat): * wasm/stress/wasm-js-multi-value-exception-in-iterator.js: Added. (buildWat.throwError): (buildWat.throwErrorInIterator): (buildWat.tooManyValues): (buildWat.tooFewValues): (buildWat): * wasm/stress/wasm-wasm-call-indirect-many-return-types-on-stack.js: Added. (buildWat): * wasm/stress/wasm-wasm-call-many-return-types-on-stack-no-args.js: Added. (buildWat): * wasm/wabt-wrapper.js: Added. (export.compile): * wasm/wast-tests/br-if-at-end-of-block.wasm: Added. * wasm/wast-tests/br-if-at-end-of-block.wast: Added. * wasm/wast-tests/harness.js: (async.runWasmFile): * wasm/wast-tests/single-param-loop-signature.wasm: Added. * wasm/wast-tests/single-param-loop-signature.wast: Added. Source/JavaScriptCore: The wasm multi-value proposal makes two major changes to the spec. The first is that functions may now return more than one value across calls. When calling to/from JS, if there is more than one return type we return/receive a JSArray/Iterable, respectively. In the Wasm calls JS case, if the iteratable object does not vend the exact number of objects expected by the signature an error is thrown. The second major change in the multi-value proposal allows blocks to have any signature type. This works in a backwards compatible way by exploiting the fact that the old value-type thunk signatures (where the block takes no arguments and returns just the value type i.e. [] -> [type]) were always encoded as a negative number. If a block has a function signature, it is encoded as a positive index into the type section. When a block has a function signature type then the values from the enclosing stack are popped off that stack and added to the new block's stack. In the case of a br/br_if to a Loop block the "argument" values should be on the brancher's stack. The biggest change in this patch is stripping down the WasmCallingConventions file into one simpler API that just tells you where the each argument should be located. It also now handles adding or subtracting sizeof(CallerFrameAndPC) depending on whether you are caller or callee. Additionally, when computing locations for the callee it returns a B3::ValueRep that has the offsetFromFP rather than offsetFromSP. Since the code has been cleaned up I tried to also reduce code duplication in the various stubs for wasm code. This patch also removes the Air specific calling convention code and moves that logic into the Air IR generator. Since blocks can now have arbitrary signatures the control entries now use a const signature* rather than just the return type. Additionally, what used to be the result phi is now the phis for all the results for non-loop blocks and the arguments for a loop block. Due to the control flow restrictions of wasm conveniently we don't have to worry about generating non-optimal SSA, thus we can just use phis directly rather than using a variable. Lastly, to help clean up some code in the IR generators new helper methods were added to create call Patchpoints. These helpers do most of the boiler-plate initialization. * JavaScriptCore.xcodeproj/project.pbxproj: * assembler/AbstractMacroAssembler.h: (JSC::AbstractMacroAssembler::ImplicitAddress::ImplicitAddress): * assembler/LinkBuffer.cpp: (JSC::shouldDumpDisassemblyFor): * assembler/LinkBuffer.h: * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::callOperation): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::callOperation): * b3/B3LowerToAir.cpp: * b3/B3PatchpointSpecial.cpp: (JSC::B3::PatchpointSpecial::forEachArg): (JSC::B3::PatchpointSpecial::isValid): (JSC::B3::PatchpointSpecial::admitsStack): (JSC::B3::PatchpointSpecial::generate): * b3/B3Procedure.h: (JSC::B3::Procedure::resultCount const): (JSC::B3::Procedure::typeAtOffset const): (JSC::B3::Procedure::returnCount const): Deleted. * b3/B3StackmapGenerationParams.cpp: (JSC::B3::StackmapGenerationParams::code const): * b3/B3StackmapGenerationParams.h: * b3/B3ValueRep.h: * b3/air/AirHelpers.h: Added. (JSC::B3::Air::moveForType): (JSC::B3::Air::relaxedMoveForType): * jit/AssemblyHelpers.h: (JSC::AssemblyHelpers::store64FromReg): (JSC::AssemblyHelpers::store32FromReg): (JSC::AssemblyHelpers::load64ToReg): (JSC::AssemblyHelpers::load32ToReg): * runtime/JSCConfig.h: * runtime/OptionsList.h: * tools/JSDollarVM.cpp: * tools/VMInspector.cpp: (JSC::VMInspector::dumpValue): * wasm/WasmAirIRGenerator.cpp: (JSC::Wasm::ConstrainedTmp::operator bool const): (JSC::Wasm::TypedTmp::dump const): (JSC::Wasm::AirIRGenerator::ControlData::ControlData): (JSC::Wasm::AirIRGenerator::ControlData::dump const): (JSC::Wasm::AirIRGenerator::ControlData::blockType const): (JSC::Wasm::AirIRGenerator::ControlData::signature const): (JSC::Wasm::AirIRGenerator::ControlData::targetBlockForBranch): (JSC::Wasm::AirIRGenerator::ControlData::convertIfToBlock): (JSC::Wasm::AirIRGenerator::addEndToUnreachable): (JSC::Wasm::AirIRGenerator::emitCallPatchpoint): (JSC::Wasm::AirIRGenerator::validateInst): (JSC::Wasm::AirIRGenerator::tmpsForSignature): (JSC::Wasm::AirIRGenerator::emitPatchpoint): (JSC::Wasm::AirIRGenerator::AirIRGenerator): (JSC::Wasm::AirIRGenerator::toB3ResultType): (JSC::Wasm::AirIRGenerator::addBottom): (JSC::Wasm::AirIRGenerator::emitLoopTierUpCheck): (JSC::Wasm::AirIRGenerator::addTopLevel): (JSC::Wasm::AirIRGenerator::addLoop): (JSC::Wasm::AirIRGenerator::addBlock): (JSC::Wasm::AirIRGenerator::addIf): (JSC::Wasm::AirIRGenerator::addElse): (JSC::Wasm::AirIRGenerator::addElseToUnreachable): (JSC::Wasm::AirIRGenerator::addReturn): (JSC::Wasm::AirIRGenerator::addBranch): (JSC::Wasm::AirIRGenerator::addSwitch): (JSC::Wasm::AirIRGenerator::endBlock): (JSC::Wasm::AirIRGenerator::addCall): (JSC::Wasm::AirIRGenerator::addCallIndirect): (JSC::Wasm::dumpExpressionStack): (JSC::Wasm::AirIRGenerator::dump): (JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncUF64>): (JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncUF32>): (JSC::Wasm::AirIRGenerator::ControlData::type const): Deleted. (JSC::Wasm::AirIRGenerator::ControlData::hasNonVoidSignature const): Deleted. (JSC::Wasm::AirIRGenerator::ControlData::resultForBranch const): Deleted. * wasm/WasmB3IRGenerator.cpp: (JSC::Wasm::B3IRGenerator::ControlData::ControlData): (JSC::Wasm::B3IRGenerator::ControlData::dump const): (JSC::Wasm::B3IRGenerator::ControlData::blockType const): (JSC::Wasm::B3IRGenerator::ControlData::hasNonVoidresult const): (JSC::Wasm::B3IRGenerator::ControlData::targetBlockForBranch): (JSC::Wasm::B3IRGenerator::ControlData::convertIfToBlock): (JSC::Wasm::B3IRGenerator::addEndToUnreachable): (JSC::Wasm::B3IRGenerator::B3IRGenerator): (JSC::Wasm::B3IRGenerator::framePointer): (JSC::Wasm::B3IRGenerator::toB3ResultType): (JSC::Wasm::B3IRGenerator::addArguments): (JSC::Wasm::B3IRGenerator::addGrowMemory): (JSC::Wasm::B3IRGenerator::addLoop): (JSC::Wasm::B3IRGenerator::addTopLevel): (JSC::Wasm::B3IRGenerator::addBlock): (JSC::Wasm::B3IRGenerator::addIf): (JSC::Wasm::B3IRGenerator::addElse): (JSC::Wasm::B3IRGenerator::addElseToUnreachable): (JSC::Wasm::B3IRGenerator::addReturn): (JSC::Wasm::B3IRGenerator::addBranch): (JSC::Wasm::B3IRGenerator::addSwitch): (JSC::Wasm::B3IRGenerator::endBlock): (JSC::Wasm::B3IRGenerator::createCallPatchpoint): (JSC::Wasm::B3IRGenerator::addCall): (JSC::Wasm::B3IRGenerator::addCallIndirect): (JSC::Wasm::B3IRGenerator::ControlData::type const): Deleted. (JSC::Wasm::B3IRGenerator::ControlData::hasNonVoidSignature const): Deleted. (JSC::Wasm::B3IRGenerator::ControlData::resultForBranch const): Deleted. (JSC::Wasm::B3IRGenerator::createStack): Deleted. * wasm/WasmBBQPlan.cpp: (JSC::Wasm::BBQPlan::didReceiveFunctionData): (JSC::Wasm::BBQPlan::parseAndValidateModule): (JSC::Wasm::BBQPlan::complete): * wasm/WasmBBQPlan.h: * wasm/WasmBinding.cpp: (JSC::Wasm::wasmToWasm): * wasm/WasmCallingConvention.cpp: (JSC::Wasm::jsCallingConvention): (JSC::Wasm::wasmCallingConvention): (JSC::Wasm::jscCallingConvention): Deleted. (JSC::Wasm::jscCallingConventionAir): Deleted. (JSC::Wasm::wasmCallingConventionAir): Deleted. * wasm/WasmCallingConvention.h: (JSC::Wasm::CallInformation::CallInformation): (JSC::Wasm::CallInformation::computeResultsOffsetList): (JSC::Wasm::WasmCallingConvention::WasmCallingConvention): (JSC::Wasm::WasmCallingConvention::marshallLocationImpl const): (JSC::Wasm::WasmCallingConvention::marshallLocation const): (JSC::Wasm::WasmCallingConvention::callInformationFor const): (JSC::Wasm::JSCallingConvention::JSCallingConvention): (JSC::Wasm::JSCallingConvention::marshallLocationImpl const): (JSC::Wasm::JSCallingConvention::marshallLocation const): (JSC::Wasm::JSCallingConvention::callInformationFor const): (JSC::Wasm::CallingConvention::CallingConvention): Deleted. (JSC::Wasm::CallingConvention::marshallArgumentImpl const): Deleted. (JSC::Wasm::CallingConvention::marshallArgument const): Deleted. (JSC::Wasm::CallingConvention::headerSizeInBytes): Deleted. (JSC::Wasm::CallingConvention::setupFrameInPrologue const): Deleted. (JSC::Wasm::CallingConvention::loadArguments const): Deleted. (JSC::Wasm::CallingConvention::setupCall const): Deleted. (JSC::Wasm::CallingConventionAir::CallingConventionAir): Deleted. (JSC::Wasm::CallingConventionAir::prologueScratch const): Deleted. (JSC::Wasm::CallingConventionAir::marshallArgumentImpl const): Deleted. (JSC::Wasm::CallingConventionAir::marshallArgument const): Deleted. (JSC::Wasm::CallingConventionAir::headerSizeInBytes): Deleted. (JSC::Wasm::CallingConventionAir::loadArguments const): Deleted. (JSC::Wasm::CallingConventionAir::setupCall const): Deleted. (JSC::Wasm::nextJSCOffset): Deleted. * wasm/WasmFormat.h: * wasm/WasmFunctionParser.h: (JSC::Wasm::splitStack): (JSC::Wasm::FunctionParser::signature const): (JSC::Wasm::FunctionParser<Context>::FunctionParser): (JSC::Wasm::FunctionParser<Context>::parseBody): (JSC::Wasm::FunctionParser<Context>::parseExpression): (JSC::Wasm::FunctionParser<Context>::parseUnreachableExpression): * wasm/WasmInstance.h: * wasm/WasmMemoryInformation.cpp: (JSC::Wasm::getPinnedRegisters): * wasm/WasmOMGForOSREntryPlan.cpp: (JSC::Wasm::OMGForOSREntryPlan::work): * wasm/WasmOMGPlan.cpp: (JSC::Wasm::OMGPlan::work): * wasm/WasmParser.h: (JSC::Wasm::FailureHelper::makeString): (JSC::Wasm::Parser<SuccessType>::Parser): (JSC::Wasm::Parser<SuccessType>::peekInt7): (JSC::Wasm::Parser<SuccessType>::parseBlockSignature): (JSC::Wasm::Parser<SuccessType>::parseValueType): (JSC::Wasm::Parser<SuccessType>::parseResultType): Deleted. * wasm/WasmSectionParser.cpp: (JSC::Wasm::SectionParser::parseType): (JSC::Wasm::SectionParser::parseStart): * wasm/WasmSectionParser.h: * wasm/WasmSignature.cpp: (JSC::Wasm::Signature::toString const): (JSC::Wasm::Signature::dump const): (JSC::Wasm::computeHash): (JSC::Wasm::Signature::hash const): (JSC::Wasm::Signature::tryCreate): (JSC::Wasm::SignatureInformation::SignatureInformation): (JSC::Wasm::ParameterTypes::hash): (JSC::Wasm::ParameterTypes::equal): (JSC::Wasm::ParameterTypes::translate): (JSC::Wasm::SignatureInformation::signatureFor): (JSC::Wasm::SignatureInformation::adopt): Deleted. * wasm/WasmSignature.h: (JSC::Wasm::Signature::Signature): (JSC::Wasm::Signature::allocatedSize): (JSC::Wasm::Signature::returnCount const): (JSC::Wasm::Signature::returnType const): (JSC::Wasm::Signature::returnsVoid const): (JSC::Wasm::Signature::argument const): (JSC::Wasm::Signature::operator== const): (JSC::Wasm::Signature::getReturnType): (JSC::Wasm::Signature::getArgument): (JSC::Wasm::SignatureHash::SignatureHash): (JSC::Wasm::SignatureHash::equal): (JSC::Wasm::SignatureInformation::thunkFor const): (JSC::Wasm::Signature::returnType): Deleted. (JSC::Wasm::Signature::argument): Deleted. * wasm/WasmStreamingParser.cpp: (JSC::Wasm::StreamingParser::parseCodeSectionSize): (JSC::Wasm::StreamingParser::parseFunctionPayload): (JSC::Wasm::StreamingParser::parseSectionPayload): * wasm/WasmStreamingParser.h: (JSC::Wasm::StreamingParserClient::didReceiveSectionData): (JSC::Wasm::StreamingParser::reportError): (JSC::Wasm::StreamingParserClient::didReceiveFunctionData): Deleted. * wasm/WasmThunks.cpp: (JSC::Wasm::throwExceptionFromWasmThunkGenerator): (JSC::Wasm::throwStackOverflowFromWasmThunkGenerator): (JSC::Wasm::triggerOMGEntryTierUpThunkGenerator): * wasm/WasmValidate.cpp: (JSC::Wasm::Validate::ControlData::ControlData): (JSC::Wasm::Validate::ControlData::dump const): (JSC::Wasm::Validate::ControlData::blockType const): (JSC::Wasm::Validate::ControlData::signature const): (JSC::Wasm::Validate::ControlData::branchTargetArity const): (JSC::Wasm::Validate::ControlData::branchTargetType const): (JSC::Wasm::Validate::fail const): (JSC::Wasm::Validate::addTableGet): (JSC::Wasm::Validate::addTableGrow): (JSC::Wasm::Validate::addTableFill): (JSC::Wasm::Validate::addRefIsNull): (JSC::Wasm::Validate::addTopLevel): (JSC::Wasm::splitStack): (JSC::Wasm::Validate::addBlock): (JSC::Wasm::Validate::addLoop): (JSC::Wasm::Validate::addIf): (JSC::Wasm::Validate::addElseToUnreachable): (JSC::Wasm::Validate::addReturn): (JSC::Wasm::Validate::checkBranchTarget): (JSC::Wasm::Validate::addSwitch): (JSC::Wasm::Validate::addGrowMemory): (JSC::Wasm::Validate::addEndToUnreachable): (JSC::Wasm::Validate::addCall): (JSC::Wasm::Validate::addCallIndirect): (JSC::Wasm::Validate::unify): (JSC::Wasm::Validate::ControlData::hasNonVoidSignature const): Deleted. (JSC::Wasm::Validate::ControlData::type const): Deleted. (JSC::Wasm::Validate::ControlData::branchTargetSignature const): Deleted. * wasm/generateWasmOpsHeader.py: * wasm/js/JSToWasm.cpp: (JSC::Wasm::boxWasmResult): (JSC::Wasm::allocateResultsArray): (JSC::Wasm::marshallJSResult): (JSC::Wasm::createJSToWasmWrapper): * wasm/js/JSToWasm.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): * wasm/js/WasmToJS.cpp: (JSC::Wasm::handleBadI64Use): (JSC::Wasm::wasmToJS): * wasm/js/WasmToJS.h: * wasm/js/WebAssemblyFunction.cpp: (JSC::callWebAssemblyFunction): (JSC::WebAssemblyFunction::useTagRegisters const): (JSC::WebAssemblyFunction::jsCallEntrypointSlow): * wasm/js/WebAssemblyModuleRecord.cpp: (JSC::WebAssemblyModuleRecord::link): Tools: * Scripts/run-jsc-stress-tests: Canonical link: https://commits.webkit.org/215930@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250559 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-10-01 16:38:26 +00:00
WebAssembly: update wabt.js https://bugs.webkit.org/show_bug.cgi?id=218876 Patch by Sergey Rubanov <chi187@gmail.com> on 2020-11-13 Reviewed by Yusuke Suzuki. * wasm/libwabt.js: (WabtModule): Deleted. * wasm/regress/llint-callee-saves-with-fast-memory.js: (async test): * wasm/regress/llint-callee-saves-without-fast-memory.js: (async test): * wasm/regress/regression-with-loop.js: (async test): * wasm/regress/stack-consistency.js: (async test): * wasm/stress/js-wasm-call-many-return-types-on-stack-no-args.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/stress/js-wasm-js-varying-arities.js: (async paramForwarder): (async test): (paramForwarder): Deleted. * wasm/stress/local-ref.js: (async test): * wasm/stress/loop-more-args-than-results.js: (async test): * wasm/stress/set-local-enclosed-stack.js: (async test): (assert.eq.instance.exports.foo): Deleted. (assert.eq): Deleted. * wasm/stress/top-most-enclosing-stack.js: (async test): * wasm/stress/trunc-int-min-minus-one.js: (async test): * wasm/stress/wasm-js-call-many-return-types-on-stack-no-args.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/stress/wasm-js-multi-value-exception-in-iterator.js: (async buildWat): (async test): (buildWat.throwError): Deleted. (buildWat.throwErrorInIterator): Deleted. (buildWat.tooManyValues): Deleted. (buildWat.tooFewValues): Deleted. (buildWat): Deleted. * wasm/stress/wasm-wasm-call-indirect-many-return-types-on-stack.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/stress/wasm-wasm-call-many-return-types-on-stack-no-args.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/wabt-wrapper.js: (export.async compile): (export.compile): Deleted. Canonical link: https://commits.webkit.org/231540@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269766 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-11-13 08:36:26 +00:00
function xh(a,b,c,d){var e=0,f=0,g=0,h=0,i=0,j=0,k=0;e=P-160|0;P=e;Pa(e+16|0,0,144);p[e+92>>2]=-1;p[e+60>>2]=b;p[e+24>>2]=-1;p[e+20>>2]=b;pf(e+16|0);Yv(e,e+16|0,d);d=p[e+8>>2];g=p[e+12>>2];h=p[e>>2];i=p[e+4>>2];if(c){j=c;f=b;b=p[e+20>>2]-p[e+24>>2]|0;k=b;c=b+p[e+136>>2]|0;b=p[e+140>>2]+(b>>31)|0;b=c>>>0<k>>>0?b+1|0:b;p[j>>2]=!(b|c)?f:f+c|0}p[a>>2]=h;p[a+4>>2]=i;p[a+8>>2]=d;p[a+12>>2]=g;P=e+160|0}function Zq(a){a=a|0;var b=0,c=0,d=0;p[a>>2]=22312;c=p[a+104>>2];if(c){b=p[a+108>>2];d=c;a:{if((c|0)==(b|0)){break a}while(1){ia(b+ -40|0);b=b+ -44|0;if((c|0)!=(b|0)){continue}break}d=p[a+104>>2]}p[a+108>>2]=c;ea(d)}b=p[a+92>>2];if(b){while(1){d=p[b+4>>2];m[p[p[b>>2]+4>>2]](b);b=d;if(b){continue}break}}p[a+92>>2]=0;p[a+96>>2]=0;p[a+100>>2]=0;ia(a+52|0);if(n[a+51|0]<=-1){ea(p[a+40>>2])}return a|0}function Wp(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;f=P-32|0;P=f;e=p[a+16>>2];a:{b:{if(e>>>0>=143){while(1){fa(p[a+8>>2],63520,142,0,0);e=e+ -142|0;if(e>>>0>142){continue}break}e=p[a+16>>2];break b}if(!e){break a}}fa(p[a+8>>2],63520,e,0,0)}e=p[a+8>>2];p[f+16>>2]=c;p[f+20>>2]=d;p[f+8>>2]=c;p[f+12>>2]=d;p[f>>2]=b;ja(e,25416,f);a=p[a+12>>2];a=m[p[p[a>>2]+796>>2]](a,b,c,d)|0;P=f+32|0;return a|0}function Qp(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0;g=P-16|0;P=g;f=p[a+16>>2];a:{b:{if(f>>>0>=143){while(1){fa(p[a+8>>2],63520,142,0,0);f=f+ -142|0;if(f>>>0>142){continue}break}f=p[a+16>>2];break b}if(!f){break a}}fa(p[a+8>>2],63520,f,0,0)}f=p[a+8>>2];p[g+12>>2]=e;p[g+8>>2]=d;p[g+4>>2]=c;p[g>>2]=b;ja(f,25640,g);a=p[a+12>>2];a=m[p[p[a>>2]+696>>2]](a,b,c,d,e)|0;P=g+16|0;return a|0}function Yq(a){a=a|0;var b=0,c=0,d=0;p[a>>2]=22312;c=p[a+104>>2];if(c){b=p[a+108>>2];d=c;a:{if((c|0)==(b|0)){break a}while(1){ia(b+ -40|0);b=b+ -44|0;if((c|0)!=(b|0)){continue}break}d=p[a+104>>2]}p[a+108>>2]=c;ea(d)}b=p[a+92>>2];if(b){while(1){d=p[b+4>>2];m[p[p[b>>2]+4>>2]](b);b=d;if(b){continue}break}}p[a+92>>2]=0;p[a+96>>2]=0;p[a+100>>2]=0;ia(a+52|0);if(n[a+51|0]<=-1){ea(p[a+40>>2])}ea(a)}function Qc(a,b,c,d){var e=0,f=0,g=0;e=P-16|0;P=e;a:{b:{c:{g=q[a|0];switch(g+ -43|0){case 0:case 2:break c;default:break b}}f=1;if(!d){break a}a=a+1|0;f=(g|0)==45}p[e+8>>2]=0;p[e+12>>2]=0;d=Nb(a,b,e+8|0);b=p[e+8>>2];a=p[e+12>>2];if(f){f=1;if((a|0)==-2147483648&b>>>0>0|a>>>0>2147483648){break a}a=0-(a+(0<b>>>0)|0)|0;b=0-b|0;p[e+8>>2]=b;p[e+12>>2]=a}p[c>>2]=b;p[c+4>>2]=a;f=d}P=e+16|0;return f}function Lu(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0;b=P-32|0;P=b;e=p[a+20>>2];c=p[a+24>>2]-e|0;d=(c|0)/12|0;a:{if(!c){p[b+4>>2]=d;p[b>>2]=0;Ba(a,15936,b);c=1;break a}f=d+ -1|0;g=v(f,12)+e|0;if(p[g>>2]!=5){Ba(a,17760,0);c=1;break a}c=1;if(d>>>0<=1){p[b+20>>2]=d;p[b+16>>2]=1;Ba(a,15936,b+16|0);break a}p[g>>2]=6;p[(v(f,12)+e|0)+4>>2]=p[p[(v(d,12)+e|0)+ -20>>2]+4>>2]+144;c=0}P=b+32|0;return c|0}function nn(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0;d=P-16|0;P=d;p[d+8>>2]=c;c=p[a+16>>2];a:{b:{if(c>>>0>=143){while(1){fa(p[a+8>>2],63520,142,0,0);c=c+ -142|0;if(c>>>0>142){continue}break}c=p[a+16>>2];break b}if(!c){break a}}fa(p[a+8>>2],63520,c,0,0)}c=p[a+8>>2];e=d,f=ya(d+8|0),p[e+4>>2]=f;p[d>>2]=b;ja(c,29445,d);a=p[a+12>>2];a=m[p[p[a>>2]+816>>2]](a,b,p[d+8>>2])|0;P=d+16|0;return a|0}function dq(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0;d=P-16|0;P=d;p[d+8>>2]=c;c=p[a+16>>2];a:{b:{if(c>>>0>=143){while(1){fa(p[a+8>>2],63520,142,0,0);c=c+ -142|0;if(c>>>0>142){continue}break}c=p[a+16>>2];break b}if(!c){break a}}fa(p[a+8>>2],63520,c,0,0)}c=p[a+8>>2];e=d,f=ya(d+8|0),p[e+4>>2]=f;p[d>>2]=b;ja(c,24978,d);a=p[a+12>>2];a=m[p[p[a>>2]+564>>2]](a,b,p[d+8>>2])|0;P=d+16|0;return a|0}function Ln(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0;d=P-16|0;P=d;p[d+8>>2]=c;c=p[a+16>>2];a:{b:{if(c>>>0>=143){while(1){fa(p[a+8>>2],63520,142,0,0);c=c+ -142|0;if(c>>>0>142){continue}break}c=p[a+16>>2];break b}if(!c){break a}}fa(p[a+8>>2],63520,c,0,0)}c=p[a+8>>2];e=d,f=ya(d+8|0),p[e+4>>2]=f;p[d>>2]=b;ja(c,28797,d);a=p[a+12>>2];a=m[p[p[a>>2]+572>>2]](a,b,p[d+8>>2])|0;P=d+16|0;return a|0}function la(a){var b=0,c=0;c=P-16|0;P=c;a:{b:{switch(p[a+36>>2]+ -1|0){case 0:b=p[a+24>>2];n[c+14|0]=32;fa(b,c+14|0,1,0,0);break a;case 1:case 2:break b;d
function Gh(a,b){var c=0,d=0,e=0;c=p[b>>2];p[a+12>>2]=0;p[a+4>>2]=0;p[a+8>>2]=0;p[a>>2]=c;c=p[b+8>>2]-p[b+4>>2]|0;d=(c|0)/20|0;a:{if(c){if(d>>>0>=214748365){break a}c=ha(c);p[a+4>>2]=c;p[a+8>>2]=c;p[a+12>>2]=v(d,20)+c;d=p[b+4>>2];e=p[b+8>>2];if((d|0)!=(e|0)){while(1){Gh(c,d);c=c+20|0;d=d+20|0;if((e|0)!=(d|0)){continue}break}}p[a+8>>2]=c}p[a+16>>2]=p[b+16>>2];return}ua();E()}function xt(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0;d=P-112|0;P=d;b=p[p[p[a+12>>2]+148>>2]+(b<<2)>>2];p[d+20>>2]=0;p[d+24>>2]=0;e=p[a+36>>2];f=d,g=ma(e),p[f+12>>2]=g;p[d+8>>2]=e;p[d+16>>2]=p[p[a+4>>2]+8>>2];a=pa(d+32|0,c,d+8|0);c=p[b+72>>2];a:{if(c>>>0<s[b+76>>2]){e=ka(d+72|0,a);p[c>>2]=1;ka(c+4|0,e);ia(e);p[b+72>>2]=c+44;break a}dh(b+68|0,a)}ia(a);P=d+112|0;return 0}function qq(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;e=P-16|0;P=e;d=p[a+16>>2];a:{b:{if(d>>>0>=143){while(1){fa(p[a+8>>2],63520,142,0,0);d=d+ -142|0;if(d>>>0>142){continue}break}d=p[a+16>>2];break b}if(!d){break a}}fa(p[a+8>>2],63520,d,0,0)}d=p[a+8>>2];p[e+8>>2]=b;p[e+12>>2]=c;p[e>>2]=b;p[e+4>>2]=c;ja(d,24624,e);a=p[a+12>>2];a=m[p[p[a>>2]+360>>2]](a,b,c)|0;P=e+16|0;return a|0}function ak(a,b,c){var d=0,e=0,f=0,g=0;d=P-144|0;P=d;p[a+80>>2]=b;f=ka(d+24|0,c);e=ka(d- -64|0,f);c=ka(d+104|0,e);b=p[c+24>>2];g=p[a+164>>2]-p[a+160>>2]>>3;a:{b:{if(b>>>0>=g>>>0){p[d+8>>2]=g;p[d+4>>2]=b;p[d>>2]=45629;b=xa(a,c,45492,d);ia(c);c=0;if(!b){break b}break a}ia(c)}c=p[p[a+160>>2]+(p[e+24>>2]<<3)>>2];b=0}ia(e);ia(f);a=Fe(a+16|0,c);P=d+144|0;return(b|0)==1|(a|0)==1}function Ab(a,b){var c=0,d=0,e=0,f=0,g=0;c=P-16|0;P=c;d=p[a+4>>2];n[c+13|0]=34;fa(d,c+13|0,1,0,0);f=p[b+4>>2];if(f){g=p[b>>2];b=0;while(1){d=q[b+g|0];a:{if(!((d|0)!=34?!(d>>>0<32|(d|0)==92):0)){e=p[a+4>>2];p[c>>2]=d;ja(e,32316,c);break a}e=p[a+4>>2];n[c+14|0]=d;fa(e,c+14|0,1,0,0)}b=b+1|0;if((f|0)!=(b|0)){continue}break}}a=p[a+4>>2];n[c+15|0]=34;fa(a,c+15|0,1,0,0);P=c+16|0}function iy(a,b){var c=0,d=0;d=1;a:{if((ra(a,24)|0)==1){break a}if((ra(a,5)|0)==1){break a}c=ha(24);p[c+8>>2]=0;p[c+12>>2]=0;p[c>>2]=58948;p[c+4>>2]=7;p[c+16>>2]=0;p[c+20>>2]=0;b:{if((oe(a,c+8|0)|0)==1){break b}if((Rh(a,c+12|0,1)|0)==1){break b}if((ra(a,36)|0)==1){break b}a=p[b>>2];p[b>>2]=c;d=0;if(!a){break a}m[p[p[a>>2]+4>>2]](a);return 0}m[p[p[c>>2]+4>>2]](c)}return d}function Xp(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;e=P-32|0;P=e;d=p[a+16>>2];a:{b:{if(d>>>0>=143){while(1){fa(p[a+8>>2],63520,142,0,0);d=d+ -142|0;if(d>>>0>142){continue}break}d=p[a+16>>2];break b}if(!d){break a}}fa(p[a+8>>2],63520,d,0,0)}d=p[a+8>>2];p[e+16>>2]=c;p[e>>2]=b;u[e+8>>3]=(f(0,c),i());ja(d,25361,e);a=p[a+12>>2];a=m[p[p[a>>2]+792>>2]](a,b,c)|0;P=e+32|0;return a|0}function qy(a){a=a|0;var b=0,c=0,d=0;d=1;a:{b=p[a>>2];if(ob(b)){break a}b=b+ -60|0;c=b&31;if((32<=(b&63)>>>0?1048576>>>c|0:((1<<c)-1&1048576)<<32-c|8650753>>>c)&1?b>>>0<53:0){break a}b=p[a+4>>2];if(p[a>>2]!=24){return 0}a=b;if(ob(b)){break a}d=0;a=a+ -60|0;if(a>>>0>=53){break a}b=a&31;return(32<=(a&63)>>>0?1048576>>>b|0:((1<<b)-1&1048576)<<32-b|8650753>>>b)&1}return d|0}function Rp(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;f=P-16|0;P=f;e=p[a+16>>2];a:{b:{if(e>>>0>=143){while(1){fa(p[a+8>>2],63520,142,0,0);e=e+ -142|0;if(e>>>0>142){continue}break}e=p[a+16>>2];break b}if(!e){break a}}fa(p[a+8>>2],63520,e,0,0)}e=p[a+8>>2];p[f+8>>2]=c;p[f+12>>2]=d;p[f>>2]=b;ja(e,25592,f);a=p[a+12>>2];a=m[p[p[a>>2]+812>>2]](a,b,c,d)|0;P=f+16|0;return a|0}function Jl(a){a=a|0;var b=0,c=0,d=0,e=0;p[a>>2]=42312;c=p[a+60>>2];if(c){b=c;d=p[a- -64>>2];e=b;a:{if((b|0)==(d|0)){break a}while(1){b=d+ -12|0;if(n[d+ -1|0]<=-1){ea(p[b>>2])}d=b;if((c|0)!=(b|0)){continue}break}e=p[a+60>>2]}b=e;p[a+64>>2]=c;ea(b)}b=p[a+48>>2];if(b){p[a+52>>2]=b;ea(b)}b=p[a+36>>2];if(b){p[a+40>>2]=b;ea(b)}b=p[a+24>>2];if(b){p[a+28>>2]=b;ea(b)}return a|0}function ly(a,b){var c=0,d=0;d=1;a:{if((ra(a,24)|0)==1){break a}if((ra(a,2)|0)==1){break a}c=ha(24);p[c+8>>2]=0;p[c+12>>2]=0;p[c>>2]=58536;p[c+4>>2]=9;p[c+16>>2]=0;p[c+20>>2]=0;b:{if((oe(a,c+8|0)|0)==1){break b}if((Xa(a,c+12|0)|0)==1){break b}if((ra(a,36)|0)==1){break b}a=p[b>>2];p[b>>2]=c;d=0;if(!a){break a}m[p[p[a>>2]+4>>2]](a);return 0}m[p[p[c>>2
function Mt(a){a=a|0;if(a){ea(a)}}function Fe(a,b){Ra(a,b);return 0}function Dm(a){a=a|0;return 33228}function og(a){Ra(a,-1);return 0}function oc(a){a=a|0;return a|0}function kh(a,b){return Fv(a,b)}function on(a){a=a|0;ea($e(a))}function jf(a,b){mh(a,b,ma(b))}function Bb(a,b){n[a|0]=q[b|0]}function Za(a){a=a|0;return 0}function he(a,b){n[a+11|0]=b}function pw(){return 370400}function fe(a,b){p[a>>2]=b}function Ka(a){a=a|0;ea(a)}function gf(a,b){Av(a,b)}function ua(){nc();E()}function nc(){H();E()}function mc(a){a=a|0}function Ty(){Tv()}function Un(){}
Add support for the Wasm multi-value proposal https://bugs.webkit.org/show_bug.cgi?id=202250 Reviewed by Saam Barati. JSTests: This patch adds a new way to run stress tests via the .wat text format. By attaching an asm.js compiled version of the wabt tool we can easily create wat files programatically and convert them into a wasm blob to compile. To make this easy there is a wabt-wrapper.js module file that exports two useful functions that correspond to WebAssembly.compile and WebAssembly.instantiate. * wasm.yaml: * wasm/function-tests/if-no-else-non-void.js: * wasm/js-api/web-assembly-instantiate.js: (assert.asyncTest.async.test): (assert.asyncTest): * wasm/libwabt.js: Added. (WabtModule): (set get if): * wasm/references/func_ref.js: * wasm/references/validation.js: (assert.throws): * wasm/spec-harness/index.js: * wasm/spec-tests/block.wast.js: * wasm/spec-tests/br.wast.js: * wasm/spec-tests/br_if.wast.js: * wasm/spec-tests/call.wast.js: * wasm/spec-tests/call_indirect.wast.js: * wasm/spec-tests/func.wast.js: * wasm/spec-tests/if.wast.js: * wasm/spec-tests/loop.wast.js: * wasm/spec-tests/type.wast.js: * wasm/stress/js-wasm-call-many-return-types-on-stack-no-args.js: Added. (buildWat): * wasm/stress/js-wasm-js-varying-arities.js: Added. (paramForwarder): * wasm/stress/wasm-js-call-many-return-types-on-stack-no-args.js: Added. (buildWat): * wasm/stress/wasm-js-multi-value-exception-in-iterator.js: Added. (buildWat.throwError): (buildWat.throwErrorInIterator): (buildWat.tooManyValues): (buildWat.tooFewValues): (buildWat): * wasm/stress/wasm-wasm-call-indirect-many-return-types-on-stack.js: Added. (buildWat): * wasm/stress/wasm-wasm-call-many-return-types-on-stack-no-args.js: Added. (buildWat): * wasm/wabt-wrapper.js: Added. (export.compile): * wasm/wast-tests/br-if-at-end-of-block.wasm: Added. * wasm/wast-tests/br-if-at-end-of-block.wast: Added. * wasm/wast-tests/harness.js: (async.runWasmFile): * wasm/wast-tests/single-param-loop-signature.wasm: Added. * wasm/wast-tests/single-param-loop-signature.wast: Added. Source/JavaScriptCore: The wasm multi-value proposal makes two major changes to the spec. The first is that functions may now return more than one value across calls. When calling to/from JS, if there is more than one return type we return/receive a JSArray/Iterable, respectively. In the Wasm calls JS case, if the iteratable object does not vend the exact number of objects expected by the signature an error is thrown. The second major change in the multi-value proposal allows blocks to have any signature type. This works in a backwards compatible way by exploiting the fact that the old value-type thunk signatures (where the block takes no arguments and returns just the value type i.e. [] -> [type]) were always encoded as a negative number. If a block has a function signature, it is encoded as a positive index into the type section. When a block has a function signature type then the values from the enclosing stack are popped off that stack and added to the new block's stack. In the case of a br/br_if to a Loop block the "argument" values should be on the brancher's stack. The biggest change in this patch is stripping down the WasmCallingConventions file into one simpler API that just tells you where the each argument should be located. It also now handles adding or subtracting sizeof(CallerFrameAndPC) depending on whether you are caller or callee. Additionally, when computing locations for the callee it returns a B3::ValueRep that has the offsetFromFP rather than offsetFromSP. Since the code has been cleaned up I tried to also reduce code duplication in the various stubs for wasm code. This patch also removes the Air specific calling convention code and moves that logic into the Air IR generator. Since blocks can now have arbitrary signatures the control entries now use a const signature* rather than just the return type. Additionally, what used to be the result phi is now the phis for all the results for non-loop blocks and the arguments for a loop block. Due to the control flow restrictions of wasm conveniently we don't have to worry about generating non-optimal SSA, thus we can just use phis directly rather than using a variable. Lastly, to help clean up some code in the IR generators new helper methods were added to create call Patchpoints. These helpers do most of the boiler-plate initialization. * JavaScriptCore.xcodeproj/project.pbxproj: * assembler/AbstractMacroAssembler.h: (JSC::AbstractMacroAssembler::ImplicitAddress::ImplicitAddress): * assembler/LinkBuffer.cpp: (JSC::shouldDumpDisassemblyFor): * assembler/LinkBuffer.h: * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::callOperation): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::callOperation): * b3/B3LowerToAir.cpp: * b3/B3PatchpointSpecial.cpp: (JSC::B3::PatchpointSpecial::forEachArg): (JSC::B3::PatchpointSpecial::isValid): (JSC::B3::PatchpointSpecial::admitsStack): (JSC::B3::PatchpointSpecial::generate): * b3/B3Procedure.h: (JSC::B3::Procedure::resultCount const): (JSC::B3::Procedure::typeAtOffset const): (JSC::B3::Procedure::returnCount const): Deleted. * b3/B3StackmapGenerationParams.cpp: (JSC::B3::StackmapGenerationParams::code const): * b3/B3StackmapGenerationParams.h: * b3/B3ValueRep.h: * b3/air/AirHelpers.h: Added. (JSC::B3::Air::moveForType): (JSC::B3::Air::relaxedMoveForType): * jit/AssemblyHelpers.h: (JSC::AssemblyHelpers::store64FromReg): (JSC::AssemblyHelpers::store32FromReg): (JSC::AssemblyHelpers::load64ToReg): (JSC::AssemblyHelpers::load32ToReg): * runtime/JSCConfig.h: * runtime/OptionsList.h: * tools/JSDollarVM.cpp: * tools/VMInspector.cpp: (JSC::VMInspector::dumpValue): * wasm/WasmAirIRGenerator.cpp: (JSC::Wasm::ConstrainedTmp::operator bool const): (JSC::Wasm::TypedTmp::dump const): (JSC::Wasm::AirIRGenerator::ControlData::ControlData): (JSC::Wasm::AirIRGenerator::ControlData::dump const): (JSC::Wasm::AirIRGenerator::ControlData::blockType const): (JSC::Wasm::AirIRGenerator::ControlData::signature const): (JSC::Wasm::AirIRGenerator::ControlData::targetBlockForBranch): (JSC::Wasm::AirIRGenerator::ControlData::convertIfToBlock): (JSC::Wasm::AirIRGenerator::addEndToUnreachable): (JSC::Wasm::AirIRGenerator::emitCallPatchpoint): (JSC::Wasm::AirIRGenerator::validateInst): (JSC::Wasm::AirIRGenerator::tmpsForSignature): (JSC::Wasm::AirIRGenerator::emitPatchpoint): (JSC::Wasm::AirIRGenerator::AirIRGenerator): (JSC::Wasm::AirIRGenerator::toB3ResultType): (JSC::Wasm::AirIRGenerator::addBottom): (JSC::Wasm::AirIRGenerator::emitLoopTierUpCheck): (JSC::Wasm::AirIRGenerator::addTopLevel): (JSC::Wasm::AirIRGenerator::addLoop): (JSC::Wasm::AirIRGenerator::addBlock): (JSC::Wasm::AirIRGenerator::addIf): (JSC::Wasm::AirIRGenerator::addElse): (JSC::Wasm::AirIRGenerator::addElseToUnreachable): (JSC::Wasm::AirIRGenerator::addReturn): (JSC::Wasm::AirIRGenerator::addBranch): (JSC::Wasm::AirIRGenerator::addSwitch): (JSC::Wasm::AirIRGenerator::endBlock): (JSC::Wasm::AirIRGenerator::addCall): (JSC::Wasm::AirIRGenerator::addCallIndirect): (JSC::Wasm::dumpExpressionStack): (JSC::Wasm::AirIRGenerator::dump): (JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncUF64>): (JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncUF32>): (JSC::Wasm::AirIRGenerator::ControlData::type const): Deleted. (JSC::Wasm::AirIRGenerator::ControlData::hasNonVoidSignature const): Deleted. (JSC::Wasm::AirIRGenerator::ControlData::resultForBranch const): Deleted. * wasm/WasmB3IRGenerator.cpp: (JSC::Wasm::B3IRGenerator::ControlData::ControlData): (JSC::Wasm::B3IRGenerator::ControlData::dump const): (JSC::Wasm::B3IRGenerator::ControlData::blockType const): (JSC::Wasm::B3IRGenerator::ControlData::hasNonVoidresult const): (JSC::Wasm::B3IRGenerator::ControlData::targetBlockForBranch): (JSC::Wasm::B3IRGenerator::ControlData::convertIfToBlock): (JSC::Wasm::B3IRGenerator::addEndToUnreachable): (JSC::Wasm::B3IRGenerator::B3IRGenerator): (JSC::Wasm::B3IRGenerator::framePointer): (JSC::Wasm::B3IRGenerator::toB3ResultType): (JSC::Wasm::B3IRGenerator::addArguments): (JSC::Wasm::B3IRGenerator::addGrowMemory): (JSC::Wasm::B3IRGenerator::addLoop): (JSC::Wasm::B3IRGenerator::addTopLevel): (JSC::Wasm::B3IRGenerator::addBlock): (JSC::Wasm::B3IRGenerator::addIf): (JSC::Wasm::B3IRGenerator::addElse): (JSC::Wasm::B3IRGenerator::addElseToUnreachable): (JSC::Wasm::B3IRGenerator::addReturn): (JSC::Wasm::B3IRGenerator::addBranch): (JSC::Wasm::B3IRGenerator::addSwitch): (JSC::Wasm::B3IRGenerator::endBlock): (JSC::Wasm::B3IRGenerator::createCallPatchpoint): (JSC::Wasm::B3IRGenerator::addCall): (JSC::Wasm::B3IRGenerator::addCallIndirect): (JSC::Wasm::B3IRGenerator::ControlData::type const): Deleted. (JSC::Wasm::B3IRGenerator::ControlData::hasNonVoidSignature const): Deleted. (JSC::Wasm::B3IRGenerator::ControlData::resultForBranch const): Deleted. (JSC::Wasm::B3IRGenerator::createStack): Deleted. * wasm/WasmBBQPlan.cpp: (JSC::Wasm::BBQPlan::didReceiveFunctionData): (JSC::Wasm::BBQPlan::parseAndValidateModule): (JSC::Wasm::BBQPlan::complete): * wasm/WasmBBQPlan.h: * wasm/WasmBinding.cpp: (JSC::Wasm::wasmToWasm): * wasm/WasmCallingConvention.cpp: (JSC::Wasm::jsCallingConvention): (JSC::Wasm::wasmCallingConvention): (JSC::Wasm::jscCallingConvention): Deleted. (JSC::Wasm::jscCallingConventionAir): Deleted. (JSC::Wasm::wasmCallingConventionAir): Deleted. * wasm/WasmCallingConvention.h: (JSC::Wasm::CallInformation::CallInformation): (JSC::Wasm::CallInformation::computeResultsOffsetList): (JSC::Wasm::WasmCallingConvention::WasmCallingConvention): (JSC::Wasm::WasmCallingConvention::marshallLocationImpl const): (JSC::Wasm::WasmCallingConvention::marshallLocation const): (JSC::Wasm::WasmCallingConvention::callInformationFor const): (JSC::Wasm::JSCallingConvention::JSCallingConvention): (JSC::Wasm::JSCallingConvention::marshallLocationImpl const): (JSC::Wasm::JSCallingConvention::marshallLocation const): (JSC::Wasm::JSCallingConvention::callInformationFor const): (JSC::Wasm::CallingConvention::CallingConvention): Deleted. (JSC::Wasm::CallingConvention::marshallArgumentImpl const): Deleted. (JSC::Wasm::CallingConvention::marshallArgument const): Deleted. (JSC::Wasm::CallingConvention::headerSizeInBytes): Deleted. (JSC::Wasm::CallingConvention::setupFrameInPrologue const): Deleted. (JSC::Wasm::CallingConvention::loadArguments const): Deleted. (JSC::Wasm::CallingConvention::setupCall const): Deleted. (JSC::Wasm::CallingConventionAir::CallingConventionAir): Deleted. (JSC::Wasm::CallingConventionAir::prologueScratch const): Deleted. (JSC::Wasm::CallingConventionAir::marshallArgumentImpl const): Deleted. (JSC::Wasm::CallingConventionAir::marshallArgument const): Deleted. (JSC::Wasm::CallingConventionAir::headerSizeInBytes): Deleted. (JSC::Wasm::CallingConventionAir::loadArguments const): Deleted. (JSC::Wasm::CallingConventionAir::setupCall const): Deleted. (JSC::Wasm::nextJSCOffset): Deleted. * wasm/WasmFormat.h: * wasm/WasmFunctionParser.h: (JSC::Wasm::splitStack): (JSC::Wasm::FunctionParser::signature const): (JSC::Wasm::FunctionParser<Context>::FunctionParser): (JSC::Wasm::FunctionParser<Context>::parseBody): (JSC::Wasm::FunctionParser<Context>::parseExpression): (JSC::Wasm::FunctionParser<Context>::parseUnreachableExpression): * wasm/WasmInstance.h: * wasm/WasmMemoryInformation.cpp: (JSC::Wasm::getPinnedRegisters): * wasm/WasmOMGForOSREntryPlan.cpp: (JSC::Wasm::OMGForOSREntryPlan::work): * wasm/WasmOMGPlan.cpp: (JSC::Wasm::OMGPlan::work): * wasm/WasmParser.h: (JSC::Wasm::FailureHelper::makeString): (JSC::Wasm::Parser<SuccessType>::Parser): (JSC::Wasm::Parser<SuccessType>::peekInt7): (JSC::Wasm::Parser<SuccessType>::parseBlockSignature): (JSC::Wasm::Parser<SuccessType>::parseValueType): (JSC::Wasm::Parser<SuccessType>::parseResultType): Deleted. * wasm/WasmSectionParser.cpp: (JSC::Wasm::SectionParser::parseType): (JSC::Wasm::SectionParser::parseStart): * wasm/WasmSectionParser.h: * wasm/WasmSignature.cpp: (JSC::Wasm::Signature::toString const): (JSC::Wasm::Signature::dump const): (JSC::Wasm::computeHash): (JSC::Wasm::Signature::hash const): (JSC::Wasm::Signature::tryCreate): (JSC::Wasm::SignatureInformation::SignatureInformation): (JSC::Wasm::ParameterTypes::hash): (JSC::Wasm::ParameterTypes::equal): (JSC::Wasm::ParameterTypes::translate): (JSC::Wasm::SignatureInformation::signatureFor): (JSC::Wasm::SignatureInformation::adopt): Deleted. * wasm/WasmSignature.h: (JSC::Wasm::Signature::Signature): (JSC::Wasm::Signature::allocatedSize): (JSC::Wasm::Signature::returnCount const): (JSC::Wasm::Signature::returnType const): (JSC::Wasm::Signature::returnsVoid const): (JSC::Wasm::Signature::argument const): (JSC::Wasm::Signature::operator== const): (JSC::Wasm::Signature::getReturnType): (JSC::Wasm::Signature::getArgument): (JSC::Wasm::SignatureHash::SignatureHash): (JSC::Wasm::SignatureHash::equal): (JSC::Wasm::SignatureInformation::thunkFor const): (JSC::Wasm::Signature::returnType): Deleted. (JSC::Wasm::Signature::argument): Deleted. * wasm/WasmStreamingParser.cpp: (JSC::Wasm::StreamingParser::parseCodeSectionSize): (JSC::Wasm::StreamingParser::parseFunctionPayload): (JSC::Wasm::StreamingParser::parseSectionPayload): * wasm/WasmStreamingParser.h: (JSC::Wasm::StreamingParserClient::didReceiveSectionData): (JSC::Wasm::StreamingParser::reportError): (JSC::Wasm::StreamingParserClient::didReceiveFunctionData): Deleted. * wasm/WasmThunks.cpp: (JSC::Wasm::throwExceptionFromWasmThunkGenerator): (JSC::Wasm::throwStackOverflowFromWasmThunkGenerator): (JSC::Wasm::triggerOMGEntryTierUpThunkGenerator): * wasm/WasmValidate.cpp: (JSC::Wasm::Validate::ControlData::ControlData): (JSC::Wasm::Validate::ControlData::dump const): (JSC::Wasm::Validate::ControlData::blockType const): (JSC::Wasm::Validate::ControlData::signature const): (JSC::Wasm::Validate::ControlData::branchTargetArity const): (JSC::Wasm::Validate::ControlData::branchTargetType const): (JSC::Wasm::Validate::fail const): (JSC::Wasm::Validate::addTableGet): (JSC::Wasm::Validate::addTableGrow): (JSC::Wasm::Validate::addTableFill): (JSC::Wasm::Validate::addRefIsNull): (JSC::Wasm::Validate::addTopLevel): (JSC::Wasm::splitStack): (JSC::Wasm::Validate::addBlock): (JSC::Wasm::Validate::addLoop): (JSC::Wasm::Validate::addIf): (JSC::Wasm::Validate::addElseToUnreachable): (JSC::Wasm::Validate::addReturn): (JSC::Wasm::Validate::checkBranchTarget): (JSC::Wasm::Validate::addSwitch): (JSC::Wasm::Validate::addGrowMemory): (JSC::Wasm::Validate::addEndToUnreachable): (JSC::Wasm::Validate::addCall): (JSC::Wasm::Validate::addCallIndirect): (JSC::Wasm::Validate::unify): (JSC::Wasm::Validate::ControlData::hasNonVoidSignature const): Deleted. (JSC::Wasm::Validate::ControlData::type const): Deleted. (JSC::Wasm::Validate::ControlData::branchTargetSignature const): Deleted. * wasm/generateWasmOpsHeader.py: * wasm/js/JSToWasm.cpp: (JSC::Wasm::boxWasmResult): (JSC::Wasm::allocateResultsArray): (JSC::Wasm::marshallJSResult): (JSC::Wasm::createJSToWasmWrapper): * wasm/js/JSToWasm.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): * wasm/js/WasmToJS.cpp: (JSC::Wasm::handleBadI64Use): (JSC::Wasm::wasmToJS): * wasm/js/WasmToJS.h: * wasm/js/WebAssemblyFunction.cpp: (JSC::callWebAssemblyFunction): (JSC::WebAssemblyFunction::useTagRegisters const): (JSC::WebAssemblyFunction::jsCallEntrypointSlow): * wasm/js/WebAssemblyModuleRecord.cpp: (JSC::WebAssemblyModuleRecord::link): Tools: * Scripts/run-jsc-stress-tests: Canonical link: https://commits.webkit.org/215930@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250559 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-10-01 16:38:26 +00:00
// EMSCRIPTEN_END_FUNCS
WebAssembly: update wabt.js https://bugs.webkit.org/show_bug.cgi?id=218876 Patch by Sergey Rubanov <chi187@gmail.com> on 2020-11-13 Reviewed by Yusuke Suzuki. * wasm/libwabt.js: (WabtModule): Deleted. * wasm/regress/llint-callee-saves-with-fast-memory.js: (async test): * wasm/regress/llint-callee-saves-without-fast-memory.js: (async test): * wasm/regress/regression-with-loop.js: (async test): * wasm/regress/stack-consistency.js: (async test): * wasm/stress/js-wasm-call-many-return-types-on-stack-no-args.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/stress/js-wasm-js-varying-arities.js: (async paramForwarder): (async test): (paramForwarder): Deleted. * wasm/stress/local-ref.js: (async test): * wasm/stress/loop-more-args-than-results.js: (async test): * wasm/stress/set-local-enclosed-stack.js: (async test): (assert.eq.instance.exports.foo): Deleted. (assert.eq): Deleted. * wasm/stress/top-most-enclosing-stack.js: (async test): * wasm/stress/trunc-int-min-minus-one.js: (async test): * wasm/stress/wasm-js-call-many-return-types-on-stack-no-args.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/stress/wasm-js-multi-value-exception-in-iterator.js: (async buildWat): (async test): (buildWat.throwError): Deleted. (buildWat.throwErrorInIterator): Deleted. (buildWat.tooManyValues): Deleted. (buildWat.tooFewValues): Deleted. (buildWat): Deleted. * wasm/stress/wasm-wasm-call-indirect-many-return-types-on-stack.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/stress/wasm-wasm-call-many-return-types-on-stack-no-args.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/wabt-wrapper.js: (export.async compile): (export.compile): Deleted. Canonical link: https://commits.webkit.org/231540@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269766 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-11-13 08:36:26 +00:00
m[1]=$e;m[2]=on;m[3]=va;m[4]=Wd;m[5]=Ud;m[6]=Ug;m[7]=Ug;m[8]=zm;m[9]=rm;m[10]=Ue;m[11]=Lg;m[12]=va;m[13]=va;m[14]=va;m[15]=va;m[16]=Hg;m[17]=Hg;m[18]=Wd;m[19]=va;m[20]=Ud;m[21]=va;m[22]=Oe;m[23]=Oe;m[24]=Oe;m[25]=Wd;m[26]=Ud;m[27]=va;m[28]=Eg;m[29]=va;m[30]=va;m[31]=Eg;m[32]=va;m[33]=Zl;m[34]=Ul;m[35]=Ml;m[36]=Yc;m[37]=Yc;m[38]=Yc;m[39]=Yc;m[40]=Yc;m[41]=Ue;m[42]=va;m[43]=va;m[44]=va;m[45]=va;m[46]=Ue;m[47]=Lg;m[48]=va;m[49]=va;m[50]=va;m[51]=va;m[52]=Wd;m[53]=va;m[54]=Ud;m[55]=El;m[56]=va;m[57]=va;m[58]=va;m[59]=va;m[60]=va;m[61]=va;m[62]=va;m[63]=va;m[64]=va;m[65]=va;m[66]=va;m[67]=va;m[68]=yi;m[69]=si;m[70]=qi;m[71]=zc;m[72]=va;m[73]=Za;m[74]=xc;m[75]=Pc;m[76]=Za;m[77]=va;m[78]=Oy;m[79]=Hy;m[80]=ty;m[81]=ey;m[82]=Za;m[83]=va;m[84]=Yx;m[85]=me;m[86]=Cx;m[87]=ux;m[88]=px;m[89]=ox;m[90]=mx;m[91]=Za;m[92]=va;m[93]=cx;m[94]=Uw;m[95]=Za;m[96]=va;m[97]=Jw;m[98]=yw;m[99]=Za;m[100]=va;m[101]=ow;m[102]=gw;m[103]=Za;m[104]=va;m[105]=dw;m[106]=Zv;m[107]=Sv;m[108]=nf;m[109]=va;m[110]=Za;m[111]=va;m[112]=Nv;m[113]=Kv;m[114]=Za;m[115]=va;m[116]=Iv;m[117]=Za;m[118]=va;m[119]=va;m[120]=Gv;m[121]=va;m[122]=wv;m[123]=va;m[124]=Za;m[125]=va;m[126]=va;m[127]=Pc;m[128]=Pc;m[129]=Pc;m[130]=va;m[131]=Pc;m[132]=va;m[133]=va;m[134]=va;m[135]=kv;m[136]=bv;m[137]=$u;m[138]=_u;m[139]=Zu;m[140]=Yu;m[141]=Xu;m[142]=Vu;m[143]=Uu;m[144]=Tu;m[145]=Su;m[146]=Ru;m[147]=Qu;m[148]=Ou;m[149]=Nu;m[150]=Lu;m[151]=Ku;m[152]=Ju;m[153]=Iu;m[154]=Hu;m[155]=Gu;m[156]=Za;m[157]=Fu;m[158]=Eu;m[159]=Du;m[160]=Cu;m[161]=Au;m[162]=zu;m[163]=yu;m[164]=xu;m[165]=wu;m[166]=vu;m[167]=uu;m[168]=tu;m[169]=su;m[170]=ru;m[171]=pu;m[172]=ou;m[173]=nu;m[174]=mu;m[175]=lu;m[176]=ku;m[177]=ju;m[178]=iu;m[179]=hu;m[180]=gu;m[181]=eu;m[182]=du;m[183]=cu;m[184]=bu;m[185]=au;m[186]=$t;m[187]=_t;m[188]=Zt;m[189]=Yt;m[190]=Xt;m[191]=Vt;m[192]=Ut;m[193]=St;m[194]=Rt;m[195]=Qt;m[196]=Pt;m[197]=Ot;m[198]=Nt;m[199]=Kt;m[200]=Za;m[201]=Jt;m[202]=It;m[203]=Ht;m[204]=va;m[205]=Gt;m[206]=Ft;m[207]=Et;m[208]=nf;m[209]=Dt;m[210]=Ct;m[211]=zt;m[212]=xt;m[213]=va;m[214]=Za;m[215]=va;m[216]=wt;m[217]=vt;m[218]=ut;m[219]=nf;m[220]=tt;m[221]=va;m[222]=Za;m[223]=va;m[224]=va;m[225]=Za;m[226]=va;m[227]=xc;m[228]=st;m[229]=xc;m[230]=qt;m[231]=pt;m[232]=xc;m[233]=va;m[234]=ot;m[235]=nt;m[236]=Za;m[237]=va;m[238]=Pc;m[239]=me;m[240]=Za;m[241]=va;m[242]=me;m[243]=va;m[244]=va;m[245]=Za;m[246]=va;m[247]=va;m[248]=xc;m[249]=lt;m[250]=kt;m[251]=it;m[252]=xc;m[253]=ht;m[254]=va;m[255]=me;m[256]=va;m[257]=Pc;m[258]=va;m[259]=xc;m[260]=Pc;m[261]=Za;m[262]=va;m[263]=va;m[264]=gt;m[265]=Za;m[266]=ft;m[267]=et;m[268]=dt;m[269]=ct;m[270]=bt;m[271]=at;m[272]=$s;m[273]=Zs;m[274]=Ys;m[275]=Xs;m[276]=Ws;m[277]=Vs;m[278]=Us;m[279]=Ts;m[280]=Ss;m[281]=Rs;m[282]=Qs;m[283]=Os;m[284]=Ns;m[285]=Ms;m[286]=Gs;m[287]=Ls;m[288]=Ks;m[289]=Js;m[290]=Is;m[291]=Hs;m[292]=Es;m[293]=Ds;m[294]=Cs;m[295]=Bs;m[296]=As;m[297]=zs;m[298]=ys;m[299]=xs;m[300]=ws;m[301]=vs;m[302]=ts;m[303]=ss;m[304]=rs;m[305]=qs;m[306]=ps;m[307]=os;m[308]=ns;m[309]=ms;m[310]=oc;m[311]=Ka;m[312]=Ka;m[313]=Ka;m[314]=Ka;m[315]=Ka;m[316]=Ka;m[317]=Ka;m[318]=Ka;m[319]=ks;m[320]=js;m[321]=is;m[322]=hs;m[323]=gs;m[324]=fs;m[325]=es;m[326]=ds;m[327]=cs;m[328]=bs;m[329]=$r;m[330]=_r;m[331]=Zr;m[332]=Yr;m[333]=Ka;m[334]=Ka;m[335]=Ka;m[336]=Ka;m[337]=Xr;m[338]=Wr;m[339]=Vr;m[340]=Ur;m[341]=Tr;m[342]=Sr;m[343]=Ka;m[344]=Pr;m[345]=Or;m[346]=Nr;m[347]=Mr;m[348]=Lr;m[349]=Kr;m[350]=Jr;m[351]=Ir;m[352]=Ka;m[353]=Hr;m[354]=Gr;m[355]=Ka;m[356]=Ka;m[357]=Er;m[358]=Dr;m[359]=Ka;m[360]=Cr;m[361]=Br;m[362]=Ar;m[363]=zr;m[364]=yr;m[365]=xr;m[366]=wr;m[367]=vr;m[368]=tr;m[369]=sr;m[370]=rr;m[371]=qr;m[372]=pr;m[373]=or;m[374]=nr;m[375]=mr;m[376]=lr;m[377]=kr;m[378]=Ka;m[379]=Ka;m[380]=Ka;m[381]=Ka;m[382]=Ka;m[383]=ir;m[384]=hr;m[385]=gr;m[386]=fr;m[387]=er;m[388]=dr;m[389]=Ka;m[390]=cr;m[391]=br;m[392]=ar;m[393]=$q;m[394]=Ka;m[395]=Ka;m[396]=Ka;m[397]=Ka;m[398]=Ka;m[399]=Ka;m[400]=Zq;m[401]=Yq;m[402]=Xq;m[403]=Wq;m[404]=Tq;m[405]=Sq;m[406]=oc;m[407]=Ka;m[408]=Qq;m[409]=Pq;m[410]=Oq;m[411]=Bp;m[412]=Nq;m[413]=Mq;m[414]=Ap;m[415]=zp;m[416]=yp;m[417]=Lq;m[418]=Kq;m[419]=Jq;m[420]=xp;m[4
Add support for the Wasm multi-value proposal https://bugs.webkit.org/show_bug.cgi?id=202250 Reviewed by Saam Barati. JSTests: This patch adds a new way to run stress tests via the .wat text format. By attaching an asm.js compiled version of the wabt tool we can easily create wat files programatically and convert them into a wasm blob to compile. To make this easy there is a wabt-wrapper.js module file that exports two useful functions that correspond to WebAssembly.compile and WebAssembly.instantiate. * wasm.yaml: * wasm/function-tests/if-no-else-non-void.js: * wasm/js-api/web-assembly-instantiate.js: (assert.asyncTest.async.test): (assert.asyncTest): * wasm/libwabt.js: Added. (WabtModule): (set get if): * wasm/references/func_ref.js: * wasm/references/validation.js: (assert.throws): * wasm/spec-harness/index.js: * wasm/spec-tests/block.wast.js: * wasm/spec-tests/br.wast.js: * wasm/spec-tests/br_if.wast.js: * wasm/spec-tests/call.wast.js: * wasm/spec-tests/call_indirect.wast.js: * wasm/spec-tests/func.wast.js: * wasm/spec-tests/if.wast.js: * wasm/spec-tests/loop.wast.js: * wasm/spec-tests/type.wast.js: * wasm/stress/js-wasm-call-many-return-types-on-stack-no-args.js: Added. (buildWat): * wasm/stress/js-wasm-js-varying-arities.js: Added. (paramForwarder): * wasm/stress/wasm-js-call-many-return-types-on-stack-no-args.js: Added. (buildWat): * wasm/stress/wasm-js-multi-value-exception-in-iterator.js: Added. (buildWat.throwError): (buildWat.throwErrorInIterator): (buildWat.tooManyValues): (buildWat.tooFewValues): (buildWat): * wasm/stress/wasm-wasm-call-indirect-many-return-types-on-stack.js: Added. (buildWat): * wasm/stress/wasm-wasm-call-many-return-types-on-stack-no-args.js: Added. (buildWat): * wasm/wabt-wrapper.js: Added. (export.compile): * wasm/wast-tests/br-if-at-end-of-block.wasm: Added. * wasm/wast-tests/br-if-at-end-of-block.wast: Added. * wasm/wast-tests/harness.js: (async.runWasmFile): * wasm/wast-tests/single-param-loop-signature.wasm: Added. * wasm/wast-tests/single-param-loop-signature.wast: Added. Source/JavaScriptCore: The wasm multi-value proposal makes two major changes to the spec. The first is that functions may now return more than one value across calls. When calling to/from JS, if there is more than one return type we return/receive a JSArray/Iterable, respectively. In the Wasm calls JS case, if the iteratable object does not vend the exact number of objects expected by the signature an error is thrown. The second major change in the multi-value proposal allows blocks to have any signature type. This works in a backwards compatible way by exploiting the fact that the old value-type thunk signatures (where the block takes no arguments and returns just the value type i.e. [] -> [type]) were always encoded as a negative number. If a block has a function signature, it is encoded as a positive index into the type section. When a block has a function signature type then the values from the enclosing stack are popped off that stack and added to the new block's stack. In the case of a br/br_if to a Loop block the "argument" values should be on the brancher's stack. The biggest change in this patch is stripping down the WasmCallingConventions file into one simpler API that just tells you where the each argument should be located. It also now handles adding or subtracting sizeof(CallerFrameAndPC) depending on whether you are caller or callee. Additionally, when computing locations for the callee it returns a B3::ValueRep that has the offsetFromFP rather than offsetFromSP. Since the code has been cleaned up I tried to also reduce code duplication in the various stubs for wasm code. This patch also removes the Air specific calling convention code and moves that logic into the Air IR generator. Since blocks can now have arbitrary signatures the control entries now use a const signature* rather than just the return type. Additionally, what used to be the result phi is now the phis for all the results for non-loop blocks and the arguments for a loop block. Due to the control flow restrictions of wasm conveniently we don't have to worry about generating non-optimal SSA, thus we can just use phis directly rather than using a variable. Lastly, to help clean up some code in the IR generators new helper methods were added to create call Patchpoints. These helpers do most of the boiler-plate initialization. * JavaScriptCore.xcodeproj/project.pbxproj: * assembler/AbstractMacroAssembler.h: (JSC::AbstractMacroAssembler::ImplicitAddress::ImplicitAddress): * assembler/LinkBuffer.cpp: (JSC::shouldDumpDisassemblyFor): * assembler/LinkBuffer.h: * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::callOperation): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::callOperation): * b3/B3LowerToAir.cpp: * b3/B3PatchpointSpecial.cpp: (JSC::B3::PatchpointSpecial::forEachArg): (JSC::B3::PatchpointSpecial::isValid): (JSC::B3::PatchpointSpecial::admitsStack): (JSC::B3::PatchpointSpecial::generate): * b3/B3Procedure.h: (JSC::B3::Procedure::resultCount const): (JSC::B3::Procedure::typeAtOffset const): (JSC::B3::Procedure::returnCount const): Deleted. * b3/B3StackmapGenerationParams.cpp: (JSC::B3::StackmapGenerationParams::code const): * b3/B3StackmapGenerationParams.h: * b3/B3ValueRep.h: * b3/air/AirHelpers.h: Added. (JSC::B3::Air::moveForType): (JSC::B3::Air::relaxedMoveForType): * jit/AssemblyHelpers.h: (JSC::AssemblyHelpers::store64FromReg): (JSC::AssemblyHelpers::store32FromReg): (JSC::AssemblyHelpers::load64ToReg): (JSC::AssemblyHelpers::load32ToReg): * runtime/JSCConfig.h: * runtime/OptionsList.h: * tools/JSDollarVM.cpp: * tools/VMInspector.cpp: (JSC::VMInspector::dumpValue): * wasm/WasmAirIRGenerator.cpp: (JSC::Wasm::ConstrainedTmp::operator bool const): (JSC::Wasm::TypedTmp::dump const): (JSC::Wasm::AirIRGenerator::ControlData::ControlData): (JSC::Wasm::AirIRGenerator::ControlData::dump const): (JSC::Wasm::AirIRGenerator::ControlData::blockType const): (JSC::Wasm::AirIRGenerator::ControlData::signature const): (JSC::Wasm::AirIRGenerator::ControlData::targetBlockForBranch): (JSC::Wasm::AirIRGenerator::ControlData::convertIfToBlock): (JSC::Wasm::AirIRGenerator::addEndToUnreachable): (JSC::Wasm::AirIRGenerator::emitCallPatchpoint): (JSC::Wasm::AirIRGenerator::validateInst): (JSC::Wasm::AirIRGenerator::tmpsForSignature): (JSC::Wasm::AirIRGenerator::emitPatchpoint): (JSC::Wasm::AirIRGenerator::AirIRGenerator): (JSC::Wasm::AirIRGenerator::toB3ResultType): (JSC::Wasm::AirIRGenerator::addBottom): (JSC::Wasm::AirIRGenerator::emitLoopTierUpCheck): (JSC::Wasm::AirIRGenerator::addTopLevel): (JSC::Wasm::AirIRGenerator::addLoop): (JSC::Wasm::AirIRGenerator::addBlock): (JSC::Wasm::AirIRGenerator::addIf): (JSC::Wasm::AirIRGenerator::addElse): (JSC::Wasm::AirIRGenerator::addElseToUnreachable): (JSC::Wasm::AirIRGenerator::addReturn): (JSC::Wasm::AirIRGenerator::addBranch): (JSC::Wasm::AirIRGenerator::addSwitch): (JSC::Wasm::AirIRGenerator::endBlock): (JSC::Wasm::AirIRGenerator::addCall): (JSC::Wasm::AirIRGenerator::addCallIndirect): (JSC::Wasm::dumpExpressionStack): (JSC::Wasm::AirIRGenerator::dump): (JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncUF64>): (JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncUF32>): (JSC::Wasm::AirIRGenerator::ControlData::type const): Deleted. (JSC::Wasm::AirIRGenerator::ControlData::hasNonVoidSignature const): Deleted. (JSC::Wasm::AirIRGenerator::ControlData::resultForBranch const): Deleted. * wasm/WasmB3IRGenerator.cpp: (JSC::Wasm::B3IRGenerator::ControlData::ControlData): (JSC::Wasm::B3IRGenerator::ControlData::dump const): (JSC::Wasm::B3IRGenerator::ControlData::blockType const): (JSC::Wasm::B3IRGenerator::ControlData::hasNonVoidresult const): (JSC::Wasm::B3IRGenerator::ControlData::targetBlockForBranch): (JSC::Wasm::B3IRGenerator::ControlData::convertIfToBlock): (JSC::Wasm::B3IRGenerator::addEndToUnreachable): (JSC::Wasm::B3IRGenerator::B3IRGenerator): (JSC::Wasm::B3IRGenerator::framePointer): (JSC::Wasm::B3IRGenerator::toB3ResultType): (JSC::Wasm::B3IRGenerator::addArguments): (JSC::Wasm::B3IRGenerator::addGrowMemory): (JSC::Wasm::B3IRGenerator::addLoop): (JSC::Wasm::B3IRGenerator::addTopLevel): (JSC::Wasm::B3IRGenerator::addBlock): (JSC::Wasm::B3IRGenerator::addIf): (JSC::Wasm::B3IRGenerator::addElse): (JSC::Wasm::B3IRGenerator::addElseToUnreachable): (JSC::Wasm::B3IRGenerator::addReturn): (JSC::Wasm::B3IRGenerator::addBranch): (JSC::Wasm::B3IRGenerator::addSwitch): (JSC::Wasm::B3IRGenerator::endBlock): (JSC::Wasm::B3IRGenerator::createCallPatchpoint): (JSC::Wasm::B3IRGenerator::addCall): (JSC::Wasm::B3IRGenerator::addCallIndirect): (JSC::Wasm::B3IRGenerator::ControlData::type const): Deleted. (JSC::Wasm::B3IRGenerator::ControlData::hasNonVoidSignature const): Deleted. (JSC::Wasm::B3IRGenerator::ControlData::resultForBranch const): Deleted. (JSC::Wasm::B3IRGenerator::createStack): Deleted. * wasm/WasmBBQPlan.cpp: (JSC::Wasm::BBQPlan::didReceiveFunctionData): (JSC::Wasm::BBQPlan::parseAndValidateModule): (JSC::Wasm::BBQPlan::complete): * wasm/WasmBBQPlan.h: * wasm/WasmBinding.cpp: (JSC::Wasm::wasmToWasm): * wasm/WasmCallingConvention.cpp: (JSC::Wasm::jsCallingConvention): (JSC::Wasm::wasmCallingConvention): (JSC::Wasm::jscCallingConvention): Deleted. (JSC::Wasm::jscCallingConventionAir): Deleted. (JSC::Wasm::wasmCallingConventionAir): Deleted. * wasm/WasmCallingConvention.h: (JSC::Wasm::CallInformation::CallInformation): (JSC::Wasm::CallInformation::computeResultsOffsetList): (JSC::Wasm::WasmCallingConvention::WasmCallingConvention): (JSC::Wasm::WasmCallingConvention::marshallLocationImpl const): (JSC::Wasm::WasmCallingConvention::marshallLocation const): (JSC::Wasm::WasmCallingConvention::callInformationFor const): (JSC::Wasm::JSCallingConvention::JSCallingConvention): (JSC::Wasm::JSCallingConvention::marshallLocationImpl const): (JSC::Wasm::JSCallingConvention::marshallLocation const): (JSC::Wasm::JSCallingConvention::callInformationFor const): (JSC::Wasm::CallingConvention::CallingConvention): Deleted. (JSC::Wasm::CallingConvention::marshallArgumentImpl const): Deleted. (JSC::Wasm::CallingConvention::marshallArgument const): Deleted. (JSC::Wasm::CallingConvention::headerSizeInBytes): Deleted. (JSC::Wasm::CallingConvention::setupFrameInPrologue const): Deleted. (JSC::Wasm::CallingConvention::loadArguments const): Deleted. (JSC::Wasm::CallingConvention::setupCall const): Deleted. (JSC::Wasm::CallingConventionAir::CallingConventionAir): Deleted. (JSC::Wasm::CallingConventionAir::prologueScratch const): Deleted. (JSC::Wasm::CallingConventionAir::marshallArgumentImpl const): Deleted. (JSC::Wasm::CallingConventionAir::marshallArgument const): Deleted. (JSC::Wasm::CallingConventionAir::headerSizeInBytes): Deleted. (JSC::Wasm::CallingConventionAir::loadArguments const): Deleted. (JSC::Wasm::CallingConventionAir::setupCall const): Deleted. (JSC::Wasm::nextJSCOffset): Deleted. * wasm/WasmFormat.h: * wasm/WasmFunctionParser.h: (JSC::Wasm::splitStack): (JSC::Wasm::FunctionParser::signature const): (JSC::Wasm::FunctionParser<Context>::FunctionParser): (JSC::Wasm::FunctionParser<Context>::parseBody): (JSC::Wasm::FunctionParser<Context>::parseExpression): (JSC::Wasm::FunctionParser<Context>::parseUnreachableExpression): * wasm/WasmInstance.h: * wasm/WasmMemoryInformation.cpp: (JSC::Wasm::getPinnedRegisters): * wasm/WasmOMGForOSREntryPlan.cpp: (JSC::Wasm::OMGForOSREntryPlan::work): * wasm/WasmOMGPlan.cpp: (JSC::Wasm::OMGPlan::work): * wasm/WasmParser.h: (JSC::Wasm::FailureHelper::makeString): (JSC::Wasm::Parser<SuccessType>::Parser): (JSC::Wasm::Parser<SuccessType>::peekInt7): (JSC::Wasm::Parser<SuccessType>::parseBlockSignature): (JSC::Wasm::Parser<SuccessType>::parseValueType): (JSC::Wasm::Parser<SuccessType>::parseResultType): Deleted. * wasm/WasmSectionParser.cpp: (JSC::Wasm::SectionParser::parseType): (JSC::Wasm::SectionParser::parseStart): * wasm/WasmSectionParser.h: * wasm/WasmSignature.cpp: (JSC::Wasm::Signature::toString const): (JSC::Wasm::Signature::dump const): (JSC::Wasm::computeHash): (JSC::Wasm::Signature::hash const): (JSC::Wasm::Signature::tryCreate): (JSC::Wasm::SignatureInformation::SignatureInformation): (JSC::Wasm::ParameterTypes::hash): (JSC::Wasm::ParameterTypes::equal): (JSC::Wasm::ParameterTypes::translate): (JSC::Wasm::SignatureInformation::signatureFor): (JSC::Wasm::SignatureInformation::adopt): Deleted. * wasm/WasmSignature.h: (JSC::Wasm::Signature::Signature): (JSC::Wasm::Signature::allocatedSize): (JSC::Wasm::Signature::returnCount const): (JSC::Wasm::Signature::returnType const): (JSC::Wasm::Signature::returnsVoid const): (JSC::Wasm::Signature::argument const): (JSC::Wasm::Signature::operator== const): (JSC::Wasm::Signature::getReturnType): (JSC::Wasm::Signature::getArgument): (JSC::Wasm::SignatureHash::SignatureHash): (JSC::Wasm::SignatureHash::equal): (JSC::Wasm::SignatureInformation::thunkFor const): (JSC::Wasm::Signature::returnType): Deleted. (JSC::Wasm::Signature::argument): Deleted. * wasm/WasmStreamingParser.cpp: (JSC::Wasm::StreamingParser::parseCodeSectionSize): (JSC::Wasm::StreamingParser::parseFunctionPayload): (JSC::Wasm::StreamingParser::parseSectionPayload): * wasm/WasmStreamingParser.h: (JSC::Wasm::StreamingParserClient::didReceiveSectionData): (JSC::Wasm::StreamingParser::reportError): (JSC::Wasm::StreamingParserClient::didReceiveFunctionData): Deleted. * wasm/WasmThunks.cpp: (JSC::Wasm::throwExceptionFromWasmThunkGenerator): (JSC::Wasm::throwStackOverflowFromWasmThunkGenerator): (JSC::Wasm::triggerOMGEntryTierUpThunkGenerator): * wasm/WasmValidate.cpp: (JSC::Wasm::Validate::ControlData::ControlData): (JSC::Wasm::Validate::ControlData::dump const): (JSC::Wasm::Validate::ControlData::blockType const): (JSC::Wasm::Validate::ControlData::signature const): (JSC::Wasm::Validate::ControlData::branchTargetArity const): (JSC::Wasm::Validate::ControlData::branchTargetType const): (JSC::Wasm::Validate::fail const): (JSC::Wasm::Validate::addTableGet): (JSC::Wasm::Validate::addTableGrow): (JSC::Wasm::Validate::addTableFill): (JSC::Wasm::Validate::addRefIsNull): (JSC::Wasm::Validate::addTopLevel): (JSC::Wasm::splitStack): (JSC::Wasm::Validate::addBlock): (JSC::Wasm::Validate::addLoop): (JSC::Wasm::Validate::addIf): (JSC::Wasm::Validate::addElseToUnreachable): (JSC::Wasm::Validate::addReturn): (JSC::Wasm::Validate::checkBranchTarget): (JSC::Wasm::Validate::addSwitch): (JSC::Wasm::Validate::addGrowMemory): (JSC::Wasm::Validate::addEndToUnreachable): (JSC::Wasm::Validate::addCall): (JSC::Wasm::Validate::addCallIndirect): (JSC::Wasm::Validate::unify): (JSC::Wasm::Validate::ControlData::hasNonVoidSignature const): Deleted. (JSC::Wasm::Validate::ControlData::type const): Deleted. (JSC::Wasm::Validate::ControlData::branchTargetSignature const): Deleted. * wasm/generateWasmOpsHeader.py: * wasm/js/JSToWasm.cpp: (JSC::Wasm::boxWasmResult): (JSC::Wasm::allocateResultsArray): (JSC::Wasm::marshallJSResult): (JSC::Wasm::createJSToWasmWrapper): * wasm/js/JSToWasm.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): * wasm/js/WasmToJS.cpp: (JSC::Wasm::handleBadI64Use): (JSC::Wasm::wasmToJS): * wasm/js/WasmToJS.h: * wasm/js/WebAssemblyFunction.cpp: (JSC::callWebAssemblyFunction): (JSC::WebAssemblyFunction::useTagRegisters const): (JSC::WebAssemblyFunction::jsCallEntrypointSlow): * wasm/js/WebAssemblyModuleRecord.cpp: (JSC::WebAssemblyModuleRecord::link): Tools: * Scripts/run-jsc-stress-tests: Canonical link: https://commits.webkit.org/215930@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250559 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-10-01 16:38:26 +00:00
// EMSCRIPTEN_END_ASM
WebAssembly: update wabt.js https://bugs.webkit.org/show_bug.cgi?id=218876 Patch by Sergey Rubanov <chi187@gmail.com> on 2020-11-13 Reviewed by Yusuke Suzuki. * wasm/libwabt.js: (WabtModule): Deleted. * wasm/regress/llint-callee-saves-with-fast-memory.js: (async test): * wasm/regress/llint-callee-saves-without-fast-memory.js: (async test): * wasm/regress/regression-with-loop.js: (async test): * wasm/regress/stack-consistency.js: (async test): * wasm/stress/js-wasm-call-many-return-types-on-stack-no-args.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/stress/js-wasm-js-varying-arities.js: (async paramForwarder): (async test): (paramForwarder): Deleted. * wasm/stress/local-ref.js: (async test): * wasm/stress/loop-more-args-than-results.js: (async test): * wasm/stress/set-local-enclosed-stack.js: (async test): (assert.eq.instance.exports.foo): Deleted. (assert.eq): Deleted. * wasm/stress/top-most-enclosing-stack.js: (async test): * wasm/stress/trunc-int-min-minus-one.js: (async test): * wasm/stress/wasm-js-call-many-return-types-on-stack-no-args.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/stress/wasm-js-multi-value-exception-in-iterator.js: (async buildWat): (async test): (buildWat.throwError): Deleted. (buildWat.throwErrorInIterator): Deleted. (buildWat.tooManyValues): Deleted. (buildWat.tooFewValues): Deleted. (buildWat): Deleted. * wasm/stress/wasm-wasm-call-indirect-many-return-types-on-stack.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/stress/wasm-wasm-call-many-return-types-on-stack-no-args.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/wabt-wrapper.js: (export.async compile): (export.compile): Deleted. Canonical link: https://commits.webkit.org/231540@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269766 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-11-13 08:36:26 +00:00
)(asmLibraryArg,wasmMemory,wasmTable)},instantiate:function(binary,info){return{then:function(ok){var module=new WebAssembly.Module(binary);ok({"instance":new WebAssembly.Instance(module)})}}},RuntimeError:Error};wasmBinary=[];if(typeof WebAssembly!=="object"){abort("no native wasm support detected")}var wasmMemory;var wasmTable=new WebAssembly.Table({"initial":924,"maximum":924+10,"element":"anyfunc"});var ABORT=false;var EXITSTATUS=0;function assert(condition,text){if(!condition){abort("Assertion failed: "+text)}}var UTF8Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(heap,idx,maxBytesToRead){var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heap[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heap.subarray&&UTF8Decoder){return UTF8Decoder.decode(heap.subarray(idx,endPtr))}else{var str="";while(idx<endPtr){var u0=heap[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heap[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heap[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heap[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}}return str}function UTF8ToString(ptr,maxBytesToRead){return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}function stringToUTF8Array(str,heap,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}function lengthBytesUTF8(str){var len=0;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127)++len;else if(u<=2047)len+=2;else if(u<=65535)len+=3;else len+=4}return len}function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i<str.length;++i){HEAP8[buffer++>>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}var WASM_PAGE_SIZE=65536;function alignUp(x,multiple){if(x%multiple>0){x+=multiple-x%multiple}return x}var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBufferAndViews(buf){buffer=buf;Module["HEAP8"]=HEAP8=new Int8Array(buf);Module["HEAP16"]=HEAP16=new Int16Array(buf);Module["HEAP32"]=HEAP32=new Int32Array(buf);Module["HEAPU8"]=HEAPU8=new Uint8Array(buf);Module["HEAPU16"]=HEAPU16=new Uint16Array(buf);Module["HEAPU32"]=HEAPU32=new Uint32Array(buf);Module["HEAPF32"]=HEAPF32=new Float32Array(buf);Module["HEAPF64"]=HEAPF64=new Float64Array(buf)}var DYNAMIC_BASE=5614032,DYNAMICTOP_PTR=370992;var INITIAL_INITIAL_MEMORY=Module["INITIAL_MEMORY"]||16777216;if(Module["wasmMemory"]){wasmMemory=Module["wasmMemory"]}else{wasmMemory=new WebAssembly.Memory({"initial":INITIAL_INITIAL_MEMORY/WASM_PAGE_SIZE,"maximum":2147483648/WASM_PAGE_SIZE})}if(wasmMemory){buffer=wasmMemory.buffer}INITIAL_INITIAL_MEMORY=buffer.byteLength;updateGlobalBufferAndViews(buffer);HEAP32[DYNAMICTOP_PTR>>2]=DYNAMIC_BASE;function callRuntimeCallbacks(callbacks){while(callbacks.length>0){var callback=callbacks.shift();if(typeof callback=="function"){callback(Module);continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){Module["dynCall_v"](func)}else{Module["dynCall_vi"](func,callback.arg)}}else{func(callback.arg===undefined?null:callback.arg)}}}var __ATPRERUN__=[];var __ATINIT__=[];var __ATMAIN__=[];var __ATPOSTRUN__=[];var
return WabtModule.ready
Add support for the Wasm multi-value proposal https://bugs.webkit.org/show_bug.cgi?id=202250 Reviewed by Saam Barati. JSTests: This patch adds a new way to run stress tests via the .wat text format. By attaching an asm.js compiled version of the wabt tool we can easily create wat files programatically and convert them into a wasm blob to compile. To make this easy there is a wabt-wrapper.js module file that exports two useful functions that correspond to WebAssembly.compile and WebAssembly.instantiate. * wasm.yaml: * wasm/function-tests/if-no-else-non-void.js: * wasm/js-api/web-assembly-instantiate.js: (assert.asyncTest.async.test): (assert.asyncTest): * wasm/libwabt.js: Added. (WabtModule): (set get if): * wasm/references/func_ref.js: * wasm/references/validation.js: (assert.throws): * wasm/spec-harness/index.js: * wasm/spec-tests/block.wast.js: * wasm/spec-tests/br.wast.js: * wasm/spec-tests/br_if.wast.js: * wasm/spec-tests/call.wast.js: * wasm/spec-tests/call_indirect.wast.js: * wasm/spec-tests/func.wast.js: * wasm/spec-tests/if.wast.js: * wasm/spec-tests/loop.wast.js: * wasm/spec-tests/type.wast.js: * wasm/stress/js-wasm-call-many-return-types-on-stack-no-args.js: Added. (buildWat): * wasm/stress/js-wasm-js-varying-arities.js: Added. (paramForwarder): * wasm/stress/wasm-js-call-many-return-types-on-stack-no-args.js: Added. (buildWat): * wasm/stress/wasm-js-multi-value-exception-in-iterator.js: Added. (buildWat.throwError): (buildWat.throwErrorInIterator): (buildWat.tooManyValues): (buildWat.tooFewValues): (buildWat): * wasm/stress/wasm-wasm-call-indirect-many-return-types-on-stack.js: Added. (buildWat): * wasm/stress/wasm-wasm-call-many-return-types-on-stack-no-args.js: Added. (buildWat): * wasm/wabt-wrapper.js: Added. (export.compile): * wasm/wast-tests/br-if-at-end-of-block.wasm: Added. * wasm/wast-tests/br-if-at-end-of-block.wast: Added. * wasm/wast-tests/harness.js: (async.runWasmFile): * wasm/wast-tests/single-param-loop-signature.wasm: Added. * wasm/wast-tests/single-param-loop-signature.wast: Added. Source/JavaScriptCore: The wasm multi-value proposal makes two major changes to the spec. The first is that functions may now return more than one value across calls. When calling to/from JS, if there is more than one return type we return/receive a JSArray/Iterable, respectively. In the Wasm calls JS case, if the iteratable object does not vend the exact number of objects expected by the signature an error is thrown. The second major change in the multi-value proposal allows blocks to have any signature type. This works in a backwards compatible way by exploiting the fact that the old value-type thunk signatures (where the block takes no arguments and returns just the value type i.e. [] -> [type]) were always encoded as a negative number. If a block has a function signature, it is encoded as a positive index into the type section. When a block has a function signature type then the values from the enclosing stack are popped off that stack and added to the new block's stack. In the case of a br/br_if to a Loop block the "argument" values should be on the brancher's stack. The biggest change in this patch is stripping down the WasmCallingConventions file into one simpler API that just tells you where the each argument should be located. It also now handles adding or subtracting sizeof(CallerFrameAndPC) depending on whether you are caller or callee. Additionally, when computing locations for the callee it returns a B3::ValueRep that has the offsetFromFP rather than offsetFromSP. Since the code has been cleaned up I tried to also reduce code duplication in the various stubs for wasm code. This patch also removes the Air specific calling convention code and moves that logic into the Air IR generator. Since blocks can now have arbitrary signatures the control entries now use a const signature* rather than just the return type. Additionally, what used to be the result phi is now the phis for all the results for non-loop blocks and the arguments for a loop block. Due to the control flow restrictions of wasm conveniently we don't have to worry about generating non-optimal SSA, thus we can just use phis directly rather than using a variable. Lastly, to help clean up some code in the IR generators new helper methods were added to create call Patchpoints. These helpers do most of the boiler-plate initialization. * JavaScriptCore.xcodeproj/project.pbxproj: * assembler/AbstractMacroAssembler.h: (JSC::AbstractMacroAssembler::ImplicitAddress::ImplicitAddress): * assembler/LinkBuffer.cpp: (JSC::shouldDumpDisassemblyFor): * assembler/LinkBuffer.h: * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::callOperation): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::callOperation): * b3/B3LowerToAir.cpp: * b3/B3PatchpointSpecial.cpp: (JSC::B3::PatchpointSpecial::forEachArg): (JSC::B3::PatchpointSpecial::isValid): (JSC::B3::PatchpointSpecial::admitsStack): (JSC::B3::PatchpointSpecial::generate): * b3/B3Procedure.h: (JSC::B3::Procedure::resultCount const): (JSC::B3::Procedure::typeAtOffset const): (JSC::B3::Procedure::returnCount const): Deleted. * b3/B3StackmapGenerationParams.cpp: (JSC::B3::StackmapGenerationParams::code const): * b3/B3StackmapGenerationParams.h: * b3/B3ValueRep.h: * b3/air/AirHelpers.h: Added. (JSC::B3::Air::moveForType): (JSC::B3::Air::relaxedMoveForType): * jit/AssemblyHelpers.h: (JSC::AssemblyHelpers::store64FromReg): (JSC::AssemblyHelpers::store32FromReg): (JSC::AssemblyHelpers::load64ToReg): (JSC::AssemblyHelpers::load32ToReg): * runtime/JSCConfig.h: * runtime/OptionsList.h: * tools/JSDollarVM.cpp: * tools/VMInspector.cpp: (JSC::VMInspector::dumpValue): * wasm/WasmAirIRGenerator.cpp: (JSC::Wasm::ConstrainedTmp::operator bool const): (JSC::Wasm::TypedTmp::dump const): (JSC::Wasm::AirIRGenerator::ControlData::ControlData): (JSC::Wasm::AirIRGenerator::ControlData::dump const): (JSC::Wasm::AirIRGenerator::ControlData::blockType const): (JSC::Wasm::AirIRGenerator::ControlData::signature const): (JSC::Wasm::AirIRGenerator::ControlData::targetBlockForBranch): (JSC::Wasm::AirIRGenerator::ControlData::convertIfToBlock): (JSC::Wasm::AirIRGenerator::addEndToUnreachable): (JSC::Wasm::AirIRGenerator::emitCallPatchpoint): (JSC::Wasm::AirIRGenerator::validateInst): (JSC::Wasm::AirIRGenerator::tmpsForSignature): (JSC::Wasm::AirIRGenerator::emitPatchpoint): (JSC::Wasm::AirIRGenerator::AirIRGenerator): (JSC::Wasm::AirIRGenerator::toB3ResultType): (JSC::Wasm::AirIRGenerator::addBottom): (JSC::Wasm::AirIRGenerator::emitLoopTierUpCheck): (JSC::Wasm::AirIRGenerator::addTopLevel): (JSC::Wasm::AirIRGenerator::addLoop): (JSC::Wasm::AirIRGenerator::addBlock): (JSC::Wasm::AirIRGenerator::addIf): (JSC::Wasm::AirIRGenerator::addElse): (JSC::Wasm::AirIRGenerator::addElseToUnreachable): (JSC::Wasm::AirIRGenerator::addReturn): (JSC::Wasm::AirIRGenerator::addBranch): (JSC::Wasm::AirIRGenerator::addSwitch): (JSC::Wasm::AirIRGenerator::endBlock): (JSC::Wasm::AirIRGenerator::addCall): (JSC::Wasm::AirIRGenerator::addCallIndirect): (JSC::Wasm::dumpExpressionStack): (JSC::Wasm::AirIRGenerator::dump): (JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncUF64>): (JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncUF32>): (JSC::Wasm::AirIRGenerator::ControlData::type const): Deleted. (JSC::Wasm::AirIRGenerator::ControlData::hasNonVoidSignature const): Deleted. (JSC::Wasm::AirIRGenerator::ControlData::resultForBranch const): Deleted. * wasm/WasmB3IRGenerator.cpp: (JSC::Wasm::B3IRGenerator::ControlData::ControlData): (JSC::Wasm::B3IRGenerator::ControlData::dump const): (JSC::Wasm::B3IRGenerator::ControlData::blockType const): (JSC::Wasm::B3IRGenerator::ControlData::hasNonVoidresult const): (JSC::Wasm::B3IRGenerator::ControlData::targetBlockForBranch): (JSC::Wasm::B3IRGenerator::ControlData::convertIfToBlock): (JSC::Wasm::B3IRGenerator::addEndToUnreachable): (JSC::Wasm::B3IRGenerator::B3IRGenerator): (JSC::Wasm::B3IRGenerator::framePointer): (JSC::Wasm::B3IRGenerator::toB3ResultType): (JSC::Wasm::B3IRGenerator::addArguments): (JSC::Wasm::B3IRGenerator::addGrowMemory): (JSC::Wasm::B3IRGenerator::addLoop): (JSC::Wasm::B3IRGenerator::addTopLevel): (JSC::Wasm::B3IRGenerator::addBlock): (JSC::Wasm::B3IRGenerator::addIf): (JSC::Wasm::B3IRGenerator::addElse): (JSC::Wasm::B3IRGenerator::addElseToUnreachable): (JSC::Wasm::B3IRGenerator::addReturn): (JSC::Wasm::B3IRGenerator::addBranch): (JSC::Wasm::B3IRGenerator::addSwitch): (JSC::Wasm::B3IRGenerator::endBlock): (JSC::Wasm::B3IRGenerator::createCallPatchpoint): (JSC::Wasm::B3IRGenerator::addCall): (JSC::Wasm::B3IRGenerator::addCallIndirect): (JSC::Wasm::B3IRGenerator::ControlData::type const): Deleted. (JSC::Wasm::B3IRGenerator::ControlData::hasNonVoidSignature const): Deleted. (JSC::Wasm::B3IRGenerator::ControlData::resultForBranch const): Deleted. (JSC::Wasm::B3IRGenerator::createStack): Deleted. * wasm/WasmBBQPlan.cpp: (JSC::Wasm::BBQPlan::didReceiveFunctionData): (JSC::Wasm::BBQPlan::parseAndValidateModule): (JSC::Wasm::BBQPlan::complete): * wasm/WasmBBQPlan.h: * wasm/WasmBinding.cpp: (JSC::Wasm::wasmToWasm): * wasm/WasmCallingConvention.cpp: (JSC::Wasm::jsCallingConvention): (JSC::Wasm::wasmCallingConvention): (JSC::Wasm::jscCallingConvention): Deleted. (JSC::Wasm::jscCallingConventionAir): Deleted. (JSC::Wasm::wasmCallingConventionAir): Deleted. * wasm/WasmCallingConvention.h: (JSC::Wasm::CallInformation::CallInformation): (JSC::Wasm::CallInformation::computeResultsOffsetList): (JSC::Wasm::WasmCallingConvention::WasmCallingConvention): (JSC::Wasm::WasmCallingConvention::marshallLocationImpl const): (JSC::Wasm::WasmCallingConvention::marshallLocation const): (JSC::Wasm::WasmCallingConvention::callInformationFor const): (JSC::Wasm::JSCallingConvention::JSCallingConvention): (JSC::Wasm::JSCallingConvention::marshallLocationImpl const): (JSC::Wasm::JSCallingConvention::marshallLocation const): (JSC::Wasm::JSCallingConvention::callInformationFor const): (JSC::Wasm::CallingConvention::CallingConvention): Deleted. (JSC::Wasm::CallingConvention::marshallArgumentImpl const): Deleted. (JSC::Wasm::CallingConvention::marshallArgument const): Deleted. (JSC::Wasm::CallingConvention::headerSizeInBytes): Deleted. (JSC::Wasm::CallingConvention::setupFrameInPrologue const): Deleted. (JSC::Wasm::CallingConvention::loadArguments const): Deleted. (JSC::Wasm::CallingConvention::setupCall const): Deleted. (JSC::Wasm::CallingConventionAir::CallingConventionAir): Deleted. (JSC::Wasm::CallingConventionAir::prologueScratch const): Deleted. (JSC::Wasm::CallingConventionAir::marshallArgumentImpl const): Deleted. (JSC::Wasm::CallingConventionAir::marshallArgument const): Deleted. (JSC::Wasm::CallingConventionAir::headerSizeInBytes): Deleted. (JSC::Wasm::CallingConventionAir::loadArguments const): Deleted. (JSC::Wasm::CallingConventionAir::setupCall const): Deleted. (JSC::Wasm::nextJSCOffset): Deleted. * wasm/WasmFormat.h: * wasm/WasmFunctionParser.h: (JSC::Wasm::splitStack): (JSC::Wasm::FunctionParser::signature const): (JSC::Wasm::FunctionParser<Context>::FunctionParser): (JSC::Wasm::FunctionParser<Context>::parseBody): (JSC::Wasm::FunctionParser<Context>::parseExpression): (JSC::Wasm::FunctionParser<Context>::parseUnreachableExpression): * wasm/WasmInstance.h: * wasm/WasmMemoryInformation.cpp: (JSC::Wasm::getPinnedRegisters): * wasm/WasmOMGForOSREntryPlan.cpp: (JSC::Wasm::OMGForOSREntryPlan::work): * wasm/WasmOMGPlan.cpp: (JSC::Wasm::OMGPlan::work): * wasm/WasmParser.h: (JSC::Wasm::FailureHelper::makeString): (JSC::Wasm::Parser<SuccessType>::Parser): (JSC::Wasm::Parser<SuccessType>::peekInt7): (JSC::Wasm::Parser<SuccessType>::parseBlockSignature): (JSC::Wasm::Parser<SuccessType>::parseValueType): (JSC::Wasm::Parser<SuccessType>::parseResultType): Deleted. * wasm/WasmSectionParser.cpp: (JSC::Wasm::SectionParser::parseType): (JSC::Wasm::SectionParser::parseStart): * wasm/WasmSectionParser.h: * wasm/WasmSignature.cpp: (JSC::Wasm::Signature::toString const): (JSC::Wasm::Signature::dump const): (JSC::Wasm::computeHash): (JSC::Wasm::Signature::hash const): (JSC::Wasm::Signature::tryCreate): (JSC::Wasm::SignatureInformation::SignatureInformation): (JSC::Wasm::ParameterTypes::hash): (JSC::Wasm::ParameterTypes::equal): (JSC::Wasm::ParameterTypes::translate): (JSC::Wasm::SignatureInformation::signatureFor): (JSC::Wasm::SignatureInformation::adopt): Deleted. * wasm/WasmSignature.h: (JSC::Wasm::Signature::Signature): (JSC::Wasm::Signature::allocatedSize): (JSC::Wasm::Signature::returnCount const): (JSC::Wasm::Signature::returnType const): (JSC::Wasm::Signature::returnsVoid const): (JSC::Wasm::Signature::argument const): (JSC::Wasm::Signature::operator== const): (JSC::Wasm::Signature::getReturnType): (JSC::Wasm::Signature::getArgument): (JSC::Wasm::SignatureHash::SignatureHash): (JSC::Wasm::SignatureHash::equal): (JSC::Wasm::SignatureInformation::thunkFor const): (JSC::Wasm::Signature::returnType): Deleted. (JSC::Wasm::Signature::argument): Deleted. * wasm/WasmStreamingParser.cpp: (JSC::Wasm::StreamingParser::parseCodeSectionSize): (JSC::Wasm::StreamingParser::parseFunctionPayload): (JSC::Wasm::StreamingParser::parseSectionPayload): * wasm/WasmStreamingParser.h: (JSC::Wasm::StreamingParserClient::didReceiveSectionData): (JSC::Wasm::StreamingParser::reportError): (JSC::Wasm::StreamingParserClient::didReceiveFunctionData): Deleted. * wasm/WasmThunks.cpp: (JSC::Wasm::throwExceptionFromWasmThunkGenerator): (JSC::Wasm::throwStackOverflowFromWasmThunkGenerator): (JSC::Wasm::triggerOMGEntryTierUpThunkGenerator): * wasm/WasmValidate.cpp: (JSC::Wasm::Validate::ControlData::ControlData): (JSC::Wasm::Validate::ControlData::dump const): (JSC::Wasm::Validate::ControlData::blockType const): (JSC::Wasm::Validate::ControlData::signature const): (JSC::Wasm::Validate::ControlData::branchTargetArity const): (JSC::Wasm::Validate::ControlData::branchTargetType const): (JSC::Wasm::Validate::fail const): (JSC::Wasm::Validate::addTableGet): (JSC::Wasm::Validate::addTableGrow): (JSC::Wasm::Validate::addTableFill): (JSC::Wasm::Validate::addRefIsNull): (JSC::Wasm::Validate::addTopLevel): (JSC::Wasm::splitStack): (JSC::Wasm::Validate::addBlock): (JSC::Wasm::Validate::addLoop): (JSC::Wasm::Validate::addIf): (JSC::Wasm::Validate::addElseToUnreachable): (JSC::Wasm::Validate::addReturn): (JSC::Wasm::Validate::checkBranchTarget): (JSC::Wasm::Validate::addSwitch): (JSC::Wasm::Validate::addGrowMemory): (JSC::Wasm::Validate::addEndToUnreachable): (JSC::Wasm::Validate::addCall): (JSC::Wasm::Validate::addCallIndirect): (JSC::Wasm::Validate::unify): (JSC::Wasm::Validate::ControlData::hasNonVoidSignature const): Deleted. (JSC::Wasm::Validate::ControlData::type const): Deleted. (JSC::Wasm::Validate::ControlData::branchTargetSignature const): Deleted. * wasm/generateWasmOpsHeader.py: * wasm/js/JSToWasm.cpp: (JSC::Wasm::boxWasmResult): (JSC::Wasm::allocateResultsArray): (JSC::Wasm::marshallJSResult): (JSC::Wasm::createJSToWasmWrapper): * wasm/js/JSToWasm.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): * wasm/js/WasmToJS.cpp: (JSC::Wasm::handleBadI64Use): (JSC::Wasm::wasmToJS): * wasm/js/WasmToJS.h: * wasm/js/WebAssemblyFunction.cpp: (JSC::callWebAssemblyFunction): (JSC::WebAssemblyFunction::useTagRegisters const): (JSC::WebAssemblyFunction::jsCallEntrypointSlow): * wasm/js/WebAssemblyModuleRecord.cpp: (JSC::WebAssemblyModuleRecord::link): Tools: * Scripts/run-jsc-stress-tests: Canonical link: https://commits.webkit.org/215930@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250559 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-10-01 16:38:26 +00:00
}
);
})();
if (typeof exports === 'object' && typeof module === 'object')
module.exports = WabtModule;
else if (typeof define === 'function' && define['amd'])
define([], function() { return WabtModule; });
else if (typeof exports === 'object')
exports["WabtModule"] = WabtModule;
WebAssembly: update wabt.js https://bugs.webkit.org/show_bug.cgi?id=218876 Patch by Sergey Rubanov <chi187@gmail.com> on 2020-11-13 Reviewed by Yusuke Suzuki. * wasm/libwabt.js: (WabtModule): Deleted. * wasm/regress/llint-callee-saves-with-fast-memory.js: (async test): * wasm/regress/llint-callee-saves-without-fast-memory.js: (async test): * wasm/regress/regression-with-loop.js: (async test): * wasm/regress/stack-consistency.js: (async test): * wasm/stress/js-wasm-call-many-return-types-on-stack-no-args.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/stress/js-wasm-js-varying-arities.js: (async paramForwarder): (async test): (paramForwarder): Deleted. * wasm/stress/local-ref.js: (async test): * wasm/stress/loop-more-args-than-results.js: (async test): * wasm/stress/set-local-enclosed-stack.js: (async test): (assert.eq.instance.exports.foo): Deleted. (assert.eq): Deleted. * wasm/stress/top-most-enclosing-stack.js: (async test): * wasm/stress/trunc-int-min-minus-one.js: (async test): * wasm/stress/wasm-js-call-many-return-types-on-stack-no-args.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/stress/wasm-js-multi-value-exception-in-iterator.js: (async buildWat): (async test): (buildWat.throwError): Deleted. (buildWat.throwErrorInIterator): Deleted. (buildWat.tooManyValues): Deleted. (buildWat.tooFewValues): Deleted. (buildWat): Deleted. * wasm/stress/wasm-wasm-call-indirect-many-return-types-on-stack.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/stress/wasm-wasm-call-many-return-types-on-stack-no-args.js: (async buildWat): (async test): (buildWat): Deleted. * wasm/wabt-wrapper.js: (export.async compile): (export.compile): Deleted. Canonical link: https://commits.webkit.org/231540@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269766 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-11-13 08:36:26 +00:00