src/hotspot/share/code/icBuffer.hpp
author eosterlund
Wed, 05 Dec 2018 15:57:26 +0100
changeset 52857 7e268f863ff0
parent 47216 71c04702a3d5
child 52896 98408c7c0b73
permissions -rw-r--r--
8214338: Move IC stub refilling out of IC cache transitions Reviewed-by: dlong, rbackman
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
22234
da823d78ad65 8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents: 16368
diff changeset
     2
 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_CODE_ICBUFFER_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_CODE_ICBUFFER_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
13887
89b873bcc55b 7200163: add CodeComments functionality to assember stubs
kvn
parents: 13728
diff changeset
    28
#include "asm/codeBuffer.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "code/stubs.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "interpreter/bytecodes.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "memory/allocation.hpp"
46625
edefffab74e2 8183552: Move align functions to align.hpp
stefank
parents: 46620
diff changeset
    32
#include "utilities/align.hpp"
52857
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 47216
diff changeset
    33
#include "utilities/macros.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    34
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// For CompiledIC's:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
// In cases where we do not have MT-safe state transformation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// we go to a transition state, using ICStubs. At a safepoint,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// the inline caches are transferred from the transitional code:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
//    instruction_address --> 01 set xxx_oop, Ginline_cache_klass
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
//                            23 jump_to Gtemp, yyyy
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
//                            4  nop
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
class ICStub: public Stub {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  int                 _size;       // total size of the stub incl. code
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  address             _ic_site;    // points at call instruction of owning ic-buffer
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  /* stub code follows here */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  friend class ICStubInterface;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  // This will be called only by ICStubInterface
13887
89b873bcc55b 7200163: add CodeComments functionality to assember stubs
kvn
parents: 13728
diff changeset
    54
  void    initialize(int size,
16368
713209c45a82 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 13887
diff changeset
    55
                     CodeStrings strings)        { _size = size; _ic_site = NULL; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  void    finalize(); // called when a method is removed
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  // General info
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  int     size() const                           { return _size; }
46620
750c6edff33b 8178500: Replace usages of round_to and round_down with align_up and align_down
stefank
parents: 22234
diff changeset
    60
  static  int code_size_to_size(int code_size)   { return align_up((int)sizeof(ICStub), CodeEntryAlignment) + code_size; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  // Creation
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
    64
  void set_stub(CompiledIC *ic, void* cached_value, address dest_addr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  // Code info
46620
750c6edff33b 8178500: Replace usages of round_to and round_down with align_up and align_down
stefank
parents: 22234
diff changeset
    67
  address code_begin() const                     { return (address)this + align_up(sizeof(ICStub), CodeEntryAlignment); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  address code_end() const                       { return (address)this + size(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  // Call site info
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  address ic_site() const                        { return _ic_site; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  void    clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  bool    is_empty() const                       { return _ic_site == NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  // stub info
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  address destination() const;  // destination of jump instruction
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
    77
  void* cached_value() const;   // cached_value for stub
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  // Debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  void    verify()            PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  void    print()             PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  // Creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  friend ICStub* ICStub_from_destination_address(address destination_address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
// ICStub Creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
inline ICStub* ICStub_from_destination_address(address destination_address) {
46620
750c6edff33b 8178500: Replace usages of round_to and round_down with align_up and align_down
stefank
parents: 22234
diff changeset
    89
  ICStub* stub = (ICStub*) (destination_address - align_up(sizeof(ICStub), CodeEntryAlignment));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  stub->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  return stub;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
class InlineCacheBuffer: public AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  // friends
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  friend class ICStub;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  static int ic_stub_code_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  static StubQueue* _buffer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
   105
  static CompiledICHolder* _pending_released;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
   106
  static int _pending_count;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
   107
52857
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 47216
diff changeset
   108
  DEBUG_ONLY(static volatile int _needs_refill;)
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 47216
diff changeset
   109
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  static StubQueue* buffer()                         { return _buffer;         }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  static ICStub* new_ic_stub();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  // Machine-dependent implementation of ICBuffer
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
   115
  static void    assemble_ic_buffer_code(address code_begin, void* cached_value, address entry_point);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  static address ic_buffer_entry_point  (address code_begin);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
   117
  static void*   ic_buffer_cached_value (address code_begin);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    // Initialization; must be called before first usage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  static void initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  // Access
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  static bool contains(address instruction_address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    // removes the ICStubs after backpatching
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  static void update_inline_caches();
52857
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 47216
diff changeset
   129
  static void refill_ic_stubs();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  // for debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  static bool is_empty();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
   134
  static void release_pending_icholders();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
   135
  static void queue_for_release(CompiledICHolder* icholder);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
   136
  static int pending_icholder_count() { return _pending_count; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  // New interface
52857
7e268f863ff0 8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents: 47216
diff changeset
   139
  static bool    create_transition_stub(CompiledIC *ic, void* cached_value, address entry);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  static address ic_destination_for(CompiledIC *ic);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
   141
  static void*   cached_value_for(CompiledIC *ic);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   143
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   144
#endif // SHARE_VM_CODE_ICBUFFER_HPP