src/share/vm/shark/sharkBuilder.hpp

Tue, 23 Nov 2010 13:22:55 -0800

author
stefank
date
Tue, 23 Nov 2010 13:22:55 -0800
changeset 2314
f95d63e2154a
parent 2047
d2ede61b7a12
child 4314
2cd5e15048e6
permissions
-rw-r--r--

6989984: Use standard include model for Hospot
Summary: Replaced MakeDeps and the includeDB files with more standardized solutions.
Reviewed-by: coleenp, kvn, kamg

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

mercurial