comparison src/share/vm/graal/graalEnv.cpp @ 19321:98592ae4b1fa

only record method dependencies if JVMTI hotswapping or breakpointing is enabled don't verify dependencies if the SystemDictionary was not updated during compilation
author Doug Simon <doug.simon@oracle.com>
date Thu, 12 Feb 2015 16:54:12 +0100
parents 8f2fb6bec986
children dd8989d5547f
comparison
equal deleted inserted replaced
19320:49605c649beb 19321:98592ae4b1fa
42 #include "runtime/reflection.hpp" 42 #include "runtime/reflection.hpp"
43 #include "runtime/sharedRuntime.hpp" 43 #include "runtime/sharedRuntime.hpp"
44 #include "utilities/dtrace.hpp" 44 #include "utilities/dtrace.hpp"
45 #include "graal/graalRuntime.hpp" 45 #include "graal/graalRuntime.hpp"
46 #include "graal/graalJavaAccess.hpp" 46 #include "graal/graalJavaAccess.hpp"
47
48 GraalEnv::GraalEnv(CompileTask* task, int system_dictionary_modification_counter) {
49 _task = task;
50 _system_dictionary_modification_counter = system_dictionary_modification_counter;
51 {
52 // Get Jvmti capabilities under lock to get consistent values.
53 MutexLocker mu(JvmtiThreadState_lock);
54 _jvmti_can_hotswap_or_post_breakpoint = JvmtiExport::can_hotswap_or_post_breakpoint();
55 _jvmti_can_access_local_variables = JvmtiExport::can_access_local_variables();
56 _jvmti_can_post_on_exceptions = JvmtiExport::can_post_on_exceptions();
57 }
58 }
47 59
48 // ------------------------------------------------------------------ 60 // ------------------------------------------------------------------
49 // Note: the logic of this method should mirror the logic of 61 // Note: the logic of this method should mirror the logic of
50 // constantPoolOopDesc::verify_constant_pool_resolve. 62 // constantPoolOopDesc::verify_constant_pool_resolve.
51 bool GraalEnv::check_klass_accessibility(KlassHandle accessing_klass, KlassHandle resolved_klass) { 63 bool GraalEnv::check_klass_accessibility(KlassHandle accessing_klass, KlassHandle resolved_klass) {
407 } 419 }
408 420
409 // ------------------------------------------------------------------ 421 // ------------------------------------------------------------------
410 // Check for changes to the system dictionary during compilation 422 // Check for changes to the system dictionary during compilation
411 // class loads, evolution, breakpoints 423 // class loads, evolution, breakpoints
412 bool GraalEnv::check_for_system_dictionary_modification(Dependencies* dependencies) { 424 bool GraalEnv::check_for_system_dictionary_modification(Dependencies* dependencies, GraalEnv* env) {
413 // Dependencies must be checked when the system dictionary changes. 425 // If JVMTI capabilities were enabled during compile, the compilation is invalidated.
414 // If logging is enabled all violated dependences will be recorded in 426 if (env != NULL) {
415 // the log. In debug mode check dependencies even if the system 427 if (!env->_jvmti_can_hotswap_or_post_breakpoint && JvmtiExport::can_hotswap_or_post_breakpoint()) {
416 // dictionary hasn't changed to verify that no invalid dependencies 428 // Hotswapping or breakpointing was enabled during compilation
417 // were inserted. Any violated dependences in this case are dumped to 429 return false;
418 // the tty. 430 }
419 431 }
420 // TODO (thomaswue): Always check dependency for now. 432
421 //bool counter_changed = system_dictionary_modification_counter_changed(); 433 // Dependencies must be checked when the system dictionary changes
422 //bool test_deps = counter_changed; 434 // or if we don't know whether it has changed (i.e., env == NULL).
423 //DEBUG_ONLY(test_deps = true); 435 // In debug mode, always check dependencies.
424 //if (!test_deps) return; 436 bool counter_changed = env != NULL && env->_system_dictionary_modification_counter != SystemDictionary::number_of_modifications();
437 bool verify_deps = env == NULL || trueInDebug;
438 if (!counter_changed && !verify_deps) {
439 return true;
440 }
425 441
426 for (Dependencies::DepStream deps(dependencies); deps.next(); ) { 442 for (Dependencies::DepStream deps(dependencies); deps.next(); ) {
427 Klass* witness = deps.check_dependency(); 443 Klass* witness = deps.check_dependency();
428 if (witness != NULL) { 444 if (witness != NULL) {
429 return false; 445 return false;
448 OopMapSet* oop_map_set, 464 OopMapSet* oop_map_set,
449 ExceptionHandlerTable* handler_table, 465 ExceptionHandlerTable* handler_table,
450 AbstractCompiler* compiler, 466 AbstractCompiler* compiler,
451 DebugInformationRecorder* debug_info, 467 DebugInformationRecorder* debug_info,
452 Dependencies* dependencies, 468 Dependencies* dependencies,
453 CompileTask* task, 469 GraalEnv* env,
454 int compile_id, 470 int compile_id,
455 bool has_unsafe_access, 471 bool has_unsafe_access,
456 Handle installed_code, 472 Handle installed_code,
457 Handle speculation_log) { 473 Handle speculation_log) {
458 GRAAL_EXCEPTION_CONTEXT; 474 GRAAL_EXCEPTION_CONTEXT;
469 485
470 // Encode the dependencies now, so we can check them right away. 486 // Encode the dependencies now, so we can check them right away.
471 dependencies->encode_content_bytes(); 487 dependencies->encode_content_bytes();
472 488
473 // Check for {class loads, evolution, breakpoints} during compilation 489 // Check for {class loads, evolution, breakpoints} during compilation
474 if (!check_for_system_dictionary_modification(dependencies)) { 490 if (!check_for_system_dictionary_modification(dependencies, env)) {
475 // While not a true deoptimization, it is a preemptive decompile. 491 // While not a true deoptimization, it is a preemptive decompile.
476 MethodData* mdp = method()->method_data(); 492 MethodData* mdp = method()->method_data();
477 if (mdp != NULL) { 493 if (mdp != NULL) {
478 mdp->inc_decompile_count(); 494 mdp->inc_decompile_count();
479 if (mdp->decompile_count() > (uint)PerMethodRecompilationCutoff) { 495 if (mdp->decompile_count() > (uint)PerMethodRecompilationCutoff) {
514 } else { 530 } else {
515 nm->set_has_unsafe_access(has_unsafe_access); 531 nm->set_has_unsafe_access(has_unsafe_access);
516 532
517 // Record successful registration. 533 // Record successful registration.
518 // (Put nm into the task handle *before* publishing to the Java heap.) 534 // (Put nm into the task handle *before* publishing to the Java heap.)
535 CompileTask* task = env == NULL ? NULL : env->task();
519 if (task != NULL) task->set_code(nm); 536 if (task != NULL) task->set_code(nm);
520 537
521 if (installed_code->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isDefault(installed_code())) { 538 if (installed_code->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isDefault(installed_code())) {
522 if (entry_bci == InvocationEntryBci) { 539 if (entry_bci == InvocationEntryBci) {
523 if (TieredCompilation) { 540 if (TieredCompilation) {