Mercurial > hg > truffle
comparison src/share/vm/code/dependencies.cpp @ 21559:be896a1983c0
recast all Graal native code as JVMCI code (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 28 May 2015 15:36:48 +0200 |
parents | 91d70d102132 |
children | 12dcf5ba8b34 |
comparison
equal
deleted
inserted
replaced
21558:d563baeca9df | 21559:be896a1983c0 |
---|---|
50 void Dependencies::initialize(ciEnv* env) { | 50 void Dependencies::initialize(ciEnv* env) { |
51 Arena* arena = env->arena(); | 51 Arena* arena = env->arena(); |
52 _oop_recorder = env->oop_recorder(); | 52 _oop_recorder = env->oop_recorder(); |
53 _log = env->log(); | 53 _log = env->log(); |
54 _dep_seen = new(arena) GrowableArray<int>(arena, 500, 0, 0); | 54 _dep_seen = new(arena) GrowableArray<int>(arena, 500, 0, 0); |
55 #ifdef GRAAL | 55 #ifdef JVMCI |
56 _using_dep_values = false; | 56 _using_dep_values = false; |
57 #endif // GRAAL | 57 #endif // JVMCI |
58 DEBUG_ONLY(_deps[end_marker] = NULL); | 58 DEBUG_ONLY(_deps[end_marker] = NULL); |
59 for (int i = (int)FIRST_TYPE; i < (int)TYPE_LIMIT; i++) { | 59 for (int i = (int)FIRST_TYPE; i < (int)TYPE_LIMIT; i++) { |
60 _deps[i] = new(arena) GrowableArray<ciBaseObject*>(arena, 10, 0, 0); | 60 _deps[i] = new(arena) GrowableArray<ciBaseObject*>(arena, 10, 0, 0); |
61 } | 61 } |
62 _content_bytes = NULL; | 62 _content_bytes = NULL; |
122 void Dependencies::assert_call_site_target_value(ciCallSite* call_site, ciMethodHandle* method_handle) { | 122 void Dependencies::assert_call_site_target_value(ciCallSite* call_site, ciMethodHandle* method_handle) { |
123 check_ctxk(call_site->klass()); | 123 check_ctxk(call_site->klass()); |
124 assert_common_2(call_site_target_value, call_site, method_handle); | 124 assert_common_2(call_site_target_value, call_site, method_handle); |
125 } | 125 } |
126 | 126 |
127 #ifdef GRAAL | 127 #ifdef JVMCI |
128 | 128 |
129 Dependencies::Dependencies(Arena* arena, OopRecorder* oop_recorder, CompileLog* log) { | 129 Dependencies::Dependencies(Arena* arena, OopRecorder* oop_recorder, CompileLog* log) { |
130 _oop_recorder = oop_recorder; | 130 _oop_recorder = oop_recorder; |
131 _log = log; | 131 _log = log; |
132 _dep_seen = new(arena) GrowableArray<int>(arena, 500, 0, 0); | 132 _dep_seen = new(arena) GrowableArray<int>(arena, 500, 0, 0); |
178 } | 178 } |
179 | 179 |
180 void Dependencies::assert_call_site_target_value(oop call_site, oop method_handle) { | 180 void Dependencies::assert_call_site_target_value(oop call_site, oop method_handle) { |
181 assert_common_2(call_site_target_value, DepValue(_oop_recorder, JNIHandles::make_local(call_site)), DepValue(_oop_recorder, JNIHandles::make_local(method_handle))); | 181 assert_common_2(call_site_target_value, DepValue(_oop_recorder, JNIHandles::make_local(call_site)), DepValue(_oop_recorder, JNIHandles::make_local(method_handle))); |
182 } | 182 } |
183 #endif // GRAAL | 183 #endif // JVMCI |
184 | 184 |
185 | 185 |
186 // Helper function. If we are adding a new dep. under ctxk2, | 186 // Helper function. If we are adding a new dep. under ctxk2, |
187 // try to find an old dep. under a broader* ctxk1. If there is | 187 // try to find an old dep. under a broader* ctxk1. If there is |
188 // | 188 // |
292 deps->append(ctxk); | 292 deps->append(ctxk); |
293 deps->append(x); | 293 deps->append(x); |
294 deps->append(x2); | 294 deps->append(x2); |
295 } | 295 } |
296 | 296 |
297 #ifdef GRAAL | 297 #ifdef JVMCI |
298 bool Dependencies::maybe_merge_ctxk(GrowableArray<DepValue>* deps, | 298 bool Dependencies::maybe_merge_ctxk(GrowableArray<DepValue>* deps, |
299 int ctxk_i, DepValue ctxk2_dv) { | 299 int ctxk_i, DepValue ctxk2_dv) { |
300 Klass* ctxk1 = deps->at(ctxk_i).as_klass(_oop_recorder); | 300 Klass* ctxk1 = deps->at(ctxk_i).as_klass(_oop_recorder); |
301 Klass* ctxk2 = ctxk2_dv.as_klass(_oop_recorder); | 301 Klass* ctxk2 = ctxk2_dv.as_klass(_oop_recorder); |
302 if (ctxk2->is_subtype_of(ctxk1)) { | 302 if (ctxk2->is_subtype_of(ctxk1)) { |
362 | 362 |
363 // append the assertion in the correct bucket: | 363 // append the assertion in the correct bucket: |
364 deps->append(x0); | 364 deps->append(x0); |
365 deps->append(x1); | 365 deps->append(x1); |
366 } | 366 } |
367 #endif // GRAAL | 367 #endif // JVMCI |
368 | 368 |
369 /// Support for encoding dependencies into an nmethod: | 369 /// Support for encoding dependencies into an nmethod: |
370 | 370 |
371 void Dependencies::copy_to(nmethod* nm) { | 371 void Dependencies::copy_to(nmethod* nm) { |
372 address beg = nm->dependencies_begin(); | 372 address beg = nm->dependencies_begin(); |
390 static int sort_dep_arg_2(ciBaseObject** p1, ciBaseObject** p2) | 390 static int sort_dep_arg_2(ciBaseObject** p1, ciBaseObject** p2) |
391 { return sort_dep(p1, p2, 2); } | 391 { return sort_dep(p1, p2, 2); } |
392 static int sort_dep_arg_3(ciBaseObject** p1, ciBaseObject** p2) | 392 static int sort_dep_arg_3(ciBaseObject** p1, ciBaseObject** p2) |
393 { return sort_dep(p1, p2, 3); } | 393 { return sort_dep(p1, p2, 3); } |
394 | 394 |
395 #ifdef GRAAL | 395 #ifdef JVMCI |
396 // metadata deps are sorted before object deps | 396 // metadata deps are sorted before object deps |
397 static int sort_dep_value(Dependencies::DepValue* p1, Dependencies::DepValue* p2, int narg) { | 397 static int sort_dep_value(Dependencies::DepValue* p1, Dependencies::DepValue* p2, int narg) { |
398 for (int i = 0; i < narg; i++) { | 398 for (int i = 0; i < narg; i++) { |
399 int diff = p1[i].sort_key() - p2[i].sort_key(); | 399 int diff = p1[i].sort_key() - p2[i].sort_key(); |
400 if (diff != 0) return diff; | 400 if (diff != 0) return diff; |
405 { return sort_dep_value(p1, p2, 1); } | 405 { return sort_dep_value(p1, p2, 1); } |
406 static int sort_dep_value_arg_2(Dependencies::DepValue* p1, Dependencies::DepValue* p2) | 406 static int sort_dep_value_arg_2(Dependencies::DepValue* p1, Dependencies::DepValue* p2) |
407 { return sort_dep_value(p1, p2, 2); } | 407 { return sort_dep_value(p1, p2, 2); } |
408 static int sort_dep_value_arg_3(Dependencies::DepValue* p1, Dependencies::DepValue* p2) | 408 static int sort_dep_value_arg_3(Dependencies::DepValue* p1, Dependencies::DepValue* p2) |
409 { return sort_dep_value(p1, p2, 3); } | 409 { return sort_dep_value(p1, p2, 3); } |
410 #endif // GRAAL | 410 #endif // JVMCI |
411 | 411 |
412 void Dependencies::sort_all_deps() { | 412 void Dependencies::sort_all_deps() { |
413 #ifdef GRAAL | 413 #ifdef JVMCI |
414 if (_using_dep_values) { | 414 if (_using_dep_values) { |
415 for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { | 415 for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { |
416 DepType dept = (DepType)deptv; | 416 DepType dept = (DepType)deptv; |
417 GrowableArray<DepValue>* deps = _dep_values[dept]; | 417 GrowableArray<DepValue>* deps = _dep_values[dept]; |
418 if (deps->length() <= 1) continue; | 418 if (deps->length() <= 1) continue; |
423 default: ShouldNotReachHere(); | 423 default: ShouldNotReachHere(); |
424 } | 424 } |
425 } | 425 } |
426 return; | 426 return; |
427 } | 427 } |
428 #endif // GRAAL | 428 #endif // JVMCI |
429 for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { | 429 for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { |
430 DepType dept = (DepType)deptv; | 430 DepType dept = (DepType)deptv; |
431 GrowableArray<ciBaseObject*>* deps = _deps[dept]; | 431 GrowableArray<ciBaseObject*>* deps = _deps[dept]; |
432 if (deps->length() <= 1) continue; | 432 if (deps->length() <= 1) continue; |
433 switch (dep_args(dept)) { | 433 switch (dep_args(dept)) { |
439 } | 439 } |
440 } | 440 } |
441 | 441 |
442 size_t Dependencies::estimate_size_in_bytes() { | 442 size_t Dependencies::estimate_size_in_bytes() { |
443 size_t est_size = 100; | 443 size_t est_size = 100; |
444 #ifdef GRAAL | 444 #ifdef JVMCI |
445 if (_using_dep_values) { | 445 if (_using_dep_values) { |
446 for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { | 446 for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { |
447 DepType dept = (DepType)deptv; | 447 DepType dept = (DepType)deptv; |
448 GrowableArray<DepValue>* deps = _dep_values[dept]; | 448 GrowableArray<DepValue>* deps = _dep_values[dept]; |
449 est_size += deps->length() * 2; // tags and argument(s) | 449 est_size += deps->length() * 2; // tags and argument(s) |
450 } | 450 } |
451 return est_size; | 451 return est_size; |
452 } | 452 } |
453 #endif // GRAAL | 453 #endif // JVMCI |
454 for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { | 454 for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { |
455 DepType dept = (DepType)deptv; | 455 DepType dept = (DepType)deptv; |
456 GrowableArray<ciBaseObject*>* deps = _deps[dept]; | 456 GrowableArray<ciBaseObject*>* deps = _deps[dept]; |
457 est_size += deps->length()*2; // tags and argument(s) | 457 est_size += deps->length()*2; // tags and argument(s) |
458 } | 458 } |
488 sort_all_deps(); | 488 sort_all_deps(); |
489 | 489 |
490 // cast is safe, no deps can overflow INT_MAX | 490 // cast is safe, no deps can overflow INT_MAX |
491 CompressedWriteStream bytes((int)estimate_size_in_bytes()); | 491 CompressedWriteStream bytes((int)estimate_size_in_bytes()); |
492 | 492 |
493 #ifdef GRAAL | 493 #ifdef JVMCI |
494 if (_using_dep_values) { | 494 if (_using_dep_values) { |
495 for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { | 495 for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { |
496 DepType dept = (DepType)deptv; | 496 DepType dept = (DepType)deptv; |
497 GrowableArray<DepValue>* deps = _dep_values[dept]; | 497 GrowableArray<DepValue>* deps = _dep_values[dept]; |
498 if (deps->length() == 0) continue; | 498 if (deps->length() == 0) continue; |
518 bytes.write_int(idx); | 518 bytes.write_int(idx); |
519 } | 519 } |
520 } | 520 } |
521 } | 521 } |
522 } else { | 522 } else { |
523 #endif // GRAAL | 523 #endif // JVMCI |
524 for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { | 524 for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { |
525 DepType dept = (DepType)deptv; | 525 DepType dept = (DepType)deptv; |
526 GrowableArray<ciBaseObject*>* deps = _deps[dept]; | 526 GrowableArray<ciBaseObject*>* deps = _deps[dept]; |
527 if (deps->length() == 0) continue; | 527 if (deps->length() == 0) continue; |
528 int stride = dep_args(dept); | 528 int stride = dep_args(dept); |
552 } | 552 } |
553 bytes.write_int(idx); | 553 bytes.write_int(idx); |
554 } | 554 } |
555 } | 555 } |
556 } | 556 } |
557 #ifdef GRAAL | 557 #ifdef JVMCI |
558 } | 558 } |
559 #endif // GRAAL | 559 #endif // JVMCI |
560 | 560 |
561 // write a sentinel byte to mark the end | 561 // write a sentinel byte to mark the end |
562 bytes.write_byte(end_marker); | 562 bytes.write_byte(end_marker); |
563 | 563 |
564 // round it out to a word boundary | 564 // round it out to a word boundary |