src/hotspot/share/runtime/interfaceSupport.cpp
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 54786 ebf733a324d4
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    53 VMEntryWrapper::~VMEntryWrapper() {
    53 VMEntryWrapper::~VMEntryWrapper() {
    54   InterfaceSupport::check_gc_alot();
    54   InterfaceSupport::check_gc_alot();
    55   if (WalkStackALot) {
    55   if (WalkStackALot) {
    56     InterfaceSupport::walk_stack();
    56     InterfaceSupport::walk_stack();
    57   }
    57   }
    58 #ifdef COMPILER2
       
    59   // This option is not used by Compiler 1
       
    60   if (StressDerivedPointers) {
       
    61     InterfaceSupport::stress_derived_pointers();
       
    62   }
       
    63 #endif
       
    64   if (DeoptimizeALot || DeoptimizeRandom) {
    58   if (DeoptimizeALot || DeoptimizeRandom) {
    65     InterfaceSupport::deoptimizeAll();
    59     InterfaceSupport::deoptimizeAll();
    66   }
    60   }
    67   if (ZombieALot) {
    61   if (ZombieALot) {
    68     InterfaceSupport::zombieAll();
    62     InterfaceSupport::zombieAll();
    69   }
    63   }
    70   // do verification AFTER potential deoptimization
    64   // do verification AFTER potential deoptimization
    71   if (VerifyStack) {
    65   if (VerifyStack) {
    72     InterfaceSupport::verify_stack();
    66     InterfaceSupport::verify_stack();
    73   }
    67   }
       
    68 }
       
    69 
       
    70 VMNativeEntryWrapper::VMNativeEntryWrapper() {
       
    71   if (GCALotAtAllSafepoints) InterfaceSupport::check_gc_alot();
       
    72 }
       
    73 
       
    74 VMNativeEntryWrapper::~VMNativeEntryWrapper() {
       
    75   if (GCALotAtAllSafepoints) InterfaceSupport::check_gc_alot();
    74 }
    76 }
    75 
    77 
    76 long InterfaceSupport::_number_of_calls       = 0;
    78 long InterfaceSupport::_number_of_calls       = 0;
    77 long InterfaceSupport::_scavenge_alot_counter = 1;
    79 long InterfaceSupport::_scavenge_alot_counter = 1;
    78 long InterfaceSupport::_fullgc_alot_counter   = 1;
    80 long InterfaceSupport::_fullgc_alot_counter   = 1;
   224   }
   226   }
   225   deoptimizeAllCounter++;
   227   deoptimizeAllCounter++;
   226 }
   228 }
   227 
   229 
   228 
   230 
   229 void InterfaceSupport::stress_derived_pointers() {
       
   230 #ifdef COMPILER2
       
   231   JavaThread *thread = JavaThread::current();
       
   232   if (!is_init_completed()) return;
       
   233   ResourceMark rm(thread);
       
   234   bool found = false;
       
   235   for (StackFrameStream sfs(thread); !sfs.is_done() && !found; sfs.next()) {
       
   236     CodeBlob* cb = sfs.current()->cb();
       
   237     if (cb != NULL && cb->oop_maps() ) {
       
   238       // Find oopmap for current method
       
   239       const ImmutableOopMap* map = cb->oop_map_for_return_address(sfs.current()->pc());
       
   240       assert(map != NULL, "no oopmap found for pc");
       
   241       found = map->has_derived_pointer();
       
   242     }
       
   243   }
       
   244   if (found) {
       
   245     // $$$ Not sure what to do here.
       
   246     /*
       
   247     Scavenge::invoke(0);
       
   248     */
       
   249   }
       
   250 #endif
       
   251 }
       
   252 
       
   253 
       
   254 void InterfaceSupport::verify_stack() {
   231 void InterfaceSupport::verify_stack() {
   255   JavaThread* thread = JavaThread::current();
   232   JavaThread* thread = JavaThread::current();
   256   ResourceMark rm(thread);
   233   ResourceMark rm(thread);
   257   // disabled because it throws warnings that oop maps should only be accessed
   234   // disabled because it throws warnings that oop maps should only be accessed
   258   // in VM thread or during debugging
   235   // in VM thread or during debugging
   290   if (ScavengeALot || FullGCALot) {
   267   if (ScavengeALot || FullGCALot) {
   291     srand(ScavengeALotInterval * FullGCALotInterval);
   268     srand(ScavengeALotInterval * FullGCALotInterval);
   292   }
   269   }
   293 #endif
   270 #endif
   294 }
   271 }
   295 
       
   296 #ifdef ASSERT
       
   297 // JRT_LEAF rules:
       
   298 // A JRT_LEAF method may not interfere with safepointing by
       
   299 //   1) acquiring or blocking on a Mutex or JavaLock - checked
       
   300 //   2) allocating heap memory - checked
       
   301 //   3) executing a VM operation - checked
       
   302 //   4) executing a system call (including malloc) that could block or grab a lock
       
   303 //   5) invoking GC
       
   304 //   6) reaching a safepoint
       
   305 //   7) running too long
       
   306 // Nor may any method it calls.
       
   307 JRTLeafVerifier::JRTLeafVerifier()
       
   308   : NoSafepointVerifier(true, JRTLeafVerifier::should_verify_GC())
       
   309 {
       
   310 }
       
   311 
       
   312 JRTLeafVerifier::~JRTLeafVerifier()
       
   313 {
       
   314 }
       
   315 
       
   316 bool JRTLeafVerifier::should_verify_GC() {
       
   317   switch (JavaThread::current()->thread_state()) {
       
   318   case _thread_in_Java:
       
   319     // is in a leaf routine, there must be no safepoint.
       
   320     return true;
       
   321   case _thread_in_native:
       
   322     // A native thread is not subject to safepoints.
       
   323     // Even while it is in a leaf routine, GC is ok
       
   324     return false;
       
   325   default:
       
   326     // Leaf routines cannot be called from other contexts.
       
   327     ShouldNotReachHere();
       
   328     return false;
       
   329   }
       
   330 }
       
   331 #endif // ASSERT