circuitpython/tests/ports/webassembly
Damien George ffa98cb014 webassembly/proxy_js: Reuse JsProxy ref if object matches.
This reduces memory use by reusing objects, and improves identity/equality
relationships of JavaScript objects on the Python side.

In 77bd8fe5b8 PyProxy's were reused when the
same Python object was proxied across to JavaScript.  This commit does the
same thing but for JsProxy's going from JS to Python.  If an existing
JsProxy reference exists for the JS object about to be proxied across, then
it's reused.

This helps reduce the number of alive objects (memory use), and, more
importantly, improves equality relationships of JavaScript objects on the
Python side.  Eg we now get, on the Python side:

    import js

    print(js.Object == js.Object)

that prints True.  Previously it was False.

Note that this change does not make identity work with `is`, for example
`js.Object is js.Object` is actually False.  With more work that could be
made True but for now we leave that as-is.

The behaviour with this commit matches Pyodide semantics.

Signed-off-by: Damien George <damien@micropython.org>
2025-07-31 11:40:50 +10:00
..
asyncio_await_resolve_no_arg.mjs webassembly/asyncio: Fix case where a Promise is resolved with no arg. 2024-05-13 11:48:41 +10:00
asyncio_await_resolve_no_arg.mjs.exp webassembly/asyncio: Fix case where a Promise is resolved with no arg. 2024-05-13 11:48:41 +10:00
asyncio_create_task.mjs webassembly: Add JavaScript-based asyncio support. 2024-04-24 16:24:00 +10:00
asyncio_create_task.mjs.exp webassembly: Add JavaScript-based asyncio support. 2024-04-24 16:24:00 +10:00
asyncio_sleep.mjs webassembly: Add JavaScript-based asyncio support. 2024-04-24 16:24:00 +10:00
asyncio_sleep.mjs.exp webassembly: Add JavaScript-based asyncio support. 2024-04-24 16:24:00 +10:00
asyncio_top_level_await.mjs webassembly/asyncio: Schedule run loop when tasks are pushed to queue. 2024-06-20 00:11:54 +10:00
asyncio_top_level_await.mjs.exp webassembly/asyncio: Schedule run loop when tasks are pushed to queue. 2024-06-20 00:11:54 +10:00
await_error_handling.mjs webassembly/proxy_c: Ensure objs thrown into generators are exceptions. 2024-05-13 11:52:17 +10:00
await_error_handling.mjs.exp webassembly/proxy_js: Create a special "undefined" type for Python. 2024-05-16 12:49:10 +10:00
await_js_async_py.mjs webassembly/proxy_c: Ensure return value of async fun is passed to JS. 2024-03-30 13:13:51 +11:00
await_js_async_py.mjs.exp webassembly/proxy_c: Ensure return value of async fun is passed to JS. 2024-03-30 13:13:51 +11:00
basic.js tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
basic.js.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
filesystem.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
filesystem.mjs.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
float.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
float.mjs.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
fun_call.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
fun_call.mjs.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
fun_proxy.mjs webassembly/proxy_js: Allow a Python proxy of a function to be undone. 2024-03-30 13:13:51 +11:00
fun_proxy.mjs.exp webassembly/proxy_js: Allow a Python proxy of a function to be undone. 2024-03-30 13:13:51 +11:00
fun_py_callback_js.mjs webassembly/proxy_js: Promote Python thenable to a Promise. 2024-03-30 13:13:51 +11:00
fun_py_callback_js.mjs.exp webassembly/proxy_js: Promote Python thenable to a Promise. 2024-03-30 13:13:51 +11:00
globals.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
globals.mjs.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
heap_expand.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
heap_expand.mjs.exp webassembly: Reuse PyProxy objects when they are the same Python object. 2024-07-19 11:55:24 +10:00
iterator.mjs webassembly/objpyproxy: Implement JS iterator protocol for Py iterables. 2024-05-07 00:20:56 +10:00
iterator.mjs.exp webassembly/objpyproxy: Implement JS iterator protocol for Py iterables. 2024-05-07 00:20:56 +10:00
js_proxy_attribute.mjs webassembly/objjsproxy: Lookup attributes without testing they exist. 2024-06-28 11:40:24 +10:00
js_proxy_attribute.mjs.exp webassembly/objjsproxy: Lookup attributes without testing they exist. 2024-06-28 11:40:24 +10:00
js_proxy_iterator.mjs webassembly/objjsproxy: Implement proxying of JS iterable protocol. 2024-06-18 22:14:34 +10:00
js_proxy_iterator.mjs.exp webassembly/objjsproxy: Implement proxying of JS iterable protocol. 2024-06-18 22:14:34 +10:00
jsffi_create_proxy.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
jsffi_create_proxy.mjs.exp webassembly/proxy_js: Create a special "undefined" type for Python. 2024-05-16 12:49:10 +10:00
jsffi_to_js.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
jsffi_to_js.mjs.exp webassembly/proxy_js: Create a special "undefined" type for Python. 2024-05-16 12:49:10 +10:00
method_bind_behaviour.mjs webassembly/objjsproxy: Fix binding of self to JavaScript methods. 2025-07-24 14:38:08 +10:00
method_bind_behaviour.mjs.exp webassembly/objjsproxy: Fix binding of self to JavaScript methods. 2025-07-24 14:38:08 +10:00
override_new.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
override_new.mjs.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
promise_with_resolvers.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
promise_with_resolvers.mjs.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
py_proxy_delete.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
py_proxy_delete.mjs.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
py_proxy_dict.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
py_proxy_dict.mjs.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
py_proxy_dict_undefined.mjs webassembly/proxy_c: Return undefined if dict lookup failed on JS side. 2024-05-16 12:49:42 +10:00
py_proxy_dict_undefined.mjs.exp webassembly/proxy_c: Return undefined if dict lookup failed on JS side. 2024-05-16 12:49:42 +10:00
py_proxy_get.mjs webassembly/objpyproxy: Avoid throwing on implicit symbols access. 2025-07-17 14:37:53 +10:00
py_proxy_get.mjs.exp webassembly/objpyproxy: Avoid throwing on implicit symbols access. 2025-07-17 14:37:53 +10:00
py_proxy_has.mjs webassembly/objpyproxy: Avoid throwing on symbol or iterator has-check. 2025-07-04 15:08:03 +10:00
py_proxy_has.mjs.exp webassembly/objpyproxy: Avoid throwing on symbol or iterator has-check. 2025-07-04 15:08:03 +10:00
py_proxy_identity.mjs webassembly/proxy_js: Reuse JsProxy ref if object matches. 2025-07-31 11:40:50 +10:00
py_proxy_identity.mjs.exp webassembly/proxy_js: Reuse JsProxy ref if object matches. 2025-07-31 11:40:50 +10:00
py_proxy_own_keys.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
py_proxy_own_keys.mjs.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
py_proxy_set.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
py_proxy_set.mjs.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
py_proxy_to_js.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
py_proxy_to_js.mjs.exp webassembly/proxy_js: Revert back to converting Py None to JS null. 2024-05-16 12:44:43 +10:00
register_js_module.js tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
register_js_module.js.exp webassembly/proxy_js: Create a special "undefined" type for Python. 2024-05-16 12:49:10 +10:00
run_python_async.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
run_python_async.mjs.exp webassembly/proxy_js: Reuse JsProxy ref if object matches. 2025-07-31 11:40:50 +10:00
run_python_async2.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
run_python_async2.mjs.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
run_python_async_error.mjs webassembly/proxy_c: Reject promises with a PythonError instance. 2024-05-06 14:04:13 +10:00
run_python_async_error.mjs.exp webassembly/proxy_c: Reject promises with a PythonError instance. 2024-05-06 14:04:13 +10:00
run_python_async_no_await.mjs webassembly/api: Resolve thenables returned from runPythonAsync. 2024-05-07 11:33:05 +10:00
run_python_async_no_await.mjs.exp webassembly/api: Resolve thenables returned from runPythonAsync. 2024-05-07 11:33:05 +10:00
this_behaviour.mjs tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
this_behaviour.mjs.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
various.js tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00
various.js.exp tests/ports/webassembly: Add webassembly JS tests. 2024-03-22 14:31:25 +11:00