# HG changeset patch # User Christian Wimmer # Date 1354239828 28800 # Node ID 4983da9d3fc7f60ffda46310128d8ae3b5f10bef # Parent f1f32b695d1ef1987afa54351a2fc4c8999ece61# Parent 9d0b984864836a3ca789e4edd94d53adfa69fd0d Merge diff -r f1f32b695d1e -r 4983da9d3fc7 src/share/vm/code/dependencies.cpp --- a/src/share/vm/code/dependencies.cpp Thu Nov 29 17:43:09 2012 -0800 +++ b/src/share/vm/code/dependencies.cpp Thu Nov 29 17:43:48 2012 -0800 @@ -139,12 +139,11 @@ assert(TYPE_LIMIT <= (1<oop_is_array()) { // As a special case, support this assertion on an array type, // which reduces to an assertion on its element type. @@ -156,17 +155,19 @@ //if (ctxk->is_final()) return; // Ex: String[][] } check_ctxk(ctxk); - assert_common_1(leaf_type, ctxk_dv); + assert_common_1(leaf_type, DepValue(_oop_recorder, ctxk)); } -void Dependencies::assert_abstract_with_unique_concrete_subtype(DepValue ctxk, DepValue conck) { - check_ctxk_abstract(ctxk.as_klass()); - assert_common_2(abstract_with_unique_concrete_subtype, ctxk, conck); +void Dependencies::assert_abstract_with_unique_concrete_subtype(Klass* ctxk, Klass* conck) { + check_ctxk_abstract(ctxk); + DepValue ctxk_dv(_oop_recorder, ctxk); + DepValue conck_dv(_oop_recorder, conck, &ctxk_dv); + assert_common_2(abstract_with_unique_concrete_subtype, ctxk_dv, conck_dv); } -void Dependencies::assert_unique_concrete_method(DepValue ctxk, DepValue uniqm) { - check_ctxk(ctxk.as_klass()); - assert_common_2(unique_concrete_method, ctxk, uniqm); +void Dependencies::assert_unique_concrete_method(Klass* ctxk, Method* uniqm) { + check_ctxk(ctxk); + assert_common_2(unique_concrete_method, DepValue(_oop_recorder, ctxk), DepValue(_oop_recorder, uniqm)); } #endif // GRAAL @@ -285,8 +286,8 @@ #ifdef GRAAL bool Dependencies::maybe_merge_ctxk(GrowableArray* deps, int ctxk_i, DepValue ctxk2_dv) { - Klass* ctxk1 = deps->at(ctxk_i).as_klass(); - Klass* ctxk2 = ctxk2_dv.as_klass(); + Klass* ctxk1 = deps->at(ctxk_i).as_klass(_oop_recorder); + Klass* ctxk2 = ctxk2_dv.as_klass(_oop_recorder); if (ctxk2->is_subtype_of(ctxk1)) { return true; // success, and no need to change } else if (ctxk1->is_subtype_of(ctxk2)) { @@ -382,18 +383,18 @@ #ifdef GRAAL // metadata deps are sorted before object deps -static int sort_dep_value(DepValue* p1, DepValue* p2, int narg) { +static int sort_dep_value(Dependencies::DepValue* p1, Dependencies::DepValue* p2, int narg) { for (int i = 0; i < narg; i++) { int diff = p1[i].sort_key() - p2[i].sort_key(); if (diff != 0) return diff; } return 0; } -static int sort_dep_value_arg_1(DepValue* p1, DepValue* p2) +static int sort_dep_value_arg_1(Dependencies::DepValue* p1, Dependencies::DepValue* p2) { return sort_dep_value(p1, p2, 1); } -static int sort_dep_value_arg_2(DepValue* p1, DepValue* p2) +static int sort_dep_value_arg_2(Dependencies::DepValue* p1, Dependencies::DepValue* p2) { return sort_dep_value(p1, p2, 2); } -static int sort_dep_value_arg_3(DepValue* p1, DepValue* p2) +static int sort_dep_value_arg_3(Dependencies::DepValue* p1, Dependencies::DepValue* p2) { return sort_dep_value(p1, p2, 3); } #endif // GRAAL @@ -491,9 +492,9 @@ jbyte code_byte = (jbyte)dept; int skipj = -1; if (ctxkj >= 0 && ctxkj+1 < stride) { - Klass* ctxk = deps->at(i+ctxkj+0).as_klass(); - DepValue x = deps->at(i+ctxkj+1); // following argument - if (ctxk == ctxk_encoded_as_null(dept, x.as_metadata())) { + Klass* ctxk = deps->at(i+ctxkj+0).as_klass(_oop_recorder); + DepValue x = deps->at(i+ctxkj+1); // following argument + if (ctxk == ctxk_encoded_as_null(dept, x.as_metadata(_oop_recorder))) { skipj = ctxkj; // we win: maybe one less oop to keep track of code_byte |= default_context_type_bit; } diff -r f1f32b695d1e -r 4983da9d3fc7 src/share/vm/code/dependencies.hpp --- a/src/share/vm/code/dependencies.hpp Thu Nov 29 17:43:09 2012 -0800 +++ b/src/share/vm/code/dependencies.hpp Thu Nov 29 17:43:48 2012 -0800 @@ -59,43 +59,6 @@ class CallSiteDepChange; class No_Safepoint_Verifier; -#ifdef GRAAL - -// Dependency values that don't rely on the ciBaseObject types. -class DepValue VALUE_OBJ_CLASS_SPEC { -private: - OopRecorder* _oop_recorder; - int _index; // positive -> metadata, negative -> object - -public: - DepValue() : _oop_recorder(NULL), _index(max_jint) {} - DepValue(OopRecorder* oop_recorder, Metadata* metadata) : _oop_recorder(oop_recorder) { - int index = oop_recorder->find_index(metadata); - _index = index; - } - DepValue(OopRecorder* oop_recorder, jobject obj) : _oop_recorder(oop_recorder) { - int index = oop_recorder->find_index(obj); - _index = -(index + 1); - } - - // Used to sort values in order of index with metadata values preceding object values - int sort_key() const { return -_index; } - - bool operator == (const DepValue& dv) const { return dv._oop_recorder == _oop_recorder && dv._index == _index; } - - bool is_valid() const { return _index != max_jint; } - int index() const { assert(is_valid(), "oops"); return _index < 0 ? -(_index + 1) : _index; } - bool is_metadata() const { assert(is_valid(), "oops"); return _index >= 0; } - bool is_method() const { assert(is_valid(), "oops"); return as_metadata()->is_method(); } - bool is_klass() const { assert(is_valid(), "oops"); return as_metadata()->is_klass(); } - bool is_object() const { return !is_metadata(); } - - Metadata* as_metadata() const { assert(is_metadata(), "oops"); return _oop_recorder->metadata_at(index()); } - Klass* as_klass() const { assert(is_klass(), "oops"); return (Klass*) as_metadata(); } - Method* as_method() const { assert(is_method(), "oops"); return (Method*) as_metadata(); } -}; -#endif - class Dependencies: public ResourceObj { public: // Note: In the comments on dependency types, most uses of the terms @@ -237,6 +200,51 @@ static void check_valid_dependency_type(DepType dept); +#ifdef GRAAL + // A Metadata* or object value recorded in an OopRecorder + class DepValue VALUE_OBJ_CLASS_SPEC { + private: + // Unique identifier of the value within the associated OopRecorder that + // encodes both the category of the value (0: invalid, positive: metadata, negative: object) + // and the index within a category specific array (metadata: index + 1, object: -(index + 1)) + int _id; + + public: + DepValue() : _id(0) {} + DepValue(OopRecorder* rec, Metadata* metadata, DepValue* candidate = NULL) { + assert(candidate == NULL || candidate->is_metadata(), "oops"); + if (candidate != NULL && candidate->as_metadata(rec) == metadata) { + _id = candidate->_id; + } else { + _id = rec->find_index(metadata) + 1; + } + } + DepValue(OopRecorder* rec, jobject obj, DepValue* candidate = NULL) { + assert(candidate == NULL || candidate->is_object(), "oops"); + if (candidate != NULL && candidate->as_object(rec) == obj) { + _id = candidate->_id; + } else { + _id = -(rec->find_index(obj) + 1); + } + } + + // Used to sort values in ascending order of index() with metadata values preceding object values + int sort_key() const { return -_id; } + + bool operator == (const DepValue& other) const { return other._id == _id; } + + bool is_valid() const { return _id != 0; } + int index() const { assert(is_valid(), "oops"); return _id < 0 ? -(_id + 1) : _id - 1; } + bool is_metadata() const { assert(is_valid(), "oops"); return _id > 0; } + bool is_object() const { assert(is_valid(), "oops"); return _id < 0; } + + Metadata* as_metadata(OopRecorder* rec) const { assert(is_metadata(), "oops"); return rec->metadata_at(index()); } + Klass* as_klass(OopRecorder* rec) const { assert(as_metadata(rec)->is_klass(), "oops"); return (Klass*) as_metadata(rec); } + Method* as_method(OopRecorder* rec) const { assert(as_metadata(rec)->is_method(), "oops"); return (Method*) as_metadata(rec); } + jobject as_object(OopRecorder* rec) const { assert(is_object(), "oops"); return rec->oop_at(index()); } + }; +#endif + private: // State for writing a new set of dependencies: GrowableArray* _dep_seen; // (seen[h->ident] & (1<assert_evol_method(method_dv); + _dependencies->assert_evol_method(method()); } void CodeInstaller::assumption_ConcreteSubtype(Handle assumption) { @@ -409,12 +408,10 @@ Klass* context = asKlass(HotSpotResolvedObjectType::metaspaceKlass(context_handle)); Klass* subtype = asKlass(HotSpotResolvedObjectType::metaspaceKlass(subtype_handle)); - DepValue subtype_dv(_oop_recorder, subtype); - _dependencies->assert_leaf_type(subtype_dv); + _dependencies->assert_leaf_type(subtype); if (context != subtype) { assert(context->is_abstract(), ""); - DepValue context_dv(_oop_recorder, context); - _dependencies->assert_abstract_with_unique_concrete_subtype(context_dv, subtype_dv); + _dependencies->assert_abstract_with_unique_concrete_subtype(context, subtype); } } @@ -425,9 +422,7 @@ methodHandle impl = getMethodFromHotSpotMethod(impl_handle()); Klass* context = asKlass(HotSpotResolvedObjectType::metaspaceKlass(context_handle)); - DepValue context_dv(_oop_recorder, context); - DepValue impl_dv(_oop_recorder, impl()); - _dependencies->assert_unique_concrete_method(context_dv, impl_dv); + _dependencies->assert_unique_concrete_method(context, impl()); } void CodeInstaller::process_exception_handlers() { diff -r f1f32b695d1e -r 4983da9d3fc7 src/share/vm/prims/jni.cpp --- a/src/share/vm/prims/jni.cpp Thu Nov 29 17:43:09 2012 -0800 +++ b/src/share/vm/prims/jni.cpp Thu Nov 29 17:43:48 2012 -0800 @@ -5152,9 +5152,8 @@ *(JNIEnv**)penv = thread->jni_environment(); #ifdef GRAAL - GraalCompiler* compiler = GraalCompiler::instance(); - ciObjectFactory::initialize(); - compiler->initialize(); + GraalCompiler* compiler = GraalCompiler::instance(); + compiler->initialize(); #endif // Tracks the time application was running before GC