< prev index next >

src/hotspot/share/oops/arrayOop.hpp

Print this page
@@ -1,7 +1,7 @@
  /*
-  * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
+  * Copyright (c) 1997, 2025, 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.

@@ -24,10 +24,11 @@
  
  #ifndef SHARE_OOPS_ARRAYOOP_HPP
  #define SHARE_OOPS_ARRAYOOP_HPP
  
  #include "oops/oop.hpp"
+ #include "runtime/globals.hpp"
  #include "utilities/align.hpp"
  #include "utilities/globalDefinitions.hpp"
  
  // arrayOopDesc is the abstract baseclass for all arrays.  It doesn't
  // declare pure virtual to enforce this because that would allocate a vtbl

@@ -53,10 +54,13 @@
      return reinterpret_cast<int*>(ptr + length_offset_in_bytes());
    }
  
    // Given a type, return true if elements of that type must be aligned to 64-bit.
    static bool element_type_should_be_aligned(BasicType type) {
+     if (EnableValhalla && type == T_FLAT_ELEMENT) {
+       return true; //CMH: tighten the alignment when removing T_FLAT_ELEMENT
+     }
  #ifdef _LP64
      if (type == T_OBJECT || type == T_ARRAY) {
        return !UseCompressedOops;
      }
  #endif

@@ -71,11 +75,11 @@
      int hs = length_offset_in_bytes() + (int)sizeof(int);
  #ifdef ASSERT
      // make sure it isn't called before UseCompressedOops is initialized.
      static int arrayoopdesc_hs = 0;
      if (arrayoopdesc_hs == 0) arrayoopdesc_hs = hs;
-     assert(arrayoopdesc_hs == hs, "header size can't change");
+     // assert(arrayoopdesc_hs == hs, "header size can't change");
  #endif // ASSERT
      return (int)hs;
    }
  
    // The _length field is not declared in C++.  It is allocated after the

@@ -130,10 +134,11 @@
    // to typeArrayOop::object_size(scale, length, header_size) without causing an
    // overflow. We also need to make sure that this will not overflow a size_t on
    // 32 bit platforms when we convert it to a byte size.
    static int32_t max_array_length(BasicType type) {
      assert(type < T_CONFLICT, "wrong type");
+     assert(type != T_FLAT_ELEMENT, "wrong type");
      assert(type2aelembytes(type) != 0, "wrong type");
  
      int hdr_size_in_bytes = base_offset_in_bytes(type);
      // This is rounded-up and may overlap with the first array elements.
      int hdr_size_in_words = align_up(hdr_size_in_bytes, HeapWordSize) / HeapWordSize;
< prev index next >