Tue, 24 Jul 2012 10:51:00 -0700
7023639: JSR 292 method handle invocation needs a fast path for compiled code
6984705: JSR 292 method handle creation should not go through JNI
Summary: remove assembly code for JDK 7 chained method handles
Reviewed-by: jrose, twisti, kvn, mhaupt
Contributed-by: John Rose <john.r.rose@oracle.com>, Christian Thalinger <christian.thalinger@oracle.com>, Michael Haupt <michael.haupt@oracle.com>
1 /*
2 * Copyright (c) 1999, 2010, 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 */
25 #include "precompiled.hpp"
26 #include "c1/c1_ValueType.hpp"
27 #include "ci/ciArray.hpp"
28 #include "ci/ciInstance.hpp"
29 #include "ci/ciNullObject.hpp"
32 // predefined types
33 VoidType* voidType = NULL;
34 IntType* intType = NULL;
35 LongType* longType = NULL;
36 FloatType* floatType = NULL;
37 DoubleType* doubleType = NULL;
38 ObjectType* objectType = NULL;
39 ArrayType* arrayType = NULL;
40 InstanceType* instanceType = NULL;
41 ClassType* classType = NULL;
42 AddressType* addressType = NULL;
43 IllegalType* illegalType = NULL;
46 // predefined constants
47 IntConstant* intZero = NULL;
48 IntConstant* intOne = NULL;
49 ObjectConstant* objectNull = NULL;
52 void ValueType::initialize(Arena* arena) {
53 // Note: Must initialize all types for each compilation
54 // as they are allocated within a ResourceMark!
56 // types
57 voidType = new (arena) VoidType();
58 intType = new (arena) IntType();
59 longType = new (arena) LongType();
60 floatType = new (arena) FloatType();
61 doubleType = new (arena) DoubleType();
62 objectType = new (arena) ObjectType();
63 arrayType = new (arena) ArrayType();
64 instanceType = new (arena) InstanceType();
65 classType = new (arena) ClassType();
66 addressType = new (arena) AddressType();
67 illegalType = new (arena) IllegalType();
69 intZero = new (arena) IntConstant(0);
70 intOne = new (arena) IntConstant(1);
71 objectNull = new (arena) ObjectConstant(ciNullObject::make());
72 };
75 ValueType* ValueType::meet(ValueType* y) const {
76 // incomplete & conservative solution for now - fix this!
77 assert(tag() == y->tag(), "types must match");
78 return base();
79 }
82 ValueType* ValueType::join(ValueType* y) const {
83 Unimplemented();
84 return NULL;
85 }
89 jobject ObjectType::encoding() const {
90 assert(is_constant(), "must be");
91 return constant_value()->constant_encoding();
92 }
94 bool ObjectType::is_loaded() const {
95 assert(is_constant(), "must be");
96 return constant_value()->is_loaded();
97 }
99 ciObject* ObjectConstant::constant_value() const { return _value; }
100 ciObject* ArrayConstant::constant_value() const { return _value; }
101 ciObject* InstanceConstant::constant_value() const { return _value; }
102 ciObject* ClassConstant::constant_value() const { return _value; }
104 ciType* ObjectConstant::exact_type() const {
105 ciObject* c = constant_value();
106 return (c != NULL && !c->is_null_object()) ? c->klass() : NULL;
107 }
108 ciType* ArrayConstant::exact_type() const {
109 ciObject* c = constant_value();
110 return (c != NULL && !c->is_null_object()) ? c->klass() : NULL;
111 }
112 ciType* InstanceConstant::exact_type() const {
113 ciObject* c = constant_value();
114 return (c != NULL && !c->is_null_object()) ? c->klass() : NULL;
115 }
116 ciType* ClassConstant::exact_type() const {
117 ciObject* c = constant_value();
118 return (c != NULL && !c->is_null_object()) ? c->klass() : NULL;
119 }
122 ValueType* as_ValueType(BasicType type) {
123 switch (type) {
124 case T_VOID : return voidType;
125 case T_BYTE : // fall through
126 case T_CHAR : // fall through
127 case T_SHORT : // fall through
128 case T_BOOLEAN: // fall through
129 case T_INT : return intType;
130 case T_LONG : return longType;
131 case T_FLOAT : return floatType;
132 case T_DOUBLE : return doubleType;
133 case T_ARRAY : return arrayType;
134 case T_OBJECT : return objectType;
135 case T_ADDRESS: return addressType;
136 case T_ILLEGAL: return illegalType;
137 }
138 ShouldNotReachHere();
139 return illegalType;
140 }
143 ValueType* as_ValueType(ciConstant value) {
144 switch (value.basic_type()) {
145 case T_BYTE : // fall through
146 case T_CHAR : // fall through
147 case T_SHORT : // fall through
148 case T_BOOLEAN: // fall through
149 case T_INT : return new IntConstant (value.as_int ());
150 case T_LONG : return new LongConstant (value.as_long ());
151 case T_FLOAT : return new FloatConstant (value.as_float ());
152 case T_DOUBLE : return new DoubleConstant(value.as_double());
153 case T_ARRAY : // fall through (ciConstant doesn't have an array accessor)
154 case T_OBJECT : return new ObjectConstant(value.as_object());
155 }
156 ShouldNotReachHere();
157 return illegalType;
158 }
161 BasicType as_BasicType(ValueType* type) {
162 switch (type->tag()) {
163 case voidTag: return T_VOID;
164 case intTag: return T_INT;
165 case longTag: return T_LONG;
166 case floatTag: return T_FLOAT;
167 case doubleTag: return T_DOUBLE;
168 case objectTag: return T_OBJECT;
169 case addressTag: return T_ADDRESS;
170 case illegalTag: return T_ILLEGAL;
171 }
172 ShouldNotReachHere();
173 return T_ILLEGAL;
174 }