Path: blob/master/runtime/compiler/z/codegen/J9ZSnippet.cpp
6004 views
/*******************************************************************************1* Copyright (c) 2000, 2016 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/Snippet.hpp"23#include "codegen/CodeGenerator.hpp"24#include "codegen/InstOpCode.hpp"25#include "infra/Assert.hpp"2627/**28* Helper method to insert Runtime Instrumentation Hooks RION or RIOFF in snippet29*30* @param cg Code Generator Pointer31* @param cursor Current binary encoding cursor32* @param op Runtime Instrumentation opcode: TR::InstOpCode::RION or TR::InstOpCode::RIOFF33* @param isPrivateLinkage Whether the snippet is involved in a private JIT linkage (i.e. Call Helper to JITCODE)34* @return Updated binary encoding cursor after RI hook generation.35*/36uint8_t *37J9::Z::Snippet::generateRuntimeInstrumentationOnOffInstruction(TR::CodeGenerator *cg, uint8_t *cursor, TR::InstOpCode::Mnemonic op, bool isPrivateLinkage)38{39if (cg->getSupportsRuntimeInstrumentation())40{41if (!isPrivateLinkage || cg->getEnableRIOverPrivateLinkage())42{43if (op == TR::InstOpCode::RION)44*(int32_t *) cursor = 0xAA010000;45else if (op == TR::InstOpCode::RIOFF)46*(int32_t *) cursor = 0xAA030000;47else48TR_ASSERT( 0, "Unexpected RI opcode.");49cursor += sizeof(int32_t);50}51}52return cursor;53}545556/**57* Helper method to query the length of Runtime Instrumentation Hooks RION or RIOFF in snippet58*59* @param cg Code Generator Pointer60* @param isPrivateLinkage Whether the snippet is involved in a private JIT linkage (i.e. Call Helper to JITCODE)61* @return The length of RION or RIOFF encoding if generated. Zero otherwise.62*/63uint32_t64J9::Z::Snippet::getRuntimeInstrumentationOnOffInstructionLength(TR::CodeGenerator *cg, bool isPrivateLinkage)65{66if (cg->getSupportsRuntimeInstrumentation())67{68if (!isPrivateLinkage || cg->getEnableRIOverPrivateLinkage())69return sizeof(int32_t); // Both RION and RIOFF are 32-bit (4-byte) instructions.70}71return 0;72}737475