src/share/vm/runtime/stackValueCollection.cpp

changeset 0
f90c822e73f8
child 1
2d8a650513c2
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/runtime/stackValueCollection.cpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,166 @@
     1.4 +/*
     1.5 + * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#include "precompiled.hpp"
    1.29 +#include "runtime/stackValueCollection.hpp"
    1.30 +#ifdef TARGET_ARCH_x86
    1.31 +# include "jniTypes_x86.hpp"
    1.32 +#endif
    1.33 +#ifdef TARGET_ARCH_sparc
    1.34 +# include "jniTypes_sparc.hpp"
    1.35 +#endif
    1.36 +#ifdef TARGET_ARCH_zero
    1.37 +# include "jniTypes_zero.hpp"
    1.38 +#endif
    1.39 +#ifdef TARGET_ARCH_arm
    1.40 +# include "jniTypes_arm.hpp"
    1.41 +#endif
    1.42 +#ifdef TARGET_ARCH_ppc
    1.43 +# include "jniTypes_ppc.hpp"
    1.44 +#endif
    1.45 +
    1.46 +PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
    1.47 +
    1.48 +jint StackValueCollection::int_at(int slot) const {
    1.49 +  intptr_t val =  at(slot)->get_int();
    1.50 +  jint ival = *((jint*) (&val));
    1.51 +  return ival;
    1.52 +}
    1.53 +
    1.54 +jlong StackValueCollection::long_at(int slot) const {
    1.55 +#ifdef _LP64
    1.56 +  return at(slot+1)->get_int();
    1.57 +#else
    1.58 +  union {
    1.59 +    jlong jl;
    1.60 +    jint  array[2];
    1.61 +  } value;
    1.62 +  // Interpreter stack is reversed in memory:
    1.63 +  // low memory location is in higher java local slot.
    1.64 +  value.array[0] = at(slot+1)->get_int();
    1.65 +  value.array[1] = at(slot  )->get_int();
    1.66 +  return value.jl;
    1.67 +#endif
    1.68 +}
    1.69 +
    1.70 +Handle StackValueCollection::obj_at(int slot) const {
    1.71 +  return at(slot)->get_obj();
    1.72 +}
    1.73 +
    1.74 +jfloat StackValueCollection::float_at(int slot) const {
    1.75 +  intptr_t res = at(slot)->get_int();
    1.76 +  return *((jfloat*) (&res));
    1.77 +}
    1.78 +
    1.79 +jdouble StackValueCollection::double_at(int slot) const {
    1.80 +#ifdef _LP64
    1.81 +  intptr_t res = at(slot+1)->get_int();
    1.82 +  return *((jdouble*) (&res));
    1.83 +#else
    1.84 +  union {
    1.85 +    jdouble jd;
    1.86 +    jint    array[2];
    1.87 +  } value;
    1.88 +  // Interpreter stack is reversed in memory:
    1.89 +  // low memory location is in higher java local slot.
    1.90 +  value.array[0] = at(slot+1)->get_int();
    1.91 +  value.array[1] = at(slot  )->get_int();
    1.92 +  return value.jd;
    1.93 +#endif
    1.94 +}
    1.95 +
    1.96 +void StackValueCollection::set_int_at(int slot, jint value) {
    1.97 +  intptr_t val;
    1.98 +  *((jint*) (&val)) = value;
    1.99 +  at(slot)->set_int(val);
   1.100 +}
   1.101 +
   1.102 +void StackValueCollection::set_long_at(int slot, jlong value) {
   1.103 +#ifdef _LP64
   1.104 +  at(slot+1)->set_int(value);
   1.105 +#else
   1.106 +  union {
   1.107 +    jlong jl;
   1.108 +    jint  array[2];
   1.109 +  } x;
   1.110 +  // Interpreter stack is reversed in memory:
   1.111 +  // low memory location is in higher java local slot.
   1.112 +  x.jl = value;
   1.113 +  at(slot+1)->set_int(x.array[0]);
   1.114 +  at(slot+0)->set_int(x.array[1]);
   1.115 +#endif
   1.116 +}
   1.117 +
   1.118 +void StackValueCollection::set_obj_at(int slot, Handle value) {
   1.119 +  at(slot)->set_obj(value);
   1.120 +}
   1.121 +
   1.122 +void StackValueCollection::set_float_at(int slot, jfloat value) {
   1.123 +#ifdef _LP64
   1.124 +  union {
   1.125 +    intptr_t jd;
   1.126 +    jint    array[2];
   1.127 +  } val;
   1.128 +  // Interpreter stores 32 bit floats in first half of 64 bit word.
   1.129 +  val.array[0] = *(jint*)(&value);
   1.130 +  val.array[1] = 0;
   1.131 +  at(slot)->set_int(val.jd);
   1.132 +#else
   1.133 +  at(slot)->set_int(*(jint*)(&value));
   1.134 +#endif
   1.135 +}
   1.136 +
   1.137 +void StackValueCollection::set_double_at(int slot, jdouble value) {
   1.138 +#ifdef _LP64
   1.139 +  at(slot+1)->set_int(*(intptr_t*)(&value));
   1.140 +#else
   1.141 +  union {
   1.142 +    jdouble jd;
   1.143 +    jint    array[2];
   1.144 +  } x;
   1.145 +  // Interpreter stack is reversed in memory:
   1.146 +  // low memory location is in higher java local slot.
   1.147 +  x.jd = value;
   1.148 +  at(slot+1)->set_int(x.array[0]);
   1.149 +  at(slot+0)->set_int(x.array[1]);
   1.150 +#endif
   1.151 +}
   1.152 +
   1.153 +#ifndef PRODUCT
   1.154 +void StackValueCollection::print() {
   1.155 +  for(int index = 0; index < size(); index++) {
   1.156 +    tty->print("\t  %2d ", index);
   1.157 +    at(index)->print_on(tty);
   1.158 +    if( at(index  )->type() == T_INT &&
   1.159 +        index+1 < size() &&
   1.160 +        at(index+1)->type() == T_INT ) {
   1.161 +      tty->print("  " INT64_FORMAT " (long)", long_at(index));
   1.162 +      tty->cr();
   1.163 +      tty->print("\t     %.15e (double)", double_at(index));
   1.164 +      tty->print("  " PTR64_FORMAT " (longhex)", long_at(index));
   1.165 +    }
   1.166 +    tty->cr();
   1.167 +  }
   1.168 +}
   1.169 +#endif

mercurial