src/share/vm/code/nmethod.hpp

changeset 8734
c73c5d205d0a
parent 8075
be740540f60c
child 8856
ac27a9c85bea
     1.1 --- a/src/share/vm/code/nmethod.hpp	Tue Apr 04 02:49:51 2017 -0700
     1.2 +++ b/src/share/vm/code/nmethod.hpp	Fri Apr 07 02:15:31 2017 +0900
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -39,15 +39,16 @@
    1.11    Klass*   _exception_type;
    1.12    address  _pc[cache_size];
    1.13    address  _handler[cache_size];
    1.14 -  int      _count;
    1.15 +  volatile int _count;
    1.16    ExceptionCache* _next;
    1.17  
    1.18    address pc_at(int index)                     { assert(index >= 0 && index < count(),""); return _pc[index]; }
    1.19    void    set_pc_at(int index, address a)      { assert(index >= 0 && index < cache_size,""); _pc[index] = a; }
    1.20    address handler_at(int index)                { assert(index >= 0 && index < count(),""); return _handler[index]; }
    1.21    void    set_handler_at(int index, address a) { assert(index >= 0 && index < cache_size,""); _handler[index] = a; }
    1.22 -  int     count()                              { return _count; }
    1.23 -  void    increment_count()                    { _count++; }
    1.24 +  int     count()                              { return OrderAccess::load_acquire(&_count); }
    1.25 +  // increment_count is only called under lock, but there may be concurrent readers.
    1.26 +  void    increment_count()                    { OrderAccess::release_store(&_count, _count + 1); }
    1.27  
    1.28   public:
    1.29  
    1.30 @@ -237,7 +238,7 @@
    1.31    // counter is decreased (by 1) while sweeping.
    1.32    int _hotness_counter;
    1.33  
    1.34 -  ExceptionCache *_exception_cache;
    1.35 +  ExceptionCache * volatile _exception_cache;
    1.36    PcDescCache     _pc_desc_cache;
    1.37  
    1.38    // These are used for compiled synchronized native methods to
    1.39 @@ -433,7 +434,7 @@
    1.40  
    1.41    // flag accessing and manipulation
    1.42    bool  is_in_use() const                         { return _state == in_use; }
    1.43 -  bool  is_alive() const                          { return _state == in_use || _state == not_entrant; }
    1.44 +  bool  is_alive() const                          { unsigned char s = _state; return s == in_use || s == not_entrant; }
    1.45    bool  is_not_entrant() const                    { return _state == not_entrant; }
    1.46    bool  is_zombie() const                         { return _state == zombie; }
    1.47    bool  is_unloaded() const                       { return _state == unloaded;   }
    1.48 @@ -555,8 +556,10 @@
    1.49    void  set_stack_traversal_mark(long l)          { _stack_traversal_mark = l; }
    1.50  
    1.51    // Exception cache support
    1.52 +  // Note: _exception_cache may be read concurrently. We rely on memory_order_consume here.
    1.53    ExceptionCache* exception_cache() const         { return _exception_cache; }
    1.54    void set_exception_cache(ExceptionCache *ec)    { _exception_cache = ec; }
    1.55 +  void release_set_exception_cache(ExceptionCache *ec) { OrderAccess::release_store_ptr(&_exception_cache, ec); }
    1.56    address handler_for_exception_and_pc(Handle exception, address pc);
    1.57    void add_handler_for_exception_and_pc(Handle exception, address pc, address handler);
    1.58    void clean_exception_cache(BoolObjectClosure* is_alive);

mercurial