Skip to content
Permalink
Browse files
8244810: [lworld] Decommission arrayStorageProperties from Klass:arra…
…y_klass() et el
  • Loading branch information
David Simms committed May 14, 2020
1 parent f87a1b4 commit 2e5a9581372fe6366a45b0c300acba85dc967b09
@@ -1094,7 +1094,7 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* thread, Runtime1::StubID stub_i
{ Bytecode_anewarray anew(caller_method(), caller_method->bcp_from(bci));
Klass* ek = caller_method->constants()->klass_at(anew.index(), CHECK);
if (ek->is_value() && caller_method->constants()->klass_at_noresolve(anew.index())->is_Q_signature()) {
k = ek->array_klass(ArrayStorageProperties::flattened_and_null_free, 1, CHECK);
k = ek->array_klass(1, CHECK);
assert(ArrayKlass::cast(k)->storage_properties().is_null_free(), "Expect a null-free array class here");
} else {
k = ek->array_klass(CHECK);
@@ -138,10 +138,8 @@ ciObjArrayKlass* ciObjArrayKlass::make_impl(ciKlass* element_klass, bool never_n
if (element_klass->is_loaded()) {
EXCEPTION_CONTEXT;
// The element klass is loaded
ArrayStorageProperties props = never_null ? ArrayStorageProperties::flattened_and_null_free : ArrayStorageProperties::empty;
Klass* array = element_klass->get_Klass()->array_klass(props, THREAD);
Klass* array = element_klass->get_Klass()->array_klass(THREAD);
if (element_klass->is_valuetype()) {
assert(!ObjArrayKlass::cast(array)->storage_properties().is_flattened(), "should not be flattened");
assert(ObjArrayKlass::cast(array)->storage_properties().is_null_free() == never_null, "wrong nullability storage property");
}
if (HAS_PENDING_EXCEPTION) {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2020, 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
@@ -133,8 +133,7 @@ ciValueArrayKlass* ciValueArrayKlass::make_impl(ciKlass* element_klass) {
{
EXCEPTION_CONTEXT;
// The element klass is loaded
Klass* array = element_klass->get_Klass()->array_klass(ArrayStorageProperties::flattened_and_null_free, 1, THREAD);
assert(ValueArrayKlass::cast(array)->storage_properties().is_flattened(), "should be flattened");
Klass* array = element_klass->get_Klass()->array_klass(1, THREAD);
assert(ValueArrayKlass::cast(array)->storage_properties().is_null_free(), "should be null free");
if (HAS_PENDING_EXCEPTION) {
CLEAR_PENDING_EXCEPTION;
@@ -289,11 +289,11 @@ Klass* SystemDictionary::resolve_array_class_or_null(Symbol* class_name,
protection_domain,
CHECK_NULL);
if (k != NULL) {
k = k->array_klass(ArrayStorageProperties::for_signature(class_name), ndims, CHECK_NULL);
k = k->array_klass(ndims, CHECK_NULL);
}
} else {
k = Universe::typeArrayKlassObj(t);
k = TypeArrayKlass::cast(k)->array_klass(ArrayStorageProperties::empty, ndims, CHECK_NULL);
k = TypeArrayKlass::cast(k)->array_klass(ndims, CHECK_NULL);
}
return k;
}
@@ -1019,7 +1019,7 @@ Klass* SystemDictionary::find_instance_or_array_klass(Symbol* class_name,
k = SystemDictionary::find(ss.as_symbol(), class_loader, protection_domain, THREAD);
}
if (k != NULL) {
k = k->array_klass_or_null(ArrayStorageProperties::for_signature(class_name), ndims);
k = k->array_klass_or_null(ndims);
}
} else {
k = find(class_name, class_loader, protection_domain, THREAD);
@@ -2283,7 +2283,7 @@ Klass* SystemDictionary::find_constrained_instance_or_array_klass(
}
// If element class already loaded, allocate array klass
if (klass != NULL) {
klass = klass->array_klass_or_null(ArrayStorageProperties::for_signature(class_name), ndims);
klass = klass->array_klass_or_null(ndims);
}
} else {
MutexLocker mu(THREAD, SystemDictionary_lock);
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, 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
@@ -136,7 +136,7 @@ objArrayOop oopFactory::new_objArray(Klass* klass, int length, TRAPS) {
arrayOop oopFactory::new_valueArray(Klass* klass, int length, TRAPS) {
assert(klass->is_value(), "Klass must be value type");
// Request flattened, but we might not actually get it...either way "null-free" are the aaload/aastore semantics
Klass* array_klass = klass->array_klass(ArrayStorageProperties::flattened_and_null_free, 1, CHECK_NULL);
Klass* array_klass = klass->array_klass(1, CHECK_NULL);
assert(ArrayKlass::cast(array_klass)->storage_properties().is_null_free(), "Expect a null-free array class here");

arrayOop oop;
@@ -152,10 +152,10 @@ arrayOop oopFactory::new_valueArray(Klass* klass, int length, TRAPS) {
objArrayHandle oopFactory::copy_valueArray_to_objArray(valueArrayHandle array, TRAPS) {
int len = array->length();
ValueArrayKlass* vak = ValueArrayKlass::cast(array->klass());
objArrayHandle oarray = new_objArray_handle(vak->element_klass(),
array->length(), CHECK_(objArrayHandle()));
vak->copy_array(array(), 0, oarray(), 0, len, CHECK_(objArrayHandle()));
return oarray;
objArrayOop oarray = new_objectArray(array->length(), CHECK_(objArrayHandle()));
objArrayHandle oarrayh(THREAD, oarray);
vak->copy_array(array(), 0, oarrayh(), 0, len, CHECK_(objArrayHandle()));
return oarrayh;
}

objArrayHandle oopFactory::ensure_objArray(oop array, TRAPS) {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, 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
@@ -60,10 +60,10 @@ class oopFactory: AllStatic {
// Value arrays...
// LWorld:
// - Q-type signature allocation should use this path.
// - L-type signature allocation should use new_objArray (even with value type elements)
// - L-type signature allocation should use new_objArray
//
// Method specifically creates ArrayStorageProperties::null_free and possibly flattened if possible
// i.e. valueArrayOop if flattening can be done, else objArrayOop with "null free" storage properties
// Method specifically null free and possibly flattened if possible
// i.e. valueArrayOop if flattening can be done, else "null free" objArrayOop
static arrayOop new_valueArray(Klass* klass, int length, TRAPS);

// Helper conversions from value to obj array...
@@ -99,8 +99,9 @@ ArrayKlass::ArrayKlass(Symbol* name, KlassID id) :
JFR_ONLY(INIT_ID(this);)
}

Symbol* ArrayKlass::create_element_klass_array_name(bool is_qtype, Klass* element_klass, TRAPS) {
Symbol* ArrayKlass::create_element_klass_array_name(Klass* element_klass, TRAPS) {
Symbol* name = NULL;
bool is_qtype = element_klass->is_value();
if (!element_klass->is_instance_klass() || is_qtype ||
(name = InstanceKlass::cast(element_klass)->array_name()) == NULL) {

@@ -123,10 +124,10 @@ Symbol* ArrayKlass::create_element_klass_array_name(bool is_qtype, Klass* elemen
new_str[idx++] = JVM_SIGNATURE_ENDCLASS;
}
new_str[idx++] = '\0';
name = SymbolTable::new_permanent_symbol(new_str);
if (element_klass->is_instance_klass() && (!is_qtype)) {
name = SymbolTable::new_symbol(new_str);
if (element_klass->is_instance_klass()) {
InstanceKlass* ik = InstanceKlass::cast(element_klass);
ik->set_array_name(name); // CMH: only cache and deref array_name for L-type...missing for Q-type
ik->set_array_name(name);
}
}

@@ -161,7 +162,7 @@ GrowableArray<Klass*>* ArrayKlass::compute_secondary_supers(int num_extra_slots,
objArrayOop ArrayKlass::allocate_arrayArray(int n, int length, TRAPS) {
check_array_allocation_length(length, arrayOopDesc::max_array_length(T_ARRAY), CHECK_NULL);
int size = objArrayOopDesc::object_size(length);
Klass* k = array_klass(ArrayStorageProperties::for_signature(name()), n+dimension(), CHECK_NULL);
Klass* k = array_klass(n+dimension(), CHECK_NULL);
ArrayKlass* ak = ArrayKlass::cast(k);
objArrayOop o = (objArrayOop)Universe::heap()->array_allocate(ak, size, length,
/* do_zero */ true, CHECK_NULL);
@@ -26,6 +26,7 @@
#define SHARE_OOPS_ARRAYKLASS_HPP

#include "oops/klass.hpp"
#include "oops/arrayStorageProperties.hpp"

class fieldDescriptor;
class klassVtable;
@@ -55,8 +56,8 @@ class ArrayKlass: public Klass {
ArrayKlass(Symbol* name, KlassID id);
ArrayKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for cds"); }

// Create array_name for element klass, creates a permanent symbol, returns result
static Symbol* create_element_klass_array_name(bool is_qtype, Klass* element_klass, TRAPS);
// Create array_name for element klass
static Symbol* create_element_klass_array_name(Klass* element_klass, TRAPS);

public:
// Instance variables
@@ -30,7 +30,6 @@
STATIC_ASSERT((int)ArrayStorageProperties::nof_oop_properties <= (int)oopDesc::storage_props_nof_bits);

const ArrayStorageProperties ArrayStorageProperties::empty = ArrayStorageProperties(empty_value);
const ArrayStorageProperties ArrayStorageProperties::flattened = ArrayStorageProperties(flattened_value);
const ArrayStorageProperties ArrayStorageProperties::null_free = ArrayStorageProperties(null_free_value);
const ArrayStorageProperties ArrayStorageProperties::flattened_and_null_free =
ArrayStorageProperties(flattened_value | null_free_value);
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2020, 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
@@ -51,27 +51,18 @@ class ArrayStorageProperties {

bool is_empty() const { return _flags == empty_value; }

void clear_flattened() { clear_flags_bits(flattened_value); }

bool is_flattened() const { return test_flags_bit(flattened_bit); }
void set_flattened() { set_flags_bits(flattened_value); }

bool is_null_free() const { return test_flags_bit(null_free_bit); }
void set_null_free() { set_flags_bits(null_free_value); }

uint8_t value() const { return _flags; }
template <typename T> T encode(int shift) const { return static_cast<T>(_flags) << shift; }

// Well-known constants...
static const ArrayStorageProperties empty;
static const ArrayStorageProperties flattened;
static const ArrayStorageProperties null_free;
static const ArrayStorageProperties flattened_and_null_free;

static ArrayStorageProperties for_signature(Symbol* sig) {
return (sig->is_Q_array_signature() || sig->is_Q_signature()) ?
ArrayStorageProperties::flattened_and_null_free : ArrayStorageProperties::empty;
}
};


@@ -1449,8 +1449,7 @@ void InstanceKlass::check_valid_for_instantiation(bool throwError, TRAPS) {
}
}

Klass* InstanceKlass::array_klass_impl(ArrayStorageProperties storage_props, bool or_null, int n, TRAPS) {
assert(storage_props.is_empty(), "Unexpected");
Klass* InstanceKlass::array_klass_impl(bool or_null, int n, TRAPS) {
// Need load-acquire for lock-free read
if (array_klasses_acquire() == NULL) {
if (or_null) return NULL;
@@ -1463,7 +1462,7 @@ Klass* InstanceKlass::array_klass_impl(ArrayStorageProperties storage_props, boo

// Check if update has already taken place
if (array_klasses() == NULL) {
Klass* k = ObjArrayKlass::allocate_objArray_klass(storage_props, 1, this, CHECK_NULL);
Klass* k = ObjArrayKlass::allocate_objArray_klass(1, this, CHECK_NULL);
// use 'release' to pair with lock-free load
release_set_array_klasses(k);
}
@@ -1472,13 +1471,13 @@ Klass* InstanceKlass::array_klass_impl(ArrayStorageProperties storage_props, boo
// _this will always be set at this point
ObjArrayKlass* oak = (ObjArrayKlass*)array_klasses();
if (or_null) {
return oak->array_klass_or_null(storage_props, n);
return oak->array_klass_or_null(n);
}
return oak->array_klass(storage_props, n, THREAD);
return oak->array_klass(n, THREAD);
}

Klass* InstanceKlass::array_klass_impl(ArrayStorageProperties storage_props, bool or_null, TRAPS) {
return array_klass_impl(storage_props, or_null, 1, THREAD);
Klass* InstanceKlass::array_klass_impl(bool or_null, TRAPS) {
return array_klass_impl(or_null, 1, THREAD);
}

static int call_class_initializer_counter = 0; // for debugging
@@ -1454,10 +1454,10 @@ class InstanceKlass: public Klass {
JNIid* jni_id_for_impl (int offset);
protected:
// Returns the array class for the n'th dimension
virtual Klass* array_klass_impl(ArrayStorageProperties storage_props, bool or_null, int n, TRAPS);
virtual Klass* array_klass_impl(bool or_null, int n, TRAPS);

// Returns the array class with this class as element type
virtual Klass* array_klass_impl(ArrayStorageProperties storage_props, bool or_null, TRAPS);
virtual Klass* array_klass_impl(bool or_null, TRAPS);

private:

@@ -631,29 +631,29 @@ void Klass::set_archived_java_mirror_raw(oop m) {
}
#endif // INCLUDE_CDS_JAVA_HEAP

Klass* Klass::array_klass_or_null(ArrayStorageProperties storage_props, int rank) {
Klass* Klass::array_klass_or_null(int rank) {
EXCEPTION_MARK;
// No exception can be thrown by array_klass_impl when called with or_null == true.
// (In anycase, the execption mark will fail if it do so)
return array_klass_impl(storage_props, true, rank, THREAD);
return array_klass_impl(true, rank, THREAD);
}


Klass* Klass::array_klass_or_null(ArrayStorageProperties storage_props) {
Klass* Klass::array_klass_or_null() {
EXCEPTION_MARK;
// No exception can be thrown by array_klass_impl when called with or_null == true.
// (In anycase, the execption mark will fail if it do so)
return array_klass_impl(storage_props, true, THREAD);
return array_klass_impl(true, THREAD);
}


Klass* Klass::array_klass_impl(ArrayStorageProperties storage_props, bool or_null, int rank, TRAPS) {
Klass* Klass::array_klass_impl(bool or_null, int rank, TRAPS) {
fatal("array_klass should be dispatched to InstanceKlass, ObjArrayKlass or TypeArrayKlass");
return NULL;
}


Klass* Klass::array_klass_impl(ArrayStorageProperties storage_props, bool or_null, TRAPS) {
Klass* Klass::array_klass_impl(bool or_null, TRAPS) {
fatal("array_klass should be dispatched to InstanceKlass, ObjArrayKlass or TypeArrayKlass");
return NULL;
}
@@ -743,16 +743,6 @@ void Klass::oop_print_on(oop obj, outputStream* st) {
st->cr();
st->print(BULLET"prototype_header: " INTPTR_FORMAT, _prototype_header.value());
st->cr();
ArrayStorageProperties props = obj->array_storage_properties();
if (props.value() != 0) {
st->print(" - array storage properties: ");
if (props.is_flattened()) {
st->print(" flat");
}
if (props.is_null_free()) {
st->print(" non nullable");
}
}
}

// print class
@@ -28,7 +28,6 @@
#include "classfile/classLoaderData.hpp"
#include "memory/iterator.hpp"
#include "memory/memRegion.hpp"
#include "oops/arrayStorageProperties.hpp"
#include "oops/markWord.hpp"
#include "oops/metadata.hpp"
#include "oops/oop.hpp"
@@ -480,27 +479,15 @@ class Klass : public Metadata {
}

// array class with specific rank
Klass* array_klass(int rank, TRAPS) {
return array_klass_impl(ArrayStorageProperties::empty, false, rank, THREAD);
}

Klass* array_klass(ArrayStorageProperties storage_props, int rank, TRAPS) {
return array_klass_impl(storage_props, false, rank, THREAD);
}
Klass* array_klass(int rank, TRAPS) { return array_klass_impl(false, rank, THREAD); }

// array class with this klass as element type
Klass* array_klass(TRAPS) {
return array_klass_impl(ArrayStorageProperties::empty, false, THREAD);
}

Klass* array_klass(ArrayStorageProperties storage_props, TRAPS) {
return array_klass_impl(storage_props, false, THREAD);
}
Klass* array_klass(TRAPS) { return array_klass_impl(false, THREAD); }

// These will return NULL instead of allocating on the heap:
// NB: these can block for a mutex, like other functions with TRAPS arg.
Klass* array_klass_or_null(ArrayStorageProperties storage_props, int rank);
Klass* array_klass_or_null(ArrayStorageProperties storage_props);
Klass* array_klass_or_null(int rank);
Klass* array_klass_or_null();

virtual oop protection_domain() const = 0;

@@ -513,8 +500,8 @@ class Klass : public Metadata {
oop klass_holder() const { return class_loader_data()->holder_phantom(); }

protected:
virtual Klass* array_klass_impl(ArrayStorageProperties storage_props, bool or_null, int rank, TRAPS);
virtual Klass* array_klass_impl(ArrayStorageProperties storage_props, bool or_null, TRAPS);
virtual Klass* array_klass_impl(bool or_null, int rank, TRAPS);
virtual Klass* array_klass_impl(bool or_null, TRAPS);

// Error handling when length > max_length or length < 0
static void check_array_allocation_length(int length, int max_length, TRAPS);

0 comments on commit 2e5a958

Please sign in to comment.