src/hotspot/share/jfr/jni/jfrJavaCall.cpp
author coleenp
Tue, 14 May 2019 11:29:18 -0400
changeset 54847 59ea39bb2809
parent 50113 caf115bb98ad
child 55302 686dedba1d9a
permissions -rw-r--r--
8223657: Remove unused THREAD argument from SymbolTable functions Summary: also made lookup and lookup_only functions private to SymbolTable. External callers use new_symbol or probe. Reviewed-by: dholmes, gziemski
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     1
/*
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 50113
diff changeset
     2
 * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     4
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     7
 * published by the Free Software Foundation.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     8
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    13
 * accompanied this code).
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    14
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    18
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    21
 * questions.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    22
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    23
 */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    24
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    25
#include "precompiled.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    26
#include "classfile/symbolTable.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    27
#include "classfile/systemDictionary.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    28
#include "jfr/jni/jfrJavaCall.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    29
#include "jfr/jni/jfrJavaSupport.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    30
#include "memory/resourceArea.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    31
#include "runtime/handles.inline.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    32
#include "runtime/javaCalls.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    33
#include "utilities/globalDefinitions.hpp"
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    34
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    35
#ifdef ASSERT
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    36
static bool is_large_value(const JavaValue& value) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    37
  return value.get_type() == T_LONG || value.get_type() == T_DOUBLE;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    38
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    39
#endif // ASSERT
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    40
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 50113
diff changeset
    41
static Symbol* resolve(const char* str) {
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    42
  assert(str != NULL, "invariant");
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 50113
diff changeset
    43
  return SymbolTable::new_symbol(str);
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    44
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    45
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    46
static Klass* resolve(Symbol* k_sym, TRAPS) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    47
  assert(k_sym != NULL, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    48
  return SystemDictionary::resolve_or_fail(k_sym, true, THREAD);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    49
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    50
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    51
JfrJavaArguments::Parameters::Parameters() : _storage_index(0), _java_stack_slots(0) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    52
  JavaValue value(T_VOID);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    53
  push(value);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    54
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    55
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    56
void JfrJavaArguments::Parameters::push(const JavaValue& value) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    57
  assert(_storage != NULL, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    58
  assert(!is_large_value(value), "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    59
  assert(_storage_index < SIZE, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    60
  _storage[_storage_index++] = value;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    61
  _java_stack_slots++;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    62
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    63
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    64
void JfrJavaArguments::Parameters::push_large(const JavaValue& value) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    65
  assert(_storage != NULL, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    66
  assert(is_large_value(value), "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    67
  assert(_storage_index < SIZE, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    68
  _storage[_storage_index++] = value;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    69
  _java_stack_slots += 2;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    70
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    71
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    72
void JfrJavaArguments::Parameters::set_receiver(const oop receiver) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    73
  assert(_storage != NULL, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    74
  assert(receiver != NULL, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    75
  JavaValue value(T_OBJECT);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    76
  value.set_jobject((jobject)receiver);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    77
  _storage[0] = value;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    78
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    79
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    80
void JfrJavaArguments::Parameters::set_receiver(Handle receiver) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    81
  set_receiver(receiver());
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    82
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    83
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    84
oop JfrJavaArguments::Parameters::receiver() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    85
  assert(has_receiver(), "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    86
  assert(_storage[0].get_type() == T_OBJECT, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    87
  return (oop)_storage[0].get_jobject();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    88
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    89
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    90
bool JfrJavaArguments::Parameters::has_receiver() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    91
  assert(_storage != NULL, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    92
  assert(_storage_index >= 1, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    93
  assert(_java_stack_slots >= 1, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    94
  return _storage[0].get_type() == T_OBJECT;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    95
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    96
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    97
void JfrJavaArguments::Parameters::push_oop(const oop obj) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    98
  JavaValue value(T_OBJECT);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    99
  value.set_jobject((jobject)obj);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   100
  push(value);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   101
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   102
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   103
void JfrJavaArguments::Parameters::push_oop(Handle h_obj) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   104
  push_oop(h_obj());
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   105
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   106
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   107
void JfrJavaArguments::Parameters::push_jobject(jobject h) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   108
  JavaValue value(T_ADDRESS);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   109
  value.set_jobject(h);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   110
  push(value);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   111
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   112
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   113
void JfrJavaArguments::Parameters::push_jint(jint i) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   114
  JavaValue value(T_INT);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   115
  value.set_jint(i);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   116
  push(value);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   117
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   118
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   119
void JfrJavaArguments::Parameters::push_jfloat(jfloat f) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   120
  JavaValue value(T_FLOAT);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   121
  value.set_jfloat(f);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   122
  push(value);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   123
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   124
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   125
void JfrJavaArguments::Parameters::push_jdouble(jdouble d) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   126
  JavaValue value(T_DOUBLE);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   127
  value.set_jdouble(d);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   128
  push_large(value);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   129
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   130
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   131
void JfrJavaArguments::Parameters::push_jlong(jlong l) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   132
  JavaValue value(T_LONG);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   133
  value.set_jlong(l);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   134
  push_large(value);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   135
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   136
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   137
// including receiver (even if there is none)
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   138
inline int JfrJavaArguments::Parameters::length() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   139
  assert(_storage_index >= 1, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   140
  return _storage_index;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   141
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   142
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   143
inline int JfrJavaArguments::Parameters::java_stack_slots() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   144
  return _java_stack_slots;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   145
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   146
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   147
const JavaValue& JfrJavaArguments::Parameters::values(int idx) const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   148
  assert(idx >= 0, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   149
  assert(idx < SIZE, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   150
  return _storage[idx];
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   151
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   152
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   153
void JfrJavaArguments::Parameters::copy(JavaCallArguments& args, TRAPS) const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   154
  DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(THREAD));
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   155
  if (has_receiver()) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   156
    args.set_receiver(Handle(THREAD, receiver()));
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   157
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   158
  for (int i = 1; i < length(); ++i) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   159
    switch(values(i).get_type()) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   160
      case T_BOOLEAN:
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   161
      case T_CHAR:
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   162
      case T_SHORT:
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   163
      case T_INT:
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   164
        args.push_int(values(i).get_jint());
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   165
        break;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   166
      case T_LONG:
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   167
        args.push_long(values(i).get_jlong());
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   168
        break;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   169
      case T_FLOAT:
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   170
        args.push_float(values(i).get_jfloat());
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   171
        break;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   172
      case T_DOUBLE:
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   173
        args.push_double(values(i).get_jdouble());
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   174
        break;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   175
      case T_OBJECT:
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   176
        args.push_oop(Handle(THREAD, (oop)values(i).get_jobject()));
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   177
        break;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   178
      case T_ADDRESS:
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   179
        args.push_jobject(values(i).get_jobject());
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   180
        break;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   181
      default:
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   182
        ShouldNotReachHere();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   183
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   184
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   185
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   186
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   187
JfrJavaArguments::JfrJavaArguments(JavaValue* result) : _result(result), _klass(NULL), _name(NULL), _signature(NULL), _array_length(0) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   188
  assert(result != NULL, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   189
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   190
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   191
JfrJavaArguments::JfrJavaArguments(JavaValue* result, const char* klass_name, const char* name, const char* signature, TRAPS) :
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   192
  _result(result),
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   193
  _klass(NULL),
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   194
  _name(NULL),
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   195
  _signature(NULL),
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   196
  _array_length(0) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   197
  assert(result != NULL, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   198
  if (klass_name != NULL) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   199
    set_klass(klass_name, CHECK);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   200
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   201
  if (name != NULL) {
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 50113
diff changeset
   202
    set_name(name);
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   203
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   204
  if (signature != NULL) {
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 50113
diff changeset
   205
    set_signature(signature);
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   206
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   207
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   208
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   209
JfrJavaArguments::JfrJavaArguments(JavaValue* result, const Klass* klass, const Symbol* name, const Symbol* signature) : _result(result),
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   210
  _klass(NULL),
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   211
  _name(NULL),
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   212
  _signature(NULL),
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   213
  _array_length(0) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   214
  assert(result != NULL, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   215
  if (klass != NULL) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   216
    set_klass(klass);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   217
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   218
  if (name != NULL) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   219
    set_name(name);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   220
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   221
  if (signature != NULL) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   222
    set_signature(signature);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   223
  }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   224
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   225
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   226
Klass* JfrJavaArguments::klass() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   227
  assert(_klass != NULL, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   228
  return const_cast<Klass*>(_klass);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   229
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   230
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   231
void JfrJavaArguments::set_klass(const char* klass_name, TRAPS) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   232
  assert(klass_name != NULL, "invariant");
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 50113
diff changeset
   233
  Symbol* const k_sym = resolve(klass_name);
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   234
  assert(k_sym != NULL, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   235
  const Klass* const klass = resolve(k_sym, CHECK);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   236
  set_klass(klass);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   237
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   238
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   239
void JfrJavaArguments::set_klass(const Klass* klass) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   240
  assert(klass != NULL, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   241
  _klass = klass;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   242
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   243
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   244
Symbol* JfrJavaArguments::name() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   245
  assert(_name != NULL, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   246
  return const_cast<Symbol*>(_name);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   247
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   248
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 50113
diff changeset
   249
void JfrJavaArguments::set_name(const char* name) {
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   250
  assert(name != NULL, "invariant");
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 50113
diff changeset
   251
  const Symbol* const sym = resolve(name);
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   252
  set_name(sym);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   253
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   254
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   255
void JfrJavaArguments::set_name(const Symbol* name) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   256
  assert(name != NULL, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   257
  _name = name;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   258
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   259
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   260
Symbol* JfrJavaArguments::signature() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   261
  assert(_signature != NULL, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   262
  return const_cast<Symbol*>(_signature);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   263
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   264
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 50113
diff changeset
   265
void JfrJavaArguments::set_signature(const char* signature) {
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   266
  assert(signature != NULL, "invariant");
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 50113
diff changeset
   267
  const Symbol* const sym = resolve(signature);
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   268
  set_signature(sym);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   269
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   270
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   271
void JfrJavaArguments::set_signature(const Symbol* signature) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   272
  assert(signature != NULL, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   273
  _signature = signature;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   274
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   275
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   276
int JfrJavaArguments::array_length() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   277
  return _array_length;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   278
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   279
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   280
void JfrJavaArguments::set_array_length(int length) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   281
  assert(length >= 0, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   282
  _array_length = length;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   283
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   284
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   285
JavaValue* JfrJavaArguments::result() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   286
  assert(_result != NULL, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   287
  return const_cast<JavaValue*>(_result);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   288
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   289
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   290
int JfrJavaArguments::length() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   291
  return _params.length();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   292
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   293
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   294
bool JfrJavaArguments::has_receiver() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   295
  return _params.has_receiver();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   296
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   297
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   298
oop JfrJavaArguments::receiver() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   299
  return _params.receiver();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   300
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   301
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   302
void JfrJavaArguments::set_receiver(const oop receiver) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   303
  _params.set_receiver(receiver);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   304
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   305
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   306
void JfrJavaArguments::set_receiver(Handle receiver) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   307
  _params.set_receiver(receiver);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   308
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   309
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   310
void JfrJavaArguments::push_oop(const oop obj) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   311
  _params.push_oop(obj);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   312
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   313
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   314
void JfrJavaArguments::push_oop(Handle h_obj) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   315
  _params.push_oop(h_obj);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   316
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   317
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   318
void JfrJavaArguments::push_jobject(jobject h) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   319
  _params.push_jobject(h);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   320
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   321
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   322
void JfrJavaArguments::push_int(jint i) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   323
  _params.push_jint(i);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   324
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   325
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   326
void JfrJavaArguments::push_float(jfloat f) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   327
  _params.push_jfloat(f);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   328
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   329
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   330
void JfrJavaArguments::push_double(jdouble d) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   331
  _params.push_jdouble(d);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   332
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   333
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   334
void JfrJavaArguments::push_long(jlong l) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   335
  _params.push_jlong(l);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   336
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   337
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   338
const JavaValue& JfrJavaArguments::param(int idx) const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   339
  return _params.values(idx);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   340
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   341
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   342
int JfrJavaArguments::java_call_arg_slots() const {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   343
  return _params.java_stack_slots();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   344
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   345
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   346
void JfrJavaArguments::copy(JavaCallArguments& args, TRAPS) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   347
  _params.copy(args, THREAD);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   348
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   349
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   350
void JfrJavaCall::call_static(JfrJavaArguments* args, TRAPS) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   351
  assert(args != NULL, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   352
  DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(THREAD));
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   353
  ResourceMark rm(THREAD);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   354
  HandleMark hm(THREAD);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   355
  JavaCallArguments jcas(args->java_call_arg_slots());
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   356
  args->copy(jcas, CHECK);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   357
  JavaCalls::call_static(args->result(), args->klass(), args->name(), args->signature(), &jcas, THREAD);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   358
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   359
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   360
void JfrJavaCall::call_special(JfrJavaArguments* args, TRAPS) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   361
  assert(args != NULL, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   362
  assert(args->has_receiver(), "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   363
  DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(THREAD));
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   364
  ResourceMark rm(THREAD);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   365
  HandleMark hm(THREAD);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   366
  JavaCallArguments jcas(args->java_call_arg_slots());
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   367
  args->copy(jcas, CHECK);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   368
  JavaCalls::call_special(args->result(), args->klass(), args->name(), args->signature(), &jcas, THREAD);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   369
}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   370
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   371
void JfrJavaCall::call_virtual(JfrJavaArguments* args, TRAPS) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   372
  assert(args != NULL, "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   373
  assert(args->has_receiver(), "invariant");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   374
  DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(THREAD));
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   375
  ResourceMark rm(THREAD);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   376
  HandleMark hm(THREAD);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   377
  JavaCallArguments jcas(args->java_call_arg_slots());
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   378
  args->copy(jcas, CHECK);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   379
  JavaCalls::call_virtual(args->result(), args->klass(), args->name(), args->signature(), &jcas, THREAD);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   380
}