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