Ignore:
Timestamp:
Oct 31, 2019, 3:32:52 PM (6 years ago)
Author:
Tadeu Zagallo
Message:

[WebAssembly] Create a Wasm interpreter
https://bugs.webkit.org/show_bug.cgi?id=194257
<rdar://problem/44186794>

Reviewed by Saam Barati.

Source/JavaScriptCore:

Add an interpreter tier to WebAssembly which reuses the LLInt infrastructure. The interpreter
currently tiers up straight to OMG and can OSR enter at the prologue and from loops. The initial
implementation of the interpreter is very naive, but despite the lack of optimizations it still
shows a 2x improvement on the WebAssembly subtests in JetStream2 and 2x improvement on the
PSPDFKit benchmark. It reduces "compilation" times by ~3x and it's neutral on throughput.

The interpreter follows the same calling conventions as the BBQ/OMG, this means that:

  • We have to allocate locals for all argument registers and write all arguments registers to the stack in the prologue.
  • Calls have to allocate space for at least as many arguments as the number of argument registers. Before each call, all argument registers must be loaded from the stack, and after we return from the call, all registers must be stored back to the stack, in case they contain return values. We carefully layout the stack so that the arguments that would already have to be passed in the stack end up in the right place. The stack layout for calls is:

[ gprs ][ fprs ][ optional stack arguments ][ callee frame ]

sp

  • The return opcode has to load all registers from the stack, since they might need to contain results of the function.
  • The calling convention requires that the callee should store itself in the callee slot of the call frame, which is impossible in the interpreter, since the code we execute is the same for all callees. In order to work around that, we generate an entry thunk to the wasm interpreter for each function. All this thunk does is store the callee in the call frame and tail call the interpreter.
  • CMakeLists.txt:
  • DerivedSources-input.xcfilelist:
  • DerivedSources-output.xcfilelist:
  • DerivedSources.make:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Sources.txt:
  • bytecode/BytecodeDumper.cpp:

(JSC::BytecodeDumper<Block>::constantName const):
(JSC::BytecodeDumper<Block>::dumpValue):
(JSC::BytecodeDumper<Block>::dumpBytecode):
(JSC::CodeBlockBytecodeDumper<Block>::vm const):
(JSC::CodeBlockBytecodeDumper<Block>::identifier const):
(JSC::CodeBlockBytecodeDumper<Block>::dumpIdentifiers):
(JSC::CodeBlockBytecodeDumper<Block>::dumpConstants):
(JSC::CodeBlockBytecodeDumper<Block>::dumpExceptionHandlers):
(JSC::CodeBlockBytecodeDumper<Block>::dumpSwitchJumpTables):
(JSC::CodeBlockBytecodeDumper<Block>::dumpStringSwitchJumpTables):
(JSC::CodeBlockBytecodeDumper<Block>::dumpBlock):

  • bytecode/BytecodeDumper.h:

(JSC::BytecodeDumper::dumpValue):
(JSC::BytecodeDumper::BytecodeDumper):

  • bytecode/BytecodeGeneratorification.cpp:

(JSC::performGeneratorification):

  • bytecode/BytecodeList.rb:
  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::dumpBytecode):

  • bytecode/Fits.h:
  • bytecode/Instruction.h:

(JSC::BaseInstruction::BaseInstruction):
(JSC::BaseInstruction::Impl::opcodeID const):
(JSC::BaseInstruction::opcodeID const):
(JSC::BaseInstruction::name const):
(JSC::BaseInstruction::isWide16 const):
(JSC::BaseInstruction::isWide32 const):
(JSC::BaseInstruction::hasMetadata const):
(JSC::BaseInstruction::sizeShiftAmount const):
(JSC::BaseInstruction::size const):
(JSC::BaseInstruction::is const):
(JSC::BaseInstruction::as const):
(JSC::BaseInstruction::cast):
(JSC::BaseInstruction::cast const):
(JSC::BaseInstruction::wide16 const):
(JSC::BaseInstruction::wide32 const):

  • bytecode/InstructionStream.h:

(JSC::InstructionStream::iterator::operator+=):
(JSC::InstructionStream::iterator::operator++):
(JSC::InstructionStreamWriter::iterator::operator+=):
(JSC::InstructionStreamWriter::iterator::operator++):

  • bytecode/Opcode.cpp:
  • bytecode/Opcode.h:
  • bytecode/PreciseJumpTargetsInlines.h:
  • bytecode/UnlinkedCodeBlock.h:
  • bytecode/VirtualRegister.cpp:

(JSC::VirtualRegister::VirtualRegister):

  • bytecode/VirtualRegister.h:
  • bytecompiler/BytecodeGenerator.cpp:

(JSC::GenericLabel<JSGeneratorTraits>::setLocation):
(JSC::BytecodeGenerator::BytecodeGenerator):

  • bytecompiler/BytecodeGenerator.h:
  • bytecompiler/BytecodeGeneratorBase.h: Added.
  • bytecompiler/BytecodeGeneratorBaseInlines.h: Added.

(JSC::shrinkToFit):
(JSC::BytecodeGeneratorBase<Traits>::BytecodeGeneratorBase):
(JSC::BytecodeGeneratorBase<Traits>::newLabel):
(JSC::BytecodeGeneratorBase<Traits>::newEmittedLabel):
(JSC::BytecodeGeneratorBase<Traits>::reclaimFreeRegisters):
(JSC::BytecodeGeneratorBase<Traits>::emitLabel):
(JSC::BytecodeGeneratorBase<Traits>::recordOpcode):
(JSC::BytecodeGeneratorBase<Traits>::alignWideOpcode16):
(JSC::BytecodeGeneratorBase<Traits>::alignWideOpcode32):
(JSC::BytecodeGeneratorBase<Traits>::write):
(JSC::BytecodeGeneratorBase<Traits>::newRegister):
(JSC::BytecodeGeneratorBase<Traits>::newTemporary):
(JSC::BytecodeGeneratorBase<Traits>::addVar):
(JSC::BytecodeGeneratorBase<Traits>::allocateCalleeSaveSpace):

  • bytecompiler/Label.h:

(JSC::GenericBoundLabel::GenericBoundLabel):
(JSC::GenericBoundLabel::target):
(JSC::GenericBoundLabel::saveTarget):
(JSC::GenericBoundLabel::commitTarget):

  • dfg/DFGByteCodeParser.cpp:
  • dfg/DFGCapabilities.cpp:

(JSC::DFG::capabilityLevel):

  • dfg/DFGOperations.cpp:
  • generator/Argument.rb:
  • generator/DSL.rb:
  • generator/GeneratedFile.rb:
  • generator/Opcode.rb:
  • generator/Options.rb:
  • generator/Section.rb:
  • generator/Wasm.rb: Added.
  • interpreter/Register.h:
  • interpreter/RegisterInlines.h:

(JSC::Register::operator=):

  • jit/JITArithmetic.cpp:
  • jit/JITOpcodes.cpp:
  • llint/LLIntData.cpp:

(JSC::LLInt::initialize):

  • llint/LLIntData.h:

(JSC::LLInt::wasmExceptionInstructions):

  • llint/LLIntOfflineAsmConfig.h:
  • llint/LLIntOffsetsExtractor.cpp:
  • llint/LLIntSlowPaths.cpp:
  • llint/LLIntThunks.cpp:

(JSC::LLInt::generateThunkWithJumpTo):
(JSC::LLInt::wasmFunctionEntryThunk):

  • llint/LLIntThunks.h:
  • llint/LowLevelInterpreter.asm:
  • llint/LowLevelInterpreter32_64.asm:
  • llint/LowLevelInterpreter64.asm:
  • llint/WebAssembly.asm: Added.
  • offlineasm/arm64.rb:
  • offlineasm/instructions.rb:
  • offlineasm/parser.rb:
  • offlineasm/registers.rb:
  • offlineasm/transform.rb:
  • offlineasm/x86.rb:
  • parser/Nodes.h:
  • runtime/Error.cpp:

(JSC::FindFirstCallerFrameWithCodeblockFunctor::operator() const):

  • runtime/ErrorInstance.cpp:

(JSC::ErrorInstance::finishCreation):

  • runtime/Options.cpp:

(JSC::overrideDefaults):

  • runtime/OptionsList.h:
  • runtime/SamplingProfiler.cpp:

(JSC::FrameWalker::recordJITFrame):
(JSC::FrameWalker::resetAtMachineFrame):

  • wasm/WasmAirIRGenerator.cpp:

(JSC::Wasm::AirIRGenerator::isControlTypeIf):
(JSC::Wasm::AirIRGenerator::emitLoopTierUpCheck):

  • wasm/WasmB3IRGenerator.cpp:

(JSC::Wasm::B3IRGenerator::isControlTypeIf):

  • wasm/WasmBBQPlan.cpp:

(JSC::Wasm::BBQPlan::prepareImpl):
(JSC::Wasm::BBQPlan::work):
(JSC::Wasm::BBQPlan::compileFunction):
(JSC::Wasm::BBQPlan::didCompleteCompilation):
(JSC::Wasm::BBQPlan::initializeCallees):

  • wasm/WasmBBQPlan.h:
  • wasm/WasmBBQPlanInlines.h: Removed.
  • wasm/WasmCallee.cpp:

(JSC::Wasm::Callee::Callee):
(JSC::Wasm::Callee::dump const):
(JSC::Wasm::JITCallee::JITCallee):
(JSC::Wasm::LLIntCallee::setEntrypoint):
(JSC::Wasm::LLIntCallee::entrypoint const):
(JSC::Wasm::LLIntCallee::calleeSaveRegisters):
(JSC::Wasm:: const):

  • wasm/WasmCallee.h:

(JSC::Wasm::Callee::setOSREntryCallee):
(JSC::Wasm::JITCallee::wasmToWasmCallsites):
(JSC::Wasm::JITCallee:: const):

  • wasm/WasmCallingConvention.h:
  • wasm/WasmCodeBlock.cpp:

(JSC::Wasm::CodeBlock::CodeBlock):

  • wasm/WasmCodeBlock.h:

(JSC::Wasm::CodeBlock::wasmEntrypointCalleeFromFunctionIndexSpace):
(JSC::Wasm::CodeBlock::wasmBBQCalleeFromFunctionIndexSpace):
(JSC::Wasm::CodeBlock::wasmToWasmExitStub):

  • wasm/WasmCompilationMode.cpp:

(JSC::Wasm::makeString):

  • wasm/WasmCompilationMode.h:
  • wasm/WasmEmbedder.h:
  • wasm/WasmEntryPlan.cpp: Added.

(JSC::Wasm::EntryPlan::EntryPlan):
(JSC::Wasm::EntryPlan::stateString):
(JSC::Wasm::EntryPlan::moveToState):
(JSC::Wasm::EntryPlan::didReceiveFunctionData):
(JSC::Wasm::EntryPlan::parseAndValidateModule):
(JSC::Wasm::EntryPlan::prepare):
(JSC::Wasm::EntryPlan::ThreadCountHolder::ThreadCountHolder):
(JSC::Wasm::EntryPlan::ThreadCountHolder::~ThreadCountHolder):
(JSC::Wasm::EntryPlan::complete):
(JSC::Wasm::EntryPlan::compileFunctions):
(JSC::Wasm::EntryPlan::work):

  • wasm/WasmEntryPlan.h: Copied from Source/JavaScriptCore/wasm/WasmBBQPlan.h.

(JSC::Wasm::EntryPlan::parseAndValidateModule):
(JSC::Wasm::EntryPlan::exports const):
(JSC::Wasm::EntryPlan::internalFunctionCount const):
(JSC::Wasm::EntryPlan::takeModuleInformation):
(JSC::Wasm::EntryPlan::takeWasmToWasmExitStubs):
(JSC::Wasm::EntryPlan::takeWasmToWasmCallsites):
(JSC::Wasm::EntryPlan::hasBeenPrepared const):
(JSC::Wasm::EntryPlan::tryReserveCapacity):

  • wasm/WasmFunctionCodeBlock.cpp: Added.

(JSC::Wasm::FunctionCodeBlock::setInstructions):
(JSC::Wasm::FunctionCodeBlock::dumpBytecode):
(JSC::Wasm::FunctionCodeBlock::addOutOfLineJumpTarget):
(JSC::Wasm::FunctionCodeBlock::outOfLineJumpOffset):
(JSC::Wasm::FunctionCodeBlock::outOfLineJumpTarget):
(JSC::Wasm::FunctionCodeBlock::addSignature):
(JSC::Wasm::FunctionCodeBlock::signature const):
(JSC::Wasm::FunctionCodeBlock::addJumpTable):
(JSC::Wasm::FunctionCodeBlock::jumpTable const const):
(JSC::Wasm::FunctionCodeBlock::numberOfJumpTables const):

  • wasm/WasmFunctionCodeBlock.h: Added.

(JSC::Wasm::FunctionCodeBlock::FunctionCodeBlock):
(JSC::Wasm::FunctionCodeBlock::getConstant const):
(JSC::Wasm::FunctionCodeBlock::functionIndex const):
(JSC::Wasm::FunctionCodeBlock::addJumpTarget):
(JSC::Wasm::FunctionCodeBlock::numberOfJumpTargets):
(JSC::Wasm::FunctionCodeBlock::lastJumpTarget):
(JSC::Wasm::FunctionCodeBlock::outOfLineJumpOffset):
(JSC::Wasm::FunctionCodeBlock::bytecodeOffset):
(JSC::Wasm::FunctionCodeBlock::tierUpCounter):

  • wasm/WasmFunctionParser.h:

(JSC::Wasm::FunctionParser<Context>::parseExpression):
(JSC::Wasm::FunctionParser<Context>::parseUnreachableExpression):

  • wasm/WasmInstance.h:
  • wasm/WasmLLIntGenerator.cpp: Added.

(JSC::Wasm::LLIntGenerator::ControlType::ControlType):
(JSC::Wasm::LLIntGenerator::ControlType::loop):
(JSC::Wasm::LLIntGenerator::ControlType::topLevel):
(JSC::Wasm::LLIntGenerator::ControlType::block):
(JSC::Wasm::LLIntGenerator::ControlType::if_):
(JSC::Wasm::LLIntGenerator::ControlType::targetLabelForBranch const):
(JSC::Wasm::LLIntGenerator::fail const):
(JSC::Wasm::LLIntGenerator::unifyValuesWithBlock):
(JSC::Wasm::LLIntGenerator::emptyExpression):
(JSC::Wasm::LLIntGenerator::createStack):
(JSC::Wasm::LLIntGenerator::isControlTypeIf):
(JSC::Wasm::LLIntGenerator::addEndToUnreachable):
(JSC::Wasm::LLIntGenerator::setParser):
(JSC::Wasm::LLIntGenerator::dump):
(JSC::Wasm::LLIntGenerator::virtualRegisterForLocal):
(JSC::Wasm::LLIntGenerator::tmpsForSignature):
(JSC::Wasm::LLIntGenerator::jsNullConstant):
(JSC::Wasm::LLIntGenerator::isConstant):
(JSC::Wasm::parseAndCompileBytecode):
(JSC::Wasm::LLIntGenerator::LLIntGenerator):
(JSC::Wasm::LLIntGenerator::finalize):
(JSC::Wasm::LLIntGenerator::callInformationFor):
(JSC::Wasm::LLIntGenerator::addArguments):
(JSC::Wasm::LLIntGenerator::addLocal):
(JSC::Wasm::LLIntGenerator::addConstant):
(JSC::Wasm::LLIntGenerator::getLocal):
(JSC::Wasm::LLIntGenerator::setLocal):
(JSC::Wasm::LLIntGenerator::getGlobal):
(JSC::Wasm::LLIntGenerator::setGlobal):
(JSC::Wasm::LLIntGenerator::addLoop):
(JSC::Wasm::LLIntGenerator::addTopLevel):
(JSC::Wasm::LLIntGenerator::addBlock):
(JSC::Wasm::LLIntGenerator::addIf):
(JSC::Wasm::LLIntGenerator::addElse):
(JSC::Wasm::LLIntGenerator::addElseToUnreachable):
(JSC::Wasm::LLIntGenerator::addReturn):
(JSC::Wasm::LLIntGenerator::addBranch):
(JSC::Wasm::LLIntGenerator::addSwitch):
(JSC::Wasm::LLIntGenerator::endBlock):
(JSC::Wasm::LLIntGenerator::addCall):
(JSC::Wasm::LLIntGenerator::addCallIndirect):
(JSC::Wasm::LLIntGenerator::addRefIsNull):
(JSC::Wasm::LLIntGenerator::addRefFunc):
(JSC::Wasm::LLIntGenerator::addTableGet):
(JSC::Wasm::LLIntGenerator::addTableSet):
(JSC::Wasm::LLIntGenerator::addTableSize):
(JSC::Wasm::LLIntGenerator::addTableGrow):
(JSC::Wasm::LLIntGenerator::addTableFill):
(JSC::Wasm::LLIntGenerator::addUnreachable):
(JSC::Wasm::LLIntGenerator::addCurrentMemory):
(JSC::Wasm::LLIntGenerator::addGrowMemory):
(JSC::Wasm::LLIntGenerator::addSelect):
(JSC::Wasm::LLIntGenerator::load):
(JSC::Wasm::LLIntGenerator::store):
(JSC::GenericLabel<Wasm::GeneratorTraits>::setLocation):

  • wasm/WasmLLIntGenerator.h: Copied from Source/JavaScriptCore/wasm/WasmCompilationMode.h.
  • wasm/WasmLLIntPlan.cpp: Added.

(JSC::Wasm::LLIntPlan::prepareImpl):
(JSC::Wasm::LLIntPlan::compileFunction):
(JSC::Wasm::LLIntPlan::didCompleteCompilation):
(JSC::Wasm::LLIntPlan::initializeCallees):

  • wasm/WasmLLIntPlan.h: Copied from Source/JavaScriptCore/wasm/WasmOMGForOSREntryPlan.h.
  • wasm/WasmLLIntTierUpCounter.cpp: Copied from Source/JavaScriptCore/wasm/WasmCompilationMode.cpp.

(JSC::Wasm::LLIntTierUpCounter::addOSREntryDataForLoop):
(JSC::Wasm::LLIntTierUpCounter::osrEntryDataForLoop const const):

  • wasm/WasmLLIntTierUpCounter.h: Copied from Source/JavaScriptCore/wasm/WasmOMGForOSREntryPlan.h.

(JSC::Wasm::LLIntTierUpCounter::LLIntTierUpCounter):
(JSC::Wasm::LLIntTierUpCounter::optimizeAfterWarmUp):
(JSC::Wasm::LLIntTierUpCounter::checkIfOptimizationThresholdReached):
(JSC::Wasm::LLIntTierUpCounter::optimizeSoon):

  • wasm/WasmMemoryInformation.cpp:

(JSC::Wasm::PinnedRegisterInfo::get):

  • wasm/WasmModule.cpp:

(JSC::Wasm::makeValidationResult):
(JSC::Wasm::makeValidationCallback):
(JSC::Wasm::Module::validateSync):
(JSC::Wasm::Module::validateAsync):

  • wasm/WasmOMGForOSREntryPlan.cpp:

(JSC::Wasm::OMGForOSREntryPlan::OMGForOSREntryPlan):
(JSC::Wasm::OMGForOSREntryPlan::work):

  • wasm/WasmOMGForOSREntryPlan.h:
  • wasm/WasmOMGPlan.cpp:

(JSC::Wasm::OMGPlan::work):

  • wasm/WasmSlowPaths.cpp: Added.

(JSC::LLInt::jitCompileAndSetHeuristics):
(JSC::LLInt::WASM_SLOW_PATH_DECL):
(JSC::LLInt::doWasmCall):
(JSC::LLInt::doWasmCallIndirect):
(JSC::LLInt::slow_path_wasm_throw_exception):
(JSC::LLInt::slow_path_wasm_popcount):
(JSC::LLInt::slow_path_wasm_popcountll):

  • wasm/WasmSlowPaths.h: Added.
  • wasm/WasmTable.cpp:

(JSC::Wasm::FuncRefTable::function const):
(JSC::Wasm::FuncRefTable::instance const):

  • wasm/WasmTable.h:
  • wasm/WasmTierUpCount.h:
  • wasm/WasmValidate.cpp:

(JSC::Wasm::Validate::isControlTypeIf):

  • wasm/js/JSToWasm.cpp:

(JSC::Wasm::createJSToWasmWrapper):

  • wasm/js/JSToWasm.h:
  • wasm/js/WebAssemblyFunction.cpp:

(JSC::WebAssemblyFunction::calleeSaves const):

Tools:

Add a mode that runs WebAssembly tests without the LLInt (i.e. only Air)
and update the no-air mode to also disable the LLInt tier.

  • Scripts/run-jsc-stress-tests:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm

    r251556 r251886  
    1 # Copyrsght (C) 2011-2019 Apple Inc. All rights reserved.
     1# Copyright (C) 2011-2019 Apple Inc. All rights reserved.
    22#
    33# Redistribution and use in source and binary forms, with or without
     
    185185const MetadataOffsetTable16Offset = 0
    186186const MetadataOffsetTable32Offset = constexpr UnlinkedMetadataTable::s_offset16TableSize
     187const NumberOfJSOpcodeIDs = constexpr numOpcodeIDs
    187188
    188189# Some value representation constants.
     
    313314end
    314315
    315 macro dispatchOp(size, opcodeName)
     316macro genericDispatchOp(dispatch, size, opcodeName)
    316317    macro dispatchNarrow()
    317318        dispatch(constexpr %opcodeName%_length)
     
    328329    size(dispatchNarrow, dispatchWide16, dispatchWide32, macro (dispatch) dispatch() end)
    329330end
     331
     332macro dispatchOp(size, opcodeName)
     333    genericDispatchOp(dispatch, size, opcodeName)
     334end
     335
    330336
    331337macro getu(size, opcodeStruct, fieldName, dst)
     
    364370end
    365371
    366 macro jumpImpl(targetOffsetReg)
     372macro jumpImpl(dispatchIndirect, targetOffsetReg)
    367373    btiz targetOffsetReg, .outOfLineJumpTarget
    368374    dispatchIndirect(targetOffsetReg)
     
    376382    prologue()
    377383    fn(narrow)
     384    if ASSERT_ENABLED
     385        break
     386        break
     387    end
    378388
    379389# FIXME: We cannot enable wide16 bytecode in Windows CLoop. With MSVC, as CLoop::execute gets larger code
     
    385395    prologue()
    386396    fn(wide16)
     397    if ASSERT_ENABLED
     398        break
     399        break
     400    end
    387401end
    388402
     
    390404    prologue()
    391405    fn(wide32)
     406    if ASSERT_ENABLED
     407        break
     408        break
     409    end
    392410end
    393411
     
    433451        macro jump(fieldName)
    434452            get(fieldName, t0)
    435             jumpImpl(t0)
     453            jumpImpl(dispatchIndirect, t0)
    436454        end
    437455
     
    558576
    559577macro assert(assertion)
     578    if ASSERT_ENABLED
     579        assertion(.ok)
     580        crash()
     581    .ok:
     582    end
     583end
     584
     585macro assert_with(assertion, crash)
    560586    if ASSERT_ENABLED
    561587        assertion(.ok)
     
    782808end
    783809
     810macro copyCalleeSavesToEntryFrameCalleeSavesBuffer(entryFrame)
     811    if ARM64 or ARM64E or X86_64 or X86_64_WIN or ARMv7 or MIPS
     812        vmEntryRecord(entryFrame, entryFrame)
     813        leap VMEntryRecord::calleeSaveRegistersBuffer[entryFrame], entryFrame
     814        if ARM64 or ARM64E
     815            storeq csr0, [entryFrame]
     816            storeq csr1, 8[entryFrame]
     817            storeq csr2, 16[entryFrame]
     818            storeq csr3, 24[entryFrame]
     819            storeq csr4, 32[entryFrame]
     820            storeq csr5, 40[entryFrame]
     821            storeq csr6, 48[entryFrame]
     822            storeq csr7, 56[entryFrame]
     823            storeq csr8, 64[entryFrame]
     824            storeq csr9, 72[entryFrame]
     825            stored csfr0, 80[entryFrame]
     826            stored csfr1, 88[entryFrame]
     827            stored csfr2, 96[entryFrame]
     828            stored csfr3, 104[entryFrame]
     829            stored csfr4, 112[entryFrame]
     830            stored csfr5, 120[entryFrame]
     831            stored csfr6, 128[entryFrame]
     832            stored csfr7, 136[entryFrame]
     833        elsif X86_64
     834            storeq csr0, [entryFrame]
     835            storeq csr1, 8[entryFrame]
     836            storeq csr2, 16[entryFrame]
     837            storeq csr3, 24[entryFrame]
     838            storeq csr4, 32[entryFrame]
     839        elsif X86_64_WIN
     840            storeq csr0, [entryFrame]
     841            storeq csr1, 8[entryFrame]
     842            storeq csr2, 16[entryFrame]
     843            storeq csr3, 24[entryFrame]
     844            storeq csr4, 32[entryFrame]
     845            storeq csr5, 40[entryFrame]
     846            storeq csr6, 48[entryFrame]
     847        elsif ARMv7 or MIPS
     848            storep csr0, [entryFrame]
     849        end
     850    end
     851end
     852
    784853macro copyCalleeSavesToVMEntryFrameCalleeSavesBuffer(vm, temp)
    785854    if ARM64 or ARM64E or X86_64 or X86_64_WIN or ARMv7 or MIPS
    786855        loadp VM::topEntryFrame[vm], temp
    787         vmEntryRecord(temp, temp)
    788         leap VMEntryRecord::calleeSaveRegistersBuffer[temp], temp
    789         if ARM64 or ARM64E
    790             storeq csr0, [temp]
    791             storeq csr1, 8[temp]
    792             storeq csr2, 16[temp]
    793             storeq csr3, 24[temp]
    794             storeq csr4, 32[temp]
    795             storeq csr5, 40[temp]
    796             storeq csr6, 48[temp]
    797             storeq csr7, 56[temp]
    798             storeq csr8, 64[temp]
    799             storeq csr9, 72[temp]
    800             stored csfr0, 80[temp]
    801             stored csfr1, 88[temp]
    802             stored csfr2, 96[temp]
    803             stored csfr3, 104[temp]
    804             stored csfr4, 112[temp]
    805             stored csfr5, 120[temp]
    806             stored csfr6, 128[temp]
    807             stored csfr7, 136[temp]
    808         elsif X86_64
    809             storeq csr0, [temp]
    810             storeq csr1, 8[temp]
    811             storeq csr2, 16[temp]
    812             storeq csr3, 24[temp]
    813             storeq csr4, 32[temp]
    814         elsif X86_64_WIN
    815             storeq csr0, [temp]
    816             storeq csr1, 8[temp]
    817             storeq csr2, 16[temp]
    818             storeq csr3, 24[temp]
    819             storeq csr4, 32[temp]
    820             storeq csr5, 40[temp]
    821             storeq csr6, 48[temp]
    822         elsif ARMv7 or MIPS
    823             storep csr0, [temp]
    824         end
     856        copyCalleeSavesToEntryFrameCalleeSavesBuffer(temp)
    825857    end
    826858end
     
    11561188    end
    11571189    codeBlockGetter(t1)
     1190    codeBlockSetter(t1)
    11581191    if not (C_LOOP or C_LOOP_WIN)
    11591192        baddis 5, CodeBlock::m_llintExecuteCounter + BaselineExecutionCounter::m_counter[t1], .continue
     
    11851218        jmp r0, JSEntryPtrTag
    11861219    .recover:
    1187         codeBlockGetter(t1)
     1220        notFunctionCodeBlockGetter(t1)
    11881221    .continue:
    11891222    end
    1190 
    1191     codeBlockSetter(t1)
    11921223
    11931224    preserveCalleeSavesUsedByLLInt()
     
    12301261    # Stack check slow path returned that the stack was ok.
    12311262    # Since they were clobbered, need to get CodeBlock and new sp
    1232     codeBlockGetter(t1)
     1263    notFunctionCodeBlockGetter(t1)
    12331264    getFrameRegisterSizeForCodeBlock(t1, t0)
    12341265    subp cfr, t0, t0
     
    13721403        crash()
    13731404else
    1374     macro initPCRelative(pcBase)
     1405    macro initPCRelative(kind, pcBase)
    13751406        if X86_64 or X86_64_WIN or X86 or X86_WIN
    1376             call _relativePCBase
    1377         _relativePCBase:
     1407            call _%kind%_relativePCBase
     1408        _%kind%_relativePCBase:
    13781409            pop pcBase
    13791410        elsif ARM64 or ARM64E
    13801411        elsif ARMv7
    1381         _relativePCBase:
     1412        _%kind%_relativePCBase:
    13821413            move pc, pcBase
    13831414            subp 3, pcBase   # Need to back up the PC and set the Thumb2 bit
    13841415        elsif MIPS
    1385             la _relativePCBase, pcBase
     1416            la _%kind%_relativePCBase, pcBase
    13861417            setcallreg pcBase # needed to set $t9 to the right value for the .cpload created by the label.
    1387         _relativePCBase:
    1388         end
    1389 end
    1390 
    1391 # The PC base is in t3, as this is what _llint_entry leaves behind through
    1392 # initPCRelative(t3)
    1393 macro setEntryAddress(index, label)
    1394     setEntryAddressCommon(index, label, a0)
    1395 end
    1396 
    1397 macro setEntryAddressWide16(index, label)
    1398      setEntryAddressCommon(index, label, a1)
    1399 end
    1400 
    1401 macro setEntryAddressWide32(index, label)
    1402      setEntryAddressCommon(index, label, a2)
    1403 end
    1404 
    1405 macro setEntryAddressCommon(index, label, map)
    1406     if X86_64
    1407         leap (label - _relativePCBase)[t3], t4
    1408         move index, t5
    1409         storep t4, [map, t5, 8]
    1410     elsif X86_64_WIN
    1411         leap (label - _relativePCBase)[t3], t4
    1412         move index, t0
    1413         storep t4, [map, t0, 8]
    1414     elsif X86 or X86_WIN
    1415         leap (label - _relativePCBase)[t3], t4
    1416         move index, t5
    1417         storep t4, [map, t5, 4]
    1418     elsif ARM64 or ARM64E
    1419         pcrtoaddr label, t3
    1420         move index, t4
    1421         storep t3, [map, t4, PtrSize]
    1422     elsif ARMv7
    1423         mvlbl (label - _relativePCBase), t4
    1424         addp t4, t3, t4
    1425         move index, t5
    1426         storep t4, [map, t5, 4]
    1427     elsif MIPS
    1428         la label, t4
    1429         la _relativePCBase, t3
    1430         subp t3, t4
    1431         addp t4, t3, t4
    1432         move index, t5
    1433         storep t4, [map, t5, 4]
    1434     end
    1435 end
    1436 
    1437 global _llint_entry
     1418        _%kind%_relativePCBase:
     1419        end
     1420    end
     1421
     1422    # The PC base is in t3, as this is what _llint_entry leaves behind through
     1423    # initPCRelative(t3)
     1424    macro setEntryAddressCommon(kind, index, label, map)
     1425        if X86_64
     1426            leap (label - _%kind%_relativePCBase)[t3], t4
     1427            move index, t5
     1428            storep t4, [map, t5, 8]
     1429        elsif X86_64_WIN
     1430            leap (label - _%kind%_relativePCBase)[t3], t4
     1431            move index, t0
     1432            storep t4, [map, t0, 8]
     1433        elsif X86 or X86_WIN
     1434            leap (label - _%kind%_relativePCBase)[t3], t4
     1435            move index, t5
     1436            storep t4, [map, t5, 4]
     1437        elsif ARM64 or ARM64E
     1438            pcrtoaddr label, t3
     1439            move index, t4
     1440            storep t3, [map, t4, PtrSize]
     1441        elsif ARMv7
     1442            mvlbl (label - _%kind%_relativePCBase), t4
     1443            addp t4, t3, t4
     1444            move index, t5
     1445            storep t4, [map, t5, 4]
     1446        elsif MIPS
     1447            la label, t4
     1448            la _%kind%_relativePCBase, t3
     1449            subp t3, t4
     1450            addp t4, t3, t4
     1451            move index, t5
     1452            storep t4, [map, t5, 4]
     1453        end
     1454    end
     1455
     1456
     1457
     1458    macro includeEntriesAtOffset(kind, fn)
     1459        macro setEntryAddress(index, label)
     1460            setEntryAddressCommon(kind, index, label, a0)
     1461        end
     1462
     1463        macro setEntryAddressWide16(index, label)
     1464             setEntryAddressCommon(kind, index, label, a1)
     1465        end
     1466
     1467        macro setEntryAddressWide32(index, label)
     1468             setEntryAddressCommon(kind, index, label, a2)
     1469        end
     1470
     1471        fn()
     1472    end
     1473
     1474
     1475macro entry(kind, initialize)
     1476    global _%kind%_entry
     1477    _%kind%_entry:
     1478        functionPrologue()
     1479        pushCalleeSaves()
     1480        if X86 or X86_WIN
     1481            loadp 20[sp], a0
     1482            loadp 24[sp], a1
     1483            loadp 28[sp], a2
     1484        end
     1485
     1486        initPCRelative(kind, t3)
     1487
     1488        # Include generated bytecode initialization file.
     1489        includeEntriesAtOffset(kind, initialize)
     1490        popCalleeSaves()
     1491        functionEpilogue()
     1492        ret
     1493end
     1494
    14381495# Entry point for the llint to initialize.
    1439 _llint_entry:
    1440     functionPrologue()
    1441     pushCalleeSaves()
    1442     if X86 or X86_WIN
    1443         loadp 20[sp], a0
    1444         loadp 24[sp], a1
    1445         loadp 28[sp], a2
    1446     end
    1447 
    1448     initPCRelative(t3)
    1449 
    1450     # Include generated bytecode initialization file.
     1496entry(llint, macro()
    14511497    include InitBytecodes
    1452 
    1453     popCalleeSaves()
    1454     functionEpilogue()
    1455     ret
    1456 end
     1498end)
     1499
     1500end // not (C_LOOP or C_LOOP_WIN)
    14571501
    14581502_llint_op_wide16:
     
    14631507
    14641508macro noWide(label)
    1465 _llint_%label%_wide16:
     1509_%label%_wide16:
    14661510    crash()
    14671511
    1468 _llint_%label%_wide32:
     1512_%label%_wide32:
    14691513    crash()
    14701514end
    14711515
    1472 noWide(op_wide16)
    1473 noWide(op_wide32)
    1474 noWide(op_enter)
     1516noWide(llint_op_wide16)
     1517noWide(llint_op_wide32)
     1518noWide(llint_op_enter)
    14751519
    14761520op(llint_program_prologue, macro ()
     
    19712015    end
    19722016end
     2017
     2018if WEBASSEMBLY
     2019
     2020entry(wasm, macro()
     2021    include InitWasm
     2022end)
     2023
     2024macro wasmScope()
     2025    # Wrap the script in a macro since it overwrites some of the LLInt macros,
     2026    # but we don't want to interfere with the LLInt opcodes
     2027    include WebAssembly
     2028end
     2029wasmScope()
     2030
     2031else
     2032
     2033# These need to be defined even when WebAssembly is disabled
     2034op(wasm_function_prologue, macro ()
     2035    crash()
     2036end)
     2037
     2038op(wasm_function_prologue_no_tls, macro ()
     2039    crash()
     2040end)
     2041
     2042end
Note: See TracChangeset for help on using the changeset viewer.