Mercurial > hg > truffle
comparison src/share/vm/interpreter/bytecode.hpp @ 6725:da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author | coleenp |
---|---|
date | Sat, 01 Sep 2012 13:25:18 -0400 |
parents | 1d7922586cf6 |
children |
comparison
equal
deleted
inserted
replaced
6724:36d1d483d5d6 | 6725:da91efe96a93 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
25 #ifndef SHARE_VM_INTERPRETER_BYTECODE_HPP | 25 #ifndef SHARE_VM_INTERPRETER_BYTECODE_HPP |
26 #define SHARE_VM_INTERPRETER_BYTECODE_HPP | 26 #define SHARE_VM_INTERPRETER_BYTECODE_HPP |
27 | 27 |
28 #include "interpreter/bytecodes.hpp" | 28 #include "interpreter/bytecodes.hpp" |
29 #include "memory/allocation.hpp" | 29 #include "memory/allocation.hpp" |
30 #include "oops/methodOop.hpp" | 30 #include "oops/method.hpp" |
31 #ifdef TARGET_ARCH_x86 | 31 #ifdef TARGET_ARCH_x86 |
32 # include "bytes_x86.hpp" | 32 # include "bytes_x86.hpp" |
33 #endif | 33 #endif |
34 #ifdef TARGET_ARCH_sparc | 34 #ifdef TARGET_ARCH_sparc |
35 # include "bytes_sparc.hpp" | 35 # include "bytes_sparc.hpp" |
66 int get_Java_u4_at (int offset) const { return Bytes::get_Java_u4(addr_at(offset)); } | 66 int get_Java_u4_at (int offset) const { return Bytes::get_Java_u4(addr_at(offset)); } |
67 int get_native_u2_at (int offset) const { return Bytes::get_native_u2(addr_at(offset)); } | 67 int get_native_u2_at (int offset) const { return Bytes::get_native_u2(addr_at(offset)); } |
68 int get_native_u4_at (int offset) const { return Bytes::get_native_u4(addr_at(offset)); } | 68 int get_native_u4_at (int offset) const { return Bytes::get_native_u4(addr_at(offset)); } |
69 | 69 |
70 public: | 70 public: |
71 Bytecode(methodOop method, address bcp): _bcp(bcp), _code(Bytecodes::code_at(method, addr_at(0))) { | 71 Bytecode(Method* method, address bcp): _bcp(bcp), _code(Bytecodes::code_at(method, addr_at(0))) { |
72 assert(method != NULL, "this form requires a valid methodOop"); | 72 assert(method != NULL, "this form requires a valid Method*"); |
73 } | 73 } |
74 // Defined in ciStreams.hpp | 74 // Defined in ciStreams.hpp |
75 inline Bytecode(const ciBytecodeStream* stream, address bcp = NULL); | 75 inline Bytecode(const ciBytecodeStream* stream, address bcp = NULL); |
76 | 76 |
77 // Attributes | 77 // Attributes |
94 return Bytes::get_native_u2(p); | 94 return Bytes::get_native_u2(p); |
95 else return Bytes::get_Java_u2(p); | 95 else return Bytes::get_Java_u2(p); |
96 } | 96 } |
97 int get_index_u1_cpcache(Bytecodes::Code bc) const { | 97 int get_index_u1_cpcache(Bytecodes::Code bc) const { |
98 assert_same_format_as(bc); assert_index_size(1, bc); | 98 assert_same_format_as(bc); assert_index_size(1, bc); |
99 return *(jubyte*)addr_at(1) + constantPoolOopDesc::CPCACHE_INDEX_TAG; | 99 return *(jubyte*)addr_at(1) + ConstantPool::CPCACHE_INDEX_TAG; |
100 } | 100 } |
101 int get_index_u2_cpcache(Bytecodes::Code bc) const { | 101 int get_index_u2_cpcache(Bytecodes::Code bc) const { |
102 assert_same_format_as(bc); assert_index_size(2, bc); assert_native_index(bc); | 102 assert_same_format_as(bc); assert_index_size(2, bc); assert_native_index(bc); |
103 return Bytes::get_native_u2(addr_at(1)) + constantPoolOopDesc::CPCACHE_INDEX_TAG; | 103 return Bytes::get_native_u2(addr_at(1)) + ConstantPool::CPCACHE_INDEX_TAG; |
104 } | 104 } |
105 int get_index_u4(Bytecodes::Code bc) const { | 105 int get_index_u4(Bytecodes::Code bc) const { |
106 assert_same_format_as(bc); assert_index_size(4, bc); | 106 assert_same_format_as(bc); assert_index_size(4, bc); |
107 assert(can_use_native_byte_order(bc), ""); | 107 assert(can_use_native_byte_order(bc), ""); |
108 return Bytes::get_native_u4(addr_at(1)); | 108 return Bytes::get_native_u4(addr_at(1)); |
156 }; | 156 }; |
157 | 157 |
158 | 158 |
159 class Bytecode_lookupswitch: public Bytecode { | 159 class Bytecode_lookupswitch: public Bytecode { |
160 public: | 160 public: |
161 Bytecode_lookupswitch(methodOop method, address bcp): Bytecode(method, bcp) { verify(); } | 161 Bytecode_lookupswitch(Method* method, address bcp): Bytecode(method, bcp) { verify(); } |
162 // Defined in ciStreams.hpp | 162 // Defined in ciStreams.hpp |
163 inline Bytecode_lookupswitch(const ciBytecodeStream* stream); | 163 inline Bytecode_lookupswitch(const ciBytecodeStream* stream); |
164 void verify() const PRODUCT_RETURN; | 164 void verify() const PRODUCT_RETURN; |
165 | 165 |
166 // Attributes | 166 // Attributes |
172 } | 172 } |
173 }; | 173 }; |
174 | 174 |
175 class Bytecode_tableswitch: public Bytecode { | 175 class Bytecode_tableswitch: public Bytecode { |
176 public: | 176 public: |
177 Bytecode_tableswitch(methodOop method, address bcp): Bytecode(method, bcp) { verify(); } | 177 Bytecode_tableswitch(Method* method, address bcp): Bytecode(method, bcp) { verify(); } |
178 // Defined in ciStreams.hpp | 178 // Defined in ciStreams.hpp |
179 inline Bytecode_tableswitch(const ciBytecodeStream* stream); | 179 inline Bytecode_tableswitch(const ciBytecodeStream* stream); |
180 void verify() const PRODUCT_RETURN; | 180 void verify() const PRODUCT_RETURN; |
181 | 181 |
182 // Attributes | 182 // Attributes |
194 const methodHandle _method; // method containing the bytecode | 194 const methodHandle _method; // method containing the bytecode |
195 | 195 |
196 Bytecode_member_ref(methodHandle method, int bci) : Bytecode(method(), method()->bcp_from(bci)), _method(method) {} | 196 Bytecode_member_ref(methodHandle method, int bci) : Bytecode(method(), method()->bcp_from(bci)), _method(method) {} |
197 | 197 |
198 methodHandle method() const { return _method; } | 198 methodHandle method() const { return _method; } |
199 constantPoolOop constants() const { return _method->constants(); } | 199 ConstantPool* constants() const { return _method->constants(); } |
200 constantPoolCacheOop cpcache() const { return _method->constants()->cache(); } | 200 ConstantPoolCache* cpcache() const { return _method->constants()->cache(); } |
201 ConstantPoolCacheEntry* cpcache_entry() const; | 201 ConstantPoolCacheEntry* cpcache_entry() const; |
202 | 202 |
203 public: | 203 public: |
204 int index() const; // cache index (loaded from instruction) | 204 int index() const; // cache index (loaded from instruction) |
205 int pool_index() const; // constant pool index | 205 int pool_index() const; // constant pool index |
276 }; | 276 }; |
277 | 277 |
278 // Abstraction for checkcast | 278 // Abstraction for checkcast |
279 class Bytecode_checkcast: public Bytecode { | 279 class Bytecode_checkcast: public Bytecode { |
280 public: | 280 public: |
281 Bytecode_checkcast(methodOop method, address bcp): Bytecode(method, bcp) { verify(); } | 281 Bytecode_checkcast(Method* method, address bcp): Bytecode(method, bcp) { verify(); } |
282 void verify() const { assert(Bytecodes::java_code(code()) == Bytecodes::_checkcast, "check checkcast"); } | 282 void verify() const { assert(Bytecodes::java_code(code()) == Bytecodes::_checkcast, "check checkcast"); } |
283 | 283 |
284 // Returns index | 284 // Returns index |
285 long index() const { return get_index_u2(Bytecodes::_checkcast); }; | 285 long index() const { return get_index_u2(Bytecodes::_checkcast); }; |
286 }; | 286 }; |
287 | 287 |
288 // Abstraction for instanceof | 288 // Abstraction for instanceof |
289 class Bytecode_instanceof: public Bytecode { | 289 class Bytecode_instanceof: public Bytecode { |
290 public: | 290 public: |
291 Bytecode_instanceof(methodOop method, address bcp): Bytecode(method, bcp) { verify(); } | 291 Bytecode_instanceof(Method* method, address bcp): Bytecode(method, bcp) { verify(); } |
292 void verify() const { assert(code() == Bytecodes::_instanceof, "check instanceof"); } | 292 void verify() const { assert(code() == Bytecodes::_instanceof, "check instanceof"); } |
293 | 293 |
294 // Returns index | 294 // Returns index |
295 long index() const { return get_index_u2(Bytecodes::_instanceof); }; | 295 long index() const { return get_index_u2(Bytecodes::_instanceof); }; |
296 }; | 296 }; |
297 | 297 |
298 class Bytecode_new: public Bytecode { | 298 class Bytecode_new: public Bytecode { |
299 public: | 299 public: |
300 Bytecode_new(methodOop method, address bcp): Bytecode(method, bcp) { verify(); } | 300 Bytecode_new(Method* method, address bcp): Bytecode(method, bcp) { verify(); } |
301 void verify() const { assert(java_code() == Bytecodes::_new, "check new"); } | 301 void verify() const { assert(java_code() == Bytecodes::_new, "check new"); } |
302 | 302 |
303 // Returns index | 303 // Returns index |
304 long index() const { return get_index_u2(Bytecodes::_new); }; | 304 long index() const { return get_index_u2(Bytecodes::_new); }; |
305 }; | 305 }; |
306 | 306 |
307 class Bytecode_multianewarray: public Bytecode { | 307 class Bytecode_multianewarray: public Bytecode { |
308 public: | 308 public: |
309 Bytecode_multianewarray(methodOop method, address bcp): Bytecode(method, bcp) { verify(); } | 309 Bytecode_multianewarray(Method* method, address bcp): Bytecode(method, bcp) { verify(); } |
310 void verify() const { assert(java_code() == Bytecodes::_multianewarray, "check new"); } | 310 void verify() const { assert(java_code() == Bytecodes::_multianewarray, "check new"); } |
311 | 311 |
312 // Returns index | 312 // Returns index |
313 long index() const { return get_index_u2(Bytecodes::_multianewarray); }; | 313 long index() const { return get_index_u2(Bytecodes::_multianewarray); }; |
314 }; | 314 }; |
315 | 315 |
316 class Bytecode_anewarray: public Bytecode { | 316 class Bytecode_anewarray: public Bytecode { |
317 public: | 317 public: |
318 Bytecode_anewarray(methodOop method, address bcp): Bytecode(method, bcp) { verify(); } | 318 Bytecode_anewarray(Method* method, address bcp): Bytecode(method, bcp) { verify(); } |
319 void verify() const { assert(java_code() == Bytecodes::_anewarray, "check anewarray"); } | 319 void verify() const { assert(java_code() == Bytecodes::_anewarray, "check anewarray"); } |
320 | 320 |
321 // Returns index | 321 // Returns index |
322 long index() const { return get_index_u2(Bytecodes::_anewarray); }; | 322 long index() const { return get_index_u2(Bytecodes::_anewarray); }; |
323 }; | 323 }; |
338 assert(stdc == Bytecodes::_ldc || | 338 assert(stdc == Bytecodes::_ldc || |
339 stdc == Bytecodes::_ldc_w || | 339 stdc == Bytecodes::_ldc_w || |
340 stdc == Bytecodes::_ldc2_w, "load constant"); | 340 stdc == Bytecodes::_ldc2_w, "load constant"); |
341 } | 341 } |
342 | 342 |
343 // Only non-standard bytecodes (fast_aldc) have CP cache indexes. | 343 // Only non-standard bytecodes (fast_aldc) have reference cache indexes. |
344 bool has_cache_index() const { return code() >= Bytecodes::number_of_java_codes; } | 344 bool has_cache_index() const { return code() >= Bytecodes::number_of_java_codes; } |
345 | 345 |
346 int pool_index() const; // index into constant pool | 346 int pool_index() const; // index into constant pool |
347 int cache_index() const { // index into CP cache (or -1 if none) | 347 int cache_index() const { // index into reference cache (or -1 if none) |
348 return has_cache_index() ? raw_index() : -1; | 348 return has_cache_index() ? raw_index() : -1; |
349 } | 349 } |
350 | 350 |
351 BasicType result_type() const; // returns the result type of the ldc | 351 BasicType result_type() const; // returns the result type of the ldc |
352 | 352 |