mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 21:27:52 -04:00
395c98db19
Started at 349,880,038 allocations and 42s - Switched to making `Symbol` in GOOS be a "fixed type", just a wrapper around a `const char*` pointing to the string in the symbol table. This is a step toward making a lot of things better, but by itself not a huge improvement. Some things may be worse due to more temp `std::string` allocations, but one day all these can be removed. On linux it saved allocations (347,685,429), and saved a second or two (41 s). - cache `#t` and `#f` in interpreter, better lookup for special forms/builtins (hashtable of pointers instead of strings, vector for the small special form list). Dropped time to 38s. - special-case in quasiquote when splicing is the last thing in a list. Allocation dropped to 340,603,082 - custom hash table for environment lookups (lexical vars). Dropped to 36s and 314,637,194 - less allocation in `read_list` 311,613,616. Time about the same. - `let` and `let*` in Interpreter.cpp 191,988,083, time down to 28s.
45 lines
808 B
C
45 lines
808 B
C
#include <cstdlib>
|
|
|
|
#include "common/common_types.h"
|
|
|
|
u32 crc32(const u8* data, size_t size);
|
|
|
|
#include <cstring>
|
|
|
|
#ifdef __aarch64__
|
|
#include <arm_acle.h>
|
|
inline u32 crc32(const u8* data, size_t size) {
|
|
u32 result = 0xffffffff;
|
|
while (size >= 4) {
|
|
u32 x;
|
|
memcpy(&x, data, 4);
|
|
data += 4;
|
|
size -= 4;
|
|
result = __crc32w(result, x);
|
|
}
|
|
while (size) {
|
|
result = __crc32b(result, *data);
|
|
data++;
|
|
size--;
|
|
}
|
|
return ~result;
|
|
}
|
|
#else
|
|
#include <immintrin.h>
|
|
inline u32 crc32(const u8* data, size_t size) {
|
|
u32 result = 0xffffffff;
|
|
while (size >= 4) {
|
|
u32 x;
|
|
memcpy(&x, data, 4);
|
|
data += 4;
|
|
size -= 4;
|
|
result = _mm_crc32_u32(result, x);
|
|
}
|
|
while (size) {
|
|
result = _mm_crc32_u8(result, *data);
|
|
data++;
|
|
size--;
|
|
}
|
|
return ~result;
|
|
}
|
|
#endif |