Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/code/location.hpp
32285 views
/*1* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_CODE_LOCATION_HPP25#define SHARE_VM_CODE_LOCATION_HPP2627#include "asm/assembler.hpp"28#include "code/vmreg.hpp"29#include "memory/allocation.hpp"3031// A Location describes a concrete machine variable location32// (such as integer or floating point register or a stack-held33// variable). Used when generating debug-information for nmethods.34//35// Encoding:36//37// bits (use low bits for best compression):38// Type: [3..0]39// Where: [4]40// Offset: [31..5]4142class Location VALUE_OBJ_CLASS_SPEC {43friend class VMStructs;44public:45enum Where {46on_stack,47in_register48};4950enum Type {51invalid, // Invalid location52normal, // Ints, floats, double halves53oop, // Oop (please GC me!)54int_in_long, // Integer held in long register55lng, // Long held in one register56float_in_dbl, // Float held in double register57dbl, // Double held in one register58addr, // JSR return address59narrowoop // Narrow Oop (please GC me!)60};616263private:64enum {65TYPE_MASK = (juint) 0x0F,66TYPE_SHIFT = 0,67WHERE_MASK = (juint) 0x10,68WHERE_SHIFT = 4,69OFFSET_MASK = (juint) 0xFFFFFFE0,70OFFSET_SHIFT = 571};7273juint _value;7475// Create a bit-packed Location76Location(Where where_, Type type_, unsigned offset_) {77set(where_, type_, offset_);78assert( where () == where_ , "" );79assert( type () == type_ , "" );80assert( offset() == offset_, "" );81}8283inline void set(Where where_, Type type_, unsigned offset_) {84_value = (juint) ((where_ << WHERE_SHIFT) |85(type_ << TYPE_SHIFT) |86((offset_ << OFFSET_SHIFT) & OFFSET_MASK));87}8889public:9091// Stack location Factory. Offset is 4-byte aligned; remove low bits92static Location new_stk_loc( Type t, int offset ) { return Location(on_stack,t,offset>>LogBytesPerInt); }93// Register location Factory94static Location new_reg_loc( Type t, VMReg reg ) { return Location(in_register, t, reg->value()); }95// Default constructor96Location() { set(on_stack,invalid,0); }9798// Bit field accessors99Where where() const { return (Where) ((_value & WHERE_MASK) >> WHERE_SHIFT);}100Type type() const { return (Type) ((_value & TYPE_MASK) >> TYPE_SHIFT); }101unsigned offset() const { return (unsigned) ((_value & OFFSET_MASK) >> OFFSET_SHIFT); }102103// Accessors104bool is_register() const { return where() == in_register; }105bool is_stack() const { return where() == on_stack; }106107int stack_offset() const { assert(where() == on_stack, "wrong Where"); return offset()<<LogBytesPerInt; }108int register_number() const { assert(where() == in_register, "wrong Where"); return offset() ; }109110VMReg reg() const { assert(where() == in_register, "wrong Where"); return VMRegImpl::as_VMReg(offset()) ; }111112// Printing113void print_on(outputStream* st) const;114115// Serialization of debugging information116Location(DebugInfoReadStream* stream);117void write_on(DebugInfoWriteStream* stream);118119// check120static bool legal_offset_in_bytes(int offset_in_bytes);121};122123#endif // SHARE_VM_CODE_LOCATION_HPP124125126