comparison src/share/vm/jvmci/jvmciCompilerToVM.hpp @ 21559:be896a1983c0

recast all Graal native code as JVMCI code (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Thu, 28 May 2015 15:36:48 +0200
parents src/share/vm/graal/graalCompilerToVM.hpp@a38a54030ea2
children
comparison
equal deleted inserted replaced
21558:d563baeca9df 21559:be896a1983c0
1 /*
2 * Copyright (c) 2011, 2013, 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 #ifndef SHARE_VM_JVMCI_JVMCI_COMPILER_TO_VM_HPP
25 #define SHARE_VM_JVMCI_JVMCI_COMPILER_TO_VM_HPP
26
27 #include "prims/jni.h"
28 #include "runtime/javaCalls.hpp"
29
30 class CompilerToVM {
31 public:
32 /**
33 * Tag bits used by lookupKlassInPool to distinguish the types in Java.
34 */
35 enum Tags {
36 KLASS_TAG = 0x0,
37 SYMBOL_TAG = 0x1
38 };
39
40 static intptr_t tag_pointer(Klass* klass) {
41 return ((intptr_t) klass) | KLASS_TAG;
42 }
43
44 static intptr_t tag_pointer(Symbol* symbol) {
45 return ((intptr_t) symbol) | SYMBOL_TAG;
46 }
47
48 // nothing here - no need to define the jni method implementations in a header file
49 };
50
51 extern JNINativeMethod CompilerToVM_methods[];
52 int CompilerToVM_methods_count();
53
54 inline Method* asMethod(jlong metaspaceMethod) {
55 return (Method*) (address) metaspaceMethod;
56 }
57
58 inline MethodData* asMethodData(jlong metaspaceMethodData) {
59 return (MethodData*) (address) metaspaceMethodData;
60 }
61
62 inline Klass* asKlass(jlong metaspaceKlass) {
63 return (Klass*) (address) metaspaceKlass;
64 }
65
66 class JavaArgumentUnboxer : public SignatureIterator {
67 protected:
68 JavaCallArguments* _jca;
69 arrayOop _args;
70 int _index;
71
72 oop next_arg(BasicType expectedType) {
73 assert(_index < _args->length(), "out of bounds");
74 oop arg=((objArrayOop) (_args))->obj_at(_index++);
75 assert(expectedType == T_OBJECT || java_lang_boxing_object::is_instance(arg, expectedType), "arg type mismatch");
76 return arg;
77 }
78
79 public:
80 JavaArgumentUnboxer(Symbol* signature, JavaCallArguments* jca, arrayOop args, bool is_static) : SignatureIterator(signature) {
81 this->_return_type = T_ILLEGAL;
82 _jca = jca;
83 _index = 0;
84 _args = args;
85 if (!is_static) {
86 _jca->push_oop(next_arg(T_OBJECT));
87 }
88 iterate();
89 assert(_index == args->length(), "arg count mismatch with signature");
90 }
91
92 inline void do_bool() { if (!is_return_type()) _jca->push_int(next_arg(T_BOOLEAN)->bool_field(java_lang_boxing_object::value_offset_in_bytes(T_BOOLEAN))); }
93 inline void do_char() { if (!is_return_type()) _jca->push_int(next_arg(T_CHAR)->char_field(java_lang_boxing_object::value_offset_in_bytes(T_CHAR))); }
94 inline void do_short() { if (!is_return_type()) _jca->push_int(next_arg(T_SHORT)->short_field(java_lang_boxing_object::value_offset_in_bytes(T_SHORT))); }
95 inline void do_byte() { if (!is_return_type()) _jca->push_int(next_arg(T_BYTE)->byte_field(java_lang_boxing_object::value_offset_in_bytes(T_BYTE))); }
96 inline void do_int() { if (!is_return_type()) _jca->push_int(next_arg(T_INT)->int_field(java_lang_boxing_object::value_offset_in_bytes(T_INT))); }
97
98 inline void do_long() { if (!is_return_type()) _jca->push_long(next_arg(T_LONG)->long_field(java_lang_boxing_object::value_offset_in_bytes(T_LONG))); }
99 inline void do_float() { if (!is_return_type()) _jca->push_float(next_arg(T_FLOAT)->float_field(java_lang_boxing_object::value_offset_in_bytes(T_FLOAT))); }
100 inline void do_double() { if (!is_return_type()) _jca->push_double(next_arg(T_DOUBLE)->double_field(java_lang_boxing_object::value_offset_in_bytes(T_DOUBLE))); }
101
102 inline void do_object() { _jca->push_oop(next_arg(T_OBJECT)); }
103 inline void do_object(int begin, int end) { if (!is_return_type()) _jca->push_oop(next_arg(T_OBJECT)); }
104 inline void do_array(int begin, int end) { if (!is_return_type()) _jca->push_oop(next_arg(T_OBJECT)); }
105 inline void do_void() { }
106 };
107
108 #endif // SHARE_VM_JVMCI_JVMCI_COMPILER_TO_VM_HPP