test/hotspot/gtest/oops/test_arrayOop.cpp
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 41671 hotspot/test/native/oops/test_arrayOop.cpp@9e0c6db4918a
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
41290
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
     2
 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    24
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "oops/arrayOop.hpp"
11637
030466036615 7013347: allow crypto functions to be called inline to enhance performance
never
parents: 11247
diff changeset
    26
#include "oops/oop.inline.hpp"
41290
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    27
#include "unittest.hpp"
10994
fc93bca9c720 7102044: G1: VM crashes with assert(old_end != new_end) failed: don't call this otherwise
brutisso
parents: 8921
diff changeset
    28
#include "utilities/globalDefinitions.hpp"
fc93bca9c720 7102044: G1: VM crashes with assert(old_end != new_end) failed: don't call this otherwise
brutisso
parents: 8921
diff changeset
    29
41290
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    30
class arrayOopDescTest {
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    31
 public:
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    32
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    33
  static int header_size_in_bytes() {
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    34
    return arrayOopDesc::header_size_in_bytes();
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    35
  }
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    36
};
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    37
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    38
static bool check_max_length_overflow(BasicType type) {
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    39
  julong length = arrayOopDesc::max_array_length(type);
10994
fc93bca9c720 7102044: G1: VM crashes with assert(old_end != new_end) failed: don't call this otherwise
brutisso
parents: 8921
diff changeset
    40
  julong bytes_per_element = type2aelembytes(type);
41290
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    41
  julong bytes = length * bytes_per_element
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    42
          + arrayOopDescTest::header_size_in_bytes();
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    43
  return (julong) (size_t) bytes == bytes;
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    44
}
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    45
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41290
diff changeset
    46
TEST_VM(arrayOopDesc, boolean) {
41290
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    47
  ASSERT_PRED1(check_max_length_overflow, T_BOOLEAN);
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    48
}
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    49
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41290
diff changeset
    50
TEST_VM(arrayOopDesc, char) {
41290
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    51
  ASSERT_PRED1(check_max_length_overflow, T_CHAR);
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    52
}
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    53
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41290
diff changeset
    54
TEST_VM(arrayOopDesc, float) {
41290
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    55
  ASSERT_PRED1(check_max_length_overflow, T_FLOAT);
10994
fc93bca9c720 7102044: G1: VM crashes with assert(old_end != new_end) failed: don't call this otherwise
brutisso
parents: 8921
diff changeset
    56
}
fc93bca9c720 7102044: G1: VM crashes with assert(old_end != new_end) failed: don't call this otherwise
brutisso
parents: 8921
diff changeset
    57
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41290
diff changeset
    58
TEST_VM(arrayOopDesc, double) {
41290
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    59
  ASSERT_PRED1(check_max_length_overflow, T_DOUBLE);
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    60
}
10994
fc93bca9c720 7102044: G1: VM crashes with assert(old_end != new_end) failed: don't call this otherwise
brutisso
parents: 8921
diff changeset
    61
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41290
diff changeset
    62
TEST_VM(arrayOopDesc, byte) {
41290
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    63
  ASSERT_PRED1(check_max_length_overflow, T_BYTE);
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    64
}
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    65
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41290
diff changeset
    66
TEST_VM(arrayOopDesc, short) {
41290
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    67
  ASSERT_PRED1(check_max_length_overflow, T_SHORT);
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    68
}
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    69
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41290
diff changeset
    70
TEST_VM(arrayOopDesc, int) {
41290
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    71
  ASSERT_PRED1(check_max_length_overflow, T_INT);
10994
fc93bca9c720 7102044: G1: VM crashes with assert(old_end != new_end) failed: don't call this otherwise
brutisso
parents: 8921
diff changeset
    72
}
fc93bca9c720 7102044: G1: VM crashes with assert(old_end != new_end) failed: don't call this otherwise
brutisso
parents: 8921
diff changeset
    73
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41290
diff changeset
    74
TEST_VM(arrayOopDesc, long) {
41290
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    75
  ASSERT_PRED1(check_max_length_overflow, T_LONG);
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    76
}
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    77
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41290
diff changeset
    78
TEST_VM(arrayOopDesc, object) {
41290
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    79
  ASSERT_PRED1(check_max_length_overflow, T_OBJECT);
35529
39376b4613b5 8147012: Fix includes in internalVMTests.cpp
ehelin
parents: 11637
diff changeset
    80
}
10994
fc93bca9c720 7102044: G1: VM crashes with assert(old_end != new_end) failed: don't call this otherwise
brutisso
parents: 8921
diff changeset
    81
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41290
diff changeset
    82
TEST_VM(arrayOopDesc, array) {
41290
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    83
  ASSERT_PRED1(check_max_length_overflow, T_ARRAY);
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    84
}
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    85
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41290
diff changeset
    86
TEST_VM(arrayOopDesc, narrowOop) {
41290
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    87
  ASSERT_PRED1(check_max_length_overflow, T_NARROWOOP);
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    88
}
8ff9c4ea1690 8165601: Convert arrayOopDesc_test to Gtest
kzhaldyb
parents: 35529
diff changeset
    89
// T_VOID and T_ADDRESS are not supported by max_array_length()