Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1553)

Unified Diff: runtime/vm/intrinsifier_x64.cc

Issue 2510783002: VM: Optimize RegExp.matchAsPrefix(...) by generating a sticky RegExp specialization. (Closed)
Patch Set: Done Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/intrinsifier_x64.cc
diff --git a/runtime/vm/intrinsifier_x64.cc b/runtime/vm/intrinsifier_x64.cc
index b888804ec48014899ce266223dccc7c3d406fc48..9f6f053fb132aa5cde0413227b9075429b11bf2d 100644
--- a/runtime/vm/intrinsifier_x64.cc
+++ b/runtime/vm/intrinsifier_x64.cc
@@ -2193,7 +2193,7 @@ void Intrinsifier::TwoByteString_equality(Assembler* assembler) {
void Intrinsifier::RegExp_ExecuteMatch(Assembler* assembler) {
erikcorry 2016/11/17 13:56:17 Can't RegExp_ExecuteMatch and RegExp_ExecuteMatchS
Vyacheslav Egorov (Google) 2016/11/17 16:51:33 In this case code below would have to check for bo
- if (FLAG_interpret_irregexp) return;
+ if (FLAG_interpret_irregexp || FLAG_precompiled_runtime) return;
rmacnak 2016/11/17 00:49:52 Why add this? FLAG_interpret_irregexp should alrea
Vyacheslav Egorov (Google) 2016/11/17 16:51:33 There was a code somewhere that checked both so I
static const intptr_t kRegExpParamOffset = 3 * kWordSize;
static const intptr_t kStringParamOffset = 2 * kWordSize;
@@ -2211,7 +2211,41 @@ void Intrinsifier::RegExp_ExecuteMatch(Assembler* assembler) {
__ LoadClassId(RDI, RDI);
__ SubImmediate(RDI, Immediate(kOneByteStringCid));
__ movq(RAX, FieldAddress(RBX, RDI, TIMES_8,
- RegExp::function_offset(kOneByteStringCid)));
+ RegExp::function_offset(kOneByteStringCid,
+ /*sticky=*/false)));
+
+ // Registers are now set up for the lazy compile stub. It expects the function
+ // in RAX, the argument descriptor in R10, and IC-Data in RCX.
+ __ xorq(RCX, RCX);
+
+ // Tail-call the function.
+ __ movq(CODE_REG, FieldAddress(RAX, Function::code_offset()));
+ __ movq(RDI, FieldAddress(RAX, Function::entry_point_offset()));
+ __ jmp(RDI);
+}
+
+
+void Intrinsifier::RegExp_ExecuteMatchSticky(Assembler* assembler) {
+ if (FLAG_interpret_irregexp || FLAG_precompiled_runtime) return;
+
+ static const intptr_t kRegExpParamOffset = 3 * kWordSize;
+ static const intptr_t kStringParamOffset = 2 * kWordSize;
+ // start_index smi is located at offset 1.
+
+ // Incoming registers:
+ // RAX: Function. (Will be loaded with the specialized matcher function.)
+ // RCX: Unknown. (Must be GC safe on tail call.)
+ // R10: Arguments descriptor. (Will be preserved.)
+
+ // Load the specialized function pointer into RAX. Leverage the fact the
+ // string CIDs as well as stored function pointers are in sequence.
+ __ movq(RBX, Address(RSP, kRegExpParamOffset));
+ __ movq(RDI, Address(RSP, kStringParamOffset));
+ __ LoadClassId(RDI, RDI);
+ __ SubImmediate(RDI, Immediate(kOneByteStringCid));
+ __ movq(RAX, FieldAddress(RBX, RDI, TIMES_8,
+ RegExp::function_offset(kOneByteStringCid,
+ /*sticky=*/true)));
// Registers are now set up for the lazy compile stub. It expects the function
// in RAX, the argument descriptor in R10, and IC-Data in RCX.

Powered by Google App Engine
This is Rietveld 408576698