src/hotspot/share/jvmci/jvmciCodeInstaller.hpp
author herrick
Wed, 27 Mar 2019 08:27:58 -0400
branchJDK-8200758-branch
changeset 57288 0be43184f52a
parent 53244 9807daeb47c4
child 54669 ad45b3802d4e
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52381
diff changeset
     2
 * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     4
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     8
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    13
 * accompanied this code).
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    14
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    18
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    21
 * questions.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    22
 */
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    23
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52381
diff changeset
    24
#ifndef SHARE_JVMCI_JVMCICODEINSTALLER_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52381
diff changeset
    25
#define SHARE_JVMCI_JVMCICODEINSTALLER_HPP
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    26
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    27
#include "jvmci/jvmciCompiler.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    28
#include "jvmci/jvmciEnv.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    29
#include "code/nativeInst.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    30
52381
7f90bc64b0fc 8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents: 50729
diff changeset
    31
#if INCLUDE_AOT
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    32
class RelocBuffer : public StackObj {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    33
  enum { stack_size = 1024 };
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    34
public:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    35
  RelocBuffer() : _size(0), _buffer(0) {}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    36
  ~RelocBuffer();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    37
  void ensure_size(size_t bytes);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    38
  void set_size(size_t bytes);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    39
  address begin() const;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    40
  size_t size() const { return _size; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    41
private:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    42
  size_t _size;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    43
  char _static_buffer[stack_size];
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    44
  char *_buffer;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    45
};
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    46
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
    47
class AOTOopRecorder : public OopRecorder {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
    48
public:
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
    49
  AOTOopRecorder(Arena* arena = NULL, bool deduplicate = false);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
    50
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
    51
  virtual int find_index(Metadata* h);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
    52
  virtual int find_index(jobject h);
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
    53
  int nr_meta_refs() const;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
    54
  jobject meta_element(int pos) const;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
    55
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
    56
private:
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
    57
  void record_meta_ref(jobject ref, int index);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
    58
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
    59
  GrowableArray<jobject>* _meta_refs;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
    60
};
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
    61
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    62
class CodeMetadata {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    63
public:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    64
  CodeMetadata() {}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    65
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    66
  CodeBlob* get_code_blob() const { return _cb; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    67
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    68
  PcDesc* get_pc_desc() const { return _pc_desc; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    69
  int get_nr_pc_desc() const { return _nr_pc_desc; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    70
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    71
  u_char* get_scopes_desc() const { return _scopes_desc; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    72
  int get_scopes_size() const { return _nr_scopes_desc; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    73
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    74
  RelocBuffer* get_reloc_buffer() { return &_reloc_buffer; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    75
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
    76
  AOTOopRecorder* get_oop_recorder() { return _oop_recorder; }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
    77
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    78
  ExceptionHandlerTable* get_exception_table() { return _exception_table; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    79
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    80
  void set_pc_desc(PcDesc* desc, int count) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    81
    _pc_desc = desc;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    82
    _nr_pc_desc = count;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    83
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    84
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    85
  void set_scopes(u_char* scopes, int size) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    86
    _scopes_desc = scopes;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    87
    _nr_scopes_desc = size;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    88
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    89
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
    90
  void set_oop_recorder(AOTOopRecorder* recorder) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
    91
    _oop_recorder = recorder;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
    92
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
    93
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    94
  void set_exception_table(ExceptionHandlerTable* table) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    95
    _exception_table = table;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    96
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    97
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    98
private:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    99
  CodeBlob* _cb;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   100
  PcDesc* _pc_desc;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   101
  int _nr_pc_desc;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   102
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   103
  u_char* _scopes_desc;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   104
  int _nr_scopes_desc;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   105
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   106
  RelocBuffer _reloc_buffer;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
   107
  AOTOopRecorder* _oop_recorder;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   108
  ExceptionHandlerTable* _exception_table;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   109
};
52381
7f90bc64b0fc 8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents: 50729
diff changeset
   110
#endif // INCLUDE_AOT
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   111
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   112
/*
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   113
 * This class handles the conversion from a InstalledCode to a CodeBlob or an nmethod.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   114
 */
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   115
class CodeInstaller : public StackObj {
35123
b0b89d83bcf5 8134994: use separate VMStructs databases for SA and JVMCI
twisti
parents: 34502
diff changeset
   116
  friend class JVMCIVMStructs;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   117
private:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   118
  enum MarkId {
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
   119
    VERIFIED_ENTRY                         = 1,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
   120
    UNVERIFIED_ENTRY                       = 2,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
   121
    OSR_ENTRY                              = 3,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
   122
    EXCEPTION_HANDLER_ENTRY                = 4,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
   123
    DEOPT_HANDLER_ENTRY                    = 5,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
   124
    INVOKEINTERFACE                        = 6,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
   125
    INVOKEVIRTUAL                          = 7,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
   126
    INVOKESTATIC                           = 8,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
   127
    INVOKESPECIAL                          = 9,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
   128
    INLINE_INVOKE                          = 10,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
   129
    POLL_NEAR                              = 11,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
   130
    POLL_RETURN_NEAR                       = 12,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
   131
    POLL_FAR                               = 13,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
   132
    POLL_RETURN_FAR                        = 14,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
   133
    CARD_TABLE_ADDRESS                     = 15,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
   134
    CARD_TABLE_SHIFT                       = 16,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
   135
    HEAP_TOP_ADDRESS                       = 17,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
   136
    HEAP_END_ADDRESS                       = 18,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
   137
    NARROW_KLASS_BASE_ADDRESS              = 19,
43435
01521491ec10 8172310: [AOT] Fix unverified entry point
iveresov
parents: 43416
diff changeset
   138
    NARROW_OOP_BASE_ADDRESS                = 20,
01521491ec10 8172310: [AOT] Fix unverified entry point
iveresov
parents: 43416
diff changeset
   139
    CRC_TABLE_ADDRESS                      = 21,
01521491ec10 8172310: [AOT] Fix unverified entry point
iveresov
parents: 43416
diff changeset
   140
    LOG_OF_HEAP_REGION_GRAIN_BYTES         = 22,
01521491ec10 8172310: [AOT] Fix unverified entry point
iveresov
parents: 43416
diff changeset
   141
    INLINE_CONTIGUOUS_ALLOCATION_SUPPORTED = 23,
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
   142
    INVOKE_INVALID                         = -1
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   143
  };
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   144
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   145
  Arena         _arena;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   146
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   147
  jobject       _data_section_handle;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   148
  jobject       _data_section_patches_handle;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   149
  jobject       _sites_handle;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   150
  CodeOffsets   _offsets;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   151
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   152
  jobject       _code_handle;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   153
  jint          _code_size;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   154
  jint          _total_frame_size;
35823
59a847ec6ee3 8146608: [JVMCI] DebugInfo Tests on DeoptimizeALot runs fails in assert(_pc == *pc_addr || pc == *pc_addr) frame::patch_pc() /frame_x86.cpp:285
rschatz
parents: 35582
diff changeset
   155
  jint          _orig_pc_offset;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   156
  jint          _parameter_count;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   157
  jint          _constants_size;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   158
#ifndef PRODUCT
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   159
  jobject       _comments_handle;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   160
#endif
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   161
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   162
  bool          _has_wide_vector;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   163
  jobject       _word_kind_handle;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   164
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   165
  MarkId        _next_call_type;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   166
  address       _invoke_mark_pc;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   167
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   168
  CodeSection*  _instructions;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   169
  CodeSection*  _constants;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   170
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   171
  OopRecorder*              _oop_recorder;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   172
  DebugInformationRecorder* _debug_recorder;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   173
  Dependencies*             _dependencies;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   174
  ExceptionHandlerTable     _exception_handler_table;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   175
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
   176
  bool _immutable_pic_compilation;  // Installer is called for Immutable PIC compilation.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
   177
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   178
  static ConstantOopWriteValue* _oop_null_scope_value;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   179
  static ConstantIntValue*    _int_m1_scope_value;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   180
  static ConstantIntValue*    _int_0_scope_value;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   181
  static ConstantIntValue*    _int_1_scope_value;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   182
  static ConstantIntValue*    _int_2_scope_value;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   183
  static LocationValue*       _illegal_value;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   184
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   185
  jint pd_next_offset(NativeInstruction* inst, jint pc_offset, Handle method, TRAPS);
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   186
  void pd_patch_OopConstant(int pc_offset, Handle constant, TRAPS);
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   187
  void pd_patch_MetaspaceConstant(int pc_offset, Handle constant, TRAPS);
36063
96e86c7f8fec 8149689: [JVMCI] CodeInstaller::pd_patch_DataSectionReference should be able to throw exceptions
twisti
parents: 35823
diff changeset
   188
  void pd_patch_DataSectionReference(int pc_offset, int data_offset, TRAPS);
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   189
  void pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination, TRAPS);
48487
abf1d797e380 8193260: AArch64: JVMCI: Implement trampoline calls
aph
parents: 47668
diff changeset
   190
  void pd_relocate_JavaMethod(CodeBuffer &cbuf, Handle method, jint pc_offset, TRAPS);
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   191
  void pd_relocate_poll(address pc, jint mark, TRAPS);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   192
49192
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 48487
diff changeset
   193
  objArrayOop sites();
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 48487
diff changeset
   194
  arrayOop code();
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 48487
diff changeset
   195
  arrayOop data_section();
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 48487
diff changeset
   196
  objArrayOop data_section_patches();
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   197
#ifndef PRODUCT
49192
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 48487
diff changeset
   198
  objArrayOop comments();
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   199
#endif
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   200
49192
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 48487
diff changeset
   201
  oop word_kind();
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   202
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   203
public:
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   204
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41697
diff changeset
   205
  CodeInstaller(bool immutable_pic_compilation) : _arena(mtCompiler), _immutable_pic_compilation(immutable_pic_compilation) {}
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   206
52381
7f90bc64b0fc 8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents: 50729
diff changeset
   207
#if INCLUDE_AOT
34165
66826441022f 8142329: [JVMCI] pass Handle by value
twisti
parents: 34153
diff changeset
   208
  JVMCIEnv::CodeInstallResult gather_metadata(Handle target, Handle compiled_code, CodeMetadata& metadata, TRAPS);
52381
7f90bc64b0fc 8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents: 50729
diff changeset
   209
#endif
34165
66826441022f 8142329: [JVMCI] pass Handle by value
twisti
parents: 34153
diff changeset
   210
  JVMCIEnv::CodeInstallResult install(JVMCICompiler* compiler, Handle target, Handle compiled_code, CodeBlob*& cb, Handle installed_code, Handle speculation_log, TRAPS);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   211
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   212
  static address runtime_call_target_address(oop runtime_call);
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   213
  static VMReg get_hotspot_reg(jint jvmciRegisterNumber, TRAPS);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   214
  static bool is_general_purpose_reg(VMReg hotspotRegister);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   215
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   216
  const OopMapSet* oopMapSet() const { return _debug_recorder->_oopmaps; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   217
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   218
protected:
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42861
diff changeset
   219
  Location::Type get_oop_type(Thread* thread, Handle value);
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   220
  ScopeValue* get_scope_value(Handle value, BasicType type, GrowableArray<ScopeValue*>* objects, ScopeValue* &second, TRAPS);
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   221
  MonitorValue* get_monitor_value(Handle value, GrowableArray<ScopeValue*>* objects, TRAPS);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   222
41697
94ef14db8a20 8166869: [JVMCI] record metadata relocations for metadata references
never
parents: 36842
diff changeset
   223
  void* record_metadata_reference(CodeSection* section, address dest, Handle constant, TRAPS);
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   224
#ifdef _LP64
41697
94ef14db8a20 8166869: [JVMCI] record metadata relocations for metadata references
never
parents: 36842
diff changeset
   225
  narrowKlass record_narrow_metadata_reference(CodeSection* section, address dest, Handle constant, TRAPS);
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   226
#endif
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   227
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35123
diff changeset
   228
  // extract the fields of the HotSpotCompiledCode
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   229
  void initialize_fields(oop target, oop target_method, TRAPS);
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   230
  void initialize_dependencies(oop target_method, OopRecorder* oop_recorder, TRAPS);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   231
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   232
  int estimate_stubs_size(TRAPS);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   233
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   234
  // perform data and call relocation on the CodeBuffer
43416
f8c241512446 8171082: [AOT] AOT'd SystemModules.modules() fails to load when too large
rbackman
parents: 42861
diff changeset
   235
  JVMCIEnv::CodeInstallResult initialize_buffer(CodeBuffer& buffer, bool check_size, TRAPS);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   236
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42861
diff changeset
   237
  void assumption_NoFinalizableSubclass(Thread* thread, Handle assumption);
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42861
diff changeset
   238
  void assumption_ConcreteSubtype(Thread* thread, Handle assumption);
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42861
diff changeset
   239
  void assumption_LeafType(Thread* thread, Handle assumption);
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42861
diff changeset
   240
  void assumption_ConcreteMethod(Thread* thread, Handle assumption);
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42861
diff changeset
   241
  void assumption_CallSiteTargetValue(Thread* thread, Handle assumption);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   242
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   243
  void site_Safepoint(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS);
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   244
  void site_Infopoint(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS);
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   245
  void site_Call(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS);
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   246
  void site_DataPatch(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS);
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   247
  void site_Mark(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS);
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35123
diff changeset
   248
  void site_ExceptionHandler(jint pc_offset, Handle site);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   249
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   250
  OopMap* create_oop_map(Handle debug_info, TRAPS);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   251
34502
1cfcb971cb17 8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents: 34165
diff changeset
   252
  /**
1cfcb971cb17 8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents: 34165
diff changeset
   253
   * Specifies the level of detail to record for a scope.
1cfcb971cb17 8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents: 34165
diff changeset
   254
   */
1cfcb971cb17 8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents: 34165
diff changeset
   255
  enum ScopeMode {
1cfcb971cb17 8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents: 34165
diff changeset
   256
    // Only record a method and BCI
1cfcb971cb17 8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents: 34165
diff changeset
   257
    BytecodePosition,
1cfcb971cb17 8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents: 34165
diff changeset
   258
    // Record a method, bci and JVM frame state
1cfcb971cb17 8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents: 34165
diff changeset
   259
    FullFrame
1cfcb971cb17 8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents: 34165
diff changeset
   260
  };
1cfcb971cb17 8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents: 34165
diff changeset
   261
50729
7755c93d3923 8204209: [Graal] Compilation fails during nmethod printing with "assert(bci == 0 || 0 <= bci && bci < code_size()) failed: illegal bci"
iveresov
parents: 49192
diff changeset
   262
  int map_jvmci_bci(int bci);
42861
1d4dfdf4390b 8169938: [AOT] SIGSEGV at ~BufferBlob::vtable chunks
dlong
parents: 42650
diff changeset
   263
  void record_scope(jint pc_offset, Handle debug_info, ScopeMode scope_mode, bool return_oop, TRAPS);
1d4dfdf4390b 8169938: [AOT] SIGSEGV at ~BufferBlob::vtable chunks
dlong
parents: 42650
diff changeset
   264
  void record_scope(jint pc_offset, Handle debug_info, ScopeMode scope_mode, TRAPS) {
1d4dfdf4390b 8169938: [AOT] SIGSEGV at ~BufferBlob::vtable chunks
dlong
parents: 42650
diff changeset
   265
    record_scope(pc_offset, debug_info, scope_mode, false /* return_oop */, THREAD);
1d4dfdf4390b 8169938: [AOT] SIGSEGV at ~BufferBlob::vtable chunks
dlong
parents: 42650
diff changeset
   266
  }
1d4dfdf4390b 8169938: [AOT] SIGSEGV at ~BufferBlob::vtable chunks
dlong
parents: 42650
diff changeset
   267
  void record_scope(jint pc_offset, Handle position, ScopeMode scope_mode, GrowableArray<ScopeValue*>* objects, bool return_oop, TRAPS);
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   268
  void record_object_value(ObjectValue* sv, Handle value, GrowableArray<ScopeValue*>* objects, TRAPS);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   269
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   270
  GrowableArray<ScopeValue*>* record_virtual_objects(Handle debug_info, TRAPS);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   271
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   272
  int estimateStubSpace(int static_call_stubs);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   273
};
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   274
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   275
/**
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   276
 * Gets the Method metaspace object from a HotSpotResolvedJavaMethodImpl Java object.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   277
 */
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   278
Method* getMethodFromHotSpotMethod(oop hotspot_method);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   279
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   280
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   281
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52381
diff changeset
   282
#endif // SHARE_JVMCI_JVMCICODEINSTALLER_HPP