src/share/vm/runtime/stackValueCollection.cpp

Mon, 12 Aug 2019 18:30:40 +0300

author
apetushkov
date
Mon, 12 Aug 2019 18:30:40 +0300
changeset 9858
b985cbb00e68
parent 6680
78bbf4d43a14
child 6876
710a3c8b516e
permissions
-rw-r--r--

8223147: JFR Backport
8199712: Flight Recorder
8203346: JFR: Inconsistent signature of jfr_add_string_constant
8195817: JFR.stop should require name of recording
8195818: JFR.start should increase autogenerated name by one
8195819: Remove recording=x from jcmd JFR.check output
8203921: JFR thread sampling is missing fixes from JDK-8194552
8203929: Limit amount of data for JFR.dump
8203664: JFR start failure after AppCDS archive created with JFR StartFlightRecording
8003209: JFR events for network utilization
8207392: [PPC64] Implement JFR profiling
8202835: jfr/event/os/TestSystemProcess.java fails on missing events
Summary: Backport JFR from JDK11. Initial integration
Reviewed-by: neugens

     1 /*
     2  * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #include "precompiled.hpp"
    26 #include "runtime/stackValueCollection.hpp"
    27 #ifdef TARGET_ARCH_x86
    28 # include "jniTypes_x86.hpp"
    29 #endif
    30 #ifdef TARGET_ARCH_sparc
    31 # include "jniTypes_sparc.hpp"
    32 #endif
    33 #ifdef TARGET_ARCH_zero
    34 # include "jniTypes_zero.hpp"
    35 #endif
    36 #ifdef TARGET_ARCH_arm
    37 # include "jniTypes_arm.hpp"
    38 #endif
    39 #ifdef TARGET_ARCH_ppc
    40 # include "jniTypes_ppc.hpp"
    41 #endif
    43 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
    45 jint StackValueCollection::int_at(int slot) const {
    46   intptr_t val =  at(slot)->get_int();
    47   jint ival = *((jint*) (&val));
    48   return ival;
    49 }
    51 jlong StackValueCollection::long_at(int slot) const {
    52 #ifdef _LP64
    53   return at(slot+1)->get_int();
    54 #else
    55   union {
    56     jlong jl;
    57     jint  array[2];
    58   } value;
    59   // Interpreter stack is reversed in memory:
    60   // low memory location is in higher java local slot.
    61   value.array[0] = at(slot+1)->get_int();
    62   value.array[1] = at(slot  )->get_int();
    63   return value.jl;
    64 #endif
    65 }
    67 Handle StackValueCollection::obj_at(int slot) const {
    68   return at(slot)->get_obj();
    69 }
    71 jfloat StackValueCollection::float_at(int slot) const {
    72   intptr_t res = at(slot)->get_int();
    73   return *((jfloat*) (&res));
    74 }
    76 jdouble StackValueCollection::double_at(int slot) const {
    77 #ifdef _LP64
    78   intptr_t res = at(slot+1)->get_int();
    79   return *((jdouble*) (&res));
    80 #else
    81   union {
    82     jdouble jd;
    83     jint    array[2];
    84   } value;
    85   // Interpreter stack is reversed in memory:
    86   // low memory location is in higher java local slot.
    87   value.array[0] = at(slot+1)->get_int();
    88   value.array[1] = at(slot  )->get_int();
    89   return value.jd;
    90 #endif
    91 }
    93 void StackValueCollection::set_int_at(int slot, jint value) {
    94   intptr_t val;
    95   *((jint*) (&val)) = value;
    96   at(slot)->set_int(val);
    97 }
    99 void StackValueCollection::set_long_at(int slot, jlong value) {
   100 #ifdef _LP64
   101   at(slot+1)->set_int(value);
   102 #else
   103   union {
   104     jlong jl;
   105     jint  array[2];
   106   } x;
   107   // Interpreter stack is reversed in memory:
   108   // low memory location is in higher java local slot.
   109   x.jl = value;
   110   at(slot+1)->set_int(x.array[0]);
   111   at(slot+0)->set_int(x.array[1]);
   112 #endif
   113 }
   115 void StackValueCollection::set_obj_at(int slot, Handle value) {
   116   at(slot)->set_obj(value);
   117 }
   119 void StackValueCollection::set_float_at(int slot, jfloat value) {
   120 #ifdef _LP64
   121   union {
   122     intptr_t jd;
   123     jint    array[2];
   124   } val;
   125   // Interpreter stores 32 bit floats in first half of 64 bit word.
   126   val.array[0] = *(jint*)(&value);
   127   val.array[1] = 0;
   128   at(slot)->set_int(val.jd);
   129 #else
   130   at(slot)->set_int(*(jint*)(&value));
   131 #endif
   132 }
   134 void StackValueCollection::set_double_at(int slot, jdouble value) {
   135 #ifdef _LP64
   136   at(slot+1)->set_int(*(intptr_t*)(&value));
   137 #else
   138   union {
   139     jdouble jd;
   140     jint    array[2];
   141   } x;
   142   // Interpreter stack is reversed in memory:
   143   // low memory location is in higher java local slot.
   144   x.jd = value;
   145   at(slot+1)->set_int(x.array[0]);
   146   at(slot+0)->set_int(x.array[1]);
   147 #endif
   148 }
   150 #ifndef PRODUCT
   151 void StackValueCollection::print() {
   152   for(int index = 0; index < size(); index++) {
   153     tty->print("\t  %2d ", index);
   154     at(index)->print_on(tty);
   155     if( at(index  )->type() == T_INT &&
   156         index+1 < size() &&
   157         at(index+1)->type() == T_INT ) {
   158       tty->print("  " INT64_FORMAT " (long)", long_at(index));
   159       tty->cr();
   160       tty->print("\t     %.15e (double)", double_at(index));
   161       tty->print("  " PTR64_FORMAT " (longhex)", long_at(index));
   162     }
   163     tty->cr();
   164   }
   165 }
   166 #endif

mercurial