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, 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 | #include "precompiled.hpp" |
stefank@2314 | 27 | #include "oops/arrayOop.hpp" |
stefank@2314 | 28 | #include "oops/oop.hpp" |
stefank@2314 | 29 | #include "shark/llvmHeaders.hpp" |
stefank@2314 | 30 | #include "shark/sharkContext.hpp" |
stefank@2314 | 31 | #include "utilities/globalDefinitions.hpp" |
twisti@2047 | 32 | |
twisti@2047 | 33 | using namespace llvm; |
twisti@2047 | 34 | |
twisti@2047 | 35 | SharkContext::SharkContext(const char* name) |
twisti@2047 | 36 | : LLVMContext(), |
twisti@2047 | 37 | _free_queue(NULL) { |
twisti@2047 | 38 | // Create a module to build our functions into |
twisti@2047 | 39 | _module = new Module(name, *this); |
twisti@2047 | 40 | |
twisti@2047 | 41 | // Create basic types |
twisti@2047 | 42 | _void_type = Type::getVoidTy(*this); |
twisti@2047 | 43 | _bit_type = Type::getInt1Ty(*this); |
twisti@2047 | 44 | _jbyte_type = Type::getInt8Ty(*this); |
twisti@2047 | 45 | _jshort_type = Type::getInt16Ty(*this); |
twisti@2047 | 46 | _jint_type = Type::getInt32Ty(*this); |
twisti@2047 | 47 | _jlong_type = Type::getInt64Ty(*this); |
twisti@2047 | 48 | _jfloat_type = Type::getFloatTy(*this); |
twisti@2047 | 49 | _jdouble_type = Type::getDoubleTy(*this); |
twisti@2047 | 50 | |
twisti@2047 | 51 | // Create compound types |
twisti@2047 | 52 | _itableOffsetEntry_type = PointerType::getUnqual( |
twisti@2047 | 53 | ArrayType::get(jbyte_type(), itableOffsetEntry::size() * wordSize)); |
twisti@2047 | 54 | |
twisti@2047 | 55 | _klass_type = PointerType::getUnqual( |
twisti@2047 | 56 | ArrayType::get(jbyte_type(), sizeof(Klass))); |
twisti@2047 | 57 | |
twisti@2047 | 58 | _jniEnv_type = PointerType::getUnqual( |
twisti@2047 | 59 | ArrayType::get(jbyte_type(), sizeof(JNIEnv))); |
twisti@2047 | 60 | |
twisti@2047 | 61 | _jniHandleBlock_type = PointerType::getUnqual( |
twisti@2047 | 62 | ArrayType::get(jbyte_type(), sizeof(JNIHandleBlock))); |
twisti@2047 | 63 | |
twisti@2047 | 64 | _methodOop_type = PointerType::getUnqual( |
twisti@2047 | 65 | ArrayType::get(jbyte_type(), sizeof(methodOopDesc))); |
twisti@2047 | 66 | |
twisti@2047 | 67 | _monitor_type = ArrayType::get( |
twisti@2047 | 68 | jbyte_type(), frame::interpreter_frame_monitor_size() * wordSize); |
twisti@2047 | 69 | |
twisti@2047 | 70 | _oop_type = PointerType::getUnqual( |
twisti@2047 | 71 | ArrayType::get(jbyte_type(), sizeof(oopDesc))); |
twisti@2047 | 72 | |
twisti@2047 | 73 | _thread_type = PointerType::getUnqual( |
twisti@2047 | 74 | ArrayType::get(jbyte_type(), sizeof(JavaThread))); |
twisti@2047 | 75 | |
twisti@2047 | 76 | _zeroStack_type = PointerType::getUnqual( |
twisti@2047 | 77 | ArrayType::get(jbyte_type(), sizeof(ZeroStack))); |
twisti@2047 | 78 | |
twisti@2047 | 79 | std::vector<const Type*> params; |
twisti@2047 | 80 | params.push_back(methodOop_type()); |
twisti@2047 | 81 | params.push_back(intptr_type()); |
twisti@2047 | 82 | params.push_back(thread_type()); |
twisti@2047 | 83 | _entry_point_type = FunctionType::get(jint_type(), params, false); |
twisti@2047 | 84 | |
twisti@2047 | 85 | params.clear(); |
twisti@2047 | 86 | params.push_back(methodOop_type()); |
twisti@2047 | 87 | params.push_back(PointerType::getUnqual(jbyte_type())); |
twisti@2047 | 88 | params.push_back(intptr_type()); |
twisti@2047 | 89 | params.push_back(thread_type()); |
twisti@2047 | 90 | _osr_entry_point_type = FunctionType::get(jint_type(), params, false); |
twisti@2047 | 91 | |
twisti@2047 | 92 | // Create mappings |
twisti@2047 | 93 | for (int i = 0; i < T_CONFLICT; i++) { |
twisti@2047 | 94 | switch (i) { |
twisti@2047 | 95 | case T_BOOLEAN: |
twisti@2047 | 96 | _to_stackType[i] = jint_type(); |
twisti@2047 | 97 | _to_arrayType[i] = jbyte_type(); |
twisti@2047 | 98 | break; |
twisti@2047 | 99 | |
twisti@2047 | 100 | case T_BYTE: |
twisti@2047 | 101 | _to_stackType[i] = jint_type(); |
twisti@2047 | 102 | _to_arrayType[i] = jbyte_type(); |
twisti@2047 | 103 | break; |
twisti@2047 | 104 | |
twisti@2047 | 105 | case T_CHAR: |
twisti@2047 | 106 | _to_stackType[i] = jint_type(); |
twisti@2047 | 107 | _to_arrayType[i] = jshort_type(); |
twisti@2047 | 108 | break; |
twisti@2047 | 109 | |
twisti@2047 | 110 | case T_SHORT: |
twisti@2047 | 111 | _to_stackType[i] = jint_type(); |
twisti@2047 | 112 | _to_arrayType[i] = jshort_type(); |
twisti@2047 | 113 | break; |
twisti@2047 | 114 | |
twisti@2047 | 115 | case T_INT: |
twisti@2047 | 116 | _to_stackType[i] = jint_type(); |
twisti@2047 | 117 | _to_arrayType[i] = jint_type(); |
twisti@2047 | 118 | break; |
twisti@2047 | 119 | |
twisti@2047 | 120 | case T_LONG: |
twisti@2047 | 121 | _to_stackType[i] = jlong_type(); |
twisti@2047 | 122 | _to_arrayType[i] = jlong_type(); |
twisti@2047 | 123 | break; |
twisti@2047 | 124 | |
twisti@2047 | 125 | case T_FLOAT: |
twisti@2047 | 126 | _to_stackType[i] = jfloat_type(); |
twisti@2047 | 127 | _to_arrayType[i] = jfloat_type(); |
twisti@2047 | 128 | break; |
twisti@2047 | 129 | |
twisti@2047 | 130 | case T_DOUBLE: |
twisti@2047 | 131 | _to_stackType[i] = jdouble_type(); |
twisti@2047 | 132 | _to_arrayType[i] = jdouble_type(); |
twisti@2047 | 133 | break; |
twisti@2047 | 134 | |
twisti@2047 | 135 | case T_OBJECT: |
twisti@2047 | 136 | case T_ARRAY: |
twisti@2047 | 137 | _to_stackType[i] = oop_type(); |
twisti@2047 | 138 | _to_arrayType[i] = oop_type(); |
twisti@2047 | 139 | break; |
twisti@2047 | 140 | |
twisti@2047 | 141 | case T_ADDRESS: |
twisti@2047 | 142 | _to_stackType[i] = intptr_type(); |
twisti@2047 | 143 | _to_arrayType[i] = NULL; |
twisti@2047 | 144 | break; |
twisti@2047 | 145 | |
twisti@2047 | 146 | default: |
twisti@2047 | 147 | _to_stackType[i] = NULL; |
twisti@2047 | 148 | _to_arrayType[i] = NULL; |
twisti@2047 | 149 | } |
twisti@2047 | 150 | } |
twisti@2047 | 151 | } |
twisti@2047 | 152 | |
twisti@2047 | 153 | class SharkFreeQueueItem : public CHeapObj { |
twisti@2047 | 154 | public: |
twisti@2047 | 155 | SharkFreeQueueItem(llvm::Function* function, SharkFreeQueueItem *next) |
twisti@2047 | 156 | : _function(function), _next(next) {} |
twisti@2047 | 157 | |
twisti@2047 | 158 | private: |
twisti@2047 | 159 | llvm::Function* _function; |
twisti@2047 | 160 | SharkFreeQueueItem* _next; |
twisti@2047 | 161 | |
twisti@2047 | 162 | public: |
twisti@2047 | 163 | llvm::Function* function() const { |
twisti@2047 | 164 | return _function; |
twisti@2047 | 165 | } |
twisti@2047 | 166 | SharkFreeQueueItem* next() const { |
twisti@2047 | 167 | return _next; |
twisti@2047 | 168 | } |
twisti@2047 | 169 | }; |
twisti@2047 | 170 | |
twisti@2047 | 171 | void SharkContext::push_to_free_queue(Function* function) { |
twisti@2047 | 172 | _free_queue = new SharkFreeQueueItem(function, _free_queue); |
twisti@2047 | 173 | } |
twisti@2047 | 174 | |
twisti@2047 | 175 | Function* SharkContext::pop_from_free_queue() { |
twisti@2047 | 176 | if (_free_queue == NULL) |
twisti@2047 | 177 | return NULL; |
twisti@2047 | 178 | |
twisti@2047 | 179 | SharkFreeQueueItem *item = _free_queue; |
twisti@2047 | 180 | Function *function = item->function(); |
twisti@2047 | 181 | _free_queue = item->next(); |
twisti@2047 | 182 | delete item; |
twisti@2047 | 183 | return function; |
twisti@2047 | 184 | } |