hotspot/src/share/vm/jvmci/jvmciCodeInstaller.hpp
author rschatz
Fri, 25 Mar 2016 12:43:23 +0100
changeset 36842 8f0d0faa51e2
parent 36063 96e86c7f8fec
child 41697 94ef14db8a20
permissions -rw-r--r--
8152634: generalize exception throwing routines in JVMCIRuntime Reviewed-by: twisti
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
/*
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35123
diff changeset
     2
 * Copyright (c) 2011, 2016, 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
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    24
#ifndef SHARE_VM_JVMCI_JVMCI_CODE_INSTALLER_HPP
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    25
#define SHARE_VM_JVMCI_JVMCI_CODE_INSTALLER_HPP
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
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    31
class RelocBuffer : public StackObj {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    32
  enum { stack_size = 1024 };
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    33
public:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    34
  RelocBuffer() : _size(0), _buffer(0) {}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    35
  ~RelocBuffer();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    36
  void ensure_size(size_t bytes);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    37
  void set_size(size_t bytes);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    38
  address begin() const;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    39
  size_t size() const { return _size; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    40
private:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    41
  size_t _size;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    42
  char _static_buffer[stack_size];
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    43
  char *_buffer;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    44
};
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
class CodeMetadata {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    47
public:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    48
  CodeMetadata() {}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    49
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    50
  CodeBlob* get_code_blob() const { return _cb; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    51
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    52
  PcDesc* get_pc_desc() const { return _pc_desc; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    53
  int get_nr_pc_desc() const { return _nr_pc_desc; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    54
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    55
  u_char* get_scopes_desc() const { return _scopes_desc; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    56
  int get_scopes_size() const { return _nr_scopes_desc; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    57
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    58
  RelocBuffer* get_reloc_buffer() { return &_reloc_buffer; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    59
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    60
  ExceptionHandlerTable* get_exception_table() { return _exception_table; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    61
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    62
  void set_pc_desc(PcDesc* desc, int count) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    63
    _pc_desc = desc;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    64
    _nr_pc_desc = count;
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
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    67
  void set_scopes(u_char* scopes, int size) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    68
    _scopes_desc = scopes;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    69
    _nr_scopes_desc = size;
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
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    72
  void set_exception_table(ExceptionHandlerTable* table) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    73
    _exception_table = table;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    74
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    75
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    76
private:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    77
  CodeBlob* _cb;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    78
  PcDesc* _pc_desc;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    79
  int _nr_pc_desc;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    80
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    81
  u_char* _scopes_desc;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    82
  int _nr_scopes_desc;
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
  RelocBuffer _reloc_buffer;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    85
  ExceptionHandlerTable* _exception_table;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    86
};
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    87
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
 * 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
    90
 */
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    91
class CodeInstaller : public StackObj {
35123
b0b89d83bcf5 8134994: use separate VMStructs databases for SA and JVMCI
twisti
parents: 34502
diff changeset
    92
  friend class JVMCIVMStructs;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    93
private:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    94
  enum MarkId {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    95
    VERIFIED_ENTRY             = 1,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    96
    UNVERIFIED_ENTRY           = 2,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    97
    OSR_ENTRY                  = 3,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    98
    EXCEPTION_HANDLER_ENTRY    = 4,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    99
    DEOPT_HANDLER_ENTRY        = 5,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   100
    INVOKEINTERFACE            = 6,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   101
    INVOKEVIRTUAL              = 7,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   102
    INVOKESTATIC               = 8,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   103
    INVOKESPECIAL              = 9,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   104
    INLINE_INVOKE              = 10,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   105
    POLL_NEAR                  = 11,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   106
    POLL_RETURN_NEAR           = 12,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   107
    POLL_FAR                   = 13,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   108
    POLL_RETURN_FAR            = 14,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   109
    CARD_TABLE_ADDRESS         = 15,
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   110
    CARD_TABLE_SHIFT           = 16,
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   111
    HEAP_TOP_ADDRESS           = 17,
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   112
    HEAP_END_ADDRESS           = 18,
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   113
    NARROW_KLASS_BASE_ADDRESS  = 19,
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   114
    CRC_TABLE_ADDRESS          = 20,
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   115
    INVOKE_INVALID             = -1
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   116
  };
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   117
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   118
  Arena         _arena;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   119
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   120
  jobject       _data_section_handle;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   121
  jobject       _data_section_patches_handle;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   122
  jobject       _sites_handle;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   123
  CodeOffsets   _offsets;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   124
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   125
  jobject       _code_handle;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   126
  jint          _code_size;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   127
  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
   128
  jint          _orig_pc_offset;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   129
  jint          _parameter_count;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   130
  jint          _constants_size;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   131
#ifndef PRODUCT
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   132
  jobject       _comments_handle;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   133
#endif
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   134
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   135
  bool          _has_wide_vector;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   136
  jobject       _word_kind_handle;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   137
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   138
  MarkId        _next_call_type;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   139
  address       _invoke_mark_pc;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   140
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   141
  CodeSection*  _instructions;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   142
  CodeSection*  _constants;
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
  OopRecorder*              _oop_recorder;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   145
  DebugInformationRecorder* _debug_recorder;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   146
  Dependencies*             _dependencies;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   147
  ExceptionHandlerTable     _exception_handler_table;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   148
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   149
  static ConstantOopWriteValue* _oop_null_scope_value;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   150
  static ConstantIntValue*    _int_m1_scope_value;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   151
  static ConstantIntValue*    _int_0_scope_value;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   152
  static ConstantIntValue*    _int_1_scope_value;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   153
  static ConstantIntValue*    _int_2_scope_value;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   154
  static LocationValue*       _illegal_value;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   155
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   156
  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
   157
  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
   158
  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
   159
  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
   160
  void pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination, TRAPS);
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   161
  void pd_relocate_JavaMethod(Handle method, jint pc_offset, TRAPS);
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   162
  void pd_relocate_poll(address pc, jint mark, TRAPS);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   163
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   164
  objArrayOop sites() { return (objArrayOop) JNIHandles::resolve(_sites_handle); }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   165
  arrayOop code() { return (arrayOop) JNIHandles::resolve(_code_handle); }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   166
  arrayOop data_section() { return (arrayOop) JNIHandles::resolve(_data_section_handle); }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   167
  objArrayOop data_section_patches() { return (objArrayOop) JNIHandles::resolve(_data_section_patches_handle); }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   168
#ifndef PRODUCT
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   169
  objArrayOop comments() { return (objArrayOop) JNIHandles::resolve(_comments_handle); }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   170
#endif
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   171
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   172
  oop word_kind() { return (oop) JNIHandles::resolve(_word_kind_handle); }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   173
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   174
public:
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   175
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   176
  CodeInstaller() : _arena(mtCompiler) {}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   177
34165
66826441022f 8142329: [JVMCI] pass Handle by value
twisti
parents: 34153
diff changeset
   178
  JVMCIEnv::CodeInstallResult gather_metadata(Handle target, Handle compiled_code, CodeMetadata& metadata, TRAPS);
66826441022f 8142329: [JVMCI] pass Handle by value
twisti
parents: 34153
diff changeset
   179
  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
   180
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   181
  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
   182
  static VMReg get_hotspot_reg(jint jvmciRegisterNumber, TRAPS);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   183
  static bool is_general_purpose_reg(VMReg hotspotRegister);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   184
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   185
  const OopMapSet* oopMapSet() const { return _debug_recorder->_oopmaps; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   186
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   187
protected:
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   188
  Location::Type get_oop_type(Handle value);
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   189
  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
   190
  MonitorValue* get_monitor_value(Handle value, GrowableArray<ScopeValue*>* objects, TRAPS);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   191
36842
8f0d0faa51e2 8152634: generalize exception throwing routines in JVMCIRuntime
rschatz
parents: 36063
diff changeset
   192
  void* record_metadata_reference(Handle constant, TRAPS);
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   193
#ifdef _LP64
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   194
  narrowKlass record_narrow_metadata_reference(Handle constant, TRAPS);
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   195
#endif
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   196
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35123
diff changeset
   197
  // extract the fields of the HotSpotCompiledCode
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   198
  void initialize_fields(oop target, oop target_method, TRAPS);
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   199
  void initialize_dependencies(oop target_method, OopRecorder* oop_recorder, TRAPS);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   200
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   201
  int estimate_stubs_size(TRAPS);
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
  // perform data and call relocation on the CodeBuffer
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   204
  JVMCIEnv::CodeInstallResult initialize_buffer(CodeBuffer& buffer, TRAPS);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   205
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   206
  void assumption_NoFinalizableSubclass(Handle assumption);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   207
  void assumption_ConcreteSubtype(Handle assumption);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   208
  void assumption_LeafType(Handle assumption);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   209
  void assumption_ConcreteMethod(Handle assumption);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   210
  void assumption_CallSiteTargetValue(Handle assumption);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   211
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   212
  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
   213
  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
   214
  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
   215
  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
   216
  void site_Mark(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS);
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35123
diff changeset
   217
  void site_ExceptionHandler(jint pc_offset, Handle site);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   218
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   219
  OopMap* create_oop_map(Handle debug_info, TRAPS);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   220
34502
1cfcb971cb17 8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents: 34165
diff changeset
   221
  /**
1cfcb971cb17 8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents: 34165
diff changeset
   222
   * Specifies the level of detail to record for a scope.
1cfcb971cb17 8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents: 34165
diff changeset
   223
   */
1cfcb971cb17 8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents: 34165
diff changeset
   224
  enum ScopeMode {
1cfcb971cb17 8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents: 34165
diff changeset
   225
    // Only record a method and BCI
1cfcb971cb17 8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents: 34165
diff changeset
   226
    BytecodePosition,
1cfcb971cb17 8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents: 34165
diff changeset
   227
    // Record a method, bci and JVM frame state
1cfcb971cb17 8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents: 34165
diff changeset
   228
    FullFrame
1cfcb971cb17 8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents: 34165
diff changeset
   229
  };
1cfcb971cb17 8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents: 34165
diff changeset
   230
1cfcb971cb17 8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents: 34165
diff changeset
   231
  void record_scope(jint pc_offset, Handle debug_info, ScopeMode scope_mode, TRAPS);
1cfcb971cb17 8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents: 34165
diff changeset
   232
  void record_scope(jint pc_offset, Handle position, ScopeMode scope_mode, GrowableArray<ScopeValue*>* objects, TRAPS);
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   233
  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
   234
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   235
  GrowableArray<ScopeValue*>* record_virtual_objects(Handle debug_info, TRAPS);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   236
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   237
  int estimateStubSpace(int static_call_stubs);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   238
};
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   239
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   240
/**
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   241
 * Gets the Method metaspace object from a HotSpotResolvedJavaMethodImpl Java object.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   242
 */
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   243
Method* getMethodFromHotSpotMethod(oop hotspot_method);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   244
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   245
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   246
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   247
#endif // SHARE_VM_JVMCI_JVMCI_CODE_INSTALLER_HPP