Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/shark/sharkBuilder.hpp
32285 views
/*1* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.2* Copyright 2008, 2009, 2010 Red Hat, Inc.3* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4*5* This code is free software; you can redistribute it and/or modify it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#ifndef SHARE_VM_SHARK_SHARKBUILDER_HPP26#define SHARE_VM_SHARK_SHARKBUILDER_HPP2728#include "ci/ciType.hpp"29#include "memory/barrierSet.hpp"30#include "memory/cardTableModRefBS.hpp"31#include "shark/llvmHeaders.hpp"32#include "shark/llvmValue.hpp"33#include "shark/sharkCodeBuffer.hpp"34#include "shark/sharkEntry.hpp"35#include "shark/sharkType.hpp"36#include "shark/sharkValue.hpp"37#include "utilities/debug.hpp"38#include "utilities/sizes.hpp"3940class SharkBuilder : public llvm::IRBuilder<> {41friend class SharkCompileInvariants;4243public:44SharkBuilder(SharkCodeBuffer* code_buffer);4546// The code buffer we are building into.47private:48SharkCodeBuffer* _code_buffer;4950protected:51SharkCodeBuffer* code_buffer() const {52return _code_buffer;53}5455public:56llvm::LoadInst* CreateAtomicLoad(llvm::Value* ptr,57unsigned align = HeapWordSize,58llvm::AtomicOrdering ordering = llvm::SequentiallyConsistent,59llvm::SynchronizationScope synchScope = llvm::CrossThread,60bool isVolatile = true,61const char *name = "");62llvm::StoreInst* CreateAtomicStore(llvm::Value *val,63llvm::Value *ptr,64unsigned align = HeapWordSize,65llvm::AtomicOrdering ordering = llvm::SequentiallyConsistent,66llvm::SynchronizationScope SynchScope = llvm::CrossThread,67bool isVolatile = true,68const char *name = "");6970// Helpers for accessing structures.71public:72llvm::Value* CreateAddressOfStructEntry(llvm::Value* base,73ByteSize offset,74llvm::Type* type,75const char *name = "");76llvm::LoadInst* CreateValueOfStructEntry(llvm::Value* base,77ByteSize offset,78llvm::Type* type,79const char *name = "");8081// Helpers for accessing arrays.82public:83llvm::LoadInst* CreateArrayLength(llvm::Value* arrayoop);84llvm::Value* CreateArrayAddress(llvm::Value* arrayoop,85llvm::Type* element_type,86int element_bytes,87ByteSize base_offset,88llvm::Value* index,89const char* name = "");90llvm::Value* CreateArrayAddress(llvm::Value* arrayoop,91BasicType basic_type,92ByteSize base_offset,93llvm::Value* index,94const char* name = "");95llvm::Value* CreateArrayAddress(llvm::Value* arrayoop,96BasicType basic_type,97llvm::Value* index,98const char* name = "");99100// Helpers for creating intrinsics and external functions.101private:102static llvm::Type* make_type(char type, bool void_ok);103static llvm::FunctionType* make_ftype(const char* params,104const char* ret);105llvm::Value* make_function(const char* name,106const char* params,107const char* ret);108llvm::Value* make_function(address func,109const char* params,110const char* ret);111112// Intrinsics and external functions, part 1: VM calls.113// These are functions declared with JRT_ENTRY and JRT_EXIT,114// macros which flip the thread from _thread_in_Java to115// _thread_in_vm and back. VM calls always safepoint, and can116// therefore throw exceptions. VM calls require of setup and117// teardown, and must be called with SharkTopLevelBlock::call_vm.118public:119llvm::Value* find_exception_handler();120llvm::Value* monitorenter();121llvm::Value* monitorexit();122llvm::Value* new_instance();123llvm::Value* newarray();124llvm::Value* anewarray();125llvm::Value* multianewarray();126llvm::Value* register_finalizer();127llvm::Value* safepoint();128llvm::Value* throw_ArithmeticException();129llvm::Value* throw_ArrayIndexOutOfBoundsException();130llvm::Value* throw_ClassCastException();131llvm::Value* throw_NullPointerException();132133// Intrinsics and external functions, part 2: High-level non-VM calls.134// These are called like normal functions. The stack is not set135// up for walking so they must not safepoint or throw exceptions,136// or call anything that might.137public:138llvm::Value* f2i();139llvm::Value* f2l();140llvm::Value* d2i();141llvm::Value* d2l();142llvm::Value* is_subtype_of();143llvm::Value* current_time_millis();144llvm::Value* sin();145llvm::Value* cos();146llvm::Value* tan();147llvm::Value* atan2();148llvm::Value* sqrt();149llvm::Value* log();150llvm::Value* log10();151llvm::Value* pow();152llvm::Value* exp();153llvm::Value* fabs();154llvm::Value* unsafe_field_offset_to_byte_offset();155llvm::Value* osr_migration_end();156157// Intrinsics and external functions, part 3: semi-VM calls.158// These are special cases that do VM call stuff but are invoked159// as though they were normal calls. This is acceptable so long160// as the method that calls them returns to its immediately that161// the semi VM call returns.162public:163llvm::Value* throw_StackOverflowError();164llvm::Value* uncommon_trap();165llvm::Value* deoptimized_entry_point();166167// Intrinsics and external functions, part 4: Native-Java transition.168// This is a special case in that it is invoked during a thread169// state transition. The stack must be set up for walking, and it170// may throw exceptions, but the state is _thread_in_native_trans.171public:172llvm::Value* check_special_condition_for_native_trans();173174// Intrinsics and external functions, part 5: Low-level non-VM calls.175// These have the same caveats as the high-level non-VM calls176// above. They are not accessed directly; rather, you should177// access them via the various Create* methods below.178private:179llvm::Value* cmpxchg_int();180llvm::Value* cmpxchg_ptr();181llvm::Value* frame_address();182llvm::Value* memset();183llvm::Value* unimplemented();184llvm::Value* should_not_reach_here();185llvm::Value* dump();186187// Public interface to low-level non-VM calls.188public:189llvm::CallInst* CreateGetFrameAddress();190llvm::CallInst* CreateMemset(llvm::Value* dst,191llvm::Value* value,192llvm::Value* len,193llvm::Value* align);194llvm::CallInst* CreateUnimplemented(const char* file, int line);195llvm::CallInst* CreateShouldNotReachHere(const char* file, int line);196NOT_PRODUCT(llvm::CallInst* CreateDump(llvm::Value* value));197198// HotSpot memory barriers199public:200void CreateUpdateBarrierSet(BarrierSet* bs, llvm::Value* field);201202// Helpers for accessing the code buffer.203public:204llvm::Value* code_buffer_address(int offset);205llvm::Value* CreateInlineOop(jobject object, const char* name = "");206llvm::Value* CreateInlineOop(ciObject* object, const char* name = "") {207return CreateInlineOop(object->constant_encoding(), name);208}209210llvm::Value* CreateInlineMetadata(Metadata* metadata, llvm::PointerType* type, const char* name = "");211llvm::Value* CreateInlineMetadata(ciMetadata* metadata, llvm::PointerType* type, const char* name = "") {212return CreateInlineMetadata(metadata->constant_encoding(), type, name);213}214llvm::Value* CreateInlineData(void* data,215size_t size,216llvm::Type* type,217const char* name = "");218219// Helpers for creating basic blocks.220// NB don't use unless SharkFunction::CreateBlock is unavailable.221// XXX these are hacky and should be removed.222public:223llvm::BasicBlock* GetBlockInsertionPoint() const;224llvm::BasicBlock* CreateBlock(llvm::BasicBlock* ip,225const char* name="") const;226};227#endif // SHARE_VM_SHARK_SHARKBUILDER_HPP228229230