xbintsc 0.7.0 → 0.7.6
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.
- package/dist/src/ast/common.d.ts +10 -0
- package/dist/src/checker/source.js +4 -0
- package/dist/src/checker/source.js.map +1 -1
- package/dist/src/cli/help.d.ts +1 -1
- package/dist/src/cli/main.js +15 -3
- package/dist/src/cli/main.js.map +1 -1
- package/dist/src/codegen/generator/calls/access.js +4 -11
- package/dist/src/codegen/generator/calls/access.js.map +1 -1
- package/dist/src/codegen/generator/calls/element-inline.d.ts +42 -0
- package/dist/src/codegen/generator/calls/element-inline.js +388 -0
- package/dist/src/codegen/generator/calls/element-inline.js.map +1 -0
- package/dist/src/codegen/generator/calls/invocation.js +82 -1
- package/dist/src/codegen/generator/calls/invocation.js.map +1 -1
- package/dist/src/codegen/generator/calls.d.ts +3 -1
- package/dist/src/codegen/generator/calls.js +3 -1
- package/dist/src/codegen/generator/calls.js.map +1 -1
- package/dist/src/codegen/generator/debug.js +20 -3
- package/dist/src/codegen/generator/debug.js.map +1 -1
- package/dist/src/codegen/generator/expressions/assignment.js +10 -2
- package/dist/src/codegen/generator/expressions/assignment.js.map +1 -1
- package/dist/src/codegen/generator/expressions/global-values.d.ts +19 -0
- package/dist/src/codegen/generator/expressions/global-values.js +49 -0
- package/dist/src/codegen/generator/expressions/global-values.js.map +1 -0
- package/dist/src/codegen/generator/expressions/primary.d.ts +0 -2
- package/dist/src/codegen/generator/expressions/primary.js +4 -24
- package/dist/src/codegen/generator/expressions/primary.js.map +1 -1
- package/dist/src/codegen/generator/expressions.d.ts +2 -1
- package/dist/src/codegen/generator/expressions.js +2 -1
- package/dist/src/codegen/generator/expressions.js.map +1 -1
- package/dist/src/codegen/generator/layout.d.ts +65 -0
- package/dist/src/codegen/generator/layout.js +50 -0
- package/dist/src/codegen/generator/layout.js.map +1 -0
- package/dist/src/codegen/generator/state.js +4 -0
- package/dist/src/codegen/generator/state.js.map +1 -1
- package/dist/src/diagnostics/diagnostic.js +1 -1
- package/dist/src/diagnostics/diagnostic.js.map +1 -1
- package/dist/src/diagnostics/source-text.d.ts +37 -9
- package/dist/src/diagnostics/source-text.js +124 -23
- package/dist/src/diagnostics/source-text.js.map +1 -1
- package/dist/src/diagnostics/source.d.ts +16 -6
- package/dist/src/diagnostics/source.js +25 -4
- package/dist/src/diagnostics/source.js.map +1 -1
- package/dist/src/driver/build-key.d.ts +14 -0
- package/dist/src/driver/build-key.js +6 -1
- package/dist/src/driver/build-key.js.map +1 -1
- package/dist/src/driver/bundler/concatenate.js +11 -4
- package/dist/src/driver/bundler/concatenate.js.map +1 -1
- package/dist/src/driver/bundler/graph.js +2 -2
- package/dist/src/driver/bundler/graph.js.map +1 -1
- package/dist/src/driver/bundler/merge.js +11 -5
- package/dist/src/driver/bundler/merge.js.map +1 -1
- package/dist/src/driver/bundler/reexport-resolution.js +3 -0
- package/dist/src/driver/bundler/reexport-resolution.js.map +1 -1
- package/dist/src/driver/compiler.js +13 -3
- package/dist/src/driver/compiler.js.map +1 -1
- package/dist/src/driver/frontend.js +3 -4
- package/dist/src/driver/frontend.js.map +1 -1
- package/dist/src/driver/runtime-objects.d.ts +1 -1
- package/dist/src/driver/runtime-objects.js +4 -0
- package/dist/src/driver/runtime-objects.js.map +1 -1
- package/dist/src/driver/toolchain.js +28 -5
- package/dist/src/driver/toolchain.js.map +1 -1
- package/dist/src/driver/version.d.ts +1 -1
- package/dist/src/driver/version.js +1 -1
- package/dist/src/extensions/gui/html.js +42 -10
- package/dist/src/extensions/gui/html.js.map +1 -1
- package/dist/src/extensions/gui/index.js +48 -0
- package/dist/src/extensions/gui/index.js.map +1 -1
- package/dist/src/extensions/registry.d.ts +20 -0
- package/dist/src/extensions/registry.js.map +1 -1
- package/dist/src/parser/expressions.js +2 -2
- package/dist/src/parser/expressions.js.map +1 -1
- package/dist/src/parser/helpers.d.ts +8 -0
- package/dist/src/parser/helpers.js +21 -0
- package/dist/src/parser/helpers.js.map +1 -1
- package/dist/tests/cli/main.test.js +9 -0
- package/dist/tests/cli/main.test.js.map +1 -1
- package/dist/tests/codegen/element-layout.test.d.ts +19 -0
- package/dist/tests/codegen/element-layout.test.js +80 -0
- package/dist/tests/codegen/element-layout.test.js.map +1 -0
- package/dist/tests/codegen/expressions.test.js +25 -0
- package/dist/tests/codegen/expressions.test.js.map +1 -1
- package/dist/tests/codegen/llvm.test.js +13 -0
- package/dist/tests/codegen/llvm.test.js.map +1 -1
- package/dist/tests/diagnostics/diagnostic.test.js +9 -0
- package/dist/tests/diagnostics/diagnostic.test.js.map +1 -1
- package/dist/tests/diagnostics/source-text.test.d.ts +1 -0
- package/dist/tests/diagnostics/source-text.test.js +50 -0
- package/dist/tests/diagnostics/source-text.test.js.map +1 -0
- package/dist/tests/diagnostics/source.test.js +17 -0
- package/dist/tests/diagnostics/source.test.js.map +1 -1
- package/dist/tests/driver/build-key.test.d.ts +1 -0
- package/dist/tests/driver/build-key.test.js +49 -0
- package/dist/tests/driver/build-key.test.js.map +1 -0
- package/dist/tests/driver/toolchain.test.js +8 -1
- package/dist/tests/driver/toolchain.test.js.map +1 -1
- package/dist/tests/driver/usage.test.js +2 -1
- package/dist/tests/driver/usage.test.js.map +1 -1
- package/dist/tests/e2e/async-await.test.js +16 -0
- package/dist/tests/e2e/async-await.test.js.map +1 -1
- package/dist/tests/e2e/compile-builtins.test.js +29 -0
- package/dist/tests/e2e/compile-builtins.test.js.map +1 -1
- package/dist/tests/e2e/compile-modules.test.js +13 -0
- package/dist/tests/e2e/compile-modules.test.js.map +1 -1
- package/dist/tests/e2e/compile-objects-classes.test.js.map +1 -1
- package/dist/tests/e2e/compile-prototype-chain.test.d.ts +8 -0
- package/dist/tests/e2e/compile-prototype-chain.test.js +24 -0
- package/dist/tests/e2e/compile-prototype-chain.test.js.map +1 -0
- package/dist/tests/e2e/differential-language.test.js +25 -0
- package/dist/tests/e2e/differential-language.test.js.map +1 -1
- package/dist/tests/e2e/differential-values.test.js +59 -0
- package/dist/tests/e2e/differential-values.test.js.map +1 -1
- package/dist/tests/e2e/gc.test.js +22 -0
- package/dist/tests/e2e/gc.test.js.map +1 -1
- package/dist/tests/e2e/gui-audio-extra.test.d.ts +12 -0
- package/dist/tests/e2e/gui-audio-extra.test.js +185 -0
- package/dist/tests/e2e/gui-audio-extra.test.js.map +1 -0
- package/dist/tests/e2e/gui-browser.test.js +35 -2
- package/dist/tests/e2e/gui-browser.test.js.map +1 -1
- package/dist/tests/e2e/gui-dom.test.js +88 -0
- package/dist/tests/e2e/gui-dom.test.js.map +1 -1
- package/dist/tests/e2e/gui-webgl-declarations.test.d.ts +13 -0
- package/dist/tests/e2e/gui-webgl-declarations.test.js +136 -0
- package/dist/tests/e2e/gui-webgl-declarations.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl-texture-units.test.d.ts +12 -0
- package/dist/tests/e2e/gui-webgl-texture-units.test.js +86 -0
- package/dist/tests/e2e/gui-webgl-texture-units.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2-blit.test.js +6 -2
- package/dist/tests/e2e/gui-webgl2-blit.test.js.map +1 -1
- package/dist/tests/e2e/gui-webgl2-msaa-float.test.d.ts +12 -0
- package/dist/tests/e2e/gui-webgl2-msaa-float.test.js +157 -0
- package/dist/tests/e2e/gui-webgl2-msaa-float.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2-msaa.test.d.ts +10 -0
- package/dist/tests/e2e/gui-webgl2-msaa.test.js +344 -0
- package/dist/tests/e2e/gui-webgl2-msaa.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2-target-orientation.test.d.ts +15 -0
- package/dist/tests/e2e/gui-webgl2-target-orientation.test.js +287 -0
- package/dist/tests/e2e/gui-webgl2-target-orientation.test.js.map +1 -0
- package/dist/tests/e2e/gui-webgl2.test.js +59 -1
- package/dist/tests/e2e/gui-webgl2.test.js.map +1 -1
- package/dist/tests/e2e/hang-watchdog.test.d.ts +10 -0
- package/dist/tests/e2e/hang-watchdog.test.js +50 -0
- package/dist/tests/e2e/hang-watchdog.test.js.map +1 -0
- package/dist/tests/e2e/method-call-cache.test.d.ts +5 -0
- package/dist/tests/e2e/method-call-cache.test.js +65 -0
- package/dist/tests/e2e/method-call-cache.test.js.map +1 -0
- package/dist/tests/e2e/performance-now.test.d.ts +9 -0
- package/dist/tests/e2e/performance-now.test.js +36 -0
- package/dist/tests/e2e/performance-now.test.js.map +1 -0
- package/dist/tests/e2e/property-ic.test.js +33 -0
- package/dist/tests/e2e/property-ic.test.js.map +1 -1
- package/dist/tests/e2e/shape-interning.test.d.ts +16 -0
- package/dist/tests/e2e/shape-interning.test.js +55 -0
- package/dist/tests/e2e/shape-interning.test.js.map +1 -0
- package/dist/tests/e2e/string-utf16.test.js +9 -0
- package/dist/tests/e2e/string-utf16.test.js.map +1 -1
- package/dist/tests/e2e/typed-array-views.test.js +26 -0
- package/dist/tests/e2e/typed-array-views.test.js.map +1 -1
- package/dist/tests/e2e/url-search-params.test.js +19 -0
- package/dist/tests/e2e/url-search-params.test.js.map +1 -1
- package/dist/tests/extensions/gui.test.js +16 -1
- package/dist/tests/extensions/gui.test.js.map +1 -1
- package/dist/tests/helpers.js +1 -0
- package/dist/tests/helpers.js.map +1 -1
- package/dist/tests/parser/expressions.test.js +36 -0
- package/dist/tests/parser/expressions.test.js.map +1 -1
- package/doc/ai/contributing.md +8 -5
- package/doc/ai/extensions.md +12 -3
- package/doc/ai/language-support.md +2 -1
- package/doc/ai/troubleshooting.md +14 -0
- package/doc/ai/zh-CN/contributing.md +6 -3
- package/doc/ai/zh-CN/extensions.md +10 -2
- package/doc/ai/zh-CN/language-support.md +2 -1
- package/doc/ai/zh-CN/troubleshooting.md +12 -0
- package/doc/gui/api.md +26 -4
- package/doc/gui/dom.md +8 -0
- package/doc/gui/known-issues.md +35 -6
- package/doc/gui/runtime.md +16 -1
- package/doc/gui/webgl.md +97 -26
- package/doc/gui-scripts.md +2 -1
- package/doc/gui.md +8 -5
- package/doc/implemented/checker.md +9 -0
- package/doc/implemented/codegen.md +7 -0
- package/doc/implemented/parser.md +2 -1
- package/doc/implemented/runtime-core.md +9 -2
- package/doc/implemented/stdlib.md +10 -2
- package/doc/implemented/typed-arrays.md +18 -2
- package/doc/zh-CN/gui/api.md +19 -5
- package/doc/zh-CN/gui/dom.md +6 -0
- package/doc/zh-CN/gui/known-issues.md +24 -5
- package/doc/zh-CN/gui/runtime.md +13 -1
- package/doc/zh-CN/gui/webgl.md +20 -7
- package/doc/zh-CN/gui-scripts.md +2 -1
- package/doc/zh-CN/gui.md +4 -1
- package/doc/zh-CN/implemented/checker.md +7 -0
- package/doc/zh-CN/implemented/codegen.md +7 -0
- package/doc/zh-CN/implemented/parser.md +2 -1
- package/doc/zh-CN/implemented/runtime-core.md +9 -2
- package/doc/zh-CN/implemented/stdlib.md +6 -2
- package/doc/zh-CN/implemented/typed-arrays.md +14 -2
- package/package.json +7 -7
- package/runtime/ext_gui/audio.cpp +39 -3
- package/runtime/ext_gui/audio_extra.cpp +353 -0
- package/runtime/ext_gui/audio_extra.h +47 -0
- package/runtime/ext_gui/audio_fft.h +76 -0
- package/runtime/ext_gui/audio_internal.h +21 -0
- package/runtime/ext_gui/audio_mixer.cpp +46 -1
- package/runtime/ext_gui/audio_mixer.h +89 -1
- package/runtime/ext_gui/audio_mixer_extra.cpp +126 -0
- package/runtime/ext_gui/audio_nodes.cpp +242 -0
- package/runtime/ext_gui/audio_nodes_internal.h +81 -0
- package/runtime/ext_gui/audio_nodes_spatial.cpp +375 -0
- package/runtime/ext_gui/browser.cpp +9 -0
- package/runtime/ext_gui/browser_screen.cpp +73 -0
- package/runtime/ext_gui/dom_api_canvas.cpp +9 -1
- package/runtime/ext_gui/dom_api_internal.h +3 -0
- package/runtime/ext_gui/dom_api_node.cpp +21 -0
- package/runtime/ext_gui/dom_api_node_read.cpp +29 -0
- package/runtime/ext_gui/dom_api_proto.cpp +3 -0
- package/runtime/ext_gui/dom_api_webgl2.cpp +16 -11
- package/runtime/ext_gui/dom_api_webgl2_msaa.cpp +64 -0
- package/runtime/ext_gui/dom_api_webgl_compressed.cpp +2 -2
- package/runtime/ext_gui/dom_api_webgl_framebuffer.cpp +68 -11
- package/runtime/ext_gui/dom_api_webgl_methods.h +3 -0
- package/runtime/ext_gui/dom_api_webgl_state.cpp +4 -2
- package/runtime/ext_gui/dom_api_webgl_texture.cpp +6 -6
- package/runtime/ext_gui/gui.cpp +6 -1
- package/runtime/ext_gui/gui_engine.h +2 -0
- package/runtime/ext_gui/gui_events.cpp +13 -8
- package/runtime/ext_gui/gui_webgl.cpp +3 -2
- package/runtime/ext_gui/style_ua.cpp +4 -0
- package/runtime/ext_gui/warnings.cpp +1 -1
- package/runtime/ext_gui/webgl.h +102 -7
- package/runtime/ext_gui/webgl_api.h +3 -2
- package/runtime/ext_gui/webgl_blit.cpp +109 -15
- package/runtime/ext_gui/webgl_blit_color.cpp +264 -0
- package/runtime/ext_gui/webgl_blit_depth.cpp +26 -8
- package/runtime/ext_gui/webgl_buffer.cpp +20 -170
- package/runtime/ext_gui/webgl_context.cpp +117 -169
- package/runtime/ext_gui/webgl_draw.cpp +116 -5
- package/runtime/ext_gui/webgl_draw_buffers.cpp +21 -6
- package/runtime/ext_gui/webgl_draw_setup.cpp +1 -0
- package/runtime/ext_gui/webgl_draw_state.h +2 -0
- package/runtime/ext_gui/webgl_feature.cpp +2 -2
- package/runtime/ext_gui/webgl_feature.h +4 -3
- package/runtime/ext_gui/webgl_framebuffer.cpp +346 -0
- package/runtime/ext_gui/webgl_glsl_rewrite.cpp +78 -47
- package/runtime/ext_gui/webgl_objects.h +16 -2
- package/runtime/ext_gui/webgl_pipeline.cpp +1 -1
- package/runtime/ext_gui/webgl_state.cpp +45 -36
- package/runtime/ext_gui/webgl_targets.cpp +440 -0
- package/runtime/ext_gui/webgl_texture.cpp +81 -25
- package/runtime/ext_gui/window.cpp +8 -0
- package/runtime/rt.h +27 -27
- package/runtime/rt_binary.h +44 -0
- package/runtime/rt_internal.h +52 -60
- package/runtime/rt_object.h +83 -0
- package/runtime/rt_profile.h +45 -0
- package/runtime/xt_alloc.c +88 -133
- package/runtime/xt_array_buffer.c +99 -71
- package/runtime/xt_builtins.c +3 -1
- package/runtime/xt_constructors.c +1 -0
- package/runtime/xt_containers/access.inc +96 -11
- package/runtime/xt_containers/arrays.inc +2 -1
- package/runtime/xt_containers/cstr_cache.inc +56 -0
- package/runtime/xt_containers/method_cache.inc +121 -0
- package/runtime/xt_containers/object_keys.inc +58 -0
- package/runtime/xt_containers/objects.inc +47 -79
- package/runtime/xt_containers/shapes.inc +153 -8
- package/runtime/xt_containers.c +4 -0
- package/runtime/xt_gc_release.c +70 -0
- package/runtime/xt_gc_stack.c +83 -0
- package/runtime/xt_gc_verify.c +1 -0
- package/runtime/xt_io/console.inc +66 -0
- package/runtime/xt_io/exception.inc +32 -6
- package/runtime/xt_io/watchdog.inc +101 -0
- package/runtime/xt_io.c +1 -0
- package/runtime/xt_loop.c +23 -3
- package/runtime/xt_pool.c +151 -0
- package/runtime/xt_profile.c +126 -0
- package/runtime/xt_stdlib/dispatch.inc +7 -1
- package/runtime/xt_stdlib/math.inc +272 -57
- package/runtime/xt_stdlib2/json_stringify.inc +1 -2
- package/runtime/xt_stdlib2/regexp-match.inc +17 -0
- package/runtime/xt_storage/indexed_db.c +4 -1
- package/runtime/xt_structured_clone.c +2 -1
- package/runtime/xt_typed_array/construction.inc +10 -0
- package/runtime/xt_typed_array/elements.inc +43 -23
- package/runtime/xt_url.c +50 -0
- package/runtime/xt_values/constructors.inc +4 -1
- package/runtime/xt_values/strings.inc +3 -1
- package/src/ast/common.ts +10 -0
- package/src/checker/source.ts +3 -0
- package/src/cli/main.ts +14 -3
- package/src/codegen/generator/calls/access.ts +5 -10
- package/src/codegen/generator/calls/element-inline.ts +433 -0
- package/src/codegen/generator/calls/invocation.ts +87 -1
- package/src/codegen/generator/calls.ts +5 -0
- package/src/codegen/generator/debug.ts +21 -3
- package/src/codegen/generator/expressions/assignment.ts +11 -2
- package/src/codegen/generator/expressions/global-values.ts +57 -0
- package/src/codegen/generator/expressions/primary.ts +4 -27
- package/src/codegen/generator/expressions.ts +3 -0
- package/src/codegen/generator/layout.ts +54 -0
- package/src/codegen/generator/state.ts +5 -0
- package/src/diagnostics/diagnostic.ts +1 -1
- package/src/diagnostics/source-text.ts +118 -22
- package/src/diagnostics/source.ts +29 -7
- package/src/driver/build-key.ts +21 -1
- package/src/driver/bundler/concatenate.ts +12 -5
- package/src/driver/bundler/graph.ts +2 -2
- package/src/driver/bundler/merge.ts +11 -4
- package/src/driver/bundler/reexport-resolution.ts +2 -0
- package/src/driver/compiler.ts +14 -3
- package/src/driver/frontend.ts +3 -4
- package/src/driver/runtime-objects.ts +4 -0
- package/src/driver/toolchain.ts +28 -5
- package/src/driver/version.ts +1 -1
- package/src/extensions/gui/html.ts +41 -11
- package/src/extensions/gui/index.ts +50 -1
- package/src/extensions/registry.ts +20 -0
- package/src/parser/expressions.ts +2 -2
- package/src/parser/helpers.ts +22 -0
package/runtime/rt.h
CHANGED
|
@@ -277,6 +277,12 @@ xt_value xt_array_ctor(int32_t argc, xt_value *argv);
|
|
|
277
277
|
xt_value xt_object_ctor(int32_t argc, xt_value *argv);
|
|
278
278
|
/** Call `target[name](...)`, falling back to built-in Array/String methods. */
|
|
279
279
|
xt_value xt_call_method(xt_value target, xt_value name, int32_t argc, xt_value *argv);
|
|
280
|
+
/** `obj.name(...)` with a monomorphic method inline cache: `cache` points at
|
|
281
|
+
* three zero-initialised i64 words owned by the generated code. A hit calls the
|
|
282
|
+
* cached slot's current value with `target` as `this`; a miss runs the full
|
|
283
|
+
* dispatch and then fills the cache. */
|
|
284
|
+
xt_value xt_call_method_ic(xt_value target, xt_value name, int32_t argc, xt_value *argv,
|
|
285
|
+
int64_t *cache);
|
|
280
286
|
/** Implements `Math.<name>(...)`; the name is interned by the compiler. */
|
|
281
287
|
xt_value xt_math_call(xt_value name, int32_t argc, xt_value *argv);
|
|
282
288
|
/* The first-class `Math` object (function members as native closures). */
|
|
@@ -291,33 +297,7 @@ xt_value xt_object_static(xt_value name, int32_t argc, xt_value *argv);
|
|
|
291
297
|
/** Implements `Number.<name>(...)` / `String.<name>(...)` statics. */
|
|
292
298
|
xt_value xt_number_static(xt_value name, int32_t argc, xt_value *argv);
|
|
293
299
|
xt_value xt_string_static(xt_value name, int32_t argc, xt_value *argv);
|
|
294
|
-
|
|
295
|
-
xt_value xt_typed_array_ctor_by_name(xt_value name, int32_t argc, xt_value *argv);
|
|
296
|
-
xt_value xt_typed_array_static_by_name(xt_value name, xt_value method, int32_t argc, xt_value *argv);
|
|
297
|
-
xt_value xt_typed_array_prototype(xt_value name);
|
|
298
|
-
/** Bulk access to the bytes an `ArrayBuffer` (or a typed array's backing
|
|
299
|
-
* store) holds, for decoders and encoders that cannot afford one property read
|
|
300
|
-
* per byte. `offset` and `count` are clamped to the buffer and the number of
|
|
301
|
-
* bytes actually transferred is returned. Extensions pass the backing buffer
|
|
302
|
-
* plus a view's `byteOffset`/`byteLength`; see `runtime/ext_gui/audio.cpp`. */
|
|
303
|
-
uint32_t xt_array_buffer_copy_bytes_out(xt_value buffer, uint32_t offset, uint8_t *dst,
|
|
304
|
-
uint32_t count);
|
|
305
|
-
uint32_t xt_array_buffer_copy_bytes_in(xt_value buffer, uint32_t offset, const uint8_t *src,
|
|
306
|
-
uint32_t count);
|
|
307
|
-
/** Allocate a zero-filled `ArrayBuffer` of `byte_length` bytes (the native
|
|
308
|
-
* counterpart of `new ArrayBuffer(n)`). */
|
|
309
|
-
xt_value xt_array_buffer_alloc(uint32_t byte_length);
|
|
310
|
-
/** Typed-array view internals for extensions: whether `value` is a view, the
|
|
311
|
-
* `ArrayBuffer` it views, and the byte offset of the view inside it. */
|
|
312
|
-
int xt_is_typed_array(xt_value value);
|
|
313
|
-
/** Element kind (0..8: U8, I8, U8C, U16, I16, U32, I32, F32, F64), or -1. */
|
|
314
|
-
int xt_typed_array_kind_of(xt_value value);
|
|
315
|
-
/** Read one element (coerced to a number) from a typed-array view. */
|
|
316
|
-
xt_value xt_typed_array_read(xt_value array, uint32_t index);
|
|
317
|
-
xt_value xt_typed_array_backing_buffer(xt_value value);
|
|
318
|
-
uint32_t xt_typed_array_view_offset(xt_value value);
|
|
319
|
-
/** Number of elements in a typed-array view. */
|
|
320
|
-
uint32_t xt_typed_array_length(xt_value value);
|
|
300
|
+
#include "rt_binary.h"
|
|
321
301
|
/** Error-family construction and prototype lookup by constructor name. */
|
|
322
302
|
xt_value xt_error_ctor_by_name(xt_value name, int32_t argc, xt_value *argv);
|
|
323
303
|
xt_value xt_error_prototype(xt_value name);
|
|
@@ -511,6 +491,11 @@ xt_value xt_get(xt_value target, xt_value key);
|
|
|
511
491
|
* two zero-initialised i64 words owned by the generated code. */
|
|
512
492
|
xt_value xt_get_ic(xt_value target, xt_value key, int64_t *cache);
|
|
513
493
|
xt_value xt_set(xt_value target, xt_value key, xt_value value);
|
|
494
|
+
/** `obj[key]` read with an element fast path: typed arrays and plain arrays are
|
|
495
|
+
* answered without the general dispatch, everything else goes to `xt_get_ic`. */
|
|
496
|
+
xt_value xt_get_element(xt_value target, xt_value key, int64_t *cache);
|
|
497
|
+
/** `obj[key] = value` with the same element fast path. */
|
|
498
|
+
xt_value xt_set_element(xt_value target, xt_value key, xt_value value);
|
|
514
499
|
/* Materialise a first-class runtime method value (`arr.map`) as an unbound
|
|
515
500
|
* closure that expects the receiver through `this`. Returns `XT_UNDEFINED` when
|
|
516
501
|
* `name` is not a method of `target`, so it can be used as a property fallback. */
|
|
@@ -546,6 +531,10 @@ void xt_stack_push(const char *name, const char *file, int32_t line);
|
|
|
546
531
|
void xt_stack_pop(void);
|
|
547
532
|
/** Set the innermost frame's line (called just before `new Error(...)`). */
|
|
548
533
|
void xt_stack_set_line(int32_t line);
|
|
534
|
+
|
|
535
|
+
/** Milliseconds since the program's time origin — the clock behind
|
|
536
|
+
* `performance.now()` and the timestamp an animation-frame callback receives. */
|
|
537
|
+
double xt_monotonic_ms(void);
|
|
549
538
|
void xt_console_log(int32_t argc, xt_value *argv);
|
|
550
539
|
void xt_console_info(int32_t argc, xt_value *argv);
|
|
551
540
|
void xt_console_warn(int32_t argc, xt_value *argv);
|
|
@@ -561,6 +550,9 @@ xt_value xt_console_table(int32_t argc, xt_value *argv);
|
|
|
561
550
|
xt_value xt_console_time(int32_t argc, xt_value *argv);
|
|
562
551
|
xt_value xt_console_time_end(int32_t argc, xt_value *argv);
|
|
563
552
|
xt_value xt_console_time_log(int32_t argc, xt_value *argv);
|
|
553
|
+
/** The global `console` object: one cached object whose methods are closures,
|
|
554
|
+
* so `const log = console.log` / `console.error.bind(console)` work. */
|
|
555
|
+
xt_value xt_console_object(int32_t argc, xt_value *argv);
|
|
564
556
|
void xt_print(xt_value v);
|
|
565
557
|
void xt_println(xt_value v);
|
|
566
558
|
|
|
@@ -574,6 +566,11 @@ size_t xt_heap_allocations(void);
|
|
|
574
566
|
* that lives outside the heap graph. The slot may be registered before it
|
|
575
567
|
* holds a value; it is marked on every collection and registration is
|
|
576
568
|
* idempotent. `xt_gc_add_root_range` registers `count` consecutive cells.
|
|
569
|
+
*
|
|
570
|
+
* A lazily built value must be registered *before* the allocations that build
|
|
571
|
+
* it. A static cell is outside the conservative stack scan, so a collection
|
|
572
|
+
* between storing the value and registering its slot would sweep an object the
|
|
573
|
+
* program still holds.
|
|
577
574
|
*/
|
|
578
575
|
void xt_gc_add_root(xt_value *slot);
|
|
579
576
|
void xt_gc_add_root_range(xt_value *base, size_t count);
|
|
@@ -593,3 +590,6 @@ void xt_gc_mark_value(xt_value value);
|
|
|
593
590
|
#endif
|
|
594
591
|
|
|
595
592
|
#endif /* xbintsc_RUNTIME_H */
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* xbintsc runtime — binary data: `ArrayBuffer`, typed arrays and `DataView`.
|
|
3
|
+
*
|
|
4
|
+
* Included by `rt.h`. An `ArrayBuffer` owns one `calloc`ed byte block (see
|
|
5
|
+
* `xt_object.buffer_bytes`), and a typed-array view caches the block plus its
|
|
6
|
+
* byte offset, so element access is a `memcpy`-sized read/write instead of a
|
|
7
|
+
* property lookup. The helpers here are what the compiler, the standard library
|
|
8
|
+
* and extensions (audio/image decoders, wasm memories) share.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#ifndef XT_RT_BINARY_H
|
|
12
|
+
#define XT_RT_BINARY_H
|
|
13
|
+
|
|
14
|
+
/** Typed-array constructor/static/prototype dispatch by constructor name. */
|
|
15
|
+
xt_value xt_typed_array_ctor_by_name(xt_value name, int32_t argc, xt_value *argv);
|
|
16
|
+
xt_value xt_typed_array_static_by_name(xt_value name, xt_value method, int32_t argc, xt_value *argv);
|
|
17
|
+
xt_value xt_typed_array_prototype(xt_value name);
|
|
18
|
+
|
|
19
|
+
/** Bulk access to the bytes an `ArrayBuffer` (or a typed array's backing
|
|
20
|
+
* store) holds, for decoders and encoders that cannot afford one property read
|
|
21
|
+
* per byte. `offset` and `count` are clamped to the buffer and the number of
|
|
22
|
+
* bytes actually transferred is returned. Extensions pass the backing buffer
|
|
23
|
+
* plus a view's `byteOffset`/`byteLength`; see `runtime/ext_gui/audio.cpp`. */
|
|
24
|
+
uint32_t xt_array_buffer_copy_bytes_out(xt_value buffer, uint32_t offset, uint8_t *dst,
|
|
25
|
+
uint32_t count);
|
|
26
|
+
uint32_t xt_array_buffer_copy_bytes_in(xt_value buffer, uint32_t offset, const uint8_t *src,
|
|
27
|
+
uint32_t count);
|
|
28
|
+
/** Allocate a zero-filled `ArrayBuffer` of `byte_length` bytes (the native
|
|
29
|
+
* counterpart of `new ArrayBuffer(n)`). */
|
|
30
|
+
xt_value xt_array_buffer_alloc(uint32_t byte_length);
|
|
31
|
+
|
|
32
|
+
/** Typed-array view internals for extensions: whether `value` is a view, the
|
|
33
|
+
* `ArrayBuffer` it views, and the byte offset of the view inside it. */
|
|
34
|
+
int xt_is_typed_array(xt_value value);
|
|
35
|
+
/** Element kind (0..8: U8, I8, U8C, U16, I16, U32, I32, F32, F64), or -1. */
|
|
36
|
+
int xt_typed_array_kind_of(xt_value value);
|
|
37
|
+
/** Read one element (coerced to a number) from a typed-array view. */
|
|
38
|
+
xt_value xt_typed_array_read(xt_value array, uint32_t index);
|
|
39
|
+
xt_value xt_typed_array_backing_buffer(xt_value value);
|
|
40
|
+
uint32_t xt_typed_array_view_offset(xt_value value);
|
|
41
|
+
/** Number of elements in a typed-array view. */
|
|
42
|
+
uint32_t xt_typed_array_length(xt_value value);
|
|
43
|
+
|
|
44
|
+
#endif /* XT_RT_BINARY_H */
|
package/runtime/rt_internal.h
CHANGED
|
@@ -61,10 +61,14 @@
|
|
|
61
61
|
#define XT_OBJECT_KIND_WEAK_MAP 17
|
|
62
62
|
#define XT_OBJECT_KIND_WEAK_SET 18
|
|
63
63
|
#define XT_OBJECT_KIND_WEAK_REF 19
|
|
64
|
+
/* An ArrayBuffer: an ordinary object whose *bytes* live in a plain `uint8_t`
|
|
65
|
+
* block instead of boxed values. Typed arrays and DataViews index that block
|
|
66
|
+
* directly, which is the difference between a geometry loop running at memory
|
|
67
|
+
* speed and one paying a runtime call per byte. */
|
|
68
|
+
#define XT_OBJECT_KIND_ARRAY_BUFFER 20
|
|
64
69
|
|
|
65
70
|
/* Common header for every heap object. `flags` bit 0 is the collector's mark
|
|
66
|
-
* bit; it is cleared on every surviving object at the end of a sweep. */
|
|
67
|
-
typedef struct xt_header {
|
|
71
|
+
* bit; it is cleared on every surviving object at the end of a sweep. */typedef struct xt_header {
|
|
68
72
|
uint8_t kind;
|
|
69
73
|
uint8_t flags;
|
|
70
74
|
uint16_t reserved;
|
|
@@ -73,6 +77,22 @@ typedef struct xt_header {
|
|
|
73
77
|
} xt_header;
|
|
74
78
|
|
|
75
79
|
#define XT_GC_MARK 0x01u
|
|
80
|
+
/** Block came from the small-block pool (see `xt_alloc.c`); the collector
|
|
81
|
+
* returns it to its size class instead of `free`. */
|
|
82
|
+
#define XT_GC_POOLED 0x02u
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Whether an allocation kind is an ordinary object with a property bag — the
|
|
86
|
+
* kinds the generic `xt_object_get`/`xt_set`/`keys`/inspect paths accept.
|
|
87
|
+
*
|
|
88
|
+
* An ArrayBuffer is one of them: it is an object that *also* owns a byte block,
|
|
89
|
+
* so its `byteLength`/`slice` stay ordinary properties and `Object.keys`
|
|
90
|
+
* behaves like it does for any other object.
|
|
91
|
+
*/
|
|
92
|
+
static inline int xt_kind_is_object(int kind) {
|
|
93
|
+
return kind == XT_OBJECT_KIND_OBJECT || kind == XT_OBJECT_KIND_ERROR ||
|
|
94
|
+
kind == XT_OBJECT_KIND_ARRAY_BUFFER;
|
|
95
|
+
}
|
|
76
96
|
|
|
77
97
|
/* A string is either *flat* (`flat` points at `capacity` bytes, the last one
|
|
78
98
|
* NUL) or a *cons* node (`flat == NULL`, `left`/`right` name the operands).
|
|
@@ -103,61 +123,7 @@ typedef struct {
|
|
|
103
123
|
uint32_t *limbs;
|
|
104
124
|
} xt_bigint;
|
|
105
125
|
|
|
106
|
-
|
|
107
|
-
/* String or Symbol value (see `xt_to_property_key`). */
|
|
108
|
-
xt_value key;
|
|
109
|
-
xt_value value;
|
|
110
|
-
/* Accessor properties (`get x()` / `set x(v)`) store the functions here;
|
|
111
|
-
* when set, `value` is ignored and property access invokes the getter. */
|
|
112
|
-
xt_value getter;
|
|
113
|
-
xt_value setter;
|
|
114
|
-
} xt_property;
|
|
115
|
-
|
|
116
|
-
/* Hidden-class descriptor for ordinary objects. Shapes are interned by their
|
|
117
|
-
* (parent, key) transition and never freed, so an object's shape pointer is a
|
|
118
|
-
* stable layout identity. Shape keys are rooted by a collector provider in
|
|
119
|
-
* xt_containers/shapes.inc. */
|
|
120
|
-
typedef struct xt_shape {
|
|
121
|
-
xt_value key;
|
|
122
|
-
uint32_t count;
|
|
123
|
-
struct xt_shape *parent;
|
|
124
|
-
struct xt_shape *next; /* hash-bucket chain */
|
|
125
|
-
struct xt_shape *all_next; /* every shape, for the GC root provider */
|
|
126
|
-
} xt_shape;
|
|
127
|
-
|
|
128
|
-
typedef struct {
|
|
129
|
-
xt_header header;
|
|
130
|
-
uint32_t count;
|
|
131
|
-
uint32_t capacity;
|
|
132
|
-
xt_property *properties;
|
|
133
|
-
xt_shape *shape;
|
|
134
|
-
xt_value prototype;
|
|
135
|
-
uint8_t frozen;
|
|
136
|
-
uint8_t is_array_base;
|
|
137
|
-
uint16_t reserved2;
|
|
138
|
-
/* Captured `Error.stack` for XT_OBJECT_KIND_ERROR, XT_UNDEFINED otherwise.
|
|
139
|
-
* Deliberately not a property: `Object.keys`, `for...in` and JSON.stringify
|
|
140
|
-
* must not see it, while `error.stack` returns it through `xt_get`. */
|
|
141
|
-
xt_value error_stack;
|
|
142
|
-
/* Optional dynamic-property view (host objects such as `element.style`); see
|
|
143
|
-
* `xt_object_hooks` in `rt.h`. NULL for ordinary objects. */
|
|
144
|
-
const xt_object_hooks *hooks;
|
|
145
|
-
void *hook_data;
|
|
146
|
-
} xt_object;
|
|
147
|
-
|
|
148
|
-
typedef struct {
|
|
149
|
-
xt_header header;
|
|
150
|
-
uint32_t length;
|
|
151
|
-
uint32_t capacity;
|
|
152
|
-
xt_value *items;
|
|
153
|
-
/* Named (non-index) properties such as `raw` on template strings or
|
|
154
|
-
* `index`/`input` on RegExp match results, stored in an `xt_object`. */
|
|
155
|
-
xt_value extra;
|
|
156
|
-
/* The array's [[Prototype]] (`Array.prototype` for ordinary arrays). Arrays
|
|
157
|
-
* are a distinct allocation kind, so this field is what lets
|
|
158
|
-
* `Object.getPrototypeOf([])` and `x instanceof <Array alias>` work. */
|
|
159
|
-
xt_value prototype;
|
|
160
|
-
} xt_array;
|
|
126
|
+
#include "rt_object.h"
|
|
161
127
|
|
|
162
128
|
typedef struct {
|
|
163
129
|
xt_header header;
|
|
@@ -208,8 +174,18 @@ void xt_gc_set_stack_base(void *base);
|
|
|
208
174
|
void xt_gc_arm(void);
|
|
209
175
|
/* Run a full collection now. Re-entrant calls are ignored. */
|
|
210
176
|
void xt_gc_collect(void);
|
|
177
|
+
/* Release the payload and the block of a swept object (xt_gc_release.c). */
|
|
178
|
+
void xt_gc_release(xt_header *header);
|
|
211
179
|
/* Override the automatic trigger threshold (bytes of live heap). */
|
|
212
180
|
void xt_gc_set_threshold(size_t bytes);
|
|
181
|
+
|
|
182
|
+
/* Small-block buffers allocated outside the collector (an object's property
|
|
183
|
+
* table, an array's items). `xt_raw_realloc` copies through a new block. */
|
|
184
|
+
void *xt_pool_alloc(size_t size);
|
|
185
|
+
void xt_pool_free_block(void *block, size_t size);
|
|
186
|
+
void *xt_raw_alloc(size_t size);
|
|
187
|
+
void xt_raw_free(void *pointer);
|
|
188
|
+
void *xt_raw_realloc(void *pointer, size_t new_size);
|
|
213
189
|
extern _Thread_local int xt_gc_worker_thread;
|
|
214
190
|
void xt_gc_verify_payloads(void); /* XT_GC_VERIFY=1 */
|
|
215
191
|
void xt_gc_debug_record_free(uintptr_t address, size_t size, int kind);
|
|
@@ -228,11 +204,11 @@ void xt_gc_register_root_provider(void (*provider)(void));
|
|
|
228
204
|
* region the caller records where its stack was suspended, so every active
|
|
229
205
|
* region is scanned and suspended callers stay reachable. */
|
|
230
206
|
void xt_gc_push_stack(uintptr_t low, uintptr_t high);
|
|
231
|
-
|
|
232
|
-
* `sp` stay live while a deeper generator region runs). */
|
|
207
|
+
void xt_gc_init_main_stack(uintptr_t high);
|
|
233
208
|
void xt_gc_suspend(uintptr_t sp);
|
|
234
209
|
void xt_gc_pop_stack(void);
|
|
235
|
-
|
|
210
|
+
size_t xt_gc_stack_region_count(void);
|
|
211
|
+
void xt_gc_stack_region_bounds(size_t index, uintptr_t current, uintptr_t *low, uintptr_t *high);
|
|
236
212
|
/* Marking primitives used by root providers and per-kind trace hooks. */
|
|
237
213
|
void xt_gc_mark_value(xt_value value);
|
|
238
214
|
void xt_gc_mark_header(xt_header *header);
|
|
@@ -413,6 +389,12 @@ xt_value xt_iter_open(xt_value value);
|
|
|
413
389
|
|
|
414
390
|
/* xbintsc clock helpers (xt_loop.c): monotonic milliseconds for
|
|
415
391
|
* `performance.now`, wall-clock milliseconds for `Date`. */
|
|
392
|
+
/** Snapshot the `performance.now()` time origin (the generated `main` calls
|
|
393
|
+
* this at startup through `xt_gc_init`). */
|
|
394
|
+
void xt_time_init(void);
|
|
395
|
+
|
|
396
|
+
/* Opt-in runtime call counters (`XT_PROFILE=1`, see xt_profile.c). */
|
|
397
|
+
#include "rt_profile.h"
|
|
416
398
|
double xt_monotonic_ms(void);
|
|
417
399
|
double xt_wallclock_ms(void);
|
|
418
400
|
|
|
@@ -592,9 +574,19 @@ const char *xt_typed_array_name_of(int kind);
|
|
|
592
574
|
/* ArrayBuffer helpers (xt_array_buffer.c). */
|
|
593
575
|
int xt_is_array_buffer(xt_value value);
|
|
594
576
|
uint32_t xt_array_buffer_byte_length(xt_value value);
|
|
577
|
+
/* The backing bytes, or NULL for a detached/zero-length/unrelated value.
|
|
578
|
+
* `byte_length` receives the buffer's length. Valid until the buffer is
|
|
579
|
+
* detached or resized — callers use it within one operation. */
|
|
580
|
+
uint8_t *xt_array_buffer_bytes(xt_value buffer, uint32_t *byte_length);
|
|
595
581
|
uint8_t xt_array_buffer_get_byte(xt_value buffer, uint32_t index);
|
|
596
582
|
void xt_array_buffer_set_byte(xt_value buffer, uint32_t index, uint8_t value);
|
|
597
583
|
xt_value xt_array_buffer_ctor(int32_t argc, xt_value *argv);
|
|
584
|
+
/** The `ArrayBuffer.prototype.slice` method value `xt_get` serves. */
|
|
585
|
+
xt_value xt_array_buffer_slice_value(void);
|
|
586
|
+
/* `byteLength`/`slice` as served from the buffer's kind (XT_UNDEFINED for any
|
|
587
|
+
* other key); shared by `xt_get` and `xt_object_get`. */
|
|
588
|
+
xt_value xt_array_buffer_served_property(xt_value buffer, xt_value key);
|
|
598
589
|
#include "xt_web.h"
|
|
599
590
|
#include "xt_async_io.h"
|
|
600
591
|
#endif /* XT_RT_INTERNAL_H */
|
|
592
|
+
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* xbintsc runtime — object layout.
|
|
3
|
+
*
|
|
4
|
+
* Included by `rt_internal.h`, after the common `xt_header` and the value tags,
|
|
5
|
+
* because every container kind below starts with that header. Keeping the
|
|
6
|
+
* layouts in one small file makes it obvious what an "object" is in this runtime:
|
|
7
|
+
* a header, a property bag with an interned hidden-class shape, a prototype, and
|
|
8
|
+
* the per-kind side slots (an ArrayBuffer's bytes, a typed-array view's resolved
|
|
9
|
+
* base, an Error's captured stack, a host view's hooks).
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
#ifndef XT_RT_OBJECT_H
|
|
13
|
+
#define XT_RT_OBJECT_H
|
|
14
|
+
|
|
15
|
+
typedef struct {
|
|
16
|
+
/* String or Symbol value (see `xt_to_property_key`). */
|
|
17
|
+
xt_value key;
|
|
18
|
+
xt_value value;
|
|
19
|
+
/* Accessor properties (`get x()` / `set x(v)`) store the functions here;
|
|
20
|
+
* when set, `value` is ignored and property access invokes the getter. */
|
|
21
|
+
xt_value getter;
|
|
22
|
+
xt_value setter;
|
|
23
|
+
} xt_property;
|
|
24
|
+
|
|
25
|
+
/* Hidden-class descriptor for ordinary objects. Shapes are interned by their
|
|
26
|
+
* (parent, key) transition and never freed, so an object's shape pointer is a
|
|
27
|
+
* stable layout identity. Shape keys are rooted by a collector provider in
|
|
28
|
+
* xt_containers/shapes.inc. */
|
|
29
|
+
typedef struct xt_shape {
|
|
30
|
+
xt_value key;
|
|
31
|
+
uint32_t count;
|
|
32
|
+
struct xt_shape *parent;
|
|
33
|
+
struct xt_shape *next; /* hash-bucket chain */
|
|
34
|
+
struct xt_shape *all_next; /* every shape, for the GC root provider */
|
|
35
|
+
} xt_shape;
|
|
36
|
+
|
|
37
|
+
typedef struct {
|
|
38
|
+
xt_header header;
|
|
39
|
+
uint32_t count;
|
|
40
|
+
uint32_t capacity;
|
|
41
|
+
xt_property *properties;
|
|
42
|
+
xt_shape *shape;
|
|
43
|
+
xt_value prototype;
|
|
44
|
+
uint8_t frozen;
|
|
45
|
+
uint8_t is_array_base;
|
|
46
|
+
uint16_t reserved2;
|
|
47
|
+
/* Captured `Error.stack` for XT_OBJECT_KIND_ERROR, XT_UNDEFINED otherwise.
|
|
48
|
+
* Deliberately not a property: `Object.keys`, `for...in` and JSON.stringify
|
|
49
|
+
* must not see it, while `error.stack` returns it through `xt_get`. */
|
|
50
|
+
xt_value error_stack;
|
|
51
|
+
/* Optional dynamic-property view (host objects such as `element.style`); see
|
|
52
|
+
* `xt_object_hooks` in `rt.h`. NULL for ordinary objects. */
|
|
53
|
+
const xt_object_hooks *hooks;
|
|
54
|
+
void *hook_data;
|
|
55
|
+
/* XT_OBJECT_KIND_ARRAY_BUFFER only: the backing bytes, owned by this object
|
|
56
|
+
* and freed by the collector when it is swept. Views resolve them through
|
|
57
|
+
* `xt_array_buffer_bytes` and index them directly. */
|
|
58
|
+
uint8_t *buffer_bytes;
|
|
59
|
+
uint32_t buffer_length;
|
|
60
|
+
/* Typed-array views only: the bytes this view indexes (the buffer's block at
|
|
61
|
+
* the view's byte offset) and how many are available from there, set once in
|
|
62
|
+
* `xt_ta_view` and read on the per-element path. A buffer's block never moves
|
|
63
|
+
* while it is alive, and the view keeps its buffer alive as a property, so no
|
|
64
|
+
* invalidation is needed. NULL for every other object. */
|
|
65
|
+
uint8_t *view_bytes;
|
|
66
|
+
uint32_t view_length;
|
|
67
|
+
} xt_object;
|
|
68
|
+
|
|
69
|
+
typedef struct {
|
|
70
|
+
xt_header header;
|
|
71
|
+
uint32_t length;
|
|
72
|
+
uint32_t capacity;
|
|
73
|
+
xt_value *items;
|
|
74
|
+
/* Named (non-index) properties such as `raw` on template strings or
|
|
75
|
+
* `index`/`input` on RegExp match results, stored in an `xt_object`. */
|
|
76
|
+
xt_value extra;
|
|
77
|
+
/* The array's [[Prototype]] (`Array.prototype` for ordinary arrays). Arrays
|
|
78
|
+
* are a distinct allocation kind, so this field is what lets
|
|
79
|
+
* `Object.getPrototypeOf([])` and `x instanceof <Array alias>` work. */
|
|
80
|
+
xt_value prototype;
|
|
81
|
+
} xt_array;
|
|
82
|
+
|
|
83
|
+
#endif /* XT_RT_OBJECT_H */
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* xbintsc runtime — opt-in call counters.
|
|
3
|
+
*
|
|
4
|
+
* Included by `rt_internal.h` so every runtime unit can bump a counter with
|
|
5
|
+
* `XT_PROFILE_TICK`; `xt_profile.c` owns the storage and the exit dump. Kept in
|
|
6
|
+
* its own header so the shared runtime header stays within the size budget.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#ifndef XT_RT_PROFILE_H
|
|
10
|
+
#define XT_RT_PROFILE_H
|
|
11
|
+
|
|
12
|
+
enum {
|
|
13
|
+
XT_PROFILE_ALLOC,
|
|
14
|
+
XT_PROFILE_GC,
|
|
15
|
+
XT_PROFILE_MATH,
|
|
16
|
+
XT_PROFILE_SET,
|
|
17
|
+
XT_PROFILE_GET_IC,
|
|
18
|
+
XT_PROFILE_METHOD_IC,
|
|
19
|
+
XT_PROFILE_OBJECT_SET,
|
|
20
|
+
XT_PROFILE_OBJECT_INSERT,
|
|
21
|
+
XT_PROFILE_OBJECT_FIND,
|
|
22
|
+
XT_PROFILE_OBJECT_RESERVE,
|
|
23
|
+
XT_PROFILE_CLOSURE_CALL,
|
|
24
|
+
XT_PROFILE_ARRAY_GET,
|
|
25
|
+
XT_PROFILE_STRING_CSTR,
|
|
26
|
+
XT_PROFILE_TYPED_READ,
|
|
27
|
+
XT_PROFILE_TYPED_WRITE,
|
|
28
|
+
XT_PROFILE_COUNT
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
extern int xt_profile_on;
|
|
32
|
+
extern unsigned long long xt_profile_calls[XT_PROFILE_COUNT];
|
|
33
|
+
void xt_profile_init(void);
|
|
34
|
+
/* Diagnostics for allocation pressure: how many blocks of each object kind are
|
|
35
|
+
* allocated, and which C-string property names are looked up most (the string
|
|
36
|
+
* created by `xt_object_get_cstr` is one allocation per lookup). */
|
|
37
|
+
void xt_profile_note_alloc(int kind);
|
|
38
|
+
void xt_profile_note_cstr(const char *key);
|
|
39
|
+
|
|
40
|
+
#define XT_PROFILE_TICK(slot) \
|
|
41
|
+
do { \
|
|
42
|
+
if (xt_profile_on) xt_profile_calls[slot]++; \
|
|
43
|
+
} while (0)
|
|
44
|
+
|
|
45
|
+
#endif /* XT_RT_PROFILE_H */
|