Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/cpu/x86/vm/bytes_x86.hpp
32285 views
/*1* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef CPU_X86_VM_BYTES_X86_HPP25#define CPU_X86_VM_BYTES_X86_HPP2627#include "memory/allocation.hpp"2829class Bytes: AllStatic {30private:31#ifndef AMD6432// Helper function for swap_u833static inline u8 swap_u8_base(u4 x, u4 y); // compiler-dependent implementation34#endif // AMD643536public:37// Returns true if the byte ordering used by Java is different from the native byte ordering38// of the underlying machine. For example, this is true for Intel x86, but false for Solaris39// on Sparc.40static inline bool is_Java_byte_ordering_different(){ return true; }414243// Efficient reading and writing of unaligned unsigned data in platform-specific byte ordering44// (no special code is needed since x86 CPUs can access unaligned data)45static inline u2 get_native_u2(address p) { return *(u2*)p; }46static inline u4 get_native_u4(address p) { return *(u4*)p; }47static inline u8 get_native_u8(address p) { return *(u8*)p; }4849static inline void put_native_u2(address p, u2 x) { *(u2*)p = x; }50static inline void put_native_u4(address p, u4 x) { *(u4*)p = x; }51static inline void put_native_u8(address p, u8 x) { *(u8*)p = x; }525354// Efficient reading and writing of unaligned unsigned data in Java55// byte ordering (i.e. big-endian ordering). Byte-order reversal is56// needed since x86 CPUs use little-endian format.57static inline u2 get_Java_u2(address p) { return swap_u2(get_native_u2(p)); }58static inline u4 get_Java_u4(address p) { return swap_u4(get_native_u4(p)); }59static inline u8 get_Java_u8(address p) { return swap_u8(get_native_u8(p)); }6061static inline void put_Java_u2(address p, u2 x) { put_native_u2(p, swap_u2(x)); }62static inline void put_Java_u4(address p, u4 x) { put_native_u4(p, swap_u4(x)); }63static inline void put_Java_u8(address p, u8 x) { put_native_u8(p, swap_u8(x)); }646566// Efficient swapping of byte ordering67static inline u2 swap_u2(u2 x); // compiler-dependent implementation68static inline u4 swap_u4(u4 x); // compiler-dependent implementation69static inline u8 swap_u8(u8 x);70};717273// The following header contains the implementations of swap_u2, swap_u4, and swap_u8[_base]74#ifdef TARGET_OS_ARCH_linux_x8675# include "bytes_linux_x86.inline.hpp"76#endif77#ifdef TARGET_OS_ARCH_solaris_x8678# include "bytes_solaris_x86.inline.hpp"79#endif80#ifdef TARGET_OS_ARCH_windows_x8681# include "bytes_windows_x86.inline.hpp"82#endif83#ifdef TARGET_OS_ARCH_bsd_x8684# include "bytes_bsd_x86.inline.hpp"85#endif868788#endif // CPU_X86_VM_BYTES_X86_HPP899091