LibJS: Add missing internal object string printing for debugging

When testing with JS_BYTECODE_DEBUG macro defined or using the All_Debug
profile, internal objects were not known in Value class to the function
Value::to_string_without_side_effects leading to a VERIFICATION FAILED
when running the test-js or test-web programs.

Internal objects are known in the Value class as cells, and do not have
a dedicated tag to identify them. Internal objects are detected using
is_cell function call, but only after all other types have been
checked as other types of non-internal objects can also be cells.

Both the String and Utf16String version of the function were updated.
This commit is contained in:
Rocco Corsi 2025-11-03 21:07:22 -05:00 committed by Andreas Kling
parent 7260159b8f
commit 11dc254d27
Notes: github-actions[bot] 2025-11-30 18:23:47 +00:00

View file

@ -386,6 +386,8 @@ String Value::to_string_without_side_effects() const
case EMPTY_TAG:
return "<empty>"_string;
default:
if (is_cell())
return String::formatted("[internal object {}]", as_cell().class_name()).release_value();
VERIFY_NOT_REACHED();
}
}
@ -417,6 +419,8 @@ Utf16String Value::to_utf16_string_without_side_effects() const
case EMPTY_TAG:
return "<empty>"_utf16;
default:
if (is_cell())
return Utf16String::formatted("[internal object {}]", as_cell().class_name());
VERIFY_NOT_REACHED();
}
}