mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 00:52:18 +01:00
Add slice base.u8 peek/poke methods
wuffs_png_decode_filter_1_sub/clang9 4.59GB/s ± 0% 4.59GB/s ± 0% ~ (p=0.151 n=5+5) wuffs_png_decode_filter_1_sub/gcc10 1.85GB/s ± 0% 4.11GB/s ± 0% +122.24% (p=0.016 n=5+4)
This commit is contained in:
1 parent
602b711ba6
commit
26a7280900
13 files changed
+204
-48
No files matched your search
@@ -19,6 +19,7 @@
|
|||||||
- Added `example/json-to-cbor`.
|
- Added `example/json-to-cbor`.
|
||||||
- Added `example/jsonfindptrs`.
|
- Added `example/jsonfindptrs`.
|
||||||
- Added `example/jsonptr`.
|
- Added `example/jsonptr`.
|
||||||
|
- Added `slice base.u8 peek/poke` methods.
|
||||||
- Added `std/bmp`.
|
- Added `std/bmp`.
|
||||||
- Added `std/cbor`.
|
- Added `std/cbor`.
|
||||||
- Added `std/gif.config_decoder`.
|
- Added `std/gif.config_decoder`.
|
||||||
|
|||||||
@@ -718,8 +718,14 @@ wuffs_base__poke_u16be__no_bounds_check(uint8_t* p, uint16_t x) {
|
|||||||
|
|
||||||
static inline void //
|
static inline void //
|
||||||
wuffs_base__poke_u16le__no_bounds_check(uint8_t* p, uint16_t x) {
|
wuffs_base__poke_u16le__no_bounds_check(uint8_t* p, uint16_t x) {
|
||||||
|
#if defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__)
|
||||||
|
// This seems to perform better on gcc 10 (but not clang 9). Clang also
|
||||||
|
// defines "__GNUC__".
|
||||||
|
memcpy(p, &x, 2);
|
||||||
|
#else
|
||||||
p[0] = (uint8_t)(x >> 0);
|
p[0] = (uint8_t)(x >> 0);
|
||||||
p[1] = (uint8_t)(x >> 8);
|
p[1] = (uint8_t)(x >> 8);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void //
|
static inline void //
|
||||||
@@ -746,10 +752,16 @@ wuffs_base__poke_u32be__no_bounds_check(uint8_t* p, uint32_t x) {
|
|||||||
|
|
||||||
static inline void //
|
static inline void //
|
||||||
wuffs_base__poke_u32le__no_bounds_check(uint8_t* p, uint32_t x) {
|
wuffs_base__poke_u32le__no_bounds_check(uint8_t* p, uint32_t x) {
|
||||||
|
#if defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__)
|
||||||
|
// This seems to perform better on gcc 10 (but not clang 9). Clang also
|
||||||
|
// defines "__GNUC__".
|
||||||
|
memcpy(p, &x, 4);
|
||||||
|
#else
|
||||||
p[0] = (uint8_t)(x >> 0);
|
p[0] = (uint8_t)(x >> 0);
|
||||||
p[1] = (uint8_t)(x >> 8);
|
p[1] = (uint8_t)(x >> 8);
|
||||||
p[2] = (uint8_t)(x >> 16);
|
p[2] = (uint8_t)(x >> 16);
|
||||||
p[3] = (uint8_t)(x >> 24);
|
p[3] = (uint8_t)(x >> 24);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void //
|
static inline void //
|
||||||
@@ -826,6 +838,11 @@ wuffs_base__poke_u64be__no_bounds_check(uint8_t* p, uint64_t x) {
|
|||||||
|
|
||||||
static inline void //
|
static inline void //
|
||||||
wuffs_base__poke_u64le__no_bounds_check(uint8_t* p, uint64_t x) {
|
wuffs_base__poke_u64le__no_bounds_check(uint8_t* p, uint64_t x) {
|
||||||
|
#if defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__)
|
||||||
|
// This seems to perform better on gcc 10 (but not clang 9). Clang also
|
||||||
|
// defines "__GNUC__".
|
||||||
|
memcpy(p, &x, 8);
|
||||||
|
#else
|
||||||
p[0] = (uint8_t)(x >> 0);
|
p[0] = (uint8_t)(x >> 0);
|
||||||
p[1] = (uint8_t)(x >> 8);
|
p[1] = (uint8_t)(x >> 8);
|
||||||
p[2] = (uint8_t)(x >> 16);
|
p[2] = (uint8_t)(x >> 16);
|
||||||
@@ -834,6 +851,7 @@ wuffs_base__poke_u64le__no_bounds_check(uint8_t* p, uint64_t x) {
|
|||||||
p[5] = (uint8_t)(x >> 40);
|
p[5] = (uint8_t)(x >> 40);
|
||||||
p[6] = (uint8_t)(x >> 48);
|
p[6] = (uint8_t)(x >> 48);
|
||||||
p[7] = (uint8_t)(x >> 56);
|
p[7] = (uint8_t)(x >> 56);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------
|
// --------
|
||||||
|
|||||||
@@ -591,6 +591,29 @@ func (g *gen) writeBuiltinSlice(b *buffer, recv *a.Expr, method t.ID, args []*a.
|
|||||||
b.writes(", ")
|
b.writes(", ")
|
||||||
return g.writeArgs(b, args, depth)
|
return g.writeArgs(b, args, depth)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (t.IDPeekU8 <= method) && (method <= t.IDPeekU64LE) {
|
||||||
|
b.printf("wuffs_base__%s__no_bounds_check(", method.Str(g.tm))
|
||||||
|
if err := g.writeExpr(b, recv, depth); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
b.writes(".ptr)")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t.IDPokeU8 <= method) && (method <= t.IDPokeU64LE) {
|
||||||
|
b.printf("(wuffs_base__%s__no_bounds_check(", method.Str(g.tm))
|
||||||
|
if err := g.writeExpr(b, recv, depth); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
b.writes(".ptr, ")
|
||||||
|
if err := g.writeExpr(b, args[0].AsArg().Value(), depth); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
b.writes("), wuffs_base__make_empty_struct())")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
return errNoSuchBuiltin
|
return errNoSuchBuiltin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,10 +96,11 @@ const BaseFundamentalPublicH = "" +
|
|||||||
"1]) << 32) |\n ((uint64_t)(p[2]) << 24) | ((uint64_t)(p[3]) << 16) |\n ((uint64_t)(p[4]) << 8) | ((uint64_t)(p[5]) << 0);\n}\n\nstatic inline uint64_t //\nwuffs_base__peek_u48le__no_bounds_check(const uint8_t* p) {\n return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 32) | ((uint64_t)(p[5]) << 40);\n}\n\nstatic inline uint64_t //\nwuffs_base__peek_u56be__no_bounds_check(const uint8_t* p) {\n return ((uint64_t)(p[0]) << 48) | ((uint64_t)(p[1]) << 40) |\n ((uint64_t)(p[2]) << 32) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 16) | ((uint64_t)(p[5]) << 8) |\n ((uint64_t)(p[6]) << 0);\n}\n\nstatic inline uint64_t //\nwuffs_base__peek_u56le__no_bounds_check(const uint8_t* p) {\n return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 32) | ((uint64_t)(p[5]) << 40) |\n ((uint64_t)(p[" +
|
"1]) << 32) |\n ((uint64_t)(p[2]) << 24) | ((uint64_t)(p[3]) << 16) |\n ((uint64_t)(p[4]) << 8) | ((uint64_t)(p[5]) << 0);\n}\n\nstatic inline uint64_t //\nwuffs_base__peek_u48le__no_bounds_check(const uint8_t* p) {\n return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 32) | ((uint64_t)(p[5]) << 40);\n}\n\nstatic inline uint64_t //\nwuffs_base__peek_u56be__no_bounds_check(const uint8_t* p) {\n return ((uint64_t)(p[0]) << 48) | ((uint64_t)(p[1]) << 40) |\n ((uint64_t)(p[2]) << 32) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 16) | ((uint64_t)(p[5]) << 8) |\n ((uint64_t)(p[6]) << 0);\n}\n\nstatic inline uint64_t //\nwuffs_base__peek_u56le__no_bounds_check(const uint8_t* p) {\n return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 32) | ((uint64_t)(p[5]) << 40) |\n ((uint64_t)(p[" +
|
||||||
"6]) << 48);\n}\n\nstatic inline uint64_t //\nwuffs_base__peek_u64be__no_bounds_check(const uint8_t* p) {\n return ((uint64_t)(p[0]) << 56) | ((uint64_t)(p[1]) << 48) |\n ((uint64_t)(p[2]) << 40) | ((uint64_t)(p[3]) << 32) |\n ((uint64_t)(p[4]) << 24) | ((uint64_t)(p[5]) << 16) |\n ((uint64_t)(p[6]) << 8) | ((uint64_t)(p[7]) << 0);\n}\n\nstatic inline uint64_t //\nwuffs_base__peek_u64le__no_bounds_check(const uint8_t* p) {\n return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 32) | ((uint64_t)(p[5]) << 40) |\n ((uint64_t)(p[6]) << 48) | ((uint64_t)(p[7]) << 56);\n}\n\n" +
|
"6]) << 48);\n}\n\nstatic inline uint64_t //\nwuffs_base__peek_u64be__no_bounds_check(const uint8_t* p) {\n return ((uint64_t)(p[0]) << 56) | ((uint64_t)(p[1]) << 48) |\n ((uint64_t)(p[2]) << 40) | ((uint64_t)(p[3]) << 32) |\n ((uint64_t)(p[4]) << 24) | ((uint64_t)(p[5]) << 16) |\n ((uint64_t)(p[6]) << 8) | ((uint64_t)(p[7]) << 0);\n}\n\nstatic inline uint64_t //\nwuffs_base__peek_u64le__no_bounds_check(const uint8_t* p) {\n return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 32) | ((uint64_t)(p[5]) << 40) |\n ((uint64_t)(p[6]) << 48) | ((uint64_t)(p[7]) << 56);\n}\n\n" +
|
||||||
"" +
|
"" +
|
||||||
"// --------\n\n#define wuffs_base__poke_u8be__no_bounds_check \\\n wuffs_base__poke_u8__no_bounds_check\n#define wuffs_base__poke_u8le__no_bounds_check \\\n wuffs_base__poke_u8__no_bounds_check\n\nstatic inline void //\nwuffs_base__poke_u8__no_bounds_check(uint8_t* p, uint8_t x) {\n p[0] = x;\n}\n\nstatic inline void //\nwuffs_base__poke_u16be__no_bounds_check(uint8_t* p, uint16_t x) {\n p[0] = (uint8_t)(x >> 8);\n p[1] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__poke_u16le__no_bounds_check(uint8_t* p, uint16_t x) {\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n}\n\nstatic inline void //\nwuffs_base__poke_u24be__no_bounds_check(uint8_t* p, uint32_t x) {\n p[0] = (uint8_t)(x >> 16);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__poke_u24le__no_bounds_check(uint8_t* p, uint32_t x) {\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 16);\n}\n\nstatic inline void //\nwuffs_base__poke_u32be__no_bounds_check(uint8_t* p, uint32_t " +
|
"// --------\n\n#define wuffs_base__poke_u8be__no_bounds_check \\\n wuffs_base__poke_u8__no_bounds_check\n#define wuffs_base__poke_u8le__no_bounds_check \\\n wuffs_base__poke_u8__no_bounds_check\n\nstatic inline void //\nwuffs_base__poke_u8__no_bounds_check(uint8_t* p, uint8_t x) {\n p[0] = x;\n}\n\nstatic inline void //\nwuffs_base__poke_u16be__no_bounds_check(uint8_t* p, uint16_t x) {\n p[0] = (uint8_t)(x >> 8);\n p[1] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__poke_u16le__no_bounds_check(uint8_t* p, uint16_t x) {\n#if defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__)\n // This seems to perform better on gcc 10 (but not clang 9). Clang also\n // defines \"__GNUC__\".\n memcpy(p, &x, 2);\n#else\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n#endif\n}\n\nstatic inline void //\nwuffs_base__poke_u24be__no_bounds_check(uint8_t* p, uint32_t x) {\n p[0] = (uint8_t)(x >> 16);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__poke_u24le__no_bounds_chec" +
|
||||||
"x) {\n p[0] = (uint8_t)(x >> 24);\n p[1] = (uint8_t)(x >> 16);\n p[2] = (uint8_t)(x >> 8);\n p[3] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__poke_u32le__no_bounds_check(uint8_t* p, uint32_t x) {\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 16);\n p[3] = (uint8_t)(x >> 24);\n}\n\nstatic inline void //\nwuffs_base__poke_u40be__no_bounds_check(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 32);\n p[1] = (uint8_t)(x >> 24);\n p[2] = (uint8_t)(x >> 16);\n p[3] = (uint8_t)(x >> 8);\n p[4] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__poke_u40le__no_bounds_check(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 16);\n p[3] = (uint8_t)(x >> 24);\n p[4] = (uint8_t)(x >> 32);\n}\n\nstatic inline void //\nwuffs_base__poke_u48be__no_bounds_check(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 40);\n p[1] = (uint8_t)(x >> 32);\n p[2] = (uint8_t)(x >> 24);\n p[3] = (uint8_t)(x >> 16);\n p[4] = (uint8_t)(x " +
|
"k(uint8_t* p, uint32_t x) {\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 16);\n}\n\nstatic inline void //\nwuffs_base__poke_u32be__no_bounds_check(uint8_t* p, uint32_t x) {\n p[0] = (uint8_t)(x >> 24);\n p[1] = (uint8_t)(x >> 16);\n p[2] = (uint8_t)(x >> 8);\n p[3] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__poke_u32le__no_bounds_check(uint8_t* p, uint32_t x) {\n#if defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__)\n // This seems to perform better on gcc 10 (but not clang 9). Clang also\n // defines \"__GNUC__\".\n memcpy(p, &x, 4);\n#else\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 16);\n p[3] = (uint8_t)(x >> 24);\n#endif\n}\n\nstatic inline void //\nwuffs_base__poke_u40be__no_bounds_check(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 32);\n p[1] = (uint8_t)(x >> 24);\n p[2] = (uint8_t)(x >> 16);\n p[3] = (uint8_t)(x >> 8);\n p[4] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__poke_u40le__no_bounds_chec" +
|
||||||
">> 8);\n p[5] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__poke_u48le__no_bounds_check(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 16);\n p[3] = (uint8_t)(x >> 24);\n p[4] = (uint8_t)(x >> 32);\n p[5] = (uint8_t)(x >> 40);\n}\n\nstatic inline void //\nwuffs_base__poke_u56be__no_bounds_check(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 48);\n p[1] = (uint8_t)(x >> 40);\n p[2] = (uint8_t)(x >> 32);\n p[3] = (uint8_t)(x >> 24);\n p[4] = (uint8_t)(x >> 16);\n p[5] = (uint8_t)(x >> 8);\n p[6] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__poke_u56le__no_bounds_check(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 16);\n p[3] = (uint8_t)(x >> 24);\n p[4] = (uint8_t)(x >> 32);\n p[5] = (uint8_t)(x >> 40);\n p[6] = (uint8_t)(x >> 48);\n}\n\nstatic inline void //\nwuffs_base__poke_u64be__no_bounds_check(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 56);\n p[1] = (uint8_t)" +
|
"k(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 16);\n p[3] = (uint8_t)(x >> 24);\n p[4] = (uint8_t)(x >> 32);\n}\n\nstatic inline void //\nwuffs_base__poke_u48be__no_bounds_check(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 40);\n p[1] = (uint8_t)(x >> 32);\n p[2] = (uint8_t)(x >> 24);\n p[3] = (uint8_t)(x >> 16);\n p[4] = (uint8_t)(x >> 8);\n p[5] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__poke_u48le__no_bounds_check(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 16);\n p[3] = (uint8_t)(x >> 24);\n p[4] = (uint8_t)(x >> 32);\n p[5] = (uint8_t)(x >> 40);\n}\n\nstatic inline void //\nwuffs_base__poke_u56be__no_bounds_check(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 48);\n p[1] = (uint8_t)(x >> 40);\n p[2] = (uint8_t)(x >> 32);\n p[3] = (uint8_t)(x >> 24);\n p[4] = (uint8_t)(x >> 16);\n p[5] = (uint8_t)(x >> 8);\n p[6] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_" +
|
||||||
"(x >> 48);\n p[2] = (uint8_t)(x >> 40);\n p[3] = (uint8_t)(x >> 32);\n p[4] = (uint8_t)(x >> 24);\n p[5] = (uint8_t)(x >> 16);\n p[6] = (uint8_t)(x >> 8);\n p[7] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__poke_u64le__no_bounds_check(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 16);\n p[3] = (uint8_t)(x >> 24);\n p[4] = (uint8_t)(x >> 32);\n p[5] = (uint8_t)(x >> 40);\n p[6] = (uint8_t)(x >> 48);\n p[7] = (uint8_t)(x >> 56);\n}\n\n" +
|
"base__poke_u56le__no_bounds_check(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 16);\n p[3] = (uint8_t)(x >> 24);\n p[4] = (uint8_t)(x >> 32);\n p[5] = (uint8_t)(x >> 40);\n p[6] = (uint8_t)(x >> 48);\n}\n\nstatic inline void //\nwuffs_base__poke_u64be__no_bounds_check(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 56);\n p[1] = (uint8_t)(x >> 48);\n p[2] = (uint8_t)(x >> 40);\n p[3] = (uint8_t)(x >> 32);\n p[4] = (uint8_t)(x >> 24);\n p[5] = (uint8_t)(x >> 16);\n p[6] = (uint8_t)(x >> 8);\n p[7] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__poke_u64le__no_bounds_check(uint8_t* p, uint64_t x) {\n#if defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__)\n // This seems to perform better on gcc 10 (but not clang 9). Clang also\n // defines \"__GNUC__\".\n memcpy(p, &x, 8);\n#else\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 16);\n p[3] = (uint8_t)(x >> 24);\n p[4] = (uint8_t)(x >> 32);\n p[5] = (uin" +
|
||||||
|
"t8_t)(x >> 40);\n p[6] = (uint8_t)(x >> 48);\n p[7] = (uint8_t)(x >> 56);\n#endif\n}\n\n" +
|
||||||
"" +
|
"" +
|
||||||
"// --------\n\n// Load and Store functions are deprecated. Use Peek and Poke instead.\n\n#define wuffs_base__load_u8__no_bounds_check \\\n wuffs_base__peek_u8__no_bounds_check\n#define wuffs_base__load_u16be__no_bounds_check \\\n wuffs_base__peek_u16be__no_bounds_check\n#define wuffs_base__load_u16le__no_bounds_check \\\n wuffs_base__peek_u16le__no_bounds_check\n#define wuffs_base__load_u24be__no_bounds_check \\\n wuffs_base__peek_u24be__no_bounds_check\n#define wuffs_base__load_u24le__no_bounds_check \\\n wuffs_base__peek_u24le__no_bounds_check\n#define wuffs_base__load_u32be__no_bounds_check \\\n wuffs_base__peek_u32be__no_bounds_check\n#define wuffs_base__load_u32le__no_bounds_check \\\n wuffs_base__peek_u32le__no_bounds_check\n#define wuffs_base__load_u40be__no_bounds_check \\\n wuffs_base__peek_u40be__no_bounds_check\n#define wuffs_base__load_u40le__no_bounds_check \\\n wuffs_base__peek_u40le__no_bounds_check\n#define wuffs_base__load_u48be__no_bounds_check \\\n wuffs_base__peek_u48be__no_bounds_check\n#define wuffs_base__load_" +
|
"// --------\n\n// Load and Store functions are deprecated. Use Peek and Poke instead.\n\n#define wuffs_base__load_u8__no_bounds_check \\\n wuffs_base__peek_u8__no_bounds_check\n#define wuffs_base__load_u16be__no_bounds_check \\\n wuffs_base__peek_u16be__no_bounds_check\n#define wuffs_base__load_u16le__no_bounds_check \\\n wuffs_base__peek_u16le__no_bounds_check\n#define wuffs_base__load_u24be__no_bounds_check \\\n wuffs_base__peek_u24be__no_bounds_check\n#define wuffs_base__load_u24le__no_bounds_check \\\n wuffs_base__peek_u24le__no_bounds_check\n#define wuffs_base__load_u32be__no_bounds_check \\\n wuffs_base__peek_u32be__no_bounds_check\n#define wuffs_base__load_u32le__no_bounds_check \\\n wuffs_base__peek_u32le__no_bounds_check\n#define wuffs_base__load_u40be__no_bounds_check \\\n wuffs_base__peek_u40be__no_bounds_check\n#define wuffs_base__load_u40le__no_bounds_check \\\n wuffs_base__peek_u40le__no_bounds_check\n#define wuffs_base__load_u48be__no_bounds_check \\\n wuffs_base__peek_u48be__no_bounds_check\n#define wuffs_base__load_" +
|
||||||
"u48le__no_bounds_check \\\n wuffs_base__peek_u48le__no_bounds_check\n#define wuffs_base__load_u56be__no_bounds_check \\\n wuffs_base__peek_u56be__no_bounds_check\n#define wuffs_base__load_u56le__no_bounds_check \\\n wuffs_base__peek_u56le__no_bounds_check\n#define wuffs_base__load_u64be__no_bounds_check \\\n wuffs_base__peek_u64be__no_bounds_check\n#define wuffs_base__load_u64le__no_bounds_check \\\n wuffs_base__peek_u64le__no_bounds_check\n\n#define wuffs_base__store_u8__no_bounds_check \\\n wuffs_base__poke_u8__no_bounds_check\n#define wuffs_base__store_u16be__no_bounds_check \\\n wuffs_base__poke_u16be__no_bounds_check\n#define wuffs_base__store_u16le__no_bounds_check \\\n wuffs_base__poke_u16le__no_bounds_check\n#define wuffs_base__store_u24be__no_bounds_check \\\n wuffs_base__poke_u24be__no_bounds_check\n#define wuffs_base__store_u24le__no_bounds_check \\\n wuffs_base__poke_u24le__no_bounds_check\n#define wuffs_base__store_u32be__no_bounds_check \\\n wuffs_base__poke_u32be__no_bounds_check\n#define wuffs_base__store_u32le__no_" +
|
"u48le__no_bounds_check \\\n wuffs_base__peek_u48le__no_bounds_check\n#define wuffs_base__load_u56be__no_bounds_check \\\n wuffs_base__peek_u56be__no_bounds_check\n#define wuffs_base__load_u56le__no_bounds_check \\\n wuffs_base__peek_u56le__no_bounds_check\n#define wuffs_base__load_u64be__no_bounds_check \\\n wuffs_base__peek_u64be__no_bounds_check\n#define wuffs_base__load_u64le__no_bounds_check \\\n wuffs_base__peek_u64le__no_bounds_check\n\n#define wuffs_base__store_u8__no_bounds_check \\\n wuffs_base__poke_u8__no_bounds_check\n#define wuffs_base__store_u16be__no_bounds_check \\\n wuffs_base__poke_u16be__no_bounds_check\n#define wuffs_base__store_u16le__no_bounds_check \\\n wuffs_base__poke_u16le__no_bounds_check\n#define wuffs_base__store_u24be__no_bounds_check \\\n wuffs_base__poke_u24be__no_bounds_check\n#define wuffs_base__store_u24le__no_bounds_check \\\n wuffs_base__poke_u24le__no_bounds_check\n#define wuffs_base__store_u32be__no_bounds_check \\\n wuffs_base__poke_u32be__no_bounds_check\n#define wuffs_base__store_u32le__no_" +
|
||||||
|
|||||||
@@ -608,6 +608,40 @@ var SliceFuncs = []string{
|
|||||||
"GENERIC T1.suffix(up_to: u64) T1",
|
"GENERIC T1.suffix(up_to: u64) T1",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var SliceU8Funcs = []string{
|
||||||
|
"GENERIC T1.peek_u8() u8",
|
||||||
|
"GENERIC T1.peek_u16be() u16",
|
||||||
|
"GENERIC T1.peek_u16le() u16",
|
||||||
|
"GENERIC T1.peek_u24be() u32",
|
||||||
|
"GENERIC T1.peek_u24le() u32",
|
||||||
|
"GENERIC T1.peek_u32be() u32",
|
||||||
|
"GENERIC T1.peek_u32le() u32",
|
||||||
|
"GENERIC T1.peek_u40be() u64",
|
||||||
|
"GENERIC T1.peek_u40le() u64",
|
||||||
|
"GENERIC T1.peek_u48be() u64",
|
||||||
|
"GENERIC T1.peek_u48le() u64",
|
||||||
|
"GENERIC T1.peek_u56be() u64",
|
||||||
|
"GENERIC T1.peek_u56le() u64",
|
||||||
|
"GENERIC T1.peek_u64be() u64",
|
||||||
|
"GENERIC T1.peek_u64le() u64",
|
||||||
|
|
||||||
|
"GENERIC T1.poke_u8!(a: u8)",
|
||||||
|
"GENERIC T1.poke_u16be!(a: u16)",
|
||||||
|
"GENERIC T1.poke_u16le!(a: u16)",
|
||||||
|
"GENERIC T1.poke_u24be!(a: u32)",
|
||||||
|
"GENERIC T1.poke_u24le!(a: u32)",
|
||||||
|
"GENERIC T1.poke_u32be!(a: u32)",
|
||||||
|
"GENERIC T1.poke_u32le!(a: u32)",
|
||||||
|
"GENERIC T1.poke_u40be!(a: u64)",
|
||||||
|
"GENERIC T1.poke_u40le!(a: u64)",
|
||||||
|
"GENERIC T1.poke_u48be!(a: u64)",
|
||||||
|
"GENERIC T1.poke_u48le!(a: u64)",
|
||||||
|
"GENERIC T1.poke_u56be!(a: u64)",
|
||||||
|
"GENERIC T1.poke_u56le!(a: u64)",
|
||||||
|
"GENERIC T1.poke_u64be!(a: u64)",
|
||||||
|
"GENERIC T1.poke_u64le!(a: u64)",
|
||||||
|
}
|
||||||
|
|
||||||
var TableFuncs = []string{
|
var TableFuncs = []string{
|
||||||
"GENERIC T2.height() u64",
|
"GENERIC T2.height() u64",
|
||||||
"GENERIC T2.stride() u64",
|
"GENERIC T2.stride() u64",
|
||||||
|
|||||||
+39
-15
@@ -1051,6 +1051,8 @@ func (q *checker) bcheckExprCallSpecialCases(n *a.Expr, depth uint32) (bounds, e
|
|||||||
recv := lhs.LHS().AsExpr()
|
recv := lhs.LHS().AsExpr()
|
||||||
method := lhs.Ident()
|
method := lhs.Ident()
|
||||||
|
|
||||||
|
advance, advanceExpr, update := (*big.Int)(nil), (*a.Expr)(nil), false
|
||||||
|
|
||||||
if recvTyp := recv.MType(); recvTyp == nil {
|
if recvTyp := recv.MType(); recvTyp == nil {
|
||||||
return bounds{}, errNotASpecialCase
|
return bounds{}, errNotASpecialCase
|
||||||
|
|
||||||
@@ -1094,8 +1096,6 @@ func (q *checker) bcheckExprCallSpecialCases(n *a.Expr, depth uint32) (bounds, e
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if recvTyp.IsIOTokenType() {
|
} else if recvTyp.IsIOTokenType() {
|
||||||
advance, advanceExpr, update := (*big.Int)(nil), (*a.Expr)(nil), false
|
|
||||||
|
|
||||||
if method == t.IDUndoByte {
|
if method == t.IDUndoByte {
|
||||||
if err := q.canUndoByte(recv); err != nil {
|
if err := q.canUndoByte(recv); err != nil {
|
||||||
return bounds{}, err
|
return bounds{}, err
|
||||||
@@ -1146,23 +1146,31 @@ func (q *checker) bcheckExprCallSpecialCases(n *a.Expr, depth uint32) (bounds, e
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (advance != nil) || (advanceExpr != nil) {
|
} else if recvTyp.Eq(typeExprSliceU8) {
|
||||||
if ok, err := q.optimizeIOMethodAdvance(recv, advance, advanceExpr, update); err != nil {
|
if method >= t.IDPeekU8 {
|
||||||
return bounds{}, err
|
if m := method - t.IDPeekU8; m < t.ID(len(ioMethodAdvances)) {
|
||||||
} else if !ok {
|
au := ioMethodAdvances[m]
|
||||||
adv := ""
|
advance, update = au.advance, au.update
|
||||||
if advance != nil {
|
|
||||||
adv = advance.String()
|
|
||||||
} else {
|
|
||||||
adv = advanceExpr.Str(q.tm)
|
|
||||||
}
|
|
||||||
return bounds{}, fmt.Errorf("check: could not prove %s pre-condition: %s.length() >= %s",
|
|
||||||
method.Str(q.tm), recv.Str(q.tm), adv)
|
|
||||||
}
|
}
|
||||||
// TODO: drop other recv-related facts?
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (advance != nil) || (advanceExpr != nil) {
|
||||||
|
if ok, err := q.optimizeIOMethodAdvance(recv, advance, advanceExpr, update); err != nil {
|
||||||
|
return bounds{}, err
|
||||||
|
} else if !ok {
|
||||||
|
adv := ""
|
||||||
|
if advance != nil {
|
||||||
|
adv = advance.String()
|
||||||
|
} else {
|
||||||
|
adv = advanceExpr.Str(q.tm)
|
||||||
|
}
|
||||||
|
return bounds{}, fmt.Errorf("check: could not prove %s pre-condition: %s.length() >= %s",
|
||||||
|
method.Str(q.tm), recv.Str(q.tm), adv)
|
||||||
|
}
|
||||||
|
// TODO: drop other recv-related facts?
|
||||||
|
}
|
||||||
|
|
||||||
return bounds{}, errNotASpecialCase
|
return bounds{}, errNotASpecialCase
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1319,6 +1327,22 @@ var ioMethodAdvances = [...]struct {
|
|||||||
t.IDPeekU64BE - t.IDPeekU8: {eight, false},
|
t.IDPeekU64BE - t.IDPeekU8: {eight, false},
|
||||||
t.IDPeekU64LE - t.IDPeekU8: {eight, false},
|
t.IDPeekU64LE - t.IDPeekU8: {eight, false},
|
||||||
|
|
||||||
|
t.IDPokeU8 - t.IDPeekU8: {one, false},
|
||||||
|
t.IDPokeU16BE - t.IDPeekU8: {two, false},
|
||||||
|
t.IDPokeU16LE - t.IDPeekU8: {two, false},
|
||||||
|
t.IDPokeU24BE - t.IDPeekU8: {three, false},
|
||||||
|
t.IDPokeU24LE - t.IDPeekU8: {three, false},
|
||||||
|
t.IDPokeU32BE - t.IDPeekU8: {four, false},
|
||||||
|
t.IDPokeU32LE - t.IDPeekU8: {four, false},
|
||||||
|
t.IDPokeU40BE - t.IDPeekU8: {five, false},
|
||||||
|
t.IDPokeU40LE - t.IDPeekU8: {five, false},
|
||||||
|
t.IDPokeU48BE - t.IDPeekU8: {six, false},
|
||||||
|
t.IDPokeU48LE - t.IDPeekU8: {six, false},
|
||||||
|
t.IDPokeU56BE - t.IDPeekU8: {seven, false},
|
||||||
|
t.IDPokeU56LE - t.IDPeekU8: {seven, false},
|
||||||
|
t.IDPokeU64BE - t.IDPeekU8: {eight, false},
|
||||||
|
t.IDPokeU64LE - t.IDPeekU8: {eight, false},
|
||||||
|
|
||||||
t.IDWriteU8Fast - t.IDPeekU8: {one, true},
|
t.IDWriteU8Fast - t.IDPeekU8: {one, true},
|
||||||
t.IDWriteU16BEFast - t.IDPeekU8: {two, true},
|
t.IDWriteU16BEFast - t.IDPeekU8: {two, true},
|
||||||
t.IDWriteU16LEFast - t.IDPeekU8: {two, true},
|
t.IDWriteU16LEFast - t.IDPeekU8: {two, true},
|
||||||
|
|||||||
+9
-4
@@ -91,8 +91,9 @@ func Check(tm *t.Map, files []*a.File, resolveUse func(usePath string) ([]byte,
|
|||||||
funcs: map[t.QQID]*a.Func{},
|
funcs: map[t.QQID]*a.Func{},
|
||||||
localVars: map[t.QQID]typeMap{},
|
localVars: map[t.QQID]typeMap{},
|
||||||
|
|
||||||
builtInSliceFuncs: map[t.QQID]*a.Func{},
|
builtInSliceFuncs: map[t.QQID]*a.Func{},
|
||||||
builtInTableFuncs: map[t.QQID]*a.Func{},
|
builtInSliceU8Funcs: map[t.QQID]*a.Func{},
|
||||||
|
builtInTableFuncs: map[t.QQID]*a.Func{},
|
||||||
|
|
||||||
builtInInterfaces: map[t.QID][]t.QQID{},
|
builtInInterfaces: map[t.QID][]t.QQID{},
|
||||||
builtInInterfaceFuncs: map[t.QQID]*a.Func{},
|
builtInInterfaceFuncs: map[t.QQID]*a.Func{},
|
||||||
@@ -105,6 +106,9 @@ func Check(tm *t.Map, files []*a.File, resolveUse func(usePath string) ([]byte,
|
|||||||
if err := c.parseBuiltInFuncs(c.builtInSliceFuncs, builtin.SliceFuncs); err != nil {
|
if err := c.parseBuiltInFuncs(c.builtInSliceFuncs, builtin.SliceFuncs); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if err := c.parseBuiltInFuncs(c.builtInSliceU8Funcs, builtin.SliceU8Funcs); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if err := c.parseBuiltInFuncs(c.builtInTableFuncs, builtin.TableFuncs); err != nil {
|
if err := c.parseBuiltInFuncs(c.builtInTableFuncs, builtin.TableFuncs); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -221,8 +225,9 @@ type Checker struct {
|
|||||||
funcs map[t.QQID]*a.Func
|
funcs map[t.QQID]*a.Func
|
||||||
localVars map[t.QQID]typeMap
|
localVars map[t.QQID]typeMap
|
||||||
|
|
||||||
builtInSliceFuncs map[t.QQID]*a.Func
|
builtInSliceFuncs map[t.QQID]*a.Func
|
||||||
builtInTableFuncs map[t.QQID]*a.Func
|
builtInSliceU8Funcs map[t.QQID]*a.Func
|
||||||
|
builtInTableFuncs map[t.QQID]*a.Func
|
||||||
|
|
||||||
builtInInterfaces map[t.QID][]t.QQID
|
builtInInterfaces map[t.QID][]t.QQID
|
||||||
builtInInterfaceFuncs map[t.QQID]*a.Func
|
builtInInterfaceFuncs map[t.QQID]*a.Func
|
||||||
|
|||||||
@@ -58,7 +58,9 @@ func (q *checker) optimizeIOMethodAdvance(receiver *a.Expr, advance *big.Int, ad
|
|||||||
// receiver.length(), even if they aren't an exact match.
|
// receiver.length(), even if they aren't an exact match.
|
||||||
|
|
||||||
op := x.Operator()
|
op := x.Operator()
|
||||||
if op != t.IDXBinaryGreaterEq && op != t.IDXBinaryGreaterThan {
|
if (op != t.IDXBinaryGreaterEq) &&
|
||||||
|
(op != t.IDXBinaryGreaterThan) &&
|
||||||
|
(op != t.IDXBinaryEqEq) {
|
||||||
return x, nil
|
return x, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -154,6 +154,11 @@ func (c *Checker) resolveFunc(typ *a.TypeExpr) (*a.Func, error) {
|
|||||||
if f := c.builtInSliceFuncs[qqid]; f != nil {
|
if f := c.builtInSliceFuncs[qqid]; f != nil {
|
||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
|
if lTyp.Eq(typeExprSliceU8) {
|
||||||
|
if f := c.builtInSliceU8Funcs[qqid]; f != nil {
|
||||||
|
return f, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else if lTyp.IsTableType() {
|
} else if lTyp.IsTableType() {
|
||||||
qqid[0] = t.IDBase
|
qqid[0] = t.IDBase
|
||||||
|
|||||||
+9
-8
@@ -665,20 +665,21 @@ func (q *checker) tcheckDot(n *a.Expr, depth uint32) error {
|
|||||||
if lTyp.IsSliceType() {
|
if lTyp.IsSliceType() {
|
||||||
qqid[0] = t.IDBase
|
qqid[0] = t.IDBase
|
||||||
qqid[1] = t.IDDagger1
|
qqid[1] = t.IDDagger1
|
||||||
if q.c.builtInSliceFuncs[qqid] == nil {
|
if (q.c.builtInSliceFuncs[qqid] != nil) ||
|
||||||
return fmt.Errorf("check: no slice method %q", n.Ident().Str(q.tm))
|
((q.c.builtInSliceU8Funcs[qqid] != nil) && lTyp.Eq(typeExprSliceU8)) {
|
||||||
|
n.SetMType(a.NewTypeExpr(t.IDFunc, 0, n.Ident(), lTyp.AsNode(), nil, nil))
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
n.SetMType(a.NewTypeExpr(t.IDFunc, 0, n.Ident(), lTyp.AsNode(), nil, nil))
|
return fmt.Errorf("check: no slice method %q", n.Ident().Str(q.tm))
|
||||||
return nil
|
|
||||||
|
|
||||||
} else if lTyp.IsTableType() {
|
} else if lTyp.IsTableType() {
|
||||||
qqid[0] = t.IDBase
|
qqid[0] = t.IDBase
|
||||||
qqid[1] = t.IDDagger2
|
qqid[1] = t.IDDagger2
|
||||||
if q.c.builtInTableFuncs[qqid] == nil {
|
if q.c.builtInTableFuncs[qqid] != nil {
|
||||||
return fmt.Errorf("check: no table method %q", n.Ident().Str(q.tm))
|
n.SetMType(a.NewTypeExpr(t.IDFunc, 0, n.Ident(), lTyp.AsNode(), nil, nil))
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
n.SetMType(a.NewTypeExpr(t.IDFunc, 0, n.Ident(), lTyp.AsNode(), nil, nil))
|
return fmt.Errorf("check: no table method %q", n.Ident().Str(q.tm))
|
||||||
return nil
|
|
||||||
|
|
||||||
} else if lTyp.Decorator() != 0 {
|
} else if lTyp.Decorator() != 0 {
|
||||||
return fmt.Errorf("check: invalid type %q for dot-expression LHS %q", lTyp.Str(q.tm), lhs.Str(q.tm))
|
return fmt.Errorf("check: invalid type %q for dot-expression LHS %q", lTyp.Str(q.tm), lhs.Str(q.tm))
|
||||||
|
|||||||
@@ -582,6 +582,24 @@ const (
|
|||||||
|
|
||||||
// --------
|
// --------
|
||||||
|
|
||||||
|
IDPokeU8 = ID(0x1D1)
|
||||||
|
IDPokeU16BE = ID(0x1D2)
|
||||||
|
IDPokeU16LE = ID(0x1D3)
|
||||||
|
IDPokeU24BE = ID(0x1D4)
|
||||||
|
IDPokeU24LE = ID(0x1D5)
|
||||||
|
IDPokeU32BE = ID(0x1D6)
|
||||||
|
IDPokeU32LE = ID(0x1D7)
|
||||||
|
IDPokeU40BE = ID(0x1D8)
|
||||||
|
IDPokeU40LE = ID(0x1D9)
|
||||||
|
IDPokeU48BE = ID(0x1DA)
|
||||||
|
IDPokeU48LE = ID(0x1DB)
|
||||||
|
IDPokeU56BE = ID(0x1DC)
|
||||||
|
IDPokeU56LE = ID(0x1DD)
|
||||||
|
IDPokeU64BE = ID(0x1DE)
|
||||||
|
IDPokeU64LE = ID(0x1DF)
|
||||||
|
|
||||||
|
// --------
|
||||||
|
|
||||||
IDWriteU8Fast = ID(0x1E1)
|
IDWriteU8Fast = ID(0x1E1)
|
||||||
IDWriteU16BEFast = ID(0x1E2)
|
IDWriteU16BEFast = ID(0x1E2)
|
||||||
IDWriteU16LEFast = ID(0x1E3)
|
IDWriteU16LEFast = ID(0x1E3)
|
||||||
@@ -969,6 +987,24 @@ var builtInsByID = [nBuiltInIDs]string{
|
|||||||
|
|
||||||
// --------
|
// --------
|
||||||
|
|
||||||
|
IDPokeU8: "poke_u8",
|
||||||
|
IDPokeU16BE: "poke_u16be",
|
||||||
|
IDPokeU16LE: "poke_u16le",
|
||||||
|
IDPokeU24BE: "poke_u24be",
|
||||||
|
IDPokeU24LE: "poke_u24le",
|
||||||
|
IDPokeU32BE: "poke_u32be",
|
||||||
|
IDPokeU32LE: "poke_u32le",
|
||||||
|
IDPokeU40BE: "poke_u40be",
|
||||||
|
IDPokeU40LE: "poke_u40le",
|
||||||
|
IDPokeU48BE: "poke_u48be",
|
||||||
|
IDPokeU48LE: "poke_u48le",
|
||||||
|
IDPokeU56BE: "poke_u56be",
|
||||||
|
IDPokeU56LE: "poke_u56le",
|
||||||
|
IDPokeU64BE: "poke_u64be",
|
||||||
|
IDPokeU64LE: "poke_u64le",
|
||||||
|
|
||||||
|
// --------
|
||||||
|
|
||||||
IDWriteU8Fast: "write_u8_fast",
|
IDWriteU8Fast: "write_u8_fast",
|
||||||
IDWriteU16BEFast: "write_u16be_fast",
|
IDWriteU16BEFast: "write_u16be_fast",
|
||||||
IDWriteU16LEFast: "write_u16le_fast",
|
IDWriteU16LEFast: "write_u16le_fast",
|
||||||
|
|||||||
@@ -792,8 +792,14 @@ wuffs_base__poke_u16be__no_bounds_check(uint8_t* p, uint16_t x) {
|
|||||||
|
|
||||||
static inline void //
|
static inline void //
|
||||||
wuffs_base__poke_u16le__no_bounds_check(uint8_t* p, uint16_t x) {
|
wuffs_base__poke_u16le__no_bounds_check(uint8_t* p, uint16_t x) {
|
||||||
|
#if defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__)
|
||||||
|
// This seems to perform better on gcc 10 (but not clang 9). Clang also
|
||||||
|
// defines "__GNUC__".
|
||||||
|
memcpy(p, &x, 2);
|
||||||
|
#else
|
||||||
p[0] = (uint8_t)(x >> 0);
|
p[0] = (uint8_t)(x >> 0);
|
||||||
p[1] = (uint8_t)(x >> 8);
|
p[1] = (uint8_t)(x >> 8);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void //
|
static inline void //
|
||||||
@@ -820,10 +826,16 @@ wuffs_base__poke_u32be__no_bounds_check(uint8_t* p, uint32_t x) {
|
|||||||
|
|
||||||
static inline void //
|
static inline void //
|
||||||
wuffs_base__poke_u32le__no_bounds_check(uint8_t* p, uint32_t x) {
|
wuffs_base__poke_u32le__no_bounds_check(uint8_t* p, uint32_t x) {
|
||||||
|
#if defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__)
|
||||||
|
// This seems to perform better on gcc 10 (but not clang 9). Clang also
|
||||||
|
// defines "__GNUC__".
|
||||||
|
memcpy(p, &x, 4);
|
||||||
|
#else
|
||||||
p[0] = (uint8_t)(x >> 0);
|
p[0] = (uint8_t)(x >> 0);
|
||||||
p[1] = (uint8_t)(x >> 8);
|
p[1] = (uint8_t)(x >> 8);
|
||||||
p[2] = (uint8_t)(x >> 16);
|
p[2] = (uint8_t)(x >> 16);
|
||||||
p[3] = (uint8_t)(x >> 24);
|
p[3] = (uint8_t)(x >> 24);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void //
|
static inline void //
|
||||||
@@ -900,6 +912,11 @@ wuffs_base__poke_u64be__no_bounds_check(uint8_t* p, uint64_t x) {
|
|||||||
|
|
||||||
static inline void //
|
static inline void //
|
||||||
wuffs_base__poke_u64le__no_bounds_check(uint8_t* p, uint64_t x) {
|
wuffs_base__poke_u64le__no_bounds_check(uint8_t* p, uint64_t x) {
|
||||||
|
#if defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__)
|
||||||
|
// This seems to perform better on gcc 10 (but not clang 9). Clang also
|
||||||
|
// defines "__GNUC__".
|
||||||
|
memcpy(p, &x, 8);
|
||||||
|
#else
|
||||||
p[0] = (uint8_t)(x >> 0);
|
p[0] = (uint8_t)(x >> 0);
|
||||||
p[1] = (uint8_t)(x >> 8);
|
p[1] = (uint8_t)(x >> 8);
|
||||||
p[2] = (uint8_t)(x >> 16);
|
p[2] = (uint8_t)(x >> 16);
|
||||||
@@ -908,6 +925,7 @@ wuffs_base__poke_u64le__no_bounds_check(uint8_t* p, uint64_t x) {
|
|||||||
p[5] = (uint8_t)(x >> 40);
|
p[5] = (uint8_t)(x >> 40);
|
||||||
p[6] = (uint8_t)(x >> 48);
|
p[6] = (uint8_t)(x >> 48);
|
||||||
p[7] = (uint8_t)(x >> 56);
|
p[7] = (uint8_t)(x >> 56);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------
|
// --------
|
||||||
@@ -31045,18 +31063,12 @@ wuffs_png__decoder__filter_1_distance_4_sse128(
|
|||||||
v_c.len = 4;
|
v_c.len = 4;
|
||||||
uint8_t* i_end0_c = i_slice_c.ptr + ((i_slice_c.len / 4) * 4);
|
uint8_t* i_end0_c = i_slice_c.ptr + ((i_slice_c.len / 4) * 4);
|
||||||
while (v_c.ptr < i_end0_c) {
|
while (v_c.ptr < i_end0_c) {
|
||||||
v_x32 = ((((uint32_t)(v_c.ptr[0])) << 0) |
|
v_x32 = wuffs_base__peek_u32le__no_bounds_check(v_c.ptr);
|
||||||
(((uint32_t)(v_c.ptr[1])) << 8) |
|
|
||||||
(((uint32_t)(v_c.ptr[2])) << 16) |
|
|
||||||
(((uint32_t)(v_c.ptr[3])) << 24));
|
|
||||||
(v_x128 = _mm_cvtsi32_si128((int)(v_x32)), wuffs_base__make_empty_struct());
|
(v_x128 = _mm_cvtsi32_si128((int)(v_x32)), wuffs_base__make_empty_struct());
|
||||||
v_x128 = _mm_add_epi8(v_x128, v_a128);
|
v_x128 = _mm_add_epi8(v_x128, v_a128);
|
||||||
v_a128 = v_x128;
|
v_a128 = v_x128;
|
||||||
v_x32 = ((uint32_t)(_mm_cvtsi128_si32(v_x128)));
|
v_x32 = ((uint32_t)(_mm_cvtsi128_si32(v_x128)));
|
||||||
v_c.ptr[0] = ((uint8_t)((255 & (v_x32 >> 0))));
|
(wuffs_base__poke_u32le__no_bounds_check(v_c.ptr, v_x32), wuffs_base__make_empty_struct());
|
||||||
v_c.ptr[1] = ((uint8_t)((255 & (v_x32 >> 8))));
|
|
||||||
v_c.ptr[2] = ((uint8_t)((255 & (v_x32 >> 16))));
|
|
||||||
v_c.ptr[3] = ((uint8_t)((255 & (v_x32 >> 24))));
|
|
||||||
v_c.ptr += 4;
|
v_c.ptr += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,19 +25,13 @@ pri func decoder.filter_1_distance_4_sse128!(curr: slice base.u8),
|
|||||||
var a128 : base.sse128_i
|
var a128 : base.sse128_i
|
||||||
|
|
||||||
iterate (c = args.curr)(length: 4, advance: 4, unroll: 1) {
|
iterate (c = args.curr)(length: 4, advance: 4, unroll: 1) {
|
||||||
x32 = ((c[0] as base.u32) << 0x00) |
|
x32 = c.peek_u32le()
|
||||||
((c[1] as base.u32) << 0x08) |
|
|
||||||
((c[2] as base.u32) << 0x10) |
|
|
||||||
((c[3] as base.u32) << 0x18)
|
|
||||||
x128.load_u32!(a: x32)
|
x128.load_u32!(a: x32)
|
||||||
|
|
||||||
x128 = x128._mm_add_epi8!(b: a128)
|
x128 = x128._mm_add_epi8!(b: a128)
|
||||||
a128 = x128
|
a128 = x128
|
||||||
|
|
||||||
x32 = x128.truncate_u32()
|
x32 = x128.truncate_u32()
|
||||||
c[0] = (0xFF & (x32 >> 0x00)) as base.u8
|
c.poke_u32le!(a: x32)
|
||||||
c[1] = (0xFF & (x32 >> 0x08)) as base.u8
|
|
||||||
c[2] = (0xFF & (x32 >> 0x10)) as base.u8
|
|
||||||
c[3] = (0xFF & (x32 >> 0x18)) as base.u8
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user