jseption 0.0.0-stage → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/LICENSE +26 -0
  2. package/README.md +191 -2
  3. package/dist/atoms.d.ts +255 -0
  4. package/dist/atoms.js +445 -0
  5. package/dist/atoms.js.map +1 -0
  6. package/dist/builtins/array.d.ts +3 -0
  7. package/dist/builtins/array.js +116 -0
  8. package/dist/builtins/array.js.map +1 -0
  9. package/dist/builtins/bigint.d.ts +3 -0
  10. package/dist/builtins/bigint.js +122 -0
  11. package/dist/builtins/bigint.js.map +1 -0
  12. package/dist/builtins/boolean.d.ts +2 -0
  13. package/dist/builtins/boolean.js +26 -0
  14. package/dist/builtins/boolean.js.map +1 -0
  15. package/dist/builtins/date.d.ts +3 -0
  16. package/dist/builtins/date.js +1046 -0
  17. package/dist/builtins/date.js.map +1 -0
  18. package/dist/builtins/error.d.ts +2 -0
  19. package/dist/builtins/error.js +154 -0
  20. package/dist/builtins/error.js.map +1 -0
  21. package/dist/builtins/function.d.ts +5 -0
  22. package/dist/builtins/function.js +164 -0
  23. package/dist/builtins/function.js.map +1 -0
  24. package/dist/builtins/global.d.ts +2 -0
  25. package/dist/builtins/global.js +29 -0
  26. package/dist/builtins/global.js.map +1 -0
  27. package/dist/builtins/index.d.ts +3 -0
  28. package/dist/builtins/index.js +139 -0
  29. package/dist/builtins/index.js.map +1 -0
  30. package/dist/builtins/json.d.ts +6 -0
  31. package/dist/builtins/json.js +984 -0
  32. package/dist/builtins/json.js.map +1 -0
  33. package/dist/builtins/mapset.d.ts +4 -0
  34. package/dist/builtins/mapset.js +234 -0
  35. package/dist/builtins/mapset.js.map +1 -0
  36. package/dist/builtins/math.d.ts +2 -0
  37. package/dist/builtins/math.js +62 -0
  38. package/dist/builtins/math.js.map +1 -0
  39. package/dist/builtins/native.d.ts +22 -0
  40. package/dist/builtins/native.js +250 -0
  41. package/dist/builtins/native.js.map +1 -0
  42. package/dist/builtins/number.d.ts +4 -0
  43. package/dist/builtins/number.js +76 -0
  44. package/dist/builtins/number.js.map +1 -0
  45. package/dist/builtins/object.d.ts +12 -0
  46. package/dist/builtins/object.js +575 -0
  47. package/dist/builtins/object.js.map +1 -0
  48. package/dist/builtins/promise.d.ts +13 -0
  49. package/dist/builtins/promise.js +582 -0
  50. package/dist/builtins/promise.js.map +1 -0
  51. package/dist/builtins/proxy.d.ts +3 -0
  52. package/dist/builtins/proxy.js +226 -0
  53. package/dist/builtins/proxy.js.map +1 -0
  54. package/dist/builtins/reflect.d.ts +2 -0
  55. package/dist/builtins/reflect.js +109 -0
  56. package/dist/builtins/reflect.js.map +1 -0
  57. package/dist/builtins/regexp.d.ts +2 -0
  58. package/dist/builtins/regexp.js +203 -0
  59. package/dist/builtins/regexp.js.map +1 -0
  60. package/dist/builtins/string.d.ts +4 -0
  61. package/dist/builtins/string.js +135 -0
  62. package/dist/builtins/string.js.map +1 -0
  63. package/dist/builtins/symbol.d.ts +3 -0
  64. package/dist/builtins/symbol.js +98 -0
  65. package/dist/builtins/symbol.js.map +1 -0
  66. package/dist/builtins/typedarray.d.ts +15 -0
  67. package/dist/builtins/typedarray.js +1838 -0
  68. package/dist/builtins/typedarray.js.map +1 -0
  69. package/dist/builtins/weakref.d.ts +18 -0
  70. package/dist/builtins/weakref.js +130 -0
  71. package/dist/builtins/weakref.js.map +1 -0
  72. package/dist/dump.d.ts +2 -0
  73. package/dist/dump.js +124 -0
  74. package/dist/dump.js.map +1 -0
  75. package/dist/embed.d.ts +18 -0
  76. package/dist/embed.js +286 -0
  77. package/dist/embed.js.map +1 -0
  78. package/dist/interpreter.d.ts +81 -0
  79. package/dist/interpreter.js +3768 -0
  80. package/dist/interpreter.js.map +1 -0
  81. package/dist/jit.d.ts +59 -0
  82. package/dist/jit.js +3440 -0
  83. package/dist/jit.js.map +1 -0
  84. package/dist/jit_hook.d.ts +21 -0
  85. package/dist/jit_hook.js +4 -0
  86. package/dist/jit_hook.js.map +1 -0
  87. package/dist/jit_runtime.d.ts +104 -0
  88. package/dist/jit_runtime.js +721 -0
  89. package/dist/jit_runtime.js.map +1 -0
  90. package/dist/jit_stack.d.ts +24 -0
  91. package/dist/jit_stack.js +227 -0
  92. package/dist/jit_stack.js.map +1 -0
  93. package/dist/jseption.d.ts +15 -0
  94. package/dist/jseption.js +61 -0
  95. package/dist/jseption.js.map +1 -0
  96. package/dist/opcodes.d.ts +347 -0
  97. package/dist/opcodes.js +322 -0
  98. package/dist/opcodes.js.map +1 -0
  99. package/dist/parser.d.ts +283 -0
  100. package/dist/parser.js +9752 -0
  101. package/dist/parser.js.map +1 -0
  102. package/dist/qjs.d.ts +2 -0
  103. package/dist/qjs.js +122 -0
  104. package/dist/qjs.js.map +1 -0
  105. package/dist/quickjs.d.ts +460 -0
  106. package/dist/quickjs.js +3408 -0
  107. package/dist/quickjs.js.map +1 -0
  108. package/dist/std.d.ts +4 -0
  109. package/dist/std.js +273 -0
  110. package/dist/std.js.map +1 -0
  111. package/dist/values.d.ts +447 -0
  112. package/dist/values.js +461 -0
  113. package/dist/values.js.map +1 -0
  114. package/package.json +59 -4
@@ -0,0 +1,21 @@
1
+ import type { JSFunctionBytecode, JSValue } from './values.ts';
2
+ export declare const JIT_NOT_COMPILED: unique symbol;
3
+ export interface HostFrame {
4
+ kind: 'compiled' | 'interp' | 'cfunc' | 'native';
5
+ name: string;
6
+ file: string;
7
+ line: number;
8
+ col: number;
9
+ }
10
+ export interface JitStackHooks {
11
+ capture(): string;
12
+ frames(host_stack: string): HostFrame[];
13
+ compiled_on_top(host_stack: string): boolean;
14
+ }
15
+ export interface JitHooks {
16
+ try_call: ((ctx: any, func_obj: JSValue, func_data: any, b: JSFunctionBytecode, this_obj: JSValue, new_target: JSValue, argv: JSValue[], flags: number) => JSValue | typeof JIT_NOT_COMPILED) | null;
17
+ stack: JitStackHooks | null;
18
+ make_wrapper: ((ctx: any, b: JSFunctionBytecode, var_refs: any[], proto: JSValue | null, is_ctor: boolean) => JSValue | null) | null;
19
+ osr: ((ctx: any, func_obj: JSValue, b: JSFunctionBytecode, sf: any, pc: number, sp: number) => JSValue | typeof JIT_NOT_COMPILED) | null;
20
+ }
21
+ export declare const jit_hooks: JitHooks;
@@ -0,0 +1,4 @@
1
+ /* returned by try_call when the function is not (yet) compiled */
2
+ export const JIT_NOT_COMPILED = Symbol('JIT_NOT_COMPILED');
3
+ export const jit_hooks = { try_call: null, stack: null, make_wrapper: null, osr: null };
4
+ //# sourceMappingURL=jit_hook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jit_hook.js","sourceRoot":"","sources":["../src/jit_hook.ts"],"names":[],"mappings":"AASA,kEAAkE;AAClE,MAAM,CAAC,MAAM,gBAAgB,GAAkB,MAAM,CAAC,kBAAkB,CAAC,CAAC;AA0C1E,MAAM,CAAC,MAAM,SAAS,GAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC","sourcesContent":["/*\n * Hook between the interpreter and the compiled tier (src/jit.ts).\n *\n * This module has no imports so that the interpreter can depend on it\n * without creating an import cycle. jit.ts installs `try_call` when it is\n * loaded; when it is not loaded the interpreter runs everything.\n */\nimport type { JSFunctionBytecode, JSValue } from './values.ts';\n\n/* returned by try_call when the function is not (yet) compiled */\nexport const JIT_NOT_COMPILED: unique symbol = Symbol('JIT_NOT_COMPILED');\n\n/* a guest-relevant frame of the host stack (see src/jit_stack.ts):\n compiled: a compiled guest function, with its guest position when known;\n interp: the host frame running an interpreter frame (`js_interpret`);\n cfunc: the host frame running a C function frame (`js_call_c_function`);\n native: a host builtin called by guest code (`[].map`) */\nexport interface HostFrame {\n kind: 'compiled' | 'interp' | 'cfunc' | 'native';\n name: string;\n file: string;\n line: number;\n col: number;\n}\n\nexport interface JitStackHooks {\n /* the current host stack, captured with a frame limit high enough for guest backtraces */\n capture(): string;\n /* the guest-relevant frames of a host stack, innermost first */\n frames(host_stack: string): HostFrame[];\n /* true when the innermost guest frame of the host stack is compiled code (its position is\n only available now, from the host stack), false when it is an interpreter frame */\n compiled_on_top(host_stack: string): boolean;\n}\n\nexport interface JitHooks {\n /* Called at the entry of JS_CallInternal for bytecode functions.\n `func_data` is the closure data of the function object (bytecode + var refs). */\n try_call: ((ctx: any, func_obj: JSValue, func_data: any, b: JSFunctionBytecode, this_obj: JSValue,\n new_target: JSValue, argv: JSValue[], flags: number) => JSValue | typeof JIT_NOT_COMPILED) | null;\n /* backtrace support for compiled frames; null while the compiled tier is off */\n stack: JitStackHooks | null;\n /* Creates the function object of an interpreted closure of a normal function as a\n retargetable wrapper (it calls the compiled body once one exists), or returns null for the\n generic interpreter wrapper. */\n make_wrapper: ((ctx: any, b: JSFunctionBytecode, var_refs: any[], proto: JSValue | null, is_ctor: boolean) => JSValue | null) | null;\n /* On-stack replacement: called by the interpreter when a backward jump to `pc` is taken in a\n frame of `func_obj`; returns the frame's result (JS_EXCEPTION with the exception pending)\n when the rest of the frame ran in compiled code, else JIT_NOT_COMPILED. */\n osr: ((ctx: any, func_obj: JSValue, b: JSFunctionBytecode, sf: any, pc: number, sp: number) => JSValue | typeof JIT_NOT_COMPILED) | null;\n}\n\nexport const jit_hooks: JitHooks = { try_call: null, stack: null, make_wrapper: null, osr: null };\n"]}
@@ -0,0 +1,104 @@
1
+ import { JSContext, JSValue, JSFunctionBytecode, JSAtom } from './quickjs.ts';
2
+ import { JSVarRef } from './values.ts';
3
+ export interface JitCompiledLike {
4
+ make: (var_refs: JSVarRef[], func_obj?: JSValue) => [Function, Function, (() => Function) | null];
5
+ }
6
+ export declare const JIT_FACTORY_PARAMS: string[];
7
+ export declare function jit_runtime_factory_args(RT: JitRuntime, b: JSFunctionBytecode): any[];
8
+ export declare function make_jit_runtime(ctx: JSContext, compile: (b: JSFunctionBytecode) => JitCompiledLike | null): JitRuntime;
9
+ export declare function jit_runtime_call_priv(ctx: JSContext, priv: Function, this_obj: JSValue, argv: JSValue[]): JSValue;
10
+ export declare function jit_bytecode_uses_args(b: JSFunctionBytecode): boolean;
11
+ export declare function jit_runtime_make_wrapper(ctx: JSContext, b: JSFunctionBytecode, var_refs: JSVarRef[], proto: JSValue | null, is_ctor: boolean): JSValue | null;
12
+ export declare function jit_runtime_call_compiled(ctx: JSContext, direct: Function, this_obj: JSValue, new_target: JSValue, argv: JSValue[], flags: number): JSValue;
13
+ export declare class JitRuntime {
14
+ ctx: JSContext;
15
+ compile: (b: JSFunctionBytecode) => JitCompiledLike | null;
16
+ DONE: any;
17
+ Obj: Function;
18
+ constructor(ctx: JSContext, compile: (b: JSFunctionBytecode) => JitCompiledLike | null);
19
+ throw_pending(): never;
20
+ check<T>(v: T): T;
21
+ checkn(r: number): void;
22
+ to_guest_exception(e: unknown): JSValue;
23
+ catchable(e: unknown): JSValue;
24
+ poll(): void;
25
+ poll_handler(): void;
26
+ throw_type_error(msg: string): never;
27
+ throw_reference_error(msg: string): never;
28
+ throw_internal_error(msg: string): never;
29
+ throw_not_a_constructor(_f: JSValue): never;
30
+ throw_uninitialized(b: JSFunctionBytecode, idx: number, is_ref: boolean): never;
31
+ throw_error(atom: JSAtom, type: number): never;
32
+ new_cell(v: JSValue): JSVarRef;
33
+ new_object(): JSValue;
34
+ new_object_null(): JSValue;
35
+ array(elems: JSValue[]): JSValue;
36
+ atom_value(atom: JSAtom): JSValue;
37
+ private_symbol(atom: JSAtom): JSValue;
38
+ sloppy_this(t: JSValue): JSValue;
39
+ regexp(pattern: JSValue, flags: JSValue): JSValue;
40
+ to_object(v: JSValue): JSValue;
41
+ to_propkey(v: JSValue): JSValue;
42
+ to_numeric(v: JSValue): JSValue;
43
+ inc(v: JSValue): JSValue;
44
+ dec(v: JSValue): JSValue;
45
+ in(k: JSValue, o: JSValue): boolean;
46
+ instanceof(v: JSValue, c: JSValue): boolean;
47
+ get_prototype(o: JSValue): JSValue;
48
+ call_slow(f: JSValue, thisv: JSValue, args: JSValue[]): JSValue;
49
+ construct_slow(f: JSValue, new_target: JSValue, args: JSValue[]): JSValue;
50
+ call_method_prim(o: JSValue, atom: JSAtom, args: JSValue[]): JSValue;
51
+ call_method_prim_key(o: JSValue, key: JSValue, args: JSValue[]): JSValue;
52
+ apply(f: JSValue, thisv: JSValue, arr: JSValue, magic: number): JSValue;
53
+ create_this(new_target: JSValue): JSValue;
54
+ init_ctor(self: JSValue, new_target: JSValue, args: IArguments, off: number): JSValue;
55
+ arguments(args: IArguments, off: number): JSValue;
56
+ mapped_arguments(args: IArguments, off: number, cells: JSVarRef[], self: JSValue): JSValue;
57
+ rest(args: IArguments, off: number, first: number): JSValue;
58
+ home_object(self: JSValue): JSValue;
59
+ closure(b: JSFunctionBytecode, var_refs: JSVarRef[], _parent: JSValue): JSValue;
60
+ define_class(name: JSAtom | JSValue, parent_class: JSValue, b: JSFunctionBytecode, class_flags: number, var_refs: JSVarRef[], is_computed_name: boolean): [JSValue, JSValue];
61
+ set_home_object(f: JSValue, home: JSValue): void;
62
+ set_name(f: JSValue, atom: JSAtom): void;
63
+ set_name_computed(f: JSValue, name: JSValue): void;
64
+ define_method(obj: JSValue, key: JSAtom | JSValue, fn: JSValue, op_flags: number, computed: boolean): void;
65
+ set_proto(o: JSValue, proto: JSValue): void;
66
+ check_brand(o: JSValue, f: JSValue): void;
67
+ add_brand(o: JSValue, f: JSValue): void;
68
+ get_private_field(o: JSValue, name: JSValue): JSValue;
69
+ put_private_field(o: JSValue, name: JSValue, v: JSValue): void;
70
+ define_private_field(o: JSValue, name: JSValue, v: JSValue): void;
71
+ private_in(o: JSValue, name: JSValue): boolean;
72
+ check_var(atom: JSAtom): boolean;
73
+ get_global(atom: JSAtom, throw_ref_error: boolean): JSValue;
74
+ put_global(atom: JSAtom, v: JSValue, flag: number, strict: boolean): void;
75
+ put_global_strict(atom: JSAtom, defined: JSValue, v: JSValue): void;
76
+ check_define_var(atom: JSAtom, flags: number): void;
77
+ define_var(atom: JSAtom, flags: number): void;
78
+ define_func(atom: JSAtom, v: JSValue, flags: number): void;
79
+ get_global_ref(atom: JSAtom): [JSValue, JSValue];
80
+ delete_global(atom: JSAtom): boolean;
81
+ get_field(o: JSValue, atom: JSAtom): JSValue;
82
+ get_field_str(o: JSValue, name: string): JSValue;
83
+ get_length(o: JSValue): JSValue;
84
+ get_el(o: JSValue, k: JSValue): JSValue;
85
+ put_field(o: JSValue, atom: JSAtom, v: JSValue, strict: boolean): void;
86
+ put_el(o: JSValue, k: JSValue, v: JSValue, strict: boolean): void;
87
+ delete(o: JSValue, k: JSValue, strict: boolean): boolean;
88
+ define_field(o: JSValue, atom: JSAtom, v: JSValue): void;
89
+ define_array_el(arr: JSValue, pos: JSValue, v: JSValue): void;
90
+ append(arr: JSValue, pos: JSValue, src: JSValue): number;
91
+ copy_data_properties(target: JSValue, source: JSValue, excluded: JSValue): void;
92
+ get_ref_value(o: JSValue, k: JSValue, strict: boolean): JSValue;
93
+ put_ref_value(o: JSValue, k: JSValue, v: JSValue, strict: boolean): void;
94
+ get_super_value(thisv: JSValue, o: JSValue, k: JSValue): JSValue;
95
+ put_super_value(thisv: JSValue, o: JSValue, k: JSValue, v: JSValue): void;
96
+ for_in_start(o: JSValue): JSValue;
97
+ for_in_next(it: JSValue): JSValue;
98
+ get_iterator(o: JSValue): JSValue;
99
+ for_of_start(o: JSValue): [JSValue, JSValue];
100
+ for_of_next(iter: JSValue, next: JSValue): JSValue;
101
+ iterator_close(iter: JSValue): void;
102
+ iterator_close_exc(iter: JSValue): void;
103
+ iterator_call(iter: JSValue, val: JSValue, flags: number): JSValue;
104
+ }