aboutsummaryrefslogtreecommitdiff
path: root/src/share/vm/oops/methodOop.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/share/vm/oops/methodOop.cpp')
-rw-r--r--src/share/vm/oops/methodOop.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/share/vm/oops/methodOop.cpp b/src/share/vm/oops/methodOop.cpp
index db4dc7735..83543fee2 100644
--- a/src/share/vm/oops/methodOop.cpp
+++ b/src/share/vm/oops/methodOop.cpp
@@ -430,11 +430,11 @@ bool methodOopDesc::can_be_statically_bound() const {
bool methodOopDesc::is_accessor() const {
if (code_size() != 5) return false;
if (size_of_parameters() != 1) return false;
- if (Bytecodes::java_code_at(code_base()+0) != Bytecodes::_aload_0 ) return false;
- if (Bytecodes::java_code_at(code_base()+1) != Bytecodes::_getfield) return false;
- Bytecodes::Code ret_bc = Bytecodes::java_code_at(code_base()+4);
- if (Bytecodes::java_code_at(code_base()+4) != Bytecodes::_areturn &&
- Bytecodes::java_code_at(code_base()+4) != Bytecodes::_ireturn ) return false;
+ methodOop m = (methodOop)this; // pass to code_at() to avoid method_from_bcp
+ if (Bytecodes::java_code_at(code_base()+0, m) != Bytecodes::_aload_0 ) return false;
+ if (Bytecodes::java_code_at(code_base()+1, m) != Bytecodes::_getfield) return false;
+ if (Bytecodes::java_code_at(code_base()+4, m) != Bytecodes::_areturn &&
+ Bytecodes::java_code_at(code_base()+4, m) != Bytecodes::_ireturn ) return false;
return true;
}
@@ -955,7 +955,7 @@ extern "C" {
// This is only done during class loading, so it is OK to assume method_idnum matches the methods() array
static void reorder_based_on_method_index(objArrayOop methods,
objArrayOop annotations,
- oop* temp_array) {
+ GrowableArray<oop>* temp_array) {
if (annotations == NULL) {
return;
}
@@ -963,12 +963,15 @@ static void reorder_based_on_method_index(objArrayOop methods,
int length = methods->length();
int i;
// Copy to temp array
- memcpy(temp_array, annotations->obj_at_addr(0), length * sizeof(oop));
+ temp_array->clear();
+ for (i = 0; i < length; i++) {
+ temp_array->append(annotations->obj_at(i));
+ }
// Copy back using old method indices
for (i = 0; i < length; i++) {
methodOop m = (methodOop) methods->obj_at(i);
- annotations->obj_at_put(i, temp_array[m->method_idnum()]);
+ annotations->obj_at_put(i, temp_array->at(m->method_idnum()));
}
}
@@ -997,7 +1000,7 @@ void methodOopDesc::sort_methods(objArrayOop methods,
// Use a simple bubble sort for small number of methods since
// qsort requires a functional pointer call for each comparison.
- if (length < 8) {
+ if (UseCompressedOops || length < 8) {
bool sorted = true;
for (int i=length-1; i>0; i--) {
for (int j=0; j<i; j++) {
@@ -1010,11 +1013,14 @@ void methodOopDesc::sort_methods(objArrayOop methods,
}
}
if (sorted) break;
- sorted = true;
+ sorted = true;
}
} else {
+ // XXX This doesn't work for UseCompressedOops because the compare fn
+ // will have to decode the methodOop anyway making it not much faster
+ // than above.
compareFn compare = (compareFn) (idempotent ? method_compare_idempotent : method_compare);
- qsort(methods->obj_at_addr(0), length, oopSize, compare);
+ qsort(methods->base(), length, heapOopSize, compare);
}
// Sort annotations if necessary
@@ -1022,8 +1028,9 @@ void methodOopDesc::sort_methods(objArrayOop methods,
assert(methods_parameter_annotations == NULL || methods_parameter_annotations->length() == methods->length(), "");
assert(methods_default_annotations == NULL || methods_default_annotations->length() == methods->length(), "");
if (do_annotations) {
+ ResourceMark rm;
// Allocate temporary storage
- oop* temp_array = NEW_RESOURCE_ARRAY(oop, length);
+ GrowableArray<oop>* temp_array = new GrowableArray<oop>(length);
reorder_based_on_method_index(methods, methods_annotations, temp_array);
reorder_based_on_method_index(methods, methods_parameter_annotations, temp_array);
reorder_based_on_method_index(methods, methods_default_annotations, temp_array);