Path: blob/master/runtime/compiler/arm/codegen/J9UnresolvedDataSnippet.cpp
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#include "codegen/CodeGenerator.hpp"23#include "codegen/MemoryReference.hpp"24#include "codegen/UnresolvedDataSnippet.hpp"25#include "codegen/Relocation.hpp"26#include "il/Node.hpp"27#include "il/Node_inlines.hpp"28#include "il/StaticSymbol.hpp"29#include "il/StaticSymbol_inlines.hpp"30#include "il/Symbol.hpp"3132TR_RuntimeHelper33J9::ARM::UnresolvedDataSnippet::getHelper()34{35if (getDataSymbol()->getShadowSymbol() != NULL) // instance data36{37if (resolveForStore())38return TR_ARMinterpreterUnresolvedInstanceDataStoreGlue;39else40return TR_ARMinterpreterUnresolvedInstanceDataGlue;41}42if (getDataSymbol()->isClassObject()) // class object43{44if (getDataSymbol()->addressIsCPIndexOfStatic())45return TR_ARMinterpreterUnresolvedClassGlue2;46return TR_ARMinterpreterUnresolvedClassGlue;47}4849if (getDataSymbol()->isConstString()) // const string50return TR_ARMinterpreterUnresolvedStringGlue;5152if (getDataSymbol()->isConstMethodType())53return TR_interpreterUnresolvedMethodTypeGlue;5455if (getDataSymbol()->isConstMethodHandle())56return TR_interpreterUnresolvedMethodHandleGlue;5758if (getDataSymbol()->isCallSiteTableEntry())59return TR_interpreterUnresolvedCallSiteTableEntryGlue;6061if (getDataSymbol()->isMethodTypeTableEntry())62return TR_interpreterUnresolvedMethodTypeTableEntryGlue;6364if (resolveForStore())65return TR_ARMinterpreterUnresolvedStaticDataStoreGlue;66else67return TR_ARMinterpreterUnresolvedStaticDataGlue;6869}7071uint8_t *72J9::ARM::UnresolvedDataSnippet::emitSnippetBody()73{74uint8_t *cursor = cg()->getBinaryBufferCursor();7576getSnippetLabel()->setCodeLocation(cursor);7778*(int32_t *)cursor = encodeHelperBranchAndLink(cg()->symRefTab()->findOrCreateRuntimeHelper(getHelper()), cursor, getNode(), cg()); // BL resolve79cursor += 4;8081*(int32_t *)cursor = (intptr_t)getAddressOfDataReference(); // Code Cache RA82cg()->addExternalRelocation(new (cg()->trHeapMemory()) TR::ExternalRelocation(83cursor,84NULL,85TR_AbsoluteMethodAddress, cg()), __FILE__, __LINE__, getNode());86cursor += 4;8788if (getDataSymbol()->isCallSiteTableEntry())89{90*(int32_t *)cursor = getDataSymbol()->castToCallSiteTableEntrySymbol()->getCallSiteIndex();91}92else if (getDataSymbol()->isMethodTypeTableEntry())93{94*(int32_t *)cursor = getDataSymbol()->castToMethodTypeTableEntrySymbol()->getMethodTypeIndex();95}96else97{98*(int32_t *)cursor = getDataSymbolReference()->getCPIndex(); // CP index99}100cursor += 4;101102*(int32_t *)cursor = (intptr_t)getDataSymbolReference()->getOwningMethod(cg()->comp())->constantPool(); // CP103cg()->addExternalRelocation(new (cg()->trHeapMemory()) TR::ExternalRelocation(104cursor,105*(uint8_t **)cursor,106getNode() ? (uint8_t *)getNode()->getInlinedSiteIndex() : (uint8_t *)-1,107TR_ConstantPool, cg()), __FILE__, __LINE__, getNode());108cursor += 4;109110*(int32_t *)cursor = getMemoryReference()->getOffset(); // offset111if (getDataSymbol()->isConstObjectRef())112{113// reset the offset to NULL114// the resolve + picbuilder will fully provide the addr to use115*(int32_t *)cursor = 0;116}117cursor += 4;118119*(int32_t *)cursor = 0xE3A00000; // Template (mov immed)120toRealRegister(getMemoryReference()->getModBase())->setRegisterFieldRD((uint32_t *)cursor);121return cursor+4;122}123124uint32_t125J9::ARM::UnresolvedDataSnippet::getLength(int32_t estimatedSnippetStart)126{127return 6 * 4;128}129130131132