Skip to content

Commit

Permalink
8260467: Move well-known classes from systemDictionary.hpp to vmClass…
Browse files Browse the repository at this point in the history
…es.hpp

Reviewed-by: dholmes, coleenp
  • Loading branch information
iklam committed Jan 28, 2021
1 parent 62ffe75 commit 396a496
Show file tree
Hide file tree
Showing 35 changed files with 752 additions and 573 deletions.
13 changes: 7 additions & 6 deletions src/hotspot/cpu/aarch64/methodHandles_aarch64.cpp
@@ -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.
*
Expand All @@ -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"
Expand All @@ -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()));
}
Expand All @@ -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;
Expand Down Expand Up @@ -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.");
}

Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/cpu/aarch64/methodHandles_aarch64.hpp
@@ -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.
*
Expand Down Expand Up @@ -36,11 +36,11 @@ enum /* platform_dependent_constants */ {
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");
}

Expand Down
11 changes: 6 additions & 5 deletions src/hotspot/cpu/arm/methodHandles_arm.cpp
Expand Up @@ -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"
Expand All @@ -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()));
Expand All @@ -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);
Expand Down Expand Up @@ -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.");
}

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/arm/methodHandles_arm.hpp
@@ -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
Expand Down Expand Up @@ -35,7 +35,7 @@ enum /* platform_dependent_constants */ {
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;
Expand Down
11 changes: 6 additions & 5 deletions src/hotspot/cpu/ppc/methodHandles_ppc.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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.");
}
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/cpu/ppc/methodHandles_ppc.hpp
@@ -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.
*
Expand Down Expand Up @@ -36,13 +36,13 @@ enum /* platform_dependent_constants */ {
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");
}
Expand Down
11 changes: 6 additions & 5 deletions src/hotspot/cpu/s390/methodHandles_s390.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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()));
Expand All @@ -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!");
Expand Down Expand Up @@ -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.");
}
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/cpu/s390/methodHandles_s390.hpp
@@ -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.
*
Expand Down Expand Up @@ -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");
}
Expand Down
11 changes: 6 additions & 5 deletions src/hotspot/cpu/x86/methodHandles_x86.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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()));
}
Expand All @@ -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
Expand Down Expand Up @@ -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.");
}

Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/cpu/x86/methodHandles_x86.hpp
@@ -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
Expand Down Expand Up @@ -35,11 +35,11 @@ enum /* platform_dependent_constants */ {
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");
}

Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/ci/ciEnv.cpp
@@ -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
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 8 additions & 8 deletions src/hotspot/share/ci/ciEnv.hpp
@@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -84,9 +84,9 @@ class ciEnv : StackObj {
// 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;
Expand Down Expand Up @@ -383,12 +383,12 @@ class ciEnv : StackObj {


// 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");
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/ci/ciObjArrayKlass.cpp
@@ -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
Expand Down Expand Up @@ -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
Expand Down

1 comment on commit 396a496

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.