1 /*
2 * Copyright (c) 1998, 2012, 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 *
321 bool is_byte() const { return flag_state() == btos; }
322 bool is_char() const { return flag_state() == ctos; }
323 bool is_short() const { return flag_state() == stos; }
324 bool is_int() const { return flag_state() == itos; }
325 bool is_long() const { return flag_state() == ltos; }
326 bool is_float() const { return flag_state() == ftos; }
327 bool is_double() const { return flag_state() == dtos; }
328 bool is_object() const { return flag_state() == atos; }
329 TosState flag_state() const { assert((uint)number_of_states <= (uint)tos_state_mask+1, "");
330 return (TosState)((_flags >> tos_state_shift) & tos_state_mask); }
331
332 // Code generation support
333 static WordSize size() { return in_WordSize(sizeof(ConstantPoolCacheEntry) / HeapWordSize); }
334 static ByteSize size_in_bytes() { return in_ByteSize(sizeof(ConstantPoolCacheEntry)); }
335 static ByteSize indices_offset() { return byte_offset_of(ConstantPoolCacheEntry, _indices); }
336 static ByteSize f1_offset() { return byte_offset_of(ConstantPoolCacheEntry, _f1); }
337 static ByteSize f2_offset() { return byte_offset_of(ConstantPoolCacheEntry, _f2); }
338 static ByteSize flags_offset() { return byte_offset_of(ConstantPoolCacheEntry, _flags); }
339
340 // RedefineClasses() API support:
341 // If this constantPoolCacheEntry refers to old_method then update it
342 // to refer to new_method.
343 // trace_name_printed is set to true if the current call has
344 // printed the klass name so that other routines in the adjust_*
345 // group don't print the klass name.
346 bool adjust_method_entry(Method* old_method, Method* new_method,
347 bool * trace_name_printed);
348 NOT_PRODUCT(bool check_no_old_entries();)
349 bool is_interesting_method_entry(Klass* k);
350
351 // Debugging & Printing
352 void print (outputStream* st, int index) const;
353 void verify(outputStream* st) const;
354
355 static void verify_tos_state_shift() {
356 // When shifting flags as a 32-bit int, make sure we don't need an extra mask for tos_state:
357 assert((((u4)-1 >> tos_state_shift) & ~tos_state_mask) == 0, "no need for tos_state mask");
358 }
359 };
360
361
362 // A constant pool cache is a runtime data structure set aside to a constant pool. The cache
363 // holds interpreter runtime information for all field access and invoke bytecodes. The cache
364 // is created and initialized before a class is actively used (i.e., initialized), the indivi-
365 // dual cache entries are filled at resolution (i.e., "link") time (see also: rewriter.*).
366
367 class ConstantPoolCache: public MetaspaceObj {
368 friend class VMStructs;
407 void initialize(intArray& inverse_index_map, intArray& invokedynamic_references_map);
408
409 // Accessors
410 void set_constant_pool(ConstantPool* pool) { _constant_pool = pool; }
411 ConstantPool* constant_pool() const { return _constant_pool; }
412 // Fetches the entry at the given index.
413 // In either case the index must not be encoded or byte-swapped in any way.
414 ConstantPoolCacheEntry* entry_at(int i) const {
415 assert(0 <= i && i < length(), "index out of bounds");
416 return base() + i;
417 }
418
419 // Code generation
420 static ByteSize base_offset() { return in_ByteSize(sizeof(ConstantPoolCache)); }
421 static ByteSize entry_offset(int raw_index) {
422 int index = raw_index;
423 return (base_offset() + ConstantPoolCacheEntry::size_in_bytes() * index);
424 }
425
426 // RedefineClasses() API support:
427 // If any entry of this constantPoolCache points to any of
428 // old_methods, replace it with the corresponding new_method.
429 // trace_name_printed is set to true if the current call has
430 // printed the klass name so that other routines in the adjust_*
431 // group don't print the klass name.
432 void adjust_method_entries(Method** old_methods, Method** new_methods,
433 int methods_length, bool * trace_name_printed);
434 NOT_PRODUCT(bool check_no_old_entries();)
435
436 // Deallocate - no fields to deallocate
437 DEBUG_ONLY(bool on_stack() { return false; })
438 void deallocate_contents(ClassLoaderData* data) {}
439 bool is_klass() const { return false; }
440
441 // Printing
442 void print_on(outputStream* st) const;
443 void print_value_on(outputStream* st) const;
444
445 const char* internal_name() const { return "{constant pool cache}"; }
446
447 // Verify
448 void verify_on(outputStream* st);
449 };
450
451 #endif // SHARE_VM_OOPS_CPCACHEOOP_HPP
|
1 /*
2 * Copyright (c) 1998, 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 *
321 bool is_byte() const { return flag_state() == btos; }
322 bool is_char() const { return flag_state() == ctos; }
323 bool is_short() const { return flag_state() == stos; }
324 bool is_int() const { return flag_state() == itos; }
325 bool is_long() const { return flag_state() == ltos; }
326 bool is_float() const { return flag_state() == ftos; }
327 bool is_double() const { return flag_state() == dtos; }
328 bool is_object() const { return flag_state() == atos; }
329 TosState flag_state() const { assert((uint)number_of_states <= (uint)tos_state_mask+1, "");
330 return (TosState)((_flags >> tos_state_shift) & tos_state_mask); }
331
332 // Code generation support
333 static WordSize size() { return in_WordSize(sizeof(ConstantPoolCacheEntry) / HeapWordSize); }
334 static ByteSize size_in_bytes() { return in_ByteSize(sizeof(ConstantPoolCacheEntry)); }
335 static ByteSize indices_offset() { return byte_offset_of(ConstantPoolCacheEntry, _indices); }
336 static ByteSize f1_offset() { return byte_offset_of(ConstantPoolCacheEntry, _f1); }
337 static ByteSize f2_offset() { return byte_offset_of(ConstantPoolCacheEntry, _f2); }
338 static ByteSize flags_offset() { return byte_offset_of(ConstantPoolCacheEntry, _flags); }
339
340 // RedefineClasses() API support:
341 // If this ConstantPoolCacheEntry refers to old_method then update it
342 // to refer to new_method.
343 // trace_name_printed is set to true if the current call has
344 // printed the klass name so that other routines in the adjust_*
345 // group don't print the klass name.
346 bool adjust_method_entry(Method* old_method, Method* new_method,
347 bool * trace_name_printed);
348 bool check_no_old_or_obsolete_entries();
349 bool is_interesting_method_entry(Klass* k);
350
351 // Debugging & Printing
352 void print (outputStream* st, int index) const;
353 void verify(outputStream* st) const;
354
355 static void verify_tos_state_shift() {
356 // When shifting flags as a 32-bit int, make sure we don't need an extra mask for tos_state:
357 assert((((u4)-1 >> tos_state_shift) & ~tos_state_mask) == 0, "no need for tos_state mask");
358 }
359 };
360
361
362 // A constant pool cache is a runtime data structure set aside to a constant pool. The cache
363 // holds interpreter runtime information for all field access and invoke bytecodes. The cache
364 // is created and initialized before a class is actively used (i.e., initialized), the indivi-
365 // dual cache entries are filled at resolution (i.e., "link") time (see also: rewriter.*).
366
367 class ConstantPoolCache: public MetaspaceObj {
368 friend class VMStructs;
407 void initialize(intArray& inverse_index_map, intArray& invokedynamic_references_map);
408
409 // Accessors
410 void set_constant_pool(ConstantPool* pool) { _constant_pool = pool; }
411 ConstantPool* constant_pool() const { return _constant_pool; }
412 // Fetches the entry at the given index.
413 // In either case the index must not be encoded or byte-swapped in any way.
414 ConstantPoolCacheEntry* entry_at(int i) const {
415 assert(0 <= i && i < length(), "index out of bounds");
416 return base() + i;
417 }
418
419 // Code generation
420 static ByteSize base_offset() { return in_ByteSize(sizeof(ConstantPoolCache)); }
421 static ByteSize entry_offset(int raw_index) {
422 int index = raw_index;
423 return (base_offset() + ConstantPoolCacheEntry::size_in_bytes() * index);
424 }
425
426 // RedefineClasses() API support:
427 // If any entry of this ConstantPoolCache points to any of
428 // old_methods, replace it with the corresponding new_method.
429 // trace_name_printed is set to true if the current call has
430 // printed the klass name so that other routines in the adjust_*
431 // group don't print the klass name.
432 void adjust_method_entries(Method** old_methods, Method** new_methods,
433 int methods_length, bool * trace_name_printed);
434 bool check_no_old_or_obsolete_entries();
435 void dump_cache();
436
437 // Deallocate - no fields to deallocate
438 DEBUG_ONLY(bool on_stack() { return false; })
439 void deallocate_contents(ClassLoaderData* data) {}
440 bool is_klass() const { return false; }
441
442 // Printing
443 void print_on(outputStream* st) const;
444 void print_value_on(outputStream* st) const;
445
446 const char* internal_name() const { return "{constant pool cache}"; }
447
448 // Verify
449 void verify_on(outputStream* st);
450 };
451
452 #endif // SHARE_VM_OOPS_CPCACHEOOP_HPP
|