src/hotspot/share/aot/aotCodeHeap.hpp
author coleenp
Thu, 10 Jan 2019 15:13:51 -0500
changeset 53244 9807daeb47c4
parent 51731 8745f8f1b0f8
child 53641 c572eb605087
permissions -rw-r--r--
8216167: Update include guards to reflect correct directories Summary: Use script and some manual fixup to fix directores names in include guards. Reviewed-by: lfoltan, eosterlund, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51731
diff changeset
     2
 * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     4
 *
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     8
 *
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    13
 * accompanied this code).
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    14
 *
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    18
 *
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    21
 * questions.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    22
 */
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    23
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51731
diff changeset
    24
#ifndef SHARE_AOT_AOTCODEHEAP_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51731
diff changeset
    25
#define SHARE_AOT_AOTCODEHEAP_HPP
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    26
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    27
#include "aot/aotCompiledMethod.hpp"
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    28
#include "classfile/symbolTable.hpp"
46958
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46949
diff changeset
    29
#include "metaprogramming/integralConstant.hpp"
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46949
diff changeset
    30
#include "metaprogramming/isRegisteredEnum.hpp"
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    31
#include "oops/metadata.hpp"
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    32
#include "oops/method.hpp"
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    33
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    34
enum CodeState {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    35
  not_set = 0, // _aot fields is not set yet
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    36
  in_use  = 1, // _aot field is set to corresponding AOTCompiledMethod
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    37
  invalid = 2  // AOT code is invalidated because dependencies failed
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    38
};
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    39
46958
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46949
diff changeset
    40
template<> struct IsRegisteredEnum<CodeState> : public TrueType {};
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46949
diff changeset
    41
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    42
typedef struct {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    43
  AOTCompiledMethod* _aot;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    44
  CodeState _state; // State change cases: not_set->in_use, not_set->invalid
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    45
} CodeToAMethod;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    46
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    47
class ClassLoaderData;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    48
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    49
class AOTClass {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    50
public:
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    51
  ClassLoaderData* _classloader;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    52
};
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    53
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    54
typedef struct {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    55
  int _name_offset;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    56
  int _code_offset;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    57
  int _meta_offset;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    58
  int _metadata_got_offset;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    59
  int _metadata_got_size;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    60
  int _code_id;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    61
} AOTMethodOffsets;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    62
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    63
typedef struct {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    64
  const char* _name;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    65
  address     _code;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    66
  aot_metadata* _meta;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    67
  jlong*      _state_adr;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    68
  address     _metadata_table;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    69
  int         _metadata_size;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    70
} AOTMethodData;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    71
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    72
typedef struct {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    73
  int _got_index;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    74
  int _class_id;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    75
  int _compiled_methods_offset;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    76
  int _dependent_methods_offset;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    77
  uint64_t _fingerprint;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    78
} AOTKlassData;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    79
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    80
typedef struct {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    81
  int _version;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    82
  int _class_count;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    83
  int _method_count;
46949
44ccdba2d72e 8186453: [AOT] refactor AOT tool code
kvn
parents: 46647
diff changeset
    84
  int _klasses_got_size;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    85
  int _metadata_got_size;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    86
  int _oop_got_size;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    87
  int _jvm_version_offset;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    88
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    89
  enum {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    90
    AOT_SHARED_VERSION = 1
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    91
  };
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    92
} AOTHeader;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    93
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    94
typedef struct {
51206
14b870bda24f 8207069: [AOT] we should check that VM uses the same GC as one used for AOT library generation.
kvn
parents: 48172
diff changeset
    95
  enum { CONFIG_SIZE = 8 * jintSize + 11 };
14b870bda24f 8207069: [AOT] we should check that VM uses the same GC as one used for AOT library generation.
kvn
parents: 48172
diff changeset
    96
  // 8 int values
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    97
  int _config_size;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    98
  int _narrowOopShift;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    99
  int _narrowKlassShift;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   100
  int _contendedPaddingWidth;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   101
  int _fieldsAllocationStyle;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   102
  int _objectAlignment;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   103
  int _codeSegmentSize;
51206
14b870bda24f 8207069: [AOT] we should check that VM uses the same GC as one used for AOT library generation.
kvn
parents: 48172
diff changeset
   104
  int _gc;
14b870bda24f 8207069: [AOT] we should check that VM uses the same GC as one used for AOT library generation.
kvn
parents: 48172
diff changeset
   105
  // byte[11] array map to boolean values here
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   106
  bool _debug_VM;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   107
  bool _useCompressedOops;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   108
  bool _useCompressedClassPointers;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   109
  bool _compactFields;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   110
  bool _useTLAB;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   111
  bool _useBiasedLocking;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   112
  bool _tieredAOT;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   113
  bool _enableContended;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   114
  bool _restrictContended;
43405
1fab8e6866d7 8168792: [AOT] problems in MethodHandle with aot-compiled java.base
iveresov
parents: 42650
diff changeset
   115
  bool _omitAssertions;
48172
e26fc5201707 8191437: AOT doesn't work easily after thread local handshakes
dlong
parents: 47668
diff changeset
   116
  bool _threadLocalHandshakes;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   117
} AOTConfiguration;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   118
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   119
class AOTLib : public CHeapObj<mtCode> {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   120
  static bool _narrow_oop_shift_initialized;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   121
  static int _narrow_oop_shift;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   122
  static int _narrow_klass_shift;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   123
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   124
  bool _valid;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   125
  void* _dl_handle;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   126
  const int _dso_id;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   127
  const char* _name;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   128
  // VM configuration during AOT compilation
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   129
  AOTConfiguration* _config;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   130
  AOTHeader* _header;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   131
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   132
  void handle_config_error(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   133
public:
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   134
  AOTLib(void* handle, const char* name, int dso_id);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   135
  virtual ~AOTLib();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   136
  static int  narrow_oop_shift() { return _narrow_oop_shift; }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   137
  static int  narrow_klass_shift() { return _narrow_klass_shift; }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   138
  static bool narrow_oop_shift_initialized() { return _narrow_oop_shift_initialized; }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   139
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   140
  bool is_valid() const {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   141
    return _valid;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   142
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   143
  const char* name() const {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   144
    return _name;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   145
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   146
  void* dl_handle() const {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   147
    return _dl_handle;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   148
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   149
  int id() const {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   150
    return _dso_id;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   151
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   152
  AOTHeader* header() const {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   153
    return _header;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   154
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   155
  AOTConfiguration* config() const {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   156
    return _config;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   157
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   158
  void verify_config();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   159
  void verify_flag(bool aot_flag, bool flag, const char* name);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   160
  void verify_flag(int  aot_flag, int  flag, const char* name);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   161
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   162
  address load_symbol(const char *name);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   163
};
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   164
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   165
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   166
class AOTCodeHeap : public CodeHeap {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   167
  AOTLib* _lib;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   168
  int _aot_id;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   169
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   170
  int _class_count;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   171
  int _method_count;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   172
  AOTClass* _classes;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   173
  CodeToAMethod* _code_to_aot;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   174
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   175
  address _code_space;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   176
  address _code_segments;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   177
  jlong*  _method_state;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   178
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   179
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   180
  // Collect metaspace info: names -> address in .got section
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   181
  const char* _metaspace_names;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   182
  address _method_metadata;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   183
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   184
  address _methods_offsets;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   185
  address _klasses_offsets;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   186
  address _dependencies;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   187
46949
44ccdba2d72e 8186453: [AOT] refactor AOT tool code
kvn
parents: 46647
diff changeset
   188
  Metadata** _klasses_got;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   189
  Metadata** _metadata_got;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   190
  oop*    _oop_got;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   191
46949
44ccdba2d72e 8186453: [AOT] refactor AOT tool code
kvn
parents: 46647
diff changeset
   192
  int _klasses_got_size;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   193
  int _metadata_got_size;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   194
  int _oop_got_size;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   195
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   196
  // Collect stubs info
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   197
  int* _stubs_offsets;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   198
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   199
  bool _lib_symbols_initialized;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   200
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   201
  void adjust_boundaries(AOTCompiledMethod* method) {
46647
634dc786bf96 8183573: Refactor CodeHeap and AOTCodeHeap to devirtualize hot methods
redestad
parents: 46556
diff changeset
   202
    char* low = (char*)method->code_begin();
634dc786bf96 8183573: Refactor CodeHeap and AOTCodeHeap to devirtualize hot methods
redestad
parents: 46556
diff changeset
   203
    if (low < low_boundary()) {
634dc786bf96 8183573: Refactor CodeHeap and AOTCodeHeap to devirtualize hot methods
redestad
parents: 46556
diff changeset
   204
      _memory.set_low_boundary(low);
634dc786bf96 8183573: Refactor CodeHeap and AOTCodeHeap to devirtualize hot methods
redestad
parents: 46556
diff changeset
   205
      _memory.set_low(low);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   206
    }
46647
634dc786bf96 8183573: Refactor CodeHeap and AOTCodeHeap to devirtualize hot methods
redestad
parents: 46556
diff changeset
   207
    char* high = (char *)method->code_end();
634dc786bf96 8183573: Refactor CodeHeap and AOTCodeHeap to devirtualize hot methods
redestad
parents: 46556
diff changeset
   208
    if (high > high_boundary()) {
634dc786bf96 8183573: Refactor CodeHeap and AOTCodeHeap to devirtualize hot methods
redestad
parents: 46556
diff changeset
   209
      _memory.set_high_boundary(high);
634dc786bf96 8183573: Refactor CodeHeap and AOTCodeHeap to devirtualize hot methods
redestad
parents: 46556
diff changeset
   210
      _memory.set_high(high);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   211
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   212
    assert(_method_count > 0, "methods count should be set already");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   213
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   214
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   215
  void register_stubs();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   216
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   217
  void link_shared_runtime_symbols();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   218
  void link_stub_routines_symbols();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   219
  void link_os_symbols();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   220
  void link_graal_runtime_symbols();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   221
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   222
  void link_global_lib_symbols();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   223
  void link_primitive_array_klasses();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   224
  void publish_aot(const methodHandle& mh, AOTMethodData* method_data, int code_id);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   225
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   226
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   227
  AOTCompiledMethod* next_in_use_at(int index) const;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   228
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   229
  // Find klass in SystemDictionary for aot metadata.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   230
  static Klass* lookup_klass(const char* name, int len, const Method* method, Thread* THREAD);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   231
public:
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   232
  AOTCodeHeap(AOTLib* lib);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   233
  virtual ~AOTCodeHeap();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   234
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   235
  AOTCompiledMethod* find_aot(address p) const;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   236
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   237
  virtual void* find_start(void* p)     const;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   238
  virtual CodeBlob* find_blob_unsafe(void* start) const;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   239
  virtual void* first() const;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   240
  virtual void* next(void *p) const;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   241
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   242
  AOTKlassData* find_klass(InstanceKlass* ik);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 43945
diff changeset
   243
  bool load_klass_data(InstanceKlass* ik, Thread* thread);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   244
  Klass* get_klass_from_got(const char* klass_name, int klass_len, const Method* method);
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   245
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   246
  bool is_dependent_method(Klass* dependee, AOTCompiledMethod* aot);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   247
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   248
  const char* get_name_at(int offset) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   249
    return _metaspace_names + offset;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   250
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   251
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   252
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   253
  void oops_do(OopClosure* f);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   254
  void metadata_do(void f(Metadata*));
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   255
  void got_metadata_do(void f(Metadata*));
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   256
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   257
#ifdef ASSERT
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   258
  bool got_contains(Metadata **p) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   259
    return (p >= &_metadata_got[0] && p < &_metadata_got[_metadata_got_size]) ||
46949
44ccdba2d72e 8186453: [AOT] refactor AOT tool code
kvn
parents: 46647
diff changeset
   260
           (p >= &_klasses_got[0] && p < &_klasses_got[_klasses_got_size]);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   261
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   262
#endif
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   263
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   264
  int dso_id() const { return _lib->id(); }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   265
  int aot_id() const { return _aot_id; }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   266
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   267
  int method_count() { return _method_count; }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   268
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   269
  AOTCompiledMethod* get_code_desc_at_index(int index) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   270
    if (index < _method_count && _code_to_aot[index]._state == in_use) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   271
        AOTCompiledMethod* m = _code_to_aot[index]._aot;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   272
        assert(m != NULL, "AOT method should be set");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   273
        if (!m->is_runtime_stub()) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   274
          return m;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   275
        }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   276
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   277
    return NULL;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   278
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   279
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 43945
diff changeset
   280
  static Method* find_method(Klass* klass, Thread* thread, const char* method_name);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   281
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   282
  void cleanup_inline_caches();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   283
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   284
  DEBUG_ONLY( int verify_icholder_relocations(); )
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   285
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   286
  void alive_methods_do(void f(CompiledMethod* nm));
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   287
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   288
#ifndef PRODUCT
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   289
  static int klasses_seen;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   290
  static int aot_klasses_found;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   291
  static int aot_klasses_fp_miss;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   292
  static int aot_klasses_cl_miss;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   293
  static int aot_methods_found;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   294
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   295
  static void print_statistics();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   296
#endif
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   297
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   298
  bool reconcile_dynamic_invoke(AOTCompiledMethod* caller, InstanceKlass* holder, int index, Method* adapter_method, Klass *appendix_klass);
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   299
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   300
private:
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   301
  AOTKlassData* find_klass(const char* name);
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   302
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   303
  void sweep_dependent_methods(int* indexes, int methods_cnt);
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   304
  void sweep_dependent_methods(AOTKlassData* klass_data);
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   305
  void sweep_dependent_methods(InstanceKlass* ik);
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   306
  void sweep_method(AOTCompiledMethod* aot);
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   307
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   308
  bool reconcile_dynamic_klass(AOTCompiledMethod *caller, InstanceKlass* holder, int index, Klass *dyno, const char *descriptor1, const char *descriptor2 = NULL);
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   309
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   310
  bool reconcile_dynamic_method(AOTCompiledMethod *caller, InstanceKlass* holder, int index, Method *adapter_method);
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   311
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   312
};
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   313
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51731
diff changeset
   314
#endif // SHARE_AOT_AOTCODEHEAP_HPP