Improve redbean plus code size optimizations

This change turns symbol table compression back on using Puff, which
noticeably reduces the size of programs like redbean and Python. The
redbean web server receives some minor API additions for controlling
things like SSL in addition to filling gaps in the documentation.
This commit is contained in:
Justine Tunney 2022-05-29 08:14:55 -07:00
parent 425ff5dff0
commit 13ee75150c
58 changed files with 2077 additions and 589 deletions

View file

@ -22,13 +22,14 @@
#include "libc/calls/strace.internal.h"
#include "libc/intrin/spinlock.h"
#include "libc/macros.internal.h"
#include "libc/runtime/internal.h"
#include "libc/runtime/runtime.h"
#include "libc/runtime/symbols.internal.h"
#include "libc/str/str.h"
#include "libc/str/undeflate.h"
#include "libc/x/x.h"
#include "libc/zip.h"
#include "libc/zipos/zipos.internal.h"
#include "third_party/zlib/puff.h"
static int g_lock;
hidden struct SymbolTable *__symtab; // for kprintf
@ -56,9 +57,8 @@ static ssize_t FindSymtabInZip(struct Zipos *zipos) {
* @note This code can't depend on dlmalloc()
*/
static struct SymbolTable *GetSymbolTableFromZip(struct Zipos *zipos) {
ssize_t rc, cf, lf;
size_t size, size2;
struct DeflateState ds;
ssize_t rc, cf, lf;
struct SymbolTable *res = 0;
if ((cf = FindSymtabInZip(zipos)) != -1) {
lf = GetZipCfileOffset(zipos->map + cf);
@ -69,17 +69,14 @@ static struct SymbolTable *GetSymbolTableFromZip(struct Zipos *zipos) {
case kZipCompressionNone:
memcpy(res, (void *)ZIP_LFILE_CONTENT(zipos->map + lf), size);
break;
#if 0
// TODO(jart): fix me
case kZipCompressionDeflate:
rc = undeflate(res, size, (void *)ZIP_LFILE_CONTENT(zipos->map + lf),
GetZipLfileCompressedSize(zipos->map + lf), &ds);
if (rc == -1) {
if (__inflate((void *)res, size,
(void *)ZIP_LFILE_CONTENT(zipos->map + lf),
GetZipLfileCompressedSize(zipos->map + lf))) {
munmap(res, size2);
res = 0;
}
break;
#endif
default:
munmap(res, size2);
res = 0;