mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 07:36:50 +00:00
LibJS/Bytecode: Don't reparse regular expressions on instantiation
The RegExpLiteral AST node already has the parsed regex::Parser::Result so let's plumb that over to the bytecode executable instead of reparsing the regex every time NewRegExp is executed. ~12% speed-up on language/literals/regexp/S7.8.5_A2.1_T2.js in test262.
This commit is contained in:
@@ -289,7 +289,12 @@ Bytecode::CodeGenerationErrorOr<void> RegExpLiteral::generate_bytecode(Bytecode:
|
||||
{
|
||||
auto source_index = generator.intern_string(m_pattern);
|
||||
auto flags_index = generator.intern_string(m_flags);
|
||||
generator.emit<Bytecode::Op::NewRegExp>(source_index, flags_index);
|
||||
auto regex_index = generator.intern_regex(Bytecode::ParsedRegex {
|
||||
.regex = m_parsed_regex,
|
||||
.pattern = m_parsed_pattern,
|
||||
.flags = m_parsed_flags,
|
||||
});
|
||||
generator.emit<Bytecode::Op::NewRegExp>(source_index, flags_index, regex_index);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user