1 /* 2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. 3 * Copyright 2008, 2009, 2010 Red Hat, Inc. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 * 24 */ 25 26 #ifndef SHARE_VM_SHARK_SHARKRUNTIME_HPP 27 #define SHARE_VM_SHARK_SHARKRUNTIME_HPP 28 29 #include "memory/allocation.hpp" 30 #include "runtime/thread.hpp" 31 #include "shark/llvmHeaders.hpp" 32 #include "shark/llvmValue.hpp" 33 34 class SharkRuntime : public AllStatic { 35 // VM calls 36 public: 37 static int find_exception_handler(JavaThread* thread, 38 int* indexes, 39 int num_indexes); 40 41 static void monitorenter(JavaThread* thread, BasicObjectLock* lock); 42 static void monitorexit(JavaThread* thread, BasicObjectLock* lock); 43 44 static void new_instance(JavaThread* thread, int index); 45 static void newarray(JavaThread* thread, BasicType type, int size); 46 static void anewarray(JavaThread* thread, int index, int size); 47 static void multianewarray(JavaThread* thread, 48 int index, 49 int ndims, 50 int* dims); 51 52 static void register_finalizer(JavaThread* thread, oop object); 53 54 static void throw_ArithmeticException(JavaThread* thread, 55 const char* file, 56 int line); 57 static void throw_ArrayIndexOutOfBoundsException(JavaThread* thread, 58 const char* file, 59 int line, 60 int index); 61 static void throw_ClassCastException(JavaThread* thread, 62 const char* file, 63 int line); 64 static void throw_NullPointerException(JavaThread* thread, 65 const char* file, 66 int line); 67 68 // Helpers for VM calls 69 private: 70 static const SharkFrame* last_frame(JavaThread *thread) { 71 return thread->last_frame().zero_sharkframe(); 72 } 73 static Method* method(JavaThread *thread) { 74 return last_frame(thread)->method(); 75 } 76 static address bcp(JavaThread *thread, int bci) { 77 return method(thread)->code_base() + bci; 78 } 79 static int two_byte_index(JavaThread *thread, int bci) { 80 return Bytes::get_Java_u2(bcp(thread, bci) + 1); 81 } 82 static intptr_t tos_at(JavaThread *thread, int offset) { 83 return *(thread->zero_stack()->sp() + offset); 84 } 85 86 // Non-VM calls 87 public: 88 static void dump(const char *name, intptr_t value); 89 static bool is_subtype_of(Klass* check_klass, Klass* object_klass); 90 static int uncommon_trap(JavaThread* thread, int trap_request); 91 }; 92 93 #endif // SHARE_VM_SHARK_SHARKRUNTIME_HPP