Add ability to (de)serialize symbols

Fixes: https://github.com/quickjs-ng/quickjs/issues/481
This commit is contained in:
Saúl Ibarra Corretgé authored and GitHub committed 2024-09-24 10:01:08 +02:00
1 parent d9a43d5a82
commit c25aad7b49
7 files changed
+3087 -2948

No files matched your search

+51 -50
View File
@@ -2,57 +2,58 @@
#include "quickjs-libc.h"
const uint32_t qjsc_function_source_size = 384;
const uint32_t qjsc_function_source_size = 390;
const uint8_t qjsc_function_source[384] = {
0x0e, 0x06, 0x0c, 0x61, 0x63, 0x74, 0x75, 0x61,
0x6c, 0x02, 0x66, 0x30, 0x74, 0x65, 0x73, 0x74,
0x73, 0x2f, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69,
0x6f, 0x6e, 0x5f, 0x73, 0x6f, 0x75, 0x72, 0x63,
0x65, 0x2e, 0x6a, 0x73, 0x0c, 0x65, 0x78, 0x70,
0x65, 0x63, 0x74, 0x14, 0x75, 0x73, 0x65, 0x20,
0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x34, 0x66,
0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20,
0x66, 0x28, 0x29, 0x20, 0x7b, 0x20, 0x72, 0x65,
0x74, 0x75, 0x72, 0x6e, 0x20, 0x34, 0x32, 0x20,
0x7d, 0x0c, 0x00, 0xfa, 0x01, 0xa2, 0x01, 0x00,
0x06, 0x00, 0x03, 0x00, 0x01, 0xa0, 0x01, 0x06,
0xa4, 0x01, 0x00, 0x00, 0x00, 0xb8, 0x03, 0x02,
0x00, 0x30, 0xba, 0x03, 0x04, 0x00, 0x70, 0xb8,
0x03, 0x04, 0x03, 0x70, 0x10, 0x00, 0x01, 0x00,
0xe4, 0x01, 0x00, 0x01, 0x00, 0x0c, 0x43, 0xfa,
0x01, 0xba, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00,
0x00, 0x03, 0x00, 0xbb, 0x2a, 0x28, 0xbc, 0x03,
0x03, 0x01, 0x04, 0x02, 0x1e, 0x0c, 0x0e, 0x1a,
0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
0x20, 0x66, 0x28, 0x29, 0x20, 0x7b, 0x20, 0x72,
0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x34, 0x32,
0x20, 0x7d, 0x0c, 0x03, 0xc1, 0x05, 0x08, 0xc1,
0x04, 0x3f, 0xdf, 0x00, 0x00, 0x00, 0x80, 0x3f,
0xdd, 0x00, 0x00, 0x00, 0x40, 0x3e, 0xdf, 0x00,
0x00, 0x00, 0x80, 0xbe, 0x00, 0x40, 0xdd, 0x00,
0x00, 0x00, 0x00, 0x04, 0xe0, 0x00, 0x00, 0x00,
0xc8, 0x04, 0xe1, 0x00, 0x00, 0x00, 0x3a, 0xdf,
0x00, 0x00, 0x00, 0x61, 0x01, 0x00, 0x38, 0xdd,
0x00, 0x00, 0x00, 0x42, 0x38, 0x00, 0x00, 0x00,
0x24, 0x00, 0x00, 0xc9, 0x06, 0xc8, 0x62, 0x01,
0x00, 0x38, 0xdf, 0x00, 0x00, 0x00, 0xaf, 0xe9,
0x0b, 0x38, 0x94, 0x00, 0x00, 0x00, 0x62, 0x01,
0x00, 0xee, 0x2f, 0x61, 0x03, 0x00, 0x61, 0x02,
0x00, 0x38, 0x3b, 0x00, 0x00, 0x00, 0x38, 0xdf,
0x00, 0x00, 0x00, 0x04, 0xdd, 0x00, 0x00, 0x00,
0x9d, 0x31, 0x01, 0x00, 0x04, 0x00, 0xca, 0x62,
0x02, 0x00, 0x42, 0x38, 0x00, 0x00, 0x00, 0x24,
0x00, 0x00, 0xcb, 0x06, 0xc8, 0x62, 0x03, 0x00,
0x38, 0xdf, 0x00, 0x00, 0x00, 0xaf, 0xe9, 0x0b,
0x38, 0x94, 0x00, 0x00, 0x00, 0x62, 0x03, 0x00,
0xee, 0x2f, 0x68, 0x03, 0x00, 0x68, 0x02, 0x00,
0xc4, 0x28, 0xbc, 0x03, 0x01, 0x01, 0x28, 0x60,
0x01, 0x49, 0x02, 0x21, 0x1a, 0x1b, 0x04, 0x1e,
0x1d, 0x12, 0x26, 0x49, 0x1d, 0x0c, 0x06, 0x11,
0x18, 0x2a, 0x1c, 0x37, 0x41, 0x21, 0x1c, 0x34,
0x18, 0x1b, 0x04, 0x26, 0x11, 0x3f, 0x1d, 0x0c,
0x06, 0x11, 0x18, 0x2a, 0x1c, 0x53, 0x41, 0x00,
const uint8_t qjsc_function_source[390] = {
0x0f, 0x06, 0x01, 0x0c, 0x61, 0x63, 0x74, 0x75,
0x61, 0x6c, 0x01, 0x02, 0x66, 0x01, 0x30, 0x74,
0x65, 0x73, 0x74, 0x73, 0x2f, 0x66, 0x75, 0x6e,
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x6f,
0x75, 0x72, 0x63, 0x65, 0x2e, 0x6a, 0x73, 0x01,
0x0c, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x01,
0x14, 0x75, 0x73, 0x65, 0x20, 0x73, 0x74, 0x72,
0x69, 0x63, 0x74, 0x01, 0x34, 0x66, 0x75, 0x6e,
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x66, 0x28,
0x29, 0x20, 0x7b, 0x20, 0x72, 0x65, 0x74, 0x75,
0x72, 0x6e, 0x20, 0x34, 0x32, 0x20, 0x7d, 0x0c,
0x00, 0xfa, 0x01, 0xa2, 0x01, 0x00, 0x06, 0x00,
0x03, 0x00, 0x01, 0xa0, 0x01, 0x06, 0xa4, 0x01,
0x00, 0x00, 0x00, 0xb8, 0x03, 0x02, 0x00, 0x30,
0xba, 0x03, 0x04, 0x00, 0x70, 0xb8, 0x03, 0x04,
0x03, 0x70, 0x10, 0x00, 0x01, 0x00, 0xe4, 0x01,
0x00, 0x01, 0x00, 0x0c, 0x43, 0xfa, 0x01, 0xba,
0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03,
0x00, 0xbb, 0x2a, 0x28, 0xbc, 0x03, 0x03, 0x01,
0x04, 0x02, 0x1e, 0x0c, 0x0e, 0x1a, 0x66, 0x75,
0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x66,
0x28, 0x29, 0x20, 0x7b, 0x20, 0x72, 0x65, 0x74,
0x75, 0x72, 0x6e, 0x20, 0x34, 0x32, 0x20, 0x7d,
0x0c, 0x03, 0xc1, 0x05, 0x08, 0xc1, 0x04, 0x3f,
0xdf, 0x00, 0x00, 0x00, 0x80, 0x3f, 0xdd, 0x00,
0x00, 0x00, 0x40, 0x3e, 0xdf, 0x00, 0x00, 0x00,
0x80, 0xbe, 0x00, 0x40, 0xdd, 0x00, 0x00, 0x00,
0x00, 0x04, 0xe0, 0x00, 0x00, 0x00, 0xc8, 0x04,
0xe1, 0x00, 0x00, 0x00, 0x3a, 0xdf, 0x00, 0x00,
0x00, 0x61, 0x01, 0x00, 0x38, 0xdd, 0x00, 0x00,
0x00, 0x42, 0x38, 0x00, 0x00, 0x00, 0x24, 0x00,
0x00, 0xc9, 0x06, 0xc8, 0x62, 0x01, 0x00, 0x38,
0xdf, 0x00, 0x00, 0x00, 0xaf, 0xe9, 0x0b, 0x38,
0x94, 0x00, 0x00, 0x00, 0x62, 0x01, 0x00, 0xee,
0x2f, 0x61, 0x03, 0x00, 0x61, 0x02, 0x00, 0x38,
0x3b, 0x00, 0x00, 0x00, 0x38, 0xdf, 0x00, 0x00,
0x00, 0x04, 0xdd, 0x00, 0x00, 0x00, 0x9d, 0x31,
0x01, 0x00, 0x04, 0x00, 0xca, 0x62, 0x02, 0x00,
0x42, 0x38, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00,
0xcb, 0x06, 0xc8, 0x62, 0x03, 0x00, 0x38, 0xdf,
0x00, 0x00, 0x00, 0xaf, 0xe9, 0x0b, 0x38, 0x94,
0x00, 0x00, 0x00, 0x62, 0x03, 0x00, 0xee, 0x2f,
0x68, 0x03, 0x00, 0x68, 0x02, 0x00, 0xc4, 0x28,
0xbc, 0x03, 0x01, 0x01, 0x28, 0x60, 0x01, 0x49,
0x02, 0x21, 0x1a, 0x1b, 0x04, 0x1e, 0x1d, 0x12,
0x26, 0x49, 0x1d, 0x0c, 0x06, 0x11, 0x18, 0x2a,
0x1c, 0x37, 0x41, 0x21, 0x1c, 0x34, 0x18, 0x1b,
0x04, 0x26, 0x11, 0x3f, 0x1d, 0x0c, 0x06, 0x11,
0x18, 0x2a, 0x1c, 0x53, 0x41, 0x00,
};
static JSContext *JS_NewCustomContext(JSRuntime *rt)
+14 -14
View File
@@ -2,21 +2,21 @@
#include "quickjs-libc.h"
const uint32_t qjsc_hello_size = 89;
const uint32_t qjsc_hello_size = 93;
const uint8_t qjsc_hello[89] = {
0x0e, 0x04, 0x0e, 0x63, 0x6f, 0x6e, 0x73, 0x6f,
0x6c, 0x65, 0x06, 0x6c, 0x6f, 0x67, 0x16, 0x48,
0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72,
0x6c, 0x64, 0x22, 0x65, 0x78, 0x61, 0x6d, 0x70,
0x6c, 0x65, 0x73, 0x2f, 0x68, 0x65, 0x6c, 0x6c,
0x6f, 0x2e, 0x6a, 0x73, 0x0c, 0x00, 0xfa, 0x00,
0xa2, 0x01, 0x00, 0x01, 0x00, 0x03, 0x00, 0x00,
0x14, 0x01, 0xa4, 0x01, 0x00, 0x00, 0x00, 0x38,
0xdc, 0x00, 0x00, 0x00, 0x42, 0xdd, 0x00, 0x00,
0x00, 0x04, 0xde, 0x00, 0x00, 0x00, 0x24, 0x01,
0x00, 0xcc, 0x28, 0xbe, 0x03, 0x01, 0x01, 0x00,
0x00,
const uint8_t qjsc_hello[93] = {
0x0f, 0x04, 0x01, 0x0e, 0x63, 0x6f, 0x6e, 0x73,
0x6f, 0x6c, 0x65, 0x01, 0x06, 0x6c, 0x6f, 0x67,
0x01, 0x16, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20,
0x57, 0x6f, 0x72, 0x6c, 0x64, 0x01, 0x22, 0x65,
0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f,
0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x2e, 0x6a, 0x73,
0x0c, 0x00, 0xfa, 0x00, 0xa2, 0x01, 0x00, 0x01,
0x00, 0x03, 0x00, 0x00, 0x14, 0x01, 0xa4, 0x01,
0x00, 0x00, 0x00, 0x38, 0xdc, 0x00, 0x00, 0x00,
0x42, 0xdd, 0x00, 0x00, 0x00, 0x04, 0xde, 0x00,
0x00, 0x00, 0x24, 0x01, 0x00, 0xcc, 0x28, 0xbe,
0x03, 0x01, 0x01, 0x00, 0x00,
};
static JSContext *JS_NewCustomContext(JSRuntime *rt)
+65 -63
View File
@@ -2,76 +2,78 @@
#include "quickjs-libc.h"
const uint32_t qjsc_fib_module_size = 311;
const uint32_t qjsc_fib_module_size = 314;
const uint8_t qjsc_fib_module[311] = {
0x0e, 0x03, 0x2c, 0x65, 0x78, 0x61, 0x6d, 0x70,
0x6c, 0x65, 0x73, 0x2f, 0x66, 0x69, 0x62, 0x5f,
0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x6a,
0x73, 0x06, 0x66, 0x69, 0x62, 0x02, 0x6e, 0x0d,
0xb8, 0x03, 0x00, 0x01, 0x00, 0x00, 0xba, 0x03,
0x00, 0x00, 0x00, 0x0c, 0x20, 0xfa, 0x01, 0xa2,
0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x09,
0x00, 0xba, 0x03, 0x00, 0x01, 0x0c, 0x43, 0xfa,
0x01, 0xba, 0x03, 0x01, 0x00, 0x01, 0x04, 0x01,
0x00, 0x1a, 0x01, 0xbc, 0x03, 0x00, 0x01, 0x00,
0xba, 0x03, 0x00, 0x00, 0xd0, 0xb3, 0xa7, 0xe9,
0x03, 0xb3, 0x28, 0xd0, 0xb4, 0xac, 0xe9, 0x03,
0xb4, 0x28, 0xdc, 0xd0, 0xb4, 0x9e, 0xee, 0xdc,
0xd0, 0xb5, 0x9e, 0xee, 0x9d, 0x28, 0xb8, 0x03,
0x02, 0x08, 0x20, 0x04, 0x00, 0x07, 0x06, 0x07,
0x06, 0x12, 0x09, 0x08, 0x07, 0x07, 0x10, 0x07,
0x06, 0x07, 0x06, 0x12, 0x13, 0x08, 0x07, 0x08,
0x16, 0x0c, 0x0c, 0x07, 0x04, 0x0c, 0x0a, 0x0c,
0x0c, 0x07, 0x04, 0x8d, 0x01, 0x66, 0x75, 0x6e,
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x66, 0x69,
0x62, 0x28, 0x6e, 0x29, 0x0a, 0x7b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x6e,
0x20, 0x3c, 0x3d, 0x20, 0x30, 0x29, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72,
0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x30, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73,
0x65, 0x20, 0x69, 0x66, 0x20, 0x28, 0x6e, 0x20,
0x3d, 0x3d, 0x20, 0x31, 0x29, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65,
0x74, 0x75, 0x72, 0x6e, 0x20, 0x31, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65,
const uint8_t qjsc_fib_module[314] = {
0x0f, 0x03, 0x01, 0x2c, 0x65, 0x78, 0x61, 0x6d,
0x70, 0x6c, 0x65, 0x73, 0x2f, 0x66, 0x69, 0x62,
0x5f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e,
0x6a, 0x73, 0x01, 0x06, 0x66, 0x69, 0x62, 0x01,
0x02, 0x6e, 0x0d, 0xb8, 0x03, 0x00, 0x01, 0x00,
0x00, 0xba, 0x03, 0x00, 0x00, 0x00, 0x0c, 0x20,
0xfa, 0x01, 0xa2, 0x01, 0x00, 0x00, 0x00, 0x01,
0x01, 0x01, 0x09, 0x00, 0xba, 0x03, 0x00, 0x01,
0x0c, 0x43, 0xfa, 0x01, 0xba, 0x03, 0x01, 0x00,
0x01, 0x04, 0x01, 0x00, 0x1a, 0x01, 0xbc, 0x03,
0x00, 0x01, 0x00, 0xba, 0x03, 0x00, 0x00, 0xd0,
0xb3, 0xa7, 0xe9, 0x03, 0xb3, 0x28, 0xd0, 0xb4,
0xac, 0xe9, 0x03, 0xb4, 0x28, 0xdc, 0xd0, 0xb4,
0x9e, 0xee, 0xdc, 0xd0, 0xb5, 0x9e, 0xee, 0x9d,
0x28, 0xb8, 0x03, 0x02, 0x08, 0x20, 0x04, 0x00,
0x07, 0x06, 0x07, 0x06, 0x12, 0x09, 0x08, 0x07,
0x07, 0x10, 0x07, 0x06, 0x07, 0x06, 0x12, 0x13,
0x08, 0x07, 0x08, 0x16, 0x0c, 0x0c, 0x07, 0x04,
0x0c, 0x0a, 0x0c, 0x0c, 0x07, 0x04, 0x8d, 0x01,
0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
0x20, 0x66, 0x69, 0x62, 0x28, 0x6e, 0x29, 0x0a,
0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66,
0x20, 0x28, 0x6e, 0x20, 0x3c, 0x3d, 0x20, 0x30,
0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
0x20, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x65, 0x6c, 0x73, 0x65, 0x20, 0x69, 0x66, 0x20,
0x28, 0x6e, 0x20, 0x3d, 0x3d, 0x20, 0x31, 0x29,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20,
0x31, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65,
0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75,
0x72, 0x6e, 0x20, 0x66, 0x69, 0x62, 0x28, 0x6e,
0x20, 0x2d, 0x20, 0x31, 0x29, 0x20, 0x2b, 0x20,
0x66, 0x69, 0x62, 0x28, 0x6e, 0x20, 0x2d, 0x20,
0x31, 0x29, 0x20, 0x2b, 0x20, 0x66, 0x69, 0x62,
0x28, 0x6e, 0x20, 0x2d, 0x20, 0x32, 0x29, 0x3b,
0x0a, 0x7d, 0x08, 0xe9, 0x05, 0xbe, 0x00, 0xe0,
0x29, 0x06, 0x2e, 0xb8, 0x03, 0x01, 0x01, 0x06,
0x01, 0x01, 0x00, 0x07, 0x14, 0x02, 0x00,
0x32, 0x29, 0x3b, 0x0a, 0x7d, 0x08, 0xe9, 0x05,
0xbe, 0x00, 0xe0, 0x29, 0x06, 0x2e, 0xb8, 0x03,
0x01, 0x01, 0x06, 0x01, 0x01, 0x00, 0x07, 0x14,
0x02, 0x00,
};
const uint32_t qjsc_hello_module_size = 178;
const uint32_t qjsc_hello_module_size = 185;
const uint8_t qjsc_hello_module[178] = {
0x0e, 0x07, 0x30, 0x65, 0x78, 0x61, 0x6d, 0x70,
0x6c, 0x65, 0x73, 0x2f, 0x68, 0x65, 0x6c, 0x6c,
0x6f, 0x5f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65,
0x2e, 0x6a, 0x73, 0x1e, 0x2e, 0x2f, 0x66, 0x69,
0x62, 0x5f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65,
0x2e, 0x6a, 0x73, 0x06, 0x66, 0x69, 0x62, 0x0e,
0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x06,
0x6c, 0x6f, 0x67, 0x16, 0x48, 0x65, 0x6c, 0x6c,
0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x10,
0x66, 0x69, 0x62, 0x28, 0x31, 0x30, 0x29, 0x3d,
0x0d, 0xb8, 0x03, 0x01, 0xba, 0x03, 0x00, 0x00,
0x01, 0x00, 0xbc, 0x03, 0x00, 0x00, 0x0c, 0x20,
0xfa, 0x01, 0xa2, 0x01, 0x00, 0x00, 0x00, 0x05,
0x01, 0x00, 0x32, 0x00, 0xbc, 0x03, 0x00, 0x0c,
0x08, 0xe9, 0x02, 0x29, 0x38, 0xdf, 0x00, 0x00,
0x00, 0x42, 0xe0, 0x00, 0x00, 0x00, 0x04, 0xe1,
0x00, 0x00, 0x00, 0x24, 0x01, 0x00, 0x0e, 0x38,
0xdf, 0x00, 0x00, 0x00, 0x42, 0xe0, 0x00, 0x00,
0x00, 0x04, 0xe2, 0x00, 0x00, 0x00, 0x65, 0x00,
0x00, 0xbb, 0x0a, 0xee, 0x24, 0x02, 0x00, 0x0e,
0x06, 0x2e, 0xb8, 0x03, 0x01, 0x01, 0x0a, 0x01,
0x01, 0x00, 0x04, 0x0a, 0x02, 0x62, 0x00, 0x4d,
0x30, 0x00,
const uint8_t qjsc_hello_module[185] = {
0x0f, 0x07, 0x01, 0x30, 0x65, 0x78, 0x61, 0x6d,
0x70, 0x6c, 0x65, 0x73, 0x2f, 0x68, 0x65, 0x6c,
0x6c, 0x6f, 0x5f, 0x6d, 0x6f, 0x64, 0x75, 0x6c,
0x65, 0x2e, 0x6a, 0x73, 0x01, 0x1e, 0x2e, 0x2f,
0x66, 0x69, 0x62, 0x5f, 0x6d, 0x6f, 0x64, 0x75,
0x6c, 0x65, 0x2e, 0x6a, 0x73, 0x01, 0x06, 0x66,
0x69, 0x62, 0x01, 0x0e, 0x63, 0x6f, 0x6e, 0x73,
0x6f, 0x6c, 0x65, 0x01, 0x06, 0x6c, 0x6f, 0x67,
0x01, 0x16, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20,
0x57, 0x6f, 0x72, 0x6c, 0x64, 0x01, 0x10, 0x66,
0x69, 0x62, 0x28, 0x31, 0x30, 0x29, 0x3d, 0x0d,
0xb8, 0x03, 0x01, 0xba, 0x03, 0x00, 0x00, 0x01,
0x00, 0xbc, 0x03, 0x00, 0x00, 0x0c, 0x20, 0xfa,
0x01, 0xa2, 0x01, 0x00, 0x00, 0x00, 0x05, 0x01,
0x00, 0x32, 0x00, 0xbc, 0x03, 0x00, 0x0c, 0x08,
0xe9, 0x02, 0x29, 0x38, 0xdf, 0x00, 0x00, 0x00,
0x42, 0xe0, 0x00, 0x00, 0x00, 0x04, 0xe1, 0x00,
0x00, 0x00, 0x24, 0x01, 0x00, 0x0e, 0x38, 0xdf,
0x00, 0x00, 0x00, 0x42, 0xe0, 0x00, 0x00, 0x00,
0x04, 0xe2, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00,
0xbb, 0x0a, 0xee, 0x24, 0x02, 0x00, 0x0e, 0x06,
0x2e, 0xb8, 0x03, 0x01, 0x01, 0x0a, 0x01, 0x01,
0x00, 0x04, 0x0a, 0x02, 0x62, 0x00, 0x4d, 0x30,
0x00,
};
static JSContext *JS_NewCustomContext(JSRuntime *rt)
+2829 -2763
View File
File diff suppressed because it is too large. Load diff
+40 -38
View File
@@ -2,46 +2,48 @@
#include "quickjs-libc.h"
const uint32_t qjsc_test_fib_size = 293;
const uint32_t qjsc_test_fib_size = 306;
const uint8_t qjsc_test_fib[293] = {
0x0e, 0x0d, 0x28, 0x65, 0x78, 0x61, 0x6d, 0x70,
0x6c, 0x65, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74,
0x5f, 0x66, 0x69, 0x62, 0x2e, 0x6a, 0x73, 0x04,
0x6f, 0x73, 0x0a, 0x69, 0x73, 0x57, 0x69, 0x6e,
0x06, 0x66, 0x69, 0x62, 0x10, 0x70, 0x6c, 0x61,
0x74, 0x66, 0x6f, 0x72, 0x6d, 0x0a, 0x77, 0x69,
0x6e, 0x33, 0x32, 0x0c, 0x2e, 0x2f, 0x66, 0x69,
0x62, 0x2e, 0x06, 0x64, 0x6c, 0x6c, 0x04, 0x73,
0x6f, 0x0e, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c,
0x65, 0x06, 0x6c, 0x6f, 0x67, 0x16, 0x48, 0x65,
0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c,
0x64, 0x10, 0x66, 0x69, 0x62, 0x28, 0x31, 0x30,
0x29, 0x3d, 0x0d, 0xb8, 0x03, 0x01, 0xba, 0x03,
0x00, 0x00, 0x01, 0x00, 0xfc, 0x01, 0x00, 0x01,
0x0c, 0x20, 0xfa, 0x01, 0xa2, 0x01, 0x00, 0x00,
0x00, 0x05, 0x03, 0x00, 0x73, 0x00, 0xba, 0x03,
0x00, 0x0d, 0xbc, 0x03, 0x00, 0x0d, 0xbe, 0x03,
0x01, 0x0d, 0x08, 0xe9, 0x02, 0x29, 0x65, 0x00,
0x00, 0x41, 0xe0, 0x00, 0x00, 0x00, 0x04, 0xe1,
0x00, 0x00, 0x00, 0xae, 0xe1, 0x06, 0x11, 0xf1,
0xea, 0x0b, 0x70, 0x42, 0xdf, 0x00, 0x00, 0x00,
0xe2, 0x0e, 0xeb, 0x24, 0x0e, 0x04, 0xe2, 0x00,
0x00, 0x00, 0x42, 0x5d, 0x00, 0x00, 0x00, 0x65,
0x01, 0x00, 0xe9, 0x08, 0x04, 0xe3, 0x00, 0x00,
0x00, 0xeb, 0x06, 0x04, 0xe4, 0x00, 0x00, 0x00,
0x24, 0x01, 0x00, 0x35, 0x8b, 0xeb, 0xd4, 0x38,
const uint8_t qjsc_test_fib[306] = {
0x0f, 0x0d, 0x01, 0x28, 0x65, 0x78, 0x61, 0x6d,
0x70, 0x6c, 0x65, 0x73, 0x2f, 0x74, 0x65, 0x73,
0x74, 0x5f, 0x66, 0x69, 0x62, 0x2e, 0x6a, 0x73,
0x01, 0x04, 0x6f, 0x73, 0x01, 0x0a, 0x69, 0x73,
0x57, 0x69, 0x6e, 0x01, 0x06, 0x66, 0x69, 0x62,
0x01, 0x10, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f,
0x72, 0x6d, 0x01, 0x0a, 0x77, 0x69, 0x6e, 0x33,
0x32, 0x01, 0x0c, 0x2e, 0x2f, 0x66, 0x69, 0x62,
0x2e, 0x01, 0x06, 0x64, 0x6c, 0x6c, 0x01, 0x04,
0x73, 0x6f, 0x01, 0x0e, 0x63, 0x6f, 0x6e, 0x73,
0x6f, 0x6c, 0x65, 0x01, 0x06, 0x6c, 0x6f, 0x67,
0x01, 0x16, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20,
0x57, 0x6f, 0x72, 0x6c, 0x64, 0x01, 0x10, 0x66,
0x69, 0x62, 0x28, 0x31, 0x30, 0x29, 0x3d, 0x0d,
0xb8, 0x03, 0x01, 0xba, 0x03, 0x00, 0x00, 0x01,
0x00, 0xfc, 0x01, 0x00, 0x01, 0x0c, 0x20, 0xfa,
0x01, 0xa2, 0x01, 0x00, 0x00, 0x00, 0x05, 0x03,
0x00, 0x73, 0x00, 0xba, 0x03, 0x00, 0x0d, 0xbc,
0x03, 0x00, 0x0d, 0xbe, 0x03, 0x01, 0x0d, 0x08,
0xe9, 0x02, 0x29, 0x65, 0x00, 0x00, 0x41, 0xe0,
0x00, 0x00, 0x00, 0x04, 0xe1, 0x00, 0x00, 0x00,
0xae, 0xe1, 0x06, 0x11, 0xf1, 0xea, 0x0b, 0x70,
0x42, 0xdf, 0x00, 0x00, 0x00, 0xe2, 0x0e, 0xeb,
0x24, 0x0e, 0x04, 0xe2, 0x00, 0x00, 0x00, 0x42,
0x5d, 0x00, 0x00, 0x00, 0x65, 0x01, 0x00, 0xe9,
0x08, 0x04, 0xe3, 0x00, 0x00, 0x00, 0xeb, 0x06,
0x04, 0xe4, 0x00, 0x00, 0x00, 0x24, 0x01, 0x00,
0x35, 0x8b, 0xeb, 0xd4, 0x38, 0xe5, 0x00, 0x00,
0x00, 0x42, 0xe6, 0x00, 0x00, 0x00, 0x04, 0xe7,
0x00, 0x00, 0x00, 0x24, 0x01, 0x00, 0x0e, 0x38,
0xe5, 0x00, 0x00, 0x00, 0x42, 0xe6, 0x00, 0x00,
0x00, 0x04, 0xe7, 0x00, 0x00, 0x00, 0x24, 0x01,
0x00, 0x0e, 0x38, 0xe5, 0x00, 0x00, 0x00, 0x42,
0xe6, 0x00, 0x00, 0x00, 0x04, 0xe8, 0x00, 0x00,
0x00, 0x65, 0x02, 0x00, 0xbb, 0x0a, 0xee, 0x24,
0x02, 0x00, 0x0e, 0x06, 0x2e, 0xb8, 0x03, 0x01,
0x01, 0x22, 0x01, 0x01, 0x00, 0x04, 0x08, 0x1e,
0x2a, 0x18, 0x1b, 0x08, 0x0d, 0x3b, 0x1b, 0x0c,
0x07, 0x04, 0x25, 0x08, 0x0c, 0x04, 0x07, 0x10,
0x43, 0x2c, 0x25, 0x10, 0x25, 0x04, 0x27, 0x6b,
0x62, 0x00, 0x4d, 0x30, 0x00,
0x00, 0x04, 0xe8, 0x00, 0x00, 0x00, 0x65, 0x02,
0x00, 0xbb, 0x0a, 0xee, 0x24, 0x02, 0x00, 0x0e,
0x06, 0x2e, 0xb8, 0x03, 0x01, 0x01, 0x22, 0x01,
0x01, 0x00, 0x04, 0x08, 0x1e, 0x2a, 0x18, 0x1b,
0x08, 0x0d, 0x3b, 0x1b, 0x0c, 0x07, 0x04, 0x25,
0x08, 0x0c, 0x04, 0x07, 0x10, 0x43, 0x2c, 0x25,
0x10, 0x25, 0x04, 0x27, 0x6b, 0x62, 0x00, 0x4d,
0x30, 0x00,
};
static JSContext *JS_NewCustomContext(JSRuntime *rt)
+61 -20
View File
@@ -2459,11 +2459,7 @@ static inline BOOL is_strict_mode(JSContext *ctx)
static inline BOOL __JS_AtomIsConst(JSAtom v)
{
#ifdef DUMP_ATOM_LEAKS
return (int32_t)v <= 0;
#else
return (int32_t)v < JS_ATOM_END;
#endif
return (int32_t)v < JS_ATOM_END;
}
static inline BOOL __JS_AtomIsTaggedInt(JSAtom v)
@@ -2729,11 +2725,6 @@ static JSAtomKindEnum JS_AtomGetKind(JSContext *ctx, JSAtom v)
return (JSAtomKindEnum){-1}; // pacify compiler
}
static BOOL JS_AtomIsString(JSContext *ctx, JSAtom v)
{
return JS_AtomGetKind(ctx, v) == JS_ATOM_KIND_STRING;
}
static JSAtom js_get_atom_index(JSRuntime *rt, JSAtomStruct *p)
{
uint32_t i = p->hash_next; /* atom_index */
@@ -33337,9 +33328,10 @@ typedef enum BCTagEnum {
BC_TAG_OBJECT_REFERENCE,
BC_TAG_MAP,
BC_TAG_SET,
BC_TAG_SYMBOL,
} BCTagEnum;
#define BC_VERSION 14
#define BC_VERSION 15
typedef struct BCWriterState {
JSContext *ctx;
@@ -33385,6 +33377,9 @@ static const char * const bc_tag_str[] = {
"Date",
"ObjectValue",
"ObjectReference",
"Map",
"Set",
"Symbol",
};
#endif
@@ -33896,9 +33891,7 @@ static int JS_WriteObjectTag(BCWriterState *s, JSValue obj)
bc_put_leb128(s, prop_count);
for(i = 0, pr = get_shape_prop(sh); i < sh->prop_count; i++, pr++) {
atom = pr->atom;
if (atom != JS_ATOM_NULL &&
JS_AtomIsString(s->ctx, atom) &&
(pr->flags & JS_PROP_ENUMERABLE)) {
if (atom != JS_ATOM_NULL && (pr->flags & JS_PROP_ENUMERABLE)) {
if (pr->flags & JS_PROP_TMASK) {
JS_ThrowTypeError(s->ctx, "only value properties are supported");
goto fail;
@@ -34113,6 +34106,18 @@ static int JS_WriteObjectRec(BCWriterState *s, JSValue obj)
if (JS_WriteBigInt(s, obj))
goto fail;
break;
case JS_TAG_SYMBOL:
{
JSAtomStruct *p = JS_VALUE_GET_PTR(obj);
if (p->atom_type != JS_ATOM_TYPE_GLOBAL_SYMBOL && p->atom_type != JS_ATOM_TYPE_SYMBOL) {
JS_ThrowTypeError(s->ctx, "unsupported symbol type");
goto fail;
}
JSAtom atom = js_get_atom_index(s->ctx->rt, p);
bc_put_u8(s, BC_TAG_SYMBOL);
bc_put_atom(s, atom);
}
break;
default:
invalid_tag:
JS_ThrowInternalError(s->ctx, "unsupported tag (%d)", tag);
@@ -34137,8 +34142,19 @@ static int JS_WriteObjectAtoms(BCWriterState *s)
bc_put_leb128(s, s->idx_to_atom_count);
for(i = 0; i < s->idx_to_atom_count; i++) {
JSAtomStruct *p = rt->atom_array[s->idx_to_atom[i]];
JS_WriteString(s, p);
JSAtom atom = s->idx_to_atom[i];
if (__JS_AtomIsConst(atom)) {
bc_put_u8(s, 0 /* the type */);
/* TODO(saghul): encoding for tagged integers and keyword-ish atoms could be
more efficient. */
bc_put_u32(s, atom);
} else {
JSAtomStruct *p = rt->atom_array[atom];
uint8_t type = p->atom_type;
assert(type != JS_ATOM_TYPE_PRIVATE);
bc_put_u8(s, type);
JS_WriteString(s, p);
}
}
/* XXX: should check for OOM in above phase */
@@ -35346,6 +35362,19 @@ static JSValue JS_ReadObjectRec(BCReaderState *s)
case BC_TAG_SET:
obj = JS_ReadSet(s);
break;
case BC_TAG_SYMBOL:
{
JSAtom atom;
if (bc_get_atom(s, &atom))
return JS_EXCEPTION;
if (__JS_AtomIsConst(atom)) {
obj = JS_AtomToValue(s->ctx, atom);
} else {
JSAtomStruct *p = s->ctx->rt->atom_array[atom];
obj = JS_NewSymbolFromAtom(s->ctx, atom, p->atom_type);
}
}
break;
default:
invalid_tag:
return JS_ThrowSyntaxError(ctx, "invalid tag (tag=%d pos=%u)",
@@ -35357,7 +35386,7 @@ static JSValue JS_ReadObjectRec(BCReaderState *s)
static int JS_ReadObjectAtoms(BCReaderState *s)
{
uint8_t v8;
uint8_t v8, type;
JSString *p;
int i;
JSAtom atom;
@@ -35381,10 +35410,22 @@ static int JS_ReadObjectAtoms(BCReaderState *s)
return s->error_state = -1;
}
for(i = 0; i < s->idx_to_atom_count; i++) {
p = JS_ReadString(s);
if (!p)
if (bc_get_u8(s, &type)) {
return -1;
atom = JS_NewAtomStr(s->ctx, p);
}
if (type == 0) {
if (bc_get_u32(s, &atom))
return -1;
} else {
if (type < JS_ATOM_TYPE_STRING || type >= JS_ATOM_TYPE_PRIVATE) {
JS_ThrowInternalError(s->ctx, "invalid symbol type %d", type);
return -1;
}
p = JS_ReadString(s);
if (!p)
return -1;
atom = __JS_NewAtom(s->ctx->rt, p, type);
}
if (atom == JS_ATOM_NULL)
return s->error_state = -1;
s->idx_to_atom[i] = atom;
+27
View File
@@ -178,6 +178,32 @@ function bjson_test_set()
assert([...r].toString(), xs.toString());
}
function bjson_test_symbol()
{
var buf, r, o;
o = {[Symbol.toStringTag]: "42"};
buf = bjson.write(o);
r = bjson.read(buf, 0, buf.byteLength);
assert(o.toString(), r.toString());
o = Symbol('foo');
buf = bjson.write(o);
r = bjson.read(buf, 0, buf.byteLength);
assert(o.toString(), r.toString());
assert(o !== r);
o = Symbol.for('foo');
buf = bjson.write(o);
r = bjson.read(buf, 0, buf.byteLength);
assert(o === r);
o = Symbol.toStringTag;
buf = bjson.write(o);
r = bjson.read(buf, 0, buf.byteLength);
assert(o === r);
}
function bjson_test_all()
{
var obj;
@@ -210,6 +236,7 @@ function bjson_test_all()
bjson_test_regexp();
bjson_test_map();
bjson_test_set();
bjson_test_symbol();
}
bjson_test_all();