hotspot/src/share/vm/classfile/javaClasses.inline.hpp
author mchung
Tue, 24 Nov 2015 14:59:17 -0800
changeset 34280 72bfaaffee36
parent 34273 8598d07915d9
child 35498 392b50de06c6
permissions -rw-r--r--
8143911: Reintegrate JEP 259: Stack-Walking API Reviewed-by: coleenp, dfuchs, bchristi, psandoz, sspitsyn Contributed-by: Mandy Chung <mandy.chung@oracle.com>, Brent Christian <brent.christian@oracle.com>, Daniel Fuchs <daniel.fuchs@oracle.com>, Hamlin Li <huaming.li@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29081
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
     1
/*
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
     4
 *
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
     8
 *
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    13
 * accompanied this code).
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    14
 *
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    18
 *
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    21
 * questions.
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    22
 *
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    23
 */
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    24
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    25
#ifndef SHARE_VM_CLASSFILE_JAVACLASSES_INLINE_HPP
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    26
#define SHARE_VM_CLASSFILE_JAVACLASSES_INLINE_HPP
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    27
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    28
#include "classfile/javaClasses.hpp"
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    29
#include "oops/oop.inline.hpp"
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    30
#include "oops/oopsHierarchy.hpp"
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    31
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    32
inline void java_lang_invoke_CallSite::set_target_volatile(oop site, oop target) {
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    33
  site->obj_field_put_volatile(_target_offset, target);
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    34
}
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    35
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    36
inline oop  java_lang_invoke_CallSite::target(oop site) {
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    37
  return site->obj_field(_target_offset);
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    38
}
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    39
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    40
inline void java_lang_invoke_CallSite::set_target(oop site, oop target) {
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    41
  site->obj_field_put(_target_offset, target);
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    42
}
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    43
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    44
inline bool java_lang_String::is_instance_inlined(oop obj) {
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    45
  return obj != NULL && obj->klass() == SystemDictionary::String_klass();
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    46
}
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    47
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    48
inline bool java_lang_invoke_CallSite::is_instance(oop obj) {
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    49
  return obj != NULL && is_subclass(obj->klass());
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    50
}
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    51
31037
01a5c5fa5681 8079205: CallSite dependency tracking is broken after sun.misc.Cleaner became automatically cleared
vlivanov
parents: 30263
diff changeset
    52
inline bool java_lang_invoke_MethodHandleNatives_CallSiteContext::is_instance(oop obj) {
01a5c5fa5681 8079205: CallSite dependency tracking is broken after sun.misc.Cleaner became automatically cleared
vlivanov
parents: 30263
diff changeset
    53
  return obj != NULL && is_subclass(obj->klass());
01a5c5fa5681 8079205: CallSite dependency tracking is broken after sun.misc.Cleaner became automatically cleared
vlivanov
parents: 30263
diff changeset
    54
}
01a5c5fa5681 8079205: CallSite dependency tracking is broken after sun.misc.Cleaner became automatically cleared
vlivanov
parents: 30263
diff changeset
    55
29081
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    56
inline bool java_lang_invoke_MemberName::is_instance(oop obj) {
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    57
  return obj != NULL && is_subclass(obj->klass());
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    58
}
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    59
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    60
inline bool java_lang_invoke_MethodType::is_instance(oop obj) {
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    61
  return obj != NULL && obj->klass() == SystemDictionary::MethodType_klass();
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    62
}
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    63
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    64
inline bool java_lang_invoke_MethodHandle::is_instance(oop obj) {
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    65
  return obj != NULL && is_subclass(obj->klass());
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    66
}
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    67
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    68
inline bool java_lang_Class::is_instance(oop obj) {
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    69
  return obj != NULL && obj->klass() == SystemDictionary::Class_klass();
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    70
}
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    71
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    72
inline bool java_lang_invoke_DirectMethodHandle::is_instance(oop obj) {
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    73
  return obj != NULL && is_subclass(obj->klass());
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    74
}
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
    75
34280
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
    76
inline int Backtrace::merge_bci_and_version(int bci, int version) {
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
    77
  // only store u2 for version, checking for overflow.
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
    78
  if (version > USHRT_MAX || version < 0) version = USHRT_MAX;
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
    79
  assert((jushort)bci == bci, "bci should be short");
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
    80
  return build_int_from_shorts(version, bci);
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
    81
}
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
    82
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
    83
inline int Backtrace::merge_mid_and_cpref(int mid, int cpref) {
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
    84
  // only store u2 for mid and cpref, checking for overflow.
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
    85
  assert((jushort)mid == mid, "mid should be short");
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
    86
  assert((jushort)cpref == cpref, "cpref should be short");
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
    87
  return build_int_from_shorts(cpref, mid);
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
    88
}
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
    89
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
    90
inline int Backtrace::bci_at(unsigned int merged) {
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
    91
  return extract_high_short_from_int(merged);
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
    92
}
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
    93
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
    94
inline int Backtrace::version_at(unsigned int merged) {
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
    95
  return extract_low_short_from_int(merged);
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
    96
}
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
    97
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
    98
inline int Backtrace::mid_at(unsigned int merged) {
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
    99
  return extract_high_short_from_int(merged);
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   100
}
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   101
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   102
inline int Backtrace::cpref_at(unsigned int merged) {
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   103
  return extract_low_short_from_int(merged);
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   104
}
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   105
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   106
inline int Backtrace::get_line_number(const methodHandle& method, int bci) {
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   107
  int line_number = 0;
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   108
  if (method->is_native()) {
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   109
    // Negative value different from -1 below, enabling Java code in
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   110
    // class java.lang.StackTraceElement to distinguish "native" from
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   111
    // "no LineNumberTable".  JDK tests for -2.
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   112
    line_number = -2;
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   113
  } else {
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   114
    // Returns -1 if no LineNumberTable, and otherwise actual line number
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   115
    line_number = method->line_number_from_bci(bci);
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   116
    if (line_number == -1 && ShowHiddenFrames) {
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   117
      line_number = bci + 1000000;
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   118
    }
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   119
  }
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   120
  return line_number;
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   121
}
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   122
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   123
/*
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   124
 * Returns the source file name of a given InstanceKlass and version
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   125
 */
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   126
inline Symbol* Backtrace::get_source_file_name(InstanceKlass* holder, int version) {
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   127
  // Find the specific ik version that contains this source_file_name_index
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   128
  // via the previous versions list, but use the current version's
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   129
  // constant pool to look it up.  The previous version's index has been
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   130
  // merged for the current constant pool.
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   131
  InstanceKlass* ik = holder->get_klass_version(version);
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   132
  // This version has been cleaned up.
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   133
  if (ik == NULL) return NULL;
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   134
  int source_file_name_index = ik->source_file_name_index();
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   135
  return (source_file_name_index == 0) ?
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   136
      (Symbol*)NULL : holder->constants()->symbol_at(source_file_name_index);
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   137
}
72bfaaffee36 8143911: Reintegrate JEP 259: Stack-Walking API
mchung
parents: 34273
diff changeset
   138
29081
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
diff changeset
   139
#endif // SHARE_VM_CLASSFILE_JAVACLASSES_INLINE_HPP