--- old/src/share/vm/oops/method.cpp 2017-08-25 10:01:47.448620939 -0400 +++ new/src/share/vm/oops/method.cpp 2017-08-25 10:01:47.045210242 -0400 @@ -214,26 +214,14 @@ } void Method::mask_for(int bci, InterpreterOopMap* mask) { - - Thread* myThread = Thread::current(); - methodHandle h_this(myThread, this); -#if defined(ASSERT) && !INCLUDE_JVMCI - bool has_capability = myThread->is_VM_thread() || - myThread->is_ConcurrentGC_thread() || - myThread->is_GC_task_thread(); - - if (!has_capability) { - if (!VerifyStack && !VerifyLastFrame) { - // verify stack calls this outside VM thread - warning("oopmap should only be accessed by the " - "VM, GC task or CMS threads (or during debugging)"); - InterpreterOopMap local_mask; - method_holder()->mask_for(h_this, bci, &local_mask); - local_mask.print(); - } + methodHandle h_this(Thread::current(), this); + // Only GC uses the OopMapCache during thread stack root scanning + // and other uses generate an oopmap but do not save it in the cache. + if (Universe::heap()->is_gc_active()) { + method_holder()->mask_for(h_this, bci, mask); + } else { + OopMapCache::compute_one_oop_map(h_this, bci, mask); } -#endif - method_holder()->mask_for(h_this, bci, mask); return; }