hotspot/src/share/vm/oops/methodOop.cpp
Print this page
rev 611 : Merge
*** 1,10 ****
#ifdef USE_PRAGMA_IDENT_SRC
#pragma ident "@(#)methodOop.cpp 1.314 08/11/24 12:22:56 JVM"
#endif
/*
! * Copyright 1997-2007 Sun Microsystems, Inc. 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,10 ----
#ifdef USE_PRAGMA_IDENT_SRC
#pragma ident "@(#)methodOop.cpp 1.314 08/11/24 12:22:56 JVM"
#endif
/*
! * Copyright 1997-2008 Sun Microsystems, Inc. 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 431,445 ****
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;
return true;
}
bool methodOopDesc::is_initializer() const {
--- 431,445 ----
bool methodOopDesc::is_accessor() const {
if (code_size() != 5) return false;
if (size_of_parameters() != 1) 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;
}
bool methodOopDesc::is_initializer() const {
*** 673,685 ****
// ONLY USE the h_method now as make_adapter may have blocked
}
address methodOopDesc::make_adapters(methodHandle mh, TRAPS) {
- // If running -Xint we need no adapters.
- if (Arguments::mode() == Arguments::_int) return NULL;
-
// Adapters for compiled code are made eagerly here. They are fairly
// small (generally < 100 bytes) and quick to make (and cached and shared)
// so making them eagerly shouldn't be too expensive.
AdapterHandlerEntry* adapter = AdapterHandlerLibrary::get_adapter(mh);
if (adapter == NULL ) {
--- 673,682 ----
*** 889,902 ****
if (ss.is_object()) {
symbolOop sym = ss.as_symbol(CHECK_(false));
symbolHandle name (THREAD, sym);
klassOop klass = SystemDictionary::resolve_or_null(name, class_loader,
protection_domain, THREAD);
! // We are loading classes eagerly. If a ClassNotFoundException was generated,
! // be sure to ignore it.
if (HAS_PENDING_EXCEPTION) {
! if (PENDING_EXCEPTION->is_a(SystemDictionary::classNotFoundException_klass())) {
CLEAR_PENDING_EXCEPTION;
} else {
return false;
}
}
--- 886,900 ----
if (ss.is_object()) {
symbolOop sym = ss.as_symbol(CHECK_(false));
symbolHandle name (THREAD, sym);
klassOop klass = SystemDictionary::resolve_or_null(name, class_loader,
protection_domain, THREAD);
! // We are loading classes eagerly. If a ClassNotFoundException or
! // a LinkageError was generated, be sure to ignore it.
if (HAS_PENDING_EXCEPTION) {
! if (PENDING_EXCEPTION->is_a(SystemDictionary::classNotFoundException_klass()) ||
! PENDING_EXCEPTION->is_a(SystemDictionary::linkageError_klass())) {
CLEAR_PENDING_EXCEPTION;
} else {
return false;
}
}
*** 955,978 ****
// 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) {
if (annotations == NULL) {
return;
}
int length = methods->length();
int i;
// Copy to temp array
! memcpy(temp_array, annotations->obj_at_addr(0), length * sizeof(oop));
// 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()]);
}
}
// This is only done during class loading, so it is OK to assume method_idnum matches the methods() array
--- 953,979 ----
// 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,
! GrowableArray<oop>* temp_array) {
if (annotations == NULL) {
return;
}
int length = methods->length();
int i;
// Copy to temp array
! 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->at(m->method_idnum()));
}
}
// This is only done during class loading, so it is OK to assume method_idnum matches the methods() array
*** 997,1007 ****
}
}
// Use a simple bubble sort for small number of methods since
// qsort requires a functional pointer call for each comparison.
! if (length < 8) {
bool sorted = true;
for (int i=length-1; i>0; i--) {
for (int j=0; j<i; j++) {
methodOop m1 = (methodOop)methods->obj_at(j);
methodOop m2 = (methodOop)methods->obj_at(j+1);
--- 998,1008 ----
}
}
// Use a simple bubble sort for small number of methods since
// qsort requires a functional pointer call for each comparison.
! if (UseCompressedOops || length < 8) {
bool sorted = true;
for (int i=length-1; i>0; i--) {
for (int j=0; j<i; j++) {
methodOop m1 = (methodOop)methods->obj_at(j);
methodOop m2 = (methodOop)methods->obj_at(j+1);
*** 1013,1033 ****
}
if (sorted) break;
sorted = true;
}
} else {
compareFn compare = (compareFn) (idempotent ? method_compare_idempotent : method_compare);
! qsort(methods->obj_at_addr(0), length, oopSize, compare);
}
// Sort annotations if necessary
assert(methods_annotations == NULL || methods_annotations->length() == methods->length(), "");
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) {
// Allocate temporary storage
! oop* temp_array = NEW_RESOURCE_ARRAY(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);
}
--- 1014,1038 ----
}
if (sorted) break;
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->base(), length, heapOopSize, compare);
}
// Sort annotations if necessary
assert(methods_annotations == NULL || methods_annotations->length() == methods->length(), "");
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
! 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);
}