< prev index next >

src/share/vm/compiler/compilerDirectives.cpp

Print this page
rev 10354 : 8150646: Add support for blocking compiles though whitebox API
Reviewed-by: kvn, ppunegov, simonis, neliasso
Contributed-by: nils.eliasson@oracle.com, volker.simonis@gmail.com
   1 /*
   2  * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 455 
 456   assert(_bottom != NULL, "Must never be empty");
 457   _bottom->inc_refcount();
 458   return _bottom->get_for(comp);
 459 }
 460 
 461 void DirectivesStack::push(CompilerDirectives* directive) {
 462   MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
 463 
 464   directive->inc_refcount();
 465   if (_top == NULL) {
 466     assert(_bottom == NULL, "There can only be one default directive");
 467     _bottom = directive; // default directive, can never be removed.
 468   }
 469 
 470   directive->set_next(_top);
 471   _top = directive;
 472   _depth++;
 473 }
 474 
 475 void DirectivesStack::pop() {
 476   MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);


 477   pop_inner();

 478 }
 479 
 480 void DirectivesStack::pop_inner() {
 481   assert(DirectivesStack_lock->owned_by_self(), "");
 482 
 483   if (_top->next() == NULL) {
 484     return; // Do nothing - don't allow an empty stack
 485   }
 486   CompilerDirectives* tmp = _top;
 487   _top = _top->next();
 488   _depth--;
 489 
 490   DirectivesStack::release(tmp);
 491 }
 492 
 493 bool DirectivesStack::check_capacity(int request_size, outputStream* st) {
 494   if ((request_size + _depth) > CompilerDirectivesLimit) {
 495     st->print_cr("Could not add %i more directives. Currently %i/%i directives.", request_size, _depth, CompilerDirectivesLimit);
 496     return false;
 497   }


   1 /*
   2  * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 455 
 456   assert(_bottom != NULL, "Must never be empty");
 457   _bottom->inc_refcount();
 458   return _bottom->get_for(comp);
 459 }
 460 
 461 void DirectivesStack::push(CompilerDirectives* directive) {
 462   MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
 463 
 464   directive->inc_refcount();
 465   if (_top == NULL) {
 466     assert(_bottom == NULL, "There can only be one default directive");
 467     _bottom = directive; // default directive, can never be removed.
 468   }
 469 
 470   directive->set_next(_top);
 471   _top = directive;
 472   _depth++;
 473 }
 474 
 475 void DirectivesStack::pop(int count) {
 476   MutexLockerEx locker(DirectivesStack_lock, Mutex::_no_safepoint_check_flag);
 477   assert(count > -1, "No negative values");
 478   for (int i = 0; i < count; i++) {
 479     pop_inner();
 480   }
 481 }
 482 
 483 void DirectivesStack::pop_inner() {
 484   assert(DirectivesStack_lock->owned_by_self(), "");
 485 
 486   if (_top->next() == NULL) {
 487     return; // Do nothing - don't allow an empty stack
 488   }
 489   CompilerDirectives* tmp = _top;
 490   _top = _top->next();
 491   _depth--;
 492 
 493   DirectivesStack::release(tmp);
 494 }
 495 
 496 bool DirectivesStack::check_capacity(int request_size, outputStream* st) {
 497   if ((request_size + _depth) > CompilerDirectivesLimit) {
 498     st->print_cr("Could not add %i more directives. Currently %i/%i directives.", request_size, _depth, CompilerDirectivesLimit);
 499     return false;
 500   }


< prev index next >