From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- js/src/gdb/tests/test-jsid.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 js/src/gdb/tests/test-jsid.cpp (limited to 'js/src/gdb/tests/test-jsid.cpp') diff --git a/js/src/gdb/tests/test-jsid.cpp b/js/src/gdb/tests/test-jsid.cpp new file mode 100644 index 0000000000..e679b956a3 --- /dev/null +++ b/js/src/gdb/tests/test-jsid.cpp @@ -0,0 +1,45 @@ +#include "gdb-tests.h" + +#include "js/Id.h" // jsid, JS::PropertyKey +#include "js/String.h" +#include "js/Symbol.h" + +FRAGMENT(jsid, simple) { + const char* chars = "moon"; + JS::Rooted string(cx, JS_NewStringCopyZ(cx, chars)); + JS::Rooted interned(cx, JS_AtomizeAndPinString(cx, chars)); + JS::Rooted string_id(cx, JS::PropertyKey::fromPinnedString(interned)); + JS::Rooted int_id(cx, JS::PropertyKey::Int(1729)); + JS::Rooted unique_symbol_id( + cx, JS::PropertyKey::Symbol(JS::NewSymbol(cx, interned))); + JS::Rooted registry_symbol_id( + cx, JS::PropertyKey::Symbol(JS::GetSymbolFor(cx, interned))); + JS::Rooted well_known_symbol_id( + cx, JS::GetWellKnownSymbolKey(cx, JS::SymbolCode::iterator)); + jsid void_id = JS::PropertyKey::Void(); + + breakpoint(); + + use(string_id); + use(int_id); + use(unique_symbol_id); + use(registry_symbol_id); + use(well_known_symbol_id); + use(void_id); +} + +void jsid_handles(JS::Handle jsid_handle, + JS::MutableHandle mutable_jsid_handle) { + // Prevent the linker from unifying this function with others that are + // equivalent in machine code but not type. + fprintf(stderr, "Called " __FILE__ ":jsid_handles\n"); + breakpoint(); +} + +FRAGMENT(jsid, handles) { + const char* chars = "shovel"; + JS::Rooted string(cx, JS_NewStringCopyZ(cx, chars)); + JS::Rooted interned(cx, JS_AtomizeAndPinString(cx, chars)); + JS::Rooted string_id(cx, JS::PropertyKey::fromPinnedString(interned)); + jsid_handles(string_id, &string_id); +} -- cgit v1.2.3