diff --git a/hotspot/src/share/vm/metaprogramming/conditional.hpp b/hotspot/src/share/vm/metaprogramming/conditional.hpp new file mode 100644 index 00000000000..a60b0018d89 --- /dev/null +++ b/hotspot/src/share/vm/metaprogramming/conditional.hpp @@ -0,0 +1,43 @@ +/* + * 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_METAPROGRAMMING_CONDITIONAL_HPP +#define SHARE_VM_METAPROGRAMMING_CONDITIONAL_HPP + +#include "memory/allocation.hpp" + +// This trait evaluates its typedef called "type" to TrueType iff the condition +// is true. Otherwise it evaluates to FalseType. + +template +struct Conditional: AllStatic { + typedef TrueType type; +}; + +template +struct Conditional: AllStatic { + typedef FalseType type; +}; + +#endif // SHARE_VM_METAPROGRAMMING_CONDITIONAL_HPP diff --git a/hotspot/src/share/vm/metaprogramming/decay.hpp b/hotspot/src/share/vm/metaprogramming/decay.hpp new file mode 100644 index 00000000000..32449c240a4 --- /dev/null +++ b/hotspot/src/share/vm/metaprogramming/decay.hpp @@ -0,0 +1,41 @@ +/* + * 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_METAPROGRAMMING_DECAY_HPP +#define SHARE_VM_METAPROGRAMMING_DECAY_HPP + +#include "memory/allocation.hpp" +#include "metaprogramming/removeCV.hpp" +#include "metaprogramming/removeReference.hpp" + +// This trait trims the type from CV qualifiers and references. +// This trait provides a subset of the functionality of std::decay; +// array types and function types are not supported here. + +template +struct Decay: AllStatic { + typedef typename RemoveCV::type>::type type; +}; + +#endif // SHARE_VM_METAPROGRAMMING_DECAY_HPP diff --git a/hotspot/src/share/vm/metaprogramming/enableIf.hpp b/hotspot/src/share/vm/metaprogramming/enableIf.hpp new file mode 100644 index 00000000000..06e57a795c3 --- /dev/null +++ b/hotspot/src/share/vm/metaprogramming/enableIf.hpp @@ -0,0 +1,47 @@ +/* + * 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_METAPROGRAMMING_ENABLEIF_HPP +#define SHARE_VM_METAPROGRAMMING_ENABLEIF_HPP + +#include "memory/allocation.hpp" + +// This metaprogramming tool allows explicitly enabling and disabling overloads +// of member functions depending on whether the condition B holds true. +// For example typename EnableIf::value>::type func(T ptr) would +// only become an overload the compiler chooses from if the type T is a pointer. +// If it is not, then the template definition is not expanded and there will be +// no compiler error if there is another overload of func that is selected when +// T is not a pointer. Like for example +// typename EnableIf::value>::type func(T not_ptr) + +template +struct EnableIf: AllStatic {}; + +template +struct EnableIf: AllStatic { + typedef T type; +}; + +#endif // SHARE_VM_METAPROGRAMMING_ENABLEIF_HPP diff --git a/hotspot/src/share/vm/metaprogramming/integralConstant.hpp b/hotspot/src/share/vm/metaprogramming/integralConstant.hpp new file mode 100644 index 00000000000..585e848cbec --- /dev/null +++ b/hotspot/src/share/vm/metaprogramming/integralConstant.hpp @@ -0,0 +1,60 @@ +/* + * 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_METAPROGRAMMING_INTEGRALCONSTANT_HPP +#define SHARE_VM_METAPROGRAMMING_INTEGRALCONSTANT_HPP + +#include "memory/allocation.hpp" + +// An Integral Constant is a class providing a compile-time value of an +// integral type. An Integral Constant is also a nullary metafunction, +// returning itself. An integral constant object is implicitly +// convertible to the associated value. +// +// A type n is a model of Integral Constant if it meets the following +// requirements: +// +// n::ValueType : The integral type of n::value +// n::value : An integral constant expression +// n::type : IsSame::value is true +// n::value_type const c = n() : c == n::value + +// A model of the Integer Constant concept. +// T is an integral type, and is the value_type. +// v is an integral constant, and is the value. +template +struct IntegralConstant : AllStatic { + typedef T value_type; + static const value_type value = v; + typedef IntegralConstant type; + operator value_type() { return value; } +}; + +// A bool valued IntegralConstant whose value is true. +typedef IntegralConstant TrueType; + +// A bool valued IntegralConstant whose value is false. +typedef IntegralConstant FalseType; + +#endif // SHARE_VM_METAPROGRAMMING_INTEGRALCONSTANT_HPP diff --git a/hotspot/src/share/vm/metaprogramming/isConst.hpp b/hotspot/src/share/vm/metaprogramming/isConst.hpp new file mode 100644 index 00000000000..826ddb53787 --- /dev/null +++ b/hotspot/src/share/vm/metaprogramming/isConst.hpp @@ -0,0 +1,33 @@ +/* + * 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_METAPROGRAMMING_ISCONST_HPP +#define SHARE_VM_METAPROGRAMMING_ISCONST_HPP + +#include "metaprogramming/integralConstant.hpp" + +template struct IsConst: public FalseType {}; +template struct IsConst: public TrueType {}; + +#endif // SHARE_VM_METAPROGRAMMING_ISCONST_HPP diff --git a/hotspot/src/share/vm/metaprogramming/isFloatingPoint.hpp b/hotspot/src/share/vm/metaprogramming/isFloatingPoint.hpp new file mode 100644 index 00000000000..f2fb9f4586f --- /dev/null +++ b/hotspot/src/share/vm/metaprogramming/isFloatingPoint.hpp @@ -0,0 +1,50 @@ +/* + * 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_METAPROGRAMMING_ISFLOATINGPOINT_HPP +#define SHARE_VM_METAPROGRAMMING_ISFLOATINGPOINT_HPP + +#include "metaprogramming/integralConstant.hpp" + +// This metafunction returns true iff the type T (irrespective of CV qualifiers) +// is a floating point type. + +template struct IsFloatingPoint: public FalseType {}; + +template <> struct IsFloatingPoint: public TrueType {}; +template <> struct IsFloatingPoint: public TrueType {}; +template <> struct IsFloatingPoint: public TrueType {}; +template <> struct IsFloatingPoint: public TrueType {}; + +template <> struct IsFloatingPoint: public TrueType {}; +template <> struct IsFloatingPoint: public TrueType {}; +template <> struct IsFloatingPoint: public TrueType {}; +template <> struct IsFloatingPoint: public TrueType {}; + +template <> struct IsFloatingPoint: public TrueType {}; +template <> struct IsFloatingPoint: public TrueType {}; +template <> struct IsFloatingPoint: public TrueType {}; +template <> struct IsFloatingPoint: public TrueType {}; + +#endif // SHARE_VM_METAPROGRAMMING_ISFLOATINGPOINT_HPP diff --git a/hotspot/src/share/vm/metaprogramming/isIntegral.hpp b/hotspot/src/share/vm/metaprogramming/isIntegral.hpp new file mode 100644 index 00000000000..53d57139538 --- /dev/null +++ b/hotspot/src/share/vm/metaprogramming/isIntegral.hpp @@ -0,0 +1,59 @@ +/* + * 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_METAPROGRAMMING_ISINTEGRAL_HPP +#define SHARE_VM_METAPROGRAMMING_ISINTEGRAL_HPP + +#include "memory/allocation.hpp" +#include "metaprogramming/integralConstant.hpp" +#include "metaprogramming/isSigned.hpp" +#include "metaprogramming/removeCV.hpp" +#include + +// This metafunction returns true iff the type T (irrespective of CV qualifiers) +// is an integral type. Note that this is false for enums. + +template +struct IsIntegral + : public IntegralConstant::type>::is_integer> +{}; + +// This metafunction returns true iff the type T (irrespective of CV qualifiers) +// is a signed integral type. Note that this is false for enums. + +template +struct IsSignedIntegral + : public IntegralConstant::value && IsSigned::value> +{}; + +// This metafunction returns true iff the type T (irrespective of CV qualifiers) +// is an unsigned integral type. Note that this is false for enums. + +template +struct IsUnsignedIntegral + : public IntegralConstant::value && !IsSigned::value> +{}; + +#endif // SHARE_VM_METAPROGRAMMING_ISINTEGRAL_HPP diff --git a/hotspot/src/share/vm/metaprogramming/isPointer.hpp b/hotspot/src/share/vm/metaprogramming/isPointer.hpp new file mode 100644 index 00000000000..08a9d533af1 --- /dev/null +++ b/hotspot/src/share/vm/metaprogramming/isPointer.hpp @@ -0,0 +1,40 @@ +/* + * 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_METAPROGRAMMING_ISPOINTER_HPP +#define SHARE_VM_METAPROGRAMMING_ISPOINTER_HPP + +#include "metaprogramming/integralConstant.hpp" + +// This metafunction returns true iff the type T is (irrespective of CV qualifiers) +// a pointer type. + +template class IsPointer: public FalseType {}; + +template class IsPointer: public TrueType {}; +template class IsPointer: public TrueType {}; +template class IsPointer: public TrueType {}; +template class IsPointer: public TrueType {}; + +#endif // SHARE_VM_METAPROGRAMMING_ISPOINTER_HPP diff --git a/hotspot/src/share/vm/metaprogramming/isSame.hpp b/hotspot/src/share/vm/metaprogramming/isSame.hpp new file mode 100644 index 00000000000..19b24dd8907 --- /dev/null +++ b/hotspot/src/share/vm/metaprogramming/isSame.hpp @@ -0,0 +1,38 @@ +/* + * 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_METAPROGRAMMING_ISSAME_HPP +#define SHARE_VM_METAPROGRAMMING_ISSAME_HPP + +#include "metaprogramming/integralConstant.hpp" + +// This trait returns true iff the two types X and Y are the same + +template +struct IsSame: public FalseType {}; + +template +struct IsSame: public TrueType {}; + +#endif // SHARE_VM_METAPROGRAMMING_ISSAME_HPP diff --git a/hotspot/src/share/vm/metaprogramming/isSigned.hpp b/hotspot/src/share/vm/metaprogramming/isSigned.hpp new file mode 100644 index 00000000000..49dbdf12fc1 --- /dev/null +++ b/hotspot/src/share/vm/metaprogramming/isSigned.hpp @@ -0,0 +1,38 @@ +/* + * 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_METAPROGRAMMING_ISSIGNED_HPP +#define SHARE_VM_METAPROGRAMMING_ISSIGNED_HPP + +#include "memory/allocation.hpp" +#include "metaprogramming/integralConstant.hpp" +#include "metaprogramming/removeCV.hpp" +#include + +template +struct IsSigned + : public IntegralConstant::type>::is_signed> +{}; + +#endif // SHARE_VM_METAPROGRAMMING_ISSIGNED_HPP diff --git a/hotspot/src/share/vm/metaprogramming/isVolatile.hpp b/hotspot/src/share/vm/metaprogramming/isVolatile.hpp new file mode 100644 index 00000000000..16561f2e80d --- /dev/null +++ b/hotspot/src/share/vm/metaprogramming/isVolatile.hpp @@ -0,0 +1,33 @@ +/* + * 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_METAPROGRAMMING_ISVOLATILE_HPP +#define SHARE_VM_METAPROGRAMMING_ISVOLATILE_HPP + +#include "metaprogramming/integralConstant.hpp" + +template struct IsVolatile: public FalseType {}; +template struct IsVolatile: public TrueType {}; + +#endif // SHARE_VM_METAPROGRAMMING_ISVOLATILE_HPP diff --git a/hotspot/src/share/vm/metaprogramming/removeCV.hpp b/hotspot/src/share/vm/metaprogramming/removeCV.hpp new file mode 100644 index 00000000000..e40232895a8 --- /dev/null +++ b/hotspot/src/share/vm/metaprogramming/removeCV.hpp @@ -0,0 +1,50 @@ +/* + * 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_METAPROGRAMMING_REMOVECV_HPP +#define SHARE_VM_METAPROGRAMMING_REMOVECV_HPP + +#include "memory/allocation.hpp" + +template +struct RemoveCV: AllStatic { + typedef T type; +}; + +template +struct RemoveCV: AllStatic { + typedef T type; +}; + +template +struct RemoveCV: AllStatic { + typedef T type; +}; + +template +struct RemoveCV: AllStatic { + typedef T type; +}; + +#endif // SHARE_VM_METAPROGRAMMING_REMOVECV_HPP diff --git a/hotspot/src/share/vm/metaprogramming/removePointer.hpp b/hotspot/src/share/vm/metaprogramming/removePointer.hpp new file mode 100644 index 00000000000..c0d619cba1f --- /dev/null +++ b/hotspot/src/share/vm/metaprogramming/removePointer.hpp @@ -0,0 +1,41 @@ +/* + * 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_METAPROGRAMMING_REMOVEPOINTER_HPP +#define SHARE_VM_METAPROGRAMMING_REMOVEPOINTER_HPP + +#include "memory/allocation.hpp" + +// This metafunction returns for a type T either the underlying type behind +// the pointer iff T is a pointer type (irrespective of CV qualifiers), +// or the same type T if T is not a pointer type. + +template struct RemovePointer: AllStatic { typedef T type; }; + +template struct RemovePointer: AllStatic { typedef T type; }; +template struct RemovePointer: AllStatic { typedef T type; }; +template struct RemovePointer: AllStatic { typedef T type; }; +template struct RemovePointer: AllStatic { typedef T type; }; + +#endif // SHARE_VM_METAPROGRAMMING_REMOVEPOINTER_HPP diff --git a/hotspot/src/share/vm/metaprogramming/removeReference.hpp b/hotspot/src/share/vm/metaprogramming/removeReference.hpp new file mode 100644 index 00000000000..3f80ffc346e --- /dev/null +++ b/hotspot/src/share/vm/metaprogramming/removeReference.hpp @@ -0,0 +1,38 @@ +/* + * 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_METAPROGRAMMING_REMOVEREFERENCE_HPP +#define SHARE_VM_METAPROGRAMMING_REMOVEREFERENCE_HPP + +#include "memory/allocation.hpp" + +// This metafunction returns for a type T either the underlying type behind +// the reference iff T is a reference type, or the same type T if T is not +// a reference type. + +template struct RemoveReference: AllStatic { typedef T type; }; + +template struct RemoveReference: AllStatic { typedef T type; }; + +#endif // SHARE_VM_METAPROGRAMMING_REMOVEREFERENCE_HPP diff --git a/hotspot/test/native/metaprogramming/test_conditional.cpp b/hotspot/test/native/metaprogramming/test_conditional.cpp new file mode 100644 index 00000000000..30fce1e22e8 --- /dev/null +++ b/hotspot/test/native/metaprogramming/test_conditional.cpp @@ -0,0 +1,46 @@ +/* + * 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. + * + */ + +#include "precompiled.hpp" +#include "memory/allocation.hpp" +#include "metaprogramming/conditional.hpp" +#include "metaprogramming/isSame.hpp" +#include "utilities/debug.hpp" + +class ConditionalTest { + class A: AllStatic {}; + class B: AllStatic {}; + + typedef Conditional::type A_B_if_true; + static const bool A_B_if_true_is_A = IsSame::value; + static const bool A_B_if_true_is_B = IsSame::value; + STATIC_ASSERT(A_B_if_true_is_A); + STATIC_ASSERT(!A_B_if_true_is_B); + + typedef Conditional::type A_B_if_false; + static const bool A_B_if_false_is_A = IsSame::value; + static const bool A_B_if_false_is_B = IsSame::value; + STATIC_ASSERT(!A_B_if_false_is_A); + STATIC_ASSERT(A_B_if_false_is_B); +}; diff --git a/hotspot/test/native/metaprogramming/test_decay.cpp b/hotspot/test/native/metaprogramming/test_decay.cpp new file mode 100644 index 00000000000..32c08a68f72 --- /dev/null +++ b/hotspot/test/native/metaprogramming/test_decay.cpp @@ -0,0 +1,47 @@ +/* + * 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. + * + */ + +#include "precompiled.hpp" +#include "memory/allocation.hpp" +#include "metaprogramming/decay.hpp" +#include "metaprogramming/isSame.hpp" +#include "utilities/debug.hpp" + +class TestDecay: AllStatic { + class A: AllStatic {}; + + typedef const volatile A cvA; + typedef const volatile A& cvAref; + typedef const volatile A* cvAptr; + typedef const volatile A* const volatile cvAptrcv; + typedef A& Aref; + + typedef Decay::type rr_cvAref; + static const bool decay_cvAref_is_A = IsSame::value; + STATIC_ASSERT(decay_cvAref_is_A); + + typedef Decay::type rr_cvAptrcv; + static const bool decay_cvAptrcv_is_cvAptr = IsSame::value; + STATIC_ASSERT(decay_cvAptrcv_is_cvAptr); +}; diff --git a/hotspot/test/native/metaprogramming/test_enableIf.cpp b/hotspot/test/native/metaprogramming/test_enableIf.cpp new file mode 100644 index 00000000000..cc0bd7f796b --- /dev/null +++ b/hotspot/test/native/metaprogramming/test_enableIf.cpp @@ -0,0 +1,44 @@ +/* + * 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. + * + */ + +#include "precompiled.hpp" +#include "memory/allocation.hpp" +#include "metaprogramming/enableIf.hpp" +#include "utilities/debug.hpp" + +class EnableIfTest { + class A: AllStatic { + public: + template + static typename EnableIf::type test(); + template + static typename EnableIf::type test(); + }; + + static const bool A_test_true_is_char = sizeof(A::test()) == sizeof(char); + STATIC_ASSERT(A_test_true_is_char); + + static const bool A_test_false_is_long = sizeof(A::test()) == sizeof(long); + STATIC_ASSERT(A_test_false_is_long); +}; diff --git a/hotspot/test/native/metaprogramming/test_isConst.cpp b/hotspot/test/native/metaprogramming/test_isConst.cpp new file mode 100644 index 00000000000..7790f287586 --- /dev/null +++ b/hotspot/test/native/metaprogramming/test_isConst.cpp @@ -0,0 +1,47 @@ +/* + * 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. + * + */ + +#include "precompiled.hpp" +#include "memory/allocation.hpp" +#include "metaprogramming/isConst.hpp" +#include "utilities/debug.hpp" + +class IsConstTest { + class A: AllStatic {}; + + STATIC_ASSERT(!IsConst::value); + STATIC_ASSERT(IsConst::value); + STATIC_ASSERT(IsConst::value); + STATIC_ASSERT(!IsConst::value); + + STATIC_ASSERT(!IsConst::value); + STATIC_ASSERT(IsConst::value); + STATIC_ASSERT(!IsConst::value); + + STATIC_ASSERT(!IsConst::value); + STATIC_ASSERT(IsConst::value); + STATIC_ASSERT(IsConst::value); + STATIC_ASSERT(IsConst::value); +}; + diff --git a/hotspot/test/native/metaprogramming/test_isFloatingPoint.cpp b/hotspot/test/native/metaprogramming/test_isFloatingPoint.cpp new file mode 100644 index 00000000000..789dae1d1a9 --- /dev/null +++ b/hotspot/test/native/metaprogramming/test_isFloatingPoint.cpp @@ -0,0 +1,45 @@ +/* + * 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. + * + */ + +#include "precompiled.hpp" +#include "memory/allocation.hpp" +#include "metaprogramming/isFloatingPoint.hpp" +#include "utilities/debug.hpp" + +class IsFloatingPointTest: AllStatic { + STATIC_ASSERT(IsFloatingPoint::value); + STATIC_ASSERT(IsFloatingPoint::value); + STATIC_ASSERT(IsFloatingPoint::value); + + STATIC_ASSERT(IsFloatingPoint::value); + STATIC_ASSERT(!IsFloatingPoint::value); + + STATIC_ASSERT(!IsFloatingPoint::value); + STATIC_ASSERT(!IsFloatingPoint::value); + STATIC_ASSERT(!IsFloatingPoint::value); + + class A: AllStatic {}; + STATIC_ASSERT(!IsFloatingPoint::value); + STATIC_ASSERT(!IsFloatingPoint::value); +}; diff --git a/hotspot/test/native/metaprogramming/test_isIntegral.cpp b/hotspot/test/native/metaprogramming/test_isIntegral.cpp new file mode 100644 index 00000000000..f2b82fb638b --- /dev/null +++ b/hotspot/test/native/metaprogramming/test_isIntegral.cpp @@ -0,0 +1,62 @@ +/* + * 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. + * + */ + +#include "precompiled.hpp" +#include "memory/allocation.hpp" +#include "metaprogramming/isIntegral.hpp" +#include "utilities/debug.hpp" + +class IsIntegralTest: AllStatic { + class A: AllStatic {}; + + static const bool ii_voidptr = IsIntegral::value; + STATIC_ASSERT(!ii_voidptr); + + static const bool ii_Aptr = IsIntegral::value; + STATIC_ASSERT(!ii_Aptr); + + static const bool ii_cAptr = IsIntegral::value; + STATIC_ASSERT(!ii_cAptr); + + static const bool ii_vAptr = IsIntegral::value; + STATIC_ASSERT(!ii_vAptr); + + static const bool ii_Avptr = IsIntegral::value; + STATIC_ASSERT(!ii_Avptr); + + static const bool ii_intptrt = IsIntegral::value; + STATIC_ASSERT(ii_intptrt); + + static const bool ii_char = IsIntegral::value; + STATIC_ASSERT(ii_char); + + static const bool ii_cintptrt = IsIntegral::value; + STATIC_ASSERT(ii_cintptrt); + + static const bool ii_vintptrt = IsIntegral::value; + STATIC_ASSERT(ii_vintptrt); + + static const bool ii_cvintptrt = IsIntegral::value; + STATIC_ASSERT(ii_cvintptrt); +}; diff --git a/hotspot/test/native/metaprogramming/test_isPointer.cpp b/hotspot/test/native/metaprogramming/test_isPointer.cpp new file mode 100644 index 00000000000..ff3efd3d0c2 --- /dev/null +++ b/hotspot/test/native/metaprogramming/test_isPointer.cpp @@ -0,0 +1,53 @@ +/* + * 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. + * + */ + +#include "precompiled.hpp" +#include "memory/allocation.hpp" +#include "metaprogramming/isPointer.hpp" +#include "utilities/debug.hpp" + +class IsPointerTest: AllStatic { + class A: AllStatic {}; + + static const bool ip_voidptr = IsPointer::value; + STATIC_ASSERT(ip_voidptr); + + static const bool ip_Aptr = IsPointer::value; + STATIC_ASSERT(ip_Aptr); + + static const bool ip_cAptr = IsPointer::value; + STATIC_ASSERT(ip_cAptr); + + static const bool ip_vAptr = IsPointer::value; + STATIC_ASSERT(ip_vAptr); + + static const bool ip_Avptr = IsPointer::value; + STATIC_ASSERT(ip_Avptr); + + static const bool ip_intptrt = IsPointer::value; + STATIC_ASSERT(!ip_intptrt); + + static const bool ip_char = IsPointer::value; + STATIC_ASSERT(!ip_char); +}; diff --git a/hotspot/test/native/metaprogramming/test_isSame.cpp b/hotspot/test/native/metaprogramming/test_isSame.cpp new file mode 100644 index 00000000000..c2313bbb175 --- /dev/null +++ b/hotspot/test/native/metaprogramming/test_isSame.cpp @@ -0,0 +1,51 @@ +/* + * 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. + * + */ + +#include "precompiled.hpp" +#include "memory/allocation.hpp" +#include "metaprogramming/isSame.hpp" +#include "utilities/debug.hpp" + +class IsSameTest: AllStatic { + class A: AllStatic {}; + class B: AllStatic {}; + + static const bool const_A_is_A = IsSame::value; + STATIC_ASSERT(!const_A_is_A); + + static const bool volatile_A_is_A = IsSame::value; + STATIC_ASSERT(!volatile_A_is_A); + + static const bool Aref_is_A = IsSame::value; + STATIC_ASSERT(!Aref_is_A); + + static const bool Aptr_is_A = IsSame::value; + STATIC_ASSERT(!Aptr_is_A); + + static const bool A_is_B = IsSame::value; + STATIC_ASSERT(!A_is_B); + + static const bool A_is_A = IsSame::value; + STATIC_ASSERT(A_is_A); +}; diff --git a/hotspot/test/native/metaprogramming/test_isSigned.cpp b/hotspot/test/native/metaprogramming/test_isSigned.cpp new file mode 100644 index 00000000000..c67f5116553 --- /dev/null +++ b/hotspot/test/native/metaprogramming/test_isSigned.cpp @@ -0,0 +1,49 @@ +/* + * 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. + * + */ + +#include "precompiled.hpp" +#include "memory/allocation.hpp" +#include "metaprogramming/isSame.hpp" +#include "metaprogramming/isSigned.hpp" +#include "utilities/debug.hpp" + +class IsSignedTest: AllStatic { + template + class TestIntegers: AllStatic { + static const bool _signed_type_is_signed = IsSigned::value; + STATIC_ASSERT(_signed_type_is_signed); + static const bool _unsigned_type_is_unsigned = !IsSigned::value; + STATIC_ASSERT(_unsigned_type_is_unsigned); + + static const bool _cvsigned_type_is_signed = IsSigned::value; + STATIC_ASSERT(_signed_type_is_signed); + static const bool _cvunsigned_type_is_unsigned = !IsSigned::value; + STATIC_ASSERT(_unsigned_type_is_unsigned); + }; + + const TestIntegers TestByte; + const TestIntegers TestShort; + const TestIntegers TestInt; + const TestIntegers TestLong; +}; diff --git a/hotspot/test/native/metaprogramming/test_isVolatile.cpp b/hotspot/test/native/metaprogramming/test_isVolatile.cpp new file mode 100644 index 00000000000..4402cf2036b --- /dev/null +++ b/hotspot/test/native/metaprogramming/test_isVolatile.cpp @@ -0,0 +1,46 @@ +/* + * 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. + * + */ + +#include "precompiled.hpp" +#include "memory/allocation.hpp" +#include "metaprogramming/isVolatile.hpp" +#include "utilities/debug.hpp" + +class IsVolatileTest { + class A: AllStatic {}; + + STATIC_ASSERT(IsVolatile::value); + STATIC_ASSERT(IsVolatile::value); + STATIC_ASSERT(!IsVolatile::value); + STATIC_ASSERT(!IsVolatile::value); + + STATIC_ASSERT(IsVolatile::value); + STATIC_ASSERT(!IsVolatile::value); + STATIC_ASSERT(!IsVolatile::value); + + STATIC_ASSERT(!IsVolatile::value); + STATIC_ASSERT(IsVolatile::value); + STATIC_ASSERT(IsVolatile::value); + STATIC_ASSERT(IsVolatile::value); +}; diff --git a/hotspot/test/native/metaprogramming/test_removeCV.cpp b/hotspot/test/native/metaprogramming/test_removeCV.cpp new file mode 100644 index 00000000000..a91f5aa6e86 --- /dev/null +++ b/hotspot/test/native/metaprogramming/test_removeCV.cpp @@ -0,0 +1,75 @@ +/* + * 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. + * + */ + +#include "precompiled.hpp" +#include "memory/allocation.hpp" +#include "metaprogramming/removeCV.hpp" +#include "metaprogramming/isSame.hpp" +#include "utilities/debug.hpp" + +class RemoveCVTest { + class A: AllStatic {}; + + typedef const A cA; + typedef volatile A vA; + typedef const volatile A cvA; + typedef A* Aptr; + typedef const A* cAptr; + typedef A* const Aptrc; + typedef const A* const cAptrc; + typedef A& Aref; + typedef const A& cAref; + + typedef RemoveCV::type rcv_A; + static const bool rcv_A_is_A = IsSame::value; + STATIC_ASSERT(rcv_A_is_A); + + typedef RemoveCV::type rcv_cA; + static const bool rcv_cA_is_A = IsSame::value; + STATIC_ASSERT(rcv_cA_is_A); + + typedef RemoveCV::type rcv_vA; + static const bool rcv_vA_is_A = IsSame::value; + STATIC_ASSERT(rcv_vA_is_A); + + typedef RemoveCV::type rcv_cvA; + static const bool rcv_cvA_is_A = IsSame::value; + STATIC_ASSERT(rcv_cvA_is_A); + + typedef RemoveCV::type rcv_cAptr; + static const bool rcv_cAptr_is_cAptr = IsSame::value; + STATIC_ASSERT(rcv_cAptr_is_cAptr); + + typedef RemoveCV::type rcv_Aptrc; + static const bool rcv_Aptrc_is_Aptr = IsSame::value; + STATIC_ASSERT(rcv_Aptrc_is_Aptr); + + typedef RemoveCV::type rcv_cAptrc; + static const bool rcv_cAptrc_is_cAptr = IsSame::value; + STATIC_ASSERT(rcv_cAptrc_is_cAptr); + + typedef RemoveCV::type rcv_cAref; + static const bool rcv_cAref_is_cAref = IsSame::value; + STATIC_ASSERT(rcv_cAref_is_cAref); +}; diff --git a/hotspot/test/native/metaprogramming/test_removePointer.cpp b/hotspot/test/native/metaprogramming/test_removePointer.cpp new file mode 100644 index 00000000000..b6779c096d1 --- /dev/null +++ b/hotspot/test/native/metaprogramming/test_removePointer.cpp @@ -0,0 +1,45 @@ +/* + * 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. + * + */ + +#include "precompiled.hpp" +#include "memory/allocation.hpp" +#include "metaprogramming/removePointer.hpp" +#include "metaprogramming/isSame.hpp" +#include "utilities/debug.hpp" + +class RemovePointerTest { + class A: AllStatic {}; + + typedef const volatile A cvA; + typedef const volatile A& cvAref; + typedef const volatile A* const volatile cvAptrcv; + + typedef RemovePointer::type rp_cvAref; + static const bool rp_cvAref_is_cvAref = IsSame::value; + STATIC_ASSERT(rp_cvAref_is_cvAref); + + typedef RemovePointer::type rp_cvAptrcv; + static const bool rp_cvAptrcv_is_cvAptrcv = IsSame::value; + STATIC_ASSERT(rp_cvAptrcv_is_cvAptrcv); +}; diff --git a/hotspot/test/native/metaprogramming/test_removeReference.cpp b/hotspot/test/native/metaprogramming/test_removeReference.cpp new file mode 100644 index 00000000000..a8e2fcd4d7e --- /dev/null +++ b/hotspot/test/native/metaprogramming/test_removeReference.cpp @@ -0,0 +1,45 @@ +/* + * 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. + * + */ + +#include "precompiled.hpp" +#include "memory/allocation.hpp" +#include "metaprogramming/removeReference.hpp" +#include "metaprogramming/isSame.hpp" +#include "utilities/debug.hpp" + +class RemoveReferenceTest { + class A: AllStatic {}; + + typedef const volatile A cvA; + typedef const volatile A& cvAref; + typedef const volatile A* const volatile cvAptrcv; + + typedef RemoveReference::type rr_cvAref; + static const bool rr_cvAref_is_cvAref = IsSame::value; + STATIC_ASSERT(rr_cvAref_is_cvAref); + + typedef RemoveReference::type rr_cvAptrcv; + static const bool rr_cvAptrcv_is_cvAptrcv = IsSame::value; + STATIC_ASSERT(rr_cvAptrcv_is_cvAptrcv); +};