Path: blob/master/runtime/compiler/arm/codegen/ARMHelperCallSnippet.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/ARMHelperCallSnippet.hpp"2324#include <stdint.h>25#include "codegen/CodeGenerator.hpp"26#include "codegen/Relocation.hpp"27#include "codegen/SnippetGCMap.hpp"28#include "env/jittypes.h"29#include "il/LabelSymbol.hpp"30#include "il/MethodSymbol.hpp"31#include "il/RegisterMappedSymbol.hpp"32#include "il/ResolvedMethodSymbol.hpp"33#include "il/StaticSymbol.hpp"34#include "il/Symbol.hpp"35#include "il/SymbolReference.hpp"36#include "runtime/CodeCacheManager.hpp"3738uint8_t *TR::ARMHelperCallSnippet::emitSnippetBody()39{40uint8_t *buffer = cg()->getBinaryBufferCursor();41intptr_t distance = (intptr_t)getDestination()->getSymbol()->castToMethodSymbol()->getMethodAddress() - (intptr_t)buffer - 8;4243getSnippetLabel()->setCodeLocation(buffer);4445if (!(distance>=BRANCH_BACKWARD_LIMIT && distance<=BRANCH_FORWARD_LIMIT))46{47distance = TR::CodeCacheManager::instance()->findHelperTrampoline(getDestination()->getReferenceNumber(), (void *)buffer) - (intptr_t)buffer - 8;48TR_ASSERT(distance>=BRANCH_BACKWARD_LIMIT && distance<=BRANCH_FORWARD_LIMIT,49"CodeCache is more than 32MB.\n");50}5152// b|bl distance53*(int32_t *)buffer = 0xea000000 | ((distance >> 2)& 0x00ffffff);54if (_restartLabel != NULL)55*(int32_t *)buffer |= 0x01000000;56cg()->addExternalRelocation(new (cg()->trHeapMemory()) TR::ExternalRelocation(57buffer,58(uint8_t *)getDestination(),59TR_HelperAddress, cg()), __FILE__, __LINE__, getNode());60buffer += 4;6162gcMap().registerStackMap(buffer, cg());6364if (_restartLabel != NULL)65{66int32_t returnDistance = _restartLabel->getCodeLocation() - buffer - 8 ;67*(int32_t *)buffer = 0xea000000 | ((returnDistance >> 2) & 0x00ffffff);68buffer += 4;69}7071return buffer;72}7374uint32_t TR::ARMHelperCallSnippet::getLength(int32_t estimatedSnippetStart)75{76return ((_restartLabel==NULL)?4:8);77}787980