2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2021-01-28 20:51:12 +00:00
|
|
|
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "precompiled.hpp"
|
|
|
|
#include "code/codeBlob.hpp"
|
|
|
|
#include "code/codeCache.hpp"
|
|
|
|
#include "code/nmethod.hpp"
|
|
|
|
#include "code/scopeDesc.hpp"
|
|
|
|
#include "compiler/oopMap.hpp"
|
2015-05-13 15:16:06 +02:00
|
|
|
#include "gc/shared/collectedHeap.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "memory/allocation.inline.hpp"
|
2017-10-23 11:20:53 +02:00
|
|
|
#include "memory/iterator.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "memory/resourceArea.hpp"
|
2019-05-09 14:28:30 +02:00
|
|
|
#include "memory/universe.hpp"
|
2019-05-09 14:26:03 +02:00
|
|
|
#include "oops/compressedOops.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "runtime/frame.inline.hpp"
|
2018-03-14 12:12:00 +01:00
|
|
|
#include "runtime/handles.inline.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "runtime/signature.hpp"
|
2020-10-09 08:40:33 +00:00
|
|
|
#include "runtime/stackWatermarkSet.inline.hpp"
|
2017-07-05 11:33:17 +02:00
|
|
|
#include "utilities/align.hpp"
|
2019-05-16 20:14:54 -04:00
|
|
|
#include "utilities/lockFreeStack.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#ifdef COMPILER1
|
|
|
|
#include "c1/c1_Defs.hpp"
|
|
|
|
#endif
|
2014-07-04 11:46:01 +02:00
|
|
|
#ifdef COMPILER2
|
|
|
|
#include "opto/optoreg.hpp"
|
|
|
|
#endif
|
2020-12-23 23:14:37 +00:00
|
|
|
#if INCLUDE_JVMCI
|
|
|
|
#include "jvmci/jvmci_globals.hpp"
|
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// OopMapStream
|
|
|
|
|
2019-10-09 16:35:44 -07:00
|
|
|
OopMapStream::OopMapStream(OopMap* oop_map) {
|
2015-05-05 16:50:25 +02:00
|
|
|
_stream = new CompressedReadStream(oop_map->write_stream()->buffer());
|
2007-12-01 00:00:00 +00:00
|
|
|
_size = oop_map->omv_count();
|
|
|
|
_position = 0;
|
|
|
|
_valid_omv = false;
|
|
|
|
}
|
|
|
|
|
2019-10-09 16:35:44 -07:00
|
|
|
OopMapStream::OopMapStream(const ImmutableOopMap* oop_map) {
|
2015-05-05 16:50:25 +02:00
|
|
|
_stream = new CompressedReadStream(oop_map->data_addr());
|
|
|
|
_size = oop_map->count();
|
2007-12-01 00:00:00 +00:00
|
|
|
_position = 0;
|
|
|
|
_valid_omv = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OopMapStream::find_next() {
|
2019-10-09 16:35:44 -07:00
|
|
|
if (_position++ < _size) {
|
2007-12-01 00:00:00 +00:00
|
|
|
_omv.read_from(_stream);
|
2019-10-09 16:35:44 -07:00
|
|
|
_valid_omv = true;
|
|
|
|
return;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
_valid_omv = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// OopMap
|
|
|
|
|
|
|
|
// frame_size units are stack-slots (4 bytes) NOT intptr_t; we can name odd
|
|
|
|
// slots to hold 4-byte values like ints and floats in the LP64 build.
|
|
|
|
OopMap::OopMap(int frame_size, int arg_count) {
|
|
|
|
// OopMaps are usually quite so small, so pick a small initial size
|
|
|
|
set_write_stream(new CompressedWriteStream(32));
|
|
|
|
set_omv_count(0);
|
|
|
|
|
|
|
|
#ifdef ASSERT
|
|
|
|
_locs_length = VMRegImpl::stack2reg(0)->value() + frame_size + arg_count;
|
|
|
|
_locs_used = NEW_RESOURCE_ARRAY(OopMapValue::oop_types, _locs_length);
|
|
|
|
for(int i = 0; i < _locs_length; i++) _locs_used[i] = OopMapValue::unused_value;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
OopMap::OopMap(OopMap::DeepCopyToken, OopMap* source) {
|
|
|
|
// This constructor does a deep copy
|
|
|
|
// of the source OopMap.
|
|
|
|
set_write_stream(new CompressedWriteStream(source->omv_count() * 2));
|
|
|
|
set_omv_count(0);
|
|
|
|
set_offset(source->offset());
|
|
|
|
|
|
|
|
#ifdef ASSERT
|
|
|
|
_locs_length = source->_locs_length;
|
|
|
|
_locs_used = NEW_RESOURCE_ARRAY(OopMapValue::oop_types, _locs_length);
|
|
|
|
for(int i = 0; i < _locs_length; i++) _locs_used[i] = OopMapValue::unused_value;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// We need to copy the entries too.
|
|
|
|
for (OopMapStream oms(source); !oms.is_done(); oms.next()) {
|
|
|
|
OopMapValue omv = oms.current();
|
|
|
|
omv.write_on(write_stream());
|
|
|
|
increment_count();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
OopMap* OopMap::deep_copy() {
|
|
|
|
return new OopMap(_deep_copy_token, this);
|
|
|
|
}
|
|
|
|
|
2015-05-05 16:50:25 +02:00
|
|
|
void OopMap::copy_data_to(address addr) const {
|
|
|
|
memcpy(addr, write_stream()->buffer(), write_stream()->position());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int OopMap::heap_size() const {
|
|
|
|
int size = sizeof(OopMap);
|
|
|
|
int align = sizeof(void *) - 1;
|
2015-05-05 16:50:25 +02:00
|
|
|
size += write_stream()->position();
|
2007-12-01 00:00:00 +00:00
|
|
|
// Align to a reasonable ending point
|
|
|
|
size = ((size+align) & ~align);
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
// frame_size units are stack-slots (4 bytes) NOT intptr_t; we can name odd
|
|
|
|
// slots to hold 4-byte values like ints and floats in the LP64 build.
|
|
|
|
void OopMap::set_xxx(VMReg reg, OopMapValue::oop_types x, VMReg optional) {
|
|
|
|
|
|
|
|
assert(reg->value() < _locs_length, "too big reg value for stack size");
|
|
|
|
assert( _locs_used[reg->value()] == OopMapValue::unused_value, "cannot insert twice" );
|
|
|
|
debug_only( _locs_used[reg->value()] = x; )
|
|
|
|
|
2019-10-09 16:35:44 -07:00
|
|
|
OopMapValue o(reg, x, optional);
|
2007-12-01 00:00:00 +00:00
|
|
|
o.write_on(write_stream());
|
|
|
|
increment_count();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OopMap::set_oop(VMReg reg) {
|
|
|
|
set_xxx(reg, OopMapValue::oop_value, VMRegImpl::Bad());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
void OopMap::set_narrowoop(VMReg reg) {
|
|
|
|
set_xxx(reg, OopMapValue::narrowoop_value, VMRegImpl::Bad());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OopMap::set_callee_saved(VMReg reg, VMReg caller_machine_register ) {
|
|
|
|
set_xxx(reg, OopMapValue::callee_saved_value, caller_machine_register);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OopMap::set_derived_oop(VMReg reg, VMReg derived_from_local_register ) {
|
|
|
|
if( reg == derived_from_local_register ) {
|
|
|
|
// Actually an oop, derived shares storage with base,
|
|
|
|
set_oop(reg);
|
|
|
|
} else {
|
|
|
|
set_xxx(reg, OopMapValue::derived_oop_value, derived_from_local_register);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// OopMapSet
|
|
|
|
|
2020-03-05 13:14:31 +01:00
|
|
|
OopMapSet::OopMapSet() : _list(MinOopMapAllocation) {}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
void OopMapSet::add_gc_map(int pc_offset, OopMap *map ) {
|
|
|
|
map->set_offset(pc_offset);
|
|
|
|
|
|
|
|
#ifdef ASSERT
|
2020-03-05 13:14:31 +01:00
|
|
|
if(_list.length() > 0) {
|
|
|
|
OopMap* last = _list.last();
|
2007-12-01 00:00:00 +00:00
|
|
|
if (last->offset() == map->offset() ) {
|
|
|
|
fatal("OopMap inserted twice");
|
|
|
|
}
|
2020-03-05 13:14:31 +01:00
|
|
|
if (last->offset() > map->offset()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
tty->print_cr( "WARNING, maps not sorted: pc[%d]=%d, pc[%d]=%d",
|
2020-03-05 13:14:31 +01:00
|
|
|
_list.length(),last->offset(),_list.length()+1,map->offset());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // ASSERT
|
|
|
|
|
2020-03-05 13:14:31 +01:00
|
|
|
add(map);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2020-10-09 08:40:33 +00:00
|
|
|
static void add_derived_oop(oop* base, oop* derived, OopClosure* oop_fn) {
|
2020-10-09 15:16:49 +00:00
|
|
|
#if COMPILER2_OR_JVMCI
|
2007-12-01 00:00:00 +00:00
|
|
|
DerivedPointerTable::add(derived, base);
|
2020-10-09 15:16:49 +00:00
|
|
|
#endif // COMPILER2_OR_JVMCI
|
2020-10-09 08:40:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ignore_derived_oop(oop* base, oop* derived, OopClosure* oop_fn) {
|
|
|
|
}
|
|
|
|
|
|
|
|
static void process_derived_oop(oop* base, oop* derived, OopClosure* oop_fn) {
|
|
|
|
// All derived pointers must be processed before the base pointer of any derived pointer is processed.
|
|
|
|
// Otherwise, if two derived pointers use the same base, the second derived pointer will get an obscured
|
|
|
|
// offset, if the base pointer is processed in the first derived pointer.
|
|
|
|
uintptr_t offset = cast_from_oop<uintptr_t>(*derived) - cast_from_oop<uintptr_t>(*base);
|
|
|
|
*derived = *base;
|
|
|
|
oop_fn->do_oop(derived);
|
|
|
|
*derived = cast_to_oop(cast_from_oop<uintptr_t>(*derived) + offset);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef PRODUCT
|
|
|
|
static void trace_codeblob_maps(const frame *fr, const RegisterMap *reg_map) {
|
|
|
|
// Print oopmap and regmap
|
|
|
|
tty->print_cr("------ ");
|
|
|
|
CodeBlob* cb = fr->cb();
|
2015-10-08 12:49:30 -10:00
|
|
|
const ImmutableOopMapSet* maps = cb->oop_maps();
|
2015-05-05 16:50:25 +02:00
|
|
|
const ImmutableOopMap* map = cb->oop_map_for_return_address(fr->pc());
|
2007-12-01 00:00:00 +00:00
|
|
|
map->print();
|
|
|
|
if( cb->is_nmethod() ) {
|
|
|
|
nmethod* nm = (nmethod*)cb;
|
|
|
|
// native wrappers have no scope data, it is implied
|
|
|
|
if (nm->is_native_method()) {
|
|
|
|
tty->print("bci: 0 (native)");
|
|
|
|
} else {
|
|
|
|
ScopeDesc* scope = nm->scope_desc_at(fr->pc());
|
|
|
|
tty->print("bci: %d ",scope->bci());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tty->cr();
|
|
|
|
fr->print_on(tty);
|
|
|
|
tty->print(" ");
|
|
|
|
cb->print_value_on(tty); tty->cr();
|
|
|
|
reg_map->print();
|
|
|
|
tty->print_cr("------ ");
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif // PRODUCT
|
|
|
|
|
2020-10-09 08:40:33 +00:00
|
|
|
void OopMapSet::oops_do(const frame *fr, const RegisterMap* reg_map, OopClosure* f, DerivedPointerIterationMode mode) {
|
|
|
|
switch (mode) {
|
|
|
|
case DerivedPointerIterationMode::_directly:
|
|
|
|
all_do(fr, reg_map, f, process_derived_oop, &do_nothing_cl);
|
|
|
|
break;
|
|
|
|
case DerivedPointerIterationMode::_with_table:
|
|
|
|
all_do(fr, reg_map, f, add_derived_oop, &do_nothing_cl);
|
|
|
|
break;
|
|
|
|
case DerivedPointerIterationMode::_ignore:
|
|
|
|
all_do(fr, reg_map, f, ignore_derived_oop, &do_nothing_cl);
|
|
|
|
break;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OopMapSet::all_do(const frame *fr, const RegisterMap *reg_map,
|
2020-10-09 08:40:33 +00:00
|
|
|
OopClosure* oop_fn, void derived_oop_fn(oop*, oop*, OopClosure*),
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
OopClosure* value_fn) {
|
2007-12-01 00:00:00 +00:00
|
|
|
CodeBlob* cb = fr->cb();
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
assert(cb != NULL, "no codeblob");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
NOT_PRODUCT(if (TraceCodeBlobStacks) trace_codeblob_maps(fr, reg_map);)
|
|
|
|
|
2015-05-05 16:50:25 +02:00
|
|
|
const ImmutableOopMap* map = cb->oop_map_for_return_address(fr->pc());
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
assert(map != NULL, "no ptr map found");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// handle derived pointers first (otherwise base pointer may be
|
|
|
|
// changed before derived pointer offset has been collected)
|
|
|
|
{
|
2019-10-24 22:41:24 -07:00
|
|
|
for (OopMapStream oms(map); !oms.is_done(); oms.next()) {
|
|
|
|
OopMapValue omv = oms.current();
|
|
|
|
if (omv.type() != OopMapValue::derived_oop_value) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-01-28 20:51:12 +00:00
|
|
|
#ifndef COMPILER2
|
2007-12-01 00:00:00 +00:00
|
|
|
COMPILER1_PRESENT(ShouldNotReachHere();)
|
2015-10-08 12:49:30 -10:00
|
|
|
#if INCLUDE_JVMCI
|
|
|
|
if (UseJVMCICompiler) {
|
|
|
|
ShouldNotReachHere();
|
|
|
|
}
|
|
|
|
#endif
|
2021-01-28 20:51:12 +00:00
|
|
|
#endif // !COMPILER2
|
2019-10-24 22:41:24 -07:00
|
|
|
oop* loc = fr->oopmapreg_to_location(omv.reg(),reg_map);
|
|
|
|
guarantee(loc != NULL, "missing saved register");
|
|
|
|
oop *derived_loc = loc;
|
|
|
|
oop *base_loc = fr->oopmapreg_to_location(omv.content_reg(), reg_map);
|
|
|
|
// Ignore NULL oops and decoded NULL narrow oops which
|
|
|
|
// equal to CompressedOops::base() when a narrow oop
|
|
|
|
// implicit null check is used in compiled code.
|
|
|
|
// The narrow_oop_base could be NULL or be the address
|
|
|
|
// of the page below heap depending on compressed oops mode.
|
|
|
|
if (base_loc != NULL && *base_loc != NULL && !CompressedOops::is_base(*base_loc)) {
|
2020-10-09 08:40:33 +00:00
|
|
|
derived_oop_fn(base_loc, derived_loc, oop_fn);
|
2019-10-24 22:41:24 -07:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2019-10-09 16:35:44 -07:00
|
|
|
// We want coop and oop oop_types
|
|
|
|
for (OopMapStream oms(map); !oms.is_done(); oms.next()) {
|
2019-10-24 22:41:24 -07:00
|
|
|
OopMapValue omv = oms.current();
|
2007-12-01 00:00:00 +00:00
|
|
|
oop* loc = fr->oopmapreg_to_location(omv.reg(),reg_map);
|
2015-09-15 11:04:11 -07:00
|
|
|
// It should be an error if no location can be found for a
|
|
|
|
// register mentioned as contained an oop of some kind. Maybe
|
|
|
|
// this was allowed previously because value_value items might
|
|
|
|
// be missing?
|
|
|
|
guarantee(loc != NULL, "missing saved register");
|
|
|
|
if ( omv.type() == OopMapValue::oop_value ) {
|
|
|
|
oop val = *loc;
|
2019-05-09 14:26:03 +02:00
|
|
|
if (val == NULL || CompressedOops::is_base(val)) {
|
2015-09-15 11:04:11 -07:00
|
|
|
// Ignore NULL oops and decoded NULL narrow oops which
|
2019-05-09 14:26:03 +02:00
|
|
|
// equal to CompressedOops::base() when a narrow oop
|
2015-09-15 11:04:11 -07:00
|
|
|
// implicit null check is used in compiled code.
|
|
|
|
// The narrow_oop_base could be NULL or be the address
|
|
|
|
// of the page below heap depending on compressed oops mode.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
oop_fn->do_oop(loc);
|
|
|
|
} else if ( omv.type() == OopMapValue::narrowoop_value ) {
|
|
|
|
narrowOop *nl = (narrowOop*)loc;
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
#ifndef VM_LITTLE_ENDIAN
|
2015-09-15 11:04:11 -07:00
|
|
|
VMReg vmReg = omv.reg();
|
8244224: Implementation of JEP 381: Remove the Solaris and SPARC Ports
Reviewed-by: alanb, bchristi, dcubed, dfuchs, eosterlund, erikj, glaubitz, ihse, iignatyev, jjiang, kbarrett, ksrini, kvn, naoto, prr, rriggs, serb, sspitsyn, stefank, tschatzl, valeriep, weijun, weijun
2020-05-20 17:33:37 -07:00
|
|
|
if (!vmReg->is_stack()) {
|
2015-09-15 11:04:11 -07:00
|
|
|
// compressed oops in registers only take up 4 bytes of an
|
|
|
|
// 8 byte register but they are in the wrong part of the
|
|
|
|
// word so adjust loc to point at the right place.
|
|
|
|
nl = (narrowOop*)((address)nl + 4);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2015-09-15 11:04:11 -07:00
|
|
|
#endif
|
|
|
|
oop_fn->do_oop(nl);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Update callee-saved register info for the following frame
|
|
|
|
void OopMapSet::update_register_map(const frame *fr, RegisterMap *reg_map) {
|
|
|
|
ResourceMark rm;
|
|
|
|
CodeBlob* cb = fr->cb();
|
|
|
|
assert(cb != NULL, "no codeblob");
|
|
|
|
|
|
|
|
// Any reg might be saved by a safepoint handler (see generate_handler_blob).
|
|
|
|
assert( reg_map->_update_for_id == NULL || fr->is_older(reg_map->_update_for_id),
|
|
|
|
"already updated this map; do not 'update' it twice!" );
|
|
|
|
debug_only(reg_map->_update_for_id = fr->id());
|
|
|
|
|
|
|
|
// Check if caller must update oop argument
|
|
|
|
assert((reg_map->include_argument_oops() ||
|
|
|
|
!cb->caller_must_gc_arguments(reg_map->thread())),
|
|
|
|
"include_argument_oops should already be set");
|
|
|
|
|
|
|
|
// Scan through oopmap and find location of all callee-saved registers
|
|
|
|
// (we do not do update in place, since info could be overwritten)
|
|
|
|
|
|
|
|
address pc = fr->pc();
|
2015-05-05 16:50:25 +02:00
|
|
|
const ImmutableOopMap* map = cb->oop_map_for_return_address(pc);
|
2014-04-28 16:05:12 -07:00
|
|
|
assert(map != NULL, "no ptr map found");
|
|
|
|
DEBUG_ONLY(int nof_callee = 0;)
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2019-10-09 16:35:44 -07:00
|
|
|
for (OopMapStream oms(map); !oms.is_done(); oms.next()) {
|
2014-04-28 16:05:12 -07:00
|
|
|
OopMapValue omv = oms.current();
|
2019-10-09 16:35:44 -07:00
|
|
|
if (omv.type() == OopMapValue::callee_saved_value) {
|
|
|
|
VMReg reg = omv.content_reg();
|
|
|
|
oop* loc = fr->oopmapreg_to_location(omv.reg(), reg_map);
|
|
|
|
reg_map->set_location(reg, (address) loc);
|
|
|
|
DEBUG_ONLY(nof_callee++;)
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check that runtime stubs save all callee-saved registers
|
|
|
|
#ifdef COMPILER2
|
2015-10-08 12:49:30 -10:00
|
|
|
assert(cb->is_compiled_by_c1() || cb->is_compiled_by_jvmci() || !cb->is_runtime_stub() ||
|
2007-12-01 00:00:00 +00:00
|
|
|
(nof_callee >= SAVED_ON_ENTRY_REG_COUNT || nof_callee >= C_SAVED_ON_ENTRY_REG_COUNT),
|
|
|
|
"must save all");
|
|
|
|
#endif // COMPILER2
|
|
|
|
}
|
|
|
|
|
2008-04-02 12:09:59 -07:00
|
|
|
// Printing code is present in product build for -XX:+PrintAssembly.
|
|
|
|
|
|
|
|
static
|
|
|
|
void print_register_type(OopMapValue::oop_types x, VMReg optional,
|
|
|
|
outputStream* st) {
|
2007-12-01 00:00:00 +00:00
|
|
|
switch( x ) {
|
|
|
|
case OopMapValue::oop_value:
|
2008-02-20 17:23:43 -08:00
|
|
|
st->print("Oop");
|
2007-12-01 00:00:00 +00:00
|
|
|
break;
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
case OopMapValue::narrowoop_value:
|
2013-01-22 11:31:25 -08:00
|
|
|
st->print("NarrowOop");
|
2007-12-01 00:00:00 +00:00
|
|
|
break;
|
|
|
|
case OopMapValue::callee_saved_value:
|
2013-01-22 11:31:25 -08:00
|
|
|
st->print("Callers_");
|
2008-02-20 17:23:43 -08:00
|
|
|
optional->print_on(st);
|
2007-12-01 00:00:00 +00:00
|
|
|
break;
|
|
|
|
case OopMapValue::derived_oop_value:
|
2013-01-22 11:31:25 -08:00
|
|
|
st->print("Derived_oop_");
|
2008-02-20 17:23:43 -08:00
|
|
|
optional->print_on(st);
|
2007-12-01 00:00:00 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ShouldNotReachHere();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-20 17:23:43 -08:00
|
|
|
void OopMapValue::print_on(outputStream* st) const {
|
|
|
|
reg()->print_on(st);
|
|
|
|
st->print("=");
|
|
|
|
print_register_type(type(),content_reg(),st);
|
|
|
|
st->print(" ");
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 09:05:29 -04:00
|
|
|
void OopMapValue::print() const { print_on(tty); }
|
|
|
|
|
2015-05-05 16:50:25 +02:00
|
|
|
void ImmutableOopMap::print_on(outputStream* st) const {
|
|
|
|
OopMapValue omv;
|
2019-05-21 15:51:35 +02:00
|
|
|
st->print("ImmutableOopMap {");
|
2015-05-05 16:50:25 +02:00
|
|
|
for(OopMapStream oms(this); !oms.is_done(); oms.next()) {
|
|
|
|
omv = oms.current();
|
|
|
|
omv.print_on(st);
|
|
|
|
}
|
|
|
|
st->print("}");
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2019-05-10 09:05:29 -04:00
|
|
|
void ImmutableOopMap::print() const { print_on(tty); }
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
void OopMap::print_on(outputStream* st) const {
|
|
|
|
OopMapValue omv;
|
2019-05-21 15:51:35 +02:00
|
|
|
st->print("OopMap {");
|
2007-12-01 00:00:00 +00:00
|
|
|
for(OopMapStream oms((OopMap*)this); !oms.is_done(); oms.next()) {
|
|
|
|
omv = oms.current();
|
|
|
|
omv.print_on(st);
|
|
|
|
}
|
2019-05-21 15:51:35 +02:00
|
|
|
// Print hex offset in addition.
|
|
|
|
st->print("off=%d/0x%x}", (int) offset(), (int) offset());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 09:05:29 -04:00
|
|
|
void OopMap::print() const { print_on(tty); }
|
|
|
|
|
2015-05-05 16:50:25 +02:00
|
|
|
void ImmutableOopMapSet::print_on(outputStream* st) const {
|
|
|
|
const ImmutableOopMap* last = NULL;
|
2019-05-21 15:51:35 +02:00
|
|
|
const int len = count();
|
|
|
|
|
|
|
|
st->print_cr("ImmutableOopMapSet contains %d OopMaps", len);
|
|
|
|
|
|
|
|
for (int i = 0; i < len; i++) {
|
2015-05-05 16:50:25 +02:00
|
|
|
const ImmutableOopMapPair* pair = pair_at(i);
|
|
|
|
const ImmutableOopMap* map = pair->get_from(this);
|
|
|
|
if (map != last) {
|
|
|
|
st->cr();
|
|
|
|
map->print_on(st);
|
2019-05-21 15:51:35 +02:00
|
|
|
st->print(" pc offsets: ");
|
2015-05-05 16:50:25 +02:00
|
|
|
}
|
|
|
|
last = map;
|
|
|
|
st->print("%d ", pair->pc_offset());
|
|
|
|
}
|
2019-05-21 15:51:35 +02:00
|
|
|
st->cr();
|
2015-05-05 16:50:25 +02:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2019-05-10 09:05:29 -04:00
|
|
|
void ImmutableOopMapSet::print() const { print_on(tty); }
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
void OopMapSet::print_on(outputStream* st) const {
|
2020-03-05 13:14:31 +01:00
|
|
|
const int len = _list.length();
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2019-05-21 15:51:35 +02:00
|
|
|
st->print_cr("OopMapSet contains %d OopMaps", len);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2019-05-21 15:51:35 +02:00
|
|
|
for( int i = 0; i < len; i++) {
|
2007-12-01 00:00:00 +00:00
|
|
|
OopMap* m = at(i);
|
2008-04-02 12:09:59 -07:00
|
|
|
st->print_cr("#%d ",i);
|
2007-12-01 00:00:00 +00:00
|
|
|
m->print_on(st);
|
2008-04-02 12:09:59 -07:00
|
|
|
st->cr();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2019-05-21 15:51:35 +02:00
|
|
|
st->cr();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2008-04-02 12:09:59 -07:00
|
|
|
|
2019-05-10 09:05:29 -04:00
|
|
|
void OopMapSet::print() const { print_on(tty); }
|
|
|
|
|
2015-05-05 16:50:25 +02:00
|
|
|
bool OopMap::equals(const OopMap* other) const {
|
|
|
|
if (other->_omv_count != _omv_count) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (other->write_stream()->position() != write_stream()->position()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (memcmp(other->write_stream()->buffer(), write_stream()->buffer(), write_stream()->position()) != 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
const ImmutableOopMap* ImmutableOopMapSet::find_map_at_offset(int pc_offset) const {
|
|
|
|
ImmutableOopMapPair* pairs = get_pairs();
|
2019-05-21 15:51:35 +02:00
|
|
|
ImmutableOopMapPair* last = NULL;
|
2015-05-05 16:50:25 +02:00
|
|
|
|
2019-05-21 15:51:35 +02:00
|
|
|
for (int i = 0; i < _count; ++i) {
|
2015-05-05 16:50:25 +02:00
|
|
|
if (pairs[i].pc_offset() >= pc_offset) {
|
2019-05-21 15:51:35 +02:00
|
|
|
last = &pairs[i];
|
2015-05-05 16:50:25 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-21 15:51:35 +02:00
|
|
|
// Heal Coverity issue: potential index out of bounds access.
|
|
|
|
guarantee(last != NULL, "last may not be null");
|
2015-05-05 16:50:25 +02:00
|
|
|
assert(last->pc_offset() == pc_offset, "oopmap not found");
|
|
|
|
return last->get_from(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
const ImmutableOopMap* ImmutableOopMapPair::get_from(const ImmutableOopMapSet* set) const {
|
|
|
|
return set->oopmap_at_offset(_oopmap_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
ImmutableOopMap::ImmutableOopMap(const OopMap* oopmap) : _count(oopmap->count()) {
|
|
|
|
address addr = data_addr();
|
|
|
|
oopmap->copy_data_to(addr);
|
|
|
|
}
|
|
|
|
|
2015-05-21 18:10:18 +02:00
|
|
|
#ifdef ASSERT
|
|
|
|
int ImmutableOopMap::nr_of_bytes() const {
|
|
|
|
OopMapStream oms(this);
|
|
|
|
|
|
|
|
while (!oms.is_done()) {
|
|
|
|
oms.next();
|
|
|
|
}
|
|
|
|
return sizeof(ImmutableOopMap) + oms.stream_position();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-08-08 15:31:06 +02:00
|
|
|
ImmutableOopMapBuilder::ImmutableOopMapBuilder(const OopMapSet* set) : _set(set), _empty(NULL), _last(NULL), _empty_offset(-1), _last_offset(-1), _offset(0), _required(-1), _new_set(NULL) {
|
2015-10-08 12:49:30 -10:00
|
|
|
_mapping = NEW_RESOURCE_ARRAY(Mapping, _set->size());
|
|
|
|
}
|
2015-05-05 16:50:25 +02:00
|
|
|
|
|
|
|
int ImmutableOopMapBuilder::size_for(const OopMap* map) const {
|
2017-07-04 15:58:10 +02:00
|
|
|
return align_up((int)sizeof(ImmutableOopMap) + map->data_size(), 8);
|
2015-05-05 16:50:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int ImmutableOopMapBuilder::heap_size() {
|
|
|
|
int base = sizeof(ImmutableOopMapSet);
|
2017-07-04 15:58:10 +02:00
|
|
|
base = align_up(base, 8);
|
2015-05-05 16:50:25 +02:00
|
|
|
|
|
|
|
// all of ours pc / offset pairs
|
|
|
|
int pairs = _set->size() * sizeof(ImmutableOopMapPair);
|
2017-07-04 15:58:10 +02:00
|
|
|
pairs = align_up(pairs, 8);
|
2015-05-05 16:50:25 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < _set->size(); ++i) {
|
|
|
|
int size = 0;
|
|
|
|
OopMap* map = _set->at(i);
|
|
|
|
|
|
|
|
if (is_empty(map)) {
|
|
|
|
/* only keep a single empty map in the set */
|
|
|
|
if (has_empty()) {
|
|
|
|
_mapping[i].set(Mapping::OOPMAP_EMPTY, _empty_offset, 0, map, _empty);
|
|
|
|
} else {
|
|
|
|
_empty_offset = _offset;
|
|
|
|
_empty = map;
|
|
|
|
size = size_for(map);
|
|
|
|
_mapping[i].set(Mapping::OOPMAP_NEW, _offset, size, map);
|
|
|
|
}
|
|
|
|
} else if (is_last_duplicate(map)) {
|
|
|
|
/* if this entry is identical to the previous one, just point it there */
|
|
|
|
_mapping[i].set(Mapping::OOPMAP_DUPLICATE, _last_offset, 0, map, _last);
|
|
|
|
} else {
|
|
|
|
/* not empty, not an identical copy of the previous entry */
|
|
|
|
size = size_for(map);
|
|
|
|
_mapping[i].set(Mapping::OOPMAP_NEW, _offset, size, map);
|
|
|
|
_last_offset = _offset;
|
|
|
|
_last = map;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(_mapping[i]._map == map, "check");
|
|
|
|
_offset += size;
|
|
|
|
}
|
|
|
|
|
|
|
|
int total = base + pairs + _offset;
|
|
|
|
DEBUG_ONLY(total += 8);
|
2015-10-08 12:49:30 -10:00
|
|
|
_required = total;
|
2015-05-05 16:50:25 +02:00
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
2015-05-21 18:10:18 +02:00
|
|
|
void ImmutableOopMapBuilder::fill_pair(ImmutableOopMapPair* pair, const OopMap* map, int offset, const ImmutableOopMapSet* set) {
|
|
|
|
assert(offset < set->nr_of_bytes(), "check");
|
2015-05-05 16:50:25 +02:00
|
|
|
new ((address) pair) ImmutableOopMapPair(map->offset(), offset);
|
|
|
|
}
|
|
|
|
|
2015-05-21 18:10:18 +02:00
|
|
|
int ImmutableOopMapBuilder::fill_map(ImmutableOopMapPair* pair, const OopMap* map, int offset, const ImmutableOopMapSet* set) {
|
|
|
|
fill_pair(pair, map, offset, set);
|
2015-05-05 16:50:25 +02:00
|
|
|
address addr = (address) pair->get_from(_new_set); // location of the ImmutableOopMap
|
|
|
|
|
|
|
|
new (addr) ImmutableOopMap(map);
|
2017-04-12 17:53:18 +02:00
|
|
|
return size_for(map);
|
2015-05-05 16:50:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ImmutableOopMapBuilder::fill(ImmutableOopMapSet* set, int sz) {
|
|
|
|
ImmutableOopMapPair* pairs = set->get_pairs();
|
|
|
|
|
|
|
|
for (int i = 0; i < set->count(); ++i) {
|
|
|
|
const OopMap* map = _mapping[i]._map;
|
|
|
|
ImmutableOopMapPair* pair = NULL;
|
|
|
|
int size = 0;
|
|
|
|
|
|
|
|
if (_mapping[i]._kind == Mapping::OOPMAP_NEW) {
|
2015-05-21 18:10:18 +02:00
|
|
|
size = fill_map(&pairs[i], map, _mapping[i]._offset, set);
|
2015-05-05 16:50:25 +02:00
|
|
|
} else if (_mapping[i]._kind == Mapping::OOPMAP_DUPLICATE || _mapping[i]._kind == Mapping::OOPMAP_EMPTY) {
|
2015-05-21 18:10:18 +02:00
|
|
|
fill_pair(&pairs[i], map, _mapping[i]._offset, set);
|
2015-05-05 16:50:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const ImmutableOopMap* nv = set->find_map_at_offset(map->offset());
|
|
|
|
assert(memcmp(map->data(), nv->data_addr(), map->data_size()) == 0, "check identity");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ASSERT
|
2015-05-21 18:10:18 +02:00
|
|
|
void ImmutableOopMapBuilder::verify(address buffer, int size, const ImmutableOopMapSet* set) {
|
2015-05-05 16:50:25 +02:00
|
|
|
for (int i = 0; i < 8; ++i) {
|
|
|
|
assert(buffer[size - 8 + i] == (unsigned char) 0xff, "overwritten memory check");
|
|
|
|
}
|
2015-05-21 18:10:18 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < set->count(); ++i) {
|
|
|
|
const ImmutableOopMapPair* pair = set->pair_at(i);
|
|
|
|
assert(pair->oopmap_offset() < set->nr_of_bytes(), "check size");
|
|
|
|
const ImmutableOopMap* map = pair->get_from(set);
|
|
|
|
int nr_of_bytes = map->nr_of_bytes();
|
|
|
|
assert(pair->oopmap_offset() + nr_of_bytes <= set->nr_of_bytes(), "check size + size");
|
|
|
|
}
|
2015-05-05 16:50:25 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-10-08 12:49:30 -10:00
|
|
|
ImmutableOopMapSet* ImmutableOopMapBuilder::generate_into(address buffer) {
|
|
|
|
DEBUG_ONLY(memset(&buffer[_required-8], 0xff, 8));
|
2015-05-05 16:50:25 +02:00
|
|
|
|
2015-10-08 12:49:30 -10:00
|
|
|
_new_set = new (buffer) ImmutableOopMapSet(_set, _required);
|
|
|
|
fill(_new_set, _required);
|
2015-05-05 16:50:25 +02:00
|
|
|
|
2015-10-08 12:49:30 -10:00
|
|
|
DEBUG_ONLY(verify(buffer, _required, _new_set));
|
2015-05-05 16:50:25 +02:00
|
|
|
|
|
|
|
return _new_set;
|
|
|
|
}
|
|
|
|
|
2015-10-08 12:49:30 -10:00
|
|
|
ImmutableOopMapSet* ImmutableOopMapBuilder::build() {
|
|
|
|
_required = heap_size();
|
|
|
|
|
|
|
|
// We need to allocate a chunk big enough to hold the ImmutableOopMapSet and all of its ImmutableOopMaps
|
2019-09-11 14:16:27 +02:00
|
|
|
address buffer = NEW_C_HEAP_ARRAY(unsigned char, _required, mtCode);
|
2015-10-08 12:49:30 -10:00
|
|
|
return generate_into(buffer);
|
|
|
|
}
|
|
|
|
|
2015-05-05 16:50:25 +02:00
|
|
|
ImmutableOopMapSet* ImmutableOopMapSet::build_from(const OopMapSet* oopmap_set) {
|
|
|
|
ResourceMark mark;
|
|
|
|
ImmutableOopMapBuilder builder(oopmap_set);
|
|
|
|
return builder.build();
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
//------------------------------DerivedPointerTable---------------------------
|
|
|
|
|
2017-11-06 21:28:03 -08:00
|
|
|
#if COMPILER2_OR_JVMCI
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2019-05-16 20:14:54 -04:00
|
|
|
class DerivedPointerTable::Entry : public CHeapObj<mtCompiler> {
|
|
|
|
oop* _location; // Location of derived pointer, also pointing to base
|
|
|
|
intptr_t _offset; // Offset from base pointer
|
|
|
|
Entry* volatile _next;
|
|
|
|
|
|
|
|
static Entry* volatile* next_ptr(Entry& entry) { return &entry._next; }
|
|
|
|
|
|
|
|
public:
|
|
|
|
Entry(oop* location, intptr_t offset) :
|
|
|
|
_location(location), _offset(offset), _next(NULL) {}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2019-05-16 20:14:54 -04:00
|
|
|
oop* location() const { return _location; }
|
|
|
|
intptr_t offset() const { return _offset; }
|
|
|
|
Entry* next() const { return _next; }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2019-05-16 20:14:54 -04:00
|
|
|
typedef LockFreeStack<Entry, &next_ptr> List;
|
|
|
|
static List* _list;
|
|
|
|
};
|
|
|
|
|
|
|
|
DerivedPointerTable::Entry::List* DerivedPointerTable::Entry::_list = NULL;
|
2007-12-01 00:00:00 +00:00
|
|
|
bool DerivedPointerTable::_active = false;
|
|
|
|
|
2019-05-16 20:14:54 -04:00
|
|
|
bool DerivedPointerTable::is_empty() {
|
|
|
|
return Entry::_list == NULL || Entry::_list->empty();
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
void DerivedPointerTable::clear() {
|
|
|
|
// The first time, we create the list. Otherwise it should be
|
|
|
|
// empty. If not, then we have probably forgotton to call
|
|
|
|
// update_pointers after last GC/Scavenge.
|
|
|
|
assert (!_active, "should not be active");
|
2019-05-16 20:14:54 -04:00
|
|
|
assert(is_empty(), "table not empty");
|
|
|
|
if (Entry::_list == NULL) {
|
|
|
|
void* mem = NEW_C_HEAP_OBJ(Entry::List, mtCompiler);
|
|
|
|
Entry::_list = ::new (mem) Entry::List();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
_active = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns value of location as an int
|
2019-05-16 20:14:54 -04:00
|
|
|
inline intptr_t value_of_loc(oop *pointer) {
|
|
|
|
return cast_from_oop<intptr_t>((*pointer));
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
void DerivedPointerTable::add(oop *derived_loc, oop *base_loc) {
|
|
|
|
assert(Universe::heap()->is_in_or_null(*base_loc), "not an oop");
|
|
|
|
assert(derived_loc != base_loc, "Base and derived in same location");
|
2020-10-09 08:40:33 +00:00
|
|
|
assert(*derived_loc != (void*)base_loc, "location already added");
|
|
|
|
assert(Entry::_list != NULL, "list must exist");
|
|
|
|
assert(is_active(), "table must be active here");
|
|
|
|
intptr_t offset = value_of_loc(derived_loc) - value_of_loc(base_loc);
|
|
|
|
// This assert is invalid because derived pointers can be
|
|
|
|
// arbitrarily far away from their base.
|
|
|
|
// assert(offset >= -1000000, "wrong derived pointer info");
|
|
|
|
|
|
|
|
if (TraceDerivedPointers) {
|
|
|
|
tty->print_cr(
|
|
|
|
"Add derived pointer@" INTPTR_FORMAT
|
|
|
|
" - Derived: " INTPTR_FORMAT
|
|
|
|
" Base: " INTPTR_FORMAT " (@" INTPTR_FORMAT ") (Offset: " INTX_FORMAT ")",
|
|
|
|
p2i(derived_loc), p2i(*derived_loc), p2i(*base_loc), p2i(base_loc), offset
|
|
|
|
);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2020-10-09 08:40:33 +00:00
|
|
|
// Set derived oop location to point to base.
|
|
|
|
*derived_loc = (oop)base_loc;
|
|
|
|
Entry* entry = new Entry(derived_loc, offset);
|
|
|
|
Entry::_list->push(*entry);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DerivedPointerTable::update_pointers() {
|
2019-05-16 20:14:54 -04:00
|
|
|
assert(Entry::_list != NULL, "list must exist");
|
|
|
|
Entry* entries = Entry::_list->pop_all();
|
|
|
|
while (entries != NULL) {
|
|
|
|
Entry* entry = entries;
|
|
|
|
entries = entry->next();
|
2007-12-01 00:00:00 +00:00
|
|
|
oop* derived_loc = entry->location();
|
|
|
|
intptr_t offset = entry->offset();
|
|
|
|
// The derived oop was setup to point to location of base
|
2019-05-16 20:14:54 -04:00
|
|
|
oop base = **(oop**)derived_loc;
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(Universe::heap()->is_in_or_null(base), "must be an oop");
|
|
|
|
|
2020-01-24 09:27:07 +01:00
|
|
|
*derived_loc = (oop)(cast_from_oop<address>(base) + offset);
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(value_of_loc(derived_loc) - value_of_loc(&base) == offset, "sanity check");
|
|
|
|
|
|
|
|
if (TraceDerivedPointers) {
|
|
|
|
tty->print_cr("Updating derived pointer@" INTPTR_FORMAT
|
2014-05-09 16:50:54 -04:00
|
|
|
" - Derived: " INTPTR_FORMAT " Base: " INTPTR_FORMAT " (Offset: " INTX_FORMAT ")",
|
2020-01-24 09:27:07 +01:00
|
|
|
p2i(derived_loc), p2i(*derived_loc), p2i(base), offset);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Delete entry
|
|
|
|
delete entry;
|
|
|
|
}
|
2019-05-16 20:14:54 -04:00
|
|
|
assert(Entry::_list->empty(), "invariant");
|
2007-12-01 00:00:00 +00:00
|
|
|
_active = false;
|
|
|
|
}
|
|
|
|
|
2017-11-06 21:28:03 -08:00
|
|
|
#endif // COMPILER2_OR_JVMCI
|