/* * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. * 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. * * 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. *
*/
// Recording and retrieval of either oop relocations or metadata in compiled code.
class CodeBlob;
template <class T> class ValueRecorder : public StackObj { public: // A two-way mapping from positive indexes to oop handles. // The zero index is reserved for a constant (shareable) null. // Indexes may not be negative.
// Use the given arena to manage storage, if not NULL. // By default, uses the current ResourceArea.
ValueRecorder(Arena* arena = NULL);
// Generate a new index on which nmethod::oop_addr_at will work. // allocate_index and find_index never return the same index, // and allocate_index never returns the same index twice. // In fact, two successive calls to allocate_index return successive ints. int allocate_index(T h) { return add_handle(h, false);
}
// For a given jobject or Metadata*, this will return the same index // repeatedly. The index can later be given to nmethod::oop_at or // metadata_at to retrieve the oop. // However, the oop must not be changed via nmethod::oop_addr_at. int find_index(T h) { int index = maybe_find_index(h); if (index < 0) { // previously unallocated
index = add_handle(h, true);
} return index;
}
// returns the size of the generated oop/metadata table, for sizing the // CodeBlob. Must be called after all oops are allocated! int size();
// Retrieve the value at a given index.
T at(int index);
int count() { if (_handles == NULL) return 0; // there is always a NULL virtually present as first object return _handles->length() + first_index;
}
// Helper function; returns false for NULL or Universe::non_oop_word(). inlinebool is_real(T h);
// copy the generated table to nmethod void copy_values_to(nmethod* nm);
GrowableArray<T>* _handles; // ordered list (first is always NULL)
GrowableArray<int>* _no_finds; // all unfindable indexes; usually empty
IndexCache<T>* _indexes; // map: handle -> its probable index
Arena* _arena; bool _complete;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.