Tue, 23 Nov 2010 13:22:55 -0800
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 2009 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_SHARKNATIVEWRAPPER_HPP |
stefank@2314 | 27 | #define SHARE_VM_SHARK_SHARKNATIVEWRAPPER_HPP |
stefank@2314 | 28 | |
stefank@2314 | 29 | #include "runtime/handles.hpp" |
stefank@2314 | 30 | #include "shark/llvmHeaders.hpp" |
stefank@2314 | 31 | #include "shark/sharkBuilder.hpp" |
stefank@2314 | 32 | #include "shark/sharkContext.hpp" |
stefank@2314 | 33 | #include "shark/sharkInvariants.hpp" |
stefank@2314 | 34 | #include "shark/sharkStack.hpp" |
stefank@2314 | 35 | |
twisti@2047 | 36 | class SharkNativeWrapper : public SharkCompileInvariants { |
twisti@2047 | 37 | friend class SharkStackWithNativeFrame; |
twisti@2047 | 38 | |
twisti@2047 | 39 | public: |
twisti@2047 | 40 | static SharkNativeWrapper* build(SharkBuilder* builder, |
twisti@2047 | 41 | methodHandle target, |
twisti@2047 | 42 | const char* name, |
twisti@2047 | 43 | BasicType* arg_types, |
twisti@2047 | 44 | BasicType return_type) { |
twisti@2047 | 45 | return new SharkNativeWrapper(builder, |
twisti@2047 | 46 | target, |
twisti@2047 | 47 | name, |
twisti@2047 | 48 | arg_types, |
twisti@2047 | 49 | return_type); |
twisti@2047 | 50 | } |
twisti@2047 | 51 | |
twisti@2047 | 52 | private: |
twisti@2047 | 53 | SharkNativeWrapper(SharkBuilder* builder, |
twisti@2047 | 54 | methodHandle target, |
twisti@2047 | 55 | const char* name, |
twisti@2047 | 56 | BasicType* arg_types, |
twisti@2047 | 57 | BasicType return_type) |
twisti@2047 | 58 | : SharkCompileInvariants(NULL, builder), |
twisti@2047 | 59 | _target(target), |
twisti@2047 | 60 | _arg_types(arg_types), |
twisti@2047 | 61 | _return_type(return_type), |
twisti@2047 | 62 | _lock_slot_offset(0) { initialize(name); } |
twisti@2047 | 63 | |
twisti@2047 | 64 | private: |
twisti@2047 | 65 | void initialize(const char* name); |
twisti@2047 | 66 | |
twisti@2047 | 67 | private: |
twisti@2047 | 68 | methodHandle _target; |
twisti@2047 | 69 | BasicType* _arg_types; |
twisti@2047 | 70 | BasicType _return_type; |
twisti@2047 | 71 | llvm::Function* _function; |
twisti@2047 | 72 | SharkStack* _stack; |
twisti@2047 | 73 | llvm::Value* _oop_tmp_slot; |
twisti@2047 | 74 | OopMapSet* _oop_maps; |
twisti@2047 | 75 | int _receiver_slot_offset; |
twisti@2047 | 76 | int _lock_slot_offset; |
twisti@2047 | 77 | |
twisti@2047 | 78 | // The method being compiled. |
twisti@2047 | 79 | protected: |
twisti@2047 | 80 | methodHandle target() const { |
twisti@2047 | 81 | return _target; |
twisti@2047 | 82 | } |
twisti@2047 | 83 | |
twisti@2047 | 84 | // Properties of the method. |
twisti@2047 | 85 | protected: |
twisti@2047 | 86 | int arg_size() const { |
twisti@2047 | 87 | return target()->size_of_parameters(); |
twisti@2047 | 88 | } |
twisti@2047 | 89 | BasicType arg_type(int i) const { |
twisti@2047 | 90 | return _arg_types[i]; |
twisti@2047 | 91 | } |
twisti@2047 | 92 | BasicType return_type() const { |
twisti@2047 | 93 | return _return_type; |
twisti@2047 | 94 | } |
twisti@2047 | 95 | bool is_static() const { |
twisti@2047 | 96 | return target()->is_static(); |
twisti@2047 | 97 | } |
twisti@2047 | 98 | bool is_synchronized() const { |
twisti@2047 | 99 | return target()->is_synchronized(); |
twisti@2047 | 100 | } |
twisti@2047 | 101 | bool is_returning_oop() const { |
twisti@2047 | 102 | return target()->is_returning_oop(); |
twisti@2047 | 103 | } |
twisti@2047 | 104 | |
twisti@2047 | 105 | // The LLVM function we are building. |
twisti@2047 | 106 | public: |
twisti@2047 | 107 | llvm::Function* function() const { |
twisti@2047 | 108 | return _function; |
twisti@2047 | 109 | } |
twisti@2047 | 110 | |
twisti@2047 | 111 | // The Zero stack and our frame on it. |
twisti@2047 | 112 | protected: |
twisti@2047 | 113 | SharkStack* stack() const { |
twisti@2047 | 114 | return _stack; |
twisti@2047 | 115 | } |
twisti@2047 | 116 | |
twisti@2047 | 117 | // Temporary oop storage. |
twisti@2047 | 118 | protected: |
twisti@2047 | 119 | llvm::Value* oop_tmp_slot() const { |
twisti@2047 | 120 | assert(is_static() || is_returning_oop(), "should be"); |
twisti@2047 | 121 | return _oop_tmp_slot; |
twisti@2047 | 122 | } |
twisti@2047 | 123 | |
twisti@2047 | 124 | // Information required by nmethod::new_native_nmethod(). |
twisti@2047 | 125 | public: |
twisti@2047 | 126 | int frame_size() const { |
twisti@2047 | 127 | return stack()->oopmap_frame_size(); |
twisti@2047 | 128 | } |
twisti@2047 | 129 | ByteSize receiver_offset() const { |
twisti@2047 | 130 | return in_ByteSize(_receiver_slot_offset * wordSize); |
twisti@2047 | 131 | } |
twisti@2047 | 132 | ByteSize lock_offset() const { |
twisti@2047 | 133 | return in_ByteSize(_lock_slot_offset * wordSize); |
twisti@2047 | 134 | } |
twisti@2047 | 135 | OopMapSet* oop_maps() const { |
twisti@2047 | 136 | return _oop_maps; |
twisti@2047 | 137 | } |
twisti@2047 | 138 | |
twisti@2047 | 139 | // Helpers. |
twisti@2047 | 140 | private: |
twisti@2047 | 141 | llvm::BasicBlock* CreateBlock(const char* name = "") const { |
twisti@2047 | 142 | return llvm::BasicBlock::Create(SharkContext::current(), name, function()); |
twisti@2047 | 143 | } |
twisti@2047 | 144 | llvm::Value* thread_state_address() const { |
twisti@2047 | 145 | return builder()->CreateAddressOfStructEntry( |
twisti@2047 | 146 | thread(), JavaThread::thread_state_offset(), |
twisti@2047 | 147 | llvm::PointerType::getUnqual(SharkType::jint_type()), |
twisti@2047 | 148 | "thread_state_address"); |
twisti@2047 | 149 | } |
twisti@2047 | 150 | llvm::Value* pending_exception_address() const { |
twisti@2047 | 151 | return builder()->CreateAddressOfStructEntry( |
twisti@2047 | 152 | thread(), Thread::pending_exception_offset(), |
twisti@2047 | 153 | llvm::PointerType::getUnqual(SharkType::oop_type()), |
twisti@2047 | 154 | "pending_exception_address"); |
twisti@2047 | 155 | } |
twisti@2047 | 156 | void CreateSetThreadState(JavaThreadState state) const { |
twisti@2047 | 157 | builder()->CreateStore( |
twisti@2047 | 158 | LLVMValue::jint_constant(state), thread_state_address()); |
twisti@2047 | 159 | } |
twisti@2047 | 160 | void CreateWriteMemorySerializePage() const { |
twisti@2047 | 161 | builder()->CreateStore( |
twisti@2047 | 162 | LLVMValue::jint_constant(1), |
twisti@2047 | 163 | builder()->CreateIntToPtr( |
twisti@2047 | 164 | builder()->CreateAdd( |
twisti@2047 | 165 | LLVMValue::intptr_constant( |
twisti@2047 | 166 | (intptr_t) os::get_memory_serialize_page()), |
twisti@2047 | 167 | builder()->CreateAnd( |
twisti@2047 | 168 | builder()->CreateLShr( |
twisti@2047 | 169 | builder()->CreatePtrToInt(thread(), SharkType::intptr_type()), |
twisti@2047 | 170 | LLVMValue::intptr_constant(os::get_serialize_page_shift_count())), |
twisti@2047 | 171 | LLVMValue::intptr_constant(os::get_serialize_page_mask()))), |
twisti@2047 | 172 | llvm::PointerType::getUnqual(SharkType::jint_type()))); |
twisti@2047 | 173 | } |
twisti@2047 | 174 | void CreateResetHandleBlock() const { |
twisti@2047 | 175 | llvm::Value *active_handles = builder()->CreateValueOfStructEntry( |
twisti@2047 | 176 | thread(), |
twisti@2047 | 177 | JavaThread::active_handles_offset(), |
twisti@2047 | 178 | SharkType::jniHandleBlock_type(), |
twisti@2047 | 179 | "active_handles"); |
twisti@2047 | 180 | builder()->CreateStore( |
twisti@2047 | 181 | LLVMValue::intptr_constant(0), |
twisti@2047 | 182 | builder()->CreateAddressOfStructEntry( |
twisti@2047 | 183 | active_handles, |
twisti@2047 | 184 | in_ByteSize(JNIHandleBlock::top_offset_in_bytes()), |
twisti@2047 | 185 | llvm::PointerType::getUnqual(SharkType::intptr_type()), |
twisti@2047 | 186 | "top")); |
twisti@2047 | 187 | } |
twisti@2047 | 188 | llvm::LoadInst* CreateLoadPendingException() const { |
twisti@2047 | 189 | return builder()->CreateLoad( |
twisti@2047 | 190 | pending_exception_address(), "pending_exception"); |
twisti@2047 | 191 | } |
twisti@2047 | 192 | }; |
stefank@2314 | 193 | |
stefank@2314 | 194 | #endif // SHARE_VM_SHARK_SHARKNATIVEWRAPPER_HPP |