Skip to content

Commit

Permalink
8227370: Remove SharedPathsMiscInfo
Browse files Browse the repository at this point in the history
Reviewed-by: ccheung, jiangli
  • Loading branch information
iklam committed Aug 28, 2019
1 parent 11ca73d commit 87eefe2
Show file tree
Hide file tree
Showing 16 changed files with 406 additions and 617 deletions.
52 changes: 6 additions & 46 deletions src/hotspot/share/classfile/classLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@
#include "utilities/events.hpp"
#include "utilities/hashtable.inline.hpp"
#include "utilities/macros.hpp"
#if INCLUDE_CDS
#include "classfile/sharedPathsMiscInfo.hpp"
#endif

// Entry points in zip.dll for loading zip/jar file entries

Expand Down Expand Up @@ -147,7 +144,6 @@ ClassPathEntry* ClassLoader::_app_classpath_entries = NULL;
ClassPathEntry* ClassLoader::_last_app_classpath_entry = NULL;
ClassPathEntry* ClassLoader::_module_path_entries = NULL;
ClassPathEntry* ClassLoader::_last_module_path_entry = NULL;
SharedPathsMiscInfo* ClassLoader::_shared_paths_misc_info = NULL;
#endif

// helper routines
Expand Down Expand Up @@ -250,13 +246,12 @@ PackageEntry* ClassLoader::get_package_entry(const char* class_name, ClassLoader
return pkgEntryTable->lookup_only(pkg_symbol);
}

ClassPathDirEntry::ClassPathDirEntry(const char* dir) : ClassPathEntry() {
char* copy = NEW_C_HEAP_ARRAY(char, strlen(dir)+1, mtClass);
strcpy(copy, dir);
_dir = copy;
const char* ClassPathEntry::copy_path(const char* path) {
char* copy = NEW_C_HEAP_ARRAY(char, strlen(path)+1, mtClass);
strcpy(copy, path);
return copy;
}


ClassFileStream* ClassPathDirEntry::open_stream(const char* name, TRAPS) {
// construct full path name
assert((_dir != NULL) && (name != NULL), "sanity");
Expand Down Expand Up @@ -296,9 +291,7 @@ ClassFileStream* ClassPathDirEntry::open_stream(const char* name, TRAPS) {
ClassPathZipEntry::ClassPathZipEntry(jzfile* zip, const char* zip_name,
bool is_boot_append, bool from_class_path_attr) : ClassPathEntry() {
_zip = zip;
char *copy = NEW_C_HEAP_ARRAY(char, strlen(zip_name)+1, mtClass);
strcpy(copy, zip_name);
_zip_name = copy;
_zip_name = copy_path(zip_name);
_from_class_path_attr = from_class_path_attr;
}

Expand Down Expand Up @@ -383,8 +376,7 @@ ClassPathImageEntry::ClassPathImageEntry(JImageFile* jimage, const char* name) :
assert(_singleton == NULL, "VM supports only one jimage");
DEBUG_ONLY(_singleton = this);
size_t len = strlen(name) + 1;
_name = NEW_C_HEAP_ARRAY(const char, len, mtClass);
strncpy((char *)_name, name, len);
_name = copy_path(name);
}

ClassPathImageEntry::~ClassPathImageEntry() {
Expand Down Expand Up @@ -537,30 +529,10 @@ void ClassLoader::setup_bootstrap_search_path() {
} else {
trace_class_path("bootstrap loader class path=", sys_class_path);
}
#if INCLUDE_CDS
if (DumpSharedSpaces || DynamicDumpSharedSpaces) {
_shared_paths_misc_info->add_boot_classpath(sys_class_path);
}
#endif
setup_boot_search_path(sys_class_path);
}

#if INCLUDE_CDS
int ClassLoader::get_shared_paths_misc_info_size() {
return _shared_paths_misc_info->get_used_bytes();
}

void* ClassLoader::get_shared_paths_misc_info() {
return _shared_paths_misc_info->buffer();
}

bool ClassLoader::check_shared_paths_misc_info(void *buf, int size, bool is_static) {
SharedPathsMiscInfo* checker = new SharedPathsMiscInfo((char*)buf, size);
bool result = checker->check(is_static);
delete checker;
return result;
}

void ClassLoader::setup_app_search_path(const char *class_path) {
assert(DumpSharedSpaces || DynamicDumpSharedSpaces, "Sanity");

Expand Down Expand Up @@ -943,11 +915,6 @@ bool ClassLoader::update_class_path_entry_list(const char *path,
}
return true;
} else {
#if INCLUDE_CDS
if (DumpSharedSpaces || DynamicDumpSharedSpaces) {
_shared_paths_misc_info->add_nonexist_path(path);
}
#endif
return false;
}
}
Expand Down Expand Up @@ -1567,20 +1534,13 @@ void ClassLoader::initialize() {
load_zip_library();
// lookup jimage library entry points
load_jimage_library();
#if INCLUDE_CDS
// initialize search path
if (DumpSharedSpaces || DynamicDumpSharedSpaces) {
_shared_paths_misc_info = new SharedPathsMiscInfo();
}
#endif
setup_bootstrap_search_path();
}

#if INCLUDE_CDS
void ClassLoader::initialize_shared_path() {
if (DumpSharedSpaces || DynamicDumpSharedSpaces) {
ClassLoaderExt::setup_search_paths();
_shared_paths_misc_info->write_jint(0); // see comments in SharedPathsMiscInfo::check()
}
}

Expand Down
35 changes: 10 additions & 25 deletions src/hotspot/share/classfile/classLoader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,19 @@ template <typename T> class GrowableArray;
class ClassPathEntry : public CHeapObj<mtClass> {
private:
ClassPathEntry* volatile _next;
protected:
const char* copy_path(const char*path);
public:
ClassPathEntry* next() const;
virtual ~ClassPathEntry() {}
void set_next(ClassPathEntry* next);
virtual bool is_modules_image() const = 0;
virtual bool is_jar_file() const = 0;
virtual bool is_modules_image() const { return false; }
virtual bool is_jar_file() const { return false; }
// Is this entry created from the "Class-path" attribute from a JAR Manifest?
virtual bool from_class_path_attr() const = 0;
virtual bool from_class_path_attr() const { return false; }
virtual const char* name() const = 0;
virtual JImageFile* jimage() const = 0;
virtual void close_jimage() = 0;
virtual JImageFile* jimage() const { return NULL; }
virtual void close_jimage() {}
// Constructor
ClassPathEntry() : _next(NULL) {}
// Attempt to locate file_name through this class path entry.
Expand All @@ -73,18 +75,14 @@ class ClassPathDirEntry: public ClassPathEntry {
private:
const char* _dir; // Name of directory
public:
bool is_modules_image() const { return false; }
bool is_jar_file() const { return false; }
bool from_class_path_attr() const { return false; }
const char* name() const { return _dir; }
JImageFile* jimage() const { return NULL; }
void close_jimage() {}
ClassPathDirEntry(const char* dir);
ClassPathDirEntry(const char* dir) {
_dir = copy_path(dir);
}
virtual ~ClassPathDirEntry() {}
ClassFileStream* open_stream(const char* name, TRAPS);
};


// Type definitions for zip file and zip file entry
typedef void* jzfile;
typedef struct {
Expand All @@ -104,12 +102,9 @@ class ClassPathZipEntry: public ClassPathEntry {
const char* _zip_name; // Name of zip archive
bool _from_class_path_attr; // From the "Class-path" attribute of a jar file
public:
bool is_modules_image() const { return false; }
bool is_jar_file() const { return true; }
bool from_class_path_attr() const { return _from_class_path_attr; }
const char* name() const { return _zip_name; }
JImageFile* jimage() const { return NULL; }
void close_jimage() {}
ClassPathZipEntry(jzfile* zip, const char* zip_name, bool is_boot_append, bool from_class_path_attr);
virtual ~ClassPathZipEntry();
u1* open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS);
Expand All @@ -126,8 +121,6 @@ class ClassPathImageEntry: public ClassPathEntry {
DEBUG_ONLY(static ClassPathImageEntry* _singleton;)
public:
bool is_modules_image() const;
bool is_jar_file() const { return false; }
bool from_class_path_attr() const { return false; }
bool is_open() const { return _jimage != NULL; }
const char* name() const { return _name == NULL ? "" : _name; }
JImageFile* jimage() const { return _jimage; }
Expand Down Expand Up @@ -156,8 +149,6 @@ class ModuleClassPathList : public CHeapObj<mtClass> {
void add_to_list(ClassPathEntry* new_entry);
};

class SharedPathsMiscInfo;

class ClassLoader: AllStatic {
public:
enum ClassLoaderType {
Expand Down Expand Up @@ -230,8 +221,6 @@ class ClassLoader: AllStatic {
static ClassPathEntry* _last_append_entry;

// Info used by CDS
CDS_ONLY(static SharedPathsMiscInfo * _shared_paths_misc_info;)

CDS_ONLY(static ClassPathEntry* _app_classpath_entries;)
CDS_ONLY(static ClassPathEntry* _last_app_classpath_entry;)
CDS_ONLY(static ClassPathEntry* _module_path_entries;)
Expand Down Expand Up @@ -416,10 +405,6 @@ class ClassLoader: AllStatic {
}
return num_entries;
}
static void finalize_shared_paths_misc_info();
static int get_shared_paths_misc_info_size();
static void* get_shared_paths_misc_info();
static bool check_shared_paths_misc_info(void* info, int size, bool is_static);
static void exit_with_path_failure(const char* error, const char* message);
static char* skip_uri_protocol(char* source);
static void record_result(InstanceKlass* ik, const ClassFileStream* stream, TRAPS);
Expand Down
17 changes: 6 additions & 11 deletions src/hotspot/share/classfile/classLoaderExt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "classfile/classLoaderData.inline.hpp"
#include "classfile/klassFactory.hpp"
#include "classfile/modules.hpp"
#include "classfile/sharedPathsMiscInfo.hpp"
#include "classfile/systemDictionaryShared.hpp"
#include "classfile/vmSymbols.hpp"
#include "memory/allocation.inline.hpp"
Expand Down Expand Up @@ -74,7 +73,6 @@ void ClassLoaderExt::setup_app_search_path() {
trace_class_path("app loader class path (skipped)=", app_class_path);
} else {
trace_class_path("app loader class path=", app_class_path);
shared_paths_misc_info()->add_app_classpath(app_class_path);
ClassLoader::setup_app_search_path(app_class_path);
}
}
Expand Down Expand Up @@ -212,8 +210,12 @@ void ClassLoaderExt::process_jar_manifest(ClassPathEntry* entry,
char* libname = NEW_RESOURCE_ARRAY(char, libname_len + 1);
int n = os::snprintf(libname, libname_len + 1, "%.*s%s", dir_len, dir_name, file_start);
assert((size_t)n == libname_len, "Unexpected number of characters in string");
trace_class_path("library = ", libname);
ClassLoader::update_class_path_entry_list(libname, true, false, true /* from_class_path_attr */);
if (ClassLoader::update_class_path_entry_list(libname, true, false, true /* from_class_path_attr */)) {
trace_class_path("library = ", libname);
} else {
trace_class_path("library (non-existent) = ", libname);
FileMapInfo::record_non_existent_class_path_entry(libname);
}
}

file_start = file_end;
Expand All @@ -222,7 +224,6 @@ void ClassLoaderExt::process_jar_manifest(ClassPathEntry* entry,
}

void ClassLoaderExt::setup_search_paths() {
shared_paths_misc_info()->record_app_offset();
ClassLoaderExt::setup_app_search_path();
}

Expand All @@ -248,12 +249,6 @@ void ClassLoaderExt::record_result(const s2 classpath_index,
result->set_class_loader_type(classloader_type);
}

void ClassLoaderExt::finalize_shared_paths_misc_info() {
if (!_has_app_classes) {
shared_paths_misc_info()->pop_app();
}
}

// Load the class of the given name from the location given by path. The path is specified by
// the "source:" in the class list file (see classListParser.cpp), and can be a directory or
// a JAR file.
Expand Down
5 changes: 0 additions & 5 deletions src/hotspot/share/classfile/classLoaderExt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ class ClassLoaderExt: public ClassLoader { // AllStatic
static char* get_class_path_attr(const char* jar_path, char* manifest, jint manifest_size);
static void setup_app_search_path(); // Only when -Xshare:dump
static void process_module_table(ModuleEntryTable* met, TRAPS);
static SharedPathsMiscInfo* shared_paths_misc_info() {
return (SharedPathsMiscInfo*)_shared_paths_misc_info;
}
// index of first app JAR in shared classpath entry table
static jshort _app_class_paths_start_index;
// index of first modular JAR in shared modulepath entry table
Expand Down Expand Up @@ -84,8 +81,6 @@ class ClassLoaderExt: public ClassLoader { // AllStatic
return read_manifest(entry, manifest_size, false, THREAD);
}

static void finalize_shared_paths_misc_info();

static jshort app_class_paths_start_index() { return _app_class_paths_start_index; }

static jshort app_module_paths_start_index() { return _app_module_paths_start_index; }
Expand Down
Loading

0 comments on commit 87eefe2

Please sign in to comment.