annotate src/share/vm/c1x/c1x_Compiler.cpp @ 1422:3483ec571caf

* using reflected objects instead of oops * removed scratch from allocatable registers * instanceof xir snippet * arraylength xir snippet * exceptionobject xir snippet * VMEntries and VMExits as interfaces * calls to VMEntries and VMExits are routet through logging proxies
author Lukas Stadler <lukas.stadler@oracle.com>
date Mon, 02 Aug 2010 15:44:38 -0700
parents 6223633ce7dd
children 760213a60e8b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1410
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
1 /*
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
2 * Copyright 2000-2010 Sun Microsystems, Inc. All Rights Reserved.
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
4 *
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
7 * published by the Free Software Foundation.
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
8 *
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
13 * accompanied this code).
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
14 *
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
15 * You should have received a copy of the GNU General Public License version
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
18 *
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
21 * have any questions.
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
22 *
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
23 */
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
24
1406
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
25
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
26 # include "incls/_precompiled.incl"
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
27 # include "incls/_c1x_Compiler.cpp.incl"
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
28
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
29
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
30 // Initialization
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
31 void C1XCompiler::initialize() {
1414
e1a275dbc8cd Executing a+b with C1X on HotSpot ;-) !
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1413
diff changeset
32 if (_initialized) return;
e1a275dbc8cd Executing a+b with C1X on HotSpot ;-) !
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1413
diff changeset
33 _initialized = true;
1406
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
34 TRACE_C1X_1("initialize");
1412
9195b99c841b Added first VM entry method.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1410
diff changeset
35
9195b99c841b Added first VM entry method.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1410
diff changeset
36 JNIEnv *env = ((JavaThread *)Thread::current())->jni_environment();
1421
6223633ce7dd changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1418
diff changeset
37 jclass klass = env->FindClass("com/sun/hotspot/c1x/VMEntriesNative");
1418
55ac38887415 modifications for linux: argument register layout, makefile
Lukas Stadler <lukas.stadler@jku.at>
parents: 1414
diff changeset
38 assert(klass != NULL, "c1x VMEntries class not found");
1412
9195b99c841b Added first VM entry method.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1410
diff changeset
39 env->RegisterNatives(klass, VMEntries_methods, VMEntries_methods_count() );
1413
1ecc8f0aad00 Draft implementation of HotSpot CRI / first method compiling without exception.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1412
diff changeset
40
1421
6223633ce7dd changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1418
diff changeset
41 check_pending_exception("Could not register natives");
1406
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
42 }
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
43
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
44 // Compilation entry point for methods
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
45 void C1XCompiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci) {
1412
9195b99c841b Added first VM entry method.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1410
diff changeset
46 initialize();
9195b99c841b Added first VM entry method.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1410
diff changeset
47
1422
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
48 VM_ENTRY_MARK;
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
49
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
50 ResourceMark rm;
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
51 HandleMark hm;
1406
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
52
1410
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
53 CompilerThread::current()->set_compiling(true);
1422
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
54 VMExits::compileMethod((methodOop)target->get_oop(), entry_bci);
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
55 CompilerThread::current()->set_compiling(false);
1406
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
56 }
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
57
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
58 // Print compilation timers and statistics
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
59 void C1XCompiler::print_timers() {
35069ca331f2 Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff changeset
60 TRACE_C1X_1("print_timers");
1410
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
61 }
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
62
1422
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
63 oop C1XCompiler::get_RiType(oop name, klassOop accessingType, TRAPS) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
64 symbolOop klass = java_lang_String::as_symbol_or_null(name);
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
65
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
66 if (klass == vmSymbols::byte_signature()) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
67 return VMExits::createRiTypePrimitive((int)T_BYTE, THREAD);
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
68 } else if (klass == vmSymbols::char_signature()) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
69 return VMExits::createRiTypePrimitive((int)T_CHAR, THREAD);
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
70 } else if (klass == vmSymbols::double_signature()) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
71 return VMExits::createRiTypePrimitive((int)T_DOUBLE, THREAD);
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
72 } else if (klass == vmSymbols::float_signature()) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
73 return VMExits::createRiTypePrimitive((int)T_FLOAT, THREAD);
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
74 } else if (klass == vmSymbols::int_signature()) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
75 return VMExits::createRiTypePrimitive((int)T_INT, THREAD);
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
76 } else if (klass == vmSymbols::long_signature()) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
77 return VMExits::createRiTypePrimitive((int)T_LONG, THREAD);
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
78 } else if (klass == vmSymbols::bool_signature()) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
79 return VMExits::createRiTypePrimitive((int)T_BOOLEAN, THREAD);
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
80 }
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
81 Handle classloader;
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
82 if (accessingType != NULL) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
83 classloader = accessingType->klass_part()->class_loader();
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
84 }
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
85 klassOop resolved_type = SystemDictionary::resolve_or_null(klass, classloader, accessingType->klass_part()->protection_domain(), Thread::current());
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
86 if (resolved_type != NULL) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
87 return VMExits::createRiType(resolved_type, THREAD);
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
88 } else {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
89 return VMExits::createRiTypeUnresolved(klass, accessingType, THREAD);
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
90 }
1413
1ecc8f0aad00 Draft implementation of HotSpot CRI / first method compiling without exception.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1412
diff changeset
91 }
1ecc8f0aad00 Draft implementation of HotSpot CRI / first method compiling without exception.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1412
diff changeset
92
1422
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
93 oop C1XCompiler::get_RiType(ciType *type, klassOop accessor, TRAPS) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
94 if (type->is_loaded()) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
95 if (type->is_primitive_type()) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
96 return VMExits::createRiTypePrimitive((int)type->basic_type(), THREAD);
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
97 }
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
98 return VMExits::createRiType((klassOop)type->get_oop(), THREAD);
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
99 } else {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
100 return VMExits::createRiTypeUnresolved(((ciKlass *)type)->name()->get_symbolOop(), accessor, THREAD);
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
101 }
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
102 }
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
103
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
104 oop C1XCompiler::get_RiField(ciField *field, TRAPS) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
105 oop field_holder = get_RiType(field->holder(), NULL, CHECK_0);
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
106 oop field_type = get_RiType(field->type(), NULL, CHECK_0);
1413
1ecc8f0aad00 Draft implementation of HotSpot CRI / first method compiling without exception.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1412
diff changeset
107 symbolOop field_name = field->name()->get_symbolOop();
1ecc8f0aad00 Draft implementation of HotSpot CRI / first method compiling without exception.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1412
diff changeset
108 int offset = field->offset();
1ecc8f0aad00 Draft implementation of HotSpot CRI / first method compiling without exception.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1412
diff changeset
109
1ecc8f0aad00 Draft implementation of HotSpot CRI / first method compiling without exception.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1412
diff changeset
110 // TODO: implement caching
1422
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
111 return VMExits::createRiField(field_holder, field_name, field_type, offset, THREAD);
1413
1ecc8f0aad00 Draft implementation of HotSpot CRI / first method compiling without exception.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1412
diff changeset
112 }
1ecc8f0aad00 Draft implementation of HotSpot CRI / first method compiling without exception.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1412
diff changeset
113
1422
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
114 /*
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
115 oop C1XCompiler::get_RiMethod(ciMethod *method, TRAPS) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
116 methodOop m = (methodOop)method->get_oop();
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
117 return get_RiMethod(m, THREAD);
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
118 }
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
119
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
120 oop C1XCompiler::get_RiMethod(methodOop m, TRAPS) {
1410
b30a2cd5e3a2 Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1407
diff changeset
121 // TODO: implement caching
1422
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
122 return VMExits::createRiMethod(m, THREAD);
1413
1ecc8f0aad00 Draft implementation of HotSpot CRI / first method compiling without exception.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1412
diff changeset
123 }
1ecc8f0aad00 Draft implementation of HotSpot CRI / first method compiling without exception.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1412
diff changeset
124
1422
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
125
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
126 oop C1XCompiler::get_RiType(klassOop klass, TRAPS) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
127 // TODO: implement caching
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
128 return VMExits::createRiType(klass, THREAD);
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
129 }
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
130
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
131 oop C1XCompiler::get_RiConstantPool(constantPoolOop cp, TRAPS) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
132 // TODO: implement caching
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
133 return VMExits::createRiConstantPool(cp, THREAD);
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
134 }
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
135
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
136 oop C1XCompiler::get_unresolved_RiType(symbolOop klass, klassOop accessingType, TRAPS) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
137 // TODO: implement caching
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
138 return VMExits::createRiTypeUnresolved(klass, accessingType, THREAD);
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
139 }
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
140 */
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
141
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
142 // conversion internal objects -> reflected objects
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
143
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
144 oop C1XObjects::getReflectedMethod(methodOop method, TRAPS) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
145 if (method->is_initializer()) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
146 return Reflection::new_constructor(method, CHECK_0);
1413
1ecc8f0aad00 Draft implementation of HotSpot CRI / first method compiling without exception.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1412
diff changeset
147 } else {
1422
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
148 return Reflection::new_method(method, UseNewReflection, false, CHECK_0);
1413
1ecc8f0aad00 Draft implementation of HotSpot CRI / first method compiling without exception.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1412
diff changeset
149 }
1ecc8f0aad00 Draft implementation of HotSpot CRI / first method compiling without exception.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1412
diff changeset
150 }
1ecc8f0aad00 Draft implementation of HotSpot CRI / first method compiling without exception.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1412
diff changeset
151
1422
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
152 oop C1XObjects::getReflectedClass(klassOop klass) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
153 return klass->klass_part()->java_mirror();
1413
1ecc8f0aad00 Draft implementation of HotSpot CRI / first method compiling without exception.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1412
diff changeset
154 }
1ecc8f0aad00 Draft implementation of HotSpot CRI / first method compiling without exception.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1412
diff changeset
155
1422
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
156 oop C1XObjects::getReflectedSymbol(symbolOop symbol, TRAPS) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
157 return java_lang_String::create_from_symbol(symbol, THREAD)();
1413
1ecc8f0aad00 Draft implementation of HotSpot CRI / first method compiling without exception.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1412
diff changeset
158 }
1ecc8f0aad00 Draft implementation of HotSpot CRI / first method compiling without exception.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1412
diff changeset
159
1422
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
160 // conversion reflected objects -> internal objects
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
161
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
162 methodOop C1XObjects::getInternalMethod(oop method) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
163 // copied from JNIEnv::FromReflectedMethod
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
164 oop mirror = NULL;
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
165 int slot = 0;
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
166
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
167 if (method->klass() == SystemDictionary::reflect_Constructor_klass()) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
168 mirror = java_lang_reflect_Constructor::clazz(method);
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
169 slot = java_lang_reflect_Constructor::slot(method);
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
170 } else {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
171 assert(method->klass() == SystemDictionary::reflect_Method_klass(), "wrong type");
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
172 mirror = java_lang_reflect_Method::clazz(method);
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
173 slot = java_lang_reflect_Method::slot(method);
1414
e1a275dbc8cd Executing a+b with C1X on HotSpot ;-) !
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1413
diff changeset
174 }
1422
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
175 klassOop k = java_lang_Class::as_klassOop(mirror);
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
176 return instanceKlass::cast(k)->method_with_idnum(slot);
1413
1ecc8f0aad00 Draft implementation of HotSpot CRI / first method compiling without exception.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1412
diff changeset
177 }
1ecc8f0aad00 Draft implementation of HotSpot CRI / first method compiling without exception.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1412
diff changeset
178
1422
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
179 klassOop C1XObjects::getInternalClass(oop klass) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
180 return java_lang_Class::as_klassOop(klass);
1413
1ecc8f0aad00 Draft implementation of HotSpot CRI / first method compiling without exception.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 1412
diff changeset
181 }
1422
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
182
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
183 symbolOop C1XObjects::getInternalSymbol(oop string) {
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
184 return java_lang_String::as_symbol_or_null(string);
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
185 }
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
186
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
187
3483ec571caf * using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1421
diff changeset
188