2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2019-01-10 15:13:51 -05:00
|
|
|
* Copyright (c) 2005, 2019, 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
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-01-10 15:13:51 -05:00
|
|
|
#ifndef SHARE_PRIMS_JVMTICLASSFILERECONSTITUTER_HPP
|
|
|
|
#define SHARE_PRIMS_JVMTICLASSFILERECONSTITUTER_HPP
|
2010-11-23 13:22:55 -08:00
|
|
|
|
|
|
|
#include "jvmtifiles/jvmtiEnv.hpp"
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
class JvmtiConstantPoolReconstituter : public StackObj {
|
|
|
|
private:
|
|
|
|
int _cpool_size;
|
|
|
|
SymbolHashMap* _symmap;
|
|
|
|
SymbolHashMap* _classmap;
|
|
|
|
constantPoolHandle _cpool;
|
2017-03-15 10:25:37 -04:00
|
|
|
InstanceKlass* _ik;
|
2007-12-01 00:00:00 +00:00
|
|
|
jvmtiError _err;
|
|
|
|
|
|
|
|
protected:
|
2017-03-15 10:25:37 -04:00
|
|
|
InstanceKlass* ik() { return _ik; };
|
2007-12-01 00:00:00 +00:00
|
|
|
constantPoolHandle cpool() { return _cpool; };
|
|
|
|
|
2011-01-27 16:11:27 -08:00
|
|
|
u2 symbol_to_cpool_index(Symbol* sym) {
|
2007-12-01 00:00:00 +00:00
|
|
|
return _symmap->symbol_to_value(sym);
|
|
|
|
}
|
|
|
|
|
2011-01-27 16:11:27 -08:00
|
|
|
u2 class_symbol_to_cpool_index(Symbol* sym) {
|
2007-12-01 00:00:00 +00:00
|
|
|
return _classmap->symbol_to_value(sym);
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
// Calls to this constructor must be proceeded by a ResourceMark
|
|
|
|
// and a HandleMark
|
2018-03-16 09:12:13 -04:00
|
|
|
JvmtiConstantPoolReconstituter(InstanceKlass* ik);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
~JvmtiConstantPoolReconstituter() {
|
|
|
|
if (_symmap != NULL) {
|
2015-01-16 21:28:02 +00:00
|
|
|
delete _symmap;
|
2007-12-01 00:00:00 +00:00
|
|
|
_symmap = NULL;
|
|
|
|
}
|
|
|
|
if (_classmap != NULL) {
|
2015-01-16 21:28:02 +00:00
|
|
|
delete _classmap;
|
2007-12-01 00:00:00 +00:00
|
|
|
_classmap = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void set_error(jvmtiError err) { _err = err; }
|
|
|
|
jvmtiError get_error() { return _err; }
|
|
|
|
|
|
|
|
int cpool_size() { return _cpool_size; }
|
|
|
|
|
|
|
|
void copy_cpool_bytes(unsigned char *cpool_bytes) {
|
|
|
|
if (cpool_bytes == NULL) {
|
|
|
|
assert(cpool_bytes != NULL, "cpool_bytes pointer must not be NULL");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cpool()->copy_cpool_bytes(cpool_size(), _symmap, cpool_bytes);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class JvmtiClassFileReconstituter : public JvmtiConstantPoolReconstituter {
|
|
|
|
private:
|
|
|
|
size_t _buffer_size;
|
|
|
|
u1* _buffer;
|
|
|
|
u1* _buffer_ptr;
|
|
|
|
Thread* _thread;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
// initial size should be power of two
|
|
|
|
initial_buffer_size = 1024
|
|
|
|
};
|
|
|
|
|
|
|
|
inline Thread* thread() { return _thread; }
|
|
|
|
|
|
|
|
void write_class_file_format();
|
|
|
|
void write_field_infos();
|
|
|
|
void write_method_infos();
|
2015-10-23 16:48:38 -04:00
|
|
|
void write_method_info(const methodHandle& method);
|
|
|
|
void write_code_attribute(const methodHandle& method);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void write_exceptions_attribute(ConstMethod* const_method);
|
2007-12-01 00:00:00 +00:00
|
|
|
void write_synthetic_attribute();
|
|
|
|
void write_class_attributes();
|
|
|
|
void write_source_file_attribute();
|
|
|
|
void write_source_debug_extension_attribute();
|
2015-10-23 16:48:38 -04:00
|
|
|
u2 line_number_table_entries(const methodHandle& method);
|
|
|
|
void write_line_number_table_attribute(const methodHandle& method, u2 num_entries);
|
|
|
|
void write_local_variable_table_attribute(const methodHandle& method, u2 num_entries);
|
|
|
|
void write_local_variable_type_table_attribute(const methodHandle& method, u2 num_entries);
|
|
|
|
void write_stackmap_table_attribute(const methodHandle& method, int stackmap_table_len);
|
2007-12-01 00:00:00 +00:00
|
|
|
u2 inner_classes_attribute_length();
|
|
|
|
void write_inner_classes_attribute(int length);
|
|
|
|
void write_signature_attribute(u2 generic_signaure_index);
|
|
|
|
void write_attribute_name_index(const char* name);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void write_annotations_attribute(const char* attr_name, AnnotationArray* annos);
|
2013-05-07 14:04:26 +02:00
|
|
|
void write_bootstrapmethod_attribute();
|
2018-06-23 01:32:41 -04:00
|
|
|
void write_nest_host_attribute();
|
|
|
|
void write_nest_members_attribute();
|
8225054: Compiler implementation for records
8225052: javax.lang.model support for records
8225053: Preview APIs support for records
8225055: Javadoc for records
8226314: com.sun.source support for records
8227113: Specification for java.lang.Record
8233526: JVM support for records
Implement records in the compiler and the JVM, including serialization, reflection and APIs support
Co-authored-by: Brian Goetz <brian.goetz@oracle.com>
Co-authored-by: Maurizio Cimadamore <maurizio.cimadamore@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Joe Darcy <joe.darcy@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Chris Hegarty <chris.hegarty@oracle.com>
Co-authored-by: Jan Lahoda <jan.lahoda@oracle.com>
Reviewed-by: mcimadamore, briangoetz, alanb, darcy, chegar, jrose, jlahoda, coleenp, dholmes, lfoltan, mchung, sadayapalam, hannesw, sspitsyn
2019-12-04 15:57:39 -05:00
|
|
|
void write_record_attribute();
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
address writeable_address(size_t size);
|
|
|
|
void write_u1(u1 x);
|
|
|
|
void write_u2(u2 x);
|
|
|
|
void write_u4(u4 x);
|
|
|
|
void write_u8(u8 x);
|
|
|
|
|
|
|
|
public:
|
|
|
|
// Calls to this constructor must be proceeded by a ResourceMark
|
|
|
|
// and a HandleMark
|
2017-03-15 10:25:37 -04:00
|
|
|
JvmtiClassFileReconstituter(InstanceKlass* ik) :
|
|
|
|
JvmtiConstantPoolReconstituter(ik) {
|
2007-12-01 00:00:00 +00:00
|
|
|
_buffer_size = initial_buffer_size;
|
|
|
|
_buffer = _buffer_ptr = NEW_RESOURCE_ARRAY(u1, _buffer_size);
|
|
|
|
_thread = Thread::current();
|
|
|
|
write_class_file_format();
|
|
|
|
};
|
|
|
|
|
|
|
|
size_t class_file_size() { return _buffer_ptr - _buffer; }
|
|
|
|
|
|
|
|
u1* class_file_bytes() { return _buffer; }
|
|
|
|
|
2015-10-23 16:48:38 -04:00
|
|
|
static void copy_bytecodes(const methodHandle& method, unsigned char* bytecodes);
|
2007-12-01 00:00:00 +00:00
|
|
|
};
|
2010-11-23 13:22:55 -08:00
|
|
|
|
2019-01-10 15:13:51 -05:00
|
|
|
#endif // SHARE_PRIMS_JVMTICLASSFILERECONSTITUTER_HPP
|