/* * Copyright (c) 2017, 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. * */ #ifndef SHARE_VM_OOPS_VALUEKLASS_HPP #define SHARE_VM_OOPS_VALUEKLASS_HPP #include "oops/instanceKlass.hpp" #include "oops/method.hpp" #include "oops/oop.inline.hpp" // A ValueKlass is a specialized InstanceKlass for value types. class ValueKlass: public InstanceKlass { friend class VMStructs; friend class InstanceKlass; private: // Constructor ValueKlass(const ClassFileParser& parser) : InstanceKlass(parser, InstanceKlass::_misc_kind_value_type) { } // static Klass* array_klass_impl(InstanceKlass* this_k, bool or_null, int n, TRAPS); protected: // Returns the array class for the n'th dimension Klass* array_klass_impl(bool or_null, int n, TRAPS); // Returns the array class with this class as element type Klass* array_klass_impl(bool or_null, TRAPS); public: // Type testing bool is_value_slow() const { return true; } // Casting from Klass* static ValueKlass* cast(Klass* k) { assert(k->is_value(), "cast to ValueKlass"); return (ValueKlass*) k; } // Use this to return the size of an instance in heap words // Implementation is currently simple because all value types are allocated // in Java heap like Java objects. virtual int size_helper() const { return layout_helper_to_size_helper(layout_helper()); } // minimum number of bytes occupied by nonstatic fields, HeapWord aligned or pow2 int raw_value_byte_size() const; int first_field_offset() const; address data_for_oop(oop o) const { return ((address) (void*) o) + first_field_offset(); } oop oop_for_data(address data) const { oop o = (oop) (data - first_field_offset()); assert(o->is_oop(false), "Not an oop"); return o; } // Query if h/w provides atomic load/store bool is_atomic(); bool flatten_array(); bool contains_oops() const { return nonstatic_oop_map_count() > 0; } int nonstatic_oop_count(); // Prototype general store methods... // copy the fields, with no concern for GC barriers void raw_field_copy(void* src, void* dst, size_t raw_byte_size); void value_store(void* src, void* dst, bool dst_is_heap, bool dst_uninitialized) { value_store(src, dst, nonstatic_field_size() << LogBytesPerHeapOop, dst_is_heap, dst_uninitialized); } // store the value of this klass contained with src into dst, raw data ptr void value_store(void* src, void* dst, size_t raw_byte_size, bool dst_is_heap, bool dst_uninitialized); oop derive_value_type_copy(Handle src, InstanceKlass* target_klass, TRAPS); // GC support... // oop iterate raw value type data pointer (where oop_addr may not be an oop, but backing/array-element) template inline void oop_iterate_specialized(const address oop_addr, OopClosureType* closure); template inline void oop_iterate_specialized_bounded(const address oop_addr, OopClosureType* closure, void* lo, void* hi); // calling convention support GrowableArray collect_fields(int base_off = 0) const; GrowableArray return_convention(VMRegPair*& regs, int& nb_fields) const; void save_oop_fields(const GrowableArray& sig_vk, RegisterMap& map, const VMRegPair* regs, GrowableArray& handles, int nb_fields) const; bool save_oop_results(RegisterMap& map, GrowableArray& handles) const; void restore_oop_results(RegisterMap& map, GrowableArray& handles) const; oop realloc_result(const GrowableArray& sig_vk, const RegisterMap& reg_map, const VMRegPair* regs, const GrowableArray& handles, int nb_fields, TRAPS); static ValueKlass* returned_value_type(const RegisterMap& reg_map); }; #endif /* SHARE_VM_OOPS_VALUEKLASS_HPP */