Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Side by Side Diff: src/utils.h

Issue 2034093002: Implement WASM big-endian support (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Small fixes. Rebase to master Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | src/wasm/decoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_UTILS_H_ 5 #ifndef V8_UTILS_H_
6 #define V8_UTILS_H_ 6 #define V8_UTILS_H_
7 7
8 #include <limits.h> 8 #include <limits.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 } 1545 }
1546 1546
1547 static inline uint32_t ReadUnalignedUInt32(const void* p) { 1547 static inline uint32_t ReadUnalignedUInt32(const void* p) {
1548 return ReadUnalignedValue<uint32_t>(p); 1548 return ReadUnalignedValue<uint32_t>(p);
1549 } 1549 }
1550 1550
1551 static inline void WriteUnalignedUInt32(void* p, uint32_t value) { 1551 static inline void WriteUnalignedUInt32(void* p, uint32_t value) {
1552 WriteUnalignedValue(p, value); 1552 WriteUnalignedValue(p, value);
1553 } 1553 }
1554 1554
1555 template <typename V>
1556 static inline V ReadLittleEndianValue(const void* p) {
1557 #if defined(V8_TARGET_LITTLE_ENDIAN)
1558 return ReadUnalignedValue<V>(p);
1559 #elif defined(V8_TARGET_BIG_ENDIAN)
1560 V ret = 0;
1561 const byte* src = reinterpret_cast<const byte*>(p);
1562 byte* dst = reinterpret_cast<byte*>(&ret);
1563 for (size_t i = 0; i < sizeof(V); i++) {
1564 dst[i] = src[sizeof(V) - i - 1];
1565 }
1566 return ret;
1567 #endif // V8_TARGET_LITTLE_ENDIAN
1568 }
1569
1570 template <typename V>
1571 static inline void WriteLittleEndianValue(void* p, V value) {
1572 #if defined(V8_TARGET_LITTLE_ENDIAN)
1573 WriteUnalignedValue<V>(p, value);
1574 #elif defined(V8_TARGET_BIG_ENDIAN)
1575 byte* src = reinterpret_cast<byte*>(&value);
1576 byte* dst = reinterpret_cast<byte*>(p);
1577 for (size_t i = 0; i < sizeof(V); i++) {
1578 dst[i] = src[sizeof(V) - i - 1];
1579 }
1580 #endif // V8_TARGET_LITTLE_ENDIAN
1581 }
1555 } // namespace internal 1582 } // namespace internal
1556 } // namespace v8 1583 } // namespace v8
1557 1584
1558 #endif // V8_UTILS_H_ 1585 #endif // V8_UTILS_H_
OLDNEW
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | src/wasm/decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698