-
Notifications
You must be signed in to change notification settings - Fork 137
playing about with simpler buffer copying #1841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: lworld
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -986,21 +986,28 @@ objArrayOop ClassLoader::get_system_packages(TRAPS) { | |
| } | ||
|
|
||
| // caller needs ResourceMark | ||
| const char* ClassLoader::file_name_for_class_name(const char* class_name, | ||
| int class_name_len) { | ||
| char* ClassLoader::symbol_name_to_padded_buffer(const Symbol* symbol, int padding_len) { | ||
| assert(symbol != nullptr, "invariant"); | ||
| assert(padding_len >= 0, "invariant"); | ||
|
|
||
| // Include terminating nul. | ||
| int name_len = symbol->utf8_length() + 1; | ||
| char* const buffer = NEW_RESOURCE_ARRAY(char, name_len + padding_len); | ||
| symbol->as_C_string(buffer, name_len); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoids intermediate copy as happened in previous code. |
||
| return buffer; | ||
| } | ||
|
|
||
| // caller needs ResourceMark | ||
| const char* ClassLoader::file_name_for_class_name(const Symbol* class_name) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While it's undocumented in the code, I'm assuming that the symbol name is |
||
| assert(class_name != nullptr, "invariant"); | ||
| assert((int)strlen(class_name) == class_name_len, "invariant"); | ||
|
|
||
| static const char class_suffix[] = ".class"; | ||
| size_t class_suffix_len = sizeof(class_suffix); | ||
|
|
||
| char* const file_name = NEW_RESOURCE_ARRAY(char, | ||
| class_name_len + | ||
| class_suffix_len); // includes term null | ||
|
|
||
| strncpy(file_name, class_name, class_name_len); | ||
| strncpy(&file_name[class_name_len], class_suffix, class_suffix_len); | ||
| static const int suffix_len = strlen(class_suffix); | ||
|
|
||
| // Just suffix length (a trailing nul is already accounted for in the copy). | ||
| char* const file_name = symbol_name_to_padded_buffer(class_name, suffix_len); | ||
| // Append over existing trailing nul, so need to copy a new one. | ||
| strncpy(&file_name[class_name->utf8_length()], class_suffix, suffix_len + 1); | ||
| return file_name; | ||
| } | ||
|
|
||
|
|
@@ -1081,14 +1088,11 @@ InstanceKlass* ClassLoader::load_class(Symbol* name, PackageEntry* pkg_entry, bo | |
| ResourceMark rm(THREAD); | ||
| HandleMark hm(THREAD); | ||
|
|
||
| const char* const class_name = name->as_C_string(); | ||
|
|
||
| EventMarkClassLoading m("Loading class %s", class_name); | ||
|
|
||
| const char* const file_name = file_name_for_class_name(class_name, | ||
| name->utf8_length()); | ||
| const char* const file_name = file_name_for_class_name(name); | ||
| assert(file_name != nullptr, "invariant"); | ||
|
|
||
| EventMarkClassLoading m("Loading class %s", file_name); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not 100% sure what's going on here, so someone needs to check that this looks sane. |
||
|
|
||
| // Lookup stream for parsing .class file | ||
| ClassFileStream* stream = nullptr; | ||
| s2 classpath_index = 0; | ||
|
|
@@ -1347,9 +1351,7 @@ void ClassLoader::record_result(JavaThread* current, InstanceKlass* ik, | |
| assert(classpath_index == -1, "sanity"); | ||
| } | ||
|
|
||
| const char* const class_name = ik->name()->as_C_string(); | ||
| const char* const file_name = file_name_for_class_name(class_name, | ||
| ik->name()->utf8_length()); | ||
| const char* const file_name = file_name_for_class_name(ik->name()); | ||
| assert(file_name != nullptr, "invariant"); | ||
| record_result_for_builtin_loader(checked_cast<s2>(classpath_index), ik, redefined); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -247,8 +247,9 @@ class ClassLoader: AllStatic { | |
| // Canonicalizes path names, so strcmp will work properly. This is mainly | ||
| // to avoid confusing the zip library | ||
| static char* get_canonical_path(const char* orig, Thread* thread); | ||
| static const char* file_name_for_class_name(const char* class_name, | ||
| int class_name_len); | ||
|
|
||
| static char* symbol_name_to_padded_buffer(const Symbol* symbol, int padding_len); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I should probably declare this private ... |
||
| static const char* file_name_for_class_name(const Symbol* class_name); | ||
| static PackageEntry* get_package_entry(Symbol* pkg_name, ClassLoaderData* loader_data); | ||
| static int crc32(int crc, const char* buf, int len); | ||
| static bool update_class_path_entry_list(JavaThread* current, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming (hoping) that the exact format of this log is not expected to be important to anyone.