LibJS: Revert common error types to only hold a single string
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

Before porting to UTF-16, these instances held a String. The port to
UTF-16 changed them to hold the original string as a StringView, and
lazily allocated the UTF-16 message as needed. This somehow negatively
impacting the zlib.js benchmark in the Octane suite.
This commit is contained in:
Timothy Flynn 2025-08-17 18:37:47 -04:00 committed by Jelle Raaijmakers
commit 695bbcb991
Notes: github-actions[bot] 2025-08-17 23:44:52 +00:00
2 changed files with 6 additions and 14 deletions

View file

@ -9,15 +9,8 @@
namespace JS {
#define __ENUMERATE_JS_ERROR(name, message) \
const ErrorType ErrorType::name = ErrorType(message##sv);
const ErrorType ErrorType::name = ErrorType(message##_utf16);
JS_ENUMERATE_ERROR_TYPES(__ENUMERATE_JS_ERROR)
#undef __ENUMERATE_JS_ERROR
Utf16String const& ErrorType::message() const
{
if (m_message.is_empty())
m_message = Utf16String::from_utf8_without_validation(m_format);
return m_message;
}
}

View file

@ -314,17 +314,16 @@ public:
JS_ENUMERATE_ERROR_TYPES(__ENUMERATE_JS_ERROR)
#undef __ENUMERATE_JS_ERROR
StringView format() const { return m_format; }
Utf16String const& message() const;
StringView format() const { return m_message.ascii_view(); }
Utf16String const& message() const { return m_message; }
private:
explicit ErrorType(StringView format)
: m_format(format)
explicit ErrorType(Utf16String message)
: m_message(move(message))
{
}
StringView m_format;
mutable Utf16String m_message;
Utf16String m_message;
};
}