src/share/vm/utilities/chunkedList.cpp

Thu, 19 Mar 2015 19:53:34 +0100

author
zmajo
date
Thu, 19 Mar 2015 19:53:34 +0100
changeset 7638
aefa2e84b424
parent 7333
b12a2a9b05ca
permissions
-rw-r--r--

8074869: C2 code generator can replace -0.0f with +0.0f on Linux
Summary: Instead of 'fpclass', use cast float->int and double->long to check if value is +0.0f and +0.0d, respectively.
Reviewed-by: kvn, simonis, dlong

     1 /*
     2  * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #include "precompiled.hpp"
    26 #include "utilities/chunkedList.hpp"
    27 #include "utilities/debug.hpp"
    29 /////////////// Unit tests ///////////////
    31 #ifndef PRODUCT
    33 template <typename T>
    34 class TestChunkedList {
    35   typedef ChunkedList<T, mtOther> ChunkedListT;
    37  public:
    38   static void testEmpty() {
    39     ChunkedListT buffer;
    40     assert(buffer.size() == 0, "assert");
    41   }
    43   static void testFull() {
    44     ChunkedListT buffer;
    45     for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
    46       buffer.push((T)i);
    47     }
    48     assert(buffer.size() == ChunkedListT::BufferSize, "assert");
    49     assert(buffer.is_full(), "assert");
    50   }
    52   static void testSize() {
    53     ChunkedListT buffer;
    54     for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
    55       assert(buffer.size() == i, "assert");
    56       buffer.push((T)i);
    57       assert(buffer.size() == i + 1, "assert");
    58     }
    59   }
    61   static void testClear() {
    62     ChunkedListT buffer;
    64     buffer.clear();
    65     assert(buffer.size() == 0, "assert");
    67     for (uintptr_t i = 0; i < ChunkedListT::BufferSize / 2; i++) {
    68       buffer.push((T)i);
    69     }
    70     buffer.clear();
    71     assert(buffer.size() == 0, "assert");
    73     for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
    74       buffer.push((T)i);
    75     }
    76     buffer.clear();
    77     assert(buffer.size() == 0, "assert");
    78   }
    80   static void testAt() {
    81     ChunkedListT buffer;
    83     for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
    84       buffer.push((T)i);
    85       assert(buffer.at(i) == (T)i, "assert");
    86     }
    88     for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
    89       assert(buffer.at(i) == (T)i, "assert");
    90     }
    91   }
    93   static void test() {
    94     testEmpty();
    95     testFull();
    96     testSize();
    97     testClear();
    98     testAt();
    99   }
   100 };
   102 class Metadata;
   104 void TestChunkedList_test() {
   105   TestChunkedList<Metadata*>::test();
   106   TestChunkedList<size_t>::test();
   107 }
   109 #endif

mercurial