Mercurial > hg > graal-compiler
comparison src/share/vm/code/dependencies.cpp @ 7101:0778b04fc682
better encoding of dependencies during dependency recording by Graal
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 29 Nov 2012 22:53:03 +0100 |
parents | eec7173947a1 |
children | a7a93887b4c4 |
comparison
equal
deleted
inserted
replaced
7100:35568cbc6a43 | 7101:0778b04fc682 |
---|---|
137 _size_in_bytes = (size_t)-1; | 137 _size_in_bytes = (size_t)-1; |
138 | 138 |
139 assert(TYPE_LIMIT <= (1<<LG2_TYPE_LIMIT), "sanity"); | 139 assert(TYPE_LIMIT <= (1<<LG2_TYPE_LIMIT), "sanity"); |
140 } | 140 } |
141 | 141 |
142 void Dependencies::assert_evol_method(DepValue m) { | 142 void Dependencies::assert_evol_method(Method* m) { |
143 assert_common_1(evol_method, m); | 143 assert_common_1(evol_method, DepValue(_oop_recorder, m)); |
144 } | 144 } |
145 | 145 |
146 void Dependencies::assert_leaf_type(DepValue ctxk_dv) { | 146 void Dependencies::assert_leaf_type(Klass* ctxk) { |
147 Klass* ctxk = ctxk_dv.as_klass(); | |
148 if (ctxk->oop_is_array()) { | 147 if (ctxk->oop_is_array()) { |
149 // As a special case, support this assertion on an array type, | 148 // As a special case, support this assertion on an array type, |
150 // which reduces to an assertion on its element type. | 149 // which reduces to an assertion on its element type. |
151 // Note that this cannot be done with assertions that | 150 // Note that this cannot be done with assertions that |
152 // relate to concreteness or abstractness. | 151 // relate to concreteness or abstractness. |
154 if (is_java_primitive(elemt)) return; // Ex: int[][] | 153 if (is_java_primitive(elemt)) return; // Ex: int[][] |
155 ctxk = ObjArrayKlass::cast(ctxk)->bottom_klass(); | 154 ctxk = ObjArrayKlass::cast(ctxk)->bottom_klass(); |
156 //if (ctxk->is_final()) return; // Ex: String[][] | 155 //if (ctxk->is_final()) return; // Ex: String[][] |
157 } | 156 } |
158 check_ctxk(ctxk); | 157 check_ctxk(ctxk); |
159 assert_common_1(leaf_type, ctxk_dv); | 158 assert_common_1(leaf_type, DepValue(_oop_recorder, ctxk)); |
160 } | 159 } |
161 | 160 |
162 void Dependencies::assert_abstract_with_unique_concrete_subtype(DepValue ctxk, DepValue conck) { | 161 void Dependencies::assert_abstract_with_unique_concrete_subtype(Klass* ctxk, Klass* conck) { |
163 check_ctxk_abstract(ctxk.as_klass()); | 162 check_ctxk_abstract(ctxk); |
164 assert_common_2(abstract_with_unique_concrete_subtype, ctxk, conck); | 163 DepValue ctxk_dv(_oop_recorder, ctxk); |
165 } | 164 DepValue conck_dv(_oop_recorder, conck, &ctxk_dv); |
166 | 165 assert_common_2(abstract_with_unique_concrete_subtype, ctxk_dv, conck_dv); |
167 void Dependencies::assert_unique_concrete_method(DepValue ctxk, DepValue uniqm) { | 166 } |
168 check_ctxk(ctxk.as_klass()); | 167 |
169 assert_common_2(unique_concrete_method, ctxk, uniqm); | 168 void Dependencies::assert_unique_concrete_method(Klass* ctxk, Method* uniqm) { |
169 check_ctxk(ctxk); | |
170 assert_common_2(unique_concrete_method, DepValue(_oop_recorder, ctxk), DepValue(_oop_recorder, uniqm)); | |
170 } | 171 } |
171 #endif // GRAAL | 172 #endif // GRAAL |
172 | 173 |
173 | 174 |
174 // Helper function. If we are adding a new dep. under ctxk2, | 175 // Helper function. If we are adding a new dep. under ctxk2, |
283 } | 284 } |
284 | 285 |
285 #ifdef GRAAL | 286 #ifdef GRAAL |
286 bool Dependencies::maybe_merge_ctxk(GrowableArray<DepValue>* deps, | 287 bool Dependencies::maybe_merge_ctxk(GrowableArray<DepValue>* deps, |
287 int ctxk_i, DepValue ctxk2_dv) { | 288 int ctxk_i, DepValue ctxk2_dv) { |
288 Klass* ctxk1 = deps->at(ctxk_i).as_klass(); | 289 Klass* ctxk1 = deps->at(ctxk_i).as_klass(_oop_recorder); |
289 Klass* ctxk2 = ctxk2_dv.as_klass(); | 290 Klass* ctxk2 = ctxk2_dv.as_klass(_oop_recorder); |
290 if (ctxk2->is_subtype_of(ctxk1)) { | 291 if (ctxk2->is_subtype_of(ctxk1)) { |
291 return true; // success, and no need to change | 292 return true; // success, and no need to change |
292 } else if (ctxk1->is_subtype_of(ctxk2)) { | 293 } else if (ctxk1->is_subtype_of(ctxk2)) { |
293 // new context class fully subsumes previous one | 294 // new context class fully subsumes previous one |
294 deps->at_put(ctxk_i, ctxk2_dv); | 295 deps->at_put(ctxk_i, ctxk2_dv); |
380 static int sort_dep_arg_3(ciBaseObject** p1, ciBaseObject** p2) | 381 static int sort_dep_arg_3(ciBaseObject** p1, ciBaseObject** p2) |
381 { return sort_dep(p1, p2, 3); } | 382 { return sort_dep(p1, p2, 3); } |
382 | 383 |
383 #ifdef GRAAL | 384 #ifdef GRAAL |
384 // metadata deps are sorted before object deps | 385 // metadata deps are sorted before object deps |
385 static int sort_dep_value(DepValue* p1, DepValue* p2, int narg) { | 386 static int sort_dep_value(Dependencies::DepValue* p1, Dependencies::DepValue* p2, int narg) { |
386 for (int i = 0; i < narg; i++) { | 387 for (int i = 0; i < narg; i++) { |
387 int diff = p1[i].sort_key() - p2[i].sort_key(); | 388 int diff = p1[i].sort_key() - p2[i].sort_key(); |
388 if (diff != 0) return diff; | 389 if (diff != 0) return diff; |
389 } | 390 } |
390 return 0; | 391 return 0; |
391 } | 392 } |
392 static int sort_dep_value_arg_1(DepValue* p1, DepValue* p2) | 393 static int sort_dep_value_arg_1(Dependencies::DepValue* p1, Dependencies::DepValue* p2) |
393 { return sort_dep_value(p1, p2, 1); } | 394 { return sort_dep_value(p1, p2, 1); } |
394 static int sort_dep_value_arg_2(DepValue* p1, DepValue* p2) | 395 static int sort_dep_value_arg_2(Dependencies::DepValue* p1, Dependencies::DepValue* p2) |
395 { return sort_dep_value(p1, p2, 2); } | 396 { return sort_dep_value(p1, p2, 2); } |
396 static int sort_dep_value_arg_3(DepValue* p1, DepValue* p2) | 397 static int sort_dep_value_arg_3(Dependencies::DepValue* p1, Dependencies::DepValue* p2) |
397 { return sort_dep_value(p1, p2, 3); } | 398 { return sort_dep_value(p1, p2, 3); } |
398 #endif // GRAAL | 399 #endif // GRAAL |
399 | 400 |
400 void Dependencies::sort_all_deps() { | 401 void Dependencies::sort_all_deps() { |
401 #ifdef GRAAL | 402 #ifdef GRAAL |
489 assert(stride > 0, "sanity"); | 490 assert(stride > 0, "sanity"); |
490 for (int i = 0; i < deps->length(); i += stride) { | 491 for (int i = 0; i < deps->length(); i += stride) { |
491 jbyte code_byte = (jbyte)dept; | 492 jbyte code_byte = (jbyte)dept; |
492 int skipj = -1; | 493 int skipj = -1; |
493 if (ctxkj >= 0 && ctxkj+1 < stride) { | 494 if (ctxkj >= 0 && ctxkj+1 < stride) { |
494 Klass* ctxk = deps->at(i+ctxkj+0).as_klass(); | 495 Klass* ctxk = deps->at(i+ctxkj+0).as_klass(_oop_recorder); |
495 DepValue x = deps->at(i+ctxkj+1); // following argument | 496 DepValue x = deps->at(i+ctxkj+1); // following argument |
496 if (ctxk == ctxk_encoded_as_null(dept, x.as_metadata())) { | 497 if (ctxk == ctxk_encoded_as_null(dept, x.as_metadata(_oop_recorder))) { |
497 skipj = ctxkj; // we win: maybe one less oop to keep track of | 498 skipj = ctxkj; // we win: maybe one less oop to keep track of |
498 code_byte |= default_context_type_bit; | 499 code_byte |= default_context_type_bit; |
499 } | 500 } |
500 } | 501 } |
501 bytes.write_byte(code_byte); | 502 bytes.write_byte(code_byte); |