Mercurial > hg > truffle
comparison src/share/vm/graal/graalInterpreterToVM.cpp @ 5747:120820e30baa
added basic high-level interpreter support to HotSpot
author | Christian Haeubl <haeubl@ssw.jku.at> |
---|---|
date | Tue, 03 Jul 2012 16:56:40 +0200 |
parents | |
children | d5f7e737827f |
comparison
equal
deleted
inserted
replaced
5746:17d2c3b72762 | 5747:120820e30baa |
---|---|
1 /* | |
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 | |
24 #include "precompiled.hpp" | |
25 #include "prims/jni.h" | |
26 #include "graal/graalInterpreterToVM.hpp" | |
27 #include "graal/graalCompiler.hpp" | |
28 #include "graal/graalCompilerToVM.hpp" | |
29 | |
30 #ifdef HIGH_LEVEL_INTERPRETER | |
31 | |
32 // public Object invoke(HotSpotResolvedJavaMethod method, boolean highLevel, Object... args); | |
33 JNIEXPORT jobject JNICALL Java_com_oracle_graal_hotspot_HotSpotRuntimeInterpreterInterface_invoke(JNIEnv *env, jobject, jobject method, jobject args) { | |
34 TRACE_graal_3("InterpreterToVM::invoke"); | |
35 | |
36 VM_ENTRY_MARK; | |
37 HandleMark hm; | |
38 | |
39 assert(method != NULL, "just checking"); | |
40 assert(thread->is_Java_thread(), "must be"); | |
41 methodHandle mh = getMethodFromHotSpotMethod(method); | |
42 | |
43 JavaCallArguments jca; | |
44 JavaArgumentUnboxer jap(mh->signature(), &jca, (arrayOop) JNIHandles::resolve(args), mh->is_static()); | |
45 | |
46 #ifndef PRODUCT | |
47 if (PrintHighLevelInterpreterVMTransitions) { | |
48 ResourceMark rm; | |
49 tty->print_cr("High level interpreter -> VM (%s)", mh->name_and_sig_as_C_string()); | |
50 } | |
51 #endif | |
52 | |
53 JavaValue result(jap.get_ret_type()); | |
54 thread->set_high_level_interpreter_in_vm(true); | |
55 JavaCalls::call(&result, mh, &jca, THREAD); | |
56 thread->set_high_level_interpreter_in_vm(false); | |
57 | |
58 #ifndef PRODUCT | |
59 if (PrintHighLevelInterpreterVMTransitions) { | |
60 ResourceMark rm; | |
61 tty->print_cr("VM (%s) -> high level interpreter", mh->name_and_sig_as_C_string()); | |
62 } | |
63 #endif | |
64 | |
65 if (thread->has_pending_exception()) { | |
66 return NULL; | |
67 } | |
68 | |
69 if (jap.get_ret_type() == T_VOID) { | |
70 return NULL; | |
71 } else if (jap.get_ret_type() == T_OBJECT || jap.get_ret_type() == T_ARRAY) { | |
72 return JNIHandles::make_local((oop) result.get_jobject()); | |
73 } else { | |
74 oop o = java_lang_boxing_object::create(jap.get_ret_type(), (jvalue *) result.get_value_addr(), CHECK_NULL); | |
75 return JNIHandles::make_local(o); | |
76 } | |
77 } | |
78 | |
79 #define CC (char*) /*cast a literal from (const char*)*/ | |
80 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(Java_com_oracle_graal_hotspot_HotSpotRuntimeInterpreterInterface_##f)) | |
81 | |
82 #define RESOLVED_METHOD "Lcom/oracle/graal/api/meta/ResolvedJavaMethod;" | |
83 #define OBJECT "Ljava/lang/Object;" | |
84 | |
85 JNINativeMethod InterpreterToVM_methods[] = { | |
86 {CC"invoke", CC"("RESOLVED_METHOD "["OBJECT")"OBJECT, FN_PTR(invoke)} | |
87 }; | |
88 | |
89 int InterpreterToVM_methods_count() { | |
90 return sizeof(InterpreterToVM_methods) / sizeof(JNINativeMethod); | |
91 } | |
92 | |
93 #endif // HIGH_LEVEL_INTERPRETER |