jdk

Форк
0
/
stackValueCollection.cpp 
145 строк · 4.0 Кб
1
/*
2
 * Copyright (c) 2001, 2017, 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
 */
24

25
#include "precompiled.hpp"
26
#include "runtime/stackValueCollection.hpp"
27

28
jint StackValueCollection::int_at(int slot) const {
29
  return at(slot)->get_jint();
30
}
31

32
jlong StackValueCollection::long_at(int slot) const {
33
#ifdef _LP64
34
  return at(slot+1)->get_intptr();
35
#else
36
  union {
37
    jlong jl;
38
    jint  array[2];
39
  } value;
40
  // Interpreter stack is reversed in memory:
41
  // low memory location is in higher java local slot.
42
  value.array[0] = at(slot+1)->get_intptr();
43
  value.array[1] = at(slot  )->get_intptr();
44
  return value.jl;
45
#endif
46
}
47

48
Handle StackValueCollection::obj_at(int slot) const {
49
  return at(slot)->get_obj();
50
}
51

52
jfloat StackValueCollection::float_at(int slot) const {
53
  intptr_t res = at(slot)->get_intptr();
54
  return *((jfloat*) (&res));
55
}
56

57
jdouble StackValueCollection::double_at(int slot) const {
58
#ifdef _LP64
59
  intptr_t res = at(slot+1)->get_intptr();
60
  return *((jdouble*) (&res));
61
#else
62
  union {
63
    jdouble jd;
64
    jint    array[2];
65
  } value;
66
  // Interpreter stack is reversed in memory:
67
  // low memory location is in higher java local slot.
68
  value.array[0] = at(slot+1)->get_intptr();
69
  value.array[1] = at(slot  )->get_intptr();
70
  return value.jd;
71
#endif
72
}
73

74
void StackValueCollection::set_int_at(int slot, jint value) {
75
  at(slot)->set_jint(value);
76
}
77

78
void StackValueCollection::set_long_at(int slot, jlong value) {
79
#ifdef _LP64
80
  at(slot+1)->set_intptr(value);
81
#else
82
  union {
83
    jlong jl;
84
    jint  array[2];
85
  } x;
86
  // Interpreter stack is reversed in memory:
87
  // low memory location is in higher java local slot.
88
  x.jl = value;
89
  at(slot+1)->set_intptr(x.array[0]);
90
  at(slot+0)->set_intptr(x.array[1]);
91
#endif
92
}
93

94
void StackValueCollection::set_obj_at(int slot, Handle value) {
95
  at(slot)->set_obj(value);
96
}
97

98
void StackValueCollection::set_float_at(int slot, jfloat value) {
99
#ifdef _LP64
100
  union {
101
    intptr_t jd;
102
    jint    array[2];
103
  } val;
104
  // Interpreter stores 32 bit floats in first half of 64 bit word.
105
  val.array[0] = *(jint*)(&value);
106
  val.array[1] = 0;
107
  at(slot)->set_intptr(val.jd);
108
#else
109
  at(slot)->set_intptr(*(jint*)(&value));
110
#endif
111
}
112

113
void StackValueCollection::set_double_at(int slot, jdouble value) {
114
#ifdef _LP64
115
  at(slot+1)->set_intptr(*(intptr_t*)(&value));
116
#else
117
  union {
118
    jdouble jd;
119
    jint    array[2];
120
  } x;
121
  // Interpreter stack is reversed in memory:
122
  // low memory location is in higher java local slot.
123
  x.jd = value;
124
  at(slot+1)->set_intptr(x.array[0]);
125
  at(slot+0)->set_intptr(x.array[1]);
126
#endif
127
}
128

129
#ifndef PRODUCT
130
void StackValueCollection::print() {
131
  for(int index = 0; index < size(); index++) {
132
    tty->print("\t  %2d ", index);
133
    at(index)->print_on(tty);
134
    if( at(index  )->type() == T_INT &&
135
        index+1 < size() &&
136
        at(index+1)->type() == T_INT ) {
137
      tty->print("  " INT64_FORMAT " (long)", (int64_t)long_at(index));
138
      tty->cr();
139
      tty->print("\t     %.15e (double)", double_at(index));
140
      tty->print("  " INT64_FORMAT_X_0 " (longhex)", (int64_t)long_at(index));
141
    }
142
    tty->cr();
143
  }
144
}
145
#endif
146

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.