Mercurial > hg > graal-compiler
diff src/share/vm/oops/methodOop.cpp @ 113:ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
author | coleenp |
---|---|
date | Sun, 13 Apr 2008 17:43:42 -0400 |
parents | 541929da62d2 |
children | 018d5b58dd4f |
line wrap: on
line diff
--- a/src/share/vm/oops/methodOop.cpp Fri Apr 11 09:56:35 2008 -0400 +++ b/src/share/vm/oops/methodOop.cpp Sun Apr 13 17:43:42 2008 -0400 @@ -430,11 +430,11 @@ 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 @@ // 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 @@ 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 @@ // 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 @@ } } 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 @@ 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);