quickjs-done-nextgen/gen/function_source.c
Ben Noordhuis ac4cd17bb5
Track line and column numbers for expressions (#781)
Commit 73cc00e reduced the number of emitted source locations a great
deal but it resulted in at least one observable regression:

    export default async function f() {
         return "abc" + x
    }
    f() // ReferenceError should point to 2:20 but pointed to 1:1

Emit source locations for expressions again. Increases the average
number of source locations by about 15%. Non-scientifically tested
by counting source locations emitted when parsing the test suite
before and after.

No test because we currently cannot easily test stack traces coming
from module imports.

Fixes: https://github.com/quickjs-ng/quickjs/issues/779
2025-01-05 22:20:43 +01:00

82 lines
2.9 KiB
C

/* File generated automatically by the QuickJS-ng compiler. */
#include "quickjs-libc.h"
const uint32_t qjsc_function_source_size = 320;
const uint8_t qjsc_function_source[320] = {
0x13, 0x05, 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, 0x61, 0x63,
0x74, 0x75, 0x61, 0x6c, 0x01, 0x02, 0x66, 0x01,
0x0c, 0x65, 0x78, 0x70, 0x65, 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, 0x0d, 0xc0, 0x03, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0c, 0x20, 0xfa, 0x01, 0xa2,
0x01, 0x00, 0x05, 0x00, 0x03, 0x02, 0x01, 0x74,
0x05, 0xc2, 0x03, 0x02, 0x00, 0x30, 0xc4, 0x03,
0x04, 0x00, 0x70, 0xc2, 0x03, 0x04, 0x02, 0x70,
0x10, 0x00, 0x01, 0x00, 0xe4, 0x01, 0x00, 0x01,
0x00, 0xc6, 0x03, 0x00, 0x0d, 0xc4, 0x03, 0x01,
0x01, 0x0c, 0x43, 0xfa, 0x01, 0xc4, 0x03, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0x00, 0xbd,
0x2a, 0x28, 0xc0, 0x03, 0x03, 0x01, 0x00, 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, 0xc3, 0x04, 0x08, 0xcd,
0x08, 0xeb, 0x05, 0xc0, 0x00, 0xe3, 0x29, 0x04,
0xe4, 0x00, 0x00, 0x00, 0xe2, 0x62, 0x00, 0x00,
0xdf, 0x43, 0x38, 0x00, 0x00, 0x00, 0x24, 0x00,
0x00, 0xca, 0x63, 0x00, 0x00, 0x66, 0x00, 0x00,
0xb0, 0xeb, 0x0b, 0x39, 0x95, 0x00, 0x00, 0x00,
0x63, 0x00, 0x00, 0xf0, 0x30, 0x62, 0x02, 0x00,
0x62, 0x01, 0x00, 0x39, 0x3b, 0x00, 0x00, 0x00,
0x66, 0x00, 0x00, 0x04, 0xe2, 0x00, 0x00, 0x00,
0x9e, 0x32, 0x01, 0x00, 0x03, 0x00, 0xcb, 0x63,
0x01, 0x00, 0x43, 0x38, 0x00, 0x00, 0x00, 0x24,
0x00, 0x00, 0xcc, 0x63, 0x02, 0x00, 0x66, 0x00,
0x00, 0xb0, 0xeb, 0x0b, 0x39, 0x95, 0x00, 0x00,
0x00, 0x63, 0x02, 0x00, 0xf0, 0x30, 0x69, 0x02,
0x00, 0x69, 0x01, 0x00, 0x06, 0x2f, 0xc0, 0x03,
0x01, 0x01, 0x14, 0x00, 0x1c, 0x0a, 0x2a, 0x26,
0x03, 0x39, 0x28, 0x00, 0x10, 0x08, 0x27, 0x11,
0x12, 0x67, 0x0d, 0x26, 0x03, 0x39, 0x28, 0x00,
};
static JSContext *JS_NewCustomContext(JSRuntime *rt)
{
JSContext *ctx = JS_NewContext(rt);
if (!ctx)
return NULL;
return ctx;
}
int main(int argc, char **argv)
{
int r;
JSValue ret;
JSRuntime *rt;
JSContext *ctx;
r = 0;
rt = JS_NewRuntime();
js_std_set_worker_new_context_func(JS_NewCustomContext);
js_std_init_handlers(rt);
JS_SetModuleLoaderFunc(rt, NULL, js_module_loader, NULL);
ctx = JS_NewCustomContext(rt);
js_std_add_helpers(ctx, argc, argv);
js_std_eval_binary(ctx, qjsc_function_source, qjsc_function_source_size, 0);
ret = js_std_loop(ctx);
if (JS_IsException(ret)) {
js_std_dump_error1(ctx, ret);
r = 1;
}
JS_FreeValue(ctx, ret);
JS_FreeContext(ctx);
js_std_free_handlers(rt);
JS_FreeRuntime(rt);
return r;
}