hotspot/src/share/vm/code/icBuffer.hpp
author trims
Thu, 27 May 2010 19:08:38 -0700
changeset 5547 f4b087cbb361
parent 1 489c9b5090e2
child 7397 5b173b4ca846
permissions -rw-r--r--
6941466: Oracle rebranding changes for Hotspot repositories Summary: Change all the Sun copyrights to Oracle copyright Reviewed-by: ohair
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
     2
 * Copyright (c) 1997, 2003, 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
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
// For CompiledIC's:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
// In cases where we do not have MT-safe state transformation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
// we go to a transition state, using ICStubs. At a safepoint,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
// the inline caches are transferred from the transitional code:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
//    instruction_address --> 01 set xxx_oop, Ginline_cache_klass
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
//                            23 jump_to Gtemp, yyyy
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
//                            4  nop
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
class ICStub: public Stub {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  int                 _size;       // total size of the stub incl. code
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  address             _ic_site;    // points at call instruction of owning ic-buffer
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  /* stub code follows here */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  friend class ICStubInterface;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  // This will be called only by ICStubInterface
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  void    initialize(int size) { _size = size; _ic_site = NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  void    finalize(); // called when a method is removed
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  // General info
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  int     size() const                           { return _size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  static  int code_size_to_size(int code_size)   { return round_to(sizeof(ICStub), CodeEntryAlignment) + code_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  // Creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  void set_stub(CompiledIC *ic, oop cached_value, address dest_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  // Code info
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  address code_begin() const                     { return (address)this + round_to(sizeof(ICStub), CodeEntryAlignment); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  address code_end() const                       { return (address)this + size(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  // Call site info
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  address ic_site() const                        { return _ic_site; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  void    clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  bool    is_empty() const                       { return _ic_site == NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  // stub info
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  address destination() const;  // destination of jump instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  oop     cached_oop() const;   // cached_oop for stub
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  // Debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  void    verify()            PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  void    print()             PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  // Creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  friend ICStub* ICStub_from_destination_address(address destination_address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
// ICStub Creation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
inline ICStub* ICStub_from_destination_address(address destination_address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  ICStub* stub = (ICStub*) (destination_address - round_to(sizeof(ICStub), CodeEntryAlignment));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  stub->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  return stub;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
class InlineCacheBuffer: public AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  // friends
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  friend class ICStub;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  static int ic_stub_code_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  static StubQueue* _buffer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  static ICStub*    _next_stub;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  static StubQueue* buffer()                         { return _buffer;         }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  static void       set_next_stub(ICStub* next_stub) { _next_stub = next_stub; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  static ICStub*    get_next_stub()                  { return _next_stub;      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  static void       init_next_stub();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  static ICStub* new_ic_stub();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  // Machine-dependent implementation of ICBuffer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  static void    assemble_ic_buffer_code(address code_begin, oop cached_oop, address entry_point);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  static address ic_buffer_entry_point  (address code_begin);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  static oop     ic_buffer_cached_oop   (address code_begin);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    // Initialization; must be called before first usage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  static void initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  // Access
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  static bool contains(address instruction_address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    // removes the ICStubs after backpatching
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  static void update_inline_caches();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  // for debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  static bool is_empty();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  // New interface
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  static void    create_transition_stub(CompiledIC *ic, oop cached_oop, address entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  static address ic_destination_for(CompiledIC *ic);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  static oop     cached_oop_for(CompiledIC *ic);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
};