src/share/vm/runtime/stackValueCollection.cpp

Wed, 09 Apr 2008 15:10:22 -0700

author
rasbold
date
Wed, 09 Apr 2008 15:10:22 -0700
changeset 544
9f4457a14b58
parent 435
a61af66fc99e
child 1907
c18cbe5936b8
permissions
-rw-r--r--

Merge

     1 /*
     2  * Copyright 2001-2005 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 # include "incls/_precompiled.incl"
    26 # include "incls/_stackValueCollection.cpp.incl"
    28 jint StackValueCollection::int_at(int slot) const {
    29   intptr_t val =  at(slot)->get_int();
    30   jint ival = *((jint*) (&val));
    31   return ival;
    32 }
    34 jlong StackValueCollection::long_at(int slot) const {
    35 #ifdef _LP64
    36   return at(slot+1)->get_int();
    37 #else
    38   union {
    39     jlong jl;
    40     jint  array[2];
    41   } value;
    42   // Interpreter stack is reversed in memory:
    43   // low memory location is in higher java local slot.
    44   value.array[0] = at(slot+1)->get_int();
    45   value.array[1] = at(slot  )->get_int();
    46   return value.jl;
    47 #endif
    48 }
    50 Handle StackValueCollection::obj_at(int slot) const {
    51   return at(slot)->get_obj();
    52 }
    54 jfloat StackValueCollection::float_at(int slot) const {
    55   intptr_t res = at(slot)->get_int();
    56   return *((jfloat*) (&res));
    57 }
    59 jdouble StackValueCollection::double_at(int slot) const {
    60 #ifdef _LP64
    61   intptr_t res = at(slot+1)->get_int();
    62   return *((jdouble*) (&res));
    63 #else
    64   union {
    65     jdouble jd;
    66     jint    array[2];
    67   } value;
    68   // Interpreter stack is reversed in memory:
    69   // low memory location is in higher java local slot.
    70   value.array[0] = at(slot+1)->get_int();
    71   value.array[1] = at(slot  )->get_int();
    72   return value.jd;
    73 #endif
    74 }
    76 void StackValueCollection::set_int_at(int slot, jint value) {
    77   intptr_t val;
    78   *((jint*) (&val)) = value;
    79   at(slot)->set_int(val);
    80 }
    82 void StackValueCollection::set_long_at(int slot, jlong value) {
    83 #ifdef _LP64
    84   at(slot+1)->set_int(value);
    85 #else
    86   union {
    87     jlong jl;
    88     jint  array[2];
    89   } x;
    90   // Interpreter stack is reversed in memory:
    91   // low memory location is in higher java local slot.
    92   x.jl = value;
    93   at(slot+1)->set_int(x.array[0]);
    94   at(slot+0)->set_int(x.array[1]);
    95 #endif
    96 }
    98 void StackValueCollection::set_obj_at(int slot, Handle value) {
    99   at(slot)->set_obj(value);
   100 }
   102 void StackValueCollection::set_float_at(int slot, jfloat value) {
   103 #ifdef _LP64
   104   union {
   105     intptr_t jd;
   106     jint    array[2];
   107   } val;
   108   // Interpreter stores 32 bit floats in first half of 64 bit word.
   109   val.array[0] = *(jint*)(&value);
   110   val.array[1] = 0;
   111   at(slot)->set_int(val.jd);
   112 #else
   113   at(slot)->set_int(*(jint*)(&value));
   114 #endif
   115 }
   117 void StackValueCollection::set_double_at(int slot, jdouble value) {
   118 #ifdef _LP64
   119   at(slot+1)->set_int(*(intptr_t*)(&value));
   120 #else
   121   union {
   122     jdouble jd;
   123     jint    array[2];
   124   } x;
   125   // Interpreter stack is reversed in memory:
   126   // low memory location is in higher java local slot.
   127   x.jd = value;
   128   at(slot+1)->set_int(x.array[0]);
   129   at(slot+0)->set_int(x.array[1]);
   130 #endif
   131 }
   133 #ifndef PRODUCT
   134 void StackValueCollection::print() {
   135   for(int index = 0; index < size(); index++) {
   136     tty->print("\t  %2d ", index);
   137     at(index)->print_on(tty);
   138     if( at(index  )->type() == T_INT &&
   139         index+1 < size() &&
   140         at(index+1)->type() == T_INT ) {
   141       tty->print("  " INT64_FORMAT " (long)", long_at(index));
   142       tty->cr();
   143       tty->print("\t     %.15e (double)", double_at(index));
   144       tty->print("  " PTR64_FORMAT " (longhex)", long_at(index));
   145     }
   146     tty->cr();
   147   }
   148 }
   149 #endif

mercurial