Changeset 288002 in webkit for trunk/Source/JavaScriptCore/wasm/WasmBBQPlan.cpp
- Timestamp:
- Jan 13, 2022, 6:40:08 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/wasm/WasmBBQPlan.cpp
r287864 r288002 64 64 const auto& functions = m_moduleInformation->functions; 65 65 if (!tryReserveCapacity(m_wasmInternalFunctions, functions.size(), " WebAssembly functions") 66 || !tryReserveCapacity(m_wasmInternalFunctionLinkBuffers, functions.size(), " compilation contexts") 66 67 || !tryReserveCapacity(m_compilationContexts, functions.size(), " compilation contexts") 67 68 || !tryReserveCapacity(m_tierUpCounts, functions.size(), " tier-up counts") … … 70 71 71 72 m_wasmInternalFunctions.resize(functions.size()); 73 m_wasmInternalFunctionLinkBuffers.resize(functions.size()); 72 74 m_exceptionHandlerLocations.resize(functions.size()); 73 75 m_compilationContexts.resize(functions.size()); … … 183 185 184 186 m_wasmInternalFunctions[functionIndex] = compileFunction(functionIndex, m_compilationContexts[functionIndex], m_unlinkedWasmToWasmCalls[functionIndex], m_tierUpCounts[functionIndex].get()); 187 { 188 auto linkBuffer = makeUnique<LinkBuffer>(*m_compilationContexts[functionIndex].wasmEntrypointJIT, nullptr, LinkBuffer::Profile::Wasm, JITCompilationCanFail); 189 if (linkBuffer->isValid()) 190 m_wasmInternalFunctionLinkBuffers[functionIndex] = WTFMove(linkBuffer); 191 } 185 192 186 193 if (m_exportedFunctionIndices.contains(functionIndex) || m_moduleInformation->referencedFunctions().contains(functionIndex)) { … … 188 195 SignatureIndex signatureIndex = m_moduleInformation->internalFunctionSignatureIndices[functionIndex]; 189 196 const Signature& signature = SignatureInformation::get(signatureIndex); 190 auto result = m_embedderToWasmInternalFunctions.add(functionIndex, createJSToWasmWrapper(*m_compilationContexts[functionIndex].embedderEntrypointJIT, signature, &m_unlinkedWasmToWasmCalls[functionIndex], m_moduleInformation.get(), m_mode, functionIndex)); 197 198 auto embedderToWasmInternalFunction = createJSToWasmWrapper(*m_compilationContexts[functionIndex].embedderEntrypointJIT, signature, &m_unlinkedWasmToWasmCalls[functionIndex], m_moduleInformation.get(), m_mode, functionIndex); 199 auto linkBuffer = makeUnique<LinkBuffer>(*m_compilationContexts[functionIndex].embedderEntrypointJIT, nullptr, LinkBuffer::Profile::Wasm, JITCompilationCanFail); 200 201 auto result = m_embedderToWasmInternalFunctions.add(functionIndex, std::pair { WTFMove(linkBuffer), WTFMove(embedderToWasmInternalFunction) }); 191 202 ASSERT_UNUSED(result, result.isNewEntry); 192 203 } … … 239 250 { 240 251 InternalFunction* function = m_wasmInternalFunctions[functionIndex].get(); 241 LinkBuffer linkBuffer(*context.wasmEntrypointJIT, nullptr, LinkBuffer::Profile::Wasm, JITCompilationCanFail); 242 if (UNLIKELY(linkBuffer.didFailToAllocate())) { 252 if (!m_wasmInternalFunctionLinkBuffers[functionIndex]) { 243 253 Base::fail(makeString("Out of executable memory in function at index ", String::number(functionIndex))); 244 254 return; 245 255 } 256 257 auto& linkBuffer = *m_wasmInternalFunctionLinkBuffers[functionIndex]; 246 258 247 259 computeExceptionHandlerAndLoopEntrypointLocations(m_exceptionHandlerLocations[functionIndex], m_allLoopEntrypoints[functionIndex], function, context, linkBuffer); … … 254 266 } 255 267 256 if (const auto& embedderToWasmInternalFunction = m_embedderToWasmInternalFunctions.get(functionIndex)) { 257 LinkBuffer linkBuffer(*context.embedderEntrypointJIT, nullptr, LinkBuffer::Profile::Wasm, JITCompilationCanFail); 258 if (UNLIKELY(linkBuffer.didFailToAllocate())) { 259 Base::fail(makeString("Out of executable memory in function entrypoint at index ", String::number(functionIndex))); 260 return; 268 { 269 auto iter = m_embedderToWasmInternalFunctions.find(functionIndex); 270 if (iter != m_embedderToWasmInternalFunctions.end()) { 271 LinkBuffer& linkBuffer = *iter->value.first; 272 const auto& embedderToWasmInternalFunction = iter->value.second; 273 274 if (linkBuffer.didFailToAllocate()) { 275 Base::fail(makeString("Out of executable memory in function entrypoint at index ", String::number(functionIndex))); 276 return; 277 } 278 279 embedderToWasmInternalFunction->entrypoint.compilation = makeUnique<Compilation>( 280 FINALIZE_CODE(linkBuffer, JITCompilationPtrTag, "Embedder->WebAssembly entrypoint[%i] %s name %s", functionIndex, signature.toString().ascii().data(), makeString(IndexOrName(functionIndexSpace, m_moduleInformation->nameSection->get(functionIndexSpace))).ascii().data()), 281 nullptr); 261 282 } 262 263 embedderToWasmInternalFunction->entrypoint.compilation = makeUnique<Compilation>(264 FINALIZE_CODE(linkBuffer, JITCompilationPtrTag, "Embedder->WebAssembly entrypoint[%i] %s name %s", functionIndex, signature.toString().ascii().data(), makeString(IndexOrName(functionIndexSpace, m_moduleInformation->nameSection->get(functionIndexSpace))).ascii().data()),265 nullptr);266 283 } 267 284 } … … 286 303 287 304 RefPtr<EmbedderEntrypointCallee> embedderEntrypointCallee; 288 if (auto embedderToWasmFunction = m_embedderToWasmInternalFunctions.get(internalFunctionIndex)) { 289 embedderEntrypointCallee = EmbedderEntrypointCallee::create(WTFMove(embedderToWasmFunction->entrypoint)); 290 for (auto& moveLocation : embedderToWasmFunction->calleeMoveLocations) 291 MacroAssembler::repatchPointer(moveLocation, CalleeBits::boxWasm(embedderEntrypointCallee.get())); 305 { 306 auto iter = m_embedderToWasmInternalFunctions.find(internalFunctionIndex); 307 if (iter != m_embedderToWasmInternalFunctions.end()) { 308 const auto& embedderToWasmFunction = iter->value.second; 309 embedderEntrypointCallee = EmbedderEntrypointCallee::create(WTFMove(embedderToWasmFunction->entrypoint)); 310 for (auto& moveLocation : embedderToWasmFunction->calleeMoveLocations) 311 MacroAssembler::repatchPointer(moveLocation, CalleeBits::boxWasm(embedderEntrypointCallee.get())); 312 } 292 313 } 293 314
Note:
See TracChangeset
for help on using the changeset viewer.