1879N/A * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A// The following two classes are used to represent 'sizes' and 'offsets' in the VM; 0N/A// they serve as 'unit' types. ByteSize is used for sizes measured in bytes, while 0N/A// WordSize is used for sizes measured in machine words (i.e., 32bit or 64bit words 0N/A// depending on platform). 0N/A// The classes are defined with friend functions operating on them instead of member 0N/A// functions so that they (the classes) can be re-#define'd to int types in optimized 0N/A// mode. This allows full type checking and maximum safety in debug mode, and full 0N/A// optimizations (constant folding) and zero overhead (time and space wise) in the 0N/A// optimized build (some compilers do not optimize one-element value classes but 0N/A// instead create an object in memory - thus the overhead may be significant). 0N/A// Note: 1) DO NOT add new overloaded friend functions that do not have a unique function 0N/A// function name but require signature types for resolution. This will not work 0N/A// in optimized mode as both, ByteSize and WordSize are mapped to the same type 0N/A// and thus the distinction would not be possible anymore (=> compiler errors). 0N/A// 2) DO NOT add non-static member functions as they cannot be mapped so something 0N/A// compilable in the optimized build. Static member functions could be added 0N/A// but require a corresponding class definition in the optimized build. 0N/A// These classes should help doing a transition from (currently) word-size based offsets 0N/A// to byte-size based offsets in the VM (this will be important if we desire to pack 0N/A// objects more densely in the VM for 64bit machines). Such a transition should proceed 0N/A// in two steps to minimize the risk of introducing hard-to-find bugs: 0N/A// a) first transition the whole VM into a form where all sizes are strongly typed 0N/A// b) change all WordSize's to ByteSize's where desired and fix the compilation errors 0N/A // Note: This constructor must be private to avoid implicit conversions! 0N/A // Note: This constructor must be private to avoid implicit conversions! 0N/A// The following definitions must match the corresponding friend declarations 0N/A// be the case in optimized mode to ensure zero overhead for these types. 0N/A// Note: If a compiler does not inline these function calls away, one may 0N/A// want to use #define's to make sure full optimization (constant 0N/A// folding in particular) is possible. 0N/A// Use the following #define to get C++ field member offsets 1879N/A#
endif // SHARE_VM_UTILITIES_SIZES_HPP