Path: blob/master/src/hotspot/cpu/aarch64/bytes_aarch64.hpp
40930 views
/*1* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2014, Red Hat Inc. 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 it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 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 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#ifndef CPU_AARCH64_BYTES_AARCH64_HPP26#define CPU_AARCH64_BYTES_AARCH64_HPP2728#include "memory/allocation.hpp"2930class Bytes: AllStatic {31public:32// Efficient reading and writing of unaligned unsigned data in platform-specific byte ordering33// (no special code is needed since x86 CPUs can access unaligned data)34static inline u2 get_native_u2(address p) { return *(u2*)p; }35static inline u4 get_native_u4(address p) { return *(u4*)p; }36static inline u8 get_native_u8(address p) { return *(u8*)p; }3738static inline void put_native_u2(address p, u2 x) { *(u2*)p = x; }39static inline void put_native_u4(address p, u4 x) { *(u4*)p = x; }40static inline void put_native_u8(address p, u8 x) { *(u8*)p = x; }414243// Efficient reading and writing of unaligned unsigned data in Java44// byte ordering (i.e. big-endian ordering). Byte-order reversal is45// needed since x86 CPUs use little-endian format.46static inline u2 get_Java_u2(address p) { return swap_u2(get_native_u2(p)); }47static inline u4 get_Java_u4(address p) { return swap_u4(get_native_u4(p)); }48static inline u8 get_Java_u8(address p) { return swap_u8(get_native_u8(p)); }4950static inline void put_Java_u2(address p, u2 x) { put_native_u2(p, swap_u2(x)); }51static inline void put_Java_u4(address p, u4 x) { put_native_u4(p, swap_u4(x)); }52static inline void put_Java_u8(address p, u8 x) { put_native_u8(p, swap_u8(x)); }535455// Efficient swapping of byte ordering56static inline u2 swap_u2(u2 x); // compiler-dependent implementation57static inline u4 swap_u4(u4 x); // compiler-dependent implementation58static inline u8 swap_u8(u8 x);59};606162// The following header contains the implementations of swap_u2, swap_u4, and swap_u8[_base]63#include OS_CPU_HEADER(bytes)6465#endif // CPU_AARCH64_BYTES_AARCH64_HPP666768