src/hotspot/share/interpreter/bootstrapInfo.cpp
author xgong
Wed, 20 Nov 2019 05:58:19 +0000
changeset 59165 2c55c2fc08f5
parent 54600 69cfd80f8706
permissions -rw-r--r--
8234321: Call cache flush after generating trampoline. Reviewed-by: adinn, iklam
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
54600
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
     1
/*
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
     4
 *
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
     7
 * published by the Free Software Foundation.
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
     8
 *
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    13
 * accompanied this code).
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    14
 *
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    18
 *
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    21
 * questions.
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    22
 *
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    23
 */
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    24
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    25
#include "precompiled.hpp"
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    26
#include "jvm.h"
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    27
#include "classfile/javaClasses.inline.hpp"
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    28
#include "classfile/resolutionErrors.hpp"
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    29
#include "interpreter/bootstrapInfo.hpp"
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    30
#include "interpreter/linkResolver.hpp"
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    31
#include "logging/log.hpp"
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    32
#include "logging/logStream.hpp"
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    33
#include "memory/oopFactory.hpp"
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    34
#include "oops/cpCache.inline.hpp"
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    35
#include "oops/objArrayOop.inline.hpp"
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    36
#include "oops/typeArrayOop.inline.hpp"
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    37
#include "runtime/handles.inline.hpp"
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    38
#include "runtime/thread.inline.hpp"
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    39
#include "runtime/vmThread.hpp"
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    40
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    41
//------------------------------------------------------------------------------------------------------------------------
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    42
// Implementation of BootstrapInfo
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    43
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    44
BootstrapInfo::BootstrapInfo(const constantPoolHandle& pool, int bss_index, int indy_index)
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    45
  : _pool(pool),
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    46
    _bss_index(bss_index),
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    47
    _indy_index(indy_index),
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    48
    // derived and eagerly cached:
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    49
    _argc(      pool->bootstrap_argument_count_at(bss_index) ),
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    50
    _name(      pool->uncached_name_ref_at(bss_index) ),
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    51
    _signature( pool->uncached_signature_ref_at(bss_index) )
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    52
{
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    53
  _is_resolved = false;
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    54
  assert(pool->tag_at(bss_index).has_bootstrap(), "");
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    55
  assert(indy_index == -1 || pool->invokedynamic_bootstrap_ref_index_at(indy_index) == bss_index, "invalid bootstrap specifier index");
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    56
}
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    57
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    58
// If there is evidence this call site was already linked, set the
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    59
// existing linkage data into result, or throw previous exception.
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    60
// Return true if either action is taken, else false.
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    61
bool BootstrapInfo::resolve_previously_linked_invokedynamic(CallInfo& result, TRAPS) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    62
  assert(_indy_index != -1, "");
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    63
  ConstantPoolCacheEntry* cpce = invokedynamic_cp_cache_entry();
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    64
  if (!cpce->is_f1_null()) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    65
    methodHandle method(     THREAD, cpce->f1_as_method());
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    66
    Handle       appendix(   THREAD, cpce->appendix_if_resolved(_pool));
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    67
    result.set_handle(method, appendix, THREAD);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    68
    Exceptions::wrap_dynamic_exception(CHECK_false);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    69
    return true;
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    70
  } else if (cpce->indy_resolution_failed()) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    71
    int encoded_index = ResolutionErrorTable::encode_cpcache_index(_indy_index);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    72
    ConstantPool::throw_resolution_error(_pool, encoded_index, CHECK_false);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    73
    return true;
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    74
  } else {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    75
    return false;
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    76
  }
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    77
}
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    78
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    79
// Resolve the bootstrap specifier in 3 steps:
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    80
// - unpack the BSM by resolving the MH constant
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    81
// - obtain the NameAndType description for the condy/indy
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    82
// - prepare the BSM's static arguments
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    83
Handle BootstrapInfo::resolve_bsm(TRAPS) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    84
  if (_bsm.not_null())  return _bsm;
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    85
  // The tag at the bootstrap method index must be a valid method handle or a method handle in error.
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    86
  // If it is a MethodHandleInError, a resolution error will be thrown which will be wrapped if necessary
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    87
  // with a BootstrapMethodError.
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    88
  assert(_pool->tag_at(bsm_index()).is_method_handle() ||
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    89
         _pool->tag_at(bsm_index()).is_method_handle_in_error(), "MH not present, classfile structural constraint");
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    90
  oop bsm_oop = _pool->resolve_possibly_cached_constant_at(bsm_index(), THREAD);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    91
  Exceptions::wrap_dynamic_exception(CHECK_NH);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    92
  guarantee(java_lang_invoke_MethodHandle::is_instance(bsm_oop), "classfile must supply a valid BSM");
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    93
  _bsm = Handle(THREAD, bsm_oop);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    94
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    95
  // Obtain NameAndType information
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    96
  resolve_bss_name_and_type(THREAD);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    97
  Exceptions::wrap_dynamic_exception(CHECK_NH);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    98
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
    99
  // Prepare static arguments
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   100
  resolve_args(THREAD);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   101
  Exceptions::wrap_dynamic_exception(CHECK_NH);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   102
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   103
  return _bsm;
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   104
}
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   105
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   106
// Resolve metadata from the JVM_Dynamic_info or JVM_InvokeDynamic_info's name and type information.
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   107
void BootstrapInfo::resolve_bss_name_and_type(TRAPS) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   108
  assert(_bsm.not_null(), "resolve_bsm first");
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   109
  Symbol* name = this->name();
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   110
  Symbol* type = this->signature();
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   111
  _name_arg = java_lang_String::create_from_symbol(name, CHECK);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   112
  if (type->char_at(0) == '(') {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   113
    _type_arg = SystemDictionary::find_method_handle_type(type, caller(), CHECK);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   114
  } else {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   115
    _type_arg = SystemDictionary::find_java_mirror_for_type(type, caller(), SignatureStream::NCDFError, CHECK);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   116
  }
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   117
}
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   118
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   119
// Resolve the bootstrap method's static arguments and store the result in _arg_values.
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   120
void BootstrapInfo::resolve_args(TRAPS) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   121
  assert(_bsm.not_null(), "resolve_bsm first");
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   122
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   123
  // if there are no static arguments, return leaving _arg_values as null
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   124
  if (_argc == 0 && UseBootstrapCallInfo < 2) return;
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   125
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   126
  bool use_BSCI;
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   127
  switch (UseBootstrapCallInfo) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   128
  default: use_BSCI = true;  break;  // stress mode
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   129
  case 0:  use_BSCI = false; break;  // stress mode
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   130
  case 1:                            // normal mode
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   131
    // If we were to support an alternative mode of BSM invocation,
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   132
    // we'd convert to pull mode here if the BSM could be a candidate
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   133
    // for that alternative mode.  We can't easily test for things
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   134
    // like varargs here, but we can get away with approximate testing,
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   135
    // since the JDK runtime will make up the difference either way.
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   136
    // For now, exercise the pull-mode path if the BSM is of arity 2,
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   137
    // or if there is a potential condy loop (see below).
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   138
    oop mt_oop = java_lang_invoke_MethodHandle::type(_bsm());
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   139
    use_BSCI = (java_lang_invoke_MethodType::ptype_count(mt_oop) == 2);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   140
    break;
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   141
  }
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   142
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   143
  // Here's a reason to use BSCI even if it wasn't requested:
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   144
  // If a condy uses a condy argument, we want to avoid infinite
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   145
  // recursion (condy loops) in the C code.  It's OK in Java,
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   146
  // because Java has stack overflow checking, so we punt
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   147
  // potentially cyclic cases from C to Java.
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   148
  if (!use_BSCI && _pool->tag_at(_bss_index).is_dynamic_constant()) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   149
    bool found_unresolved_condy = false;
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   150
    for (int i = 0; i < _argc; i++) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   151
      int arg_index = _pool->bootstrap_argument_index_at(_bss_index, i);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   152
      if (_pool->tag_at(arg_index).is_dynamic_constant()) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   153
        // potential recursion point condy -> condy
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   154
        bool found_it = false;
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   155
        _pool->find_cached_constant_at(arg_index, found_it, CHECK);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   156
        if (!found_it) { found_unresolved_condy = true; break; }
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   157
      }
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   158
    }
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   159
    if (found_unresolved_condy)
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   160
      use_BSCI = true;
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   161
  }
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   162
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   163
  const int SMALL_ARITY = 5;
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   164
  if (use_BSCI && _argc <= SMALL_ARITY && UseBootstrapCallInfo <= 2) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   165
    // If there are only a few arguments, and none of them need linking,
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   166
    // push them, instead of asking the JDK runtime to turn around and
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   167
    // pull them, saving a JVM/JDK transition in some simple cases.
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   168
    bool all_resolved = true;
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   169
    for (int i = 0; i < _argc; i++) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   170
      bool found_it = false;
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   171
      int arg_index = _pool->bootstrap_argument_index_at(_bss_index, i);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   172
      _pool->find_cached_constant_at(arg_index, found_it, CHECK);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   173
      if (!found_it) { all_resolved = false; break; }
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   174
    }
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   175
    if (all_resolved)
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   176
      use_BSCI = false;
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   177
  }
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   178
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   179
  if (!use_BSCI) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   180
    // return {arg...}; resolution of arguments is done immediately, before JDK code is called
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   181
    objArrayOop args_oop = oopFactory::new_objArray(SystemDictionary::Object_klass(), _argc, CHECK);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   182
    objArrayHandle args(THREAD, args_oop);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   183
    _pool->copy_bootstrap_arguments_at(_bss_index, 0, _argc, args, 0, true, Handle(), CHECK);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   184
    oop arg_oop = ((_argc == 1) ? args->obj_at(0) : (oop)NULL);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   185
    // try to discard the singleton array
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   186
    if (arg_oop != NULL && !arg_oop->is_array()) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   187
      // JVM treats arrays and nulls specially in this position,
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   188
      // but other things are just single arguments
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   189
      _arg_values = Handle(THREAD, arg_oop);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   190
    } else {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   191
      _arg_values = args;
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   192
    }
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   193
  } else {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   194
    // return {arg_count, pool_index}; JDK code must pull the arguments as needed
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   195
    typeArrayOop ints_oop = oopFactory::new_typeArray(T_INT, 2, CHECK);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   196
    ints_oop->int_at_put(0, _argc);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   197
    ints_oop->int_at_put(1, _bss_index);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   198
    _arg_values = Handle(THREAD, ints_oop);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   199
  }
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   200
}
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   201
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   202
// there must be a LinkageError pending; try to save it and then throw
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   203
bool BootstrapInfo::save_and_throw_indy_exc(TRAPS) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   204
  assert(HAS_PENDING_EXCEPTION, "");
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   205
  assert(_indy_index != -1, "");
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   206
  ConstantPoolCacheEntry* cpce = invokedynamic_cp_cache_entry();
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   207
  int encoded_index = ResolutionErrorTable::encode_cpcache_index(_indy_index);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   208
  bool recorded_res_status = cpce->save_and_throw_indy_exc(_pool, _bss_index,
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   209
                                                           encoded_index,
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   210
                                                           pool()->tag_at(_bss_index),
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   211
                                                           CHECK_false);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   212
  return recorded_res_status;
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   213
}
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   214
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   215
void BootstrapInfo::resolve_newly_linked_invokedynamic(CallInfo& result, TRAPS) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   216
  assert(is_resolved(), "");
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   217
  result.set_handle(resolved_method(), resolved_appendix(), CHECK);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   218
}
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   219
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   220
void BootstrapInfo::print_msg_on(outputStream* st, const char* msg) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   221
  ResourceMark rm;
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   222
  char what[20];
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   223
  st = st ? st : tty;
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   224
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   225
  if (_indy_index != -1)
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   226
    sprintf(what, "indy#%d", decode_indy_index());
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   227
  else
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   228
    sprintf(what, "condy");
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   229
  bool have_msg = (msg != NULL && strlen(msg) > 0);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   230
  st->print_cr("%s%sBootstrap in %s %s@CP[%d] %s:%s%s BSMS[%d] BSM@CP[%d]%s argc=%d%s",
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   231
                (have_msg ? msg : ""), (have_msg ? " " : ""),
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   232
                caller()->name()->as_C_string(),
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   233
                what,  // "indy#42" or "condy"
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   234
                _bss_index,
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   235
                _name->as_C_string(),
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   236
                _signature->as_C_string(),
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   237
                (_type_arg.is_null() ? "" : "(resolved)"),
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   238
                bsms_attr_index(),
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   239
                bsm_index(), (_bsm.is_null() ? "" : "(resolved)"),
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   240
                _argc, (_arg_values.is_null() ? "" : "(resolved)"));
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   241
  if (_argc > 0) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   242
    char argbuf[80];
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   243
    argbuf[0] = 0;
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   244
    for (int i = 0; i < _argc; i++) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   245
      int pos = (int) strlen(argbuf);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   246
      if (pos + 20 > (int)sizeof(argbuf)) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   247
        sprintf(argbuf + pos, "...");
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   248
        break;
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   249
      }
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   250
      if (i > 0)  argbuf[pos++] = ',';
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   251
      sprintf(argbuf+pos, "%d", arg_index(i));
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   252
    }
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   253
    st->print_cr("  argument indexes: {%s}", argbuf);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   254
  }
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   255
  if (_bsm.not_null()) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   256
    st->print("  resolved BSM: "); _bsm->print();
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   257
  }
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   258
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   259
  // How the array of resolved arguments is printed depends highly
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   260
  // on how BootstrapInfo::resolve_args structures the array based on
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   261
  // the use_BSCI setting.
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   262
  if (_arg_values.not_null()) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   263
    // Find the static arguments within the first element of _arg_values.
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   264
    objArrayOop static_args = (objArrayOop)_arg_values();
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   265
    if (!static_args->is_array()) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   266
      assert(_argc == 1, "Invalid BSM _arg_values for non-array");
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   267
      st->print("  resolved arg[0]: "); static_args->print();
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   268
    } else if (static_args->is_objArray()) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   269
      int lines = 0;
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   270
      for (int i = 0; i < _argc; i++) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   271
        oop x = static_args->obj_at(i);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   272
        if (x != NULL) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   273
          if (++lines > 6) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   274
            st->print_cr("  resolved arg[%d]: ...", i);
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   275
            break;
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   276
          }
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   277
          st->print("  resolved arg[%d]: ", i); x->print();
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   278
        }
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   279
      }
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   280
    } else if (static_args->is_typeArray()) {
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   281
      typeArrayOop tmp_array = (typeArrayOop) static_args;
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   282
      assert(tmp_array->length() == 2, "Invalid BSM _arg_values type array");
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   283
      st->print_cr("  resolved arg[0]: %d", tmp_array->int_at(0));
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   284
      st->print_cr("  resolved arg[1]: %d", tmp_array->int_at(1));
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   285
    }
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   286
  }
69cfd80f8706 8218994: Consolidate indy and condy JVM information within a BootstrapInfo data structure
lfoltan
parents:
diff changeset
   287
}