mirror of
https://github.com/RGBCube/serenity
synced 2025-05-19 00:55:08 +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:
parent
a098f38cab
commit
c0f985ffcf
9 changed files with 109 additions and 4 deletions
|
@ -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 {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue