src/share/vm/shark/sharkBuilder.hpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

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

mercurial