Path: blob/master/runtime/compiler/x/codegen/AllocPrefetchSnippet.hpp
6004 views
/*******************************************************************************1* Copyright (c) 2000, 2020 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception20*******************************************************************************/2122#ifndef IA32ALLOCPREFETCHSNIPPET_INCL23#define IA32ALLOCPREFETCHSNIPPET_INCL2425#include "x/codegen/RestartSnippet.hpp"2627namespace TR {28void createCCPreLoadedCode(uint8_t *CCPreLoadedCodeBase, uint8_t *CCPreLoadedCodeTop, void ** CCPreLoadedCodeTable, TR::CodeGenerator *cg);29uint32_t getCCPreLoadedCodeSize();30}313233struct TR_X86AllocPrefetchGeometry34{35public:3637TR_X86AllocPrefetchGeometry(int32_t prefetchLineSize, int32_t prefetchLineCount, int32_t prefetchStaggeredLineCount, int32_t prefetchBoundaryLineCount, int32_t prefetchTLHEndLineCount) :38_prefetchLineSize(prefetchLineSize),39_prefetchLineCount(prefetchLineCount),40_prefetchStaggeredLineCount(prefetchStaggeredLineCount),41_prefetchBoundaryLineCount(prefetchBoundaryLineCount),42_prefetchTLHEndLineCount(prefetchTLHEndLineCount)43{}4445int32_t getPrefetchLineSize() const { return _prefetchLineSize; }46int32_t getPrefetchLineCount() const { return _prefetchLineCount; }47int32_t getPrefetchStaggeredLineCount() const { return _prefetchStaggeredLineCount; }48int32_t getPrefetchBoundaryLineCount() const { return _prefetchBoundaryLineCount; }49int32_t getPrefetchTLHEndLineCount() const { return _prefetchTLHEndLineCount; }5051int32_t sizeOfTLHEndCount() const { return getPrefetchTLHEndLineCount() * getPrefetchLineSize(); }52bool needWideDisplacementForTLHEndCount() const { return (sizeOfTLHEndCount() > 127 || sizeOfTLHEndCount() < -128); }5354private:55int32_t _prefetchLineSize;56int32_t _prefetchLineCount;57int32_t _prefetchStaggeredLineCount;58int32_t _prefetchBoundaryLineCount;59int32_t _prefetchTLHEndLineCount;60};6162namespace TR {6364struct HeapTypes65{66enum Type67{68ZeroedHeap,69NonZeroedHeap70};71static const char * const getPrefix(size_t index)72{ static const char * const prefixes[] =73{74"Zeroed",75"Non-Zeroed"76};77return prefixes[index];78}79};8081class X86AllocPrefetchSnippet : public TR::X86RestartSnippet82{83public:8485X86AllocPrefetchSnippet(TR::CodeGenerator *cg,86TR::Node *node,87int32_t prefetchSize,88TR::LabelSymbol *restartlab,89TR::LabelSymbol *snippetlab,90bool nonZeroTLH)91: TR::X86RestartSnippet(cg, node, restartlab, snippetlab, false)92{93_prefetchSize = prefetchSize;94_nonZeroTLH = nonZeroTLH;95}9697virtual uint8_t *emitSnippetBody();9899virtual uint32_t getLength(int32_t estimatedSnippetStart);100101int32_t getPrefetchSize() { return _prefetchSize; }102103bool isNonZeroTLH() { return _nonZeroTLH; }104105private:106107static TR_X86AllocPrefetchGeometry generatePrefetchGeometry();108template <TR::HeapTypes::Type HEAP_TYPE, bool is64Bit> static int32_t sizeOfSharedBody();109template <TR::HeapTypes::Type HEAP_TYPE, bool is64Bit> static uint8_t* emitSharedBody(uint8_t *, TR::Compilation*);110111friend void TR::createCCPreLoadedCode(uint8_t *CCPreLoadedCodeBase, uint8_t *CCPreLoadedCodeTop, void ** CCPreLoadedCodeTable, TR::CodeGenerator *cg);112friend uint32_t TR::getCCPreLoadedCodeSize();113114int32_t _prefetchSize;115bool _nonZeroTLH;116117};118119}120121#endif122123124