2
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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.
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
25
#include "precompiled.hpp"
26
#include "runtime/registerMap.hpp"
27
#include "vmreg_x86.inline.hpp"
29
address RegisterMap::pd_location(VMReg reg) const {
30
if (reg->is_XMMRegister()) {
31
int reg_base = reg->value() - ConcreteRegisterImpl::max_fpr;
32
int base_reg_enc = (reg_base / XMMRegister::max_slots_per_register);
33
assert(base_reg_enc >= 0 && base_reg_enc < XMMRegister::number_of_registers, "invalid XMMRegister: %d", base_reg_enc);
34
VMReg base_reg = as_XMMRegister(base_reg_enc)->as_VMReg();
35
intptr_t offset_in_bytes = (reg->value() - base_reg->value()) * VMRegImpl::stack_slot_size;
36
if (base_reg_enc > 15) {
37
if (offset_in_bytes == 0) {
38
return nullptr; // ZMM16-31 are stored in full.
41
if (offset_in_bytes == 0 || offset_in_bytes == 16 || offset_in_bytes == 32) {
42
// Reads of the low and high 16 byte parts should be handled by location itself because
43
// they have separate callee saved entries (see RegisterSaver::save_live_registers()).
46
// The upper part of YMM0-15 and ZMM0-15 registers are saved separately in the frame.
47
if (offset_in_bytes > 32) {
48
base_reg = base_reg->next(8);
49
offset_in_bytes -= 32;
50
} else if (offset_in_bytes > 16) {
51
base_reg = base_reg->next(4);
52
offset_in_bytes -= 16;
54
// XMM0-15 case (0 < offset_in_bytes < 16). No need to adjust base register (or offset).
57
address base_location = location(base_reg, nullptr);
58
if (base_location != nullptr) {
59
return base_location + offset_in_bytes;
65
address RegisterMap::pd_location(VMReg base_reg, int slot_idx) const {
66
return location(base_reg->next(slot_idx), nullptr);