8260467: Move well-known classes from systemDictionary.hpp to vmClasses.hpp
Reviewed-by: dholmes, coleenp
This commit is contained in:
parent
62ffe75b1f
commit
396a496f3c
src
hotspot
cpu
aarch64
arm
ppc
s390
x86
share
jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory
test/hotspot/jtreg/serviceability/sa
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
@ -26,6 +26,7 @@
|
||||
#include "precompiled.hpp"
|
||||
#include "asm/macroAssembler.hpp"
|
||||
#include "classfile/javaClasses.inline.hpp"
|
||||
#include "classfile/vmClasses.hpp"
|
||||
#include "interpreter/interpreter.hpp"
|
||||
#include "interpreter/interpreterRuntime.hpp"
|
||||
#include "memory/allocation.inline.hpp"
|
||||
@ -47,7 +48,7 @@
|
||||
|
||||
void MethodHandles::load_klass_from_Class(MacroAssembler* _masm, Register klass_reg) {
|
||||
if (VerifyMethodHandles)
|
||||
verify_klass(_masm, klass_reg, SystemDictionary::WK_KLASS_ENUM_NAME(java_lang_Class),
|
||||
verify_klass(_masm, klass_reg, VM_CLASS_ID(java_lang_Class),
|
||||
"MH argument is a Class");
|
||||
__ ldr(klass_reg, Address(klass_reg, java_lang_Class::klass_offset()));
|
||||
}
|
||||
@ -64,10 +65,10 @@ static int check_nonzero(const char* xname, int x) {
|
||||
|
||||
#ifdef ASSERT
|
||||
void MethodHandles::verify_klass(MacroAssembler* _masm,
|
||||
Register obj, SystemDictionary::WKID klass_id,
|
||||
Register obj, VMClassID klass_id,
|
||||
const char* error_message) {
|
||||
InstanceKlass** klass_addr = SystemDictionary::well_known_klass_addr(klass_id);
|
||||
Klass* klass = SystemDictionary::well_known_klass(klass_id);
|
||||
InstanceKlass** klass_addr = vmClasses::klass_addr_at(klass_id);
|
||||
Klass* klass = vmClasses::klass_at(klass_id);
|
||||
Register temp = rscratch2;
|
||||
Register temp2 = rscratch1; // used by MacroAssembler::cmpptr
|
||||
Label L_ok, L_bad;
|
||||
@ -289,7 +290,7 @@ void MethodHandles::generate_method_handle_dispatch(MacroAssembler* _masm,
|
||||
// The method is a member invoker used by direct method handles.
|
||||
if (VerifyMethodHandles) {
|
||||
// make sure the trailing argument really is a MemberName (caller responsibility)
|
||||
verify_klass(_masm, member_reg, SystemDictionary::WK_KLASS_ENUM_NAME(java_lang_invoke_MemberName),
|
||||
verify_klass(_masm, member_reg, VM_CLASS_ID(java_lang_invoke_MemberName),
|
||||
"MemberName required for invokeVirtual etc.");
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
@ -36,11 +36,11 @@ public:
|
||||
static void load_klass_from_Class(MacroAssembler* _masm, Register klass_reg);
|
||||
|
||||
static void verify_klass(MacroAssembler* _masm,
|
||||
Register obj, SystemDictionary::WKID klass_id,
|
||||
Register obj, VMClassID klass_id,
|
||||
const char* error_message = "wrong klass") NOT_DEBUG_RETURN;
|
||||
|
||||
static void verify_method_handle(MacroAssembler* _masm, Register mh_reg) {
|
||||
verify_klass(_masm, mh_reg, SystemDictionary::WK_KLASS_ENUM_NAME(java_lang_invoke_MethodHandle),
|
||||
verify_klass(_masm, mh_reg, VM_CLASS_ID(java_lang_invoke_MethodHandle),
|
||||
"reference is a MH");
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "precompiled.hpp"
|
||||
#include "jvm.h"
|
||||
#include "classfile/javaClasses.inline.hpp"
|
||||
#include "classfile/vmClasses.hpp"
|
||||
#include "interpreter/interpreter.hpp"
|
||||
#include "interpreter/interpreterRuntime.hpp"
|
||||
#include "logging/log.hpp"
|
||||
@ -53,7 +54,7 @@
|
||||
|
||||
void MethodHandles::load_klass_from_Class(MacroAssembler* _masm, Register klass_reg, Register temp1, Register temp2) {
|
||||
if (VerifyMethodHandles) {
|
||||
verify_klass(_masm, klass_reg, temp1, temp2, SystemDictionary::WK_KLASS_ENUM_NAME(java_lang_Class),
|
||||
verify_klass(_masm, klass_reg, temp1, temp2, VM_CLASS_ID(java_lang_Class),
|
||||
"MH argument is a Class");
|
||||
}
|
||||
__ ldr(klass_reg, Address(klass_reg, java_lang_Class::klass_offset()));
|
||||
@ -71,10 +72,10 @@ static int check_nonzero(const char* xname, int x) {
|
||||
|
||||
#ifdef ASSERT
|
||||
void MethodHandles::verify_klass(MacroAssembler* _masm,
|
||||
Register obj, Register temp1, Register temp2, SystemDictionary::WKID klass_id,
|
||||
Register obj, Register temp1, Register temp2, VMClassID klass_id,
|
||||
const char* error_message) {
|
||||
InstanceKlass** klass_addr = SystemDictionary::well_known_klass_addr(klass_id);
|
||||
Klass* klass = SystemDictionary::well_known_klass(klass_id);
|
||||
InstanceKlass** klass_addr = vmClasses::klass_addr_at(klass_id);
|
||||
Klass* klass = vmClasses::klass_at(klass_id);
|
||||
Label L_ok, L_bad;
|
||||
BLOCK_COMMENT("verify_klass {");
|
||||
__ verify_oop(obj);
|
||||
@ -305,7 +306,7 @@ void MethodHandles::generate_method_handle_dispatch(MacroAssembler* _masm,
|
||||
// The method is a member invoker used by direct method handles.
|
||||
if (VerifyMethodHandles) {
|
||||
// make sure the trailing argument really is a MemberName (caller responsibility)
|
||||
verify_klass(_masm, member_reg, temp2, temp3, SystemDictionary::WK_KLASS_ENUM_NAME(java_lang_invoke_MemberName),
|
||||
verify_klass(_masm, member_reg, temp2, temp3, VM_CLASS_ID(java_lang_invoke_MemberName),
|
||||
"MemberName required for invokeVirtual etc.");
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -35,7 +35,7 @@ public:
|
||||
static void load_klass_from_Class(MacroAssembler* _masm, Register klass_reg, Register temp1, Register temp2);
|
||||
|
||||
static void verify_klass(MacroAssembler* _masm,
|
||||
Register obj, Register temp1, Register temp2, SystemDictionary::WKID klass_id,
|
||||
Register obj, Register temp1, Register temp2, VMClassID klass_id,
|
||||
const char* error_message = "wrong klass") NOT_DEBUG_RETURN;
|
||||
|
||||
static void verify_ref_kind(MacroAssembler* _masm, int ref_kind, Register member_reg, Register temp) NOT_DEBUG_RETURN;
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "jvm.h"
|
||||
#include "asm/macroAssembler.inline.hpp"
|
||||
#include "classfile/javaClasses.inline.hpp"
|
||||
#include "classfile/vmClasses.hpp"
|
||||
#include "interpreter/interpreter.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "logging/logStream.hpp"
|
||||
@ -56,7 +57,7 @@ inline static RegisterOrConstant constant(int value) {
|
||||
void MethodHandles::load_klass_from_Class(MacroAssembler* _masm, Register klass_reg,
|
||||
Register temp_reg, Register temp2_reg) {
|
||||
if (VerifyMethodHandles) {
|
||||
verify_klass(_masm, klass_reg, SystemDictionary::WK_KLASS_ENUM_NAME(java_lang_Class),
|
||||
verify_klass(_masm, klass_reg, VM_CLASS_ID(java_lang_Class),
|
||||
temp_reg, temp2_reg, "MH argument is a Class");
|
||||
}
|
||||
__ ld(klass_reg, java_lang_Class::klass_offset(), klass_reg);
|
||||
@ -74,11 +75,11 @@ static int check_nonzero(const char* xname, int x) {
|
||||
|
||||
#ifdef ASSERT
|
||||
void MethodHandles::verify_klass(MacroAssembler* _masm,
|
||||
Register obj_reg, SystemDictionary::WKID klass_id,
|
||||
Register obj_reg, VMClassID klass_id,
|
||||
Register temp_reg, Register temp2_reg,
|
||||
const char* error_message) {
|
||||
InstanceKlass** klass_addr = SystemDictionary::well_known_klass_addr(klass_id);
|
||||
Klass* klass = SystemDictionary::well_known_klass(klass_id);
|
||||
InstanceKlass** klass_addr = VMClassses::klass_addr_at(klass_id);
|
||||
Klass* klass = VMClassses::klass_at(klass_id);
|
||||
Label L_ok, L_bad;
|
||||
BLOCK_COMMENT("verify_klass {");
|
||||
__ verify_oop(obj_reg, FILE_AND_LINE);
|
||||
@ -325,7 +326,7 @@ void MethodHandles::generate_method_handle_dispatch(MacroAssembler* _masm,
|
||||
// The method is a member invoker used by direct method handles.
|
||||
if (VerifyMethodHandles) {
|
||||
// make sure the trailing argument really is a MemberName (caller responsibility)
|
||||
verify_klass(_masm, member_reg, SystemDictionary::WK_KLASS_ENUM_NAME(MemberName_klass),
|
||||
verify_klass(_masm, member_reg, VM_CLASS_ID(MemberName_klass),
|
||||
temp1, temp2,
|
||||
"MemberName required for invokeVirtual etc.");
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2015 SAP SE. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
@ -36,13 +36,13 @@ public:
|
||||
static void load_klass_from_Class(MacroAssembler* _masm, Register klass_reg, Register temp_reg, Register temp2_reg);
|
||||
|
||||
static void verify_klass(MacroAssembler* _masm,
|
||||
Register obj_reg, SystemDictionary::WKID klass_id,
|
||||
Register obj_reg, VMClassID klass_id,
|
||||
Register temp_reg, Register temp2_reg,
|
||||
const char* error_message = "wrong klass") NOT_DEBUG_RETURN;
|
||||
|
||||
static void verify_method_handle(MacroAssembler* _masm, Register mh_reg,
|
||||
Register temp_reg, Register temp2_reg) {
|
||||
verify_klass(_masm, mh_reg, SystemDictionary::WK_KLASS_ENUM_NAME(java_lang_invoke_MethodHandle),
|
||||
verify_klass(_masm, mh_reg, VM_CLASS_ID(java_lang_invoke_MethodHandle),
|
||||
temp_reg, temp2_reg,
|
||||
"reference is a MH");
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "jvm.h"
|
||||
#include "asm/macroAssembler.inline.hpp"
|
||||
#include "classfile/javaClasses.inline.hpp"
|
||||
#include "classfile/vmClasses.hpp"
|
||||
#include "interpreter/interpreter.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "logging/logStream.hpp"
|
||||
@ -56,7 +57,7 @@ static RegisterOrConstant constant(int value) {
|
||||
void MethodHandles::load_klass_from_Class(MacroAssembler* _masm, Register klass_reg,
|
||||
Register temp_reg, Register temp2_reg) {
|
||||
if (VerifyMethodHandles) {
|
||||
verify_klass(_masm, klass_reg, SystemDictionary::WK_KLASS_ENUM_NAME(java_lang_Class),
|
||||
verify_klass(_masm, klass_reg, VM_CLASS_ID(java_lang_Class),
|
||||
temp_reg, temp2_reg, "MH argument is a Class");
|
||||
}
|
||||
__ z_lg(klass_reg, Address(klass_reg, java_lang_Class::klass_offset()));
|
||||
@ -75,12 +76,12 @@ static int check_nonzero(const char* xname, int x) {
|
||||
|
||||
#ifdef ASSERT
|
||||
void MethodHandles::verify_klass(MacroAssembler* _masm,
|
||||
Register obj_reg, SystemDictionary::WKID klass_id,
|
||||
Register obj_reg, VMClassID klass_id,
|
||||
Register temp_reg, Register temp2_reg,
|
||||
const char* error_message) {
|
||||
|
||||
InstanceKlass** klass_addr = SystemDictionary::well_known_klass_addr(klass_id);
|
||||
Klass* klass = SystemDictionary::well_known_klass(klass_id);
|
||||
InstanceKlass** klass_addr = VMClassses::klass_addr_at(klass_id);
|
||||
Klass* klass = VMClassses::klass_at(klass_id);
|
||||
|
||||
assert(temp_reg != Z_R0 && // Is used as base register!
|
||||
temp_reg != noreg && temp2_reg != noreg, "need valid registers!");
|
||||
@ -387,7 +388,7 @@ void MethodHandles::generate_method_handle_dispatch(MacroAssembler* _masm,
|
||||
if (VerifyMethodHandles) {
|
||||
// Make sure the trailing argument really is a MemberName (caller responsibility).
|
||||
verify_klass(_masm, member_reg,
|
||||
SystemDictionary::WK_KLASS_ENUM_NAME(MemberName_klass),
|
||||
VM_CLASS_ID(MemberName_klass),
|
||||
temp1, temp2,
|
||||
"MemberName required for invokeVirtual etc.");
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016 SAP SE. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
@ -36,13 +36,13 @@
|
||||
static void load_klass_from_Class(MacroAssembler* _masm, Register klass_reg, Register temp_reg, Register temp2_reg);
|
||||
|
||||
static void verify_klass(MacroAssembler* _masm,
|
||||
Register obj_reg, SystemDictionary::WKID klass_id,
|
||||
Register obj_reg, VMClassID klass_id,
|
||||
Register temp_reg, Register temp2_reg,
|
||||
const char* error_message = "wrong klass") NOT_DEBUG_RETURN;
|
||||
|
||||
static void verify_method_handle(MacroAssembler* _masm, Register mh_reg,
|
||||
Register temp_reg, Register temp2_reg) {
|
||||
verify_klass(_masm, mh_reg, SystemDictionary::WK_KLASS_ENUM_NAME(java_lang_invoke_MethodHandle),
|
||||
verify_klass(_masm, mh_reg, VM_CLASS_ID(java_lang_invoke_MethodHandle),
|
||||
temp_reg, temp2_reg,
|
||||
"reference is a MH");
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "precompiled.hpp"
|
||||
#include "jvm.h"
|
||||
#include "asm/macroAssembler.hpp"
|
||||
#include "classfile/vmClasses.hpp"
|
||||
#include "compiler/disassembler.hpp"
|
||||
#include "classfile/javaClasses.inline.hpp"
|
||||
#include "interpreter/interpreter.hpp"
|
||||
@ -54,7 +55,7 @@
|
||||
|
||||
void MethodHandles::load_klass_from_Class(MacroAssembler* _masm, Register klass_reg) {
|
||||
if (VerifyMethodHandles)
|
||||
verify_klass(_masm, klass_reg, SystemDictionary::WK_KLASS_ENUM_NAME(java_lang_Class),
|
||||
verify_klass(_masm, klass_reg, VM_CLASS_ID(java_lang_Class),
|
||||
"MH argument is a Class");
|
||||
__ movptr(klass_reg, Address(klass_reg, java_lang_Class::klass_offset()));
|
||||
}
|
||||
@ -71,10 +72,10 @@ static int check_nonzero(const char* xname, int x) {
|
||||
|
||||
#ifdef ASSERT
|
||||
void MethodHandles::verify_klass(MacroAssembler* _masm,
|
||||
Register obj, SystemDictionary::WKID klass_id,
|
||||
Register obj, VMClassID klass_id,
|
||||
const char* error_message) {
|
||||
InstanceKlass** klass_addr = SystemDictionary::well_known_klass_addr(klass_id);
|
||||
Klass* klass = SystemDictionary::well_known_klass(klass_id);
|
||||
InstanceKlass** klass_addr = vmClasses::klass_addr_at(klass_id);
|
||||
Klass* klass = vmClasses::klass_at(klass_id);
|
||||
Register temp = rdi;
|
||||
Register temp2 = noreg;
|
||||
LP64_ONLY(temp2 = rscratch1); // used by MacroAssembler::cmpptr and load_klass
|
||||
@ -345,7 +346,7 @@ void MethodHandles::generate_method_handle_dispatch(MacroAssembler* _masm,
|
||||
// The method is a member invoker used by direct method handles.
|
||||
if (VerifyMethodHandles) {
|
||||
// make sure the trailing argument really is a MemberName (caller responsibility)
|
||||
verify_klass(_masm, member_reg, SystemDictionary::WK_KLASS_ENUM_NAME(java_lang_invoke_MemberName),
|
||||
verify_klass(_masm, member_reg, VM_CLASS_ID(java_lang_invoke_MemberName),
|
||||
"MemberName required for invokeVirtual etc.");
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -35,11 +35,11 @@ public:
|
||||
static void load_klass_from_Class(MacroAssembler* _masm, Register klass_reg);
|
||||
|
||||
static void verify_klass(MacroAssembler* _masm,
|
||||
Register obj, SystemDictionary::WKID klass_id,
|
||||
Register obj, VMClassID klass_id,
|
||||
const char* error_message = "wrong klass") NOT_DEBUG_RETURN;
|
||||
|
||||
static void verify_method_handle(MacroAssembler* _masm, Register mh_reg) {
|
||||
verify_klass(_masm, mh_reg, SystemDictionary::WK_KLASS_ENUM_NAME(java_lang_invoke_MethodHandle),
|
||||
verify_klass(_masm, mh_reg, VM_CLASS_ID(MethodHandle_klass),
|
||||
"reference is a MH");
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -85,9 +85,9 @@
|
||||
|
||||
ciObject* ciEnv::_null_object_instance;
|
||||
|
||||
#define WK_KLASS_DEFN(name, ignore_s) ciInstanceKlass* ciEnv::_##name = NULL;
|
||||
WK_KLASSES_DO(WK_KLASS_DEFN)
|
||||
#undef WK_KLASS_DEFN
|
||||
#define VM_CLASS_DEFN(name, ignore_s) ciInstanceKlass* ciEnv::_##name = NULL;
|
||||
VM_CLASSES_DO(VM_CLASS_DEFN)
|
||||
#undef VM_CLASS_DEFN
|
||||
|
||||
ciSymbol* ciEnv::_unloaded_cisymbol = NULL;
|
||||
ciInstanceKlass* ciEnv::_unloaded_ciinstance_klass = NULL;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,7 +27,7 @@
|
||||
|
||||
#include "ci/ciClassList.hpp"
|
||||
#include "ci/ciObjectFactory.hpp"
|
||||
#include "classfile/systemDictionary.hpp"
|
||||
#include "classfile/vmClassMacros.hpp"
|
||||
#include "code/debugInfoRec.hpp"
|
||||
#include "code/dependencies.hpp"
|
||||
#include "code/exceptionHandlerTable.hpp"
|
||||
@ -84,9 +84,9 @@ private:
|
||||
// Distinguished instances of certain ciObjects..
|
||||
static ciObject* _null_object_instance;
|
||||
|
||||
#define WK_KLASS_DECL(name, ignore_s) static ciInstanceKlass* _##name;
|
||||
WK_KLASSES_DO(WK_KLASS_DECL)
|
||||
#undef WK_KLASS_DECL
|
||||
#define VM_CLASS_DECL(name, ignore_s) static ciInstanceKlass* _##name;
|
||||
VM_CLASSES_DO(VM_CLASS_DECL)
|
||||
#undef VM_CLASS_DECL
|
||||
|
||||
static ciSymbol* _unloaded_cisymbol;
|
||||
static ciInstanceKlass* _unloaded_ciinstance_klass;
|
||||
@ -383,12 +383,12 @@ public:
|
||||
|
||||
|
||||
// Access to certain well known ciObjects.
|
||||
#define WK_KLASS_FUNC(name, ignore_s) \
|
||||
#define VM_CLASS_FUNC(name, ignore_s) \
|
||||
ciInstanceKlass* name() { \
|
||||
return _##name;\
|
||||
}
|
||||
WK_KLASSES_DO(WK_KLASS_FUNC)
|
||||
#undef WK_KLASS_FUNC
|
||||
VM_CLASSES_DO(VM_CLASS_FUNC)
|
||||
#undef VM_CLASS_FUNC
|
||||
|
||||
ciInstance* NullPointerException_instance() {
|
||||
assert(_NullPointerException_instance != NULL, "initialization problem");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,6 +27,7 @@
|
||||
#include "ci/ciObjArrayKlass.hpp"
|
||||
#include "ci/ciSymbol.hpp"
|
||||
#include "ci/ciUtilities.inline.hpp"
|
||||
#include "classfile/systemDictionary.hpp"
|
||||
#include "oops/objArrayKlass.hpp"
|
||||
|
||||
// ciObjArrayKlass
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -152,12 +152,12 @@ void ciObjectFactory::init_shared_objects() {
|
||||
ciEnv::_null_object_instance = new (_arena) ciNullObject();
|
||||
init_ident_of(ciEnv::_null_object_instance);
|
||||
|
||||
#define WK_KLASS_DEFN(name, ignore_s) \
|
||||
#define VM_CLASS_DEFN(name, ignore_s) \
|
||||
if (SystemDictionary::name##_is_loaded()) \
|
||||
ciEnv::_##name = get_metadata(SystemDictionary::name())->as_instance_klass();
|
||||
|
||||
WK_KLASSES_DO(WK_KLASS_DEFN)
|
||||
#undef WK_KLASS_DEFN
|
||||
VM_CLASSES_DO(VM_CLASS_DEFN)
|
||||
#undef VM_CLASS_DEFN
|
||||
|
||||
for (int len = -1; len != _ci_metadata.length(); ) {
|
||||
len = _ci_metadata.length();
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "classfile/moduleEntry.hpp"
|
||||
#include "classfile/stringTable.hpp"
|
||||
#include "classfile/symbolTable.hpp"
|
||||
#include "classfile/vmClasses.hpp"
|
||||
#include "classfile/vmSymbols.hpp"
|
||||
#include "code/debugInfo.hpp"
|
||||
#include "code/dependencyContext.hpp"
|
||||
@ -88,7 +89,7 @@
|
||||
#endif
|
||||
|
||||
#define DECLARE_INJECTED_FIELD(klass, name, signature, may_be_java) \
|
||||
{ SystemDictionary::WK_KLASS_ENUM_NAME(klass), VM_SYMBOL_ENUM_NAME(name##_name), VM_SYMBOL_ENUM_NAME(signature), may_be_java },
|
||||
{ VM_CLASS_ID(klass), VM_SYMBOL_ENUM_NAME(name##_name), VM_SYMBOL_ENUM_NAME(signature), may_be_java },
|
||||
|
||||
InjectedField JavaClasses::_injected_fields[] = {
|
||||
ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD)
|
||||
@ -1310,7 +1311,7 @@ bool java_lang_Class::restore_archived_mirror(Klass *k,
|
||||
Handle class_loader, Handle module,
|
||||
Handle protection_domain, TRAPS) {
|
||||
// Postpone restoring archived mirror until java.lang.Class is loaded. Please
|
||||
// see more details in SystemDictionary::resolve_well_known_classes().
|
||||
// see more details in vmClasses::resolve_all().
|
||||
if (!SystemDictionary::Class_klass_loaded()) {
|
||||
assert(fixup_mirror_list() != NULL, "fixup_mirror_list not initialized");
|
||||
fixup_mirror_list()->push(k);
|
||||
@ -4916,7 +4917,7 @@ void JavaClasses::compute_offsets() {
|
||||
|
||||
// We have already called the compute_offsets() of the
|
||||
// BASIC_JAVA_CLASSES_DO_PART1 classes (java_lang_String, java_lang_Class and
|
||||
// java_lang_ref_Reference) earlier inside SystemDictionary::resolve_well_known_classes()
|
||||
// java_lang_ref_Reference) earlier inside vmClasses::resolve_all()
|
||||
BASIC_JAVA_CLASSES_DO_PART2(DO_COMPUTE_OFFSETS);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,6 +26,7 @@
|
||||
#define SHARE_CLASSFILE_JAVACLASSES_HPP
|
||||
|
||||
#include "classfile/systemDictionary.hpp"
|
||||
#include "classfile/vmClasses.hpp"
|
||||
#include "oops/oop.hpp"
|
||||
#include "oops/instanceKlass.hpp"
|
||||
#include "oops/symbol.hpp"
|
||||
@ -1717,13 +1718,13 @@ class java_lang_InternalError : AllStatic {
|
||||
|
||||
class InjectedField {
|
||||
public:
|
||||
const SystemDictionary::WKID klass_id;
|
||||
const VMClassID klass_id;
|
||||
const vmSymbolID name_index;
|
||||
const vmSymbolID signature_index;
|
||||
const bool may_be_java;
|
||||
|
||||
|
||||
Klass* klass() const { return SystemDictionary::well_known_klass(klass_id); }
|
||||
Klass* klass() const { return vmClasses::klass_at(klass_id); }
|
||||
Symbol* name() const { return lookup_symbol(name_index); }
|
||||
Symbol* signature() const { return lookup_symbol(signature_index); }
|
||||
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "classfile/stringTable.hpp"
|
||||
#include "classfile/symbolTable.hpp"
|
||||
#include "classfile/systemDictionary.hpp"
|
||||
#include "classfile/vmClasses.hpp"
|
||||
#include "classfile/vmSymbols.hpp"
|
||||
#include "code/codeCache.hpp"
|
||||
#include "gc/shared/gcTraceTime.inline.hpp"
|
||||
@ -57,7 +58,6 @@
|
||||
#include "memory/universe.hpp"
|
||||
#include "oops/access.inline.hpp"
|
||||
#include "oops/instanceKlass.hpp"
|
||||
#include "oops/instanceRefKlass.hpp"
|
||||
#include "oops/klass.inline.hpp"
|
||||
#include "oops/method.inline.hpp"
|
||||
#include "oops/objArrayKlass.hpp"
|
||||
@ -94,11 +94,6 @@ ResolutionErrorTable* SystemDictionary::_resolution_errors = NULL;
|
||||
SymbolPropertyTable* SystemDictionary::_invoke_method_table = NULL;
|
||||
ProtectionDomainCacheTable* SystemDictionary::_pd_cache_table = NULL;
|
||||
|
||||
InstanceKlass* SystemDictionary::_well_known_klasses[SystemDictionary::WKID_LIMIT]
|
||||
= { NULL /*, NULL...*/ };
|
||||
|
||||
InstanceKlass* SystemDictionary::_box_klasses[T_VOID+1] = { NULL /*, NULL...*/ };
|
||||
|
||||
OopHandle SystemDictionary::_java_system_loader;
|
||||
OopHandle SystemDictionary::_java_platform_loader;
|
||||
|
||||
@ -1418,36 +1413,6 @@ void SystemDictionary::load_shared_class_misc(InstanceKlass* ik, ClassLoaderData
|
||||
}
|
||||
}
|
||||
|
||||
void SystemDictionary::quick_resolve(InstanceKlass* klass, ClassLoaderData* loader_data, Handle domain, TRAPS) {
|
||||
assert(!Universe::is_fully_initialized(), "We can make short cuts only during VM initialization");
|
||||
assert(klass->is_shared(), "Must be shared class");
|
||||
if (klass->class_loader_data() != NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// add super and interfaces first
|
||||
Klass* super = klass->super();
|
||||
if (super != NULL && super->class_loader_data() == NULL) {
|
||||
assert(super->is_instance_klass(), "Super should be instance klass");
|
||||
quick_resolve(InstanceKlass::cast(super), loader_data, domain, CHECK);
|
||||
}
|
||||
|
||||
Array<InstanceKlass*>* ifs = klass->local_interfaces();
|
||||
for (int i = 0; i < ifs->length(); i++) {
|
||||
InstanceKlass* ik = ifs->at(i);
|
||||
if (ik->class_loader_data() == NULL) {
|
||||
quick_resolve(ik, loader_data, domain, CHECK);
|
||||
}
|
||||
}
|
||||
|
||||
klass->restore_unshareable_info(loader_data, domain, NULL, THREAD);
|
||||
load_shared_class_misc(klass, loader_data, CHECK);
|
||||
Dictionary* dictionary = loader_data->dictionary();
|
||||
unsigned int hash = dictionary->compute_hash(klass->name());
|
||||
dictionary->add_klass(hash, klass->name(), klass);
|
||||
add_to_hierarchy(klass);
|
||||
assert(klass->is_loaded(), "Must be in at least loaded state");
|
||||
}
|
||||
#endif // INCLUDE_CDS
|
||||
|
||||
InstanceKlass* SystemDictionary::load_instance_class(Symbol* class_name, Handle class_loader, TRAPS) {
|
||||
@ -1857,13 +1822,6 @@ bool SystemDictionary::do_unloading(GCTimer* gc_timer) {
|
||||
return unloading_occurred;
|
||||
}
|
||||
|
||||
// CDS: scan and relocate all classes referenced by _well_known_klasses[].
|
||||
void SystemDictionary::well_known_klasses_do(MetaspaceClosure* it) {
|
||||
for (int id = FIRST_WKID; id < WKID_LIMIT; id++) {
|
||||
it->push(well_known_klass_addr((WKID)id));
|
||||
}
|
||||
}
|
||||
|
||||
void SystemDictionary::methods_do(void f(Method*)) {
|
||||
// Walk methods in loaded classes
|
||||
MutexLocker ml(ClassLoaderDataGraph_lock);
|
||||
@ -1884,191 +1842,13 @@ void SystemDictionary::initialize(TRAPS) {
|
||||
_pd_cache_table = new ProtectionDomainCacheTable(defaultProtectionDomainCacheSize);
|
||||
|
||||
// Resolve basic classes
|
||||
resolve_well_known_classes(CHECK);
|
||||
vmClasses::resolve_all(CHECK);
|
||||
// Resolve classes used by archived heap objects
|
||||
if (UseSharedSpaces) {
|
||||
HeapShared::resolve_classes(CHECK);
|
||||
}
|
||||
}
|
||||
|
||||
// Compact table of directions on the initialization of klasses:
|
||||
// TODO: we should change the base type of vmSymbolID from int to short. Then we can declare this
|
||||
// array as vmSymbolID wk_init_info[] anf avoid all the type casts.
|
||||
static const short wk_init_info[] = {
|
||||
#define WK_KLASS_INIT_INFO(name, symbol) \
|
||||
((short)VM_SYMBOL_ENUM_NAME(symbol)),
|
||||
|
||||
WK_KLASSES_DO(WK_KLASS_INIT_INFO)
|
||||
#undef WK_KLASS_INIT_INFO
|
||||
0
|
||||
};
|
||||
|
||||
#ifdef ASSERT
|
||||
bool SystemDictionary::is_well_known_klass(Symbol* class_name) {
|
||||
int sid;
|
||||
for (int i = 0; (sid = wk_init_info[i]) != 0; i++) {
|
||||
Symbol* symbol = vmSymbols::symbol_at(vmSymbols::as_SID(sid));
|
||||
if (class_name == symbol) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SystemDictionary::is_well_known_klass(Klass* k) {
|
||||
return is_well_known_klass(k->name());
|
||||
}
|
||||
#endif
|
||||
|
||||
bool SystemDictionary::resolve_wk_klass(WKID id, TRAPS) {
|
||||
assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob");
|
||||
int sid = wk_init_info[id - FIRST_WKID];
|
||||
Symbol* symbol = vmSymbols::symbol_at(vmSymbols::as_SID(sid));
|
||||
InstanceKlass** klassp = &_well_known_klasses[id];
|
||||
|
||||
#if INCLUDE_CDS
|
||||
if (UseSharedSpaces && !JvmtiExport::should_post_class_prepare()) {
|
||||
InstanceKlass* k = *klassp;
|
||||
assert(k->is_shared_boot_class(), "must be");
|
||||
|
||||
ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
|
||||
quick_resolve(k, loader_data, Handle(), CHECK_false);
|
||||
return true;
|
||||
}
|
||||
#endif // INCLUDE_CDS
|
||||
|
||||
if (!is_wk_klass_loaded(*klassp)) {
|
||||
Klass* k = resolve_or_fail(symbol, true, CHECK_false);
|
||||
(*klassp) = InstanceKlass::cast(k);
|
||||
}
|
||||
return ((*klassp) != NULL);
|
||||
}
|
||||
|
||||
void SystemDictionary::resolve_wk_klasses_until(WKID limit_id, WKID &start_id, TRAPS) {
|
||||
assert((int)start_id <= (int)limit_id, "IDs are out of order!");
|
||||
for (int id = (int)start_id; id < (int)limit_id; id++) {
|
||||
assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob");
|
||||
resolve_wk_klass((WKID)id, CHECK);
|
||||
}
|
||||
|
||||
// move the starting value forward to the limit:
|
||||
start_id = limit_id;
|
||||
}
|
||||
|
||||
void SystemDictionary::resolve_well_known_classes(TRAPS) {
|
||||
assert(!Object_klass_loaded(), "well-known classes should only be initialized once");
|
||||
|
||||
// Create the ModuleEntry for java.base. This call needs to be done here,
|
||||
// after vmSymbols::initialize() is called but before any classes are pre-loaded.
|
||||
ClassLoader::classLoader_init2(CHECK);
|
||||
|
||||
// Preload commonly used klasses
|
||||
WKID scan = FIRST_WKID;
|
||||
// first do Object, then String, Class
|
||||
#if INCLUDE_CDS
|
||||
if (UseSharedSpaces) {
|
||||
resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(Object_klass), scan, CHECK);
|
||||
|
||||
// It's unsafe to access the archived heap regions before they
|
||||
// are fixed up, so we must do the fixup as early as possible
|
||||
// before the archived java objects are accessed by functions
|
||||
// such as java_lang_Class::restore_archived_mirror and
|
||||
// ConstantPool::restore_unshareable_info (restores the archived
|
||||
// resolved_references array object).
|
||||
//
|
||||
// HeapShared::fixup_mapped_heap_regions() fills the empty
|
||||
// spaces in the archived heap regions and may use
|
||||
// SystemDictionary::Object_klass(), so we can do this only after
|
||||
// Object_klass is resolved. See the above resolve_wk_klasses_through()
|
||||
// call. No mirror objects are accessed/restored in the above call.
|
||||
// Mirrors are restored after java.lang.Class is loaded.
|
||||
HeapShared::fixup_mapped_heap_regions();
|
||||
|
||||
// Initialize the constant pool for the Object_class
|
||||
assert(Object_klass()->is_shared(), "must be");
|
||||
Object_klass()->constants()->restore_unshareable_info(CHECK);
|
||||
resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(Class_klass), scan, CHECK);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(Class_klass), scan, CHECK);
|
||||
}
|
||||
|
||||
assert(WK_KLASS(Object_klass) != NULL, "well-known classes should now be initialized");
|
||||
|
||||
java_lang_Object::register_natives(CHECK);
|
||||
|
||||
// Calculate offsets for String and Class classes since they are loaded and
|
||||
// can be used after this point.
|
||||
java_lang_String::compute_offsets();
|
||||
java_lang_Class::compute_offsets();
|
||||
|
||||
// Fixup mirrors for classes loaded before java.lang.Class.
|
||||
Universe::initialize_basic_type_mirrors(CHECK);
|
||||
Universe::fixup_mirrors(CHECK);
|
||||
|
||||
// do a bunch more:
|
||||
resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(Reference_klass), scan, CHECK);
|
||||
|
||||
// The offsets for jlr.Reference must be computed before
|
||||
// InstanceRefKlass::update_nonstatic_oop_maps is called. That function uses
|
||||
// the offsets to remove the referent and discovered fields from the oop maps,
|
||||
// as they are treated in a special way by the GC. Removing these oops from the
|
||||
// oop maps must be done before the usual subclasses of jlr.Reference are loaded.
|
||||
java_lang_ref_Reference::compute_offsets();
|
||||
|
||||
// Preload ref klasses and set reference types
|
||||
WK_KLASS(Reference_klass)->set_reference_type(REF_OTHER);
|
||||
InstanceRefKlass::update_nonstatic_oop_maps(WK_KLASS(Reference_klass));
|
||||
|
||||
resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(PhantomReference_klass), scan, CHECK);
|
||||
WK_KLASS(SoftReference_klass)->set_reference_type(REF_SOFT);
|
||||
WK_KLASS(WeakReference_klass)->set_reference_type(REF_WEAK);
|
||||
WK_KLASS(FinalReference_klass)->set_reference_type(REF_FINAL);
|
||||
WK_KLASS(PhantomReference_klass)->set_reference_type(REF_PHANTOM);
|
||||
|
||||
// JSR 292 classes
|
||||
WKID jsr292_group_start = WK_KLASS_ENUM_NAME(MethodHandle_klass);
|
||||
WKID jsr292_group_end = WK_KLASS_ENUM_NAME(VolatileCallSite_klass);
|
||||
resolve_wk_klasses_until(jsr292_group_start, scan, CHECK);
|
||||
resolve_wk_klasses_through(jsr292_group_end, scan, CHECK);
|
||||
WKID last = WKID_LIMIT;
|
||||
resolve_wk_klasses_until(last, scan, CHECK);
|
||||
|
||||
_box_klasses[T_BOOLEAN] = WK_KLASS(Boolean_klass);
|
||||
_box_klasses[T_CHAR] = WK_KLASS(Character_klass);
|
||||
_box_klasses[T_FLOAT] = WK_KLASS(Float_klass);
|
||||
_box_klasses[T_DOUBLE] = WK_KLASS(Double_klass);
|
||||
_box_klasses[T_BYTE] = WK_KLASS(Byte_klass);
|
||||
_box_klasses[T_SHORT] = WK_KLASS(Short_klass);
|
||||
_box_klasses[T_INT] = WK_KLASS(Integer_klass);
|
||||
_box_klasses[T_LONG] = WK_KLASS(Long_klass);
|
||||
//_box_klasses[T_OBJECT] = WK_KLASS(object_klass);
|
||||
//_box_klasses[T_ARRAY] = WK_KLASS(object_klass);
|
||||
|
||||
#ifdef ASSERT
|
||||
if (UseSharedSpaces) {
|
||||
JVMTI_ONLY(assert(JvmtiExport::is_early_phase(),
|
||||
"All well known classes must be resolved in JVMTI early phase"));
|
||||
for (int i = FIRST_WKID; i < last; i++) {
|
||||
InstanceKlass* k = _well_known_klasses[i];
|
||||
assert(k->is_shared(), "must not be replaced by JVMTI class file load hook");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Tells if a given klass is a box (wrapper class, such as java.lang.Integer).
|
||||
// If so, returns the basic type it holds. If not, returns T_OBJECT.
|
||||
BasicType SystemDictionary::box_klass_type(Klass* k) {
|
||||
assert(k != NULL, "");
|
||||
for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
|
||||
if (_box_klasses[i] == k)
|
||||
return (BasicType)i;
|
||||
}
|
||||
return T_OBJECT;
|
||||
}
|
||||
|
||||
// Constraints on class loaders. The details of the algorithm can be
|
||||
// found in the OOPSLA'98 paper "Dynamic Class Loading in the Java
|
||||
// Virtual Machine" by Sheng Liang and Gilad Bracha. The basic idea is
|
||||
@ -2816,10 +2596,6 @@ ClassLoaderData* SystemDictionary::class_loader_data(Handle class_loader) {
|
||||
return ClassLoaderData::class_loader_data(class_loader());
|
||||
}
|
||||
|
||||
bool SystemDictionary::is_wk_klass_loaded(InstanceKlass* klass) {
|
||||
return !(klass == NULL || !klass->is_loaded());
|
||||
}
|
||||
|
||||
bool SystemDictionary::is_nonpublic_Object_method(Method* m) {
|
||||
assert(m != NULL, "Unexpected NULL Method*");
|
||||
return !m->is_public() && m->method_holder() == SystemDictionary::Object_klass();
|
||||
|
@ -25,6 +25,7 @@
|
||||
#ifndef SHARE_CLASSFILE_SYSTEMDICTIONARY_HPP
|
||||
#define SHARE_CLASSFILE_SYSTEMDICTIONARY_HPP
|
||||
|
||||
#include "classfile/vmClasses.hpp"
|
||||
#include "oops/oopHandle.hpp"
|
||||
#include "runtime/handles.hpp"
|
||||
#include "runtime/signature.hpp"
|
||||
@ -86,172 +87,15 @@ class EventClassLoad;
|
||||
class Symbol;
|
||||
class TableStatistics;
|
||||
|
||||
#define WK_KLASS_ENUM_NAME(kname) kname##_knum
|
||||
|
||||
// Certain classes, such as java.lang.Object and java.lang.String,
|
||||
// are "well-known", in the sense that no class loader is allowed
|
||||
// to provide a different definition.
|
||||
//
|
||||
// Each well-known class has a short klass name (like object_klass),
|
||||
// and a vmSymbol name (like java_lang_Object).
|
||||
//
|
||||
// The order of these definitions is significant: the classes are
|
||||
// resolved during early VM start-up by resolve_well_known_classes
|
||||
// in this order. Changing the order may require careful restructuring
|
||||
// of the VM start-up sequence.
|
||||
//
|
||||
#define WK_KLASSES_DO(do_klass) \
|
||||
/* well-known classes */ \
|
||||
do_klass(Object_klass, java_lang_Object ) \
|
||||
do_klass(String_klass, java_lang_String ) \
|
||||
do_klass(Class_klass, java_lang_Class ) \
|
||||
do_klass(Cloneable_klass, java_lang_Cloneable ) \
|
||||
do_klass(ClassLoader_klass, java_lang_ClassLoader ) \
|
||||
do_klass(Serializable_klass, java_io_Serializable ) \
|
||||
do_klass(System_klass, java_lang_System ) \
|
||||
do_klass(Throwable_klass, java_lang_Throwable ) \
|
||||
do_klass(Error_klass, java_lang_Error ) \
|
||||
do_klass(ThreadDeath_klass, java_lang_ThreadDeath ) \
|
||||
do_klass(Exception_klass, java_lang_Exception ) \
|
||||
do_klass(RuntimeException_klass, java_lang_RuntimeException ) \
|
||||
do_klass(SecurityManager_klass, java_lang_SecurityManager ) \
|
||||
do_klass(ProtectionDomain_klass, java_security_ProtectionDomain ) \
|
||||
do_klass(AccessControlContext_klass, java_security_AccessControlContext ) \
|
||||
do_klass(AccessController_klass, java_security_AccessController ) \
|
||||
do_klass(SecureClassLoader_klass, java_security_SecureClassLoader ) \
|
||||
do_klass(ClassNotFoundException_klass, java_lang_ClassNotFoundException ) \
|
||||
do_klass(Record_klass, java_lang_Record ) \
|
||||
do_klass(NoClassDefFoundError_klass, java_lang_NoClassDefFoundError ) \
|
||||
do_klass(LinkageError_klass, java_lang_LinkageError ) \
|
||||
do_klass(ClassCastException_klass, java_lang_ClassCastException ) \
|
||||
do_klass(ArrayStoreException_klass, java_lang_ArrayStoreException ) \
|
||||
do_klass(VirtualMachineError_klass, java_lang_VirtualMachineError ) \
|
||||
do_klass(InternalError_klass, java_lang_InternalError ) \
|
||||
do_klass(OutOfMemoryError_klass, java_lang_OutOfMemoryError ) \
|
||||
do_klass(StackOverflowError_klass, java_lang_StackOverflowError ) \
|
||||
do_klass(IllegalMonitorStateException_klass, java_lang_IllegalMonitorStateException ) \
|
||||
do_klass(Reference_klass, java_lang_ref_Reference ) \
|
||||
\
|
||||
/* ref klasses and set reference types */ \
|
||||
do_klass(SoftReference_klass, java_lang_ref_SoftReference ) \
|
||||
do_klass(WeakReference_klass, java_lang_ref_WeakReference ) \
|
||||
do_klass(FinalReference_klass, java_lang_ref_FinalReference ) \
|
||||
do_klass(PhantomReference_klass, java_lang_ref_PhantomReference ) \
|
||||
do_klass(Finalizer_klass, java_lang_ref_Finalizer ) \
|
||||
\
|
||||
do_klass(Thread_klass, java_lang_Thread ) \
|
||||
do_klass(ThreadGroup_klass, java_lang_ThreadGroup ) \
|
||||
do_klass(Properties_klass, java_util_Properties ) \
|
||||
do_klass(Module_klass, java_lang_Module ) \
|
||||
do_klass(reflect_AccessibleObject_klass, java_lang_reflect_AccessibleObject ) \
|
||||
do_klass(reflect_Field_klass, java_lang_reflect_Field ) \
|
||||
do_klass(reflect_Parameter_klass, java_lang_reflect_Parameter ) \
|
||||
do_klass(reflect_Method_klass, java_lang_reflect_Method ) \
|
||||
do_klass(reflect_Constructor_klass, java_lang_reflect_Constructor ) \
|
||||
\
|
||||
/* NOTE: needed too early in bootstrapping process to have checks based on JDK version */ \
|
||||
/* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \
|
||||
do_klass(reflect_MagicAccessorImpl_klass, reflect_MagicAccessorImpl ) \
|
||||
do_klass(reflect_MethodAccessorImpl_klass, reflect_MethodAccessorImpl ) \
|
||||
do_klass(reflect_ConstructorAccessorImpl_klass, reflect_ConstructorAccessorImpl ) \
|
||||
do_klass(reflect_DelegatingClassLoader_klass, reflect_DelegatingClassLoader ) \
|
||||
do_klass(reflect_ConstantPool_klass, reflect_ConstantPool ) \
|
||||
do_klass(reflect_UnsafeStaticFieldAccessorImpl_klass, reflect_UnsafeStaticFieldAccessorImpl ) \
|
||||
do_klass(reflect_CallerSensitive_klass, reflect_CallerSensitive ) \
|
||||
do_klass(reflect_NativeConstructorAccessorImpl_klass, reflect_NativeConstructorAccessorImpl ) \
|
||||
\
|
||||
/* support for dynamic typing; it's OK if these are NULL in earlier JDKs */ \
|
||||
do_klass(DirectMethodHandle_klass, java_lang_invoke_DirectMethodHandle ) \
|
||||
do_klass(MethodHandle_klass, java_lang_invoke_MethodHandle ) \
|
||||
do_klass(VarHandle_klass, java_lang_invoke_VarHandle ) \
|
||||
do_klass(MemberName_klass, java_lang_invoke_MemberName ) \
|
||||
do_klass(ResolvedMethodName_klass, java_lang_invoke_ResolvedMethodName ) \
|
||||
do_klass(MethodHandleNatives_klass, java_lang_invoke_MethodHandleNatives ) \
|
||||
do_klass(LambdaForm_klass, java_lang_invoke_LambdaForm ) \
|
||||
do_klass(MethodType_klass, java_lang_invoke_MethodType ) \
|
||||
do_klass(BootstrapMethodError_klass, java_lang_BootstrapMethodError ) \
|
||||
do_klass(CallSite_klass, java_lang_invoke_CallSite ) \
|
||||
do_klass(NativeEntryPoint_klass, jdk_internal_invoke_NativeEntryPoint ) \
|
||||
do_klass(Context_klass, java_lang_invoke_MethodHandleNatives_CallSiteContext ) \
|
||||
do_klass(ConstantCallSite_klass, java_lang_invoke_ConstantCallSite ) \
|
||||
do_klass(MutableCallSite_klass, java_lang_invoke_MutableCallSite ) \
|
||||
do_klass(VolatileCallSite_klass, java_lang_invoke_VolatileCallSite ) \
|
||||
/* Note: MethodHandle must be first, and VolatileCallSite last in group */ \
|
||||
\
|
||||
do_klass(AssertionStatusDirectives_klass, java_lang_AssertionStatusDirectives ) \
|
||||
do_klass(StringBuffer_klass, java_lang_StringBuffer ) \
|
||||
do_klass(StringBuilder_klass, java_lang_StringBuilder ) \
|
||||
do_klass(UnsafeConstants_klass, jdk_internal_misc_UnsafeConstants ) \
|
||||
do_klass(internal_Unsafe_klass, jdk_internal_misc_Unsafe ) \
|
||||
do_klass(module_Modules_klass, jdk_internal_module_Modules ) \
|
||||
\
|
||||
/* support for CDS */ \
|
||||
do_klass(ByteArrayInputStream_klass, java_io_ByteArrayInputStream ) \
|
||||
do_klass(URL_klass, java_net_URL ) \
|
||||
do_klass(Jar_Manifest_klass, java_util_jar_Manifest ) \
|
||||
do_klass(jdk_internal_loader_BuiltinClassLoader_klass,jdk_internal_loader_BuiltinClassLoader ) \
|
||||
do_klass(jdk_internal_loader_ClassLoaders_klass, jdk_internal_loader_ClassLoaders ) \
|
||||
do_klass(jdk_internal_loader_ClassLoaders_AppClassLoader_klass, jdk_internal_loader_ClassLoaders_AppClassLoader) \
|
||||
do_klass(jdk_internal_loader_ClassLoaders_PlatformClassLoader_klass, jdk_internal_loader_ClassLoaders_PlatformClassLoader) \
|
||||
do_klass(CodeSource_klass, java_security_CodeSource ) \
|
||||
do_klass(ConcurrentHashMap_klass, java_util_concurrent_ConcurrentHashMap ) \
|
||||
do_klass(ArrayList_klass, java_util_ArrayList ) \
|
||||
\
|
||||
do_klass(StackTraceElement_klass, java_lang_StackTraceElement ) \
|
||||
\
|
||||
/* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \
|
||||
do_klass(nio_Buffer_klass, java_nio_Buffer ) \
|
||||
\
|
||||
/* Stack Walking */ \
|
||||
do_klass(StackWalker_klass, java_lang_StackWalker ) \
|
||||
do_klass(AbstractStackWalker_klass, java_lang_StackStreamFactory_AbstractStackWalker ) \
|
||||
do_klass(StackFrameInfo_klass, java_lang_StackFrameInfo ) \
|
||||
do_klass(LiveStackFrameInfo_klass, java_lang_LiveStackFrameInfo ) \
|
||||
\
|
||||
/* support for stack dump lock analysis */ \
|
||||
do_klass(java_util_concurrent_locks_AbstractOwnableSynchronizer_klass, java_util_concurrent_locks_AbstractOwnableSynchronizer) \
|
||||
\
|
||||
/* boxing klasses */ \
|
||||
do_klass(Boolean_klass, java_lang_Boolean ) \
|
||||
do_klass(Character_klass, java_lang_Character ) \
|
||||
do_klass(Float_klass, java_lang_Float ) \
|
||||
do_klass(Double_klass, java_lang_Double ) \
|
||||
do_klass(Byte_klass, java_lang_Byte ) \
|
||||
do_klass(Short_klass, java_lang_Short ) \
|
||||
do_klass(Integer_klass, java_lang_Integer ) \
|
||||
do_klass(Long_klass, java_lang_Long ) \
|
||||
\
|
||||
/* force inline of iterators */ \
|
||||
do_klass(Iterator_klass, java_util_Iterator ) \
|
||||
\
|
||||
/* support for records */ \
|
||||
do_klass(RecordComponent_klass, java_lang_reflect_RecordComponent ) \
|
||||
\
|
||||
/* support for vectors*/ \
|
||||
do_klass(vector_VectorSupport_klass, jdk_internal_vm_vector_VectorSupport ) \
|
||||
do_klass(vector_VectorPayload_klass, jdk_internal_vm_vector_VectorPayload ) \
|
||||
do_klass(vector_Vector_klass, jdk_internal_vm_vector_Vector ) \
|
||||
do_klass(vector_VectorMask_klass, jdk_internal_vm_vector_VectorMask ) \
|
||||
do_klass(vector_VectorShuffle_klass, jdk_internal_vm_vector_VectorShuffle ) \
|
||||
\
|
||||
/*end*/
|
||||
|
||||
class SystemDictionary : AllStatic {
|
||||
// TMP: subclass from vmClasses so that we can still access the VM classes like
|
||||
// SystemDictionary::Object_klass(). This will be fixed when we replace all SystemDictionary::*_klass()
|
||||
// calls with vmClasses::*_klass().
|
||||
class SystemDictionary : public vmClasses {
|
||||
friend class BootstrapInfo;
|
||||
friend class vmClasses;
|
||||
friend class VMStructs;
|
||||
|
||||
public:
|
||||
enum WKID {
|
||||
NO_WKID = 0,
|
||||
|
||||
#define WK_KLASS_ENUM(name, symbol) WK_KLASS_ENUM_NAME(name), WK_KLASS_ENUM_NAME(symbol) = WK_KLASS_ENUM_NAME(name),
|
||||
WK_KLASSES_DO(WK_KLASS_ENUM)
|
||||
#undef WK_KLASS_ENUM
|
||||
|
||||
WKID_LIMIT,
|
||||
|
||||
FIRST_WKID = NO_WKID + 1
|
||||
};
|
||||
|
||||
// Returns a class with a given class name and class loader. Loads the
|
||||
// class if needed. If not found a NoClassDefFoundError or a
|
||||
@ -365,67 +209,12 @@ public:
|
||||
// Initialization
|
||||
static void initialize(TRAPS);
|
||||
|
||||
// Checked fast access to the well-known classes -- so that you don't try to use them
|
||||
// before they are resolved.
|
||||
static InstanceKlass* check_klass(InstanceKlass* k) {
|
||||
assert(k != NULL, "klass not loaded");
|
||||
return k;
|
||||
}
|
||||
|
||||
static bool resolve_wk_klass(WKID id, TRAPS);
|
||||
static void resolve_wk_klasses_until(WKID limit_id, WKID &start_id, TRAPS);
|
||||
static void resolve_wk_klasses_through(WKID end_id, WKID &start_id, TRAPS) {
|
||||
int limit = (int)end_id + 1;
|
||||
resolve_wk_klasses_until((WKID) limit, start_id, THREAD);
|
||||
}
|
||||
public:
|
||||
#define WK_KLASS(name) _well_known_klasses[SystemDictionary::WK_KLASS_ENUM_NAME(name)]
|
||||
|
||||
#define WK_KLASS_DECLARE(name, symbol) \
|
||||
static InstanceKlass* name() { return check_klass(_well_known_klasses[WK_KLASS_ENUM_NAME(name)]); } \
|
||||
static InstanceKlass** name##_addr() { \
|
||||
return &_well_known_klasses[SystemDictionary::WK_KLASS_ENUM_NAME(name)]; \
|
||||
} \
|
||||
static bool name##_is_loaded() { \
|
||||
return is_wk_klass_loaded(WK_KLASS(name)); \
|
||||
}
|
||||
WK_KLASSES_DO(WK_KLASS_DECLARE);
|
||||
#undef WK_KLASS_DECLARE
|
||||
|
||||
static InstanceKlass* well_known_klass(WKID id) {
|
||||
assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob");
|
||||
return _well_known_klasses[id];
|
||||
}
|
||||
|
||||
static InstanceKlass** well_known_klass_addr(WKID id) {
|
||||
assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob");
|
||||
return &_well_known_klasses[id];
|
||||
}
|
||||
static void well_known_klasses_do(MetaspaceClosure* it);
|
||||
|
||||
static InstanceKlass* box_klass(BasicType t) {
|
||||
assert((uint)t < T_VOID+1, "range check");
|
||||
return check_klass(_box_klasses[t]);
|
||||
}
|
||||
static BasicType box_klass_type(Klass* k); // inverse of box_klass
|
||||
#ifdef ASSERT
|
||||
static bool is_well_known_klass(Klass* k);
|
||||
static bool is_well_known_klass(Symbol* class_name);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
// Returns the class loader data to be used when looking up/updating the
|
||||
// system dictionary.
|
||||
static ClassLoaderData *class_loader_data(Handle class_loader);
|
||||
static bool is_wk_klass_loaded(InstanceKlass* klass);
|
||||
|
||||
public:
|
||||
static bool Object_klass_loaded() { return is_wk_klass_loaded(WK_KLASS(Object_klass)); }
|
||||
static bool Class_klass_loaded() { return is_wk_klass_loaded(WK_KLASS(Class_klass)); }
|
||||
static bool Cloneable_klass_loaded() { return is_wk_klass_loaded(WK_KLASS(Cloneable_klass)); }
|
||||
static bool Parameter_klass_loaded() { return is_wk_klass_loaded(WK_KLASS(reflect_Parameter_klass)); }
|
||||
static bool ClassLoader_klass_loaded() { return is_wk_klass_loaded(WK_KLASS(ClassLoader_klass)); }
|
||||
|
||||
// Returns java system loader
|
||||
static oop java_system_loader();
|
||||
|
||||
@ -638,11 +427,6 @@ protected:
|
||||
// Basic find on classes in the midst of being loaded
|
||||
static Symbol* find_placeholder(Symbol* name, ClassLoaderData* loader_data);
|
||||
|
||||
// Resolve well-known classes so they can be used like SystemDictionary::String_klass()
|
||||
static void resolve_well_known_classes(TRAPS);
|
||||
// quick resolve using CDS for well-known classes only.
|
||||
static void quick_resolve(InstanceKlass* klass, ClassLoaderData* loader_data, Handle domain, TRAPS) NOT_CDS_RETURN;
|
||||
|
||||
// Class loader constraints
|
||||
static void check_constraints(unsigned int hash,
|
||||
InstanceKlass* k, Handle loader,
|
||||
@ -650,11 +434,6 @@ protected:
|
||||
static void update_dictionary(unsigned int hash,
|
||||
InstanceKlass* k, Handle loader);
|
||||
|
||||
static InstanceKlass* _well_known_klasses[];
|
||||
|
||||
// table of box klasses (int_klass, etc.)
|
||||
static InstanceKlass* _box_klasses[T_VOID+1];
|
||||
|
||||
private:
|
||||
static OopHandle _java_system_loader;
|
||||
static OopHandle _java_platform_loader;
|
||||
|
@ -2178,9 +2178,9 @@ void SystemDictionaryShared::serialize_dictionary_headers(SerializeClosure* soc,
|
||||
}
|
||||
}
|
||||
|
||||
void SystemDictionaryShared::serialize_well_known_klasses(SerializeClosure* soc) {
|
||||
for (int i = FIRST_WKID; i < WKID_LIMIT; i++) {
|
||||
soc->do_ptr((void**)&_well_known_klasses[i]);
|
||||
void SystemDictionaryShared::serialize_vm_classes(SerializeClosure* soc) {
|
||||
for (auto id : EnumRange<VMClassID>{}) {
|
||||
soc->do_ptr((void**)klass_addr_at(id));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -316,7 +316,7 @@ public:
|
||||
static void adjust_lambda_proxy_class_dictionary();
|
||||
static void serialize_dictionary_headers(class SerializeClosure* soc,
|
||||
bool is_static_archive = true);
|
||||
static void serialize_well_known_klasses(class SerializeClosure* soc);
|
||||
static void serialize_vm_classes(class SerializeClosure* soc);
|
||||
static void print() { return print_on(tty); }
|
||||
static void print_on(outputStream* st) NOT_CDS_RETURN;
|
||||
static void print_table_statistics(outputStream* st) NOT_CDS_RETURN;
|
||||
|
43
src/hotspot/share/classfile/vmClassID.hpp
Normal file
43
src/hotspot/share/classfile/vmClassID.hpp
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SHARE_CLASSFILE_VMCLASSID_HPP
|
||||
#define SHARE_CLASSFILE_VMCLASSID_HPP
|
||||
|
||||
#include "classfile/vmClassMacros.hpp"
|
||||
#include "utilities/enumIterator.hpp"
|
||||
|
||||
enum class VMClassID : int {
|
||||
#define DECLARE_VM_CLASS(name, symbol) _VM_CLASS_ENUM(name), _VM_CLASS_ENUM(symbol) = _VM_CLASS_ENUM(name),
|
||||
VM_CLASSES_DO(DECLARE_VM_CLASS)
|
||||
#undef DECLARE_VM_CLASS
|
||||
|
||||
LIMIT, // exclusive upper limit
|
||||
FIRST = 0, // inclusive upper limit
|
||||
LAST = LIMIT - 1 // inclusive upper limit
|
||||
};
|
||||
|
||||
ENUMERATOR_RANGE(VMClassID, VMClassID::FIRST, VMClassID::LAST) // (inclusive start, inclusive end)
|
||||
|
||||
#endif // SHARE_CLASSFILE_VMCLASSID_HPP
|
187
src/hotspot/share/classfile/vmClassMacros.hpp
Normal file
187
src/hotspot/share/classfile/vmClassMacros.hpp
Normal file
@ -0,0 +1,187 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SHARE_CLASSFILE_VMCLASSMACROS_HPP
|
||||
#define SHARE_CLASSFILE_VMCLASSMACROS_HPP
|
||||
|
||||
// _VM_CLASS_ENUM - internal: should be used only by VMClass*.{hpp,cpp}
|
||||
#define _VM_CLASS_ENUM(kname) kname##_knum
|
||||
|
||||
#define VM_CLASS_ID(kname) VMClassID::_VM_CLASS_ENUM(kname)
|
||||
|
||||
// VM_CLASSES_DO iterates the classes that are directly referenced
|
||||
// by the VM, suhch as java.lang.Object and java.lang.String. These
|
||||
// classes are resolved at VM bootstrap, before any Java code is executed,
|
||||
// so no class loader is able to provide a different definition.
|
||||
//
|
||||
// Each VM class has a short klass name (like Object_klass),
|
||||
// and a vmSymbol name (like java_lang_Object). Both of these can
|
||||
// be used to find the VMClassID for this class. The following two
|
||||
// macros will evaluate to the same value:
|
||||
//
|
||||
// VM_CLASS_ID(Object_klass)
|
||||
// VM_CLASS_ID(java_lang_Object)
|
||||
//
|
||||
// The order of these definitions is significant: the classes are
|
||||
// resolved by vmClasses::resolve_all() in this order. Changing the
|
||||
// order may require careful restructuring of the VM start-up sequence.
|
||||
//
|
||||
#define VM_CLASSES_DO(do_klass) \
|
||||
/* well-known classes */ \
|
||||
do_klass(Object_klass, java_lang_Object ) \
|
||||
do_klass(String_klass, java_lang_String ) \
|
||||
do_klass(Class_klass, java_lang_Class ) \
|
||||
do_klass(Cloneable_klass, java_lang_Cloneable ) \
|
||||
do_klass(ClassLoader_klass, java_lang_ClassLoader ) \
|
||||
do_klass(Serializable_klass, java_io_Serializable ) \
|
||||
do_klass(System_klass, java_lang_System ) \
|
||||
do_klass(Throwable_klass, java_lang_Throwable ) \
|
||||
do_klass(Error_klass, java_lang_Error ) \
|
||||
do_klass(ThreadDeath_klass, java_lang_ThreadDeath ) \
|
||||
do_klass(Exception_klass, java_lang_Exception ) \
|
||||
do_klass(RuntimeException_klass, java_lang_RuntimeException ) \
|
||||
do_klass(SecurityManager_klass, java_lang_SecurityManager ) \
|
||||
do_klass(ProtectionDomain_klass, java_security_ProtectionDomain ) \
|
||||
do_klass(AccessControlContext_klass, java_security_AccessControlContext ) \
|
||||
do_klass(AccessController_klass, java_security_AccessController ) \
|
||||
do_klass(SecureClassLoader_klass, java_security_SecureClassLoader ) \
|
||||
do_klass(ClassNotFoundException_klass, java_lang_ClassNotFoundException ) \
|
||||
do_klass(Record_klass, java_lang_Record ) \
|
||||
do_klass(NoClassDefFoundError_klass, java_lang_NoClassDefFoundError ) \
|
||||
do_klass(LinkageError_klass, java_lang_LinkageError ) \
|
||||
do_klass(ClassCastException_klass, java_lang_ClassCastException ) \
|
||||
do_klass(ArrayStoreException_klass, java_lang_ArrayStoreException ) \
|
||||
do_klass(VirtualMachineError_klass, java_lang_VirtualMachineError ) \
|
||||
do_klass(InternalError_klass, java_lang_InternalError ) \
|
||||
do_klass(OutOfMemoryError_klass, java_lang_OutOfMemoryError ) \
|
||||
do_klass(StackOverflowError_klass, java_lang_StackOverflowError ) \
|
||||
do_klass(IllegalMonitorStateException_klass, java_lang_IllegalMonitorStateException ) \
|
||||
do_klass(Reference_klass, java_lang_ref_Reference ) \
|
||||
\
|
||||
/* ref klasses and set reference types */ \
|
||||
do_klass(SoftReference_klass, java_lang_ref_SoftReference ) \
|
||||
do_klass(WeakReference_klass, java_lang_ref_WeakReference ) \
|
||||
do_klass(FinalReference_klass, java_lang_ref_FinalReference ) \
|
||||
do_klass(PhantomReference_klass, java_lang_ref_PhantomReference ) \
|
||||
do_klass(Finalizer_klass, java_lang_ref_Finalizer ) \
|
||||
\
|
||||
do_klass(Thread_klass, java_lang_Thread ) \
|
||||
do_klass(ThreadGroup_klass, java_lang_ThreadGroup ) \
|
||||
do_klass(Properties_klass, java_util_Properties ) \
|
||||
do_klass(Module_klass, java_lang_Module ) \
|
||||
do_klass(reflect_AccessibleObject_klass, java_lang_reflect_AccessibleObject ) \
|
||||
do_klass(reflect_Field_klass, java_lang_reflect_Field ) \
|
||||
do_klass(reflect_Parameter_klass, java_lang_reflect_Parameter ) \
|
||||
do_klass(reflect_Method_klass, java_lang_reflect_Method ) \
|
||||
do_klass(reflect_Constructor_klass, java_lang_reflect_Constructor ) \
|
||||
\
|
||||
/* NOTE: needed too early in bootstrapping process to have checks based on JDK version */ \
|
||||
/* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \
|
||||
do_klass(reflect_MagicAccessorImpl_klass, reflect_MagicAccessorImpl ) \
|
||||
do_klass(reflect_MethodAccessorImpl_klass, reflect_MethodAccessorImpl ) \
|
||||
do_klass(reflect_ConstructorAccessorImpl_klass, reflect_ConstructorAccessorImpl ) \
|
||||
do_klass(reflect_DelegatingClassLoader_klass, reflect_DelegatingClassLoader ) \
|
||||
do_klass(reflect_ConstantPool_klass, reflect_ConstantPool ) \
|
||||
do_klass(reflect_UnsafeStaticFieldAccessorImpl_klass, reflect_UnsafeStaticFieldAccessorImpl ) \
|
||||
do_klass(reflect_CallerSensitive_klass, reflect_CallerSensitive ) \
|
||||
do_klass(reflect_NativeConstructorAccessorImpl_klass, reflect_NativeConstructorAccessorImpl ) \
|
||||
\
|
||||
/* support for dynamic typing; it's OK if these are NULL in earlier JDKs */ \
|
||||
do_klass(DirectMethodHandle_klass, java_lang_invoke_DirectMethodHandle ) \
|
||||
do_klass(MethodHandle_klass, java_lang_invoke_MethodHandle ) \
|
||||
do_klass(VarHandle_klass, java_lang_invoke_VarHandle ) \
|
||||
do_klass(MemberName_klass, java_lang_invoke_MemberName ) \
|
||||
do_klass(ResolvedMethodName_klass, java_lang_invoke_ResolvedMethodName ) \
|
||||
do_klass(MethodHandleNatives_klass, java_lang_invoke_MethodHandleNatives ) \
|
||||
do_klass(LambdaForm_klass, java_lang_invoke_LambdaForm ) \
|
||||
do_klass(MethodType_klass, java_lang_invoke_MethodType ) \
|
||||
do_klass(BootstrapMethodError_klass, java_lang_BootstrapMethodError ) \
|
||||
do_klass(CallSite_klass, java_lang_invoke_CallSite ) \
|
||||
do_klass(NativeEntryPoint_klass, jdk_internal_invoke_NativeEntryPoint ) \
|
||||
do_klass(Context_klass, java_lang_invoke_MethodHandleNatives_CallSiteContext ) \
|
||||
do_klass(ConstantCallSite_klass, java_lang_invoke_ConstantCallSite ) \
|
||||
do_klass(MutableCallSite_klass, java_lang_invoke_MutableCallSite ) \
|
||||
do_klass(VolatileCallSite_klass, java_lang_invoke_VolatileCallSite ) \
|
||||
/* Note: MethodHandle must be first, and VolatileCallSite last in group */ \
|
||||
\
|
||||
do_klass(AssertionStatusDirectives_klass, java_lang_AssertionStatusDirectives ) \
|
||||
do_klass(StringBuffer_klass, java_lang_StringBuffer ) \
|
||||
do_klass(StringBuilder_klass, java_lang_StringBuilder ) \
|
||||
do_klass(UnsafeConstants_klass, jdk_internal_misc_UnsafeConstants ) \
|
||||
do_klass(internal_Unsafe_klass, jdk_internal_misc_Unsafe ) \
|
||||
do_klass(module_Modules_klass, jdk_internal_module_Modules ) \
|
||||
\
|
||||
/* support for CDS */ \
|
||||
do_klass(ByteArrayInputStream_klass, java_io_ByteArrayInputStream ) \
|
||||
do_klass(URL_klass, java_net_URL ) \
|
||||
do_klass(Jar_Manifest_klass, java_util_jar_Manifest ) \
|
||||
do_klass(jdk_internal_loader_BuiltinClassLoader_klass,jdk_internal_loader_BuiltinClassLoader ) \
|
||||
do_klass(jdk_internal_loader_ClassLoaders_klass, jdk_internal_loader_ClassLoaders ) \
|
||||
do_klass(jdk_internal_loader_ClassLoaders_AppClassLoader_klass, jdk_internal_loader_ClassLoaders_AppClassLoader) \
|
||||
do_klass(jdk_internal_loader_ClassLoaders_PlatformClassLoader_klass, jdk_internal_loader_ClassLoaders_PlatformClassLoader) \
|
||||
do_klass(CodeSource_klass, java_security_CodeSource ) \
|
||||
do_klass(ConcurrentHashMap_klass, java_util_concurrent_ConcurrentHashMap ) \
|
||||
do_klass(ArrayList_klass, java_util_ArrayList ) \
|
||||
\
|
||||
do_klass(StackTraceElement_klass, java_lang_StackTraceElement ) \
|
||||
\
|
||||
/* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \
|
||||
do_klass(nio_Buffer_klass, java_nio_Buffer ) \
|
||||
\
|
||||
/* Stack Walking */ \
|
||||
do_klass(StackWalker_klass, java_lang_StackWalker ) \
|
||||
do_klass(AbstractStackWalker_klass, java_lang_StackStreamFactory_AbstractStackWalker ) \
|
||||
do_klass(StackFrameInfo_klass, java_lang_StackFrameInfo ) \
|
||||
do_klass(LiveStackFrameInfo_klass, java_lang_LiveStackFrameInfo ) \
|
||||
\
|
||||
/* support for stack dump lock analysis */ \
|
||||
do_klass(java_util_concurrent_locks_AbstractOwnableSynchronizer_klass, java_util_concurrent_locks_AbstractOwnableSynchronizer) \
|
||||
\
|
||||
/* boxing klasses */ \
|
||||
do_klass(Boolean_klass, java_lang_Boolean ) \
|
||||
do_klass(Character_klass, java_lang_Character ) \
|
||||
do_klass(Float_klass, java_lang_Float ) \
|
||||
do_klass(Double_klass, java_lang_Double ) \
|
||||
do_klass(Byte_klass, java_lang_Byte ) \
|
||||
do_klass(Short_klass, java_lang_Short ) \
|
||||
do_klass(Integer_klass, java_lang_Integer ) \
|
||||
do_klass(Long_klass, java_lang_Long ) \
|
||||
\
|
||||
/* force inline of iterators */ \
|
||||
do_klass(Iterator_klass, java_util_Iterator ) \
|
||||
\
|
||||
/* support for records */ \
|
||||
do_klass(RecordComponent_klass, java_lang_reflect_RecordComponent ) \
|
||||
\
|
||||
/* support for vectors*/ \
|
||||
do_klass(vector_VectorSupport_klass, jdk_internal_vm_vector_VectorSupport ) \
|
||||
do_klass(vector_VectorPayload_klass, jdk_internal_vm_vector_VectorPayload ) \
|
||||
do_klass(vector_Vector_klass, jdk_internal_vm_vector_Vector ) \
|
||||
do_klass(vector_VectorMask_klass, jdk_internal_vm_vector_VectorMask ) \
|
||||
do_klass(vector_VectorShuffle_klass, jdk_internal_vm_vector_VectorShuffle ) \
|
||||
\
|
||||
/*end*/
|
||||
|
||||
#endif // SHARE_CLASSFILE_VMCLASSMACROS_HPP
|
||||
|
261
src/hotspot/share/classfile/vmClasses.cpp
Normal file
261
src/hotspot/share/classfile/vmClasses.cpp
Normal file
@ -0,0 +1,261 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "classfile/classLoader.hpp"
|
||||
#include "classfile/classLoaderData.hpp"
|
||||
#include "classfile/dictionary.hpp"
|
||||
#include "classfile/systemDictionary.hpp"
|
||||
#include "classfile/vmClasses.hpp"
|
||||
#include "classfile/vmSymbols.hpp"
|
||||
#include "memory/heapShared.hpp"
|
||||
#include "memory/metaspaceClosure.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
#include "oops/instanceKlass.hpp"
|
||||
#include "oops/instanceRefKlass.hpp"
|
||||
#include "prims/jvmtiExport.hpp"
|
||||
#include "runtime/globals.hpp"
|
||||
|
||||
InstanceKlass* vmClasses::_klasses[static_cast<int>(VMClassID::LIMIT)]
|
||||
= { NULL /*, NULL...*/ };
|
||||
InstanceKlass* vmClasses::_box_klasses[T_VOID+1] = { NULL /*, NULL...*/ };
|
||||
|
||||
|
||||
// CDS: scan and relocate all classes referenced by _klasses[].
|
||||
void vmClasses::metaspace_pointers_do(MetaspaceClosure* it) {
|
||||
for (auto id : EnumRange<VMClassID>{}) {
|
||||
it->push(klass_addr_at(id));
|
||||
}
|
||||
}
|
||||
|
||||
bool vmClasses::is_loaded(InstanceKlass* klass) {
|
||||
return klass != NULL && klass->is_loaded();
|
||||
}
|
||||
|
||||
// Compact table of the vmSymbolIDs of all the VM classes (stored as short to save space)
|
||||
static const short vm_class_name_ids[] = {
|
||||
#define VM_CLASS_NAME(name, symbol) ((short)VM_SYMBOL_ENUM_NAME(symbol)),
|
||||
VM_CLASSES_DO(VM_CLASS_NAME)
|
||||
#undef VM_CLASS_NAME
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
#ifdef ASSERT
|
||||
bool vmClasses::contain(Symbol* class_name) {
|
||||
int sid;
|
||||
for (int i = 0; (sid = vm_class_name_ids[i]) != 0; i++) {
|
||||
Symbol* symbol = vmSymbols::symbol_at(vmSymbols::as_SID(sid));
|
||||
if (class_name == symbol) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool vmClasses::contain(Klass* k) {
|
||||
return contain(k->name());
|
||||
}
|
||||
#endif
|
||||
|
||||
bool vmClasses::resolve(VMClassID id, TRAPS) {
|
||||
InstanceKlass** klassp = &_klasses[as_int(id)];
|
||||
|
||||
#if INCLUDE_CDS
|
||||
if (UseSharedSpaces && !JvmtiExport::should_post_class_prepare()) {
|
||||
InstanceKlass* k = *klassp;
|
||||
assert(k->is_shared_boot_class(), "must be");
|
||||
|
||||
ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
|
||||
resolve_shared_class(k, loader_data, Handle(), CHECK_false);
|
||||
return true;
|
||||
}
|
||||
#endif // INCLUDE_CDS
|
||||
|
||||
if (!is_loaded(*klassp)) {
|
||||
int sid = vm_class_name_ids[as_int(id)];
|
||||
Symbol* symbol = vmSymbols::symbol_at(vmSymbols::as_SID(sid));
|
||||
Klass* k = SystemDictionary::resolve_or_fail(symbol, true, CHECK_false);
|
||||
(*klassp) = InstanceKlass::cast(k);
|
||||
}
|
||||
return ((*klassp) != NULL);
|
||||
}
|
||||
|
||||
void vmClasses::resolve_until(VMClassID limit_id, VMClassID &start_id, TRAPS) {
|
||||
assert((int)start_id <= (int)limit_id, "IDs are out of order!");
|
||||
for (auto id : EnumRange<VMClassID>{start_id, limit_id}) { // (inclusive start, exclusive end)
|
||||
resolve(id, CHECK);
|
||||
}
|
||||
|
||||
// move the starting value forward to the limit:
|
||||
start_id = limit_id;
|
||||
}
|
||||
|
||||
void vmClasses::resolve_all(TRAPS) {
|
||||
assert(!Object_klass_loaded(), "well-known classes should only be initialized once");
|
||||
|
||||
// Create the ModuleEntry for java.base. This call needs to be done here,
|
||||
// after vmSymbols::initialize() is called but before any classes are pre-loaded.
|
||||
ClassLoader::classLoader_init2(CHECK);
|
||||
|
||||
// Preload commonly used klasses
|
||||
VMClassID scan = VMClassID::FIRST;
|
||||
// first do Object, then String, Class
|
||||
#if INCLUDE_CDS
|
||||
if (UseSharedSpaces) {
|
||||
resolve_through(VM_CLASS_ID(Object_klass), scan, CHECK);
|
||||
|
||||
// It's unsafe to access the archived heap regions before they
|
||||
// are fixed up, so we must do the fixup as early as possible
|
||||
// before the archived java objects are accessed by functions
|
||||
// such as java_lang_Class::restore_archived_mirror and
|
||||
// ConstantPool::restore_unshareable_info (restores the archived
|
||||
// resolved_references array object).
|
||||
//
|
||||
// HeapShared::fixup_mapped_heap_regions() fills the empty
|
||||
// spaces in the archived heap regions and may use
|
||||
// SystemDictionary::Object_klass(), so we can do this only after
|
||||
// Object_klass is resolved. See the above resolve_through()
|
||||
// call. No mirror objects are accessed/restored in the above call.
|
||||
// Mirrors are restored after java.lang.Class is loaded.
|
||||
HeapShared::fixup_mapped_heap_regions();
|
||||
|
||||
// Initialize the constant pool for the Object_class
|
||||
assert(Object_klass()->is_shared(), "must be");
|
||||
Object_klass()->constants()->restore_unshareable_info(CHECK);
|
||||
resolve_through(VM_CLASS_ID(Class_klass), scan, CHECK);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
resolve_through(VM_CLASS_ID(Class_klass), scan, CHECK);
|
||||
}
|
||||
|
||||
assert(vmClasses::Object_klass() != NULL, "well-known classes should now be initialized");
|
||||
|
||||
java_lang_Object::register_natives(CHECK);
|
||||
|
||||
// Calculate offsets for String and Class classes since they are loaded and
|
||||
// can be used after this point.
|
||||
java_lang_String::compute_offsets();
|
||||
java_lang_Class::compute_offsets();
|
||||
|
||||
// Fixup mirrors for classes loaded before java.lang.Class.
|
||||
Universe::initialize_basic_type_mirrors(CHECK);
|
||||
Universe::fixup_mirrors(CHECK);
|
||||
|
||||
// do a bunch more:
|
||||
resolve_through(VM_CLASS_ID(Reference_klass), scan, CHECK);
|
||||
|
||||
// The offsets for jlr.Reference must be computed before
|
||||
// InstanceRefKlass::update_nonstatic_oop_maps is called. That function uses
|
||||
// the offsets to remove the referent and discovered fields from the oop maps,
|
||||
// as they are treated in a special way by the GC. Removing these oops from the
|
||||
// oop maps must be done before the usual subclasses of jlr.Reference are loaded.
|
||||
java_lang_ref_Reference::compute_offsets();
|
||||
|
||||
// Preload ref klasses and set reference types
|
||||
vmClasses::Reference_klass()->set_reference_type(REF_OTHER);
|
||||
InstanceRefKlass::update_nonstatic_oop_maps(vmClasses::Reference_klass());
|
||||
|
||||
resolve_through(VM_CLASS_ID(PhantomReference_klass), scan, CHECK);
|
||||
vmClasses::SoftReference_klass()->set_reference_type(REF_SOFT);
|
||||
vmClasses::WeakReference_klass()->set_reference_type(REF_WEAK);
|
||||
vmClasses::FinalReference_klass()->set_reference_type(REF_FINAL);
|
||||
vmClasses::PhantomReference_klass()->set_reference_type(REF_PHANTOM);
|
||||
|
||||
// JSR 292 classes
|
||||
VMClassID jsr292_group_start = VM_CLASS_ID(MethodHandle_klass);
|
||||
VMClassID jsr292_group_end = VM_CLASS_ID(VolatileCallSite_klass);
|
||||
resolve_until(jsr292_group_start, scan, CHECK);
|
||||
resolve_through(jsr292_group_end, scan, CHECK);
|
||||
resolve_until(VMClassID::LIMIT, scan, CHECK);
|
||||
|
||||
_box_klasses[T_BOOLEAN] = vmClasses::Boolean_klass();
|
||||
_box_klasses[T_CHAR] = vmClasses::Character_klass();
|
||||
_box_klasses[T_FLOAT] = vmClasses::Float_klass();
|
||||
_box_klasses[T_DOUBLE] = vmClasses::Double_klass();
|
||||
_box_klasses[T_BYTE] = vmClasses::Byte_klass();
|
||||
_box_klasses[T_SHORT] = vmClasses::Short_klass();
|
||||
_box_klasses[T_INT] = vmClasses::Integer_klass();
|
||||
_box_klasses[T_LONG] = vmClasses::Long_klass();
|
||||
//_box_klasses[T_OBJECT] = vmClasses::object_klass();
|
||||
//_box_klasses[T_ARRAY] = vmClasses::object_klass();
|
||||
|
||||
#ifdef ASSERT
|
||||
if (UseSharedSpaces) {
|
||||
JVMTI_ONLY(assert(JvmtiExport::is_early_phase(),
|
||||
"All well known classes must be resolved in JVMTI early phase"));
|
||||
for (auto id : EnumRange<VMClassID>{}) {
|
||||
InstanceKlass* k = _klasses[as_int(id)];
|
||||
assert(k->is_shared(), "must not be replaced by JVMTI class file load hook");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if INCLUDE_CDS
|
||||
|
||||
void vmClasses::resolve_shared_class(InstanceKlass* klass, ClassLoaderData* loader_data, Handle domain, TRAPS) {
|
||||
assert(!Universe::is_fully_initialized(), "We can make short cuts only during VM initialization");
|
||||
assert(klass->is_shared(), "Must be shared class");
|
||||
if (klass->class_loader_data() != NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// add super and interfaces first
|
||||
Klass* super = klass->super();
|
||||
if (super != NULL && super->class_loader_data() == NULL) {
|
||||
assert(super->is_instance_klass(), "Super should be instance klass");
|
||||
resolve_shared_class(InstanceKlass::cast(super), loader_data, domain, CHECK);
|
||||
}
|
||||
|
||||
Array<InstanceKlass*>* ifs = klass->local_interfaces();
|
||||
for (int i = 0; i < ifs->length(); i++) {
|
||||
InstanceKlass* ik = ifs->at(i);
|
||||
if (ik->class_loader_data() == NULL) {
|
||||
resolve_shared_class(ik, loader_data, domain, CHECK);
|
||||
}
|
||||
}
|
||||
|
||||
klass->restore_unshareable_info(loader_data, domain, NULL, THREAD);
|
||||
SystemDictionary::load_shared_class_misc(klass, loader_data, CHECK);
|
||||
Dictionary* dictionary = loader_data->dictionary();
|
||||
unsigned int hash = dictionary->compute_hash(klass->name());
|
||||
dictionary->add_klass(hash, klass->name(), klass);
|
||||
SystemDictionary::add_to_hierarchy(klass);
|
||||
assert(klass->is_loaded(), "Must be in at least loaded state");
|
||||
}
|
||||
|
||||
#endif // INCLUDE_CDS
|
||||
|
||||
// Tells if a given klass is a box (wrapper class, such as java.lang.Integer).
|
||||
// If so, returns the basic type it holds. If not, returns T_OBJECT.
|
||||
BasicType vmClasses::box_klass_type(Klass* k) {
|
||||
assert(k != NULL, "");
|
||||
for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
|
||||
if (_box_klasses[i] == k)
|
||||
return (BasicType)i;
|
||||
}
|
||||
return T_OBJECT;
|
||||
}
|
115
src/hotspot/share/classfile/vmClasses.hpp
Normal file
115
src/hotspot/share/classfile/vmClasses.hpp
Normal file
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SHARE_CLASSFILE_VMCLASSES_HPP
|
||||
#define SHARE_CLASSFILE_VMCLASSES_HPP
|
||||
|
||||
#include "classfile/vmClassID.hpp"
|
||||
#include "memory/allStatic.hpp"
|
||||
#include "runtime/handles.hpp"
|
||||
#include "utilities/exceptions.hpp"
|
||||
|
||||
class ClassLoaderData;
|
||||
class InstanceKlass;
|
||||
class MetaspaceClosure;
|
||||
|
||||
class vmClasses : AllStatic {
|
||||
friend class VMStructs;
|
||||
|
||||
static VMClassID check_id(VMClassID id) {
|
||||
assert((int)id >= (int)VMClassID::FIRST && (int)id < (int)VMClassID::LIMIT, "oob");
|
||||
return id;
|
||||
}
|
||||
|
||||
static int as_int(VMClassID id) {
|
||||
return static_cast<int>(check_id(id));
|
||||
}
|
||||
|
||||
static VMClassID as_id(int i) {
|
||||
VMClassID id = static_cast<VMClassID>(i);
|
||||
return check_id(id);
|
||||
}
|
||||
|
||||
static InstanceKlass* check_klass(InstanceKlass* k) {
|
||||
assert(k != NULL, "klass not loaded");
|
||||
return k;
|
||||
}
|
||||
|
||||
static bool is_loaded(InstanceKlass* klass);
|
||||
static bool resolve(VMClassID id, TRAPS);
|
||||
static void resolve_until(VMClassID limit_id, VMClassID &start_id, TRAPS);
|
||||
static void resolve_through(VMClassID last_id, VMClassID &start_id, TRAPS) {
|
||||
int limit = as_int(last_id) + 1;
|
||||
resolve_until(as_id(limit), start_id, THREAD);
|
||||
}
|
||||
|
||||
static void resolve_shared_class(InstanceKlass* klass, ClassLoaderData* loader_data, Handle domain, TRAPS) NOT_CDS_RETURN;
|
||||
|
||||
#ifdef ASSERT
|
||||
static bool contain(Klass* k);
|
||||
static bool contain(Symbol* class_name);
|
||||
#endif
|
||||
|
||||
static InstanceKlass* _klasses[];
|
||||
|
||||
// table of box klasses (int_klass, etc.)
|
||||
static InstanceKlass* _box_klasses[];
|
||||
|
||||
// VM_CLASS_AT should be used by vmClasses.cpp and vmStructs.cpp only.
|
||||
#define VM_CLASS_AT(name) _klasses[static_cast<int>(VM_CLASS_ID(name))]
|
||||
|
||||
public:
|
||||
#define _VM_CLASS_DECLARE(name, symbol) \
|
||||
static InstanceKlass* name() { return check_klass(VM_CLASS_AT(name)); } \
|
||||
static InstanceKlass** name##_addr() { return &VM_CLASS_AT(name); } \
|
||||
static bool name##_is_loaded() { return is_loaded(VM_CLASS_AT(name)); }
|
||||
VM_CLASSES_DO(_VM_CLASS_DECLARE);
|
||||
#undef _VM_CLASS_DECLARE
|
||||
|
||||
static InstanceKlass* klass_at(VMClassID id) {
|
||||
return _klasses[as_int(id)];
|
||||
}
|
||||
|
||||
static InstanceKlass** klass_addr_at(VMClassID id) {
|
||||
return &_klasses[as_int(id)];
|
||||
}
|
||||
|
||||
static void metaspace_pointers_do(MetaspaceClosure* it);
|
||||
static void resolve_all(TRAPS);
|
||||
|
||||
static BasicType box_klass_type(Klass* k); // inverse of box_klass
|
||||
|
||||
static InstanceKlass* box_klass(BasicType t) {
|
||||
assert((uint)t < T_VOID+1, "range check");
|
||||
return check_klass(_box_klasses[t]);
|
||||
}
|
||||
|
||||
static bool Object_klass_loaded() { return is_loaded(VM_CLASS_AT(Object_klass)); }
|
||||
static bool Class_klass_loaded() { return is_loaded(VM_CLASS_AT(Class_klass)); }
|
||||
static bool Cloneable_klass_loaded() { return is_loaded(VM_CLASS_AT(Cloneable_klass)); }
|
||||
static bool Parameter_klass_loaded() { return is_loaded(VM_CLASS_AT(reflect_Parameter_klass)); }
|
||||
static bool ClassLoader_klass_loaded() { return is_loaded(VM_CLASS_AT(ClassLoader_klass)); }
|
||||
};
|
||||
|
||||
#endif // SHARE_CLASSFILE_VMCLASSES_HPP
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,7 @@
|
||||
#include "precompiled.hpp"
|
||||
#include "classfile/classLoaderDataShared.hpp"
|
||||
#include "classfile/systemDictionaryShared.hpp"
|
||||
#include "classfile/vmClasses.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "logging/logStream.hpp"
|
||||
#include "memory/allStatic.hpp"
|
||||
@ -580,14 +581,14 @@ void ArchiveBuilder::relocate_pointers() {
|
||||
log_info(cds)("done");
|
||||
}
|
||||
|
||||
// We must relocate the System::_well_known_klasses only after we have copied the
|
||||
// We must relocate vmClasses::_klasses[] only after we have copied the
|
||||
// java objects in during dump_java_heap_objects(): during the object copy, we operate on
|
||||
// old objects which assert that their klass is the original klass.
|
||||
void ArchiveBuilder::relocate_well_known_klasses() {
|
||||
log_info(cds)("Relocating SystemDictionary::_well_known_klasses[] ... ");
|
||||
void ArchiveBuilder::relocate_vm_classes() {
|
||||
log_info(cds)("Relocating vmClasses::_klasses[] ... ");
|
||||
ResourceMark rm;
|
||||
RefRelocator doit(this);
|
||||
SystemDictionary::well_known_klasses_do(&doit);
|
||||
vmClasses::metaspace_pointers_do(&doit);
|
||||
}
|
||||
|
||||
void ArchiveBuilder::make_klasses_shareable() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -245,7 +245,7 @@ public:
|
||||
void dump_rw_region();
|
||||
void dump_ro_region();
|
||||
void relocate_pointers();
|
||||
void relocate_well_known_klasses();
|
||||
void relocate_vm_classes();
|
||||
void make_klasses_shareable();
|
||||
void write_cds_map_to_log(FileMapInfo* mapinfo,
|
||||
GrowableArray<MemRegion> *closed_heap_regions,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -31,6 +31,7 @@
|
||||
#include "classfile/classLoaderExt.hpp"
|
||||
#include "classfile/symbolTable.hpp"
|
||||
#include "classfile/systemDictionaryShared.hpp"
|
||||
#include "classfile/vmClasses.hpp"
|
||||
#include "classfile/vmSymbols.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "logging/logStream.hpp"
|
||||
@ -2035,9 +2036,10 @@ void FileMapInfo::patch_archived_heap_embedded_pointers(MemRegion* ranges, int n
|
||||
}
|
||||
}
|
||||
|
||||
// This internally allocates objects using SystemDictionary::Object_klass(), so it
|
||||
// must be called after the well-known classes are resolved.
|
||||
// This internally allocates objects using vmClasses::Object_klass(), so it
|
||||
// must be called after the Object_klass is loaded
|
||||
void FileMapInfo::fixup_mapped_heap_regions() {
|
||||
assert(vmClasses::Object_klass_loaded(), "must be");
|
||||
// If any closed regions were found, call the fill routine to make them parseable.
|
||||
// Note that closed_archive_heap_ranges may be non-NULL even if no ranges were found.
|
||||
if (num_closed_archive_heap_ranges != 0) {
|
||||
@ -2149,7 +2151,7 @@ bool FileMapInfo::initialize() {
|
||||
assert(UseSharedSpaces, "UseSharedSpaces expected.");
|
||||
|
||||
if (JvmtiExport::should_post_class_file_load_hook() && JvmtiExport::has_early_class_hook_env()) {
|
||||
// CDS assumes that no classes resolved in SystemDictionary::resolve_well_known_classes
|
||||
// CDS assumes that no classes resolved in vmClasses::resolve_all()
|
||||
// are replaced at runtime by JVMTI ClassFileLoadHook. All of those classes are resolved
|
||||
// during the JVMTI "early" stage, so we can still use CDS if
|
||||
// JvmtiExport::has_early_class_hook_env() is false.
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "classfile/stringTable.hpp"
|
||||
#include "classfile/systemDictionary.hpp"
|
||||
#include "classfile/systemDictionaryShared.hpp"
|
||||
#include "classfile/vmClasses.hpp"
|
||||
#include "classfile/vmSymbols.hpp"
|
||||
#include "code/codeCache.hpp"
|
||||
#include "gc/shared/gcVMOperations.hpp"
|
||||
@ -500,7 +501,7 @@ void MetaspaceShared::serialize(SerializeClosure* soc) {
|
||||
InstanceMirrorKlass::serialize_offsets(soc);
|
||||
|
||||
// Dump/restore well known classes (pointers)
|
||||
SystemDictionaryShared::serialize_well_known_klasses(soc);
|
||||
SystemDictionaryShared::serialize_vm_classes(soc);
|
||||
soc->do_tag(--tag);
|
||||
|
||||
CppVtables::serialize(soc);
|
||||
@ -780,7 +781,7 @@ void VM_PopulateDumpSharedSpace::doit() {
|
||||
_open_archive_heap_regions = NULL;
|
||||
dump_java_heap_objects();
|
||||
|
||||
builder.relocate_well_known_klasses();
|
||||
builder.relocate_vm_classes();
|
||||
|
||||
log_info(cds)("Update method trampolines");
|
||||
builder.update_method_trampolines();
|
||||
@ -848,7 +849,7 @@ void VM_PopulateDumpSharedSpace::doit() {
|
||||
}
|
||||
|
||||
// There may be pending VM operations. We have changed some global states
|
||||
// (such as SystemDictionary::_well_known_klasses) that may cause these VM operations
|
||||
// (such as vmClasses::_klasses) that may cause these VM operations
|
||||
// to fail. For safety, forget these operations and exit the VM directly.
|
||||
vm_direct_exit(0);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -83,6 +83,7 @@ class Universe: AllStatic {
|
||||
friend class VM_PopulateDumpSharedSpace;
|
||||
friend class Metaspace;
|
||||
friend class MetaspaceShared;
|
||||
friend class vmClasses;
|
||||
|
||||
friend jint universe_init();
|
||||
friend void universe2_init();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "classfile/systemDictionary.hpp"
|
||||
#include "runtime/handles.inline.hpp"
|
||||
#include "jfr/support/jfrIntrinsics.hpp"
|
||||
#include "opto/c2compiler.hpp"
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "classfile/javaClasses.inline.hpp"
|
||||
#include "classfile/stringTable.hpp"
|
||||
#include "classfile/symbolTable.hpp"
|
||||
#include "classfile/vmClasses.hpp"
|
||||
#include "code/codeCache.hpp"
|
||||
#include "code/dependencyContext.hpp"
|
||||
#include "compiler/compileBroker.hpp"
|
||||
@ -480,15 +481,13 @@ vmIntrinsics::ID MethodHandles::signature_polymorphic_name_id(Symbol* name) {
|
||||
}
|
||||
|
||||
// Cover the case of invokeExact and any future variants of invokeFoo.
|
||||
Klass* mh_klass = SystemDictionary::well_known_klass(
|
||||
SystemDictionary::WK_KLASS_ENUM_NAME(MethodHandle_klass) );
|
||||
Klass* mh_klass = vmClasses::klass_at(VM_CLASS_ID(MethodHandle_klass));
|
||||
if (mh_klass != NULL && is_method_handle_invoke_name(mh_klass, name)) {
|
||||
return vmIntrinsics::_invokeGeneric;
|
||||
}
|
||||
|
||||
// Cover the case of methods on VarHandle.
|
||||
Klass* vh_klass = SystemDictionary::well_known_klass(
|
||||
SystemDictionary::WK_KLASS_ENUM_NAME(VarHandle_klass) );
|
||||
Klass* vh_klass = vmClasses::klass_at(VM_CLASS_ID(VarHandle_klass));
|
||||
if (vh_klass != NULL && is_method_handle_invoke_name(vh_klass, name)) {
|
||||
return vmIntrinsics::_invokeGeneric;
|
||||
}
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "classfile/stringTable.hpp"
|
||||
#include "classfile/symbolTable.hpp"
|
||||
#include "classfile/systemDictionary.hpp"
|
||||
#include "classfile/vmClasses.hpp"
|
||||
#include "classfile/vmSymbols.hpp"
|
||||
#include "code/codeBlob.hpp"
|
||||
#include "code/codeCache.hpp"
|
||||
@ -459,14 +460,14 @@ typedef HashtableEntry<InstanceKlass*, mtClass> KlassHashtableEntry;
|
||||
/* SystemDictionary */ \
|
||||
/********************/ \
|
||||
\
|
||||
static_field(SystemDictionary, WK_KLASS(Object_klass), InstanceKlass*) \
|
||||
static_field(SystemDictionary, WK_KLASS(String_klass), InstanceKlass*) \
|
||||
static_field(SystemDictionary, WK_KLASS(Class_klass), InstanceKlass*) \
|
||||
static_field(SystemDictionary, WK_KLASS(ClassLoader_klass), InstanceKlass*) \
|
||||
static_field(SystemDictionary, WK_KLASS(System_klass), InstanceKlass*) \
|
||||
static_field(SystemDictionary, WK_KLASS(Thread_klass), InstanceKlass*) \
|
||||
static_field(SystemDictionary, WK_KLASS(ThreadGroup_klass), InstanceKlass*) \
|
||||
static_field(SystemDictionary, WK_KLASS(MethodHandle_klass), InstanceKlass*) \
|
||||
static_field(vmClasses, VM_CLASS_AT(Object_klass), InstanceKlass*) \
|
||||
static_field(vmClasses, VM_CLASS_AT(String_klass), InstanceKlass*) \
|
||||
static_field(vmClasses, VM_CLASS_AT(Class_klass), InstanceKlass*) \
|
||||
static_field(vmClasses, VM_CLASS_AT(ClassLoader_klass), InstanceKlass*) \
|
||||
static_field(vmClasses, VM_CLASS_AT(System_klass), InstanceKlass*) \
|
||||
static_field(vmClasses, VM_CLASS_AT(Thread_klass), InstanceKlass*) \
|
||||
static_field(vmClasses, VM_CLASS_AT(ThreadGroup_klass), InstanceKlass*) \
|
||||
static_field(vmClasses, VM_CLASS_AT(MethodHandle_klass), InstanceKlass*) \
|
||||
\
|
||||
/*************/ \
|
||||
/* vmSymbols */ \
|
||||
@ -1325,6 +1326,7 @@ typedef HashtableEntry<InstanceKlass*, mtClass> KlassHashtableEntry;
|
||||
declare_type(DictionaryEntry, KlassHashtableEntry) \
|
||||
declare_toplevel_type(HashtableBucket<mtInternal>) \
|
||||
declare_toplevel_type(SystemDictionary) \
|
||||
declare_toplevel_type(vmClasses) \
|
||||
declare_toplevel_type(vmSymbols) \
|
||||
\
|
||||
declare_toplevel_type(GrowableArrayBase) \
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -32,6 +32,7 @@
|
||||
enum class JavaThreadStatus : int;
|
||||
enum class JVMFlagOrigin : int;
|
||||
enum JVMFlagsEnum : int;
|
||||
enum class VMClassID : int;
|
||||
enum class vmIntrinsicID : int;
|
||||
enum class vmSymbolID : int;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -52,25 +52,32 @@ public class SystemDictionary {
|
||||
}
|
||||
|
||||
private static synchronized void initialize(TypeDataBase db) {
|
||||
Type type = db.lookupType("SystemDictionary");
|
||||
Type type = db.lookupType("vmClasses");
|
||||
|
||||
objectKlassField = type.getAddressField(WK_KLASS("Object_klass"));
|
||||
classLoaderKlassField = type.getAddressField(WK_KLASS("ClassLoader_klass"));
|
||||
stringKlassField = type.getAddressField(WK_KLASS("String_klass"));
|
||||
systemKlassField = type.getAddressField(WK_KLASS("System_klass"));
|
||||
threadKlassField = type.getAddressField(WK_KLASS("Thread_klass"));
|
||||
threadGroupKlassField = type.getAddressField(WK_KLASS("ThreadGroup_klass"));
|
||||
methodHandleKlassField = type.getAddressField(WK_KLASS("MethodHandle_klass"));
|
||||
// Note, vmStructs contains a field with the name "_klasses[static_cast<int>(VMClassID::Object_klass_knum)]"
|
||||
objectKlassField = type.getAddressField(VM_CLASS_AT("Object_klass"));
|
||||
classLoaderKlassField = type.getAddressField(VM_CLASS_AT("ClassLoader_klass"));
|
||||
stringKlassField = type.getAddressField(VM_CLASS_AT("String_klass"));
|
||||
systemKlassField = type.getAddressField(VM_CLASS_AT("System_klass"));
|
||||
threadKlassField = type.getAddressField(VM_CLASS_AT("Thread_klass"));
|
||||
threadGroupKlassField = type.getAddressField(VM_CLASS_AT("ThreadGroup_klass"));
|
||||
methodHandleKlassField = type.getAddressField(VM_CLASS_AT("MethodHandle_klass"));
|
||||
}
|
||||
|
||||
// This WK functions must follow the definitions in systemDictionary.hpp:
|
||||
private static String WK_KLASS(String name) {
|
||||
//#define WK_KLASS(name) _well_known_klasses[SystemDictionary::WK_KLASS_ENUM_NAME(name)]
|
||||
return ("_well_known_klasses[SystemDictionary::"+WK_KLASS_ENUM_NAME(name)+"]");
|
||||
// The following 3 methods must match the corresponding macros in vmClassMacros.hpp and vmClasses.hpp.
|
||||
private static String _VM_CLASS_ENUM(String kname) {
|
||||
// #define _VM_CLASS_ENUM(kname) kname##_knum
|
||||
return (kname+"_knum");
|
||||
}
|
||||
private static String WK_KLASS_ENUM_NAME(String kname) {
|
||||
//#define WK_KLASS_ENUM_NAME(kname) kname##_knum
|
||||
return (kname+"_knum");
|
||||
|
||||
private static String VM_CLASS_ID(String kname) {
|
||||
// #define VM_CLASS_ID(kname) VMClassID::_VM_CLASS_ENUM(kname)
|
||||
return "VMClassID::" + _VM_CLASS_ENUM(kname);
|
||||
}
|
||||
|
||||
private static String VM_CLASS_AT(String name) {
|
||||
// #define VM_CLASS_AT(name) _klasses[static_cast<int>(VM_CLASS_ID(name))]
|
||||
return "_klasses[static_cast<int>(" + VM_CLASS_ID(name) + ")]";
|
||||
}
|
||||
|
||||
// few well known classes -- not all are added here.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -60,11 +60,6 @@ public class ClhsdbPrintStatics {
|
||||
"ClassLoaderDataGraph::_head",
|
||||
"JNIHandles::_weak_global_handles", "PerfMemory::_top",
|
||||
"java_lang_Class::_oop_size_offset"));
|
||||
expStrMap.put("printstatics SystemDictionary", List.of(
|
||||
"Static fields of SystemDictionary",
|
||||
"SystemDictionary::Class_klass_knum",
|
||||
"SystemDictionary::ClassLoader_klass_knum",
|
||||
"SystemDictionary::Object_klass_knum"));
|
||||
expStrMap.put("printstatics Threads", List.of(
|
||||
"Static fields of Threads",
|
||||
"_number_of_threads", "_number_of_non_daemon_threads"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user