hotspot/src/share/vm/runtime/stackValueCollection.cpp
author goetz
Fri, 04 Jul 2014 11:46:01 +0200
changeset 25715 d5a8dbdc5150
parent 24424 2658d7834c6e
child 33148 68fa8b6c4340
permissions -rw-r--r--
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories. Summary: Introduce and clean up umbrella headers for the files in the cpu subdirectories. Reviewed-by: lfoltan, coleenp, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 8921
diff changeset
     2
 * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "runtime/stackValueCollection.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 8921
diff changeset
    28
PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 8921
diff changeset
    29
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
jint StackValueCollection::int_at(int slot) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
  intptr_t val =  at(slot)->get_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
  jint ival = *((jint*) (&val));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
  return ival;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
jlong StackValueCollection::long_at(int slot) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  return at(slot+1)->get_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  union {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
    jlong jl;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
    jint  array[2];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  } value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  // Interpreter stack is reversed in memory:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  // low memory location is in higher java local slot.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  value.array[0] = at(slot+1)->get_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  value.array[1] = at(slot  )->get_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  return value.jl;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
Handle StackValueCollection::obj_at(int slot) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  return at(slot)->get_obj();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
jfloat StackValueCollection::float_at(int slot) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  intptr_t res = at(slot)->get_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  return *((jfloat*) (&res));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
jdouble StackValueCollection::double_at(int slot) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  intptr_t res = at(slot+1)->get_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  return *((jdouble*) (&res));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  union {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
    jdouble jd;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    jint    array[2];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  } value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  // Interpreter stack is reversed in memory:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  // low memory location is in higher java local slot.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  value.array[0] = at(slot+1)->get_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  value.array[1] = at(slot  )->get_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  return value.jd;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
void StackValueCollection::set_int_at(int slot, jint value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  intptr_t val;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  *((jint*) (&val)) = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  at(slot)->set_int(val);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
void StackValueCollection::set_long_at(int slot, jlong value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  at(slot+1)->set_int(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  union {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    jlong jl;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    jint  array[2];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  } x;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  // Interpreter stack is reversed in memory:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  // low memory location is in higher java local slot.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  x.jl = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  at(slot+1)->set_int(x.array[0]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  at(slot+0)->set_int(x.array[1]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
void StackValueCollection::set_obj_at(int slot, Handle value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  at(slot)->set_obj(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
void StackValueCollection::set_float_at(int slot, jfloat value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  union {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    intptr_t jd;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    jint    array[2];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  } val;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  // Interpreter stores 32 bit floats in first half of 64 bit word.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  val.array[0] = *(jint*)(&value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  val.array[1] = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  at(slot)->set_int(val.jd);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  at(slot)->set_int(*(jint*)(&value));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
void StackValueCollection::set_double_at(int slot, jdouble value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  at(slot+1)->set_int(*(intptr_t*)(&value));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  union {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    jdouble jd;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
    jint    array[2];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  } x;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  // Interpreter stack is reversed in memory:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  // low memory location is in higher java local slot.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  x.jd = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  at(slot+1)->set_int(x.array[0]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  at(slot+0)->set_int(x.array[1]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
void StackValueCollection::print() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  for(int index = 0; index < size(); index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    tty->print("\t  %2d ", index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    at(index)->print_on(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    if( at(index  )->type() == T_INT &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
        index+1 < size() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
        at(index+1)->type() == T_INT ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
      tty->print("  " INT64_FORMAT " (long)", long_at(index));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
      tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
      tty->print("\t     %.15e (double)", double_at(index));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
      tty->print("  " PTR64_FORMAT " (longhex)", long_at(index));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
#endif