< prev index next >
src/share/vm/classfile/classFileParser.cpp
Print this page
@ rev 12742 : imported patch alpinefixes-copyswapaligned
|
@@ -1672,23 +1672,17 @@
}
}
}
-static void copy_u2_with_conversion(u2* dest, const u2* src, int length) {
- while (length-- > 0) {
- *dest++ = Bytes::get_Java_u2((u1*) (src++));
- }
-}
-
-const u2* ClassFileParser::parse_exception_table(const ClassFileStream* const cfs,
+const void* ClassFileParser::parse_exception_table(const ClassFileStream* const cfs,
u4 code_length,
u4 exception_table_length,
TRAPS) {
assert(cfs != NULL, "invariant");
- const u2* const exception_table_start = cfs->get_u2_buffer();
+ const void* const exception_table_start = cfs->get_u1_buffer();
assert(exception_table_start != NULL, "null exception table");
cfs->guarantee_more(8 * exception_table_length, CHECK_NULL); // start_pc,
// end_pc,
// handler_pc,
@@ -1802,11 +1796,11 @@
lvt->slot = Bytes::get_Java_u2((u1*) &src->slot);
}
// Function is used to parse both attributes:
// LocalVariableTable (LVT) and LocalVariableTypeTable (LVTT)
-const u2* ClassFileParser::parse_localvariable_table(const ClassFileStream* cfs,
+const void* ClassFileParser::parse_localvariable_table(const ClassFileStream* cfs,
u4 code_length,
u2 max_locals,
u4 code_attribute_length,
u2* const localvariable_table_length,
bool isLVTT,
@@ -1822,11 +1816,11 @@
if (_need_verify) {
guarantee_property(code_attribute_length == (sizeof(*localvariable_table_length) + size * sizeof(u2)),
"%s has wrong length in class file %s", tbl_name, CHECK_NULL);
}
- const u2* const localvariable_table_start = cfs->get_u2_buffer();
+ const u1* const localvariable_table_start = cfs->get_u1_buffer();
assert(localvariable_table_start != NULL, "null local variable table");
if (!_need_verify) {
cfs->skip_u2_fast(size);
} else {
cfs->guarantee_more(size * 2, CHECK_NULL);
@@ -1938,22 +1932,22 @@
return NULL;
}
return stackmap_table_start;
}
-const u2* ClassFileParser::parse_checked_exceptions(const ClassFileStream* const cfs,
+const void* ClassFileParser::parse_checked_exceptions(const ClassFileStream* const cfs,
u2* const checked_exceptions_length,
u4 method_attribute_length,
TRAPS) {
assert(cfs != NULL, "invariant");
assert(checked_exceptions_length != NULL, "invariant");
cfs->guarantee_more(2, CHECK_NULL); // checked_exceptions_length
*checked_exceptions_length = cfs->get_u2_fast();
const unsigned int size =
(*checked_exceptions_length) * sizeof(CheckedExceptionElement) / sizeof(u2);
- const u2* const checked_exceptions_start = cfs->get_u2_buffer();
+ const void* const checked_exceptions_start = cfs->get_u1_buffer();
assert(checked_exceptions_start != NULL, "null checked exceptions");
if (!_need_verify) {
cfs->skip_u2_fast(size);
} else {
// Verify each value in the checked exception table
@@ -2116,14 +2110,14 @@
* - HotSpot internal LVT keeps natural ordering of class file LVT entries.
*/
void ClassFileParser::copy_localvariable_table(const ConstMethod* cm,
int lvt_cnt,
u2* const localvariable_table_length,
- const u2**const localvariable_table_start,
+ const void** const localvariable_table_start,
int lvtt_cnt,
u2* const localvariable_type_table_length,
- const u2**const localvariable_type_table_start,
+ const void** const localvariable_type_table_start,
TRAPS) {
ResourceMark rm(THREAD);
typedef ResourceHashtable<LocalVariableTableElement, LocalVariableTableElement*,
@@ -2314,26 +2308,26 @@
u2 max_stack = 0;
u2 max_locals = 0;
u4 code_length = 0;
const u1* code_start = 0;
u2 exception_table_length = 0;
- const u2* exception_table_start = NULL;
+ const void* exception_table_start = NULL; // (potentially unaligned) pointer to array of u2 elements
Array<int>* exception_handlers = Universe::the_empty_int_array();
u2 checked_exceptions_length = 0;
- const u2* checked_exceptions_start = NULL;
+ const void* checked_exceptions_start = NULL; // (potentially unaligned) pointer to array of u2 elements
CompressedLineNumberWriteStream* linenumber_table = NULL;
int linenumber_table_length = 0;
int total_lvt_length = 0;
u2 lvt_cnt = 0;
u2 lvtt_cnt = 0;
bool lvt_allocated = false;
u2 max_lvt_cnt = INITIAL_MAX_LVT_NUMBER;
u2 max_lvtt_cnt = INITIAL_MAX_LVT_NUMBER;
u2* localvariable_table_length = NULL;
- const u2** localvariable_table_start = NULL;
+ const void** localvariable_table_start = NULL; // (potentially unaligned) pointer to array of LVT attributes
u2* localvariable_type_table_length = NULL;
- const u2** localvariable_type_table_start = NULL;
+ const void** localvariable_type_table_start = NULL; // (potentially unaligned) pointer to LVTT attributes
int method_parameters_length = -1;
const u1* method_parameters_data = NULL;
bool method_parameters_seen = false;
bool parsed_code_attribute = false;
bool parsed_checked_exceptions_attribute = false;
@@ -2470,21 +2464,21 @@
// Parse local variable table
if (!lvt_allocated) {
localvariable_table_length = NEW_RESOURCE_ARRAY_IN_THREAD(
THREAD, u2, INITIAL_MAX_LVT_NUMBER);
localvariable_table_start = NEW_RESOURCE_ARRAY_IN_THREAD(
- THREAD, const u2*, INITIAL_MAX_LVT_NUMBER);
+ THREAD, const void*, INITIAL_MAX_LVT_NUMBER);
localvariable_type_table_length = NEW_RESOURCE_ARRAY_IN_THREAD(
THREAD, u2, INITIAL_MAX_LVT_NUMBER);
localvariable_type_table_start = NEW_RESOURCE_ARRAY_IN_THREAD(
- THREAD, const u2*, INITIAL_MAX_LVT_NUMBER);
+ THREAD, const void*, INITIAL_MAX_LVT_NUMBER);
lvt_allocated = true;
}
if (lvt_cnt == max_lvt_cnt) {
max_lvt_cnt <<= 1;
localvariable_table_length = REALLOC_RESOURCE_ARRAY(u2, localvariable_table_length, lvt_cnt, max_lvt_cnt);
- localvariable_table_start = REALLOC_RESOURCE_ARRAY(const u2*, localvariable_table_start, lvt_cnt, max_lvt_cnt);
+ localvariable_table_start = REALLOC_RESOURCE_ARRAY(const void*, localvariable_table_start, lvt_cnt, max_lvt_cnt);
}
localvariable_table_start[lvt_cnt] =
parse_localvariable_table(cfs,
code_length,
max_locals,
@@ -2499,22 +2493,22 @@
cp->symbol_at(code_attribute_name_index) == vmSymbols::tag_local_variable_type_table()) {
if (!lvt_allocated) {
localvariable_table_length = NEW_RESOURCE_ARRAY_IN_THREAD(
THREAD, u2, INITIAL_MAX_LVT_NUMBER);
localvariable_table_start = NEW_RESOURCE_ARRAY_IN_THREAD(
- THREAD, const u2*, INITIAL_MAX_LVT_NUMBER);
+ THREAD, const void*, INITIAL_MAX_LVT_NUMBER);
localvariable_type_table_length = NEW_RESOURCE_ARRAY_IN_THREAD(
THREAD, u2, INITIAL_MAX_LVT_NUMBER);
localvariable_type_table_start = NEW_RESOURCE_ARRAY_IN_THREAD(
- THREAD, const u2*, INITIAL_MAX_LVT_NUMBER);
+ THREAD, const void*, INITIAL_MAX_LVT_NUMBER);
lvt_allocated = true;
}
// Parse local variable type table
if (lvtt_cnt == max_lvtt_cnt) {
max_lvtt_cnt <<= 1;
localvariable_type_table_length = REALLOC_RESOURCE_ARRAY(u2, localvariable_type_table_length, lvtt_cnt, max_lvtt_cnt);
- localvariable_type_table_start = REALLOC_RESOURCE_ARRAY(const u2*, localvariable_type_table_start, lvtt_cnt, max_lvtt_cnt);
+ localvariable_type_table_start = REALLOC_RESOURCE_ARRAY(const void*, localvariable_type_table_start, lvtt_cnt, max_lvtt_cnt);
}
localvariable_type_table_start[lvtt_cnt] =
parse_localvariable_table(cfs,
code_length,
max_locals,
@@ -2781,14 +2775,14 @@
linenumber_table_length);
}
// Copy exception table
if (exception_table_length > 0) {
- int size =
- exception_table_length * sizeof(ExceptionTableElement) / sizeof(u2);
- copy_u2_with_conversion((u2*) m->exception_table_start(),
- exception_table_start, size);
+ Copy::conjoint_swap_maybe<Endian::JAVA>(exception_table_start,
+ m->exception_table_start(),
+ exception_table_length * sizeof(ExceptionTableElement),
+ sizeof(u2));
}
// Copy method parameters
if (method_parameters_length > 0) {
MethodParametersElement* elem = m->constMethod()->method_parameters_start();
@@ -2800,15 +2794,14 @@
}
}
// Copy checked exceptions
if (checked_exceptions_length > 0) {
- const int size =
- checked_exceptions_length * sizeof(CheckedExceptionElement) / sizeof(u2);
- copy_u2_with_conversion((u2*) m->checked_exceptions_start(),
- checked_exceptions_start,
- size);
+ Copy::conjoint_swap_maybe<Endian::JAVA>(checked_exceptions_start,
+ m->checked_exceptions_start(),
+ checked_exceptions_length * sizeof(CheckedExceptionElement),
+ sizeof(u2));
}
// Copy class file LVT's/LVTT's into the HotSpot internal LVT.
if (total_lvt_length > 0) {
promoted_flags->set_has_localvariable_table();
< prev index next >