Path: blob/master/runtime/compiler/x/codegen/J9UnresolvedDataSnippet.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 J9_X86UNRESOLVEDDATASNIPPET_INCL23#define J9_X86UNRESOLVEDDATASNIPPET_INCL2425/*26* The following #define and typedef must appear before any #includes in this file27*/28#ifndef J9_UNRESOLVEDDATASNIPPET_CONNECTOR29#define J9_UNRESOLVEDDATASNIPPET_CONNECTOR30namespace J9 { namespace X86 { class UnresolvedDataSnippet; } }31namespace J9 { typedef J9::X86::UnresolvedDataSnippet UnresolvedDataSnippetConnector; }32#else33#error J9::X86::UnresolvedDataSnippet expected to be a primary connector, but a J9 connector is already defined34#endif353637#include "compiler/codegen/J9UnresolvedDataSnippet.hpp"3839#include <stdint.h>40#include "codegen/CodeGenerator.hpp"41#include "il/Symbol.hpp"42#include "il/SymbolReference.hpp"43#include "runtime/J9Runtime.hpp"44#include "infra/Flags.hpp"45#include "env/CompilerEnv.hpp"4647namespace TR { class Node; }484950namespace J951{5253namespace X8654{5556class UnresolvedDataSnippet : public J9::UnresolvedDataSnippet57{5859public:6061UnresolvedDataSnippet(TR::CodeGenerator *cg, TR::Node *node, TR::SymbolReference *symRef, bool isStore, bool isGCSafePoint);6263Kind getKind() { return J9::X86::UnresolvedDataSnippet::cg()->comp()->target().is64Bit() ? IsUnresolvedDataAMD64 : IsUnresolvedDataIA32; }6465virtual uint8_t *emitSnippetBody();6667virtual uint32_t getLength(int32_t estimatedSnippetStart);6869TR_RuntimeHelper getHelper();7071uint8_t *emitResolveHelperCall(uint8_t *cursor);72uint8_t *emitUnresolvedInstructionDescriptor(uint8_t *cursor);73uint32_t getUnresolvedStaticStoreDeltaWithMemBarrier();74uint8_t *emitConstantPoolAddress(uint8_t *cursor);75uint8_t *emitConstantPoolIndex(uint8_t *cursor);76uint8_t *fixupDataReferenceInstruction(uint8_t *cursor);7778TR::SymbolReference * getGlueSymRef() { return _glueSymRef; }79void setGlueSymRef(TR::SymbolReference * glueSymRef) { _glueSymRef = glueSymRef; }8081TR::Symbol *getDataSymbol() {return getDataSymbolReference()->getSymbol();}8283bool resolveMustPatch8Bytes()84{85// On 64-bit, only unresolved fields require 4-byte patching.86//87return J9::X86::UnresolvedDataSnippet::cg()->comp()->target().is64Bit() && !getDataSymbol()->isShadow();88}8990uint8_t setNumLiveX87Registers(uint8_t live)91{92// If the unresolved data snippet call is for a floating point93// load then the register assigner will free up one register on94// the fp stack, however the live count isn't changed at that point95// in which case we'll still have 8 live FPR, which we'll spill and reload96// in PicBuilder. However, if we are doing floating point load and the97// live count is 8 we'll do total of 9 pushes on the fp stack, 8 in the98// runtime code + 1 for the load, which will cause fp stack overflow and99// incorrect load. The fix is to adjust the number of live registers to 7100// when we are doing floating load in the unresolved snippet.101// See JCK: api.java.awt.geom.AffineTransform.CreateInverseTest102//103if (!isUnresolvedStore() && isFloatData() && (live == 8))104{105live--;106}107108return (_numLiveX87Registers = live);109}110111uint8_t getNumLiveX87Registers() {return _numLiveX87Registers;}112113/*114* Flags to be passed to the resolution runtime. These flags piggyback on115* the unused bits of the cpIndex.116*117* Move to J9 FE.118*/119enum120{121cpIndex_hasLiveXMMRegisters = 0x10000000,122cpIndex_doNotPatchSnippet = 0x00200000,123cpIndex_longPushTag = 0x00800000,124cpIndex_isStaticResolution = 0x20000000,125cpIndex_patch8ByteResolution = 0x40000000, // OVERLOADED: 64-BIT only126cpIndex_checkVolatility = 0x00080000,127cpIndex_procAsLongLow = 0x00040000,128cpIndex_procAsLongHigh = 0x00020000,129cpIndex_isHighWordOfLongPair = 0x40000000, // OVERLOADED: 32-BIT only130cpIndex_extremeStaticMemBarPos = 0x80000000,131cpIndex_genStaticMemBarPos = 0x00000000,132cpIndex_isFloatStore = 0x00040000, // OVERLOADED: 64-BIT only133cpIndex_isCompressedPointer = 0x40000000, // OVERLOADED: multiTenancy perform load/store134cpIndex_isOwningObjectNeeded = 0x00040000, // OVERLOADED: multiTenancy refrence type store needs owning object register135};136137bool isFloatData() {return _flags.testAll(TO_MASK32(IsFloatData));}138void setIsFloatData() {_flags.set(TO_MASK32(IsFloatData));}139void resetFloatData() {_flags.reset(TO_MASK32(IsFloatData));}140141bool hasLiveXMMRegisters() {return _flags.testAll(TO_MASK32(HasLiveXMMRegisters));}142void setHasLiveXMMRegisters(bool b) {_flags.set(TO_MASK32(HasLiveXMMRegisters), b);}143void resetHasLiveXMMRegisters() {_flags.reset(TO_MASK32(HasLiveXMMRegisters));}144145protected:146147enum148{149IsFloatData = J9::UnresolvedDataSnippet::NextSnippetFlag,150HasLiveXMMRegisters,151DoNotPatchMainline,152NextSnippetFlag153};154155static_assert((int32_t)NextSnippetFlag <= (int32_t)J9::UnresolvedDataSnippet::MaxSnippetFlag,156"J9::X86::UnresolvedDataSnippet too many flag bits for flag width");157158159private:160161TR::SymbolReference *_glueSymRef;162163uint8_t _numLiveX87Registers;164165};166167}168169}170171#endif172173174