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

Unified Diff: src/x64/regexp-macro-assembler-x64.cc

Issue 18014003: Add X32 port into V8 (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 7 years, 6 months 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: src/x64/regexp-macro-assembler-x64.cc
===================================================================
--- src/x64/regexp-macro-assembler-x64.cc (revision 15486)
+++ src/x64/regexp-macro-assembler-x64.cc (working copy)
@@ -115,6 +115,7 @@
*/
#define __ ACCESS_MASM((&masm_))
+#define __k __
RegExpMacroAssemblerX64::RegExpMacroAssemblerX64(
Mode mode,
@@ -157,7 +158,7 @@
void RegExpMacroAssemblerX64::AdvanceCurrentPosition(int by) {
if (by != 0) {
- __ addq(rdi, Immediate(by * char_size()));
+ __k addq(rdi, Immediate(by * char_size()));
}
}
@@ -241,8 +242,14 @@
int start_reg,
Label* on_no_match) {
Label fallthrough;
+#ifndef V8_TARGET_ARCH_X32
__ movq(rdx, register_location(start_reg)); // Offset of start of capture
__ movq(rbx, register_location(start_reg + 1)); // Offset of end of capture
+#else
+ __ movsxlq(rdx, register_location(start_reg)); // Offset of start of capture
+ // Offset of end of capture
+ __ movsxlq(rbx, register_location(start_reg + 1));
+#endif
__ subq(rbx, rdx); // Length of capture.
// -----------------------
@@ -316,16 +323,16 @@
// Compute new value of character position after the matched part.
__ movq(rdi, r11);
- __ subq(rdi, rsi);
+ __k subq(rdi, rsi);
} else {
ASSERT(mode_ == UC16);
// Save important/volatile registers before calling C function.
#ifndef _WIN64
// Caller save on Linux and callee save in Windows.
- __ push(rsi);
- __ push(rdi);
+ __k push(rsi);
+ __k push(rdi);
#endif
- __ push(backtrack_stackpointer());
+ __k push(backtrack_stackpointer());
static const int num_arguments = 4;
__ PrepareCallCFunction(num_arguments);
@@ -367,10 +374,10 @@
// Restore original values before reacting on result value.
__ Move(code_object_pointer(), masm_.CodeObject());
- __ pop(backtrack_stackpointer());
+ __k pop(backtrack_stackpointer());
#ifndef _WIN64
- __ pop(rdi);
- __ pop(rsi);
+ __k pop(rdi);
+ __k pop(rsi);
#endif
// Check if function returned non-zero for success or zero for failure.
@@ -378,7 +385,7 @@
BranchOrBacktrack(zero, on_no_match);
// On success, increment position by length of capture.
// Requires that rbx is callee save (true for both Win64 and AMD64 ABIs).
- __ addq(rdi, rbx);
+ __k addq(rdi, rbx);
}
__ bind(&fallthrough);
}
@@ -390,8 +397,13 @@
Label fallthrough;
// Find length of back-referenced capture.
+#ifndef V8_TARGET_ARCH_X32
__ movq(rdx, register_location(start_reg));
__ movq(rax, register_location(start_reg + 1));
+#else
+ __ movsxlq(rdx, register_location(start_reg));
+ __ movsxlq(rax, register_location(start_reg + 1));
+#endif
__ subq(rax, rdx); // Length to check.
// Fail on partial or illegal capture (start of capture after end of capture).
@@ -442,7 +454,7 @@
// Success.
// Set current character position to position after match.
__ movq(rdi, rbx);
- __ subq(rdi, rsi);
+ __k subq(rdi, rsi);
__ bind(&fallthrough);
}
@@ -681,31 +693,40 @@
#ifdef _WIN64
// MSVC passes arguments in rcx, rdx, r8, r9, with backing stack slots.
// Store register parameters in pre-allocated stack slots,
- __ movq(Operand(rbp, kInputString), rcx);
- __ movq(Operand(rbp, kStartIndex), rdx); // Passed as int32 in edx.
- __ movq(Operand(rbp, kInputStart), r8);
- __ movq(Operand(rbp, kInputEnd), r9);
+ __k movq(Operand(rbp, kInputString), rcx);
+ __k movq(Operand(rbp, kStartIndex), rdx); // Passed as int32 in edx.
+ __k movq(Operand(rbp, kInputStart), r8);
+ __k movq(Operand(rbp, kInputEnd), r9);
// Callee-save on Win64.
- __ push(rsi);
- __ push(rdi);
- __ push(rbx);
+ __k push(rsi);
+ __k push(rdi);
+ __k push(rbx);
#else
// GCC passes arguments in rdi, rsi, rdx, rcx, r8, r9 (and then on stack).
// Push register parameters on stack for reference.
+#ifndef V8_TARGET_ARCH_X32
ASSERT_EQ(kInputString, -1 * kPointerSize);
ASSERT_EQ(kStartIndex, -2 * kPointerSize);
ASSERT_EQ(kInputStart, -3 * kPointerSize);
ASSERT_EQ(kInputEnd, -4 * kPointerSize);
ASSERT_EQ(kRegisterOutput, -5 * kPointerSize);
ASSERT_EQ(kNumOutputRegisters, -6 * kPointerSize);
- __ push(rdi);
- __ push(rsi);
- __ push(rdx);
- __ push(rcx);
- __ push(r8);
- __ push(r9);
+#else
+ ASSERT_EQ(kInputString, -1 * kHWRegSize);
+ ASSERT_EQ(kStartIndex, -2 * kHWRegSize);
+ ASSERT_EQ(kInputStart, -3 * kHWRegSize);
+ ASSERT_EQ(kInputEnd, -4 * kHWRegSize);
+ ASSERT_EQ(kRegisterOutput, -5 * kHWRegSize);
+ ASSERT_EQ(kNumOutputRegisters, -6 * kHWRegSize);
+#endif
+ __k push(rdi);
+ __k push(rsi);
+ __k push(rdx);
+ __k push(rcx);
+ __k push(r8);
+ __k push(r9);
- __ push(rbx); // Callee-save
+ __k push(rbx); // Callee-save
#endif
__ push(Immediate(0)); // Number of successful matches in a global regexp.
@@ -747,11 +768,11 @@
// Load input position.
__ movq(rdi, Operand(rbp, kInputStart));
// Set up rdi to be negative offset from string end.
- __ subq(rdi, rsi);
+ __k subq(rdi, rsi);
// Set rax to address of char before start of the string
// (effectively string position -1).
__ movq(rbx, Operand(rbp, kStartIndex));
- __ neg(rbx);
+ __k neg(rbx);
if (mode_ == UC16) {
__ lea(rax, Operand(rdi, rbx, times_2, -char_size()));
} else {
@@ -799,8 +820,8 @@
Label init_loop;
__ bind(&init_loop);
__ movq(Operand(rbp, rcx, times_1, 0), rax);
- __ subq(rcx, Immediate(kPointerSize));
- __ cmpq(rcx,
+ __k subq(rcx, Immediate(kPointerSize));
+ __k cmpq(rcx,
Immediate(kRegisterZero - num_saved_registers_ * kPointerSize));
__ j(greater, &init_loop);
} else { // Unroll the loop.
@@ -831,7 +852,11 @@
__ addq(rcx, rdx);
}
for (int i = 0; i < num_saved_registers_; i++) {
+#ifndef V8_TARGET_ARCH_X32
__ movq(rax, register_location(i));
+#else
+ __ movsxlq(rax, register_location(i));
+#endif
if (i == 0 && global_with_zero_length_check()) {
// Keep capture start in rdx for the zero-length check later.
__ movq(rdx, rax);
@@ -875,9 +900,9 @@
__ j(zero, &exit_label_, Label::kNear);
// Advance current position after a zero-length match.
if (mode_ == UC16) {
- __ addq(rdi, Immediate(2));
+ __k addq(rdi, Immediate(2));
} else {
- __ incq(rdi);
+ __k incq(rdi);
}
}
@@ -897,9 +922,9 @@
#ifdef _WIN64
// Restore callee save registers.
__ lea(rsp, Operand(rbp, kLastCalleeSaveRegister));
- __ pop(rbx);
- __ pop(rdi);
- __ pop(rsi);
+ __k pop(rbx);
+ __k pop(rdi);
+ __k pop(rsi);
// Stack now at rbp.
#else
// Restore callee save register.
@@ -923,8 +948,8 @@
if (check_preempt_label_.is_linked()) {
SafeCallTarget(&check_preempt_label_);
- __ push(backtrack_stackpointer());
- __ push(rdi);
+ __k push(backtrack_stackpointer());
+ __k push(rdi);
CallCheckStackGuardState();
__ testq(rax, rax);
@@ -934,8 +959,8 @@
// Restore registers.
__ Move(code_object_pointer(), masm_.CodeObject());
- __ pop(rdi);
- __ pop(backtrack_stackpointer());
+ __k pop(rdi);
+ __k pop(backtrack_stackpointer());
// String might have moved: Reload esi from frame.
__ movq(rsi, Operand(rbp, kInputEnd));
SafeReturn();
@@ -950,8 +975,8 @@
// Save registers before calling C function
#ifndef _WIN64
// Callee-save in Microsoft 64-bit ABI, but not in AMD64 ABI.
- __ push(rsi);
- __ push(rdi);
+ __k push(rsi);
+ __k push(rdi);
#endif
// Call GrowStack(backtrack_stackpointer())
@@ -980,8 +1005,8 @@
// Restore saved registers and continue.
__ Move(code_object_pointer(), masm_.CodeObject());
#ifndef _WIN64
- __ pop(rdi);
- __ pop(rsi);
+ __k pop(rdi);
+ __k pop(rsi);
#endif
SafeReturn();
}
@@ -1085,13 +1110,22 @@
void RegExpMacroAssemblerX64::ReadCurrentPositionFromRegister(int reg) {
+#ifndef V8_TARGET_ARCH_X32
__ movq(rdi, register_location(reg));
+#else
+ __ movsxlq(rdi, register_location(reg));
+#endif
}
void RegExpMacroAssemblerX64::ReadStackPointerFromRegister(int reg) {
+#ifndef V8_TARGET_ARCH_X32
__ movq(backtrack_stackpointer(), register_location(reg));
__ addq(backtrack_stackpointer(), Operand(rbp, kStackHighEnd));
+#else
+ __ movsxlq(backtrack_stackpointer(), register_location(reg));
+ __ addl(backtrack_stackpointer(), Operand(rbp, kStackHighEnd));
+#endif
}
@@ -1099,7 +1133,7 @@
Label after_position;
__ cmpq(rdi, Immediate(-by * char_size()));
__ j(greater_equal, &after_position, Label::kNear);
- __ movq(rdi, Immediate(-by * char_size()));
+ __k movq(rdi, Immediate(-by * char_size()));
// On RegExp code entry (where this operation is used), the character before
// the current position is expected to be already loaded.
// We have advanced the position, so it's safe to read backwards.
@@ -1169,8 +1203,12 @@
__ movq(rsi, code_object_pointer());
// First argument: Next address on the stack (will be address of
// return address).
+#ifndef V8_TARGET_ARCH_X32
__ lea(rdi, Operand(rsp, -kPointerSize));
+#else
+ __ leal(rdi, Operand(rsp, -kHWRegSize));
#endif
+#endif
ExternalReference stack_check =
ExternalReference::re_check_stack_guard_state(isolate());
__ CallCFunction(stack_check, num_arguments);
@@ -1376,7 +1414,7 @@
void RegExpMacroAssemblerX64::Pop(Register target) {
ASSERT(!target.is(backtrack_stackpointer()));
- __ movsxlq(target, Operand(backtrack_stackpointer(), 0));
+ __k movsxlq(target, Operand(backtrack_stackpointer(), 0));
// Notice: This updates flags, unlike normal Pop.
__ addq(backtrack_stackpointer(), Immediate(kIntSize));
}
@@ -1440,6 +1478,7 @@
}
}
+#undef __k
#undef __
#endif // V8_INTERPRETED_REGEXP

Powered by Google App Engine
This is Rietveld 408576698