2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2019-01-09 09:01:27 -05:00
|
|
|
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "precompiled.hpp"
|
2012-06-13 19:52:59 -04:00
|
|
|
#include "classfile/altHashing.hpp"
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
#include "classfile/classLoaderData.inline.hpp"
|
2015-02-13 14:37:35 +01:00
|
|
|
#include "classfile/javaClasses.inline.hpp"
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
#include "classfile/moduleEntry.hpp"
|
2014-05-07 14:16:45 -05:00
|
|
|
#include "classfile/stringTable.hpp"
|
2019-05-09 14:28:30 +02:00
|
|
|
#include "classfile/symbolTable.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "classfile/vmSymbols.hpp"
|
|
|
|
#include "code/debugInfo.hpp"
|
2015-11-18 03:03:43 +03:00
|
|
|
#include "code/dependencyContext.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "code/pcDesc.hpp"
|
|
|
|
#include "interpreter/interpreter.hpp"
|
2018-03-15 21:29:36 +01:00
|
|
|
#include "interpreter/linkResolver.hpp"
|
2018-01-08 09:46:31 -05:00
|
|
|
#include "logging/log.hpp"
|
|
|
|
#include "logging/logStream.hpp"
|
2018-10-09 15:58:07 -04:00
|
|
|
#include "memory/heapShared.inline.hpp"
|
|
|
|
#include "memory/metaspaceShared.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "memory/oopFactory.hpp"
|
|
|
|
#include "memory/resourceArea.hpp"
|
2018-03-07 21:57:36 +01:00
|
|
|
#include "memory/universe.hpp"
|
2011-09-10 17:29:02 -07:00
|
|
|
#include "oops/fieldStreams.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "oops/instanceKlass.hpp"
|
2011-03-18 16:00:34 -07:00
|
|
|
#include "oops/instanceMirrorKlass.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "oops/klass.hpp"
|
2018-03-05 10:29:23 -05:00
|
|
|
#include "oops/method.inline.hpp"
|
2015-02-13 14:37:35 +01:00
|
|
|
#include "oops/objArrayOop.inline.hpp"
|
|
|
|
#include "oops/oop.inline.hpp"
|
2011-01-27 16:11:27 -08:00
|
|
|
#include "oops/symbol.hpp"
|
2018-02-15 23:45:15 +01:00
|
|
|
#include "oops/typeArrayOop.inline.hpp"
|
2018-10-17 15:57:10 -07:00
|
|
|
#include "prims/jvmtiExport.hpp"
|
2017-05-27 09:21:01 -04:00
|
|
|
#include "prims/resolvedMethodTable.hpp"
|
2018-08-20 13:58:23 -07:00
|
|
|
#include "runtime/fieldDescriptor.inline.hpp"
|
2018-03-21 19:45:24 -04:00
|
|
|
#include "runtime/frame.inline.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "runtime/handles.inline.hpp"
|
2018-03-16 09:12:13 -04:00
|
|
|
#include "runtime/interfaceSupport.inline.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "runtime/java.hpp"
|
|
|
|
#include "runtime/javaCalls.hpp"
|
2018-03-01 16:51:22 -05:00
|
|
|
#include "runtime/jniHandles.inline.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "runtime/safepoint.hpp"
|
2018-03-23 18:54:12 +01:00
|
|
|
#include "runtime/safepointVerifiers.hpp"
|
2012-11-27 14:20:21 +01:00
|
|
|
#include "runtime/thread.inline.hpp"
|
2018-03-21 19:45:24 -04:00
|
|
|
#include "runtime/vframe.inline.hpp"
|
2019-08-20 10:11:53 +01:00
|
|
|
#include "runtime/vm_version.hpp"
|
2017-07-05 11:33:17 +02:00
|
|
|
#include "utilities/align.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "utilities/preserveException.hpp"
|
2019-03-30 08:26:20 -07:00
|
|
|
#include "utilities/utf8.hpp"
|
2015-10-08 12:49:30 -10:00
|
|
|
#if INCLUDE_JVMCI
|
|
|
|
#include "jvmci/jvmciJavaClasses.hpp"
|
|
|
|
#endif
|
|
|
|
|
2011-09-10 17:29:02 -07:00
|
|
|
#define INJECTED_FIELD_COMPUTE_OFFSET(klass, name, signature, may_be_java) \
|
|
|
|
klass::_##name##_offset = JavaClasses::compute_injected_offset(JavaClasses::klass##_##name##_enum);
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS
|
|
|
|
#define INJECTED_FIELD_SERIALIZE_OFFSET(klass, name, signature, may_be_java) \
|
|
|
|
f->do_u4((u4*)&_##name##_offset);
|
|
|
|
#endif
|
|
|
|
|
2011-09-10 17:29:02 -07:00
|
|
|
#define DECLARE_INJECTED_FIELD(klass, name, signature, may_be_java) \
|
|
|
|
{ SystemDictionary::WK_KLASS_ENUM_NAME(klass), vmSymbols::VM_SYMBOL_ENUM_NAME(name##_name), vmSymbols::VM_SYMBOL_ENUM_NAME(signature), may_be_java },
|
|
|
|
|
|
|
|
InjectedField JavaClasses::_injected_fields[] = {
|
|
|
|
ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD)
|
|
|
|
};
|
|
|
|
|
|
|
|
int JavaClasses::compute_injected_offset(InjectedFieldID id) {
|
|
|
|
return _injected_fields[id].compute_offset();
|
|
|
|
}
|
|
|
|
|
|
|
|
InjectedField* JavaClasses::get_injected(Symbol* class_name, int* field_count) {
|
|
|
|
*field_count = 0;
|
|
|
|
|
|
|
|
vmSymbols::SID sid = vmSymbols::find_sid(class_name);
|
|
|
|
if (sid == vmSymbols::NO_SID) {
|
|
|
|
// Only well known classes can inject fields
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
int start = -1;
|
|
|
|
|
|
|
|
#define LOOKUP_INJECTED_FIELD(klass, name, signature, may_be_java) \
|
|
|
|
if (sid == vmSymbols::VM_SYMBOL_ENUM_NAME(klass)) { \
|
|
|
|
count++; \
|
|
|
|
if (start == -1) start = klass##_##name##_enum; \
|
|
|
|
}
|
|
|
|
ALL_INJECTED_FIELDS(LOOKUP_INJECTED_FIELD);
|
|
|
|
#undef LOOKUP_INJECTED_FIELD
|
|
|
|
|
|
|
|
if (start != -1) {
|
|
|
|
*field_count = count;
|
|
|
|
return _injected_fields + start;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-29 19:45:22 -07:00
|
|
|
// Helpful routine for computing field offsets at run time rather than hardcoding them
|
2018-01-08 09:46:31 -05:00
|
|
|
// Finds local fields only, including static fields. Static field offsets are from the
|
|
|
|
// beginning of the mirror.
|
|
|
|
static void compute_offset(int &dest_offset,
|
|
|
|
InstanceKlass* ik, Symbol* name_symbol, Symbol* signature_symbol,
|
|
|
|
bool is_static = false) {
|
2008-04-29 19:45:22 -07:00
|
|
|
fieldDescriptor fd;
|
2018-01-08 09:46:31 -05:00
|
|
|
if (ik == NULL) {
|
|
|
|
ResourceMark rm;
|
|
|
|
log_error(class)("Mismatch JDK version for field: %s type: %s", name_symbol->as_C_string(), signature_symbol->as_C_string());
|
2018-10-17 15:57:10 -07:00
|
|
|
vm_exit_during_initialization("Invalid layout of well-known class");
|
2018-01-08 09:46:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!ik->find_local_field(name_symbol, signature_symbol, &fd) || fd.is_static() != is_static) {
|
2008-04-29 19:45:22 -07:00
|
|
|
ResourceMark rm;
|
2018-01-08 09:46:31 -05:00
|
|
|
log_error(class)("Invalid layout of %s field: %s type: %s", ik->external_name(),
|
|
|
|
name_symbol->as_C_string(), signature_symbol->as_C_string());
|
2012-07-24 10:51:00 -07:00
|
|
|
#ifndef PRODUCT
|
2018-01-08 09:46:31 -05:00
|
|
|
// Prints all fields and offsets
|
|
|
|
Log(class) lt;
|
|
|
|
LogStream ls(lt.error());
|
|
|
|
ik->print_on(&ls);
|
2012-07-24 10:51:00 -07:00
|
|
|
#endif //PRODUCT
|
2018-10-17 15:57:10 -07:00
|
|
|
vm_exit_during_initialization("Invalid layout of well-known class: use -Xlog:class+load=info to see the origin of the problem class");
|
2008-04-29 19:45:22 -07:00
|
|
|
}
|
|
|
|
dest_offset = fd.offset();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2018-01-08 09:46:31 -05:00
|
|
|
// Overloading to pass name as a string.
|
|
|
|
static void compute_offset(int& dest_offset, InstanceKlass* ik,
|
|
|
|
const char* name_string, Symbol* signature_symbol,
|
|
|
|
bool is_static = false) {
|
|
|
|
TempNewSymbol name = SymbolTable::probe(name_string, (int)strlen(name_string));
|
|
|
|
if (name == NULL) {
|
|
|
|
ResourceMark rm;
|
|
|
|
log_error(class)("Name %s should be in the SymbolTable since its class is loaded", name_string);
|
2018-10-17 15:57:10 -07:00
|
|
|
vm_exit_during_initialization("Invalid layout of well-known class", ik->external_name());
|
2018-01-08 09:46:31 -05:00
|
|
|
}
|
|
|
|
compute_offset(dest_offset, ik, name, signature_symbol, is_static);
|
|
|
|
}
|
|
|
|
|
2012-05-14 09:36:00 -07:00
|
|
|
int java_lang_String::value_offset = 0;
|
|
|
|
int java_lang_String::hash_offset = 0;
|
2019-04-10 12:05:50 +02:00
|
|
|
int java_lang_String::hashIsZero_offset = 0;
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
int java_lang_String::coder_offset = 0;
|
2012-05-14 09:36:00 -07:00
|
|
|
|
|
|
|
bool java_lang_String::initialized = false;
|
|
|
|
|
2015-02-13 14:37:35 +01:00
|
|
|
bool java_lang_String::is_instance(oop obj) {
|
|
|
|
return is_instance_inlined(obj);
|
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS
|
|
|
|
#define FIELD_SERIALIZE_OFFSET(offset, klass, name, signature, is_static) \
|
|
|
|
f->do_u4((u4*)&offset)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define FIELD_COMPUTE_OFFSET(offset, klass, name, signature, is_static) \
|
|
|
|
compute_offset(offset, klass, name, vmSymbols::signature(), is_static)
|
|
|
|
|
|
|
|
#define STRING_FIELDS_DO(macro) \
|
|
|
|
macro(value_offset, k, vmSymbols::value_name(), byte_array_signature, false); \
|
|
|
|
macro(hash_offset, k, "hash", int_signature, false); \
|
2019-04-10 12:05:50 +02:00
|
|
|
macro(hashIsZero_offset, k, "hashIsZero", bool_signature, false); \
|
|
|
|
macro(coder_offset, k, "coder", byte_signature, false);
|
2018-03-02 17:25:55 -05:00
|
|
|
|
2012-05-14 09:36:00 -07:00
|
|
|
void java_lang_String::compute_offsets() {
|
2018-03-02 17:25:55 -05:00
|
|
|
if (initialized) {
|
|
|
|
return;
|
|
|
|
}
|
2012-05-14 09:36:00 -07:00
|
|
|
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k = SystemDictionary::String_klass();
|
2018-03-02 17:25:55 -05:00
|
|
|
STRING_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
2012-05-14 09:36:00 -07:00
|
|
|
|
|
|
|
initialized = true;
|
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_String::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
STRING_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
2019-06-04 17:56:16 +08:00
|
|
|
f->do_bool(&initialized);
|
2018-03-02 17:25:55 -05:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
class CompactStringsFixup : public FieldClosure {
|
|
|
|
private:
|
|
|
|
bool _value;
|
|
|
|
|
|
|
|
public:
|
|
|
|
CompactStringsFixup(bool value) : _value(value) {}
|
|
|
|
|
|
|
|
void do_field(fieldDescriptor* fd) {
|
|
|
|
if (fd->name() == vmSymbols::compact_strings_name()) {
|
|
|
|
oop mirror = fd->field_holder()->java_mirror();
|
|
|
|
assert(fd->field_holder() == SystemDictionary::String_klass(), "Should be String");
|
|
|
|
assert(mirror != NULL, "String must have mirror already");
|
|
|
|
mirror->bool_field_put(fd->offset(), _value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void java_lang_String::set_compact_strings(bool value) {
|
|
|
|
CompactStringsFixup fix(value);
|
2019-04-05 10:01:09 +01:00
|
|
|
SystemDictionary::String_klass()->do_local_static_fields(&fix);
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Handle java_lang_String::basic_create(int length, bool is_latin1, TRAPS) {
|
2012-05-14 09:36:00 -07:00
|
|
|
assert(initialized, "Must be initialized");
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
assert(CompactStrings || !is_latin1, "Must be UTF16 without CompactStrings");
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Create the String object first, so there's a chance that the String
|
|
|
|
// and the char array it points to end up in the same cache line.
|
|
|
|
oop obj;
|
2015-10-26 13:11:36 -04:00
|
|
|
obj = SystemDictionary::String_klass()->allocate_instance(CHECK_NH);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Create the char array. The String object must be handlized here
|
|
|
|
// because GC can happen as a result of the allocation attempt.
|
|
|
|
Handle h_obj(THREAD, obj);
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
int arr_length = is_latin1 ? length : length << 1; // 2 bytes per UTF16.
|
|
|
|
typeArrayOop buffer = oopFactory::new_byteArray(arr_length, CHECK_NH);;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Point the String at the char array
|
|
|
|
obj = h_obj();
|
|
|
|
set_value(obj, buffer);
|
|
|
|
// No need to zero the offset, allocation zero'ed the entire String object
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
set_coder(obj, is_latin1 ? CODER_LATIN1 : CODER_UTF16);
|
2007-12-01 00:00:00 +00:00
|
|
|
return h_obj;
|
|
|
|
}
|
|
|
|
|
2018-09-18 21:47:14 -07:00
|
|
|
Handle java_lang_String::create_from_unicode(const jchar* unicode, int length, TRAPS) {
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
bool is_latin1 = CompactStrings && UNICODE::is_latin1(unicode, length);
|
|
|
|
Handle h_obj = basic_create(length, is_latin1, CHECK_NH);
|
2007-12-01 00:00:00 +00:00
|
|
|
typeArrayOop buffer = value(h_obj());
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
assert(TypeArrayKlass::cast(buffer->klass())->element_type() == T_BYTE, "only byte[]");
|
|
|
|
if (is_latin1) {
|
|
|
|
for (int index = 0; index < length; index++) {
|
|
|
|
buffer->byte_at_put(index, (jbyte)unicode[index]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (int index = 0; index < length; index++) {
|
|
|
|
buffer->char_at_put(index, unicode[index]);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
|
|
|
|
#ifdef ASSERT
|
|
|
|
{
|
|
|
|
ResourceMark rm;
|
|
|
|
char* expected = UNICODE::as_utf8(unicode, length);
|
|
|
|
char* actual = as_utf8_string(h_obj());
|
|
|
|
if (strcmp(expected, actual) != 0) {
|
|
|
|
tty->print_cr("Unicode conversion failure: %s --> %s", expected, actual);
|
|
|
|
ShouldNotReachHere();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
return h_obj;
|
|
|
|
}
|
|
|
|
|
2018-09-18 21:47:14 -07:00
|
|
|
oop java_lang_String::create_oop_from_unicode(const jchar* unicode, int length, TRAPS) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Handle h_obj = create_from_unicode(unicode, length, CHECK_0);
|
2007-12-01 00:00:00 +00:00
|
|
|
return h_obj();
|
|
|
|
}
|
|
|
|
|
|
|
|
Handle java_lang_String::create_from_str(const char* utf8_str, TRAPS) {
|
|
|
|
if (utf8_str == NULL) {
|
|
|
|
return Handle();
|
|
|
|
}
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
bool has_multibyte, is_latin1;
|
|
|
|
int length = UTF8::unicode_length(utf8_str, is_latin1, has_multibyte);
|
|
|
|
if (!CompactStrings) {
|
|
|
|
has_multibyte = true;
|
|
|
|
is_latin1 = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Handle h_obj = basic_create(length, is_latin1, CHECK_NH);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (length > 0) {
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
if (!has_multibyte) {
|
2018-06-04 23:01:48 +02:00
|
|
|
const jbyte* src = reinterpret_cast<const jbyte*>(utf8_str);
|
|
|
|
ArrayAccess<>::arraycopy_from_native(src, value(h_obj()), typeArrayOopDesc::element_offset<jbyte>(0), length);
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
} else if (is_latin1) {
|
|
|
|
UTF8::convert_to_unicode(utf8_str, value(h_obj())->byte_at_addr(0), length);
|
|
|
|
} else {
|
|
|
|
UTF8::convert_to_unicode(utf8_str, value(h_obj())->char_at_addr(0), length);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
|
|
|
|
#ifdef ASSERT
|
|
|
|
// This check is too strict because the input string is not necessarily valid UTF8.
|
|
|
|
// For example, it may be created with arbitrary content via jni_NewStringUTF.
|
|
|
|
/*
|
|
|
|
{
|
|
|
|
ResourceMark rm;
|
|
|
|
const char* expected = utf8_str;
|
|
|
|
char* actual = as_utf8_string(h_obj());
|
|
|
|
if (strcmp(expected, actual) != 0) {
|
|
|
|
tty->print_cr("String conversion failure: %s --> %s", expected, actual);
|
|
|
|
ShouldNotReachHere();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
#endif
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
return h_obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
oop java_lang_String::create_oop_from_str(const char* utf8_str, TRAPS) {
|
|
|
|
Handle h_obj = create_from_str(utf8_str, CHECK_0);
|
|
|
|
return h_obj();
|
|
|
|
}
|
|
|
|
|
2011-01-27 16:11:27 -08:00
|
|
|
Handle java_lang_String::create_from_symbol(Symbol* symbol, TRAPS) {
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
const char* utf8_str = (char*)symbol->bytes();
|
|
|
|
int utf8_len = symbol->utf8_length();
|
|
|
|
|
|
|
|
bool has_multibyte, is_latin1;
|
|
|
|
int length = UTF8::unicode_length(utf8_str, utf8_len, is_latin1, has_multibyte);
|
|
|
|
if (!CompactStrings) {
|
|
|
|
has_multibyte = true;
|
|
|
|
is_latin1 = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Handle h_obj = basic_create(length, is_latin1, CHECK_NH);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (length > 0) {
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
if (!has_multibyte) {
|
2018-06-04 23:01:48 +02:00
|
|
|
const jbyte* src = reinterpret_cast<const jbyte*>(utf8_str);
|
|
|
|
ArrayAccess<>::arraycopy_from_native(src, value(h_obj()), typeArrayOopDesc::element_offset<jbyte>(0), length);
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
} else if (is_latin1) {
|
|
|
|
UTF8::convert_to_unicode(utf8_str, value(h_obj())->byte_at_addr(0), length);
|
|
|
|
} else {
|
|
|
|
UTF8::convert_to_unicode(utf8_str, value(h_obj())->char_at_addr(0), length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ASSERT
|
|
|
|
{
|
|
|
|
ResourceMark rm;
|
|
|
|
const char* expected = symbol->as_utf8();
|
|
|
|
char* actual = as_utf8_string(h_obj());
|
|
|
|
if (strncmp(expected, actual, utf8_len) != 0) {
|
|
|
|
tty->print_cr("Symbol conversion failure: %s --> %s", expected, actual);
|
|
|
|
ShouldNotReachHere();
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
#endif
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
return h_obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Converts a C string to a Java String based on current encoding
|
|
|
|
Handle java_lang_String::create_from_platform_dependent_str(const char* str, TRAPS) {
|
|
|
|
assert(str != NULL, "bad arguments");
|
|
|
|
|
|
|
|
typedef jstring (*to_java_string_fn_t)(JNIEnv*, const char *);
|
|
|
|
static to_java_string_fn_t _to_java_string_fn = NULL;
|
|
|
|
|
|
|
|
if (_to_java_string_fn == NULL) {
|
|
|
|
void *lib_handle = os::native_java_library();
|
2019-10-08 10:24:22 +02:00
|
|
|
_to_java_string_fn = CAST_TO_FN_PTR(to_java_string_fn_t, os::dll_lookup(lib_handle, "JNU_NewStringPlatform"));
|
2007-12-01 00:00:00 +00:00
|
|
|
if (_to_java_string_fn == NULL) {
|
|
|
|
fatal("NewStringPlatform missing");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
jstring js = NULL;
|
2019-10-11 08:49:42 -04:00
|
|
|
{
|
|
|
|
assert(THREAD->is_Java_thread(), "must be java thread");
|
|
|
|
JavaThread* thread = (JavaThread*)THREAD;
|
2007-12-01 00:00:00 +00:00
|
|
|
HandleMark hm(thread);
|
2008-01-17 13:38:17 -08:00
|
|
|
ThreadToNativeFromVM ttn(thread);
|
2007-12-01 00:00:00 +00:00
|
|
|
js = (_to_java_string_fn)(thread->jni_environment(), str);
|
|
|
|
}
|
2019-10-11 08:49:42 -04:00
|
|
|
|
|
|
|
Handle native_platform_string(THREAD, JNIHandles::resolve(js));
|
|
|
|
JNIHandles::destroy_local(js); // destroy local JNIHandle.
|
|
|
|
return native_platform_string;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2008-01-17 13:38:17 -08:00
|
|
|
// Converts a Java String to a native C string that can be used for
|
|
|
|
// native OS calls.
|
|
|
|
char* java_lang_String::as_platform_dependent_str(Handle java_string, TRAPS) {
|
|
|
|
typedef char* (*to_platform_string_fn_t)(JNIEnv*, jstring, bool*);
|
|
|
|
static to_platform_string_fn_t _to_platform_string_fn = NULL;
|
|
|
|
|
|
|
|
if (_to_platform_string_fn == NULL) {
|
|
|
|
void *lib_handle = os::native_java_library();
|
2010-12-01 18:26:32 -05:00
|
|
|
_to_platform_string_fn = CAST_TO_FN_PTR(to_platform_string_fn_t, os::dll_lookup(lib_handle, "GetStringPlatformChars"));
|
2008-01-17 13:38:17 -08:00
|
|
|
if (_to_platform_string_fn == NULL) {
|
|
|
|
fatal("GetStringPlatformChars missing");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
char *native_platform_string;
|
|
|
|
{ JavaThread* thread = (JavaThread*)THREAD;
|
|
|
|
assert(thread->is_Java_thread(), "must be java thread");
|
|
|
|
JNIEnv *env = thread->jni_environment();
|
|
|
|
jstring js = (jstring) JNIHandles::make_local(env, java_string());
|
|
|
|
bool is_copy;
|
|
|
|
HandleMark hm(thread);
|
|
|
|
ThreadToNativeFromVM ttn(thread);
|
|
|
|
native_platform_string = (_to_platform_string_fn)(env, js, &is_copy);
|
|
|
|
assert(is_copy == JNI_TRUE, "is_copy value changed");
|
|
|
|
JNIHandles::destroy_local(js);
|
|
|
|
}
|
|
|
|
return native_platform_string;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
Handle java_lang_String::char_converter(Handle java_string, jchar from_char, jchar to_char, TRAPS) {
|
|
|
|
oop obj = java_string();
|
|
|
|
// Typical usage is to convert all '/' to '.' in string.
|
|
|
|
typeArrayOop value = java_lang_String::value(obj);
|
2019-01-22 11:22:44 +01:00
|
|
|
int length = java_lang_String::length(obj, value);
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
bool is_latin1 = java_lang_String::is_latin1(obj);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// First check if any from_char exist
|
|
|
|
int index; // Declared outside, used later
|
|
|
|
for (index = 0; index < length; index++) {
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
jchar c = !is_latin1 ? value->char_at(index) :
|
|
|
|
((jchar) value->byte_at(index)) & 0xff;
|
|
|
|
if (c == from_char) {
|
2007-12-01 00:00:00 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (index == length) {
|
|
|
|
// No from_char, so do not copy.
|
|
|
|
return java_string;
|
|
|
|
}
|
|
|
|
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
// Check if result string will be latin1
|
|
|
|
bool to_is_latin1 = false;
|
|
|
|
|
|
|
|
// Replacement char must be latin1
|
|
|
|
if (CompactStrings && UNICODE::is_latin1(to_char)) {
|
|
|
|
if (is_latin1) {
|
|
|
|
// Source string is latin1 as well
|
|
|
|
to_is_latin1 = true;
|
|
|
|
} else if (!UNICODE::is_latin1(from_char)) {
|
|
|
|
// We are replacing an UTF16 char. Scan string to
|
|
|
|
// check if result can be latin1 encoded.
|
|
|
|
to_is_latin1 = true;
|
|
|
|
for (index = 0; index < length; index++) {
|
|
|
|
jchar c = value->char_at(index);
|
|
|
|
if (c != from_char && !UNICODE::is_latin1(c)) {
|
|
|
|
to_is_latin1 = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create new UNICODE (or byte) buffer. Must handlize value because GC
|
2007-12-01 00:00:00 +00:00
|
|
|
// may happen during String and char array creation.
|
|
|
|
typeArrayHandle h_value(THREAD, value);
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
Handle string = basic_create(length, to_is_latin1, CHECK_NH);
|
2007-12-01 00:00:00 +00:00
|
|
|
typeArrayOop from_buffer = h_value();
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
typeArrayOop to_buffer = java_lang_String::value(string());
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Copy contents
|
|
|
|
for (index = 0; index < length; index++) {
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
jchar c = (!is_latin1) ? from_buffer->char_at(index) :
|
|
|
|
((jchar) from_buffer->byte_at(index)) & 0xff;
|
2007-12-01 00:00:00 +00:00
|
|
|
if (c == from_char) {
|
|
|
|
c = to_char;
|
|
|
|
}
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
if (!to_is_latin1) {
|
|
|
|
to_buffer->char_at_put(index, c);
|
|
|
|
} else {
|
|
|
|
to_buffer->byte_at_put(index, (jbyte) c);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
return string;
|
|
|
|
}
|
|
|
|
|
2013-04-29 16:13:57 -04:00
|
|
|
jchar* java_lang_String::as_unicode_string(oop java_string, int& length, TRAPS) {
|
2007-12-01 00:00:00 +00:00
|
|
|
typeArrayOop value = java_lang_String::value(java_string);
|
2019-01-22 11:22:44 +01:00
|
|
|
length = java_lang_String::length(java_string, value);
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
bool is_latin1 = java_lang_String::is_latin1(java_string);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2013-04-29 16:13:57 -04:00
|
|
|
jchar* result = NEW_RESOURCE_ARRAY_RETURN_NULL(jchar, length);
|
|
|
|
if (result != NULL) {
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
if (!is_latin1) {
|
|
|
|
for (int index = 0; index < length; index++) {
|
|
|
|
result[index] = value->char_at(index);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (int index = 0; index < length; index++) {
|
|
|
|
result[index] = ((jchar) value->byte_at(index)) & 0xff;
|
|
|
|
}
|
2013-04-29 16:13:57 -04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
THROW_MSG_0(vmSymbols::java_lang_OutOfMemoryError(), "could not allocate Unicode string");
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-12-13 10:09:49 +01:00
|
|
|
unsigned int java_lang_String::hash_code(oop java_string) {
|
2019-04-10 12:05:50 +02:00
|
|
|
// The hash and hashIsZero fields are subject to a benign data race,
|
|
|
|
// making it crucial to ensure that any observable result of the
|
|
|
|
// calculation in this method stays correct under any possible read of
|
|
|
|
// these fields. Necessary restrictions to allow this to be correct
|
|
|
|
// without explicit memory fences or similar concurrency primitives is
|
|
|
|
// that we can ever only write to one of these two fields for a given
|
|
|
|
// String instance, and that the computation is idempotent and derived
|
|
|
|
// from immutable state
|
|
|
|
assert(initialized && (hash_offset > 0) && (hashIsZero_offset > 0), "Must be initialized");
|
|
|
|
if (java_lang_String::hash_is_set(java_string)) {
|
|
|
|
return java_string->int_field(hash_offset);
|
|
|
|
}
|
2012-06-13 19:52:59 -04:00
|
|
|
|
2019-04-10 12:05:50 +02:00
|
|
|
typeArrayOop value = java_lang_String::value(java_string);
|
|
|
|
int length = java_lang_String::length(java_string, value);
|
|
|
|
bool is_latin1 = java_lang_String::is_latin1(java_string);
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
|
2019-04-10 12:05:50 +02:00
|
|
|
unsigned int hash = 0;
|
|
|
|
if (length > 0) {
|
|
|
|
if (is_latin1) {
|
|
|
|
hash = java_lang_String::hash_code(value->byte_at_addr(0), length);
|
|
|
|
} else {
|
|
|
|
hash = java_lang_String::hash_code(value->char_at_addr(0), length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hash != 0) {
|
|
|
|
java_string->int_field_put(hash_offset, hash);
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
} else {
|
2019-04-10 12:05:50 +02:00
|
|
|
java_string->bool_field_put(hashIsZero_offset, true);
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
}
|
2019-04-10 12:05:50 +02:00
|
|
|
return hash;
|
2012-06-13 19:52:59 -04:00
|
|
|
}
|
|
|
|
|
2012-11-12 14:03:53 -08:00
|
|
|
char* java_lang_String::as_quoted_ascii(oop java_string) {
|
|
|
|
typeArrayOop value = java_lang_String::value(java_string);
|
2019-01-22 11:22:44 +01:00
|
|
|
int length = java_lang_String::length(java_string, value);
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
bool is_latin1 = java_lang_String::is_latin1(java_string);
|
2012-11-12 14:03:53 -08:00
|
|
|
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
if (length == 0) return NULL;
|
2012-11-12 14:03:53 -08:00
|
|
|
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
char* result;
|
|
|
|
int result_length;
|
|
|
|
if (!is_latin1) {
|
|
|
|
jchar* base = value->char_at_addr(0);
|
|
|
|
result_length = UNICODE::quoted_ascii_length(base, length) + 1;
|
|
|
|
result = NEW_RESOURCE_ARRAY(char, result_length);
|
|
|
|
UNICODE::as_quoted_ascii(base, length, result, result_length);
|
|
|
|
} else {
|
|
|
|
jbyte* base = value->byte_at_addr(0);
|
|
|
|
result_length = UNICODE::quoted_ascii_length(base, length) + 1;
|
|
|
|
result = NEW_RESOURCE_ARRAY(char, result_length);
|
|
|
|
UNICODE::as_quoted_ascii(base, length, result, result_length);
|
|
|
|
}
|
2012-11-12 14:03:53 -08:00
|
|
|
assert(result_length >= length + 1, "must not be shorter");
|
|
|
|
assert(result_length == (int)strlen(result) + 1, "must match");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-05-14 11:29:18 -04:00
|
|
|
Symbol* java_lang_String::as_symbol(oop java_string) {
|
2017-02-15 22:59:57 -05:00
|
|
|
typeArrayOop value = java_lang_String::value(java_string);
|
2019-01-22 11:22:44 +01:00
|
|
|
int length = java_lang_String::length(java_string, value);
|
2017-02-15 22:59:57 -05:00
|
|
|
bool is_latin1 = java_lang_String::is_latin1(java_string);
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
if (!is_latin1) {
|
|
|
|
jchar* base = (length == 0) ? NULL : value->char_at_addr(0);
|
2019-05-14 11:29:18 -04:00
|
|
|
Symbol* sym = SymbolTable::new_symbol(base, length);
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
return sym;
|
|
|
|
} else {
|
|
|
|
ResourceMark rm;
|
|
|
|
jbyte* position = (length == 0) ? NULL : value->byte_at_addr(0);
|
|
|
|
const char* base = UNICODE::as_utf8(position, length);
|
2019-05-14 11:29:18 -04:00
|
|
|
Symbol* sym = SymbolTable::new_symbol(base, length);
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
return sym;
|
|
|
|
}
|
2009-03-20 23:19:36 -07:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* java_lang_String::as_symbol_or_null(oop java_string) {
|
2009-03-20 23:19:36 -07:00
|
|
|
typeArrayOop value = java_lang_String::value(java_string);
|
2019-01-22 11:22:44 +01:00
|
|
|
int length = java_lang_String::length(java_string, value);
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
bool is_latin1 = java_lang_String::is_latin1(java_string);
|
|
|
|
if (!is_latin1) {
|
|
|
|
jchar* base = (length == 0) ? NULL : value->char_at_addr(0);
|
|
|
|
return SymbolTable::probe_unicode(base, length);
|
|
|
|
} else {
|
|
|
|
ResourceMark rm;
|
|
|
|
jbyte* position = (length == 0) ? NULL : value->byte_at_addr(0);
|
|
|
|
const char* base = UNICODE::as_utf8(position, length);
|
|
|
|
return SymbolTable::probe(base, length);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2019-01-22 11:22:44 +01:00
|
|
|
int java_lang_String::utf8_length(oop java_string, typeArrayOop value) {
|
2019-03-13 17:32:17 +01:00
|
|
|
assert(value_equals(value, java_lang_String::value(java_string)),
|
2019-01-22 11:22:44 +01:00
|
|
|
"value must be same as java_lang_String::value(java_string)");
|
|
|
|
int length = java_lang_String::length(java_string, value);
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
if (length == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
2019-01-22 11:22:44 +01:00
|
|
|
if (!java_lang_String::is_latin1(java_string)) {
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
return UNICODE::utf8_length(value->char_at_addr(0), length);
|
|
|
|
} else {
|
|
|
|
return UNICODE::utf8_length(value->byte_at_addr(0), length);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2019-01-22 11:22:44 +01:00
|
|
|
int java_lang_String::utf8_length(oop java_string) {
|
|
|
|
typeArrayOop value = java_lang_String::value(java_string);
|
|
|
|
return utf8_length(java_string, value);
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
char* java_lang_String::as_utf8_string(oop java_string) {
|
|
|
|
typeArrayOop value = java_lang_String::value(java_string);
|
2019-01-22 11:22:44 +01:00
|
|
|
int length = java_lang_String::length(java_string, value);
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
bool is_latin1 = java_lang_String::is_latin1(java_string);
|
|
|
|
if (!is_latin1) {
|
|
|
|
jchar* position = (length == 0) ? NULL : value->char_at_addr(0);
|
|
|
|
return UNICODE::as_utf8(position, length);
|
|
|
|
} else {
|
|
|
|
jbyte* position = (length == 0) ? NULL : value->byte_at_addr(0);
|
|
|
|
return UNICODE::as_utf8(position, length);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2019-01-22 11:22:44 +01:00
|
|
|
char* java_lang_String::as_utf8_string(oop java_string, typeArrayOop value, char* buf, int buflen) {
|
2019-03-13 17:32:17 +01:00
|
|
|
assert(value_equals(value, java_lang_String::value(java_string)),
|
2019-01-22 11:22:44 +01:00
|
|
|
"value must be same as java_lang_String::value(java_string)");
|
|
|
|
int length = java_lang_String::length(java_string, value);
|
|
|
|
bool is_latin1 = java_lang_String::is_latin1(java_string);
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
if (!is_latin1) {
|
|
|
|
jchar* position = (length == 0) ? NULL : value->char_at_addr(0);
|
|
|
|
return UNICODE::as_utf8(position, length, buf, buflen);
|
|
|
|
} else {
|
|
|
|
jbyte* position = (length == 0) ? NULL : value->byte_at_addr(0);
|
|
|
|
return UNICODE::as_utf8(position, length, buf, buflen);
|
|
|
|
}
|
2010-12-07 03:15:45 -08:00
|
|
|
}
|
|
|
|
|
2019-01-22 11:22:44 +01:00
|
|
|
char* java_lang_String::as_utf8_string(oop java_string, char* buf, int buflen) {
|
|
|
|
typeArrayOop value = java_lang_String::value(java_string);
|
|
|
|
return as_utf8_string(java_string, value, buf, buflen);
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
char* java_lang_String::as_utf8_string(oop java_string, int start, int len) {
|
|
|
|
typeArrayOop value = java_lang_String::value(java_string);
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
bool is_latin1 = java_lang_String::is_latin1(java_string);
|
2019-01-22 11:22:44 +01:00
|
|
|
assert(start + len <= java_lang_String::length(java_string), "just checking");
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
if (!is_latin1) {
|
|
|
|
jchar* position = value->char_at_addr(start);
|
|
|
|
return UNICODE::as_utf8(position, len);
|
|
|
|
} else {
|
|
|
|
jbyte* position = value->byte_at_addr(start);
|
|
|
|
return UNICODE::as_utf8(position, len);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2019-01-22 11:22:44 +01:00
|
|
|
char* java_lang_String::as_utf8_string(oop java_string, typeArrayOop value, int start, int len, char* buf, int buflen) {
|
2019-03-13 17:32:17 +01:00
|
|
|
assert(value_equals(value, java_lang_String::value(java_string)),
|
2019-01-22 11:22:44 +01:00
|
|
|
"value must be same as java_lang_String::value(java_string)");
|
|
|
|
assert(start + len <= java_lang_String::length(java_string), "just checking");
|
|
|
|
bool is_latin1 = java_lang_String::is_latin1(java_string);
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
if (!is_latin1) {
|
|
|
|
jchar* position = value->char_at_addr(start);
|
|
|
|
return UNICODE::as_utf8(position, len, buf, buflen);
|
|
|
|
} else {
|
|
|
|
jbyte* position = value->byte_at_addr(start);
|
|
|
|
return UNICODE::as_utf8(position, len, buf, buflen);
|
|
|
|
}
|
2014-04-03 14:54:42 +02:00
|
|
|
}
|
|
|
|
|
2018-09-18 21:47:14 -07:00
|
|
|
bool java_lang_String::equals(oop java_string, const jchar* chars, int len) {
|
2012-10-10 17:04:33 -04:00
|
|
|
assert(java_string->klass() == SystemDictionary::String_klass(),
|
2007-12-01 00:00:00 +00:00
|
|
|
"must be java_string");
|
2018-01-08 16:21:23 +01:00
|
|
|
typeArrayOop value = java_lang_String::value_no_keepalive(java_string);
|
2019-01-22 11:22:44 +01:00
|
|
|
int length = java_lang_String::length(java_string, value);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (length != len) {
|
|
|
|
return false;
|
|
|
|
}
|
2018-01-08 16:21:23 +01:00
|
|
|
bool is_latin1 = java_lang_String::is_latin1(java_string);
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
if (!is_latin1) {
|
|
|
|
for (int i = 0; i < len; i++) {
|
|
|
|
if (value->char_at(i) != chars[i]) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (int i = 0; i < len; i++) {
|
|
|
|
if ((((jchar) value->byte_at(i)) & 0xff) != chars[i]) {
|
|
|
|
return false;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-18 07:02:10 -07:00
|
|
|
bool java_lang_String::equals(oop str1, oop str2) {
|
|
|
|
assert(str1->klass() == SystemDictionary::String_klass(),
|
|
|
|
"must be java String");
|
|
|
|
assert(str2->klass() == SystemDictionary::String_klass(),
|
|
|
|
"must be java String");
|
2018-01-08 16:21:23 +01:00
|
|
|
typeArrayOop value1 = java_lang_String::value_no_keepalive(str1);
|
|
|
|
bool is_latin1 = java_lang_String::is_latin1(str1);
|
|
|
|
typeArrayOop value2 = java_lang_String::value_no_keepalive(str2);
|
|
|
|
bool is_latin2 = java_lang_String::is_latin1(str2);
|
2013-09-18 07:02:10 -07:00
|
|
|
|
2019-03-13 17:32:17 +01:00
|
|
|
if (is_latin1 != is_latin2) {
|
|
|
|
// Strings with different coders are never equal.
|
2013-09-18 07:02:10 -07:00
|
|
|
return false;
|
|
|
|
}
|
2019-03-13 17:32:17 +01:00
|
|
|
return value_equals(value1, value2);
|
2013-09-18 07:02:10 -07:00
|
|
|
}
|
|
|
|
|
2014-02-27 10:34:55 +01:00
|
|
|
void java_lang_String::print(oop java_string, outputStream* st) {
|
|
|
|
assert(java_string->klass() == SystemDictionary::String_klass(), "must be java_string");
|
2018-01-08 16:21:23 +01:00
|
|
|
typeArrayOop value = java_lang_String::value_no_keepalive(java_string);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
if (value == NULL) {
|
|
|
|
// This can happen if, e.g., printing a String
|
|
|
|
// object before its initializer has been called
|
2014-04-08 11:50:01 +02:00
|
|
|
st->print("NULL");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-01-22 11:22:44 +01:00
|
|
|
int length = java_lang_String::length(java_string, value);
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
bool is_latin1 = java_lang_String::is_latin1(java_string);
|
2014-04-08 11:50:01 +02:00
|
|
|
|
|
|
|
st->print("\"");
|
|
|
|
for (int index = 0; index < length; index++) {
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
st->print("%c", (!is_latin1) ? value->char_at(index) :
|
|
|
|
((jchar) value->byte_at(index)) & 0xff );
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2014-04-08 11:50:01 +02:00
|
|
|
st->print("\"");
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2014-04-08 13:58:38 -04:00
|
|
|
|
|
|
|
static void initialize_static_field(fieldDescriptor* fd, Handle mirror, TRAPS) {
|
2011-03-18 16:00:34 -07:00
|
|
|
assert(mirror.not_null() && fd->is_static(), "just checking");
|
|
|
|
if (fd->has_initial_value()) {
|
|
|
|
BasicType t = fd->field_type();
|
|
|
|
switch (t) {
|
|
|
|
case T_BYTE:
|
|
|
|
mirror()->byte_field_put(fd->offset(), fd->int_initial_value());
|
|
|
|
break;
|
|
|
|
case T_BOOLEAN:
|
|
|
|
mirror()->bool_field_put(fd->offset(), fd->int_initial_value());
|
|
|
|
break;
|
|
|
|
case T_CHAR:
|
|
|
|
mirror()->char_field_put(fd->offset(), fd->int_initial_value());
|
|
|
|
break;
|
|
|
|
case T_SHORT:
|
|
|
|
mirror()->short_field_put(fd->offset(), fd->int_initial_value());
|
|
|
|
break;
|
|
|
|
case T_INT:
|
|
|
|
mirror()->int_field_put(fd->offset(), fd->int_initial_value());
|
|
|
|
break;
|
|
|
|
case T_FLOAT:
|
|
|
|
mirror()->float_field_put(fd->offset(), fd->float_initial_value());
|
|
|
|
break;
|
|
|
|
case T_DOUBLE:
|
|
|
|
mirror()->double_field_put(fd->offset(), fd->double_initial_value());
|
|
|
|
break;
|
|
|
|
case T_LONG:
|
|
|
|
mirror()->long_field_put(fd->offset(), fd->long_initial_value());
|
|
|
|
break;
|
|
|
|
case T_OBJECT:
|
|
|
|
{
|
2018-03-02 17:25:55 -05:00
|
|
|
assert(fd->signature() == vmSymbols::string_signature(),
|
|
|
|
"just checking");
|
2018-10-09 15:58:07 -04:00
|
|
|
if (DumpSharedSpaces && HeapShared::is_archived_object(mirror())) {
|
2018-03-02 17:25:55 -05:00
|
|
|
// Archive the String field and update the pointer.
|
|
|
|
oop s = mirror()->obj_field(fd->offset());
|
|
|
|
oop archived_s = StringTable::create_archived_string(s, CHECK);
|
|
|
|
mirror()->obj_field_put(fd->offset(), archived_s);
|
|
|
|
} else {
|
|
|
|
oop string = fd->string_initial_value(CHECK);
|
|
|
|
mirror()->obj_field_put(fd->offset(), string);
|
|
|
|
}
|
2011-03-18 16:00:34 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
THROW_MSG(vmSymbols::java_lang_ClassFormatError(),
|
|
|
|
"Illegal ConstantValue attribute in class file");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-15 10:25:37 -04:00
|
|
|
void java_lang_Class::fixup_mirror(Klass* k, TRAPS) {
|
2012-09-07 12:04:16 -04:00
|
|
|
assert(InstanceMirrorKlass::offset_of_static_fields() != 0, "must have been computed already");
|
2011-03-18 16:00:34 -07:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// If the offset was read from the shared archive, it was fixed up already
|
|
|
|
if (!k->is_shared()) {
|
2015-10-28 09:47:23 -04:00
|
|
|
if (k->is_instance_klass()) {
|
2013-05-22 14:37:49 -04:00
|
|
|
// During bootstrap, java.lang.Class wasn't loaded so static field
|
|
|
|
// offsets were computed without the size added it. Go back and
|
|
|
|
// update all the static field offsets to included the size.
|
2018-06-12 18:12:59 -04:00
|
|
|
for (JavaFieldStream fs(InstanceKlass::cast(k)); !fs.done(); fs.next()) {
|
2013-05-22 14:37:49 -04:00
|
|
|
if (fs.access_flags().is_static()) {
|
|
|
|
int real_offset = fs.offset() + InstanceMirrorKlass::offset_of_static_fields();
|
|
|
|
fs.set_offset(real_offset);
|
|
|
|
}
|
2011-09-10 17:29:02 -07:00
|
|
|
}
|
|
|
|
}
|
2011-03-18 16:00:34 -07:00
|
|
|
}
|
2018-03-02 17:25:55 -05:00
|
|
|
|
|
|
|
if (k->is_shared() && k->has_raw_archived_mirror()) {
|
2018-10-09 15:58:07 -04:00
|
|
|
if (HeapShared::open_archive_heap_region_mapped()) {
|
2018-06-12 18:12:59 -04:00
|
|
|
bool present = restore_archived_mirror(k, Handle(), Handle(), Handle(), CHECK);
|
|
|
|
assert(present, "Missing archived mirror for %s", k->external_name());
|
2018-03-02 17:25:55 -05:00
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
k->set_java_mirror_handle(NULL);
|
|
|
|
k->clear_has_raw_archived_mirror();
|
|
|
|
}
|
|
|
|
}
|
2017-02-15 22:59:57 -05:00
|
|
|
create_mirror(k, Handle(), Handle(), Handle(), CHECK);
|
2011-03-18 16:00:34 -07:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2017-03-15 10:25:37 -04:00
|
|
|
void java_lang_Class::initialize_mirror_fields(Klass* k,
|
2014-04-08 13:58:38 -04:00
|
|
|
Handle mirror,
|
|
|
|
Handle protection_domain,
|
|
|
|
TRAPS) {
|
|
|
|
// Allocate a simple java object for a lock.
|
|
|
|
// This needs to be a java object because during class initialization
|
|
|
|
// it can be held across a java call.
|
|
|
|
typeArrayOop r = oopFactory::new_typeArray(T_INT, 0, CHECK);
|
|
|
|
set_init_lock(mirror(), r);
|
|
|
|
|
|
|
|
// Set protection domain also
|
|
|
|
set_protection_domain(mirror(), protection_domain());
|
|
|
|
|
|
|
|
// Initialize static fields
|
2017-03-15 10:25:37 -04:00
|
|
|
InstanceKlass::cast(k)->do_local_static_fields(&initialize_static_field, mirror, CHECK);
|
2014-04-08 13:58:38 -04:00
|
|
|
}
|
|
|
|
|
2017-04-07 08:04:46 +00:00
|
|
|
// Set the java.lang.Module module field in the java_lang_Class mirror
|
2017-03-15 10:25:37 -04:00
|
|
|
void java_lang_Class::set_mirror_module_field(Klass* k, Handle mirror, Handle module, TRAPS) {
|
2016-09-19 12:04:28 -04:00
|
|
|
if (module.is_null()) {
|
|
|
|
// During startup, the module may be NULL only if java.base has not been defined yet.
|
2017-04-07 08:04:46 +00:00
|
|
|
// Put the class on the fixup_module_list to patch later when the java.lang.Module
|
2019-03-10 18:53:55 -04:00
|
|
|
// for java.base is known. But note that since we captured the NULL module another
|
|
|
|
// thread may have completed that initialization.
|
2016-10-10 08:34:32 -04:00
|
|
|
|
|
|
|
bool javabase_was_defined = false;
|
|
|
|
{
|
|
|
|
MutexLocker m1(Module_lock, THREAD);
|
|
|
|
// Keep list of classes needing java.base module fixup
|
|
|
|
if (!ModuleEntryTable::javabase_defined()) {
|
2017-08-08 08:41:36 -04:00
|
|
|
assert(k->java_mirror() != NULL, "Class's mirror is null");
|
2016-10-10 08:34:32 -04:00
|
|
|
k->class_loader_data()->inc_keep_alive();
|
2017-08-08 08:41:36 -04:00
|
|
|
assert(fixup_module_field_list() != NULL, "fixup_module_field_list not initialized");
|
2017-03-15 10:25:37 -04:00
|
|
|
fixup_module_field_list()->push(k);
|
2016-10-10 08:34:32 -04:00
|
|
|
} else {
|
|
|
|
javabase_was_defined = true;
|
2016-09-19 12:04:28 -04:00
|
|
|
}
|
2016-10-10 08:34:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// If java.base was already defined then patch this particular class with java.base.
|
|
|
|
if (javabase_was_defined) {
|
2016-09-19 12:04:28 -04:00
|
|
|
ModuleEntry *javabase_entry = ModuleEntryTable::javabase_moduleEntry();
|
2017-08-23 12:00:39 -04:00
|
|
|
assert(javabase_entry != NULL && javabase_entry->module() != NULL,
|
2016-12-05 16:08:20 -05:00
|
|
|
"Setting class module field, " JAVA_BASE_NAME " should be defined");
|
2017-08-08 09:53:52 -04:00
|
|
|
Handle javabase_handle(THREAD, javabase_entry->module());
|
2016-09-19 12:04:28 -04:00
|
|
|
set_module(mirror(), javabase_handle());
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
assert(Universe::is_module_initialized() ||
|
|
|
|
(ModuleEntryTable::javabase_defined() &&
|
2019-09-17 09:51:02 +02:00
|
|
|
(module() == ModuleEntryTable::javabase_moduleEntry()->module())),
|
2017-04-07 08:04:46 +00:00
|
|
|
"Incorrect java.lang.Module specification while creating mirror");
|
2016-09-19 12:04:28 -04:00
|
|
|
set_module(mirror(), module());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-08 08:41:36 -04:00
|
|
|
// Statically allocate fixup lists because they always get created.
|
|
|
|
void java_lang_Class::allocate_fixup_lists() {
|
|
|
|
GrowableArray<Klass*>* mirror_list =
|
|
|
|
new (ResourceObj::C_HEAP, mtClass) GrowableArray<Klass*>(40, true);
|
|
|
|
set_fixup_mirror_list(mirror_list);
|
|
|
|
|
|
|
|
GrowableArray<Klass*>* module_list =
|
|
|
|
new (ResourceObj::C_HEAP, mtModule) GrowableArray<Klass*>(500, true);
|
|
|
|
set_fixup_module_field_list(module_list);
|
|
|
|
}
|
|
|
|
|
2017-03-15 10:25:37 -04:00
|
|
|
void java_lang_Class::create_mirror(Klass* k, Handle class_loader,
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
Handle module, Handle protection_domain, TRAPS) {
|
2017-07-24 17:46:06 -04:00
|
|
|
assert(k != NULL, "Use create_basic_type_mirror for primitive types");
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(k->java_mirror() == NULL, "should only assign mirror once");
|
2017-08-08 08:41:36 -04:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Use this moment of initialization to cache modifier_flags also,
|
|
|
|
// to support Class.getModifiers(). Instance classes recalculate
|
|
|
|
// the cached flags after the class file is parsed, but before the
|
|
|
|
// class is put into the system dictionary.
|
2014-04-08 13:58:38 -04:00
|
|
|
int computed_modifiers = k->compute_modifier_flags(CHECK);
|
2007-12-01 00:00:00 +00:00
|
|
|
k->set_modifier_flags(computed_modifiers);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Class_klass has to be loaded because it is used to allocate
|
|
|
|
// the mirror.
|
|
|
|
if (SystemDictionary::Class_klass_loaded()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Allocate mirror (java.lang.Class instance)
|
2017-02-15 22:59:57 -05:00
|
|
|
oop mirror_oop = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(k, CHECK);
|
|
|
|
Handle mirror(THREAD, mirror_oop);
|
2017-07-24 17:46:06 -04:00
|
|
|
Handle comp_mirror;
|
2014-04-08 13:58:38 -04:00
|
|
|
|
|
|
|
// Setup indirection from mirror->klass
|
2017-07-24 17:46:06 -04:00
|
|
|
java_lang_Class::set_klass(mirror(), k);
|
2011-03-18 16:00:34 -07:00
|
|
|
|
2012-09-07 12:04:16 -04:00
|
|
|
InstanceMirrorKlass* mk = InstanceMirrorKlass::cast(mirror->klass());
|
2014-04-08 13:58:38 -04:00
|
|
|
assert(oop_size(mirror()) == mk->instance_size(k), "should have been set");
|
|
|
|
|
2011-03-18 16:00:34 -07:00
|
|
|
java_lang_Class::set_static_oop_field_count(mirror(), mk->compute_static_oop_field_count(mirror()));
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// It might also have a component mirror. This mirror must already exist.
|
2015-10-28 09:47:23 -04:00
|
|
|
if (k->is_array_klass()) {
|
|
|
|
if (k->is_typeArray_klass()) {
|
2017-03-15 10:25:37 -04:00
|
|
|
BasicType type = TypeArrayKlass::cast(k)->element_type();
|
2017-07-24 17:46:06 -04:00
|
|
|
comp_mirror = Handle(THREAD, Universe::java_mirror(type));
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
} else {
|
2015-10-28 09:47:23 -04:00
|
|
|
assert(k->is_objArray_klass(), "Must be");
|
2017-03-15 10:25:37 -04:00
|
|
|
Klass* element_klass = ObjArrayKlass::cast(k)->element_klass();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
assert(element_klass != NULL, "Must have an element klass");
|
2017-07-24 17:46:06 -04:00
|
|
|
comp_mirror = Handle(THREAD, element_klass->java_mirror());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2017-07-24 17:46:06 -04:00
|
|
|
assert(comp_mirror() != NULL, "must have a mirror");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2014-04-08 13:58:38 -04:00
|
|
|
// Two-way link between the array klass and its component mirror:
|
2014-07-02 15:22:18 -04:00
|
|
|
// (array_klass) k -> mirror -> component_mirror -> array_klass -> k
|
2017-07-24 17:46:06 -04:00
|
|
|
set_component_mirror(mirror(), comp_mirror());
|
|
|
|
// See below for ordering dependencies between field array_klass in component mirror
|
|
|
|
// and java_mirror in this klass.
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
} else {
|
2015-10-28 09:47:23 -04:00
|
|
|
assert(k->is_instance_klass(), "Must be");
|
2013-05-22 14:37:49 -04:00
|
|
|
|
2014-04-08 13:58:38 -04:00
|
|
|
initialize_mirror_fields(k, mirror, protection_domain, THREAD);
|
|
|
|
if (HAS_PENDING_EXCEPTION) {
|
|
|
|
// If any of the fields throws an exception like OOM remove the klass field
|
|
|
|
// from the mirror so GC doesn't follow it after the klass has been deallocated.
|
|
|
|
// This mirror looks like a primitive type, which logically it is because it
|
|
|
|
// it represents no class.
|
|
|
|
java_lang_Class::set_klass(mirror(), NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-05-22 14:37:49 -04:00
|
|
|
|
2014-06-19 14:49:33 -04:00
|
|
|
// set the classLoader field in the java_lang_Class instance
|
2019-09-17 09:51:02 +02:00
|
|
|
assert(class_loader() == k->class_loader(), "should be same");
|
2014-06-19 14:49:33 -04:00
|
|
|
set_class_loader(mirror(), class_loader());
|
|
|
|
|
2017-07-24 17:46:06 -04:00
|
|
|
// Setup indirection from klass->mirror
|
2014-04-08 13:58:38 -04:00
|
|
|
// after any exceptions can happen during allocations.
|
2017-10-03 16:42:04 -04:00
|
|
|
k->set_java_mirror(mirror);
|
2017-08-08 08:41:36 -04:00
|
|
|
|
|
|
|
// Set the module field in the java_lang_Class instance. This must be done
|
|
|
|
// after the mirror is set.
|
|
|
|
set_mirror_module_field(k, mirror, module, THREAD);
|
|
|
|
|
2017-07-24 17:46:06 -04:00
|
|
|
if (comp_mirror() != NULL) {
|
|
|
|
// Set after k->java_mirror() is published, because compiled code running
|
|
|
|
// concurrently doesn't expect a k to have a null java_mirror.
|
|
|
|
release_set_array_klass(comp_mirror(), k);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
} else {
|
2017-08-08 08:41:36 -04:00
|
|
|
assert(fixup_mirror_list() != NULL, "fixup_mirror_list not initialized");
|
2017-03-15 10:25:37 -04:00
|
|
|
fixup_mirror_list()->push(k);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS_JAVA_HEAP
|
|
|
|
// Clears mirror fields. Static final fields with initial values are reloaded
|
|
|
|
// from constant pool. The object identity hash is in the object header and is
|
|
|
|
// not affected.
|
|
|
|
class ResetMirrorField: public FieldClosure {
|
|
|
|
private:
|
|
|
|
Handle _m;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ResetMirrorField(Handle mirror) : _m(mirror) {}
|
|
|
|
|
|
|
|
void do_field(fieldDescriptor* fd) {
|
|
|
|
assert(DumpSharedSpaces, "dump time only");
|
|
|
|
assert(_m.not_null(), "Mirror cannot be NULL");
|
|
|
|
|
|
|
|
if (fd->is_static() && fd->has_initial_value()) {
|
|
|
|
initialize_static_field(fd, _m, Thread::current());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
BasicType ft = fd->field_type();
|
|
|
|
switch (ft) {
|
|
|
|
case T_BYTE:
|
|
|
|
_m()->byte_field_put(fd->offset(), 0);
|
|
|
|
break;
|
|
|
|
case T_CHAR:
|
|
|
|
_m()->char_field_put(fd->offset(), 0);
|
|
|
|
break;
|
|
|
|
case T_DOUBLE:
|
|
|
|
_m()->double_field_put(fd->offset(), 0);
|
|
|
|
break;
|
|
|
|
case T_FLOAT:
|
|
|
|
_m()->float_field_put(fd->offset(), 0);
|
|
|
|
break;
|
|
|
|
case T_INT:
|
|
|
|
_m()->int_field_put(fd->offset(), 0);
|
|
|
|
break;
|
|
|
|
case T_LONG:
|
|
|
|
_m()->long_field_put(fd->offset(), 0);
|
|
|
|
break;
|
|
|
|
case T_SHORT:
|
|
|
|
_m()->short_field_put(fd->offset(), 0);
|
|
|
|
break;
|
|
|
|
case T_BOOLEAN:
|
|
|
|
_m()->bool_field_put(fd->offset(), false);
|
|
|
|
break;
|
|
|
|
case T_ARRAY:
|
|
|
|
case T_OBJECT: {
|
|
|
|
// It might be useful to cache the String field, but
|
|
|
|
// for now just clear out any reference field
|
|
|
|
oop o = _m()->obj_field(fd->offset());
|
|
|
|
_m()->obj_field_put(fd->offset(), NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
ShouldNotReachHere();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void java_lang_Class::archive_basic_type_mirrors(TRAPS) {
|
2018-10-09 15:58:07 -04:00
|
|
|
assert(HeapShared::is_heap_object_archiving_allowed(),
|
|
|
|
"HeapShared::is_heap_object_archiving_allowed() must be true");
|
2018-03-02 17:25:55 -05:00
|
|
|
|
|
|
|
for (int t = 0; t <= T_VOID; t++) {
|
|
|
|
oop m = Universe::_mirrors[t];
|
|
|
|
if (m != NULL) {
|
|
|
|
// Update the field at _array_klass_offset to point to the relocated array klass.
|
2018-10-09 15:58:07 -04:00
|
|
|
oop archived_m = HeapShared::archive_heap_object(m, THREAD);
|
2018-08-16 17:29:22 -04:00
|
|
|
assert(archived_m != NULL, "sanity");
|
2018-03-02 17:25:55 -05:00
|
|
|
Klass *ak = (Klass*)(archived_m->metadata_field(_array_klass_offset));
|
|
|
|
assert(ak != NULL || t == T_VOID, "should not be NULL");
|
|
|
|
if (ak != NULL) {
|
|
|
|
Klass *reloc_ak = MetaspaceShared::get_relocated_klass(ak);
|
|
|
|
archived_m->metadata_field_put(_array_klass_offset, reloc_ak);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clear the fields. Just to be safe
|
|
|
|
Klass *k = m->klass();
|
|
|
|
Handle archived_mirror_h(THREAD, archived_m);
|
|
|
|
ResetMirrorField reset(archived_mirror_h);
|
|
|
|
InstanceKlass::cast(k)->do_nonstatic_fields(&reset);
|
|
|
|
|
2018-07-08 12:43:05 -04:00
|
|
|
log_trace(cds, heap, mirror)(
|
|
|
|
"Archived %s mirror object from " PTR_FORMAT " ==> " PTR_FORMAT,
|
|
|
|
type2name((BasicType)t), p2i(Universe::_mirrors[t]), p2i(archived_m));
|
2018-03-02 17:25:55 -05:00
|
|
|
|
|
|
|
Universe::_mirrors[t] = archived_m;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(Universe::_mirrors[T_INT] != NULL &&
|
|
|
|
Universe::_mirrors[T_FLOAT] != NULL &&
|
|
|
|
Universe::_mirrors[T_DOUBLE] != NULL &&
|
|
|
|
Universe::_mirrors[T_BYTE] != NULL &&
|
|
|
|
Universe::_mirrors[T_BOOLEAN] != NULL &&
|
|
|
|
Universe::_mirrors[T_CHAR] != NULL &&
|
|
|
|
Universe::_mirrors[T_LONG] != NULL &&
|
|
|
|
Universe::_mirrors[T_SHORT] != NULL &&
|
|
|
|
Universe::_mirrors[T_VOID] != NULL, "sanity");
|
|
|
|
|
|
|
|
Universe::set_int_mirror(Universe::_mirrors[T_INT]);
|
|
|
|
Universe::set_float_mirror(Universe::_mirrors[T_FLOAT]);
|
|
|
|
Universe::set_double_mirror(Universe::_mirrors[T_DOUBLE]);
|
|
|
|
Universe::set_byte_mirror(Universe::_mirrors[T_BYTE]);
|
|
|
|
Universe::set_bool_mirror(Universe::_mirrors[T_BOOLEAN]);
|
|
|
|
Universe::set_char_mirror(Universe::_mirrors[T_CHAR]);
|
|
|
|
Universe::set_long_mirror(Universe::_mirrors[T_LONG]);
|
|
|
|
Universe::set_short_mirror(Universe::_mirrors[T_SHORT]);
|
|
|
|
Universe::set_void_mirror(Universe::_mirrors[T_VOID]);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// After the mirror object is successfully archived, the archived
|
|
|
|
// klass is set with _has_archived_raw_mirror flag.
|
|
|
|
//
|
|
|
|
// The _has_archived_raw_mirror flag is cleared at runtime when the
|
|
|
|
// archived mirror is restored. If archived java heap data cannot
|
|
|
|
// be used at runtime, new mirror object is created for the shared
|
|
|
|
// class. The _has_archived_raw_mirror is cleared also during the process.
|
|
|
|
oop java_lang_Class::archive_mirror(Klass* k, TRAPS) {
|
2018-10-09 15:58:07 -04:00
|
|
|
assert(HeapShared::is_heap_object_archiving_allowed(),
|
|
|
|
"HeapShared::is_heap_object_archiving_allowed() must be true");
|
2018-03-02 17:25:55 -05:00
|
|
|
|
|
|
|
// Mirror is already archived
|
|
|
|
if (k->has_raw_archived_mirror()) {
|
|
|
|
assert(k->archived_java_mirror_raw() != NULL, "no archived mirror");
|
|
|
|
return k->archived_java_mirror_raw();
|
|
|
|
}
|
|
|
|
|
|
|
|
// No mirror
|
|
|
|
oop mirror = k->java_mirror();
|
|
|
|
if (mirror == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (k->is_instance_klass()) {
|
|
|
|
InstanceKlass *ik = InstanceKlass::cast(k);
|
2018-11-07 19:40:27 -08:00
|
|
|
assert(ik->signers() == NULL, "class with signer should have been excluded");
|
2018-03-02 17:25:55 -05:00
|
|
|
|
|
|
|
if (!(ik->is_shared_boot_class() || ik->is_shared_platform_class() ||
|
|
|
|
ik->is_shared_app_class())) {
|
|
|
|
// Archiving mirror for classes from non-builtin loaders is not
|
|
|
|
// supported. Clear the _java_mirror within the archived class.
|
|
|
|
k->set_java_mirror_handle(NULL);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now start archiving the mirror object
|
2018-10-09 15:58:07 -04:00
|
|
|
oop archived_mirror = HeapShared::archive_heap_object(mirror, THREAD);
|
2018-03-02 17:25:55 -05:00
|
|
|
if (archived_mirror == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
archived_mirror = process_archived_mirror(k, mirror, archived_mirror, THREAD);
|
|
|
|
if (archived_mirror == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
k->set_archived_java_mirror_raw(archived_mirror);
|
|
|
|
|
|
|
|
k->set_has_raw_archived_mirror();
|
|
|
|
|
|
|
|
ResourceMark rm;
|
2018-07-08 12:43:05 -04:00
|
|
|
log_trace(cds, heap, mirror)(
|
|
|
|
"Archived %s mirror object from " PTR_FORMAT " ==> " PTR_FORMAT,
|
|
|
|
k->external_name(), p2i(mirror), p2i(archived_mirror));
|
2018-03-02 17:25:55 -05:00
|
|
|
|
|
|
|
return archived_mirror;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The process is based on create_mirror().
|
|
|
|
oop java_lang_Class::process_archived_mirror(Klass* k, oop mirror,
|
|
|
|
oop archived_mirror,
|
|
|
|
Thread *THREAD) {
|
|
|
|
// Clear nonstatic fields in archived mirror. Some of the fields will be set
|
|
|
|
// to archived metadata and objects below.
|
|
|
|
Klass *c = archived_mirror->klass();
|
|
|
|
Handle archived_mirror_h(THREAD, archived_mirror);
|
|
|
|
ResetMirrorField reset(archived_mirror_h);
|
|
|
|
InstanceKlass::cast(c)->do_nonstatic_fields(&reset);
|
|
|
|
|
|
|
|
if (k->is_array_klass()) {
|
|
|
|
oop archived_comp_mirror;
|
|
|
|
if (k->is_typeArray_klass()) {
|
|
|
|
// The primitive type mirrors are already archived. Get the archived mirror.
|
|
|
|
oop comp_mirror = java_lang_Class::component_mirror(mirror);
|
2018-10-09 15:58:07 -04:00
|
|
|
archived_comp_mirror = HeapShared::find_archived_heap_object(comp_mirror);
|
2018-03-02 17:25:55 -05:00
|
|
|
assert(archived_comp_mirror != NULL, "Must be");
|
|
|
|
} else {
|
|
|
|
assert(k->is_objArray_klass(), "Must be");
|
|
|
|
Klass* element_klass = ObjArrayKlass::cast(k)->element_klass();
|
|
|
|
assert(element_klass != NULL, "Must have an element klass");
|
|
|
|
archived_comp_mirror = archive_mirror(element_klass, THREAD);
|
|
|
|
if (archived_comp_mirror == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
java_lang_Class::set_component_mirror(archived_mirror, archived_comp_mirror);
|
|
|
|
} else {
|
|
|
|
assert(k->is_instance_klass(), "Must be");
|
|
|
|
|
|
|
|
// Reset local static fields in the mirror
|
|
|
|
InstanceKlass::cast(k)->do_local_static_fields(&reset);
|
|
|
|
|
|
|
|
java_lang_Class:set_init_lock(archived_mirror, NULL);
|
|
|
|
|
|
|
|
set_protection_domain(archived_mirror, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
// clear class loader and mirror_module_field
|
|
|
|
set_class_loader(archived_mirror, NULL);
|
|
|
|
set_module(archived_mirror, NULL);
|
|
|
|
|
|
|
|
// The archived mirror's field at _klass_offset is still pointing to the original
|
|
|
|
// klass. Updated the field in the archived mirror to point to the relocated
|
|
|
|
// klass in the archive.
|
|
|
|
Klass *reloc_k = MetaspaceShared::get_relocated_klass(as_Klass(mirror));
|
2018-07-08 12:43:05 -04:00
|
|
|
log_debug(cds, heap, mirror)(
|
|
|
|
"Relocate mirror metadata field at _klass_offset from " PTR_FORMAT " ==> " PTR_FORMAT,
|
|
|
|
p2i(as_Klass(mirror)), p2i(reloc_k));
|
2018-03-02 17:25:55 -05:00
|
|
|
archived_mirror->metadata_field_put(_klass_offset, reloc_k);
|
|
|
|
|
|
|
|
// The field at _array_klass_offset is pointing to the original one dimension
|
|
|
|
// higher array klass if exists. Relocate the pointer.
|
|
|
|
Klass *arr = array_klass_acquire(mirror);
|
|
|
|
if (arr != NULL) {
|
|
|
|
Klass *reloc_arr = MetaspaceShared::get_relocated_klass(arr);
|
2018-07-08 12:43:05 -04:00
|
|
|
log_debug(cds, heap, mirror)(
|
|
|
|
"Relocate mirror metadata field at _array_klass_offset from " PTR_FORMAT " ==> " PTR_FORMAT,
|
|
|
|
p2i(arr), p2i(reloc_arr));
|
2018-03-02 17:25:55 -05:00
|
|
|
archived_mirror->metadata_field_put(_array_klass_offset, reloc_arr);
|
|
|
|
}
|
|
|
|
return archived_mirror;
|
|
|
|
}
|
|
|
|
|
2018-06-12 18:12:59 -04:00
|
|
|
// Returns true if the mirror is updated, false if no archived mirror
|
|
|
|
// data is present. After the archived mirror object is restored, the
|
|
|
|
// shared klass' _has_raw_archived_mirror flag is cleared.
|
|
|
|
bool java_lang_Class::restore_archived_mirror(Klass *k,
|
2018-03-02 17:25:55 -05:00
|
|
|
Handle class_loader, Handle module,
|
|
|
|
Handle protection_domain, TRAPS) {
|
2018-09-07 15:18:14 -04:00
|
|
|
// Postpone restoring archived mirror until java.lang.Class is loaded. Please
|
2018-10-17 15:57:10 -07:00
|
|
|
// see more details in SystemDictionary::resolve_well_known_classes().
|
2018-09-07 15:18:14 -04:00
|
|
|
if (!SystemDictionary::Class_klass_loaded()) {
|
|
|
|
assert(fixup_mirror_list() != NULL, "fixup_mirror_list not initialized");
|
|
|
|
fixup_mirror_list()->push(k);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-10-09 15:58:07 -04:00
|
|
|
oop m = HeapShared::materialize_archived_object(k->archived_java_mirror_raw_narrow());
|
2018-06-12 18:12:59 -04:00
|
|
|
|
|
|
|
if (m == NULL) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
log_debug(cds, mirror)("Archived mirror is: " PTR_FORMAT, p2i(m));
|
|
|
|
|
|
|
|
// mirror is archived, restore
|
2018-10-09 15:58:07 -04:00
|
|
|
assert(HeapShared::is_archived_object(m), "must be archived mirror object");
|
2018-06-12 18:12:59 -04:00
|
|
|
Handle mirror(THREAD, m);
|
2018-03-02 17:25:55 -05:00
|
|
|
|
|
|
|
if (!k->is_array_klass()) {
|
|
|
|
// - local static final fields with initial values were initialized at dump time
|
|
|
|
|
|
|
|
// create the init_lock
|
2018-06-12 18:12:59 -04:00
|
|
|
typeArrayOop r = oopFactory::new_typeArray(T_INT, 0, CHECK_(false));
|
2018-03-02 17:25:55 -05:00
|
|
|
set_init_lock(mirror(), r);
|
|
|
|
|
|
|
|
if (protection_domain.not_null()) {
|
|
|
|
set_protection_domain(mirror(), protection_domain());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(class_loader() == k->class_loader(), "should be same");
|
|
|
|
if (class_loader.not_null()) {
|
|
|
|
set_class_loader(mirror(), class_loader());
|
|
|
|
}
|
|
|
|
|
|
|
|
k->set_java_mirror(mirror);
|
|
|
|
k->clear_has_raw_archived_mirror();
|
|
|
|
|
|
|
|
set_mirror_module_field(k, mirror, module, THREAD);
|
|
|
|
|
|
|
|
ResourceMark rm;
|
2018-07-08 12:43:05 -04:00
|
|
|
log_trace(cds, heap, mirror)(
|
|
|
|
"Restored %s archived mirror " PTR_FORMAT, k->external_name(), p2i(mirror()));
|
2018-06-12 18:12:59 -04:00
|
|
|
|
|
|
|
return true;
|
2018-03-02 17:25:55 -05:00
|
|
|
}
|
|
|
|
#endif // INCLUDE_CDS_JAVA_HEAP
|
|
|
|
|
2017-03-15 10:25:37 -04:00
|
|
|
void java_lang_Class::fixup_module_field(Klass* k, Handle module) {
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
assert(_module_offset != 0, "must have been computed already");
|
|
|
|
java_lang_Class::set_module(k->java_mirror(), module());
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2011-03-18 16:00:34 -07:00
|
|
|
int java_lang_Class::oop_size(oop java_class) {
|
2011-09-10 17:29:02 -07:00
|
|
|
assert(_oop_size_offset != 0, "must be set");
|
2016-07-05 15:34:06 -04:00
|
|
|
int size = java_class->int_field(_oop_size_offset);
|
|
|
|
assert(size > 0, "Oop size must be greater than zero, not %d", size);
|
|
|
|
return size;
|
2011-03-18 16:00:34 -07:00
|
|
|
}
|
2016-07-05 15:34:06 -04:00
|
|
|
|
2018-07-06 16:04:19 +02:00
|
|
|
|
2018-06-28 14:22:28 +02:00
|
|
|
void java_lang_Class::set_oop_size(HeapWord* java_class, int size) {
|
2011-09-10 17:29:02 -07:00
|
|
|
assert(_oop_size_offset != 0, "must be set");
|
2016-07-05 15:34:06 -04:00
|
|
|
assert(size > 0, "Oop size must be greater than zero, not %d", size);
|
2018-06-28 14:22:28 +02:00
|
|
|
*(int*)(((char*)java_class) + _oop_size_offset) = size;
|
2011-03-18 16:00:34 -07:00
|
|
|
}
|
2016-07-05 15:34:06 -04:00
|
|
|
|
2011-03-18 16:00:34 -07:00
|
|
|
int java_lang_Class::static_oop_field_count(oop java_class) {
|
2011-09-10 17:29:02 -07:00
|
|
|
assert(_static_oop_field_count_offset != 0, "must be set");
|
|
|
|
return java_class->int_field(_static_oop_field_count_offset);
|
2011-03-18 16:00:34 -07:00
|
|
|
}
|
2018-07-06 16:04:19 +02:00
|
|
|
|
|
|
|
int java_lang_Class::static_oop_field_count_raw(oop java_class) {
|
|
|
|
assert(_static_oop_field_count_offset != 0, "must be set");
|
|
|
|
return java_class->int_field_raw(_static_oop_field_count_offset);
|
|
|
|
}
|
|
|
|
|
2011-03-18 16:00:34 -07:00
|
|
|
void java_lang_Class::set_static_oop_field_count(oop java_class, int size) {
|
2011-09-10 17:29:02 -07:00
|
|
|
assert(_static_oop_field_count_offset != 0, "must be set");
|
|
|
|
java_class->int_field_put(_static_oop_field_count_offset, size);
|
2011-03-18 16:00:34 -07:00
|
|
|
}
|
|
|
|
|
2013-05-22 14:37:49 -04:00
|
|
|
oop java_lang_Class::protection_domain(oop java_class) {
|
|
|
|
assert(_protection_domain_offset != 0, "must be set");
|
|
|
|
return java_class->obj_field(_protection_domain_offset);
|
|
|
|
}
|
|
|
|
void java_lang_Class::set_protection_domain(oop java_class, oop pd) {
|
|
|
|
assert(_protection_domain_offset != 0, "must be set");
|
|
|
|
java_class->obj_field_put(_protection_domain_offset, pd);
|
|
|
|
}
|
|
|
|
|
2014-07-02 15:22:18 -04:00
|
|
|
void java_lang_Class::set_component_mirror(oop java_class, oop comp_mirror) {
|
2014-08-28 11:29:09 -04:00
|
|
|
assert(_component_mirror_offset != 0, "must be set");
|
2014-07-02 15:22:18 -04:00
|
|
|
java_class->obj_field_put(_component_mirror_offset, comp_mirror);
|
|
|
|
}
|
|
|
|
oop java_lang_Class::component_mirror(oop java_class) {
|
|
|
|
assert(_component_mirror_offset != 0, "must be set");
|
|
|
|
return java_class->obj_field(_component_mirror_offset);
|
|
|
|
}
|
|
|
|
|
2013-05-22 14:37:49 -04:00
|
|
|
oop java_lang_Class::init_lock(oop java_class) {
|
|
|
|
assert(_init_lock_offset != 0, "must be set");
|
|
|
|
return java_class->obj_field(_init_lock_offset);
|
|
|
|
}
|
|
|
|
void java_lang_Class::set_init_lock(oop java_class, oop init_lock) {
|
|
|
|
assert(_init_lock_offset != 0, "must be set");
|
|
|
|
java_class->obj_field_put(_init_lock_offset, init_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
objArrayOop java_lang_Class::signers(oop java_class) {
|
|
|
|
assert(_signers_offset != 0, "must be set");
|
|
|
|
return (objArrayOop)java_class->obj_field(_signers_offset);
|
|
|
|
}
|
|
|
|
void java_lang_Class::set_signers(oop java_class, objArrayOop signers) {
|
|
|
|
assert(_signers_offset != 0, "must be set");
|
|
|
|
java_class->obj_field_put(_signers_offset, (oop)signers);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-19 14:49:33 -04:00
|
|
|
void java_lang_Class::set_class_loader(oop java_class, oop loader) {
|
|
|
|
// jdk7 runs Queens in bootstrapping and jdk8-9 has no coordinated pushes yet.
|
|
|
|
if (_class_loader_offset != 0) {
|
|
|
|
java_class->obj_field_put(_class_loader_offset, loader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
oop java_lang_Class::class_loader(oop java_class) {
|
|
|
|
assert(_class_loader_offset != 0, "must be set");
|
|
|
|
return java_class->obj_field(_class_loader_offset);
|
|
|
|
}
|
|
|
|
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
oop java_lang_Class::module(oop java_class) {
|
|
|
|
assert(_module_offset != 0, "must be set");
|
|
|
|
return java_class->obj_field(_module_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_Class::set_module(oop java_class, oop module) {
|
|
|
|
assert(_module_offset != 0, "must be set");
|
|
|
|
java_class->obj_field_put(_module_offset, module);
|
|
|
|
}
|
|
|
|
|
2019-01-09 20:28:16 +01:00
|
|
|
oop java_lang_Class::name(Handle java_class, TRAPS) {
|
|
|
|
assert(_name_offset != 0, "must be set");
|
|
|
|
oop o = java_class->obj_field(_name_offset);
|
|
|
|
if (o == NULL) {
|
|
|
|
o = StringTable::intern(java_lang_Class::as_external_name(java_class()), THREAD);
|
|
|
|
java_class->obj_field_put(_name_offset, o);
|
|
|
|
}
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
2019-01-14 17:20:20 +01:00
|
|
|
oop java_lang_Class::source_file(oop java_class) {
|
|
|
|
assert(_source_file_offset != 0, "must be set");
|
|
|
|
return java_class->obj_field(_source_file_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_Class::set_source_file(oop java_class, oop source_file) {
|
|
|
|
assert(_source_file_offset != 0, "must be set");
|
|
|
|
java_class->obj_field_put(_source_file_offset, source_file);
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) {
|
|
|
|
// This should be improved by adding a field at the Java level or by
|
|
|
|
// introducing a new VM klass (see comment in ClassFileParser)
|
2012-09-07 12:04:16 -04:00
|
|
|
oop java_class = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(NULL, CHECK_0);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (type != T_VOID) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* aklass = Universe::typeArrayKlassObj(type);
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(aklass != NULL, "correct bootstrap");
|
2017-07-24 17:46:06 -04:00
|
|
|
release_set_array_klass(java_class, aklass);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2011-10-17 21:38:29 -07:00
|
|
|
#ifdef ASSERT
|
2012-09-07 12:04:16 -04:00
|
|
|
InstanceMirrorKlass* mk = InstanceMirrorKlass::cast(SystemDictionary::Class_klass());
|
2011-10-17 21:38:29 -07:00
|
|
|
assert(java_lang_Class::static_oop_field_count(java_class) == 0, "should have been zeroed by allocation");
|
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
return java_class;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* java_lang_Class::as_Klass(oop java_class) {
|
2007-12-01 00:00:00 +00:00
|
|
|
//%note memory_2
|
2011-03-18 16:00:34 -07:00
|
|
|
assert(java_lang_Class::is_instance(java_class), "must be a Class object");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* k = ((Klass*)java_class->metadata_field(_klass_offset));
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(k == NULL || k->is_klass(), "type check");
|
|
|
|
return k;
|
|
|
|
}
|
|
|
|
|
2018-07-06 16:04:19 +02:00
|
|
|
Klass* java_lang_Class::as_Klass_raw(oop java_class) {
|
|
|
|
//%note memory_2
|
|
|
|
assert(java_lang_Class::is_instance(java_class), "must be a Class object");
|
|
|
|
Klass* k = ((Klass*)java_class->metadata_field_raw(_klass_offset));
|
|
|
|
assert(k == NULL || k->is_klass(), "type check");
|
|
|
|
return k;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void java_lang_Class::set_klass(oop java_class, Klass* klass) {
|
2011-10-17 21:38:29 -07:00
|
|
|
assert(java_lang_Class::is_instance(java_class), "must be a Class object");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
java_class->metadata_field_put(_klass_offset, klass);
|
2011-10-17 21:38:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-20 23:19:36 -07:00
|
|
|
void java_lang_Class::print_signature(oop java_class, outputStream* st) {
|
|
|
|
assert(java_lang_Class::is_instance(java_class), "must be a Class object");
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* name = NULL;
|
2009-03-20 23:19:36 -07:00
|
|
|
bool is_instance = false;
|
|
|
|
if (is_primitive(java_class)) {
|
|
|
|
name = vmSymbols::type_signature(primitive_type(java_class));
|
|
|
|
} else {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* k = as_Klass(java_class);
|
2015-10-28 09:47:23 -04:00
|
|
|
is_instance = k->is_instance_klass();
|
2012-11-12 16:15:05 -05:00
|
|
|
name = k->name();
|
2009-03-20 23:19:36 -07:00
|
|
|
}
|
|
|
|
if (name == NULL) {
|
|
|
|
st->print("<null>");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (is_instance) st->print("L");
|
|
|
|
st->write((char*) name->base(), (int) name->utf8_length());
|
|
|
|
if (is_instance) st->print(";");
|
|
|
|
}
|
|
|
|
|
2019-05-14 11:29:18 -04:00
|
|
|
Symbol* java_lang_Class::as_signature(oop java_class, bool intern_if_not_found) {
|
2009-03-20 23:19:36 -07:00
|
|
|
assert(java_lang_Class::is_instance(java_class), "must be a Class object");
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* name;
|
2009-03-20 23:19:36 -07:00
|
|
|
if (is_primitive(java_class)) {
|
2011-01-27 16:11:27 -08:00
|
|
|
name = vmSymbols::type_signature(primitive_type(java_class));
|
|
|
|
// Because this can create a new symbol, the caller has to decrement
|
|
|
|
// the refcount, so make adjustment here and below for symbols returned
|
|
|
|
// that are not created or incremented due to a successful lookup.
|
|
|
|
name->increment_refcount();
|
2009-03-20 23:19:36 -07:00
|
|
|
} else {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* k = as_Klass(java_class);
|
2015-10-28 09:47:23 -04:00
|
|
|
if (!k->is_instance_klass()) {
|
2012-11-12 16:15:05 -05:00
|
|
|
name = k->name();
|
2011-01-27 16:11:27 -08:00
|
|
|
name->increment_refcount();
|
2009-03-20 23:19:36 -07:00
|
|
|
} else {
|
|
|
|
ResourceMark rm;
|
2012-11-12 16:15:05 -05:00
|
|
|
const char* sigstr = k->signature_name();
|
2009-03-20 23:19:36 -07:00
|
|
|
int siglen = (int) strlen(sigstr);
|
2011-01-27 16:11:27 -08:00
|
|
|
if (!intern_if_not_found) {
|
|
|
|
name = SymbolTable::probe(sigstr, siglen);
|
|
|
|
} else {
|
2019-05-14 11:29:18 -04:00
|
|
|
name = SymbolTable::new_symbol(sigstr, siglen);
|
2011-01-27 16:11:27 -08:00
|
|
|
}
|
2009-03-20 23:19:36 -07:00
|
|
|
}
|
|
|
|
}
|
2011-01-27 16:11:27 -08:00
|
|
|
return name;
|
2009-03-20 23:19:36 -07:00
|
|
|
}
|
|
|
|
|
2015-07-20 18:57:07 +03:00
|
|
|
// Returns the Java name for this Java mirror (Resource allocated)
|
|
|
|
// See Klass::external_name().
|
|
|
|
// For primitive type Java mirrors, its type name is returned.
|
|
|
|
const char* java_lang_Class::as_external_name(oop java_class) {
|
|
|
|
assert(java_lang_Class::is_instance(java_class), "must be a Class object");
|
|
|
|
const char* name = NULL;
|
|
|
|
if (is_primitive(java_class)) {
|
|
|
|
name = type2name(primitive_type(java_class));
|
|
|
|
} else {
|
|
|
|
name = as_Klass(java_class)->external_name();
|
|
|
|
}
|
|
|
|
if (name == NULL) {
|
|
|
|
name = "<null>";
|
|
|
|
}
|
|
|
|
return name;
|
|
|
|
}
|
2009-03-20 23:19:36 -07:00
|
|
|
|
2017-07-26 10:41:07 -04:00
|
|
|
Klass* java_lang_Class::array_klass_acquire(oop java_class) {
|
|
|
|
Klass* k = ((Klass*)java_class->metadata_field_acquire(_array_klass_offset));
|
2015-10-28 09:47:23 -04:00
|
|
|
assert(k == NULL || k->is_klass() && k->is_array_klass(), "should be array klass");
|
2007-12-01 00:00:00 +00:00
|
|
|
return k;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-24 17:46:06 -04:00
|
|
|
void java_lang_Class::release_set_array_klass(oop java_class, Klass* klass) {
|
2015-10-28 09:47:23 -04:00
|
|
|
assert(klass->is_klass() && klass->is_array_klass(), "should be array klass");
|
2017-07-24 17:46:06 -04:00
|
|
|
java_class->release_metadata_field_put(_array_klass_offset, klass);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BasicType java_lang_Class::primitive_type(oop java_class) {
|
|
|
|
assert(java_lang_Class::is_primitive(java_class), "just checking");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* ak = ((Klass*)java_class->metadata_field(_array_klass_offset));
|
2007-12-01 00:00:00 +00:00
|
|
|
BasicType type = T_VOID;
|
|
|
|
if (ak != NULL) {
|
|
|
|
// Note: create_basic_type_mirror above initializes ak to a non-null value.
|
2012-09-29 06:40:00 -04:00
|
|
|
type = ArrayKlass::cast(ak)->element_type();
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
2019-09-17 09:51:02 +02:00
|
|
|
assert(java_class == Universe::void_mirror(), "only valid non-array primitive");
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2019-09-17 09:51:02 +02:00
|
|
|
assert(Universe::java_mirror(type) == java_class, "must be consistent");
|
2007-12-01 00:00:00 +00:00
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
BasicType java_lang_Class::as_BasicType(oop java_class, Klass** reference_klass) {
|
2009-03-20 23:19:36 -07:00
|
|
|
assert(java_lang_Class::is_instance(java_class), "must be a Class object");
|
|
|
|
if (is_primitive(java_class)) {
|
|
|
|
if (reference_klass != NULL)
|
|
|
|
(*reference_klass) = NULL;
|
|
|
|
return primitive_type(java_class);
|
|
|
|
} else {
|
|
|
|
if (reference_klass != NULL)
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
(*reference_klass) = as_Klass(java_class);
|
2009-03-20 23:19:36 -07:00
|
|
|
return T_OBJECT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
oop java_lang_Class::primitive_mirror(BasicType t) {
|
|
|
|
oop mirror = Universe::java_mirror(t);
|
2010-01-06 14:22:39 -08:00
|
|
|
assert(mirror != NULL && mirror->is_a(SystemDictionary::Class_klass()), "must be a Class");
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(java_lang_Class::is_primitive(mirror), "must be primitive");
|
|
|
|
return mirror;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool java_lang_Class::offsets_computed = false;
|
|
|
|
int java_lang_Class::classRedefinedCount_offset = -1;
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#define CLASS_FIELDS_DO(macro) \
|
|
|
|
macro(classRedefinedCount_offset, k, "classRedefinedCount", int_signature, false) ; \
|
|
|
|
macro(_class_loader_offset, k, "classLoader", classloader_signature, false); \
|
|
|
|
macro(_component_mirror_offset, k, "componentType", class_signature, false); \
|
2019-01-09 20:28:16 +01:00
|
|
|
macro(_module_offset, k, "module", module_signature, false); \
|
|
|
|
macro(_name_offset, k, "name", string_signature, false); \
|
2018-03-02 17:25:55 -05:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
void java_lang_Class::compute_offsets() {
|
2018-03-02 17:25:55 -05:00
|
|
|
if (offsets_computed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
offsets_computed = true;
|
|
|
|
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k = SystemDictionary::Class_klass();
|
2018-03-02 17:25:55 -05:00
|
|
|
CLASS_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
|
2014-08-28 11:29:09 -04:00
|
|
|
// Init lock is a C union with component_mirror. Only instanceKlass mirrors have
|
|
|
|
// init_lock and only ArrayKlass mirrors have component_mirror. Since both are oops
|
|
|
|
// GC treats them the same.
|
|
|
|
_init_lock_offset = _component_mirror_offset;
|
|
|
|
|
2011-09-10 17:29:02 -07:00
|
|
|
CLASS_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_Class::serialize_offsets(SerializeClosure* f) {
|
2019-06-04 17:56:16 +08:00
|
|
|
f->do_bool(&offsets_computed);
|
2018-03-02 17:25:55 -05:00
|
|
|
f->do_u4((u4*)&_init_lock_offset);
|
|
|
|
|
|
|
|
CLASS_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
|
|
|
|
CLASS_INJECTED_FIELDS(INJECTED_FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
int java_lang_Class::classRedefinedCount(oop the_class_mirror) {
|
2014-06-11 09:58:23 -04:00
|
|
|
if (classRedefinedCount_offset == -1) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// If we don't have an offset for it then just return -1 as a marker.
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return the_class_mirror->int_field(classRedefinedCount_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_Class::set_classRedefinedCount(oop the_class_mirror, int value) {
|
2014-06-11 09:58:23 -04:00
|
|
|
if (classRedefinedCount_offset == -1) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// If we don't have an offset for it then nothing to set.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
the_class_mirror->int_field_put(classRedefinedCount_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Note: JDK1.1 and before had a privateInfo_offset field which was used for the
|
|
|
|
// platform thread structure, and a eetop offset which was used for thread
|
|
|
|
// local storage (and unused by the HotSpot VM). In JDK1.2 the two structures
|
|
|
|
// merged, so in the HotSpot VM we just use the eetop field for the thread
|
|
|
|
// instead of the privateInfo_offset.
|
|
|
|
//
|
|
|
|
// Note: The stackSize field is only present starting in 1.4.
|
|
|
|
|
|
|
|
int java_lang_Thread::_name_offset = 0;
|
|
|
|
int java_lang_Thread::_group_offset = 0;
|
|
|
|
int java_lang_Thread::_contextClassLoader_offset = 0;
|
|
|
|
int java_lang_Thread::_inheritedAccessControlContext_offset = 0;
|
|
|
|
int java_lang_Thread::_priority_offset = 0;
|
|
|
|
int java_lang_Thread::_eetop_offset = 0;
|
|
|
|
int java_lang_Thread::_daemon_offset = 0;
|
|
|
|
int java_lang_Thread::_stillborn_offset = 0;
|
|
|
|
int java_lang_Thread::_stackSize_offset = 0;
|
|
|
|
int java_lang_Thread::_tid_offset = 0;
|
|
|
|
int java_lang_Thread::_thread_status_offset = 0;
|
|
|
|
int java_lang_Thread::_park_blocker_offset = 0;
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#define THREAD_FIELDS_DO(macro) \
|
|
|
|
macro(_name_offset, k, vmSymbols::name_name(), string_signature, false); \
|
|
|
|
macro(_group_offset, k, vmSymbols::group_name(), threadgroup_signature, false); \
|
|
|
|
macro(_contextClassLoader_offset, k, vmSymbols::contextClassLoader_name(), classloader_signature, false); \
|
|
|
|
macro(_inheritedAccessControlContext_offset, k, vmSymbols::inheritedAccessControlContext_name(), accesscontrolcontext_signature, false); \
|
|
|
|
macro(_priority_offset, k, vmSymbols::priority_name(), int_signature, false); \
|
|
|
|
macro(_daemon_offset, k, vmSymbols::daemon_name(), bool_signature, false); \
|
|
|
|
macro(_eetop_offset, k, "eetop", long_signature, false); \
|
|
|
|
macro(_stillborn_offset, k, "stillborn", bool_signature, false); \
|
|
|
|
macro(_stackSize_offset, k, "stackSize", long_signature, false); \
|
|
|
|
macro(_tid_offset, k, "tid", long_signature, false); \
|
|
|
|
macro(_thread_status_offset, k, "threadStatus", int_signature, false); \
|
2019-04-26 00:57:03 -04:00
|
|
|
macro(_park_blocker_offset, k, "parkBlocker", object_signature, false)
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
void java_lang_Thread::compute_offsets() {
|
|
|
|
assert(_group_offset == 0, "offsets should be initialized only once");
|
|
|
|
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k = SystemDictionary::Thread_klass();
|
2018-03-02 17:25:55 -05:00
|
|
|
THREAD_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_Thread::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
THREAD_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
JavaThread* java_lang_Thread::thread(oop java_thread) {
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
return (JavaThread*)java_thread->address_field(_eetop_offset);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void java_lang_Thread::set_thread(oop java_thread, JavaThread* thread) {
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
java_thread->address_field_put(_eetop_offset, (address)thread);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-13 01:57:09 +03:00
|
|
|
oop java_lang_Thread::name(oop java_thread) {
|
|
|
|
return java_thread->obj_field(_name_offset);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-13 01:57:09 +03:00
|
|
|
void java_lang_Thread::set_name(oop java_thread, oop name) {
|
2007-12-01 00:00:00 +00:00
|
|
|
java_thread->obj_field_put(_name_offset, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ThreadPriority java_lang_Thread::priority(oop java_thread) {
|
|
|
|
return (ThreadPriority)java_thread->int_field(_priority_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void java_lang_Thread::set_priority(oop java_thread, ThreadPriority priority) {
|
|
|
|
java_thread->int_field_put(_priority_offset, priority);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
oop java_lang_Thread::threadGroup(oop java_thread) {
|
|
|
|
return java_thread->obj_field(_group_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool java_lang_Thread::is_stillborn(oop java_thread) {
|
|
|
|
return java_thread->bool_field(_stillborn_offset) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// We never have reason to turn the stillborn bit off
|
|
|
|
void java_lang_Thread::set_stillborn(oop java_thread) {
|
|
|
|
java_thread->bool_field_put(_stillborn_offset, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool java_lang_Thread::is_alive(oop java_thread) {
|
|
|
|
JavaThread* thr = java_lang_Thread::thread(java_thread);
|
|
|
|
return (thr != NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool java_lang_Thread::is_daemon(oop java_thread) {
|
|
|
|
return java_thread->bool_field(_daemon_offset) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void java_lang_Thread::set_daemon(oop java_thread) {
|
|
|
|
java_thread->bool_field_put(_daemon_offset, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
oop java_lang_Thread::context_class_loader(oop java_thread) {
|
|
|
|
return java_thread->obj_field(_contextClassLoader_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
oop java_lang_Thread::inherited_access_control_context(oop java_thread) {
|
|
|
|
return java_thread->obj_field(_inheritedAccessControlContext_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
jlong java_lang_Thread::stackSize(oop java_thread) {
|
2019-04-17 09:29:25 +02:00
|
|
|
return java_thread->long_field(_stackSize_offset);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Write the thread status value to threadStatus field in java.lang.Thread java class.
|
|
|
|
void java_lang_Thread::set_thread_status(oop java_thread,
|
|
|
|
java_lang_Thread::ThreadStatus status) {
|
2019-04-17 09:29:25 +02:00
|
|
|
java_thread->int_field_put(_thread_status_offset, status);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Read thread status value from threadStatus field in java.lang.Thread java class.
|
|
|
|
java_lang_Thread::ThreadStatus java_lang_Thread::get_thread_status(oop java_thread) {
|
2017-07-07 23:04:06 +02:00
|
|
|
// Make sure the caller is operating on behalf of the VM or is
|
|
|
|
// running VM code (state == _thread_in_vm).
|
|
|
|
assert(Threads_lock->owned_by_self() || Thread::current()->is_VM_thread() ||
|
2007-12-01 00:00:00 +00:00
|
|
|
JavaThread::current()->thread_state() == _thread_in_vm,
|
|
|
|
"Java Thread is not running in vm");
|
2019-04-17 09:29:25 +02:00
|
|
|
return (java_lang_Thread::ThreadStatus)java_thread->int_field(_thread_status_offset);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
jlong java_lang_Thread::thread_id(oop java_thread) {
|
2019-04-17 09:29:25 +02:00
|
|
|
return java_thread->long_field(_tid_offset);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
oop java_lang_Thread::park_blocker(oop java_thread) {
|
2019-04-17 09:29:25 +02:00
|
|
|
return java_thread->obj_field(_park_blocker_offset);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char* java_lang_Thread::thread_status_name(oop java_thread) {
|
|
|
|
ThreadStatus status = (java_lang_Thread::ThreadStatus)java_thread->int_field(_thread_status_offset);
|
|
|
|
switch (status) {
|
|
|
|
case NEW : return "NEW";
|
|
|
|
case RUNNABLE : return "RUNNABLE";
|
|
|
|
case SLEEPING : return "TIMED_WAITING (sleeping)";
|
|
|
|
case IN_OBJECT_WAIT : return "WAITING (on object monitor)";
|
|
|
|
case IN_OBJECT_WAIT_TIMED : return "TIMED_WAITING (on object monitor)";
|
|
|
|
case PARKED : return "WAITING (parking)";
|
|
|
|
case PARKED_TIMED : return "TIMED_WAITING (parking)";
|
|
|
|
case BLOCKED_ON_MONITOR_ENTER : return "BLOCKED (on object monitor)";
|
|
|
|
case TERMINATED : return "TERMINATED";
|
|
|
|
default : return "UNKNOWN";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
int java_lang_ThreadGroup::_parent_offset = 0;
|
|
|
|
int java_lang_ThreadGroup::_name_offset = 0;
|
|
|
|
int java_lang_ThreadGroup::_threads_offset = 0;
|
|
|
|
int java_lang_ThreadGroup::_groups_offset = 0;
|
|
|
|
int java_lang_ThreadGroup::_maxPriority_offset = 0;
|
|
|
|
int java_lang_ThreadGroup::_destroyed_offset = 0;
|
|
|
|
int java_lang_ThreadGroup::_daemon_offset = 0;
|
|
|
|
int java_lang_ThreadGroup::_nthreads_offset = 0;
|
|
|
|
int java_lang_ThreadGroup::_ngroups_offset = 0;
|
|
|
|
|
|
|
|
oop java_lang_ThreadGroup::parent(oop java_thread_group) {
|
2017-08-23 14:52:55 -04:00
|
|
|
assert(oopDesc::is_oop(java_thread_group), "thread group must be oop");
|
2007-12-01 00:00:00 +00:00
|
|
|
return java_thread_group->obj_field(_parent_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ("name as oop" accessor is not necessary)
|
|
|
|
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
const char* java_lang_ThreadGroup::name(oop java_thread_group) {
|
2007-12-01 00:00:00 +00:00
|
|
|
oop name = java_thread_group->obj_field(_name_offset);
|
|
|
|
// ThreadGroup.name can be null
|
8141132: JEP 254: Compact Strings
Adopt a more space-efficient internal representation for strings.
Co-authored-by: Brent Christian <brent.christian@oracle.com>
Co-authored-by: Vivek Deshpande <vivek.r.deshpande@intel.com>
Co-authored-by: Charlie Hunt <charlie.hunt@oracle.com>
Co-authored-by: Vladimir Kozlov <vladimir.kozlov@oracle.com>
Co-authored-by: Roger Riggs <roger.riggs@oracle.com>
Co-authored-by: Xueming Shen <xueming.shen@oracle.com>
Co-authored-by: Aleksey Shipilev <aleksey.shipilev@oracle.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Reviewed-by: alanb, bdelsart, coleenp, iklam, jiangli, jrose, kevinw, naoto, pliden, roland, smarks, twisti
2015-11-03 09:41:03 +01:00
|
|
|
if (name != NULL) {
|
|
|
|
return java_lang_String::as_utf8_string(name);
|
|
|
|
}
|
|
|
|
return NULL;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int java_lang_ThreadGroup::nthreads(oop java_thread_group) {
|
2017-08-23 14:52:55 -04:00
|
|
|
assert(oopDesc::is_oop(java_thread_group), "thread group must be oop");
|
2007-12-01 00:00:00 +00:00
|
|
|
return java_thread_group->int_field(_nthreads_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
objArrayOop java_lang_ThreadGroup::threads(oop java_thread_group) {
|
|
|
|
oop threads = java_thread_group->obj_field(_threads_offset);
|
|
|
|
assert(threads != NULL, "threadgroups should have threads");
|
|
|
|
assert(threads->is_objArray(), "just checking"); // Todo: Add better type checking code
|
|
|
|
return objArrayOop(threads);
|
|
|
|
}
|
|
|
|
|
|
|
|
int java_lang_ThreadGroup::ngroups(oop java_thread_group) {
|
2017-08-23 14:52:55 -04:00
|
|
|
assert(oopDesc::is_oop(java_thread_group), "thread group must be oop");
|
2007-12-01 00:00:00 +00:00
|
|
|
return java_thread_group->int_field(_ngroups_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
objArrayOop java_lang_ThreadGroup::groups(oop java_thread_group) {
|
|
|
|
oop groups = java_thread_group->obj_field(_groups_offset);
|
|
|
|
assert(groups == NULL || groups->is_objArray(), "just checking"); // Todo: Add better type checking code
|
|
|
|
return objArrayOop(groups);
|
|
|
|
}
|
|
|
|
|
|
|
|
ThreadPriority java_lang_ThreadGroup::maxPriority(oop java_thread_group) {
|
2017-08-23 14:52:55 -04:00
|
|
|
assert(oopDesc::is_oop(java_thread_group), "thread group must be oop");
|
2007-12-01 00:00:00 +00:00
|
|
|
return (ThreadPriority) java_thread_group->int_field(_maxPriority_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool java_lang_ThreadGroup::is_destroyed(oop java_thread_group) {
|
2017-08-23 14:52:55 -04:00
|
|
|
assert(oopDesc::is_oop(java_thread_group), "thread group must be oop");
|
2007-12-01 00:00:00 +00:00
|
|
|
return java_thread_group->bool_field(_destroyed_offset) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool java_lang_ThreadGroup::is_daemon(oop java_thread_group) {
|
2017-08-23 14:52:55 -04:00
|
|
|
assert(oopDesc::is_oop(java_thread_group), "thread group must be oop");
|
2007-12-01 00:00:00 +00:00
|
|
|
return java_thread_group->bool_field(_daemon_offset) != 0;
|
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#define THREADGROUP_FIELDS_DO(macro) \
|
|
|
|
macro(_parent_offset, k, vmSymbols::parent_name(), threadgroup_signature, false); \
|
|
|
|
macro(_name_offset, k, vmSymbols::name_name(), string_signature, false); \
|
|
|
|
macro(_threads_offset, k, vmSymbols::threads_name(), thread_array_signature, false); \
|
|
|
|
macro(_groups_offset, k, vmSymbols::groups_name(), threadgroup_array_signature, false); \
|
|
|
|
macro(_maxPriority_offset, k, vmSymbols::maxPriority_name(), int_signature, false); \
|
|
|
|
macro(_destroyed_offset, k, vmSymbols::destroyed_name(), bool_signature, false); \
|
|
|
|
macro(_daemon_offset, k, vmSymbols::daemon_name(), bool_signature, false); \
|
|
|
|
macro(_nthreads_offset, k, vmSymbols::nthreads_name(), int_signature, false); \
|
|
|
|
macro(_ngroups_offset, k, vmSymbols::ngroups_name(), int_signature, false)
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
void java_lang_ThreadGroup::compute_offsets() {
|
|
|
|
assert(_parent_offset == 0, "offsets should be initialized only once");
|
|
|
|
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k = SystemDictionary::ThreadGroup_klass();
|
2018-03-02 17:25:55 -05:00
|
|
|
THREADGROUP_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_ThreadGroup::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
THREADGROUP_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2018-03-02 17:25:55 -05:00
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#define THROWABLE_FIELDS_DO(macro) \
|
|
|
|
macro(backtrace_offset, k, "backtrace", object_signature, false); \
|
|
|
|
macro(detailMessage_offset, k, "detailMessage", string_signature, false); \
|
|
|
|
macro(stackTrace_offset, k, "stackTrace", java_lang_StackTraceElement_array, false); \
|
|
|
|
macro(depth_offset, k, "depth", int_signature, false); \
|
|
|
|
macro(static_unassigned_stacktrace_offset, k, "UNASSIGNED_STACK", java_lang_StackTraceElement_array, true)
|
2016-03-10 13:43:47 -05:00
|
|
|
|
|
|
|
void java_lang_Throwable::compute_offsets() {
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k = SystemDictionary::Throwable_klass();
|
2018-03-02 17:25:55 -05:00
|
|
|
THROWABLE_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
2016-03-10 13:43:47 -05:00
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_Throwable::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
THROWABLE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-07-22 00:29:01 -07:00
|
|
|
oop java_lang_Throwable::unassigned_stacktrace() {
|
2015-10-26 13:11:36 -04:00
|
|
|
InstanceKlass* ik = SystemDictionary::Throwable_klass();
|
2018-03-21 16:00:41 +01:00
|
|
|
oop base = ik->static_field_base_raw();
|
|
|
|
return base->obj_field(static_unassigned_stacktrace_offset);
|
2011-07-22 00:29:01 -07:00
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
oop java_lang_Throwable::backtrace(oop throwable) {
|
|
|
|
return throwable->obj_field_acquire(backtrace_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void java_lang_Throwable::set_backtrace(oop throwable, oop value) {
|
|
|
|
throwable->release_obj_field_put(backtrace_offset, value);
|
|
|
|
}
|
|
|
|
|
2016-03-10 13:43:47 -05:00
|
|
|
int java_lang_Throwable::depth(oop throwable) {
|
|
|
|
return throwable->int_field(depth_offset);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2016-03-10 13:43:47 -05:00
|
|
|
void java_lang_Throwable::set_depth(oop throwable, int value) {
|
|
|
|
throwable->int_field_put(depth_offset, value);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2017-02-15 22:59:57 -05:00
|
|
|
oop java_lang_Throwable::message(oop throwable) {
|
2007-12-01 00:00:00 +00:00
|
|
|
return throwable->obj_field(detailMessage_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-09 22:37:48 -04:00
|
|
|
// Return Symbol for detailed_message or NULL
|
|
|
|
Symbol* java_lang_Throwable::detail_message(oop throwable) {
|
|
|
|
PRESERVE_EXCEPTION_MARK; // Keep original exception
|
|
|
|
oop detailed_message = java_lang_Throwable::message(throwable);
|
|
|
|
if (detailed_message != NULL) {
|
2019-05-14 11:29:18 -04:00
|
|
|
return java_lang_String::as_symbol(detailed_message);
|
2014-07-09 22:37:48 -04:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
void java_lang_Throwable::set_message(oop throwable, oop value) {
|
|
|
|
throwable->obj_field_put(detailMessage_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-22 00:29:01 -07:00
|
|
|
void java_lang_Throwable::set_stacktrace(oop throwable, oop st_element_array) {
|
|
|
|
throwable->obj_field_put(stackTrace_offset, st_element_array);
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
void java_lang_Throwable::clear_stacktrace(oop throwable) {
|
2011-07-22 00:29:01 -07:00
|
|
|
set_stacktrace(throwable, NULL);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-15 22:59:57 -05:00
|
|
|
void java_lang_Throwable::print(oop throwable, outputStream* st) {
|
2007-12-01 00:00:00 +00:00
|
|
|
ResourceMark rm;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* k = throwable->klass();
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(k != NULL, "just checking");
|
2015-10-26 13:11:36 -04:00
|
|
|
st->print("%s", k->external_name());
|
2007-12-01 00:00:00 +00:00
|
|
|
oop msg = message(throwable);
|
|
|
|
if (msg != NULL) {
|
|
|
|
st->print(": %s", java_lang_String::as_utf8_string(msg));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-17 13:40:31 -05:00
|
|
|
// After this many redefines, the stack trace is unreliable.
|
|
|
|
const int MAX_VERSION = USHRT_MAX;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2013-01-17 13:40:31 -05:00
|
|
|
static inline bool version_matches(Method* method, int version) {
|
2015-03-20 02:44:51 -07:00
|
|
|
assert(version < MAX_VERSION, "version is too big");
|
|
|
|
return method != NULL && (method->constants()->version() == version);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2016-03-10 13:43:47 -05:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// This class provides a simple wrapper over the internal structure of
|
|
|
|
// exception backtrace to insulate users of the backtrace from needing
|
|
|
|
// to know what it looks like.
|
|
|
|
class BacktraceBuilder: public StackObj {
|
2016-03-10 13:43:47 -05:00
|
|
|
friend class BacktraceIterator;
|
2007-12-01 00:00:00 +00:00
|
|
|
private:
|
|
|
|
Handle _backtrace;
|
|
|
|
objArrayOop _head;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
typeArrayOop _methods;
|
2007-12-01 00:00:00 +00:00
|
|
|
typeArrayOop _bcis;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
objArrayOop _mirrors;
|
2017-02-01 17:56:22 -05:00
|
|
|
typeArrayOop _names; // needed to insulate method name against redefinition
|
2007-12-01 00:00:00 +00:00
|
|
|
int _index;
|
2016-01-14 13:26:19 +01:00
|
|
|
NoSafepointVerifier _nsv;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
trace_methods_offset = java_lang_Throwable::trace_methods_offset,
|
2015-03-20 02:44:51 -07:00
|
|
|
trace_bcis_offset = java_lang_Throwable::trace_bcis_offset,
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
trace_mirrors_offset = java_lang_Throwable::trace_mirrors_offset,
|
2017-02-01 17:56:22 -05:00
|
|
|
trace_names_offset = java_lang_Throwable::trace_names_offset,
|
2007-12-01 00:00:00 +00:00
|
|
|
trace_next_offset = java_lang_Throwable::trace_next_offset,
|
|
|
|
trace_size = java_lang_Throwable::trace_size,
|
|
|
|
trace_chunk_size = java_lang_Throwable::trace_chunk_size
|
|
|
|
};
|
|
|
|
|
2013-01-17 13:40:31 -05:00
|
|
|
// get info out of chunks
|
|
|
|
static typeArrayOop get_methods(objArrayHandle chunk) {
|
|
|
|
typeArrayOop methods = typeArrayOop(chunk->obj_at(trace_methods_offset));
|
|
|
|
assert(methods != NULL, "method array should be initialized in backtrace");
|
|
|
|
return methods;
|
|
|
|
}
|
|
|
|
static typeArrayOop get_bcis(objArrayHandle chunk) {
|
|
|
|
typeArrayOop bcis = typeArrayOop(chunk->obj_at(trace_bcis_offset));
|
|
|
|
assert(bcis != NULL, "bci array should be initialized in backtrace");
|
|
|
|
return bcis;
|
|
|
|
}
|
|
|
|
static objArrayOop get_mirrors(objArrayHandle chunk) {
|
|
|
|
objArrayOop mirrors = objArrayOop(chunk->obj_at(trace_mirrors_offset));
|
|
|
|
assert(mirrors != NULL, "mirror array should be initialized in backtrace");
|
|
|
|
return mirrors;
|
|
|
|
}
|
2017-02-01 17:56:22 -05:00
|
|
|
static typeArrayOop get_names(objArrayHandle chunk) {
|
|
|
|
typeArrayOop names = typeArrayOop(chunk->obj_at(trace_names_offset));
|
|
|
|
assert(names != NULL, "names array should be initialized in backtrace");
|
|
|
|
return names;
|
2015-03-20 02:44:51 -07:00
|
|
|
}
|
2013-01-17 13:40:31 -05:00
|
|
|
|
2016-03-10 13:43:47 -05:00
|
|
|
public:
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// constructor for new backtrace
|
2018-08-08 15:31:07 +02:00
|
|
|
BacktraceBuilder(TRAPS): _head(NULL), _methods(NULL), _bcis(NULL), _mirrors(NULL), _names(NULL) {
|
2007-12-01 00:00:00 +00:00
|
|
|
expand(CHECK);
|
2017-02-15 22:59:57 -05:00
|
|
|
_backtrace = Handle(THREAD, _head);
|
2007-12-01 00:00:00 +00:00
|
|
|
_index = 0;
|
|
|
|
}
|
|
|
|
|
2017-02-15 22:59:57 -05:00
|
|
|
BacktraceBuilder(Thread* thread, objArrayHandle backtrace) {
|
2013-01-17 13:40:31 -05:00
|
|
|
_methods = get_methods(backtrace);
|
|
|
|
_bcis = get_bcis(backtrace);
|
|
|
|
_mirrors = get_mirrors(backtrace);
|
2017-02-01 17:56:22 -05:00
|
|
|
_names = get_names(backtrace);
|
2013-01-17 13:40:31 -05:00
|
|
|
assert(_methods->length() == _bcis->length() &&
|
2017-02-01 17:56:22 -05:00
|
|
|
_methods->length() == _mirrors->length() &&
|
|
|
|
_mirrors->length() == _names->length(),
|
2013-01-17 13:40:31 -05:00
|
|
|
"method and source information arrays should match");
|
|
|
|
|
|
|
|
// head is the preallocated backtrace
|
2017-02-15 22:59:57 -05:00
|
|
|
_head = backtrace();
|
|
|
|
_backtrace = Handle(thread, _head);
|
2013-01-17 13:40:31 -05:00
|
|
|
_index = 0;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
void expand(TRAPS) {
|
|
|
|
objArrayHandle old_head(THREAD, _head);
|
2016-01-14 13:26:19 +01:00
|
|
|
PauseNoSafepointVerifier pnsv(&_nsv);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
objArrayOop head = oopFactory::new_objectArray(trace_size, CHECK);
|
|
|
|
objArrayHandle new_head(THREAD, head);
|
|
|
|
|
2013-01-17 13:40:31 -05:00
|
|
|
typeArrayOop methods = oopFactory::new_shortArray(trace_chunk_size, CHECK);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
typeArrayHandle new_methods(THREAD, methods);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2013-01-17 13:40:31 -05:00
|
|
|
typeArrayOop bcis = oopFactory::new_intArray(trace_chunk_size, CHECK);
|
2007-12-01 00:00:00 +00:00
|
|
|
typeArrayHandle new_bcis(THREAD, bcis);
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
objArrayOop mirrors = oopFactory::new_objectArray(trace_chunk_size, CHECK);
|
|
|
|
objArrayHandle new_mirrors(THREAD, mirrors);
|
|
|
|
|
2017-02-01 17:56:22 -05:00
|
|
|
typeArrayOop names = oopFactory::new_symbolArray(trace_chunk_size, CHECK);
|
|
|
|
typeArrayHandle new_names(THREAD, names);
|
2015-03-20 02:44:51 -07:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
if (!old_head.is_null()) {
|
|
|
|
old_head->obj_at_put(trace_next_offset, new_head());
|
|
|
|
}
|
|
|
|
new_head->obj_at_put(trace_methods_offset, new_methods());
|
|
|
|
new_head->obj_at_put(trace_bcis_offset, new_bcis());
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
new_head->obj_at_put(trace_mirrors_offset, new_mirrors());
|
2017-02-01 17:56:22 -05:00
|
|
|
new_head->obj_at_put(trace_names_offset, new_names());
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
_head = new_head();
|
|
|
|
_methods = new_methods();
|
2013-01-17 13:40:31 -05:00
|
|
|
_bcis = new_bcis();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
_mirrors = new_mirrors();
|
2017-02-01 17:56:22 -05:00
|
|
|
_names = new_names();
|
2007-12-01 00:00:00 +00:00
|
|
|
_index = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
oop backtrace() {
|
|
|
|
return _backtrace();
|
|
|
|
}
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
inline void push(Method* method, int bci, TRAPS) {
|
2012-01-22 14:03:20 -08:00
|
|
|
// Smear the -1 bci to 0 since the array only holds unsigned
|
|
|
|
// shorts. The later line number lookup would just smear the -1
|
|
|
|
// to a 0 even if it could be recorded.
|
|
|
|
if (bci == SynchronizationEntryBCI) bci = 0;
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
if (_index >= trace_chunk_size) {
|
|
|
|
methodHandle mhandle(THREAD, method);
|
|
|
|
expand(CHECK);
|
|
|
|
method = mhandle();
|
|
|
|
}
|
|
|
|
|
2018-01-29 11:55:40 -05:00
|
|
|
_methods->ushort_at_put(_index, method->orig_method_idnum());
|
2015-11-24 14:59:17 -08:00
|
|
|
_bcis->int_at_put(_index, Backtrace::merge_bci_and_version(bci, method->constants()->version()));
|
2017-02-01 17:56:22 -05:00
|
|
|
|
|
|
|
// Note:this doesn't leak symbols because the mirror in the backtrace keeps the
|
|
|
|
// klass owning the symbols alive so their refcounts aren't decremented.
|
|
|
|
Symbol* name = method->name();
|
|
|
|
_names->symbol_at_put(_index, name);
|
2013-01-17 13:40:31 -05:00
|
|
|
|
|
|
|
// We need to save the mirrors in the backtrace to keep the class
|
|
|
|
// from being unloaded while we still have this stack trace.
|
|
|
|
assert(method->method_holder()->java_mirror() != NULL, "never push null for mirror");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
_mirrors->obj_at_put(_index, method->method_holder()->java_mirror());
|
2007-12-01 00:00:00 +00:00
|
|
|
_index++;
|
|
|
|
}
|
|
|
|
|
2013-01-17 13:40:31 -05:00
|
|
|
};
|
|
|
|
|
2016-03-10 13:43:47 -05:00
|
|
|
struct BacktraceElement : public StackObj {
|
|
|
|
int _method_id;
|
|
|
|
int _bci;
|
|
|
|
int _version;
|
2017-02-01 17:56:22 -05:00
|
|
|
Symbol* _name;
|
2016-03-10 13:43:47 -05:00
|
|
|
Handle _mirror;
|
2017-02-01 17:56:22 -05:00
|
|
|
BacktraceElement(Handle mirror, int mid, int version, int bci, Symbol* name) :
|
2018-08-08 15:31:07 +02:00
|
|
|
_method_id(mid), _bci(bci), _version(version), _name(name), _mirror(mirror) {}
|
2016-03-10 13:43:47 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class BacktraceIterator : public StackObj {
|
|
|
|
int _index;
|
|
|
|
objArrayHandle _result;
|
|
|
|
objArrayHandle _mirrors;
|
|
|
|
typeArrayHandle _methods;
|
|
|
|
typeArrayHandle _bcis;
|
2017-02-01 17:56:22 -05:00
|
|
|
typeArrayHandle _names;
|
2016-03-10 13:43:47 -05:00
|
|
|
|
|
|
|
void init(objArrayHandle result, Thread* thread) {
|
|
|
|
// Get method id, bci, version and mirror from chunk
|
|
|
|
_result = result;
|
|
|
|
if (_result.not_null()) {
|
|
|
|
_methods = typeArrayHandle(thread, BacktraceBuilder::get_methods(_result));
|
|
|
|
_bcis = typeArrayHandle(thread, BacktraceBuilder::get_bcis(_result));
|
|
|
|
_mirrors = objArrayHandle(thread, BacktraceBuilder::get_mirrors(_result));
|
2017-02-01 17:56:22 -05:00
|
|
|
_names = typeArrayHandle(thread, BacktraceBuilder::get_names(_result));
|
2016-03-10 13:43:47 -05:00
|
|
|
_index = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public:
|
|
|
|
BacktraceIterator(objArrayHandle result, Thread* thread) {
|
|
|
|
init(result, thread);
|
2016-03-12 07:23:20 -05:00
|
|
|
assert(_methods.is_null() || _methods->length() == java_lang_Throwable::trace_chunk_size, "lengths don't match");
|
2016-03-10 13:43:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
BacktraceElement next(Thread* thread) {
|
|
|
|
BacktraceElement e (Handle(thread, _mirrors->obj_at(_index)),
|
2018-01-29 11:55:40 -05:00
|
|
|
_methods->ushort_at(_index),
|
2016-03-10 13:43:47 -05:00
|
|
|
Backtrace::version_at(_bcis->int_at(_index)),
|
|
|
|
Backtrace::bci_at(_bcis->int_at(_index)),
|
2017-02-01 17:56:22 -05:00
|
|
|
_names->symbol_at(_index));
|
2016-03-10 13:43:47 -05:00
|
|
|
_index++;
|
|
|
|
|
|
|
|
if (_index >= java_lang_Throwable::trace_chunk_size) {
|
|
|
|
int next_offset = java_lang_Throwable::trace_next_offset;
|
|
|
|
// Get next chunk
|
|
|
|
objArrayHandle result (thread, objArrayOop(_result->obj_at(next_offset)));
|
|
|
|
init(result, thread);
|
|
|
|
}
|
|
|
|
return e;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool repeat() {
|
|
|
|
return _result.not_null() && _mirrors->obj_at(_index) != NULL;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-01-17 13:40:31 -05:00
|
|
|
// Print stack trace element to resource allocated buffer
|
2016-03-10 13:43:47 -05:00
|
|
|
static void print_stack_element_to_stream(outputStream* st, Handle mirror, int method_id,
|
2017-02-01 17:56:22 -05:00
|
|
|
int version, int bci, Symbol* name) {
|
2016-03-10 13:43:47 -05:00
|
|
|
ResourceMark rm;
|
2013-01-17 13:40:31 -05:00
|
|
|
|
|
|
|
// Get strings and string lengths
|
|
|
|
InstanceKlass* holder = InstanceKlass::cast(java_lang_Class::as_Klass(mirror()));
|
|
|
|
const char* klass_name = holder->external_name();
|
|
|
|
int buf_len = (int)strlen(klass_name);
|
|
|
|
|
2017-02-01 17:56:22 -05:00
|
|
|
char* method_name = name->as_C_string();
|
2013-01-17 13:40:31 -05:00
|
|
|
buf_len += (int)strlen(method_name);
|
|
|
|
|
|
|
|
char* source_file_name = NULL;
|
2015-11-24 14:59:17 -08:00
|
|
|
Symbol* source = Backtrace::get_source_file_name(holder, version);
|
2015-07-23 15:18:56 -04:00
|
|
|
if (source != NULL) {
|
|
|
|
source_file_name = source->as_C_string();
|
|
|
|
buf_len += (int)strlen(source_file_name);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
char *module_name = NULL, *module_version = NULL;
|
|
|
|
ModuleEntry* module = holder->module();
|
|
|
|
if (module->is_named()) {
|
|
|
|
module_name = module->name()->as_C_string();
|
|
|
|
buf_len += (int)strlen(module_name);
|
|
|
|
if (module->version() != NULL) {
|
|
|
|
module_version = module->version()->as_C_string();
|
|
|
|
buf_len += (int)strlen(module_version);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-17 13:40:31 -05:00
|
|
|
// Allocate temporary buffer with extra space for formatting and line number
|
|
|
|
char* buf = NEW_RESOURCE_ARRAY(char, buf_len + 64);
|
|
|
|
|
|
|
|
// Print stack trace line in buffer
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
sprintf(buf, "\tat %s.%s(", klass_name, method_name);
|
|
|
|
|
|
|
|
// Print module information
|
|
|
|
if (module_name != NULL) {
|
|
|
|
if (module_version != NULL) {
|
|
|
|
sprintf(buf + (int)strlen(buf), "%s@%s/", module_name, module_version);
|
|
|
|
} else {
|
|
|
|
sprintf(buf + (int)strlen(buf), "%s/", module_name);
|
|
|
|
}
|
|
|
|
}
|
2013-01-17 13:40:31 -05:00
|
|
|
|
2017-02-01 17:56:22 -05:00
|
|
|
// The method can be NULL if the requested class version is gone
|
|
|
|
Method* method = holder->method_with_orig_idnum(method_id, version);
|
2013-01-17 13:40:31 -05:00
|
|
|
if (!version_matches(method, version)) {
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
strcat(buf, "Redefined)");
|
2013-01-17 13:40:31 -05:00
|
|
|
} else {
|
2015-11-24 14:59:17 -08:00
|
|
|
int line_number = Backtrace::get_line_number(method, bci);
|
2013-01-17 13:40:31 -05:00
|
|
|
if (line_number == -2) {
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
strcat(buf, "Native Method)");
|
2013-01-17 13:40:31 -05:00
|
|
|
} else {
|
|
|
|
if (source_file_name != NULL && (line_number != -1)) {
|
|
|
|
// Sourcename and linenumber
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
sprintf(buf + (int)strlen(buf), "%s:%d)", source_file_name, line_number);
|
2013-01-17 13:40:31 -05:00
|
|
|
} else if (source_file_name != NULL) {
|
|
|
|
// Just sourcename
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
sprintf(buf + (int)strlen(buf), "%s)", source_file_name);
|
2013-01-17 13:40:31 -05:00
|
|
|
} else {
|
|
|
|
// Neither sourcename nor linenumber
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
sprintf(buf + (int)strlen(buf), "Unknown Source)");
|
2013-01-17 13:40:31 -05:00
|
|
|
}
|
2016-04-26 10:28:51 +02:00
|
|
|
CompiledMethod* nm = method->code();
|
2013-01-17 13:40:31 -05:00
|
|
|
if (WizardMode && nm != NULL) {
|
|
|
|
sprintf(buf + (int)strlen(buf), "(nmethod " INTPTR_FORMAT ")", (intptr_t)nm);
|
|
|
|
}
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2013-01-17 13:40:31 -05:00
|
|
|
st->print_cr("%s", buf);
|
|
|
|
}
|
|
|
|
|
2015-10-23 16:48:38 -04:00
|
|
|
void java_lang_Throwable::print_stack_element(outputStream *st, const methodHandle& method, int bci) {
|
2017-02-15 22:59:57 -05:00
|
|
|
Handle mirror (Thread::current(), method->method_holder()->java_mirror());
|
2015-03-20 02:44:51 -07:00
|
|
|
int method_id = method->orig_method_idnum();
|
2013-01-17 13:40:31 -05:00
|
|
|
int version = method->constants()->version();
|
2017-02-01 17:56:22 -05:00
|
|
|
print_stack_element_to_stream(st, mirror, method_id, version, bci, method->name());
|
2013-01-17 13:40:31 -05:00
|
|
|
}
|
|
|
|
|
2015-12-23 07:27:42 -10:00
|
|
|
/**
|
|
|
|
* Print the throwable message and its stack trace plus all causes by walking the
|
|
|
|
* cause chain. The output looks the same as of Throwable.printStackTrace().
|
|
|
|
*/
|
|
|
|
void java_lang_Throwable::print_stack_trace(Handle throwable, outputStream* st) {
|
|
|
|
// First, print the message.
|
2017-02-15 22:59:57 -05:00
|
|
|
print(throwable(), st);
|
2015-12-23 07:27:42 -10:00
|
|
|
st->cr();
|
|
|
|
|
|
|
|
// Now print the stack trace.
|
|
|
|
Thread* THREAD = Thread::current();
|
|
|
|
while (throwable.not_null()) {
|
|
|
|
objArrayHandle result (THREAD, objArrayOop(backtrace(throwable())));
|
2013-01-17 13:40:31 -05:00
|
|
|
if (result.is_null()) {
|
2016-03-10 13:43:47 -05:00
|
|
|
st->print_raw_cr("\t<<no stack trace available>>");
|
2013-01-17 13:40:31 -05:00
|
|
|
return;
|
|
|
|
}
|
2016-03-10 13:43:47 -05:00
|
|
|
BacktraceIterator iter(result, THREAD);
|
2013-01-17 13:40:31 -05:00
|
|
|
|
2016-03-10 13:43:47 -05:00
|
|
|
while (iter.repeat()) {
|
|
|
|
BacktraceElement bte = iter.next(THREAD);
|
2017-02-01 17:56:22 -05:00
|
|
|
print_stack_element_to_stream(st, bte._mirror, bte._method_id, bte._version, bte._bci, bte._name);
|
2013-01-17 13:40:31 -05:00
|
|
|
}
|
|
|
|
{
|
2016-03-10 13:43:47 -05:00
|
|
|
// Call getCause() which doesn't necessarily return the _cause field.
|
2013-01-17 13:40:31 -05:00
|
|
|
EXCEPTION_MARK;
|
|
|
|
JavaValue cause(T_OBJECT);
|
|
|
|
JavaCalls::call_virtual(&cause,
|
2015-12-23 07:27:42 -10:00
|
|
|
throwable,
|
2017-03-15 10:25:37 -04:00
|
|
|
throwable->klass(),
|
2013-01-17 13:40:31 -05:00
|
|
|
vmSymbols::getCause_name(),
|
|
|
|
vmSymbols::void_throwable_signature(),
|
|
|
|
THREAD);
|
|
|
|
// Ignore any exceptions. we are in the middle of exception handling. Same as classic VM.
|
|
|
|
if (HAS_PENDING_EXCEPTION) {
|
|
|
|
CLEAR_PENDING_EXCEPTION;
|
2015-12-23 07:27:42 -10:00
|
|
|
throwable = Handle();
|
2013-01-17 13:40:31 -05:00
|
|
|
} else {
|
2015-12-23 07:27:42 -10:00
|
|
|
throwable = Handle(THREAD, (oop) cause.get_jobject());
|
|
|
|
if (throwable.not_null()) {
|
2013-01-17 13:40:31 -05:00
|
|
|
st->print("Caused by: ");
|
2017-02-15 22:59:57 -05:00
|
|
|
print(throwable(), st);
|
2013-01-17 13:40:31 -05:00
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-01-12 10:44:41 -10:00
|
|
|
/**
|
|
|
|
* Print the throwable stack trace by calling the Java method java.lang.Throwable.printStackTrace().
|
|
|
|
*/
|
|
|
|
void java_lang_Throwable::java_printStackTrace(Handle throwable, TRAPS) {
|
|
|
|
assert(throwable->is_a(SystemDictionary::Throwable_klass()), "Throwable instance expected");
|
|
|
|
JavaValue result(T_VOID);
|
|
|
|
JavaCalls::call_virtual(&result,
|
|
|
|
throwable,
|
2017-03-15 10:25:37 -04:00
|
|
|
SystemDictionary::Throwable_klass(),
|
2016-01-12 10:44:41 -10:00
|
|
|
vmSymbols::printStackTrace_name(),
|
|
|
|
vmSymbols::void_method_signature(),
|
|
|
|
THREAD);
|
|
|
|
}
|
|
|
|
|
2015-10-23 16:48:38 -04:00
|
|
|
void java_lang_Throwable::fill_in_stack_trace(Handle throwable, const methodHandle& method, TRAPS) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (!StackTraceInThrowable) return;
|
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
|
|
|
|
// Start out by clearing the backtrace for this object, in case the VM
|
|
|
|
// runs out of memory while allocating the stack trace
|
|
|
|
set_backtrace(throwable(), NULL);
|
2014-06-11 09:58:23 -04:00
|
|
|
// Clear lazily constructed Java level stacktrace if refilling occurs
|
|
|
|
// This is unnecessary in 1.7+ but harmless
|
|
|
|
clear_stacktrace(throwable());
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
int max_depth = MaxJavaStackTraceDepth;
|
|
|
|
JavaThread* thread = (JavaThread*)THREAD;
|
2016-03-10 13:43:47 -05:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
BacktraceBuilder bt(CHECK);
|
|
|
|
|
2011-04-26 14:04:43 -04:00
|
|
|
// If there is no Java frame just return the method that was being called
|
|
|
|
// with bci 0
|
|
|
|
if (!thread->has_last_Java_frame()) {
|
|
|
|
if (max_depth >= 1 && method() != NULL) {
|
|
|
|
bt.push(method(), 0, CHECK);
|
2016-03-10 13:43:47 -05:00
|
|
|
log_info(stacktrace)("%s, %d", throwable->klass()->external_name(), 1);
|
|
|
|
set_depth(throwable(), 1);
|
2011-04-26 14:04:43 -04:00
|
|
|
set_backtrace(throwable(), bt.backtrace());
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Instead of using vframe directly, this version of fill_in_stack_trace
|
|
|
|
// basically handles everything by hand. This significantly improved the
|
|
|
|
// speed of this method call up to 28.5% on Solaris sparc. 27.1% on Windows.
|
|
|
|
// See bug 6333838 for more details.
|
|
|
|
// The "ASSERT" here is to verify this method generates the exactly same stack
|
|
|
|
// trace as utilizing vframe.
|
|
|
|
#ifdef ASSERT
|
|
|
|
vframeStream st(thread);
|
|
|
|
methodHandle st_method(THREAD, st.method());
|
|
|
|
#endif
|
|
|
|
int total_count = 0;
|
|
|
|
RegisterMap map(thread, false);
|
|
|
|
int decode_offset = 0;
|
2016-04-26 10:28:51 +02:00
|
|
|
CompiledMethod* nm = NULL;
|
2007-12-01 00:00:00 +00:00
|
|
|
bool skip_fillInStackTrace_check = false;
|
|
|
|
bool skip_throwableInit_check = false;
|
2012-07-27 16:14:15 -07:00
|
|
|
bool skip_hidden = !ShowHiddenFrames;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2018-01-31 11:07:55 -05:00
|
|
|
for (frame fr = thread->last_frame(); max_depth == 0 || max_depth != total_count;) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Method* method = NULL;
|
2007-12-01 00:00:00 +00:00
|
|
|
int bci = 0;
|
|
|
|
|
|
|
|
// Compiled java method case.
|
|
|
|
if (decode_offset != 0) {
|
|
|
|
DebugInfoReadStream stream(nm, decode_offset);
|
|
|
|
decode_offset = stream.read_int();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
method = (Method*)nm->metadata_at(stream.read_int());
|
2009-08-20 12:42:57 -07:00
|
|
|
bci = stream.read_bci();
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
|
|
|
if (fr.is_first_frame()) break;
|
|
|
|
address pc = fr.pc();
|
|
|
|
if (fr.is_interpreted_frame()) {
|
2014-07-17 15:45:46 -04:00
|
|
|
address bcp = fr.interpreter_frame_bcp();
|
2007-12-01 00:00:00 +00:00
|
|
|
method = fr.interpreter_frame_method();
|
2014-07-17 15:45:46 -04:00
|
|
|
bci = method->bci_from(bcp);
|
2007-12-01 00:00:00 +00:00
|
|
|
fr = fr.sender(&map);
|
|
|
|
} else {
|
|
|
|
CodeBlob* cb = fr.cb();
|
|
|
|
// HMMM QQQ might be nice to have frame return nm as NULL if cb is non-NULL
|
|
|
|
// but non nmethod
|
|
|
|
fr = fr.sender(&map);
|
2016-04-26 10:28:51 +02:00
|
|
|
if (cb == NULL || !cb->is_compiled()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
continue;
|
|
|
|
}
|
2016-04-26 10:28:51 +02:00
|
|
|
nm = cb->as_compiled_method();
|
2007-12-01 00:00:00 +00:00
|
|
|
if (nm->method()->is_native()) {
|
|
|
|
method = nm->method();
|
|
|
|
bci = 0;
|
|
|
|
} else {
|
|
|
|
PcDesc* pd = nm->pc_desc_at(pc);
|
|
|
|
decode_offset = pd->scope_decode_offset();
|
|
|
|
// if decode_offset is not equal to 0, it will execute the
|
|
|
|
// "compiled java method case" at the beginning of the loop.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef ASSERT
|
2011-04-12 02:53:06 -04:00
|
|
|
assert(st_method() == method && st.bci() == bci,
|
|
|
|
"Wrong stack trace");
|
|
|
|
st.next();
|
|
|
|
// vframeStream::method isn't GC-safe so store off a copy
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// of the Method* in case we GC.
|
2011-04-12 02:53:06 -04:00
|
|
|
if (!st.at_end()) {
|
|
|
|
st_method = st.method();
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
#endif
|
2011-04-12 02:53:06 -04:00
|
|
|
|
|
|
|
// the format of the stacktrace will be:
|
|
|
|
// - 1 or more fillInStackTrace frames for the exception class (skipped)
|
|
|
|
// - 0 or more <init> methods for the exception class (skipped)
|
|
|
|
// - rest of the stack
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
if (!skip_fillInStackTrace_check) {
|
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
Annotate possibly intrinsified methods with @HotSpotIntrinsicCandidate. Add checks omitted by intrinsics to the library code. Add CheckIntrinsics flags to check consistency of intrinsics.
Reviewed-by: jrose, kvn, thartmann, vlivanov, abuckley, darcy, ascarpino, briangoetz, alanb, aph, dnsimon
2015-07-03 07:25:03 +02:00
|
|
|
if (method->name() == vmSymbols::fillInStackTrace_name() &&
|
2011-04-12 02:53:06 -04:00
|
|
|
throwable->is_a(method->method_holder())) {
|
2007-12-01 00:00:00 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-04-12 02:53:06 -04:00
|
|
|
else {
|
|
|
|
skip_fillInStackTrace_check = true; // gone past them all
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
if (!skip_throwableInit_check) {
|
2011-04-12 02:53:06 -04:00
|
|
|
assert(skip_fillInStackTrace_check, "logic error in backtrace filtering");
|
|
|
|
|
|
|
|
// skip <init> methods of the exception class and superclasses
|
|
|
|
// This is simlar to classic VM.
|
2007-12-01 00:00:00 +00:00
|
|
|
if (method->name() == vmSymbols::object_initializer_name() &&
|
|
|
|
throwable->is_a(method->method_holder())) {
|
|
|
|
continue;
|
|
|
|
} else {
|
2011-04-12 02:53:06 -04:00
|
|
|
// there are none or we've seen them all - either way stop checking
|
2007-12-01 00:00:00 +00:00
|
|
|
skip_throwableInit_check = true;
|
|
|
|
}
|
|
|
|
}
|
2012-07-24 10:51:00 -07:00
|
|
|
if (method->is_hidden()) {
|
|
|
|
if (skip_hidden) continue;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
bt.push(method, bci, CHECK);
|
|
|
|
total_count++;
|
|
|
|
}
|
|
|
|
|
2016-03-10 13:43:47 -05:00
|
|
|
log_info(stacktrace)("%s, %d", throwable->klass()->external_name(), total_count);
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Put completed stack trace into throwable object
|
|
|
|
set_backtrace(throwable(), bt.backtrace());
|
2016-03-10 13:43:47 -05:00
|
|
|
set_depth(throwable(), total_count);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2015-10-23 16:48:38 -04:00
|
|
|
void java_lang_Throwable::fill_in_stack_trace(Handle throwable, const methodHandle& method) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// No-op if stack trace is disabled
|
|
|
|
if (!StackTraceInThrowable) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Disable stack traces for some preallocated out of memory errors
|
|
|
|
if (!Universe::should_fill_in_stack_trace(throwable)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRESERVE_EXCEPTION_MARK;
|
|
|
|
|
|
|
|
JavaThread* thread = JavaThread::active();
|
2011-04-26 14:04:43 -04:00
|
|
|
fill_in_stack_trace(throwable, method, thread);
|
2007-12-01 00:00:00 +00:00
|
|
|
// ignore exceptions thrown during stack trace filling
|
|
|
|
CLEAR_PENDING_EXCEPTION;
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_Throwable::allocate_backtrace(Handle throwable, TRAPS) {
|
|
|
|
// Allocate stack trace - backtrace is created but not filled in
|
|
|
|
|
|
|
|
// No-op if stack trace is disabled
|
|
|
|
if (!StackTraceInThrowable) return;
|
2013-01-17 13:40:31 -05:00
|
|
|
BacktraceBuilder bt(CHECK); // creates a backtrace
|
|
|
|
set_backtrace(throwable(), bt.backtrace());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void java_lang_Throwable::fill_in_stack_trace_of_preallocated_backtrace(Handle throwable) {
|
|
|
|
// Fill in stack trace into preallocated backtrace (no GC)
|
|
|
|
|
|
|
|
// No-op if stack trace is disabled
|
|
|
|
if (!StackTraceInThrowable) return;
|
|
|
|
|
2010-01-06 14:22:39 -08:00
|
|
|
assert(throwable->is_a(SystemDictionary::Throwable_klass()), "sanity check");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2013-01-17 13:40:31 -05:00
|
|
|
JavaThread* THREAD = JavaThread::current();
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2013-01-17 13:40:31 -05:00
|
|
|
objArrayHandle backtrace (THREAD, (objArrayOop)java_lang_Throwable::backtrace(throwable()));
|
|
|
|
assert(backtrace.not_null(), "backtrace should have been preallocated");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2013-01-17 13:40:31 -05:00
|
|
|
ResourceMark rm(THREAD);
|
|
|
|
vframeStream st(THREAD);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2017-02-15 22:59:57 -05:00
|
|
|
BacktraceBuilder bt(THREAD, backtrace);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Unlike fill_in_stack_trace we do not skip fillInStackTrace or throwable init
|
|
|
|
// methods as preallocated errors aren't created by "java" code.
|
|
|
|
|
|
|
|
// fill in as much stack trace as possible
|
|
|
|
int chunk_count = 0;
|
|
|
|
for (;!st.at_end(); st.next()) {
|
2013-01-17 13:40:31 -05:00
|
|
|
bt.push(st.method(), st.bci(), CHECK);
|
2007-12-01 00:00:00 +00:00
|
|
|
chunk_count++;
|
|
|
|
|
|
|
|
// Bail-out for deep stacks
|
2016-03-10 13:43:47 -05:00
|
|
|
if (chunk_count >= trace_chunk_size) break;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2016-03-10 13:43:47 -05:00
|
|
|
set_depth(throwable(), chunk_count);
|
|
|
|
log_info(stacktrace)("%s, %d", throwable->klass()->external_name(), chunk_count);
|
2011-07-22 00:29:01 -07:00
|
|
|
|
2014-06-11 09:58:23 -04:00
|
|
|
// We support the Throwable immutability protocol defined for Java 7.
|
|
|
|
java_lang_Throwable::set_stacktrace(throwable(), java_lang_Throwable::unassigned_stacktrace());
|
|
|
|
assert(java_lang_Throwable::unassigned_stacktrace() != NULL, "not initialized");
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2016-03-10 13:43:47 -05:00
|
|
|
void java_lang_Throwable::get_stack_trace_elements(Handle throwable,
|
|
|
|
objArrayHandle stack_trace_array_h, TRAPS) {
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-03-10 13:43:47 -05:00
|
|
|
if (throwable.is_null() || stack_trace_array_h.is_null()) {
|
|
|
|
THROW(vmSymbols::java_lang_NullPointerException());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2016-03-10 13:43:47 -05:00
|
|
|
assert(stack_trace_array_h->is_objArray(), "Stack trace array should be an array of StackTraceElenent");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-03-10 13:43:47 -05:00
|
|
|
if (stack_trace_array_h->length() != depth(throwable())) {
|
|
|
|
THROW(vmSymbols::java_lang_IndexOutOfBoundsException());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2013-01-17 13:40:31 -05:00
|
|
|
|
2016-03-10 13:43:47 -05:00
|
|
|
objArrayHandle result(THREAD, objArrayOop(backtrace(throwable())));
|
|
|
|
BacktraceIterator iter(result, THREAD);
|
|
|
|
|
|
|
|
int index = 0;
|
|
|
|
while (iter.repeat()) {
|
|
|
|
BacktraceElement bte = iter.next(THREAD);
|
2013-01-17 13:40:31 -05:00
|
|
|
|
2016-03-10 13:43:47 -05:00
|
|
|
Handle stack_trace_element(THREAD, stack_trace_array_h->obj_at(index++));
|
|
|
|
|
|
|
|
if (stack_trace_element.is_null()) {
|
|
|
|
THROW(vmSymbols::java_lang_NullPointerException());
|
|
|
|
}
|
2013-01-17 13:40:31 -05:00
|
|
|
|
2016-03-10 13:43:47 -05:00
|
|
|
InstanceKlass* holder = InstanceKlass::cast(java_lang_Class::as_Klass(bte._mirror()));
|
|
|
|
methodHandle method (THREAD, holder->method_with_orig_idnum(bte._method_id, bte._version));
|
2013-01-17 13:40:31 -05:00
|
|
|
|
2016-03-10 13:43:47 -05:00
|
|
|
java_lang_StackTraceElement::fill_in(stack_trace_element, holder,
|
|
|
|
method,
|
|
|
|
bte._version,
|
|
|
|
bte._bci,
|
2017-02-01 17:56:22 -05:00
|
|
|
bte._name, CHECK);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-10 13:43:47 -05:00
|
|
|
oop java_lang_StackTraceElement::create(const methodHandle& method, int bci, TRAPS) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Allocate java.lang.StackTraceElement instance
|
2017-03-15 10:25:37 -04:00
|
|
|
InstanceKlass* k = SystemDictionary::StackTraceElement_klass();
|
2008-04-29 19:45:22 -07:00
|
|
|
assert(k != NULL, "must be loaded in 1.4+");
|
2017-03-15 10:25:37 -04:00
|
|
|
if (k->should_be_initialized()) {
|
|
|
|
k->initialize(CHECK_0);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2017-03-15 10:25:37 -04:00
|
|
|
Handle element = k->allocate_instance_handle(CHECK_0);
|
2015-11-24 14:59:17 -08:00
|
|
|
|
2016-03-10 13:43:47 -05:00
|
|
|
int version = method->constants()->version();
|
2017-02-01 17:56:22 -05:00
|
|
|
fill_in(element, method->method_holder(), method, version, bci, method->name(), CHECK_0);
|
2016-03-10 13:43:47 -05:00
|
|
|
return element();
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_StackTraceElement::fill_in(Handle element,
|
|
|
|
InstanceKlass* holder, const methodHandle& method,
|
2017-02-01 17:56:22 -05:00
|
|
|
int version, int bci, Symbol* name, TRAPS) {
|
2016-03-10 13:43:47 -05:00
|
|
|
assert(element->is_a(SystemDictionary::StackTraceElement_klass()), "sanity check");
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
ResourceMark rm(THREAD);
|
2019-01-09 20:28:16 +01:00
|
|
|
HandleMark hm(THREAD);
|
|
|
|
|
|
|
|
// Fill in class name
|
|
|
|
Handle java_class(THREAD, holder->java_mirror());
|
|
|
|
oop classname = java_lang_Class::name(java_class, CHECK);
|
2007-12-01 00:00:00 +00:00
|
|
|
java_lang_StackTraceElement::set_declaringClass(element(), classname);
|
2019-01-09 20:28:16 +01:00
|
|
|
java_lang_StackTraceElement::set_declaringClassObject(element(), java_class());
|
2016-11-03 18:08:02 -07:00
|
|
|
|
|
|
|
oop loader = holder->class_loader();
|
|
|
|
if (loader != NULL) {
|
|
|
|
oop loader_name = java_lang_ClassLoader::name(loader);
|
|
|
|
if (loader_name != NULL)
|
|
|
|
java_lang_StackTraceElement::set_classLoaderName(element(), loader_name);
|
|
|
|
}
|
2013-01-17 13:40:31 -05:00
|
|
|
|
2013-10-03 18:53:27 -04:00
|
|
|
// Fill in method name
|
2017-02-01 17:56:22 -05:00
|
|
|
oop methodname = StringTable::intern(name, CHECK);
|
2007-12-01 00:00:00 +00:00
|
|
|
java_lang_StackTraceElement::set_methodName(element(), methodname);
|
2013-01-17 13:40:31 -05:00
|
|
|
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
// Fill in module name and version
|
|
|
|
ModuleEntry* module = holder->module();
|
|
|
|
if (module->is_named()) {
|
2016-03-23 23:36:29 +01:00
|
|
|
oop module_name = StringTable::intern(module->name(), CHECK);
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
java_lang_StackTraceElement::set_moduleName(element(), module_name);
|
|
|
|
oop module_version;
|
|
|
|
if (module->version() != NULL) {
|
2016-03-23 23:36:29 +01:00
|
|
|
module_version = StringTable::intern(module->version(), CHECK);
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
} else {
|
|
|
|
module_version = NULL;
|
|
|
|
}
|
|
|
|
java_lang_StackTraceElement::set_moduleVersion(element(), module_version);
|
|
|
|
}
|
|
|
|
|
2017-02-01 17:56:22 -05:00
|
|
|
if (method() == NULL || !version_matches(method(), version)) {
|
2013-01-17 13:40:31 -05:00
|
|
|
// The method was redefined, accurate line number information isn't available
|
|
|
|
java_lang_StackTraceElement::set_fileName(element(), NULL);
|
|
|
|
java_lang_StackTraceElement::set_lineNumber(element(), -1);
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
2013-01-17 13:40:31 -05:00
|
|
|
// Fill in source file name and line number.
|
2015-11-24 14:59:17 -08:00
|
|
|
Symbol* source = Backtrace::get_source_file_name(holder, version);
|
2019-01-14 17:20:20 +01:00
|
|
|
oop source_file = java_lang_Class::source_file(java_class());
|
|
|
|
if (source != NULL) {
|
|
|
|
// Class was not redefined. We can trust its cache if set,
|
|
|
|
// else we have to initialize it.
|
|
|
|
if (source_file == NULL) {
|
|
|
|
source_file = StringTable::intern(source, CHECK);
|
|
|
|
java_lang_Class::set_source_file(java_class(), source_file);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Class was redefined. Dump the cache if it was set.
|
|
|
|
if (source_file != NULL) {
|
|
|
|
source_file = NULL;
|
|
|
|
java_lang_Class::set_source_file(java_class(), source_file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
java_lang_StackTraceElement::set_fileName(element(), source_file);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2015-11-24 14:59:17 -08:00
|
|
|
int line_number = Backtrace::get_line_number(method, bci);
|
2013-01-17 13:40:31 -05:00
|
|
|
java_lang_StackTraceElement::set_lineNumber(element(), line_number);
|
|
|
|
}
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2019-05-01 12:31:29 -07:00
|
|
|
#if INCLUDE_JVMCI
|
|
|
|
void java_lang_StackTraceElement::decode(Handle mirror, methodHandle method, int bci, Symbol*& methodname, Symbol*& filename, int& line_number) {
|
|
|
|
int method_id = method->orig_method_idnum();
|
|
|
|
int cpref = method->name_index();
|
|
|
|
decode(mirror, method_id, method->constants()->version(), bci, cpref, methodname, filename, line_number);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_StackTraceElement::decode(Handle mirror, int method_id, int version, int bci, int cpref, Symbol*& methodname, Symbol*& filename, int& line_number) {
|
|
|
|
// Fill in class name
|
|
|
|
InstanceKlass* holder = InstanceKlass::cast(java_lang_Class::as_Klass(mirror()));
|
|
|
|
Method* method = holder->method_with_orig_idnum(method_id, version);
|
|
|
|
|
|
|
|
// The method can be NULL if the requested class version is gone
|
|
|
|
Symbol* sym = (method != NULL) ? method->name() : holder->constants()->symbol_at(cpref);
|
|
|
|
|
|
|
|
// Fill in method name
|
|
|
|
methodname = sym;
|
|
|
|
|
|
|
|
if (!version_matches(method, version)) {
|
|
|
|
// If the method was redefined, accurate line number information isn't available
|
|
|
|
filename = NULL;
|
|
|
|
line_number = -1;
|
|
|
|
} else {
|
|
|
|
// Fill in source file name and line number.
|
|
|
|
// Use a specific ik version as a holder since the mirror might
|
|
|
|
// refer to a version that is now obsolete and no longer accessible
|
|
|
|
// via the previous versions list.
|
|
|
|
holder = holder->get_klass_version(version);
|
|
|
|
assert(holder != NULL, "sanity check");
|
2019-08-29 08:52:22 -04:00
|
|
|
filename = holder->source_file_name();
|
2019-05-01 12:31:29 -07:00
|
|
|
line_number = Backtrace::get_line_number(method, bci);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // INCLUDE_JVMCI
|
|
|
|
|
2015-11-24 14:59:17 -08:00
|
|
|
Method* java_lang_StackFrameInfo::get_method(Handle stackFrame, InstanceKlass* holder, TRAPS) {
|
2019-01-09 09:01:27 -05:00
|
|
|
HandleMark hm(THREAD);
|
2016-04-08 12:26:29 -07:00
|
|
|
Handle mname(THREAD, stackFrame->obj_field(_memberName_offset));
|
|
|
|
Method* method = (Method*)java_lang_invoke_MemberName::vmtarget(mname());
|
|
|
|
// we should expand MemberName::name when Throwable uses StackTrace
|
|
|
|
// MethodHandles::expand_MemberName(mname, MethodHandles::_suppress_defc|MethodHandles::_suppress_type, CHECK_NULL);
|
|
|
|
return method;
|
2015-11-24 14:59:17 -08:00
|
|
|
}
|
|
|
|
|
2017-05-27 09:21:01 -04:00
|
|
|
void java_lang_StackFrameInfo::set_method_and_bci(Handle stackFrame, const methodHandle& method, int bci, TRAPS) {
|
2015-11-24 14:59:17 -08:00
|
|
|
// set Method* or mid/cpref
|
2019-01-09 09:01:27 -05:00
|
|
|
HandleMark hm(THREAD);
|
2017-02-15 22:59:57 -05:00
|
|
|
Handle mname(Thread::current(), stackFrame->obj_field(_memberName_offset));
|
2016-04-08 12:26:29 -07:00
|
|
|
InstanceKlass* ik = method->method_holder();
|
2017-05-27 09:21:01 -04:00
|
|
|
CallInfo info(method(), ik, CHECK);
|
2016-04-08 12:26:29 -07:00
|
|
|
MethodHandles::init_method_MemberName(mname, info);
|
2015-11-24 14:59:17 -08:00
|
|
|
// set bci
|
|
|
|
java_lang_StackFrameInfo::set_bci(stackFrame(), bci);
|
|
|
|
// method may be redefined; store the version
|
|
|
|
int version = method->constants()->version();
|
|
|
|
assert((jushort)version == version, "version should be short");
|
|
|
|
java_lang_StackFrameInfo::set_version(stackFrame(), (short)version);
|
|
|
|
}
|
|
|
|
|
2016-04-08 12:26:29 -07:00
|
|
|
void java_lang_StackFrameInfo::to_stack_trace_element(Handle stackFrame, Handle stack_trace_element, TRAPS) {
|
2015-11-24 14:59:17 -08:00
|
|
|
ResourceMark rm(THREAD);
|
2019-01-09 09:01:27 -05:00
|
|
|
HandleMark hm(THREAD);
|
2017-11-09 11:13:50 -08:00
|
|
|
Handle mname(THREAD, stackFrame->obj_field(java_lang_StackFrameInfo::_memberName_offset));
|
|
|
|
Klass* clazz = java_lang_Class::as_Klass(java_lang_invoke_MemberName::clazz(mname()));
|
|
|
|
InstanceKlass* holder = InstanceKlass::cast(clazz);
|
2015-11-24 14:59:17 -08:00
|
|
|
Method* method = java_lang_StackFrameInfo::get_method(stackFrame, holder, CHECK);
|
|
|
|
|
|
|
|
short version = stackFrame->short_field(_version_offset);
|
2019-08-15 13:41:30 -07:00
|
|
|
int bci = stackFrame->int_field(_bci_offset);
|
2017-02-01 17:56:22 -05:00
|
|
|
Symbol* name = method->name();
|
|
|
|
java_lang_StackTraceElement::fill_in(stack_trace_element, holder, method, version, bci, name, CHECK);
|
2015-11-24 14:59:17 -08:00
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#define STACKFRAMEINFO_FIELDS_DO(macro) \
|
|
|
|
macro(_memberName_offset, k, "memberName", object_signature, false); \
|
2019-08-15 13:41:30 -07:00
|
|
|
macro(_bci_offset, k, "bci", int_signature, false)
|
2018-03-02 17:25:55 -05:00
|
|
|
|
2015-11-24 14:59:17 -08:00
|
|
|
void java_lang_StackFrameInfo::compute_offsets() {
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k = SystemDictionary::StackFrameInfo_klass();
|
2018-03-02 17:25:55 -05:00
|
|
|
STACKFRAMEINFO_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
2015-11-24 14:59:17 -08:00
|
|
|
STACKFRAMEINFO_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
|
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_StackFrameInfo::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
STACKFRAMEINFO_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
STACKFRAMEINFO_INJECTED_FIELDS(INJECTED_FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define LIVESTACKFRAMEINFO_FIELDS_DO(macro) \
|
|
|
|
macro(_monitors_offset, k, "monitors", object_array_signature, false); \
|
|
|
|
macro(_locals_offset, k, "locals", object_array_signature, false); \
|
|
|
|
macro(_operands_offset, k, "operands", object_array_signature, false); \
|
|
|
|
macro(_mode_offset, k, "mode", int_signature, false)
|
|
|
|
|
2015-11-24 14:59:17 -08:00
|
|
|
void java_lang_LiveStackFrameInfo::compute_offsets() {
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k = SystemDictionary::LiveStackFrameInfo_klass();
|
2018-03-02 17:25:55 -05:00
|
|
|
LIVESTACKFRAMEINFO_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
2015-11-24 14:59:17 -08:00
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_LiveStackFrameInfo::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
LIVESTACKFRAMEINFO_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define ACCESSIBLEOBJECT_FIELDS_DO(macro) \
|
|
|
|
macro(override_offset, k, "override", bool_signature, false)
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
void java_lang_reflect_AccessibleObject::compute_offsets() {
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k = SystemDictionary::reflect_AccessibleObject_klass();
|
2018-03-02 17:25:55 -05:00
|
|
|
ACCESSIBLEOBJECT_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_reflect_AccessibleObject::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
ACCESSIBLEOBJECT_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2018-03-02 17:25:55 -05:00
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
jboolean java_lang_reflect_AccessibleObject::override(oop reflect) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
return (jboolean) reflect->bool_field(override_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_AccessibleObject::set_override(oop reflect, jboolean value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
reflect->bool_field_put(override_offset, (int) value);
|
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#define METHOD_FIELDS_DO(macro) \
|
|
|
|
macro(clazz_offset, k, vmSymbols::clazz_name(), class_signature, false); \
|
|
|
|
macro(name_offset, k, vmSymbols::name_name(), string_signature, false); \
|
|
|
|
macro(returnType_offset, k, vmSymbols::returnType_name(), class_signature, false); \
|
|
|
|
macro(parameterTypes_offset, k, vmSymbols::parameterTypes_name(), class_array_signature, false); \
|
|
|
|
macro(exceptionTypes_offset, k, vmSymbols::exceptionTypes_name(), class_array_signature, false); \
|
|
|
|
macro(slot_offset, k, vmSymbols::slot_name(), int_signature, false); \
|
|
|
|
macro(modifiers_offset, k, vmSymbols::modifiers_name(), int_signature, false); \
|
2018-09-19 15:25:05 -04:00
|
|
|
macro(signature_offset, k, vmSymbols::signature_name(), string_signature, false); \
|
|
|
|
macro(annotations_offset, k, vmSymbols::annotations_name(), byte_array_signature, false); \
|
|
|
|
macro(parameter_annotations_offset, k, vmSymbols::parameter_annotations_name(), byte_array_signature, false); \
|
|
|
|
macro(annotation_default_offset, k, vmSymbols::annotation_default_name(), byte_array_signature, false);
|
2018-03-02 17:25:55 -05:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
void java_lang_reflect_Method::compute_offsets() {
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k = SystemDictionary::reflect_Method_klass();
|
2018-03-02 17:25:55 -05:00
|
|
|
METHOD_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_reflect_Method::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
METHOD_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2018-03-02 17:25:55 -05:00
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
Handle java_lang_reflect_Method::create(TRAPS) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* klass = SystemDictionary::reflect_Method_klass();
|
2007-12-01 00:00:00 +00:00
|
|
|
// This class is eagerly initialized during VM initialization, since we keep a refence
|
|
|
|
// to one of the methods
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
assert(InstanceKlass::cast(klass)->is_initialized(), "must be initialized");
|
2014-11-14 09:47:09 +01:00
|
|
|
return InstanceKlass::cast(klass)->allocate_instance_handle(THREAD);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
oop java_lang_reflect_Method::clazz(oop reflect) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
return reflect->obj_field(clazz_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Method::set_clazz(oop reflect, oop value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
reflect->obj_field_put(clazz_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
int java_lang_reflect_Method::slot(oop reflect) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
return reflect->int_field(slot_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Method::set_slot(oop reflect, int value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
reflect->int_field_put(slot_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Method::set_name(oop method, oop value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
method->obj_field_put(name_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
oop java_lang_reflect_Method::return_type(oop method) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
return method->obj_field(returnType_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Method::set_return_type(oop method, oop value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
method->obj_field_put(returnType_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
oop java_lang_reflect_Method::parameter_types(oop method) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
return method->obj_field(parameterTypes_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Method::set_parameter_types(oop method, oop value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
method->obj_field_put(parameterTypes_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Method::set_exception_types(oop method, oop value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
method->obj_field_put(exceptionTypes_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Method::set_modifiers(oop method, int value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
method->int_field_put(modifiers_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Method::set_signature(oop method, oop value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
method->obj_field_put(signature_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Method::set_annotations(oop method, oop value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
method->obj_field_put(annotations_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Method::set_parameter_annotations(oop method, oop value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
method->obj_field_put(parameter_annotations_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Method::set_annotation_default(oop method, oop value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
method->obj_field_put(annotation_default_offset, value);
|
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#define CONSTRUCTOR_FIELDS_DO(macro) \
|
|
|
|
macro(clazz_offset, k, vmSymbols::clazz_name(), class_signature, false); \
|
|
|
|
macro(parameterTypes_offset, k, vmSymbols::parameterTypes_name(), class_array_signature, false); \
|
|
|
|
macro(exceptionTypes_offset, k, vmSymbols::exceptionTypes_name(), class_array_signature, false); \
|
|
|
|
macro(slot_offset, k, vmSymbols::slot_name(), int_signature, false); \
|
|
|
|
macro(modifiers_offset, k, vmSymbols::modifiers_name(), int_signature, false); \
|
2018-09-19 15:25:05 -04:00
|
|
|
macro(signature_offset, k, vmSymbols::signature_name(), string_signature, false); \
|
|
|
|
macro(annotations_offset, k, vmSymbols::annotations_name(), byte_array_signature, false); \
|
|
|
|
macro(parameter_annotations_offset, k, vmSymbols::parameter_annotations_name(), byte_array_signature, false);
|
2018-03-02 17:25:55 -05:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
void java_lang_reflect_Constructor::compute_offsets() {
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k = SystemDictionary::reflect_Constructor_klass();
|
2018-03-02 17:25:55 -05:00
|
|
|
CONSTRUCTOR_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_reflect_Constructor::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
CONSTRUCTOR_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
Handle java_lang_reflect_Constructor::create(TRAPS) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* name = vmSymbols::java_lang_reflect_Constructor();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
|
2017-03-15 10:25:37 -04:00
|
|
|
InstanceKlass* ik = InstanceKlass::cast(k);
|
2007-12-01 00:00:00 +00:00
|
|
|
// Ensure it is initialized
|
2017-03-15 10:25:37 -04:00
|
|
|
ik->initialize(CHECK_NH);
|
|
|
|
return ik->allocate_instance_handle(THREAD);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
oop java_lang_reflect_Constructor::clazz(oop reflect) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
return reflect->obj_field(clazz_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Constructor::set_clazz(oop reflect, oop value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
reflect->obj_field_put(clazz_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
oop java_lang_reflect_Constructor::parameter_types(oop constructor) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
return constructor->obj_field(parameterTypes_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Constructor::set_parameter_types(oop constructor, oop value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
constructor->obj_field_put(parameterTypes_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Constructor::set_exception_types(oop constructor, oop value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
constructor->obj_field_put(exceptionTypes_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
int java_lang_reflect_Constructor::slot(oop reflect) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
return reflect->int_field(slot_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Constructor::set_slot(oop reflect, int value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
reflect->int_field_put(slot_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Constructor::set_modifiers(oop constructor, int value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
constructor->int_field_put(modifiers_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Constructor::set_signature(oop constructor, oop value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
constructor->obj_field_put(signature_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Constructor::set_annotations(oop constructor, oop value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
constructor->obj_field_put(annotations_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Constructor::set_parameter_annotations(oop method, oop value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
method->obj_field_put(parameter_annotations_offset, value);
|
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#define FIELD_FIELDS_DO(macro) \
|
|
|
|
macro(clazz_offset, k, vmSymbols::clazz_name(), class_signature, false); \
|
|
|
|
macro(name_offset, k, vmSymbols::name_name(), string_signature, false); \
|
|
|
|
macro(type_offset, k, vmSymbols::type_name(), class_signature, false); \
|
|
|
|
macro(slot_offset, k, vmSymbols::slot_name(), int_signature, false); \
|
|
|
|
macro(modifiers_offset, k, vmSymbols::modifiers_name(), int_signature, false); \
|
2018-09-19 15:25:05 -04:00
|
|
|
macro(signature_offset, k, vmSymbols::signature_name(), string_signature, false); \
|
|
|
|
macro(annotations_offset, k, vmSymbols::annotations_name(), byte_array_signature, false);
|
2018-03-02 17:25:55 -05:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
void java_lang_reflect_Field::compute_offsets() {
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k = SystemDictionary::reflect_Field_klass();
|
2018-03-02 17:25:55 -05:00
|
|
|
FIELD_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_reflect_Field::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
FIELD_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
Handle java_lang_reflect_Field::create(TRAPS) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* name = vmSymbols::java_lang_reflect_Field();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
|
2017-03-15 10:25:37 -04:00
|
|
|
InstanceKlass* ik = InstanceKlass::cast(k);
|
2007-12-01 00:00:00 +00:00
|
|
|
// Ensure it is initialized
|
2017-03-15 10:25:37 -04:00
|
|
|
ik->initialize(CHECK_NH);
|
|
|
|
return ik->allocate_instance_handle(THREAD);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
oop java_lang_reflect_Field::clazz(oop reflect) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
return reflect->obj_field(clazz_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Field::set_clazz(oop reflect, oop value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
reflect->obj_field_put(clazz_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
oop java_lang_reflect_Field::name(oop field) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
return field->obj_field(name_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Field::set_name(oop field, oop value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
field->obj_field_put(name_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
oop java_lang_reflect_Field::type(oop field) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
return field->obj_field(type_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Field::set_type(oop field, oop value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
field->obj_field_put(type_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
int java_lang_reflect_Field::slot(oop reflect) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
return reflect->int_field(slot_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Field::set_slot(oop reflect, int value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
reflect->int_field_put(slot_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
int java_lang_reflect_Field::modifiers(oop field) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
return field->int_field(modifiers_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Field::set_modifiers(oop field, int value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
field->int_field_put(modifiers_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Field::set_signature(oop field, oop value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
field->obj_field_put(signature_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Field::set_annotations(oop field, oop value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
field->obj_field_put(annotations_offset, value);
|
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#define CONSTANTPOOL_FIELDS_DO(macro) \
|
|
|
|
macro(_oop_offset, k, "constantPoolOop", object_signature, false)
|
|
|
|
|
2016-04-15 16:19:15 +01:00
|
|
|
void reflect_ConstantPool::compute_offsets() {
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k = SystemDictionary::reflect_ConstantPool_klass();
|
|
|
|
// The field is called ConstantPool* in the sun.reflect.ConstantPool class.
|
2018-03-02 17:25:55 -05:00
|
|
|
CONSTANTPOOL_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void reflect_ConstantPool::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
CONSTANTPOOL_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define PARAMETER_FIELDS_DO(macro) \
|
|
|
|
macro(name_offset, k, vmSymbols::name_name(), string_signature, false); \
|
|
|
|
macro(modifiers_offset, k, vmSymbols::modifiers_name(), int_signature, false); \
|
|
|
|
macro(index_offset, k, vmSymbols::index_name(), int_signature, false); \
|
|
|
|
macro(executable_offset, k, vmSymbols::executable_name(), executable_signature, false)
|
|
|
|
|
2013-01-08 14:01:36 -05:00
|
|
|
void java_lang_reflect_Parameter::compute_offsets() {
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k = SystemDictionary::reflect_Parameter_klass();
|
2018-03-02 17:25:55 -05:00
|
|
|
PARAMETER_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_reflect_Parameter::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
PARAMETER_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
2013-01-08 14:01:36 -05:00
|
|
|
}
|
2018-03-02 17:25:55 -05:00
|
|
|
#endif
|
2013-01-08 14:01:36 -05:00
|
|
|
|
|
|
|
Handle java_lang_reflect_Parameter::create(TRAPS) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
Symbol* name = vmSymbols::java_lang_reflect_Parameter();
|
|
|
|
Klass* k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
|
2017-03-15 10:25:37 -04:00
|
|
|
InstanceKlass* ik = InstanceKlass::cast(k);
|
2013-01-08 14:01:36 -05:00
|
|
|
// Ensure it is initialized
|
2017-03-15 10:25:37 -04:00
|
|
|
ik->initialize(CHECK_NH);
|
|
|
|
return ik->allocate_instance_handle(THREAD);
|
2013-01-08 14:01:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
oop java_lang_reflect_Parameter::name(oop param) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
return param->obj_field(name_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Parameter::set_name(oop param, oop value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
param->obj_field_put(name_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
int java_lang_reflect_Parameter::modifiers(oop param) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
return param->int_field(modifiers_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Parameter::set_modifiers(oop param, int value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
param->int_field_put(modifiers_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
int java_lang_reflect_Parameter::index(oop param) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
return param->int_field(index_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Parameter::set_index(oop param, int value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
param->int_field_put(index_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
oop java_lang_reflect_Parameter::executable(oop param) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
return param->obj_field(executable_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_reflect_Parameter::set_executable(oop param, oop value) {
|
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
param->obj_field_put(executable_offset, value);
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2017-04-07 08:04:46 +00:00
|
|
|
int java_lang_Module::loader_offset;
|
|
|
|
int java_lang_Module::name_offset;
|
|
|
|
int java_lang_Module::_module_entry_offset = -1;
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
|
2017-04-07 08:04:46 +00:00
|
|
|
Handle java_lang_Module::create(Handle loader, Handle module_name, TRAPS) {
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
2018-05-18 09:15:08 -07:00
|
|
|
return JavaCalls::construct_new_instance(SystemDictionary::Module_klass(),
|
2017-04-07 08:04:46 +00:00
|
|
|
vmSymbols::java_lang_module_init_signature(),
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
loader, module_name, CHECK_NH);
|
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#define MODULE_FIELDS_DO(macro) \
|
|
|
|
macro(loader_offset, k, vmSymbols::loader_name(), classloader_signature, false); \
|
|
|
|
macro(name_offset, k, vmSymbols::name_name(), string_signature, false)
|
|
|
|
|
2017-04-07 08:04:46 +00:00
|
|
|
void java_lang_Module::compute_offsets() {
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k = SystemDictionary::Module_klass();
|
2018-03-02 17:25:55 -05:00
|
|
|
MODULE_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
2018-01-08 09:46:31 -05:00
|
|
|
MODULE_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_Module::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
MODULE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
MODULE_INJECTED_FIELDS(INJECTED_FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
|
2017-04-07 08:04:46 +00:00
|
|
|
oop java_lang_Module::loader(oop module) {
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
return module->obj_field(loader_offset);
|
|
|
|
}
|
|
|
|
|
2017-04-07 08:04:46 +00:00
|
|
|
void java_lang_Module::set_loader(oop module, oop value) {
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
module->obj_field_put(loader_offset, value);
|
|
|
|
}
|
|
|
|
|
2017-04-07 08:04:46 +00:00
|
|
|
oop java_lang_Module::name(oop module) {
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
return module->obj_field(name_offset);
|
|
|
|
}
|
|
|
|
|
2017-04-07 08:04:46 +00:00
|
|
|
void java_lang_Module::set_name(oop module, oop value) {
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
|
|
|
module->obj_field_put(name_offset, value);
|
|
|
|
}
|
|
|
|
|
2018-03-06 17:15:16 -05:00
|
|
|
ModuleEntry* java_lang_Module::module_entry(oop module) {
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
assert(_module_entry_offset != -1, "Uninitialized module_entry_offset");
|
|
|
|
assert(module != NULL, "module can't be null");
|
2017-08-23 14:52:55 -04:00
|
|
|
assert(oopDesc::is_oop(module), "module must be oop");
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
|
|
|
|
ModuleEntry* module_entry = (ModuleEntry*)module->address_field(_module_entry_offset);
|
|
|
|
if (module_entry == NULL) {
|
|
|
|
// If the inject field containing the ModuleEntry* is null then return the
|
|
|
|
// class loader's unnamed module.
|
2017-04-07 08:04:46 +00:00
|
|
|
oop loader = java_lang_Module::loader(module);
|
2018-03-06 17:15:16 -05:00
|
|
|
Handle h_loader = Handle(Thread::current(), loader);
|
|
|
|
ClassLoaderData* loader_cld = SystemDictionary::register_loader(h_loader);
|
2017-04-18 13:19:42 -04:00
|
|
|
return loader_cld->unnamed_module();
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
}
|
|
|
|
return module_entry;
|
|
|
|
}
|
|
|
|
|
2017-04-07 08:04:46 +00:00
|
|
|
void java_lang_Module::set_module_entry(oop module, ModuleEntry* module_entry) {
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
assert(_module_entry_offset != -1, "Uninitialized module_entry_offset");
|
|
|
|
assert(module != NULL, "module can't be null");
|
2017-08-23 14:52:55 -04:00
|
|
|
assert(oopDesc::is_oop(module), "module must be oop");
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
module->address_field_put(_module_entry_offset, (address)module_entry);
|
|
|
|
}
|
|
|
|
|
2016-04-15 16:19:15 +01:00
|
|
|
Handle reflect_ConstantPool::create(TRAPS) {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
2017-03-15 10:25:37 -04:00
|
|
|
InstanceKlass* k = SystemDictionary::reflect_ConstantPool_klass();
|
2007-12-01 00:00:00 +00:00
|
|
|
// Ensure it is initialized
|
2017-03-15 10:25:37 -04:00
|
|
|
k->initialize(CHECK_NH);
|
|
|
|
return k->allocate_instance_handle(THREAD);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-15 16:19:15 +01:00
|
|
|
void reflect_ConstantPool::set_cp(oop reflect, ConstantPool* value) {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
oop mirror = value->pool_holder()->java_mirror();
|
|
|
|
// Save the mirror to get back the constant pool.
|
|
|
|
reflect->obj_field_put(_oop_offset, mirror);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2016-04-15 16:19:15 +01:00
|
|
|
ConstantPool* reflect_ConstantPool::get_cp(oop reflect) {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
oop mirror = reflect->obj_field(_oop_offset);
|
|
|
|
Klass* k = java_lang_Class::as_Klass(mirror);
|
2015-10-28 09:47:23 -04:00
|
|
|
assert(k->is_instance_klass(), "Must be");
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// Get the constant pool back from the klass. Since class redefinition
|
|
|
|
// merges the new constant pool into the old, this is essentially the
|
|
|
|
// same constant pool as the original. If constant pool merging is
|
|
|
|
// no longer done in the future, this will have to change to save
|
|
|
|
// the original.
|
|
|
|
return InstanceKlass::cast(k)->constants();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#define UNSAFESTATICFIELDACCESSORIMPL_FIELDS_DO(macro) \
|
|
|
|
macro(_base_offset, k, "base", object_signature, false)
|
|
|
|
|
2016-04-15 16:19:15 +01:00
|
|
|
void reflect_UnsafeStaticFieldAccessorImpl::compute_offsets() {
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k = SystemDictionary::reflect_UnsafeStaticFieldAccessorImpl_klass();
|
2018-03-02 17:25:55 -05:00
|
|
|
UNSAFESTATICFIELDACCESSORIMPL_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void reflect_UnsafeStaticFieldAccessorImpl::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
UNSAFESTATICFIELDACCESSORIMPL_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2018-03-02 17:25:55 -05:00
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2008-04-29 19:45:22 -07:00
|
|
|
oop java_lang_boxing_object::initialize_and_allocate(BasicType type, TRAPS) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* k = SystemDictionary::box_klass(type);
|
2008-04-29 19:45:22 -07:00
|
|
|
if (k == NULL) return NULL;
|
2017-03-15 10:25:37 -04:00
|
|
|
InstanceKlass* ik = InstanceKlass::cast(k);
|
|
|
|
if (!ik->is_initialized()) ik->initialize(CHECK_0);
|
|
|
|
return ik->allocate_instance(THREAD);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
oop java_lang_boxing_object::create(BasicType type, jvalue* value, TRAPS) {
|
2008-04-29 19:45:22 -07:00
|
|
|
oop box = initialize_and_allocate(type, CHECK_0);
|
|
|
|
if (box == NULL) return NULL;
|
2007-12-01 00:00:00 +00:00
|
|
|
switch (type) {
|
|
|
|
case T_BOOLEAN:
|
|
|
|
box->bool_field_put(value_offset, value->z);
|
|
|
|
break;
|
|
|
|
case T_CHAR:
|
|
|
|
box->char_field_put(value_offset, value->c);
|
|
|
|
break;
|
|
|
|
case T_FLOAT:
|
|
|
|
box->float_field_put(value_offset, value->f);
|
|
|
|
break;
|
|
|
|
case T_DOUBLE:
|
2008-05-21 16:31:35 -07:00
|
|
|
box->double_field_put(long_value_offset, value->d);
|
2007-12-01 00:00:00 +00:00
|
|
|
break;
|
|
|
|
case T_BYTE:
|
|
|
|
box->byte_field_put(value_offset, value->b);
|
|
|
|
break;
|
|
|
|
case T_SHORT:
|
|
|
|
box->short_field_put(value_offset, value->s);
|
|
|
|
break;
|
|
|
|
case T_INT:
|
|
|
|
box->int_field_put(value_offset, value->i);
|
|
|
|
break;
|
|
|
|
case T_LONG:
|
2008-05-21 16:31:35 -07:00
|
|
|
box->long_field_put(long_value_offset, value->j);
|
2007-12-01 00:00:00 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return box;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-29 19:45:22 -07:00
|
|
|
BasicType java_lang_boxing_object::basic_type(oop box) {
|
|
|
|
if (box == NULL) return T_ILLEGAL;
|
|
|
|
BasicType type = SystemDictionary::box_klass_type(box->klass());
|
|
|
|
if (type == T_OBJECT) // 'unknown' value returned by SD::bkt
|
|
|
|
return T_ILLEGAL;
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
BasicType java_lang_boxing_object::get_value(oop box, jvalue* value) {
|
2008-04-29 19:45:22 -07:00
|
|
|
BasicType type = SystemDictionary::box_klass_type(box->klass());
|
|
|
|
switch (type) {
|
|
|
|
case T_BOOLEAN:
|
2007-12-01 00:00:00 +00:00
|
|
|
value->z = box->bool_field(value_offset);
|
2008-04-29 19:45:22 -07:00
|
|
|
break;
|
|
|
|
case T_CHAR:
|
2007-12-01 00:00:00 +00:00
|
|
|
value->c = box->char_field(value_offset);
|
2008-04-29 19:45:22 -07:00
|
|
|
break;
|
|
|
|
case T_FLOAT:
|
2007-12-01 00:00:00 +00:00
|
|
|
value->f = box->float_field(value_offset);
|
2008-04-29 19:45:22 -07:00
|
|
|
break;
|
|
|
|
case T_DOUBLE:
|
2008-05-21 16:31:35 -07:00
|
|
|
value->d = box->double_field(long_value_offset);
|
2008-04-29 19:45:22 -07:00
|
|
|
break;
|
|
|
|
case T_BYTE:
|
2007-12-01 00:00:00 +00:00
|
|
|
value->b = box->byte_field(value_offset);
|
2008-04-29 19:45:22 -07:00
|
|
|
break;
|
|
|
|
case T_SHORT:
|
2007-12-01 00:00:00 +00:00
|
|
|
value->s = box->short_field(value_offset);
|
2008-04-29 19:45:22 -07:00
|
|
|
break;
|
|
|
|
case T_INT:
|
2007-12-01 00:00:00 +00:00
|
|
|
value->i = box->int_field(value_offset);
|
2008-04-29 19:45:22 -07:00
|
|
|
break;
|
|
|
|
case T_LONG:
|
2008-05-21 16:31:35 -07:00
|
|
|
value->j = box->long_field(long_value_offset);
|
2008-04-29 19:45:22 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return T_ILLEGAL;
|
|
|
|
} // end switch
|
|
|
|
return type;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BasicType java_lang_boxing_object::set_value(oop box, jvalue* value) {
|
2008-04-29 19:45:22 -07:00
|
|
|
BasicType type = SystemDictionary::box_klass_type(box->klass());
|
|
|
|
switch (type) {
|
|
|
|
case T_BOOLEAN:
|
2007-12-01 00:00:00 +00:00
|
|
|
box->bool_field_put(value_offset, value->z);
|
2008-04-29 19:45:22 -07:00
|
|
|
break;
|
|
|
|
case T_CHAR:
|
2007-12-01 00:00:00 +00:00
|
|
|
box->char_field_put(value_offset, value->c);
|
2008-04-29 19:45:22 -07:00
|
|
|
break;
|
|
|
|
case T_FLOAT:
|
2007-12-01 00:00:00 +00:00
|
|
|
box->float_field_put(value_offset, value->f);
|
2008-04-29 19:45:22 -07:00
|
|
|
break;
|
|
|
|
case T_DOUBLE:
|
2008-05-21 16:31:35 -07:00
|
|
|
box->double_field_put(long_value_offset, value->d);
|
2008-04-29 19:45:22 -07:00
|
|
|
break;
|
|
|
|
case T_BYTE:
|
2007-12-01 00:00:00 +00:00
|
|
|
box->byte_field_put(value_offset, value->b);
|
2008-04-29 19:45:22 -07:00
|
|
|
break;
|
|
|
|
case T_SHORT:
|
2007-12-01 00:00:00 +00:00
|
|
|
box->short_field_put(value_offset, value->s);
|
2008-04-29 19:45:22 -07:00
|
|
|
break;
|
|
|
|
case T_INT:
|
2007-12-01 00:00:00 +00:00
|
|
|
box->int_field_put(value_offset, value->i);
|
2008-04-29 19:45:22 -07:00
|
|
|
break;
|
|
|
|
case T_LONG:
|
2008-05-21 16:31:35 -07:00
|
|
|
box->long_field_put(long_value_offset, value->j);
|
2008-04-29 19:45:22 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return T_ILLEGAL;
|
|
|
|
} // end switch
|
|
|
|
return type;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-20 23:19:36 -07:00
|
|
|
void java_lang_boxing_object::print(BasicType type, jvalue* value, outputStream* st) {
|
|
|
|
switch (type) {
|
|
|
|
case T_BOOLEAN: st->print("%s", value->z ? "true" : "false"); break;
|
|
|
|
case T_CHAR: st->print("%d", value->c); break;
|
|
|
|
case T_BYTE: st->print("%d", value->b); break;
|
|
|
|
case T_SHORT: st->print("%d", value->s); break;
|
|
|
|
case T_INT: st->print("%d", value->i); break;
|
2017-07-06 01:50:26 +02:00
|
|
|
case T_LONG: st->print(JLONG_FORMAT, value->j); break;
|
2009-03-20 23:19:36 -07:00
|
|
|
case T_FLOAT: st->print("%f", value->f); break;
|
|
|
|
case T_DOUBLE: st->print("%lf", value->d); break;
|
|
|
|
default: st->print("type %d?", type); break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-20 13:07:44 +01:00
|
|
|
// Support for java_lang_ref_Reference
|
|
|
|
|
|
|
|
bool java_lang_ref_Reference::is_referent_field(oop obj, ptrdiff_t offset) {
|
2018-03-15 21:24:10 +01:00
|
|
|
assert(obj != NULL, "sanity");
|
2017-11-20 13:07:44 +01:00
|
|
|
if (offset != java_lang_ref_Reference::referent_offset) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Klass* k = obj->klass();
|
|
|
|
if (!k->is_instance_klass()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
InstanceKlass* ik = InstanceKlass::cast(obj->klass());
|
|
|
|
bool is_reference = ik->reference_type() != REF_NONE;
|
|
|
|
assert(!is_reference || ik->is_subclass_of(SystemDictionary::Reference_klass()), "sanity");
|
|
|
|
return is_reference;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Support for java_lang_ref_SoftReference
|
2018-01-08 09:46:31 -05:00
|
|
|
//
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#define SOFTREFERENCE_FIELDS_DO(macro) \
|
|
|
|
macro(timestamp_offset, k, "timestamp", long_signature, false); \
|
|
|
|
macro(static_clock_offset, k, "clock", long_signature, true)
|
|
|
|
|
2018-01-08 09:46:31 -05:00
|
|
|
void java_lang_ref_SoftReference::compute_offsets() {
|
|
|
|
InstanceKlass* k = SystemDictionary::SoftReference_klass();
|
2018-03-02 17:25:55 -05:00
|
|
|
SOFTREFERENCE_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_ref_SoftReference::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
SOFTREFERENCE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
2018-01-08 09:46:31 -05:00
|
|
|
}
|
2018-03-02 17:25:55 -05:00
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
jlong java_lang_ref_SoftReference::timestamp(oop ref) {
|
|
|
|
return ref->long_field(timestamp_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
jlong java_lang_ref_SoftReference::clock() {
|
2015-10-26 13:11:36 -04:00
|
|
|
InstanceKlass* ik = SystemDictionary::SoftReference_klass();
|
2018-03-21 16:00:41 +01:00
|
|
|
oop base = ik->static_field_base_raw();
|
|
|
|
return base->long_field(static_clock_offset);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_ref_SoftReference::set_clock(jlong value) {
|
2015-10-26 13:11:36 -04:00
|
|
|
InstanceKlass* ik = SystemDictionary::SoftReference_klass();
|
2018-03-21 16:00:41 +01:00
|
|
|
oop base = ik->static_field_base_raw();
|
|
|
|
base->long_field_put(static_clock_offset, value);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2013-08-06 16:33:59 -07:00
|
|
|
// Support for java_lang_invoke_DirectMethodHandle
|
|
|
|
|
|
|
|
int java_lang_invoke_DirectMethodHandle::_member_offset;
|
|
|
|
|
|
|
|
oop java_lang_invoke_DirectMethodHandle::member(oop dmh) {
|
|
|
|
oop member_name = NULL;
|
2017-08-23 14:52:55 -04:00
|
|
|
assert(oopDesc::is_oop(dmh) && java_lang_invoke_DirectMethodHandle::is_instance(dmh),
|
|
|
|
"a DirectMethodHandle oop is expected");
|
|
|
|
return dmh->obj_field(member_offset_in_bytes());
|
2013-08-06 16:33:59 -07:00
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#define DIRECTMETHODHANDLE_FIELDS_DO(macro) \
|
|
|
|
macro(_member_offset, k, "member", java_lang_invoke_MemberName_signature, false)
|
|
|
|
|
2013-08-06 16:33:59 -07:00
|
|
|
void java_lang_invoke_DirectMethodHandle::compute_offsets() {
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k = SystemDictionary::DirectMethodHandle_klass();
|
2018-03-02 17:25:55 -05:00
|
|
|
DIRECTMETHODHANDLE_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
2013-08-06 16:33:59 -07:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_invoke_DirectMethodHandle::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
DIRECTMETHODHANDLE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
// Support for java_lang_invoke_MethodHandle
|
2009-04-08 10:56:49 -07:00
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
int java_lang_invoke_MethodHandle::_type_offset;
|
2012-07-24 10:51:00 -07:00
|
|
|
int java_lang_invoke_MethodHandle::_form_offset;
|
2009-04-08 10:56:49 -07:00
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
int java_lang_invoke_MemberName::_clazz_offset;
|
|
|
|
int java_lang_invoke_MemberName::_name_offset;
|
|
|
|
int java_lang_invoke_MemberName::_type_offset;
|
|
|
|
int java_lang_invoke_MemberName::_flags_offset;
|
2017-05-27 09:21:01 -04:00
|
|
|
int java_lang_invoke_MemberName::_method_offset;
|
2011-03-11 22:34:57 -08:00
|
|
|
int java_lang_invoke_MemberName::_vmindex_offset;
|
2009-04-08 10:56:49 -07:00
|
|
|
|
2017-05-27 09:21:01 -04:00
|
|
|
int java_lang_invoke_ResolvedMethodName::_vmtarget_offset;
|
|
|
|
int java_lang_invoke_ResolvedMethodName::_vmholder_offset;
|
|
|
|
|
2012-07-24 10:51:00 -07:00
|
|
|
int java_lang_invoke_LambdaForm::_vmentry_offset;
|
2011-09-02 20:58:21 -07:00
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#define METHODHANDLE_FIELDS_DO(macro) \
|
|
|
|
macro(_type_offset, k, vmSymbols::type_name(), java_lang_invoke_MethodType_signature, false); \
|
|
|
|
macro(_form_offset, k, "form", java_lang_invoke_LambdaForm_signature, false)
|
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
void java_lang_invoke_MethodHandle::compute_offsets() {
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k = SystemDictionary::MethodHandle_klass();
|
2018-03-02 17:25:55 -05:00
|
|
|
METHODHANDLE_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_invoke_MethodHandle::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
METHODHANDLE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
2009-04-08 10:56:49 -07:00
|
|
|
}
|
2018-03-02 17:25:55 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define MEMBERNAME_FIELDS_DO(macro) \
|
|
|
|
macro(_clazz_offset, k, vmSymbols::clazz_name(), class_signature, false); \
|
|
|
|
macro(_name_offset, k, vmSymbols::name_name(), string_signature, false); \
|
|
|
|
macro(_type_offset, k, vmSymbols::type_name(), object_signature, false); \
|
|
|
|
macro(_flags_offset, k, vmSymbols::flags_name(), int_signature, false); \
|
|
|
|
macro(_method_offset, k, vmSymbols::method_name(), java_lang_invoke_ResolvedMethodName_signature, false)
|
2009-04-08 10:56:49 -07:00
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
void java_lang_invoke_MemberName::compute_offsets() {
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k = SystemDictionary::MemberName_klass();
|
2018-03-02 17:25:55 -05:00
|
|
|
MEMBERNAME_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
2017-05-27 09:21:01 -04:00
|
|
|
MEMBERNAME_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
|
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_invoke_MemberName::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
MEMBERNAME_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
MEMBERNAME_INJECTED_FIELDS(INJECTED_FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-05-27 09:21:01 -04:00
|
|
|
void java_lang_invoke_ResolvedMethodName::compute_offsets() {
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k = SystemDictionary::ResolvedMethodName_klass();
|
2017-05-27 09:21:01 -04:00
|
|
|
assert(k != NULL, "jdk mismatch");
|
|
|
|
RESOLVEDMETHOD_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
|
2009-04-08 10:56:49 -07:00
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_invoke_ResolvedMethodName::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
RESOLVEDMETHOD_INJECTED_FIELDS(INJECTED_FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define LAMBDAFORM_FIELDS_DO(macro) \
|
|
|
|
macro(_vmentry_offset, k, "vmentry", java_lang_invoke_MemberName_signature, false)
|
|
|
|
|
2012-07-24 10:51:00 -07:00
|
|
|
void java_lang_invoke_LambdaForm::compute_offsets() {
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k = SystemDictionary::LambdaForm_klass();
|
2017-05-27 09:21:01 -04:00
|
|
|
assert (k != NULL, "jdk mismatch");
|
2018-03-02 17:25:55 -05:00
|
|
|
LAMBDAFORM_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
2011-09-02 20:58:21 -07:00
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_invoke_LambdaForm::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
LAMBDAFORM_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-02-13 14:37:35 +01:00
|
|
|
bool java_lang_invoke_LambdaForm::is_instance(oop obj) {
|
|
|
|
return obj != NULL && is_subclass(obj->klass());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
oop java_lang_invoke_MethodHandle::type(oop mh) {
|
2009-04-08 10:56:49 -07:00
|
|
|
return mh->obj_field(_type_offset);
|
|
|
|
}
|
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
void java_lang_invoke_MethodHandle::set_type(oop mh, oop mtype) {
|
2009-04-08 10:56:49 -07:00
|
|
|
mh->obj_field_put(_type_offset, mtype);
|
|
|
|
}
|
|
|
|
|
2012-07-24 10:51:00 -07:00
|
|
|
oop java_lang_invoke_MethodHandle::form(oop mh) {
|
|
|
|
assert(_form_offset != 0, "");
|
|
|
|
return mh->obj_field(_form_offset);
|
2009-04-08 10:56:49 -07:00
|
|
|
}
|
|
|
|
|
2012-07-24 10:51:00 -07:00
|
|
|
void java_lang_invoke_MethodHandle::set_form(oop mh, oop lform) {
|
|
|
|
assert(_form_offset != 0, "");
|
|
|
|
mh->obj_field_put(_form_offset, lform);
|
2009-04-08 10:56:49 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/// MemberName accessors
|
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
oop java_lang_invoke_MemberName::clazz(oop mname) {
|
2009-04-08 10:56:49 -07:00
|
|
|
assert(is_instance(mname), "wrong type");
|
|
|
|
return mname->obj_field(_clazz_offset);
|
|
|
|
}
|
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
void java_lang_invoke_MemberName::set_clazz(oop mname, oop clazz) {
|
2009-04-08 10:56:49 -07:00
|
|
|
assert(is_instance(mname), "wrong type");
|
|
|
|
mname->obj_field_put(_clazz_offset, clazz);
|
|
|
|
}
|
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
oop java_lang_invoke_MemberName::name(oop mname) {
|
2009-04-08 10:56:49 -07:00
|
|
|
assert(is_instance(mname), "wrong type");
|
|
|
|
return mname->obj_field(_name_offset);
|
|
|
|
}
|
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
void java_lang_invoke_MemberName::set_name(oop mname, oop name) {
|
2009-04-08 10:56:49 -07:00
|
|
|
assert(is_instance(mname), "wrong type");
|
|
|
|
mname->obj_field_put(_name_offset, name);
|
|
|
|
}
|
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
oop java_lang_invoke_MemberName::type(oop mname) {
|
2009-04-08 10:56:49 -07:00
|
|
|
assert(is_instance(mname), "wrong type");
|
|
|
|
return mname->obj_field(_type_offset);
|
|
|
|
}
|
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
void java_lang_invoke_MemberName::set_type(oop mname, oop type) {
|
2009-04-08 10:56:49 -07:00
|
|
|
assert(is_instance(mname), "wrong type");
|
|
|
|
mname->obj_field_put(_type_offset, type);
|
|
|
|
}
|
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
int java_lang_invoke_MemberName::flags(oop mname) {
|
2009-04-08 10:56:49 -07:00
|
|
|
assert(is_instance(mname), "wrong type");
|
|
|
|
return mname->int_field(_flags_offset);
|
|
|
|
}
|
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
void java_lang_invoke_MemberName::set_flags(oop mname, int flags) {
|
2009-04-08 10:56:49 -07:00
|
|
|
assert(is_instance(mname), "wrong type");
|
|
|
|
mname->int_field_put(_flags_offset, flags);
|
|
|
|
}
|
|
|
|
|
2017-05-27 09:21:01 -04:00
|
|
|
|
|
|
|
// Return vmtarget from ResolvedMethodName method field through indirection
|
|
|
|
Method* java_lang_invoke_MemberName::vmtarget(oop mname) {
|
2009-04-08 10:56:49 -07:00
|
|
|
assert(is_instance(mname), "wrong type");
|
2017-05-27 09:21:01 -04:00
|
|
|
oop method = mname->obj_field(_method_offset);
|
|
|
|
return method == NULL ? NULL : java_lang_invoke_ResolvedMethodName::vmtarget(method);
|
2009-04-08 10:56:49 -07:00
|
|
|
}
|
|
|
|
|
2014-11-19 13:02:11 -05:00
|
|
|
bool java_lang_invoke_MemberName::is_method(oop mname) {
|
|
|
|
assert(is_instance(mname), "must be MemberName");
|
|
|
|
return (flags(mname) & (MN_IS_METHOD | MN_IS_CONSTRUCTOR)) > 0;
|
|
|
|
}
|
|
|
|
|
2017-05-27 09:21:01 -04:00
|
|
|
void java_lang_invoke_MemberName::set_method(oop mname, oop resolved_method) {
|
2009-04-08 10:56:49 -07:00
|
|
|
assert(is_instance(mname), "wrong type");
|
2017-05-27 09:21:01 -04:00
|
|
|
mname->obj_field_put(_method_offset, resolved_method);
|
2009-04-08 10:56:49 -07:00
|
|
|
}
|
|
|
|
|
2012-07-24 10:51:00 -07:00
|
|
|
intptr_t java_lang_invoke_MemberName::vmindex(oop mname) {
|
2009-04-08 10:56:49 -07:00
|
|
|
assert(is_instance(mname), "wrong type");
|
2012-07-24 10:51:00 -07:00
|
|
|
return (intptr_t) mname->address_field(_vmindex_offset);
|
2009-04-08 10:56:49 -07:00
|
|
|
}
|
|
|
|
|
2012-07-24 10:51:00 -07:00
|
|
|
void java_lang_invoke_MemberName::set_vmindex(oop mname, intptr_t index) {
|
2009-04-08 10:56:49 -07:00
|
|
|
assert(is_instance(mname), "wrong type");
|
2012-07-24 10:51:00 -07:00
|
|
|
mname->address_field_put(_vmindex_offset, (address) index);
|
2009-04-08 10:56:49 -07:00
|
|
|
}
|
|
|
|
|
2017-05-27 09:21:01 -04:00
|
|
|
|
|
|
|
Method* java_lang_invoke_ResolvedMethodName::vmtarget(oop resolved_method) {
|
|
|
|
assert(is_instance(resolved_method), "wrong type");
|
|
|
|
Method* m = (Method*)resolved_method->address_field(_vmtarget_offset);
|
|
|
|
assert(m->is_method(), "must be");
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Used by redefinition to change Method* to new Method* with same hash (name, signature)
|
|
|
|
void java_lang_invoke_ResolvedMethodName::set_vmtarget(oop resolved_method, Method* m) {
|
|
|
|
assert(is_instance(resolved_method), "wrong type");
|
|
|
|
resolved_method->address_field_put(_vmtarget_offset, (address)m);
|
|
|
|
}
|
|
|
|
|
2019-04-10 15:41:04 +02:00
|
|
|
void java_lang_invoke_ResolvedMethodName::set_vmholder(oop resolved_method, oop holder) {
|
|
|
|
assert(is_instance(resolved_method), "wrong type");
|
|
|
|
resolved_method->obj_field_put(_vmholder_offset, holder);
|
|
|
|
}
|
|
|
|
|
2017-05-27 09:21:01 -04:00
|
|
|
oop java_lang_invoke_ResolvedMethodName::find_resolved_method(const methodHandle& m, TRAPS) {
|
2019-04-10 15:41:04 +02:00
|
|
|
const Method* method = m();
|
|
|
|
|
2017-05-27 09:21:01 -04:00
|
|
|
// lookup ResolvedMethod oop in the table, or create a new one and intern it
|
2019-04-10 15:41:04 +02:00
|
|
|
oop resolved_method = ResolvedMethodTable::find_method(method);
|
|
|
|
if (resolved_method != NULL) {
|
|
|
|
return resolved_method;
|
|
|
|
}
|
|
|
|
|
|
|
|
InstanceKlass* k = SystemDictionary::ResolvedMethodName_klass();
|
|
|
|
if (!k->is_initialized()) {
|
|
|
|
k->initialize(CHECK_NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
oop new_resolved_method = k->allocate_instance(CHECK_NULL);
|
|
|
|
|
|
|
|
NoSafepointVerifier nsv;
|
|
|
|
|
|
|
|
if (method->is_old()) {
|
|
|
|
method = (method->is_deleted()) ? Universe::throw_no_such_method_error() :
|
|
|
|
method->get_new_method();
|
|
|
|
}
|
|
|
|
|
|
|
|
InstanceKlass* holder = method->method_holder();
|
|
|
|
|
|
|
|
set_vmtarget(new_resolved_method, const_cast<Method*>(method));
|
|
|
|
// Add a reference to the loader (actually mirror because unsafe anonymous classes will not have
|
|
|
|
// distinct loaders) to ensure the metadata is kept alive.
|
|
|
|
// This mirror may be different than the one in clazz field.
|
|
|
|
set_vmholder(new_resolved_method, holder->java_mirror());
|
|
|
|
|
|
|
|
// Set flag in class to indicate this InstanceKlass has entries in the table
|
|
|
|
// to avoid walking table during redefinition if none of the redefined classes
|
|
|
|
// have any membernames in the table.
|
|
|
|
holder->set_has_resolved_methods();
|
|
|
|
|
|
|
|
return ResolvedMethodTable::add_method(method, Handle(THREAD, new_resolved_method));
|
2017-02-21 02:27:01 -08:00
|
|
|
}
|
|
|
|
|
2012-07-24 10:51:00 -07:00
|
|
|
oop java_lang_invoke_LambdaForm::vmentry(oop lform) {
|
|
|
|
assert(is_instance(lform), "wrong type");
|
|
|
|
return lform->obj_field(_vmentry_offset);
|
2009-04-08 10:56:49 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
// Support for java_lang_invoke_MethodType
|
2009-04-08 10:56:49 -07:00
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
int java_lang_invoke_MethodType::_rtype_offset;
|
|
|
|
int java_lang_invoke_MethodType::_ptypes_offset;
|
2009-04-08 10:56:49 -07:00
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#define METHODTYPE_FIELDS_DO(macro) \
|
|
|
|
macro(_rtype_offset, k, "rtype", class_signature, false); \
|
|
|
|
macro(_ptypes_offset, k, "ptypes", class_array_signature, false)
|
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
void java_lang_invoke_MethodType::compute_offsets() {
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k = SystemDictionary::MethodType_klass();
|
2018-03-02 17:25:55 -05:00
|
|
|
METHODTYPE_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
2009-04-08 10:56:49 -07:00
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_invoke_MethodType::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
METHODTYPE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
void java_lang_invoke_MethodType::print_signature(oop mt, outputStream* st) {
|
2009-04-08 10:56:49 -07:00
|
|
|
st->print("(");
|
|
|
|
objArrayOop pts = ptypes(mt);
|
|
|
|
for (int i = 0, limit = pts->length(); i < limit; i++) {
|
|
|
|
java_lang_Class::print_signature(pts->obj_at(i), st);
|
|
|
|
}
|
|
|
|
st->print(")");
|
|
|
|
java_lang_Class::print_signature(rtype(mt), st);
|
|
|
|
}
|
|
|
|
|
2019-05-14 11:29:18 -04:00
|
|
|
Symbol* java_lang_invoke_MethodType::as_signature(oop mt, bool intern_if_not_found) {
|
2009-04-08 10:56:49 -07:00
|
|
|
ResourceMark rm;
|
|
|
|
stringStream buffer(128);
|
|
|
|
print_signature(mt, &buffer);
|
|
|
|
const char* sigstr = buffer.base();
|
|
|
|
int siglen = (int) buffer.size();
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol *name;
|
|
|
|
if (!intern_if_not_found) {
|
|
|
|
name = SymbolTable::probe(sigstr, siglen);
|
|
|
|
} else {
|
2019-05-14 11:29:18 -04:00
|
|
|
name = SymbolTable::new_symbol(sigstr, siglen);
|
2011-01-27 16:11:27 -08:00
|
|
|
}
|
|
|
|
return name;
|
2009-04-08 10:56:49 -07:00
|
|
|
}
|
|
|
|
|
2011-06-23 17:14:06 -07:00
|
|
|
bool java_lang_invoke_MethodType::equals(oop mt1, oop mt2) {
|
2019-09-17 09:51:02 +02:00
|
|
|
if (mt1 == mt2)
|
2012-07-24 10:51:00 -07:00
|
|
|
return true;
|
2019-09-17 09:51:02 +02:00
|
|
|
if (rtype(mt1) != rtype(mt2))
|
2011-06-23 17:14:06 -07:00
|
|
|
return false;
|
|
|
|
if (ptype_count(mt1) != ptype_count(mt2))
|
|
|
|
return false;
|
|
|
|
for (int i = ptype_count(mt1) - 1; i >= 0; i--) {
|
2019-09-17 09:51:02 +02:00
|
|
|
if (ptype(mt1, i) != ptype(mt2, i))
|
2011-06-23 17:14:06 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
oop java_lang_invoke_MethodType::rtype(oop mt) {
|
2009-04-08 10:56:49 -07:00
|
|
|
assert(is_instance(mt), "must be a MethodType");
|
|
|
|
return mt->obj_field(_rtype_offset);
|
|
|
|
}
|
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
objArrayOop java_lang_invoke_MethodType::ptypes(oop mt) {
|
2009-04-08 10:56:49 -07:00
|
|
|
assert(is_instance(mt), "must be a MethodType");
|
|
|
|
return (objArrayOop) mt->obj_field(_ptypes_offset);
|
|
|
|
}
|
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
oop java_lang_invoke_MethodType::ptype(oop mt, int idx) {
|
2009-04-08 10:56:49 -07:00
|
|
|
return ptypes(mt)->obj_at(idx);
|
|
|
|
}
|
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
int java_lang_invoke_MethodType::ptype_count(oop mt) {
|
2010-01-04 15:52:40 +01:00
|
|
|
return ptypes(mt)->length();
|
|
|
|
}
|
|
|
|
|
2012-07-24 10:51:00 -07:00
|
|
|
int java_lang_invoke_MethodType::ptype_slot_count(oop mt) {
|
|
|
|
objArrayOop pts = ptypes(mt);
|
|
|
|
int count = pts->length();
|
|
|
|
int slots = 0;
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
BasicType bt = java_lang_Class::as_BasicType(pts->obj_at(i));
|
|
|
|
slots += type2size[bt];
|
2011-05-06 16:33:13 -07:00
|
|
|
}
|
2012-07-24 10:51:00 -07:00
|
|
|
return slots;
|
2011-05-06 16:33:13 -07:00
|
|
|
}
|
|
|
|
|
2012-07-24 10:51:00 -07:00
|
|
|
int java_lang_invoke_MethodType::rtype_slot_count(oop mt) {
|
|
|
|
BasicType bt = java_lang_Class::as_BasicType(rtype(mt));
|
|
|
|
return type2size[bt];
|
2010-09-13 23:24:30 -07:00
|
|
|
}
|
|
|
|
|
2009-04-08 10:56:49 -07:00
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
// Support for java_lang_invoke_CallSite
|
2009-04-21 23:21:04 -07:00
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
int java_lang_invoke_CallSite::_target_offset;
|
2015-04-17 18:17:06 +03:00
|
|
|
int java_lang_invoke_CallSite::_context_offset;
|
2009-04-21 23:21:04 -07:00
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#define CALLSITE_FIELDS_DO(macro) \
|
|
|
|
macro(_target_offset, k, "target", java_lang_invoke_MethodHandle_signature, false); \
|
|
|
|
macro(_context_offset, k, "context", java_lang_invoke_MethodHandleNatives_CallSiteContext_signature, false)
|
|
|
|
|
2011-03-11 22:34:57 -08:00
|
|
|
void java_lang_invoke_CallSite::compute_offsets() {
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k = SystemDictionary::CallSite_klass();
|
2018-03-02 17:25:55 -05:00
|
|
|
CALLSITE_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
2009-04-21 23:21:04 -07:00
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_invoke_CallSite::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
CALLSITE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-11-05 12:36:23 +01:00
|
|
|
oop java_lang_invoke_CallSite::context_no_keepalive(oop call_site) {
|
2015-04-17 18:17:06 +03:00
|
|
|
assert(java_lang_invoke_CallSite::is_instance(call_site), "");
|
|
|
|
|
2018-11-05 12:36:23 +01:00
|
|
|
oop dep_oop = call_site->obj_field_access<AS_NO_KEEPALIVE>(_context_offset);
|
2015-04-17 18:17:06 +03:00
|
|
|
return dep_oop;
|
|
|
|
}
|
|
|
|
|
2015-05-15 19:23:11 +03:00
|
|
|
// Support for java_lang_invoke_MethodHandleNatives_CallSiteContext
|
2015-04-17 18:17:06 +03:00
|
|
|
|
2015-05-15 19:23:11 +03:00
|
|
|
int java_lang_invoke_MethodHandleNatives_CallSiteContext::_vmdependencies_offset;
|
2018-11-30 11:40:48 +01:00
|
|
|
int java_lang_invoke_MethodHandleNatives_CallSiteContext::_last_cleanup_offset;
|
2015-05-15 19:23:11 +03:00
|
|
|
|
|
|
|
void java_lang_invoke_MethodHandleNatives_CallSiteContext::compute_offsets() {
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k = SystemDictionary::Context_klass();
|
|
|
|
CALLSITECONTEXT_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
|
2015-04-17 18:17:06 +03:00
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_invoke_MethodHandleNatives_CallSiteContext::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
CALLSITECONTEXT_INJECTED_FIELDS(INJECTED_FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-11-18 03:03:43 +03:00
|
|
|
DependencyContext java_lang_invoke_MethodHandleNatives_CallSiteContext::vmdependencies(oop call_site) {
|
2015-05-15 19:23:11 +03:00
|
|
|
assert(java_lang_invoke_MethodHandleNatives_CallSiteContext::is_instance(call_site), "");
|
2018-11-30 11:40:48 +01:00
|
|
|
nmethodBucket* volatile* vmdeps_addr = (nmethodBucket* volatile*)call_site->field_addr(_vmdependencies_offset);
|
|
|
|
volatile uint64_t* last_cleanup_addr = (volatile uint64_t*)call_site->field_addr(_last_cleanup_offset);
|
|
|
|
DependencyContext dep_ctx(vmdeps_addr, last_cleanup_addr);
|
2015-11-18 03:03:43 +03:00
|
|
|
return dep_ctx;
|
2015-04-17 18:17:06 +03:00
|
|
|
}
|
2009-04-08 10:56:49 -07:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Support for java_security_AccessControlContext
|
|
|
|
|
|
|
|
int java_security_AccessControlContext::_context_offset = 0;
|
|
|
|
int java_security_AccessControlContext::_privilegedContext_offset = 0;
|
|
|
|
int java_security_AccessControlContext::_isPrivileged_offset = 0;
|
2013-04-05 10:18:36 -04:00
|
|
|
int java_security_AccessControlContext::_isAuthorized_offset = -1;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#define ACCESSCONTROLCONTEXT_FIELDS_DO(macro) \
|
|
|
|
macro(_context_offset, k, "context", protectiondomain_signature, false); \
|
|
|
|
macro(_privilegedContext_offset, k, "privilegedContext", accesscontrolcontext_signature, false); \
|
|
|
|
macro(_isPrivileged_offset, k, "isPrivileged", bool_signature, false); \
|
|
|
|
macro(_isAuthorized_offset, k, "isAuthorized", bool_signature, false)
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
void java_security_AccessControlContext::compute_offsets() {
|
|
|
|
assert(_isPrivileged_offset == 0, "offsets should be initialized only once");
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k = SystemDictionary::AccessControlContext_klass();
|
2018-03-02 17:25:55 -05:00
|
|
|
ACCESSCONTROLCONTEXT_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_security_AccessControlContext::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
ACCESSCONTROLCONTEXT_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
oop java_security_AccessControlContext::create(objArrayHandle context, bool isPrivileged, Handle privileged_context, TRAPS) {
|
|
|
|
assert(_isPrivileged_offset != 0, "offsets should have been initialized");
|
|
|
|
// Ensure klass is initialized
|
2015-10-26 13:11:36 -04:00
|
|
|
SystemDictionary::AccessControlContext_klass()->initialize(CHECK_0);
|
2007-12-01 00:00:00 +00:00
|
|
|
// Allocate result
|
2015-10-26 13:11:36 -04:00
|
|
|
oop result = SystemDictionary::AccessControlContext_klass()->allocate_instance(CHECK_0);
|
2007-12-01 00:00:00 +00:00
|
|
|
// Fill in values
|
|
|
|
result->obj_field_put(_context_offset, context());
|
|
|
|
result->obj_field_put(_privilegedContext_offset, privileged_context());
|
|
|
|
result->bool_field_put(_isPrivileged_offset, isPrivileged);
|
2013-04-22 08:33:12 -04:00
|
|
|
// whitelist AccessControlContexts created by the JVM if present
|
|
|
|
if (_isAuthorized_offset != -1) {
|
|
|
|
result->bool_field_put(_isAuthorized_offset, true);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Support for java_lang_ClassLoader
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
2011-09-10 17:29:02 -07:00
|
|
|
bool java_lang_ClassLoader::offsets_computed = false;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
int java_lang_ClassLoader::_loader_data_offset = -1;
|
2011-09-10 17:29:02 -07:00
|
|
|
int java_lang_ClassLoader::parallelCapable_offset = -1;
|
2016-11-03 18:08:02 -07:00
|
|
|
int java_lang_ClassLoader::name_offset = -1;
|
2018-06-19 07:54:11 -04:00
|
|
|
int java_lang_ClassLoader::nameAndId_offset = -1;
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
int java_lang_ClassLoader::unnamedModule_offset = -1;
|
2011-09-10 17:29:02 -07:00
|
|
|
|
2018-09-11 09:42:27 -04:00
|
|
|
ClassLoaderData* java_lang_ClassLoader::loader_data_acquire(oop loader) {
|
2018-02-22 10:39:42 +01:00
|
|
|
assert(loader != NULL && oopDesc::is_oop(loader), "loader must be oop");
|
2018-09-11 09:42:27 -04:00
|
|
|
return HeapAccess<MO_ACQUIRE>::load_at(loader, _loader_data_offset);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2018-07-06 16:04:19 +02:00
|
|
|
ClassLoaderData* java_lang_ClassLoader::loader_data_raw(oop loader) {
|
|
|
|
assert(loader != NULL && oopDesc::is_oop(loader), "loader must be oop");
|
|
|
|
return RawAccess<>::load_at(loader, _loader_data_offset);
|
|
|
|
}
|
|
|
|
|
2018-09-11 09:42:27 -04:00
|
|
|
void java_lang_ClassLoader::release_set_loader_data(oop loader, ClassLoaderData* new_data) {
|
2018-02-22 10:39:42 +01:00
|
|
|
assert(loader != NULL && oopDesc::is_oop(loader), "loader must be oop");
|
2018-09-11 09:42:27 -04:00
|
|
|
HeapAccess<MO_RELEASE>::store_at(loader, _loader_data_offset, new_data);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#define CLASSLOADER_FIELDS_DO(macro) \
|
|
|
|
macro(parallelCapable_offset, k1, "parallelLockMap", concurrenthashmap_signature, false); \
|
|
|
|
macro(name_offset, k1, vmSymbols::name_name(), string_signature, false); \
|
2018-06-19 07:54:11 -04:00
|
|
|
macro(nameAndId_offset, k1, "nameAndId", string_signature, false); \
|
2018-03-02 17:25:55 -05:00
|
|
|
macro(unnamedModule_offset, k1, "unnamedModule", module_signature, false); \
|
|
|
|
macro(parent_offset, k1, "parent", classloader_signature, false)
|
|
|
|
|
2011-09-10 17:29:02 -07:00
|
|
|
void java_lang_ClassLoader::compute_offsets() {
|
|
|
|
assert(!offsets_computed, "offsets should be initialized only once");
|
|
|
|
offsets_computed = true;
|
|
|
|
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k1 = SystemDictionary::ClassLoader_klass();
|
2018-03-02 17:25:55 -05:00
|
|
|
CLASSLOADER_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
CLASSLOADER_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
|
2011-09-10 17:29:02 -07:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_ClassLoader::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
CLASSLOADER_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
CLASSLOADER_INJECTED_FIELDS(INJECTED_FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
oop java_lang_ClassLoader::parent(oop loader) {
|
2012-07-24 10:51:00 -07:00
|
|
|
assert(is_instance(loader), "loader must be oop");
|
2007-12-01 00:00:00 +00:00
|
|
|
return loader->obj_field(parent_offset);
|
|
|
|
}
|
|
|
|
|
2018-06-19 07:54:11 -04:00
|
|
|
// Returns the name field of this class loader. If the name field has not
|
|
|
|
// been set, null will be returned.
|
2016-11-03 18:08:02 -07:00
|
|
|
oop java_lang_ClassLoader::name(oop loader) {
|
|
|
|
assert(is_instance(loader), "loader must be oop");
|
|
|
|
return loader->obj_field(name_offset);
|
|
|
|
}
|
|
|
|
|
2018-06-19 07:54:11 -04:00
|
|
|
// Returns the nameAndId field of this class loader. The format is
|
|
|
|
// as follows:
|
|
|
|
// If the defining loader has a name explicitly set then '<loader-name>' @<id>
|
|
|
|
// If the defining loader has no name then <qualified-class-name> @<id>
|
|
|
|
// If built-in loader, then omit '@<id>' as there is only one instance.
|
|
|
|
// Use ClassLoader::loader_name_id() to obtain this String as a char*.
|
|
|
|
oop java_lang_ClassLoader::nameAndId(oop loader) {
|
|
|
|
assert(is_instance(loader), "loader must be oop");
|
|
|
|
return loader->obj_field(nameAndId_offset);
|
|
|
|
}
|
|
|
|
|
2012-07-24 10:51:00 -07:00
|
|
|
bool java_lang_ClassLoader::isAncestor(oop loader, oop cl) {
|
|
|
|
assert(is_instance(loader), "loader must be oop");
|
|
|
|
assert(cl == NULL || is_instance(cl), "cl argument must be oop");
|
|
|
|
oop acl = loader;
|
|
|
|
debug_only(jint loop_count = 0);
|
|
|
|
// This loop taken verbatim from ClassLoader.java:
|
|
|
|
do {
|
|
|
|
acl = parent(acl);
|
2019-09-17 09:51:02 +02:00
|
|
|
if (cl == acl) {
|
2012-07-24 10:51:00 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
assert(++loop_count > 0, "loop_count overflow");
|
|
|
|
} while (acl != NULL);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-02-13 14:37:35 +01:00
|
|
|
bool java_lang_ClassLoader::is_instance(oop obj) {
|
|
|
|
return obj != NULL && is_subclass(obj->klass());
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2011-09-10 17:29:02 -07:00
|
|
|
// For class loader classes, parallelCapable defined
|
|
|
|
// based on non-null field
|
|
|
|
// Written to by java.lang.ClassLoader, vm only reads this field, doesn't set it
|
|
|
|
bool java_lang_ClassLoader::parallelCapable(oop class_loader) {
|
2014-06-11 09:58:23 -04:00
|
|
|
if (parallelCapable_offset == -1) {
|
2011-09-10 17:29:02 -07:00
|
|
|
// Default for backward compatibility is false
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return (class_loader->obj_field(parallelCapable_offset) != NULL);
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
bool java_lang_ClassLoader::is_trusted_loader(oop loader) {
|
|
|
|
// Fix for 4474172; see evaluation for more details
|
|
|
|
loader = non_reflection_class_loader(loader);
|
|
|
|
|
|
|
|
oop cl = SystemDictionary::java_system_loader();
|
|
|
|
while(cl != NULL) {
|
2019-09-17 09:51:02 +02:00
|
|
|
if (cl == loader) return true;
|
2007-12-01 00:00:00 +00:00
|
|
|
cl = parent(cl);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-11-17 14:23:29 -05:00
|
|
|
// Return true if this is one of the class loaders associated with
|
|
|
|
// the generated bytecodes for reflection.
|
|
|
|
bool java_lang_ClassLoader::is_reflection_class_loader(oop loader) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (loader != NULL) {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* delegating_cl_class = SystemDictionary::reflect_DelegatingClassLoader_klass();
|
2007-12-01 00:00:00 +00:00
|
|
|
// This might be null in non-1.4 JDKs
|
2016-11-17 14:23:29 -05:00
|
|
|
return (delegating_cl_class != NULL && loader->is_a(delegating_cl_class));
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
oop java_lang_ClassLoader::non_reflection_class_loader(oop loader) {
|
|
|
|
// See whether this is one of the class loaders associated with
|
|
|
|
// the generated bytecodes for reflection, and if so, "magically"
|
|
|
|
// delegate to its parent to prevent class loading from occurring
|
|
|
|
// in places where applications using reflection didn't expect it.
|
|
|
|
if (is_reflection_class_loader(loader)) {
|
|
|
|
return parent(loader);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
return loader;
|
|
|
|
}
|
|
|
|
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
oop java_lang_ClassLoader::unnamedModule(oop loader) {
|
|
|
|
assert(is_instance(loader), "loader must be oop");
|
|
|
|
return loader->obj_field(unnamedModule_offset);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Support for java_lang_System
|
2018-01-08 09:46:31 -05:00
|
|
|
//
|
2018-03-02 17:25:55 -05:00
|
|
|
#define SYSTEM_FIELDS_DO(macro) \
|
|
|
|
macro(static_in_offset, k, "in", input_stream_signature, true); \
|
|
|
|
macro(static_out_offset, k, "out", print_stream_signature, true); \
|
|
|
|
macro(static_err_offset, k, "err", print_stream_signature, true); \
|
|
|
|
macro(static_security_offset, k, "security", security_manager_signature, true)
|
|
|
|
|
2018-01-08 09:46:31 -05:00
|
|
|
void java_lang_System::compute_offsets() {
|
|
|
|
InstanceKlass* k = SystemDictionary::System_klass();
|
2018-03-02 17:25:55 -05:00
|
|
|
SYSTEM_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_System::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
SYSTEM_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2018-03-02 17:25:55 -05:00
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2018-01-08 09:46:31 -05:00
|
|
|
int java_lang_System::in_offset_in_bytes() { return static_in_offset; }
|
|
|
|
int java_lang_System::out_offset_in_bytes() { return static_out_offset; }
|
|
|
|
int java_lang_System::err_offset_in_bytes() { return static_err_offset; }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2019-04-05 10:01:09 +01:00
|
|
|
// Support for jdk_internal_misc_UnsafeConstants
|
|
|
|
//
|
|
|
|
class UnsafeConstantsFixup : public FieldClosure {
|
|
|
|
private:
|
|
|
|
int _address_size;
|
|
|
|
int _page_size;
|
|
|
|
bool _big_endian;
|
|
|
|
bool _use_unaligned_access;
|
2019-08-20 10:11:53 +01:00
|
|
|
int _data_cache_line_flush_size;
|
2019-04-05 10:01:09 +01:00
|
|
|
public:
|
|
|
|
UnsafeConstantsFixup() {
|
|
|
|
// round up values for all static final fields
|
|
|
|
_address_size = sizeof(void*);
|
|
|
|
_page_size = os::vm_page_size();
|
|
|
|
_big_endian = LITTLE_ENDIAN_ONLY(false) BIG_ENDIAN_ONLY(true);
|
|
|
|
_use_unaligned_access = UseUnalignedAccesses;
|
2019-08-20 10:11:53 +01:00
|
|
|
_data_cache_line_flush_size = (int)VM_Version::data_cache_line_flush_size();
|
2019-04-05 10:01:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void do_field(fieldDescriptor* fd) {
|
|
|
|
oop mirror = fd->field_holder()->java_mirror();
|
|
|
|
assert(mirror != NULL, "UnsafeConstants must have mirror already");
|
|
|
|
assert(fd->field_holder() == SystemDictionary::UnsafeConstants_klass(), "Should be UnsafeConstants");
|
|
|
|
assert(fd->is_final(), "fields of UnsafeConstants must be final");
|
|
|
|
assert(fd->is_static(), "fields of UnsafeConstants must be static");
|
|
|
|
if (fd->name() == vmSymbols::address_size_name()) {
|
|
|
|
mirror->int_field_put(fd->offset(), _address_size);
|
|
|
|
} else if (fd->name() == vmSymbols::page_size_name()) {
|
|
|
|
mirror->int_field_put(fd->offset(), _page_size);
|
|
|
|
} else if (fd->name() == vmSymbols::big_endian_name()) {
|
|
|
|
mirror->bool_field_put(fd->offset(), _big_endian);
|
|
|
|
} else if (fd->name() == vmSymbols::use_unaligned_access_name()) {
|
|
|
|
mirror->bool_field_put(fd->offset(), _use_unaligned_access);
|
2019-08-20 10:11:53 +01:00
|
|
|
} else if (fd->name() == vmSymbols::data_cache_line_flush_size_name()) {
|
|
|
|
mirror->int_field_put(fd->offset(), _data_cache_line_flush_size);
|
2019-04-05 10:01:09 +01:00
|
|
|
} else {
|
|
|
|
assert(false, "unexpected UnsafeConstants field");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void jdk_internal_misc_UnsafeConstants::set_unsafe_constants() {
|
|
|
|
UnsafeConstantsFixup fixup;
|
|
|
|
SystemDictionary::UnsafeConstants_klass()->do_local_static_fields(&fixup);
|
|
|
|
}
|
|
|
|
|
2011-09-10 17:29:02 -07:00
|
|
|
int java_lang_Class::_klass_offset;
|
|
|
|
int java_lang_Class::_array_klass_offset;
|
|
|
|
int java_lang_Class::_oop_size_offset;
|
|
|
|
int java_lang_Class::_static_oop_field_count_offset;
|
2014-06-19 14:49:33 -04:00
|
|
|
int java_lang_Class::_class_loader_offset;
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
int java_lang_Class::_module_offset;
|
2013-05-22 14:37:49 -04:00
|
|
|
int java_lang_Class::_protection_domain_offset;
|
2014-07-02 15:22:18 -04:00
|
|
|
int java_lang_Class::_component_mirror_offset;
|
2013-05-22 14:37:49 -04:00
|
|
|
int java_lang_Class::_init_lock_offset;
|
|
|
|
int java_lang_Class::_signers_offset;
|
2019-01-09 20:28:16 +01:00
|
|
|
int java_lang_Class::_name_offset;
|
2019-01-14 17:20:20 +01:00
|
|
|
int java_lang_Class::_source_file_offset;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
GrowableArray<Klass*>* java_lang_Class::_fixup_mirror_list = NULL;
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
GrowableArray<Klass*>* java_lang_Class::_fixup_module_field_list = NULL;
|
2007-12-01 00:00:00 +00:00
|
|
|
int java_lang_Throwable::backtrace_offset;
|
|
|
|
int java_lang_Throwable::detailMessage_offset;
|
|
|
|
int java_lang_Throwable::stackTrace_offset;
|
2016-03-10 13:43:47 -05:00
|
|
|
int java_lang_Throwable::depth_offset;
|
2011-07-22 00:29:01 -07:00
|
|
|
int java_lang_Throwable::static_unassigned_stacktrace_offset;
|
2007-12-01 00:00:00 +00:00
|
|
|
int java_lang_reflect_AccessibleObject::override_offset;
|
|
|
|
int java_lang_reflect_Method::clazz_offset;
|
|
|
|
int java_lang_reflect_Method::name_offset;
|
|
|
|
int java_lang_reflect_Method::returnType_offset;
|
|
|
|
int java_lang_reflect_Method::parameterTypes_offset;
|
|
|
|
int java_lang_reflect_Method::exceptionTypes_offset;
|
|
|
|
int java_lang_reflect_Method::slot_offset;
|
|
|
|
int java_lang_reflect_Method::modifiers_offset;
|
|
|
|
int java_lang_reflect_Method::signature_offset;
|
|
|
|
int java_lang_reflect_Method::annotations_offset;
|
|
|
|
int java_lang_reflect_Method::parameter_annotations_offset;
|
|
|
|
int java_lang_reflect_Method::annotation_default_offset;
|
|
|
|
int java_lang_reflect_Constructor::clazz_offset;
|
|
|
|
int java_lang_reflect_Constructor::parameterTypes_offset;
|
|
|
|
int java_lang_reflect_Constructor::exceptionTypes_offset;
|
|
|
|
int java_lang_reflect_Constructor::slot_offset;
|
|
|
|
int java_lang_reflect_Constructor::modifiers_offset;
|
|
|
|
int java_lang_reflect_Constructor::signature_offset;
|
|
|
|
int java_lang_reflect_Constructor::annotations_offset;
|
|
|
|
int java_lang_reflect_Constructor::parameter_annotations_offset;
|
|
|
|
int java_lang_reflect_Field::clazz_offset;
|
|
|
|
int java_lang_reflect_Field::name_offset;
|
|
|
|
int java_lang_reflect_Field::type_offset;
|
|
|
|
int java_lang_reflect_Field::slot_offset;
|
|
|
|
int java_lang_reflect_Field::modifiers_offset;
|
|
|
|
int java_lang_reflect_Field::signature_offset;
|
|
|
|
int java_lang_reflect_Field::annotations_offset;
|
2013-01-08 14:01:36 -05:00
|
|
|
int java_lang_reflect_Parameter::name_offset;
|
|
|
|
int java_lang_reflect_Parameter::modifiers_offset;
|
|
|
|
int java_lang_reflect_Parameter::index_offset;
|
|
|
|
int java_lang_reflect_Parameter::executable_offset;
|
2007-12-01 00:00:00 +00:00
|
|
|
int java_lang_boxing_object::value_offset;
|
2008-05-21 16:31:35 -07:00
|
|
|
int java_lang_boxing_object::long_value_offset;
|
2007-12-01 00:00:00 +00:00
|
|
|
int java_lang_ref_Reference::referent_offset;
|
|
|
|
int java_lang_ref_Reference::queue_offset;
|
|
|
|
int java_lang_ref_Reference::next_offset;
|
|
|
|
int java_lang_ref_Reference::discovered_offset;
|
|
|
|
int java_lang_ref_SoftReference::timestamp_offset;
|
|
|
|
int java_lang_ref_SoftReference::static_clock_offset;
|
|
|
|
int java_lang_ClassLoader::parent_offset;
|
|
|
|
int java_lang_System::static_in_offset;
|
|
|
|
int java_lang_System::static_out_offset;
|
|
|
|
int java_lang_System::static_err_offset;
|
2013-04-05 10:18:36 -04:00
|
|
|
int java_lang_System::static_security_offset;
|
2007-12-01 00:00:00 +00:00
|
|
|
int java_lang_StackTraceElement::methodName_offset;
|
|
|
|
int java_lang_StackTraceElement::fileName_offset;
|
|
|
|
int java_lang_StackTraceElement::lineNumber_offset;
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
int java_lang_StackTraceElement::moduleName_offset;
|
|
|
|
int java_lang_StackTraceElement::moduleVersion_offset;
|
2016-11-03 18:08:02 -07:00
|
|
|
int java_lang_StackTraceElement::classLoaderName_offset;
|
|
|
|
int java_lang_StackTraceElement::declaringClass_offset;
|
2016-12-13 12:36:13 -08:00
|
|
|
int java_lang_StackTraceElement::declaringClassObject_offset;
|
2015-11-24 14:59:17 -08:00
|
|
|
int java_lang_StackFrameInfo::_memberName_offset;
|
|
|
|
int java_lang_StackFrameInfo::_bci_offset;
|
|
|
|
int java_lang_StackFrameInfo::_version_offset;
|
|
|
|
int java_lang_LiveStackFrameInfo::_monitors_offset;
|
|
|
|
int java_lang_LiveStackFrameInfo::_locals_offset;
|
|
|
|
int java_lang_LiveStackFrameInfo::_operands_offset;
|
2017-01-31 11:50:42 -08:00
|
|
|
int java_lang_LiveStackFrameInfo::_mode_offset;
|
2007-12-01 00:00:00 +00:00
|
|
|
int java_lang_AssertionStatusDirectives::classes_offset;
|
|
|
|
int java_lang_AssertionStatusDirectives::classEnabled_offset;
|
|
|
|
int java_lang_AssertionStatusDirectives::packages_offset;
|
|
|
|
int java_lang_AssertionStatusDirectives::packageEnabled_offset;
|
|
|
|
int java_lang_AssertionStatusDirectives::deflt_offset;
|
|
|
|
int java_nio_Buffer::_limit_offset;
|
2018-06-05 19:58:20 -04:00
|
|
|
int java_util_concurrent_locks_AbstractOwnableSynchronizer::_owner_offset;
|
2016-04-15 16:19:15 +01:00
|
|
|
int reflect_ConstantPool::_oop_offset;
|
|
|
|
int reflect_UnsafeStaticFieldAccessorImpl::_base_offset;
|
2019-06-03 13:21:02 -07:00
|
|
|
int java_lang_Integer_IntegerCache::_static_cache_offset;
|
|
|
|
int java_lang_Long_LongCache::_static_cache_offset;
|
|
|
|
int java_lang_Character_CharacterCache::_static_cache_offset;
|
|
|
|
int java_lang_Short_ShortCache::_static_cache_offset;
|
|
|
|
int java_lang_Byte_ByteCache::_static_cache_offset;
|
|
|
|
int java_lang_Boolean::_static_TRUE_offset;
|
|
|
|
int java_lang_Boolean::_static_FALSE_offset;
|
|
|
|
|
2018-08-15 11:19:57 -07:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#define STACKTRACEELEMENT_FIELDS_DO(macro) \
|
|
|
|
macro(declaringClassObject_offset, k, "declaringClassObject", class_signature, false); \
|
|
|
|
macro(classLoaderName_offset, k, "classLoaderName", string_signature, false); \
|
|
|
|
macro(moduleName_offset, k, "moduleName", string_signature, false); \
|
|
|
|
macro(moduleVersion_offset, k, "moduleVersion", string_signature, false); \
|
|
|
|
macro(declaringClass_offset, k, "declaringClass", string_signature, false); \
|
|
|
|
macro(methodName_offset, k, "methodName", string_signature, false); \
|
|
|
|
macro(fileName_offset, k, "fileName", string_signature, false); \
|
|
|
|
macro(lineNumber_offset, k, "lineNumber", int_signature, false)
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Support for java_lang_StackTraceElement
|
2018-01-08 09:46:31 -05:00
|
|
|
void java_lang_StackTraceElement::compute_offsets() {
|
|
|
|
InstanceKlass* k = SystemDictionary::StackTraceElement_klass();
|
2018-03-02 17:25:55 -05:00
|
|
|
STACKTRACEELEMENT_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
2018-01-08 09:46:31 -05:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_StackTraceElement::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
STACKTRACEELEMENT_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
void java_lang_StackTraceElement::set_fileName(oop element, oop value) {
|
|
|
|
element->obj_field_put(fileName_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_StackTraceElement::set_declaringClass(oop element, oop value) {
|
|
|
|
element->obj_field_put(declaringClass_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_StackTraceElement::set_methodName(oop element, oop value) {
|
|
|
|
element->obj_field_put(methodName_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_StackTraceElement::set_lineNumber(oop element, int value) {
|
|
|
|
element->int_field_put(lineNumber_offset, value);
|
|
|
|
}
|
|
|
|
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
void java_lang_StackTraceElement::set_moduleName(oop element, oop value) {
|
|
|
|
element->obj_field_put(moduleName_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_StackTraceElement::set_moduleVersion(oop element, oop value) {
|
|
|
|
element->obj_field_put(moduleVersion_offset, value);
|
|
|
|
}
|
|
|
|
|
2016-11-03 18:08:02 -07:00
|
|
|
void java_lang_StackTraceElement::set_classLoaderName(oop element, oop value) {
|
|
|
|
element->obj_field_put(classLoaderName_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_StackTraceElement::set_declaringClassObject(oop element, oop value) {
|
2016-12-13 12:36:13 -08:00
|
|
|
element->obj_field_put(declaringClassObject_offset, value);
|
2016-11-03 18:08:02 -07:00
|
|
|
}
|
|
|
|
|
2015-11-24 14:59:17 -08:00
|
|
|
void java_lang_StackFrameInfo::set_version(oop element, short value) {
|
|
|
|
element->short_field_put(_version_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_StackFrameInfo::set_bci(oop element, int value) {
|
2019-08-15 13:41:30 -07:00
|
|
|
assert(value >= 0 && value < max_jushort, "must be a valid bci value");
|
2015-11-24 14:59:17 -08:00
|
|
|
element->int_field_put(_bci_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_LiveStackFrameInfo::set_monitors(oop element, oop value) {
|
|
|
|
element->obj_field_put(_monitors_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_LiveStackFrameInfo::set_locals(oop element, oop value) {
|
|
|
|
element->obj_field_put(_locals_offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_LiveStackFrameInfo::set_operands(oop element, oop value) {
|
|
|
|
element->obj_field_put(_operands_offset, value);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2017-01-31 11:50:42 -08:00
|
|
|
void java_lang_LiveStackFrameInfo::set_mode(oop element, int value) {
|
|
|
|
element->int_field_put(_mode_offset, value);
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Support for java Assertions - java_lang_AssertionStatusDirectives.
|
2018-03-02 17:25:55 -05:00
|
|
|
#define ASSERTIONSTATUSDIRECTIVES_FIELDS_DO(macro) \
|
|
|
|
macro(classes_offset, k, "classes", string_array_signature, false); \
|
|
|
|
macro(classEnabled_offset, k, "classEnabled", bool_array_signature, false); \
|
|
|
|
macro(packages_offset, k, "packages", string_array_signature, false); \
|
|
|
|
macro(packageEnabled_offset, k, "packageEnabled", bool_array_signature, false); \
|
|
|
|
macro(deflt_offset, k, "deflt", bool_signature, false)
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2018-01-08 09:46:31 -05:00
|
|
|
void java_lang_AssertionStatusDirectives::compute_offsets() {
|
|
|
|
InstanceKlass* k = SystemDictionary::AssertionStatusDirectives_klass();
|
2018-03-02 17:25:55 -05:00
|
|
|
ASSERTIONSTATUSDIRECTIVES_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
2018-01-08 09:46:31 -05:00
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_lang_AssertionStatusDirectives::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
ASSERTIONSTATUSDIRECTIVES_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
2018-01-08 09:46:31 -05:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
void java_lang_AssertionStatusDirectives::set_classes(oop o, oop val) {
|
|
|
|
o->obj_field_put(classes_offset, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_AssertionStatusDirectives::set_classEnabled(oop o, oop val) {
|
|
|
|
o->obj_field_put(classEnabled_offset, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_AssertionStatusDirectives::set_packages(oop o, oop val) {
|
|
|
|
o->obj_field_put(packages_offset, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_AssertionStatusDirectives::set_packageEnabled(oop o, oop val) {
|
|
|
|
o->obj_field_put(packageEnabled_offset, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
void java_lang_AssertionStatusDirectives::set_deflt(oop o, bool val) {
|
|
|
|
o->bool_field_put(deflt_offset, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Support for intrinsification of java.nio.Buffer.checkIndex
|
|
|
|
int java_nio_Buffer::limit_offset() {
|
|
|
|
return _limit_offset;
|
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#define BUFFER_FIELDS_DO(macro) \
|
|
|
|
macro(_limit_offset, k, "limit", int_signature, false)
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
void java_nio_Buffer::compute_offsets() {
|
2018-01-08 09:46:31 -05:00
|
|
|
InstanceKlass* k = SystemDictionary::nio_Buffer_klass();
|
2008-04-29 19:45:22 -07:00
|
|
|
assert(k != NULL, "must be loaded in 1.4+");
|
2018-03-02 17:25:55 -05:00
|
|
|
BUFFER_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2018-03-02 17:25:55 -05:00
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_nio_Buffer::serialize_offsets(SerializeClosure* f) {
|
2018-03-02 17:25:55 -05:00
|
|
|
BUFFER_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-06-05 19:58:20 -04:00
|
|
|
#define AOS_FIELDS_DO(macro) \
|
|
|
|
macro(_owner_offset, k, "exclusiveOwnerThread", thread_signature, false)
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2018-06-05 19:58:20 -04:00
|
|
|
void java_util_concurrent_locks_AbstractOwnableSynchronizer::compute_offsets() {
|
|
|
|
InstanceKlass* k = SystemDictionary::java_util_concurrent_locks_AbstractOwnableSynchronizer_klass();
|
|
|
|
AOS_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
oop java_util_concurrent_locks_AbstractOwnableSynchronizer::get_owner_threadObj(oop obj) {
|
|
|
|
assert(_owner_offset != 0, "Must be initialized");
|
|
|
|
return obj->obj_field(_owner_offset);
|
|
|
|
}
|
|
|
|
|
2018-06-27 11:55:35 -04:00
|
|
|
#if INCLUDE_CDS
|
2018-08-14 20:46:46 -07:00
|
|
|
void java_util_concurrent_locks_AbstractOwnableSynchronizer::serialize_offsets(SerializeClosure* f) {
|
2018-06-27 11:55:35 -04:00
|
|
|
AOS_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-06-03 13:21:02 -07:00
|
|
|
#define INTEGER_CACHE_FIELDS_DO(macro) \
|
|
|
|
macro(_static_cache_offset, k, "cache", java_lang_Integer_array_signature, true)
|
|
|
|
|
|
|
|
void java_lang_Integer_IntegerCache::compute_offsets(InstanceKlass *k) {
|
|
|
|
guarantee(k != NULL && k->is_initialized(), "must be loaded and initialized");
|
|
|
|
INTEGER_CACHE_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
|
|
|
}
|
|
|
|
|
|
|
|
objArrayOop java_lang_Integer_IntegerCache::cache(InstanceKlass *ik) {
|
|
|
|
oop base = ik->static_field_base_raw();
|
|
|
|
return objArrayOop(base->obj_field(_static_cache_offset));
|
|
|
|
}
|
|
|
|
|
|
|
|
Symbol* java_lang_Integer_IntegerCache::symbol() {
|
|
|
|
return vmSymbols::java_lang_Integer_IntegerCache();
|
|
|
|
}
|
|
|
|
|
|
|
|
#if INCLUDE_CDS
|
|
|
|
void java_lang_Integer_IntegerCache::serialize_offsets(SerializeClosure* f) {
|
|
|
|
INTEGER_CACHE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#undef INTEGER_CACHE_FIELDS_DO
|
|
|
|
|
|
|
|
jint java_lang_Integer::value(oop obj) {
|
|
|
|
jvalue v;
|
|
|
|
java_lang_boxing_object::get_value(obj, &v);
|
|
|
|
return v.i;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define LONG_CACHE_FIELDS_DO(macro) \
|
|
|
|
macro(_static_cache_offset, k, "cache", java_lang_Long_array_signature, true)
|
|
|
|
|
|
|
|
void java_lang_Long_LongCache::compute_offsets(InstanceKlass *k) {
|
|
|
|
guarantee(k != NULL && k->is_initialized(), "must be loaded and initialized");
|
|
|
|
LONG_CACHE_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
|
|
|
}
|
|
|
|
|
|
|
|
objArrayOop java_lang_Long_LongCache::cache(InstanceKlass *ik) {
|
|
|
|
oop base = ik->static_field_base_raw();
|
|
|
|
return objArrayOop(base->obj_field(_static_cache_offset));
|
|
|
|
}
|
|
|
|
|
|
|
|
Symbol* java_lang_Long_LongCache::symbol() {
|
|
|
|
return vmSymbols::java_lang_Long_LongCache();
|
|
|
|
}
|
|
|
|
|
|
|
|
#if INCLUDE_CDS
|
|
|
|
void java_lang_Long_LongCache::serialize_offsets(SerializeClosure* f) {
|
|
|
|
LONG_CACHE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#undef LONG_CACHE_FIELDS_DO
|
|
|
|
|
|
|
|
jlong java_lang_Long::value(oop obj) {
|
|
|
|
jvalue v;
|
|
|
|
java_lang_boxing_object::get_value(obj, &v);
|
|
|
|
return v.j;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CHARACTER_CACHE_FIELDS_DO(macro) \
|
|
|
|
macro(_static_cache_offset, k, "cache", java_lang_Character_array_signature, true)
|
|
|
|
|
|
|
|
void java_lang_Character_CharacterCache::compute_offsets(InstanceKlass *k) {
|
|
|
|
guarantee(k != NULL && k->is_initialized(), "must be loaded and initialized");
|
|
|
|
CHARACTER_CACHE_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
|
|
|
}
|
|
|
|
|
|
|
|
objArrayOop java_lang_Character_CharacterCache::cache(InstanceKlass *ik) {
|
|
|
|
oop base = ik->static_field_base_raw();
|
|
|
|
return objArrayOop(base->obj_field(_static_cache_offset));
|
|
|
|
}
|
|
|
|
|
|
|
|
Symbol* java_lang_Character_CharacterCache::symbol() {
|
|
|
|
return vmSymbols::java_lang_Character_CharacterCache();
|
|
|
|
}
|
|
|
|
|
|
|
|
#if INCLUDE_CDS
|
|
|
|
void java_lang_Character_CharacterCache::serialize_offsets(SerializeClosure* f) {
|
|
|
|
CHARACTER_CACHE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#undef CHARACTER_CACHE_FIELDS_DO
|
|
|
|
|
|
|
|
jchar java_lang_Character::value(oop obj) {
|
|
|
|
jvalue v;
|
|
|
|
java_lang_boxing_object::get_value(obj, &v);
|
|
|
|
return v.c;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SHORT_CACHE_FIELDS_DO(macro) \
|
|
|
|
macro(_static_cache_offset, k, "cache", java_lang_Short_array_signature, true)
|
|
|
|
|
|
|
|
void java_lang_Short_ShortCache::compute_offsets(InstanceKlass *k) {
|
|
|
|
guarantee(k != NULL && k->is_initialized(), "must be loaded and initialized");
|
|
|
|
SHORT_CACHE_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
|
|
|
}
|
|
|
|
|
|
|
|
objArrayOop java_lang_Short_ShortCache::cache(InstanceKlass *ik) {
|
|
|
|
oop base = ik->static_field_base_raw();
|
|
|
|
return objArrayOop(base->obj_field(_static_cache_offset));
|
|
|
|
}
|
|
|
|
|
|
|
|
Symbol* java_lang_Short_ShortCache::symbol() {
|
|
|
|
return vmSymbols::java_lang_Short_ShortCache();
|
|
|
|
}
|
|
|
|
|
|
|
|
#if INCLUDE_CDS
|
|
|
|
void java_lang_Short_ShortCache::serialize_offsets(SerializeClosure* f) {
|
|
|
|
SHORT_CACHE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#undef SHORT_CACHE_FIELDS_DO
|
|
|
|
|
|
|
|
jshort java_lang_Short::value(oop obj) {
|
|
|
|
jvalue v;
|
|
|
|
java_lang_boxing_object::get_value(obj, &v);
|
|
|
|
return v.s;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define BYTE_CACHE_FIELDS_DO(macro) \
|
|
|
|
macro(_static_cache_offset, k, "cache", java_lang_Byte_array_signature, true)
|
|
|
|
|
|
|
|
void java_lang_Byte_ByteCache::compute_offsets(InstanceKlass *k) {
|
|
|
|
guarantee(k != NULL && k->is_initialized(), "must be loaded and initialized");
|
|
|
|
BYTE_CACHE_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
|
|
|
}
|
|
|
|
|
|
|
|
objArrayOop java_lang_Byte_ByteCache::cache(InstanceKlass *ik) {
|
|
|
|
oop base = ik->static_field_base_raw();
|
|
|
|
return objArrayOop(base->obj_field(_static_cache_offset));
|
|
|
|
}
|
|
|
|
|
|
|
|
Symbol* java_lang_Byte_ByteCache::symbol() {
|
|
|
|
return vmSymbols::java_lang_Byte_ByteCache();
|
|
|
|
}
|
|
|
|
|
|
|
|
#if INCLUDE_CDS
|
|
|
|
void java_lang_Byte_ByteCache::serialize_offsets(SerializeClosure* f) {
|
|
|
|
BYTE_CACHE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#undef BYTE_CACHE_FIELDS_DO
|
|
|
|
|
|
|
|
jbyte java_lang_Byte::value(oop obj) {
|
|
|
|
jvalue v;
|
|
|
|
java_lang_boxing_object::get_value(obj, &v);
|
|
|
|
return v.b;
|
|
|
|
}
|
|
|
|
#define BOOLEAN_FIELDS_DO(macro) \
|
|
|
|
macro(_static_TRUE_offset, k, "TRUE", java_lang_Boolean_signature, true); \
|
|
|
|
macro(_static_FALSE_offset, k, "FALSE", java_lang_Boolean_signature, true)
|
|
|
|
|
|
|
|
|
|
|
|
void java_lang_Boolean::compute_offsets(InstanceKlass *k) {
|
|
|
|
guarantee(k != NULL && k->is_initialized(), "must be loaded and initialized");
|
|
|
|
BOOLEAN_FIELDS_DO(FIELD_COMPUTE_OFFSET);
|
|
|
|
}
|
|
|
|
|
|
|
|
oop java_lang_Boolean::get_TRUE(InstanceKlass *ik) {
|
|
|
|
oop base = ik->static_field_base_raw();
|
|
|
|
return base->obj_field(_static_TRUE_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
oop java_lang_Boolean::get_FALSE(InstanceKlass *ik) {
|
|
|
|
oop base = ik->static_field_base_raw();
|
|
|
|
return base->obj_field(_static_FALSE_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
Symbol* java_lang_Boolean::symbol() {
|
|
|
|
return vmSymbols::java_lang_Boolean();
|
|
|
|
}
|
|
|
|
|
|
|
|
#if INCLUDE_CDS
|
|
|
|
void java_lang_Boolean::serialize_offsets(SerializeClosure* f) {
|
|
|
|
BOOLEAN_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#undef BOOLEAN_CACHE_FIELDS_DO
|
|
|
|
|
|
|
|
jboolean java_lang_Boolean::value(oop obj) {
|
|
|
|
jvalue v;
|
|
|
|
java_lang_boxing_object::get_value(obj, &v);
|
|
|
|
return v.z;
|
|
|
|
}
|
|
|
|
|
2018-01-08 09:46:31 -05:00
|
|
|
static int member_offset(int hardcoded_offset) {
|
|
|
|
return (hardcoded_offset * heapOopSize) + instanceOopDesc::base_offset_in_bytes();
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Compute hard-coded offsets
|
|
|
|
// Invoked before SystemDictionary::initialize, so pre-loaded classes
|
|
|
|
// are not available to determine the offset_of_static_fields.
|
|
|
|
void JavaClasses::compute_hard_coded_offsets() {
|
|
|
|
|
|
|
|
// java_lang_boxing_object
|
2018-01-08 09:46:31 -05:00
|
|
|
java_lang_boxing_object::value_offset = member_offset(java_lang_boxing_object::hc_value_offset);
|
|
|
|
java_lang_boxing_object::long_value_offset = align_up(member_offset(java_lang_boxing_object::hc_value_offset), BytesPerLong);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2018-01-08 09:46:31 -05:00
|
|
|
// java_lang_ref_Reference
|
|
|
|
java_lang_ref_Reference::referent_offset = member_offset(java_lang_ref_Reference::hc_referent_offset);
|
|
|
|
java_lang_ref_Reference::queue_offset = member_offset(java_lang_ref_Reference::hc_queue_offset);
|
|
|
|
java_lang_ref_Reference::next_offset = member_offset(java_lang_ref_Reference::hc_next_offset);
|
|
|
|
java_lang_ref_Reference::discovered_offset = member_offset(java_lang_ref_Reference::hc_discovered_offset);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2018-08-14 20:46:46 -07:00
|
|
|
#define DO_COMPUTE_OFFSETS(k) k::compute_offsets();
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Compute non-hard-coded field offsets of all the classes in this file
|
|
|
|
void JavaClasses::compute_offsets() {
|
2018-03-02 17:25:55 -05:00
|
|
|
if (UseSharedSpaces) {
|
2018-10-17 15:57:10 -07:00
|
|
|
assert(JvmtiExport::is_early_phase() && !(JvmtiExport::should_post_class_file_load_hook() &&
|
|
|
|
JvmtiExport::has_early_class_hook_env()),
|
|
|
|
"JavaClasses::compute_offsets() must be called in early JVMTI phase.");
|
|
|
|
// None of the classes used by the rest of this function can be replaced by
|
|
|
|
// JMVTI ClassFileLoadHook.
|
|
|
|
// We are safe to use the archived offsets, which have already been restored
|
|
|
|
// by JavaClasses::serialize_offsets, without computing the offsets again.
|
|
|
|
return;
|
2018-03-02 17:25:55 -05:00
|
|
|
}
|
|
|
|
|
2018-08-14 20:46:46 -07:00
|
|
|
// We have already called the compute_offsets() of the
|
|
|
|
// BASIC_JAVA_CLASSES_DO_PART1 classes (java_lang_String and java_lang_Class)
|
2018-10-17 15:57:10 -07:00
|
|
|
// earlier inside SystemDictionary::resolve_well_known_classes()
|
2018-08-14 20:46:46 -07:00
|
|
|
BASIC_JAVA_CLASSES_DO_PART2(DO_COMPUTE_OFFSETS);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2018-08-14 20:46:46 -07:00
|
|
|
#if INCLUDE_CDS
|
|
|
|
#define DO_SERIALIZE_OFFSETS(k) k::serialize_offsets(soc);
|
|
|
|
|
|
|
|
void JavaClasses::serialize_offsets(SerializeClosure* soc) {
|
|
|
|
BASIC_JAVA_CLASSES_DO(DO_SERIALIZE_OFFSETS);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
#ifndef PRODUCT
|
|
|
|
|
|
|
|
// These functions exist to assert the validity of hard-coded field offsets to guard
|
|
|
|
// against changes in the class files
|
|
|
|
|
|
|
|
bool JavaClasses::check_offset(const char *klass_name, int hardcoded_offset, const char *field_name, const char* field_sig) {
|
|
|
|
EXCEPTION_MARK;
|
|
|
|
fieldDescriptor fd;
|
2019-05-14 11:29:18 -04:00
|
|
|
TempNewSymbol klass_sym = SymbolTable::new_symbol(klass_name);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Klass* k = SystemDictionary::resolve_or_fail(klass_sym, true, CATCH);
|
2017-03-15 10:25:37 -04:00
|
|
|
InstanceKlass* ik = InstanceKlass::cast(k);
|
2019-05-14 11:29:18 -04:00
|
|
|
TempNewSymbol f_name = SymbolTable::new_symbol(field_name);
|
|
|
|
TempNewSymbol f_sig = SymbolTable::new_symbol(field_sig);
|
2017-03-15 10:25:37 -04:00
|
|
|
if (!ik->find_local_field(f_name, f_sig, &fd)) {
|
2007-12-01 00:00:00 +00:00
|
|
|
tty->print_cr("Nonstatic field %s.%s not found", klass_name, field_name);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (fd.is_static()) {
|
|
|
|
tty->print_cr("Nonstatic field %s.%s appears to be static", klass_name, field_name);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (fd.offset() == hardcoded_offset ) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
tty->print_cr("Offset of nonstatic field %s.%s is hardcoded as %d but should really be %d.",
|
|
|
|
klass_name, field_name, hardcoded_offset, fd.offset());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check the hard-coded field offsets of all the classes in this file
|
|
|
|
|
|
|
|
void JavaClasses::check_offsets() {
|
|
|
|
bool valid = true;
|
|
|
|
|
|
|
|
#define CHECK_OFFSET(klass_name, cpp_klass_name, field_name, field_sig) \
|
|
|
|
valid &= check_offset(klass_name, cpp_klass_name :: field_name ## _offset, #field_name, field_sig)
|
|
|
|
|
2008-05-21 16:31:35 -07:00
|
|
|
#define CHECK_LONG_OFFSET(klass_name, cpp_klass_name, field_name, field_sig) \
|
|
|
|
valid &= check_offset(klass_name, cpp_klass_name :: long_ ## field_name ## _offset, #field_name, field_sig)
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Boxed primitive objects (java_lang_boxing_object)
|
|
|
|
|
|
|
|
CHECK_OFFSET("java/lang/Boolean", java_lang_boxing_object, value, "Z");
|
|
|
|
CHECK_OFFSET("java/lang/Character", java_lang_boxing_object, value, "C");
|
|
|
|
CHECK_OFFSET("java/lang/Float", java_lang_boxing_object, value, "F");
|
2008-05-21 16:31:35 -07:00
|
|
|
CHECK_LONG_OFFSET("java/lang/Double", java_lang_boxing_object, value, "D");
|
2007-12-01 00:00:00 +00:00
|
|
|
CHECK_OFFSET("java/lang/Byte", java_lang_boxing_object, value, "B");
|
|
|
|
CHECK_OFFSET("java/lang/Short", java_lang_boxing_object, value, "S");
|
|
|
|
CHECK_OFFSET("java/lang/Integer", java_lang_boxing_object, value, "I");
|
2008-05-21 16:31:35 -07:00
|
|
|
CHECK_LONG_OFFSET("java/lang/Long", java_lang_boxing_object, value, "J");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// java.lang.ref.Reference
|
|
|
|
|
|
|
|
CHECK_OFFSET("java/lang/ref/Reference", java_lang_ref_Reference, referent, "Ljava/lang/Object;");
|
|
|
|
CHECK_OFFSET("java/lang/ref/Reference", java_lang_ref_Reference, queue, "Ljava/lang/ref/ReferenceQueue;");
|
|
|
|
CHECK_OFFSET("java/lang/ref/Reference", java_lang_ref_Reference, next, "Ljava/lang/ref/Reference;");
|
|
|
|
// Fake field
|
|
|
|
//CHECK_OFFSET("java/lang/ref/Reference", java_lang_ref_Reference, discovered, "Ljava/lang/ref/Reference;");
|
|
|
|
|
|
|
|
if (!valid) vm_exit_during_initialization("Hard-coded field offset verification failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // PRODUCT
|
|
|
|
|
2011-09-10 17:29:02 -07:00
|
|
|
int InjectedField::compute_offset() {
|
2015-10-26 13:11:36 -04:00
|
|
|
InstanceKlass* ik = InstanceKlass::cast(klass());
|
|
|
|
for (AllFieldStream fs(ik); !fs.done(); fs.next()) {
|
2011-09-10 17:29:02 -07:00
|
|
|
if (!may_be_java && !fs.access_flags().is_internal()) {
|
|
|
|
// Only look at injected fields
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (fs.name() == name() && fs.signature() == signature()) {
|
|
|
|
return fs.offset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ResourceMark rm;
|
2015-10-26 13:11:36 -04:00
|
|
|
tty->print_cr("Invalid layout of %s at %s/%s%s", ik->external_name(), name()->as_C_string(), signature()->as_C_string(), may_be_java ? " (may_be_java)" : "");
|
2012-07-24 10:51:00 -07:00
|
|
|
#ifndef PRODUCT
|
2015-10-26 13:11:36 -04:00
|
|
|
ik->print();
|
2012-07-24 10:51:00 -07:00
|
|
|
tty->print_cr("all fields:");
|
2015-10-26 13:11:36 -04:00
|
|
|
for (AllFieldStream fs(ik); !fs.done(); fs.next()) {
|
2012-07-24 10:51:00 -07:00
|
|
|
tty->print_cr(" name: %s, sig: %s, flags: %08x", fs.name()->as_C_string(), fs.signature()->as_C_string(), fs.access_flags().as_int());
|
|
|
|
}
|
|
|
|
#endif //PRODUCT
|
2018-10-17 15:57:10 -07:00
|
|
|
vm_exit_during_initialization("Invalid layout of well-known class: use -Xlog:class+load=info to see the origin of the problem class");
|
2011-09-10 17:29:02 -07:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
void javaClasses_init() {
|
|
|
|
JavaClasses::compute_offsets();
|
|
|
|
JavaClasses::check_offsets();
|
|
|
|
FilteredFieldsMap::initialize(); // must be done after computing offsets.
|
|
|
|
}
|