1 /* 2 * Copyright (c) 1999, 2010, 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 "oops/klassOop.hpp" 31 #include "runtime/thread.hpp" 32 #include "shark/llvmHeaders.hpp" 33 #include "shark/llvmValue.hpp" 34 35 class SharkRuntime : public AllStatic { 36 // VM calls 37 public: 38 static int find_exception_handler(JavaThread* thread, 39 int* indexes, 40 int num_indexes); 41 42 static void monitorenter(JavaThread* thread, BasicObjectLock* lock); 43 static void monitorexit(JavaThread* thread, BasicObjectLock* lock); 44 45 static void new_instance(JavaThread* thread, int index); 46 static void newarray(JavaThread* thread, BasicType type, int size); 47 static void anewarray(JavaThread* thread, int index, int size); 48 static void multianewarray(JavaThread* thread, 49 int index, 50 int ndims, 51 int* dims); 52 53 static void register_finalizer(JavaThread* thread, oop object); 54 55 static void throw_ArithmeticException(JavaThread* thread, 56 const char* file, 57 int line); 58 static void throw_ArrayIndexOutOfBoundsException(JavaThread* thread, 59 const char* file, 60 int line, 61 int index); 62 static void throw_ClassCastException(JavaThread* thread, 63 const char* file, 64 int line); 65 static void throw_NullPointerException(JavaThread* thread, 66 const char* file, 67 int line); 68 69 // Helpers for VM calls 70 private: 71 static const SharkFrame* last_frame(JavaThread *thread) { 72 return thread->last_frame().zero_sharkframe(); 73 } 74 static methodOop method(JavaThread *thread) { 75 return last_frame(thread)->method(); 76 } 77 static address bcp(JavaThread *thread, int bci) { 78 return method(thread)->code_base() + bci; 79 } 80 static int two_byte_index(JavaThread *thread, int bci) { 81 return Bytes::get_Java_u2(bcp(thread, bci) + 1); 82 } 83 static intptr_t tos_at(JavaThread *thread, int offset) { 84 return *(thread->zero_stack()->sp() + offset); 85 } 86 87 // Non-VM calls 88 public: 89 static void dump(const char *name, intptr_t value); 90 static bool is_subtype_of(klassOop check_klass, klassOop object_klass); 91 static int uncommon_trap(JavaThread* thread, int trap_request); 92 }; 93 94 #endif // SHARE_VM_SHARK_SHARKRUNTIME_HPP