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

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

Issue 371923006: Add mips64 port. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase Created 6 years, 5 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
« no previous file with comments | « src/mips64/regexp-macro-assembler-mips64.h ('k') | src/mips64/simulator-mips64.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/mips64/regexp-macro-assembler-mips64.cc
diff --git a/src/mips/regexp-macro-assembler-mips.cc b/src/mips64/regexp-macro-assembler-mips64.cc
similarity index 77%
copy from src/mips/regexp-macro-assembler-mips.cc
copy to src/mips64/regexp-macro-assembler-mips64.cc
index e1a27295e8f7df9e40c34dcd2c59399c17bbec20..858ce6f52384e5ef56eaf677f87529f643ae49b0 100644
--- a/src/mips/regexp-macro-assembler-mips.cc
+++ b/src/mips64/regexp-macro-assembler-mips64.cc
@@ -4,7 +4,7 @@
#include "src/v8.h"
-#if V8_TARGET_ARCH_MIPS
+#if V8_TARGET_ARCH_MIPS64
#include "src/code-stubs.h"
#include "src/log.h"
@@ -13,7 +13,7 @@
#include "src/regexp-stack.h"
#include "src/unicode.h"
-#include "src/mips/regexp-macro-assembler-mips.h"
+#include "src/mips64/regexp-macro-assembler-mips64.h"
namespace v8 {
namespace internal {
@@ -21,16 +21,16 @@ namespace internal {
#ifndef V8_INTERPRETED_REGEXP
/*
* This assembler uses the following register assignment convention
- * - t7 : Temporarily stores the index of capture start after a matching pass
+ * - t3 : Temporarily stores the index of capture start after a matching pass
* for a global regexp.
- * - t1 : Pointer to current code object (Code*) including heap object tag.
- * - t2 : Current position in input, as negative offset from end of string.
+ * - a5 : Pointer to current code object (Code*) including heap object tag.
+ * - a6 : Current position in input, as negative offset from end of string.
* Please notice that this is the byte offset, not the character offset!
- * - t3 : Currently loaded character. Must be loaded using
+ * - a7 : Currently loaded character. Must be loaded using
* LoadCurrentCharacter before using any of the dispatch methods.
- * - t4 : Points to tip of backtrack stack
- * - t5 : Unused.
- * - t6 : End of input (points to byte after last character in input).
+ * - t0 : Points to tip of backtrack stack
+ * - t1 : Unused.
+ * - t2 : End of input (points to byte after last character in input).
* - fp : Frame pointer. Used to access arguments, local variables and
* RegExp registers.
* - sp : Points to tip of C stack.
@@ -38,20 +38,24 @@ namespace internal {
* The remaining registers are free for computations.
* Each call to a public method should retain this convention.
*
- * The stack will have the following structure:
+ * TODO(plind): O32 documented here with intent of having single 32/64 codebase
+ * in the future.
*
- * - fp[64] Isolate* isolate (address of the current isolate)
- * - fp[60] direct_call (if 1, direct call from JavaScript code,
+ * The O32 stack will have the following structure:
+ *
+ * - fp[76] Isolate* isolate (address of the current isolate)
+ * - fp[72] direct_call (if 1, direct call from JavaScript code,
* if 0, call through the runtime system).
- * - fp[56] stack_area_base (High end of the memory area to use as
+ * - fp[68] stack_area_base (High end of the memory area to use as
* backtracking stack).
- * - fp[52] capture array size (may fit multiple sets of matches)
- * - fp[48] int* capture_array (int[num_saved_registers_], for output).
- * - fp[44] secondary link/return address used by native call.
+ * - fp[64] capture array size (may fit multiple sets of matches)
+ * - fp[60] int* capture_array (int[num_saved_registers_], for output).
+ * - fp[44..59] MIPS O32 four argument slots
+ * - fp[40] secondary link/return address used by native call.
* --- sp when called ---
- * - fp[40] return address (lr).
- * - fp[36] old frame pointer (r11).
- * - fp[0..32] backup of registers s0..s7.
+ * - fp[36] return address (lr).
+ * - fp[32] old frame pointer (r11).
+ * - fp[0..31] backup of registers s0..s7.
* --- frame pointer ----
* - fp[-4] end of input (address of end of string).
* - fp[-8] start of input (address of first character in string).
@@ -69,6 +73,36 @@ namespace internal {
* - register num_registers-1
* --- sp ---
*
+ *
+ * The N64 stack will have the following structure:
+ *
+ * - fp[88] Isolate* isolate (address of the current isolate) kIsolate
+ * - fp[80] secondary link/return address used by exit frame on native call. kSecondaryReturnAddress
+ kStackFrameHeader
+ * --- sp when called ---
+ * - fp[72] ra Return from RegExp code (ra). kReturnAddress
+ * - fp[64] s9, old-fp Old fp, callee saved(s9).
+ * - fp[0..63] s0..s7 Callee-saved registers s0..s7.
+ * --- frame pointer ----
+ * - fp[-8] direct_call (1 = direct call from JS, 0 = from runtime) kDirectCall
+ * - fp[-16] stack_base (Top of backtracking stack). kStackHighEnd
+ * - fp[-24] capture array size (may fit multiple sets of matches) kNumOutputRegisters
+ * - fp[-32] int* capture_array (int[num_saved_registers_], for output). kRegisterOutput
+ * - fp[-40] end of input (address of end of string). kInputEnd
+ * - fp[-48] start of input (address of first character in string). kInputStart
+ * - fp[-56] start index (character index of start). kStartIndex
+ * - fp[-64] void* input_string (location of a handle containing the string). kInputString
+ * - fp[-72] success counter (only for global regexps to count matches). kSuccessfulCaptures
+ * - fp[-80] Offset of location before start of input (effectively character kInputStartMinusOne
+ * position -1). Used to initialize capture registers to a
+ * non-position.
+ * --------- The following output registers are 32-bit values. ---------
+ * - fp[-88] register 0 (Only positions must be stored in the first kRegisterZero
+ * - register 1 num_saved_registers_ registers)
+ * - ...
+ * - register num_registers-1
+ * --- sp ---
+ *
* The first num_saved_registers_ registers are initialized to point to
* "character -1" in the string (i.e., char_size() bytes before the first
* character of the string). The remaining registers start out as garbage.
@@ -83,7 +117,9 @@ namespace internal {
* Address secondary_return_address, // Only used by native call.
* int* capture_output_array,
* byte* stack_area_base,
- * bool direct_call = false)
+ * bool direct_call = false,
+ * void* return_address,
+ * Isolate* isolate);
* The call is performed by NativeRegExpMacroAssembler::Execute()
* (in regexp-macro-assembler.cc) via the CALL_GENERATED_REGEXP_CODE macro
* in mips/simulator-mips.h.
@@ -142,7 +178,7 @@ int RegExpMacroAssemblerMIPS::stack_limit_slack() {
void RegExpMacroAssemblerMIPS::AdvanceCurrentPosition(int by) {
if (by != 0) {
- __ Addu(current_input_offset(),
+ __ Daddu(current_input_offset(),
current_input_offset(), Operand(by * char_size()));
}
}
@@ -152,9 +188,9 @@ void RegExpMacroAssemblerMIPS::AdvanceRegister(int reg, int by) {
ASSERT(reg >= 0);
ASSERT(reg < num_registers_);
if (by != 0) {
- __ lw(a0, register_location(reg));
- __ Addu(a0, a0, Operand(by));
- __ sw(a0, register_location(reg));
+ __ ld(a0, register_location(reg));
+ __ Daddu(a0, a0, Operand(by));
+ __ sd(a0, register_location(reg));
}
}
@@ -163,7 +199,7 @@ void RegExpMacroAssemblerMIPS::Backtrack() {
CheckPreemption();
// Pop Code* offset from backtrack stack, add Code* and jump to location.
Pop(a0);
- __ Addu(a0, a0, code_pointer());
+ __ Daddu(a0, a0, code_pointer());
__ Jump(a0);
}
@@ -190,8 +226,8 @@ void RegExpMacroAssemblerMIPS::CheckAtStart(Label* on_at_start) {
BranchOrBacktrack(&not_at_start, ne, a0, Operand(zero_reg));
// If we did, are we still at the start of the input?
- __ lw(a1, MemOperand(frame_pointer(), kInputStart));
- __ Addu(a0, end_of_input_address(), Operand(current_input_offset()));
+ __ ld(a1, MemOperand(frame_pointer(), kInputStart));
+ __ Daddu(a0, end_of_input_address(), Operand(current_input_offset()));
BranchOrBacktrack(on_at_start, eq, a0, Operand(a1));
__ bind(&not_at_start);
}
@@ -202,8 +238,8 @@ void RegExpMacroAssemblerMIPS::CheckNotAtStart(Label* on_not_at_start) {
__ lw(a0, MemOperand(frame_pointer(), kStartIndex));
BranchOrBacktrack(on_not_at_start, ne, a0, Operand(zero_reg));
// If we did, are we still at the start of the input?
- __ lw(a1, MemOperand(frame_pointer(), kInputStart));
- __ Addu(a0, end_of_input_address(), Operand(current_input_offset()));
+ __ ld(a1, MemOperand(frame_pointer(), kInputStart));
+ __ Daddu(a0, end_of_input_address(), Operand(current_input_offset()));
BranchOrBacktrack(on_not_at_start, ne, a0, Operand(a1));
}
@@ -217,9 +253,9 @@ void RegExpMacroAssemblerMIPS::CheckGreedyLoop(Label* on_equal) {
Label backtrack_non_equal;
__ lw(a0, MemOperand(backtrack_stackpointer(), 0));
__ Branch(&backtrack_non_equal, ne, current_input_offset(), Operand(a0));
- __ Addu(backtrack_stackpointer(),
+ __ Daddu(backtrack_stackpointer(),
backtrack_stackpointer(),
- Operand(kPointerSize));
+ Operand(kIntSize));
__ bind(&backtrack_non_equal);
BranchOrBacktrack(on_equal, eq, current_input_offset(), Operand(a0));
}
@@ -229,17 +265,17 @@ void RegExpMacroAssemblerMIPS::CheckNotBackReferenceIgnoreCase(
int start_reg,
Label* on_no_match) {
Label fallthrough;
- __ lw(a0, register_location(start_reg)); // Index of start of capture.
- __ lw(a1, register_location(start_reg + 1)); // Index of end of capture.
- __ Subu(a1, a1, a0); // Length of capture.
+ __ ld(a0, register_location(start_reg)); // Index of start of capture.
+ __ ld(a1, register_location(start_reg + 1)); // Index of end of capture.
+ __ Dsubu(a1, a1, a0); // Length of capture.
// If length is zero, either the capture is empty or it is not participating.
// In either case succeed immediately.
__ Branch(&fallthrough, eq, a1, Operand(zero_reg));
- __ Addu(t5, a1, current_input_offset());
+ __ Daddu(t1, a1, current_input_offset());
// Check that there are enough characters left in the input.
- BranchOrBacktrack(on_no_match, gt, t5, Operand(zero_reg));
+ BranchOrBacktrack(on_no_match, gt, t1, Operand(zero_reg));
if (mode_ == ASCII) {
Label success;
@@ -248,9 +284,9 @@ void RegExpMacroAssemblerMIPS::CheckNotBackReferenceIgnoreCase(
// a0 - offset of start of capture.
// a1 - length of capture.
- __ Addu(a0, a0, Operand(end_of_input_address()));
- __ Addu(a2, end_of_input_address(), Operand(current_input_offset()));
- __ Addu(a1, a0, Operand(a1));
+ __ Daddu(a0, a0, Operand(end_of_input_address()));
+ __ Daddu(a2, end_of_input_address(), Operand(current_input_offset()));
+ __ Daddu(a1, a0, Operand(a1));
// a0 - Address of start of capture.
// a1 - Address of end of capture.
@@ -259,20 +295,20 @@ void RegExpMacroAssemblerMIPS::CheckNotBackReferenceIgnoreCase(
Label loop;
__ bind(&loop);
__ lbu(a3, MemOperand(a0, 0));
- __ addiu(a0, a0, char_size());
- __ lbu(t0, MemOperand(a2, 0));
- __ addiu(a2, a2, char_size());
+ __ daddiu(a0, a0, char_size());
+ __ lbu(a4, MemOperand(a2, 0));
+ __ daddiu(a2, a2, char_size());
- __ Branch(&loop_check, eq, t0, Operand(a3));
+ __ Branch(&loop_check, eq, a4, Operand(a3));
// Mismatch, try case-insensitive match (converting letters to lower-case).
__ Or(a3, a3, Operand(0x20)); // Convert capture character to lower-case.
- __ Or(t0, t0, Operand(0x20)); // Also convert input character.
- __ Branch(&fail, ne, t0, Operand(a3));
- __ Subu(a3, a3, Operand('a'));
+ __ Or(a4, a4, Operand(0x20)); // Also convert input character.
+ __ Branch(&fail, ne, a4, Operand(a3));
+ __ Dsubu(a3, a3, Operand('a'));
__ Branch(&loop_check, ls, a3, Operand('z' - 'a'));
// Latin-1: Check for values in range [224,254] but not 247.
- __ Subu(a3, a3, Operand(224 - 'a'));
+ __ Dsubu(a3, a3, Operand(224 - 'a'));
// Weren't Latin-1 letters.
__ Branch(&fail, hi, a3, Operand(254 - 224));
// Check for 247.
@@ -287,7 +323,7 @@ void RegExpMacroAssemblerMIPS::CheckNotBackReferenceIgnoreCase(
__ bind(&success);
// Compute new value of character position after the matched part.
- __ Subu(current_input_offset(), a2, end_of_input_address());
+ __ Dsubu(current_input_offset(), a2, end_of_input_address());
} else {
ASSERT(mode_ == UC16);
// Put regexp engine registers on stack.
@@ -309,13 +345,13 @@ void RegExpMacroAssemblerMIPS::CheckNotBackReferenceIgnoreCase(
// a3: Isolate* isolate.
// Address of start of capture.
- __ Addu(a0, a0, Operand(end_of_input_address()));
+ __ Daddu(a0, a0, Operand(end_of_input_address()));
// Length of capture.
__ mov(a2, a1);
// Save length in callee-save register for use on return.
__ mov(s3, a1);
// Address of current input position.
- __ Addu(a1, current_input_offset(), Operand(end_of_input_address()));
+ __ Daddu(a1, current_input_offset(), Operand(end_of_input_address()));
// Isolate.
__ li(a3, Operand(ExternalReference::isolate_address(masm_->isolate())));
@@ -329,12 +365,12 @@ void RegExpMacroAssemblerMIPS::CheckNotBackReferenceIgnoreCase(
// Restore regexp engine registers.
__ MultiPop(regexp_registers_to_retain);
__ li(code_pointer(), Operand(masm_->CodeObject()), CONSTANT_SIZE);
- __ lw(end_of_input_address(), MemOperand(frame_pointer(), kInputEnd));
+ __ ld(end_of_input_address(), MemOperand(frame_pointer(), kInputEnd));
// Check if function returned non-zero for success or zero for failure.
BranchOrBacktrack(on_no_match, eq, v0, Operand(zero_reg));
// On success, increment position by length of capture.
- __ Addu(current_input_offset(), current_input_offset(), Operand(s3));
+ __ Daddu(current_input_offset(), current_input_offset(), Operand(s3));
}
__ bind(&fallthrough);
@@ -348,40 +384,40 @@ void RegExpMacroAssemblerMIPS::CheckNotBackReference(
Label success;
// Find length of back-referenced capture.
- __ lw(a0, register_location(start_reg));
- __ lw(a1, register_location(start_reg + 1));
- __ Subu(a1, a1, a0); // Length to check.
+ __ ld(a0, register_location(start_reg));
+ __ ld(a1, register_location(start_reg + 1));
+ __ Dsubu(a1, a1, a0); // Length to check.
// Succeed on empty capture (including no capture).
__ Branch(&fallthrough, eq, a1, Operand(zero_reg));
- __ Addu(t5, a1, current_input_offset());
+ __ Daddu(t1, a1, current_input_offset());
// Check that there are enough characters left in the input.
- BranchOrBacktrack(on_no_match, gt, t5, Operand(zero_reg));
+ BranchOrBacktrack(on_no_match, gt, t1, Operand(zero_reg));
// Compute pointers to match string and capture string.
- __ Addu(a0, a0, Operand(end_of_input_address()));
- __ Addu(a2, end_of_input_address(), Operand(current_input_offset()));
- __ Addu(a1, a1, Operand(a0));
+ __ Daddu(a0, a0, Operand(end_of_input_address()));
+ __ Daddu(a2, end_of_input_address(), Operand(current_input_offset()));
+ __ Daddu(a1, a1, Operand(a0));
Label loop;
__ bind(&loop);
if (mode_ == ASCII) {
__ lbu(a3, MemOperand(a0, 0));
- __ addiu(a0, a0, char_size());
- __ lbu(t0, MemOperand(a2, 0));
- __ addiu(a2, a2, char_size());
+ __ daddiu(a0, a0, char_size());
+ __ lbu(a4, MemOperand(a2, 0));
+ __ daddiu(a2, a2, char_size());
} else {
ASSERT(mode_ == UC16);
__ lhu(a3, MemOperand(a0, 0));
- __ addiu(a0, a0, char_size());
- __ lhu(t0, MemOperand(a2, 0));
- __ addiu(a2, a2, char_size());
+ __ daddiu(a0, a0, char_size());
+ __ lhu(a4, MemOperand(a2, 0));
+ __ daddiu(a2, a2, char_size());
}
- BranchOrBacktrack(on_no_match, ne, a3, Operand(t0));
+ BranchOrBacktrack(on_no_match, ne, a3, Operand(a4));
__ Branch(&loop, lt, a0, Operand(a1));
// Move current character position to position after match.
- __ Subu(current_input_offset(), a2, end_of_input_address());
+ __ Dsubu(current_input_offset(), a2, end_of_input_address());
__ bind(&fallthrough);
}
@@ -416,7 +452,7 @@ void RegExpMacroAssemblerMIPS::CheckNotCharacterAfterMinusAnd(
uc16 mask,
Label* on_not_equal) {
ASSERT(minus < String::kMaxUtf16CodeUnit);
- __ Subu(a0, current_character(), Operand(minus));
+ __ Dsubu(a0, current_character(), Operand(minus));
__ And(a0, a0, Operand(mask));
BranchOrBacktrack(on_not_equal, ne, a0, Operand(c));
}
@@ -426,7 +462,7 @@ void RegExpMacroAssemblerMIPS::CheckCharacterInRange(
uc16 from,
uc16 to,
Label* on_in_range) {
- __ Subu(a0, current_character(), Operand(from));
+ __ Dsubu(a0, current_character(), Operand(from));
// Unsigned lower-or-same condition.
BranchOrBacktrack(on_in_range, ls, a0, Operand(to - from));
}
@@ -436,7 +472,7 @@ void RegExpMacroAssemblerMIPS::CheckCharacterNotInRange(
uc16 from,
uc16 to,
Label* on_not_in_range) {
- __ Subu(a0, current_character(), Operand(from));
+ __ Dsubu(a0, current_character(), Operand(from));
// Unsigned higher condition.
BranchOrBacktrack(on_not_in_range, hi, a0, Operand(to - from));
}
@@ -448,9 +484,9 @@ void RegExpMacroAssemblerMIPS::CheckBitInTable(
__ li(a0, Operand(table));
if (mode_ != ASCII || kTableMask != String::kMaxOneByteCharCode) {
__ And(a1, current_character(), Operand(kTableSize - 1));
- __ Addu(a0, a0, a1);
+ __ Daddu(a0, a0, a1);
} else {
- __ Addu(a0, a0, current_character());
+ __ Daddu(a0, a0, current_character());
}
__ lbu(a0, FieldMemOperand(a0, ByteArray::kHeaderSize));
@@ -470,7 +506,7 @@ bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(uc16 type,
Label success;
__ Branch(&success, eq, current_character(), Operand(' '));
// Check range 0x09..0x0d.
- __ Subu(a0, current_character(), Operand('\t'));
+ __ Dsubu(a0, current_character(), Operand('\t'));
__ Branch(&success, ls, a0, Operand('\r' - '\t'));
// \u00a0 (NBSP).
BranchOrBacktrack(on_no_match, ne, a0, Operand(0x00a0 - '\t'));
@@ -483,25 +519,25 @@ bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(uc16 type,
return false;
case 'd':
// Match ASCII digits ('0'..'9').
- __ Subu(a0, current_character(), Operand('0'));
+ __ Dsubu(a0, current_character(), Operand('0'));
BranchOrBacktrack(on_no_match, hi, a0, Operand('9' - '0'));
return true;
case 'D':
// Match non ASCII-digits.
- __ Subu(a0, current_character(), Operand('0'));
+ __ Dsubu(a0, current_character(), Operand('0'));
BranchOrBacktrack(on_no_match, ls, a0, Operand('9' - '0'));
return true;
case '.': {
// Match non-newlines (not 0x0a('\n'), 0x0d('\r'), 0x2028 and 0x2029).
__ Xor(a0, current_character(), Operand(0x01));
// See if current character is '\n'^1 or '\r'^1, i.e., 0x0b or 0x0c.
- __ Subu(a0, a0, Operand(0x0b));
+ __ Dsubu(a0, a0, Operand(0x0b));
BranchOrBacktrack(on_no_match, ls, a0, Operand(0x0c - 0x0b));
if (mode_ == UC16) {
// Compare original value to 0x2028 and 0x2029, using the already
// computed (current_char ^ 0x01 - 0x0b). I.e., check for
// 0x201d (0x2028 - 0x0b) or 0x201e.
- __ Subu(a0, a0, Operand(0x2028 - 0x0b));
+ __ Dsubu(a0, a0, Operand(0x2028 - 0x0b));
BranchOrBacktrack(on_no_match, ls, a0, Operand(1));
}
return true;
@@ -510,7 +546,7 @@ bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(uc16 type,
// Match newlines (0x0a('\n'), 0x0d('\r'), 0x2028 and 0x2029).
__ Xor(a0, current_character(), Operand(0x01));
// See if current character is '\n'^1 or '\r'^1, i.e., 0x0b or 0x0c.
- __ Subu(a0, a0, Operand(0x0b));
+ __ Dsubu(a0, a0, Operand(0x0b));
if (mode_ == ASCII) {
BranchOrBacktrack(on_no_match, hi, a0, Operand(0x0c - 0x0b));
} else {
@@ -519,7 +555,7 @@ bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(uc16 type,
// Compare original value to 0x2028 and 0x2029, using the already
// computed (current_char ^ 0x01 - 0x0b). I.e., check for
// 0x201d (0x2028 - 0x0b) or 0x201e.
- __ Subu(a0, a0, Operand(0x2028 - 0x0b));
+ __ Dsubu(a0, a0, Operand(0x2028 - 0x0b));
BranchOrBacktrack(on_no_match, hi, a0, Operand(1));
__ bind(&done);
}
@@ -532,7 +568,7 @@ bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(uc16 type,
}
ExternalReference map = ExternalReference::re_word_character_map();
__ li(a0, Operand(map));
- __ Addu(a0, a0, current_character());
+ __ Daddu(a0, a0, current_character());
__ lbu(a0, MemOperand(a0, 0));
BranchOrBacktrack(on_no_match, eq, a0, Operand(zero_reg));
return true;
@@ -545,7 +581,7 @@ bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(uc16 type,
}
ExternalReference map = ExternalReference::re_word_character_map();
__ li(a0, Operand(map));
- __ Addu(a0, a0, current_character());
+ __ Daddu(a0, a0, current_character());
__ lbu(a0, MemOperand(a0, 0));
BranchOrBacktrack(on_no_match, ne, a0, Operand(zero_reg));
if (mode_ != ASCII) {
@@ -593,13 +629,22 @@ Handle<HeapObject> RegExpMacroAssemblerMIPS::GetCode(Handle<String> source) {
// Start new stack frame.
// Store link register in existing stack-cell.
// Order here should correspond to order of offset constants in header file.
+ // TODO(plind): we save s0..s7, but ONLY use s3 here - use the regs
+ // or dont save.
RegList registers_to_retain = s0.bit() | s1.bit() | s2.bit() |
s3.bit() | s4.bit() | s5.bit() | s6.bit() | s7.bit() | fp.bit();
RegList argument_registers = a0.bit() | a1.bit() | a2.bit() | a3.bit();
+
+ if (kMipsAbi == kN64) {
+ // TODO(plind): Should probably alias a4-a7, for clarity.
+ argument_registers |= a4.bit() | a5.bit() | a6.bit() | a7.bit();
+ }
+
__ MultiPush(argument_registers | registers_to_retain | ra.bit());
// Set frame pointer in space for it if this is not a direct call
// from generated code.
- __ Addu(frame_pointer(), sp, Operand(4 * kPointerSize));
+ // TODO(plind): this 8 is the # of argument regs, should have definition.
+ __ Daddu(frame_pointer(), sp, Operand(8 * kPointerSize));
__ mov(a0, zero_reg);
__ push(a0); // Make room for success counter and initialize it to 0.
__ push(a0); // Make room for "position - 1" constant (value irrelevant).
@@ -611,8 +656,8 @@ Handle<HeapObject> RegExpMacroAssemblerMIPS::GetCode(Handle<String> source) {
ExternalReference stack_limit =
ExternalReference::address_of_stack_limit(masm_->isolate());
__ li(a0, Operand(stack_limit));
- __ lw(a0, MemOperand(a0));
- __ Subu(a0, sp, a0);
+ __ ld(a0, MemOperand(a0));
+ __ Dsubu(a0, sp, a0);
// Handle it if the stack pointer is already below the stack limit.
__ Branch(&stack_limit_hit, le, a0, Operand(zero_reg));
// Check if there is room for the variable number of registers above
@@ -630,22 +675,22 @@ Handle<HeapObject> RegExpMacroAssemblerMIPS::GetCode(Handle<String> source) {
__ bind(&stack_ok);
// Allocate space on stack for registers.
- __ Subu(sp, sp, Operand(num_registers_ * kPointerSize));
+ __ Dsubu(sp, sp, Operand(num_registers_ * kPointerSize));
// Load string end.
- __ lw(end_of_input_address(), MemOperand(frame_pointer(), kInputEnd));
+ __ ld(end_of_input_address(), MemOperand(frame_pointer(), kInputEnd));
// Load input start.
- __ lw(a0, MemOperand(frame_pointer(), kInputStart));
+ __ ld(a0, MemOperand(frame_pointer(), kInputStart));
// Find negative length (offset of start relative to end).
- __ Subu(current_input_offset(), a0, end_of_input_address());
+ __ Dsubu(current_input_offset(), a0, end_of_input_address());
// Set a0 to address of char before start of the input string
// (effectively string position -1).
- __ lw(a1, MemOperand(frame_pointer(), kStartIndex));
- __ Subu(a0, current_input_offset(), Operand(char_size()));
- __ sll(t5, a1, (mode_ == UC16) ? 1 : 0);
- __ Subu(a0, a0, t5);
+ __ ld(a1, MemOperand(frame_pointer(), kStartIndex));
+ __ Dsubu(a0, current_input_offset(), Operand(char_size()));
+ __ dsll(t1, a1, (mode_ == UC16) ? 1 : 0);
+ __ Dsubu(a0, a0, t1);
// Store this value in a local variable, for use when clearing
// position registers.
- __ sw(a0, MemOperand(frame_pointer(), kInputStartMinusOne));
+ __ sd(a0, MemOperand(frame_pointer(), kInputStartMinusOne));
// Initialize code pointer register
__ li(code_pointer(), Operand(masm_->CodeObject()), CONSTANT_SIZE);
@@ -667,23 +712,23 @@ Handle<HeapObject> RegExpMacroAssemblerMIPS::GetCode(Handle<String> source) {
// Fill saved registers with initial value = start offset - 1.
if (num_saved_registers_ > 8) {
// Address of register 0.
- __ Addu(a1, frame_pointer(), Operand(kRegisterZero));
+ __ Daddu(a1, frame_pointer(), Operand(kRegisterZero));
__ li(a2, Operand(num_saved_registers_));
Label init_loop;
__ bind(&init_loop);
- __ sw(a0, MemOperand(a1));
- __ Addu(a1, a1, Operand(-kPointerSize));
- __ Subu(a2, a2, Operand(1));
+ __ sd(a0, MemOperand(a1));
+ __ Daddu(a1, a1, Operand(-kPointerSize));
+ __ Dsubu(a2, a2, Operand(1));
__ Branch(&init_loop, ne, a2, Operand(zero_reg));
} else {
for (int i = 0; i < num_saved_registers_; i++) {
- __ sw(a0, register_location(i));
+ __ sd(a0, register_location(i));
}
}
}
// Initialize backtrack stack pointer.
- __ lw(backtrack_stackpointer(), MemOperand(frame_pointer(), kStackHighEnd));
+ __ ld(backtrack_stackpointer(), MemOperand(frame_pointer(), kStackHighEnd));
__ jmp(&start_label_);
@@ -694,16 +739,16 @@ Handle<HeapObject> RegExpMacroAssemblerMIPS::GetCode(Handle<String> source) {
__ bind(&success_label_);
if (num_saved_registers_ > 0) {
// Copy captures to output.
- __ lw(a1, MemOperand(frame_pointer(), kInputStart));
- __ lw(a0, MemOperand(frame_pointer(), kRegisterOutput));
- __ lw(a2, MemOperand(frame_pointer(), kStartIndex));
- __ Subu(a1, end_of_input_address(), a1);
+ __ ld(a1, MemOperand(frame_pointer(), kInputStart));
+ __ ld(a0, MemOperand(frame_pointer(), kRegisterOutput));
+ __ ld(a2, MemOperand(frame_pointer(), kStartIndex));
+ __ Dsubu(a1, end_of_input_address(), a1);
// a1 is length of input in bytes.
if (mode_ == UC16) {
- __ srl(a1, a1, 1);
+ __ dsrl(a1, a1, 1);
}
// a1 is length of input in characters.
- __ Addu(a1, a1, Operand(a2));
+ __ Daddu(a1, a1, Operand(a2));
// a1 is length of string in characters.
ASSERT_EQ(0, num_saved_registers_ % 2);
@@ -711,62 +756,63 @@ Handle<HeapObject> RegExpMacroAssemblerMIPS::GetCode(Handle<String> source) {
// unroll the loop once to add an operation between a load of a register
// and the following use of that register.
for (int i = 0; i < num_saved_registers_; i += 2) {
- __ lw(a2, register_location(i));
- __ lw(a3, register_location(i + 1));
+ __ ld(a2, register_location(i));
+ __ ld(a3, register_location(i + 1));
if (i == 0 && global_with_zero_length_check()) {
// Keep capture start in a4 for the zero-length check later.
- __ mov(t7, a2);
+ __ mov(t3, a2);
}
if (mode_ == UC16) {
- __ sra(a2, a2, 1);
- __ Addu(a2, a2, a1);
- __ sra(a3, a3, 1);
- __ Addu(a3, a3, a1);
+ __ dsra(a2, a2, 1);
+ __ Daddu(a2, a2, a1);
+ __ dsra(a3, a3, 1);
+ __ Daddu(a3, a3, a1);
} else {
- __ Addu(a2, a1, Operand(a2));
- __ Addu(a3, a1, Operand(a3));
+ __ Daddu(a2, a1, Operand(a2));
+ __ Daddu(a3, a1, Operand(a3));
}
+ // V8 expects the output to be an int32_t array.
__ sw(a2, MemOperand(a0));
- __ Addu(a0, a0, kPointerSize);
+ __ Daddu(a0, a0, kIntSize);
__ sw(a3, MemOperand(a0));
- __ Addu(a0, a0, kPointerSize);
+ __ Daddu(a0, a0, kIntSize);
}
}
if (global()) {
// Restart matching if the regular expression is flagged as global.
- __ lw(a0, MemOperand(frame_pointer(), kSuccessfulCaptures));
+ __ ld(a0, MemOperand(frame_pointer(), kSuccessfulCaptures));
__ lw(a1, MemOperand(frame_pointer(), kNumOutputRegisters));
- __ lw(a2, MemOperand(frame_pointer(), kRegisterOutput));
+ __ ld(a2, MemOperand(frame_pointer(), kRegisterOutput));
// Increment success counter.
- __ Addu(a0, a0, 1);
- __ sw(a0, MemOperand(frame_pointer(), kSuccessfulCaptures));
+ __ Daddu(a0, a0, 1);
+ __ sd(a0, MemOperand(frame_pointer(), kSuccessfulCaptures));
// Capture results have been stored, so the number of remaining global
// output registers is reduced by the number of stored captures.
- __ Subu(a1, a1, num_saved_registers_);
+ __ Dsubu(a1, a1, num_saved_registers_);
// Check whether we have enough room for another set of capture results.
__ mov(v0, a0);
__ Branch(&return_v0, lt, a1, Operand(num_saved_registers_));
- __ sw(a1, MemOperand(frame_pointer(), kNumOutputRegisters));
+ __ sd(a1, MemOperand(frame_pointer(), kNumOutputRegisters));
// Advance the location for output.
- __ Addu(a2, a2, num_saved_registers_ * kPointerSize);
- __ sw(a2, MemOperand(frame_pointer(), kRegisterOutput));
+ __ Daddu(a2, a2, num_saved_registers_ * kIntSize);
+ __ sd(a2, MemOperand(frame_pointer(), kRegisterOutput));
// Prepare a0 to initialize registers with its value in the next run.
- __ lw(a0, MemOperand(frame_pointer(), kInputStartMinusOne));
+ __ ld(a0, MemOperand(frame_pointer(), kInputStartMinusOne));
if (global_with_zero_length_check()) {
// Special case for zero-length matches.
- // t7: capture start index
+ // t3: capture start index
// Not a zero-length match, restart.
__ Branch(
- &load_char_start_regexp, ne, current_input_offset(), Operand(t7));
+ &load_char_start_regexp, ne, current_input_offset(), Operand(t3));
// Offset from the end is zero if we already reached the end.
__ Branch(&exit_label_, eq, current_input_offset(),
Operand(zero_reg));
// Advance current position after a zero-length match.
- __ Addu(current_input_offset(),
+ __ Daddu(current_input_offset(),
current_input_offset(),
Operand((mode_ == UC16) ? 2 : 1));
}
@@ -779,7 +825,7 @@ Handle<HeapObject> RegExpMacroAssemblerMIPS::GetCode(Handle<String> source) {
// Exit and return v0.
__ bind(&exit_label_);
if (global()) {
- __ lw(v0, MemOperand(frame_pointer(), kSuccessfulCaptures));
+ __ ld(v0, MemOperand(frame_pointer(), kSuccessfulCaptures));
}
__ bind(&return_v0);
@@ -811,7 +857,7 @@ Handle<HeapObject> RegExpMacroAssemblerMIPS::GetCode(Handle<String> source) {
__ Branch(&return_v0, ne, v0, Operand(zero_reg));
// String might have moved: Reload end of string from frame.
- __ lw(end_of_input_address(), MemOperand(frame_pointer(), kInputEnd));
+ __ ld(end_of_input_address(), MemOperand(frame_pointer(), kInputEnd));
__ li(code_pointer(), Operand(masm_->CodeObject()), CONSTANT_SIZE);
SafeReturn();
}
@@ -829,7 +875,7 @@ Handle<HeapObject> RegExpMacroAssemblerMIPS::GetCode(Handle<String> source) {
static const int num_arguments = 3;
__ PrepareCallCFunction(num_arguments, a0);
__ mov(a0, backtrack_stackpointer());
- __ Addu(a1, frame_pointer(), Operand(kStackHighEnd));
+ __ Daddu(a1, frame_pointer(), Operand(kStackHighEnd));
__ li(a2, Operand(ExternalReference::isolate_address(masm_->isolate())));
ExternalReference grow_stack =
ExternalReference::re_grow_stack(masm_->isolate());
@@ -843,7 +889,7 @@ Handle<HeapObject> RegExpMacroAssemblerMIPS::GetCode(Handle<String> source) {
__ mov(backtrack_stackpointer(), v0);
// Restore saved registers and continue.
__ li(code_pointer(), Operand(masm_->CodeObject()), CONSTANT_SIZE);
- __ lw(end_of_input_address(), MemOperand(frame_pointer(), kInputEnd));
+ __ ld(end_of_input_address(), MemOperand(frame_pointer(), kInputEnd));
SafeReturn();
}
@@ -878,7 +924,7 @@ void RegExpMacroAssemblerMIPS::GoTo(Label* to) {
void RegExpMacroAssemblerMIPS::IfRegisterGE(int reg,
int comparand,
Label* if_ge) {
- __ lw(a0, register_location(reg));
+ __ ld(a0, register_location(reg));
BranchOrBacktrack(if_ge, ge, a0, Operand(comparand));
}
@@ -886,14 +932,14 @@ void RegExpMacroAssemblerMIPS::IfRegisterGE(int reg,
void RegExpMacroAssemblerMIPS::IfRegisterLT(int reg,
int comparand,
Label* if_lt) {
- __ lw(a0, register_location(reg));
+ __ ld(a0, register_location(reg));
BranchOrBacktrack(if_lt, lt, a0, Operand(comparand));
}
void RegExpMacroAssemblerMIPS::IfRegisterEqPos(int reg,
Label* if_eq) {
- __ lw(a0, register_location(reg));
+ __ ld(a0, register_location(reg));
BranchOrBacktrack(if_eq, eq, a0, Operand(current_input_offset()));
}
@@ -924,7 +970,7 @@ void RegExpMacroAssemblerMIPS::PopCurrentPosition() {
void RegExpMacroAssemblerMIPS::PopRegister(int register_index) {
Pop(a0);
- __ sw(a0, register_location(register_index));
+ __ sd(a0, register_location(register_index));
}
@@ -942,10 +988,10 @@ void RegExpMacroAssemblerMIPS::PushBacktrack(Label* label) {
masm_->label_at_put(label, offset);
__ bind(&after_constant);
if (is_int16(cp_offset)) {
- __ lw(a0, MemOperand(code_pointer(), cp_offset));
+ __ lwu(a0, MemOperand(code_pointer(), cp_offset));
} else {
- __ Addu(a0, code_pointer(), cp_offset);
- __ lw(a0, MemOperand(a0, 0));
+ __ Daddu(a0, code_pointer(), cp_offset);
+ __ lwu(a0, MemOperand(a0, 0));
}
}
Push(a0);
@@ -960,21 +1006,21 @@ void RegExpMacroAssemblerMIPS::PushCurrentPosition() {
void RegExpMacroAssemblerMIPS::PushRegister(int register_index,
StackCheckFlag check_stack_limit) {
- __ lw(a0, register_location(register_index));
+ __ ld(a0, register_location(register_index));
Push(a0);
if (check_stack_limit) CheckStackLimit();
}
void RegExpMacroAssemblerMIPS::ReadCurrentPositionFromRegister(int reg) {
- __ lw(current_input_offset(), register_location(reg));
+ __ ld(current_input_offset(), register_location(reg));
}
void RegExpMacroAssemblerMIPS::ReadStackPointerFromRegister(int reg) {
- __ lw(backtrack_stackpointer(), register_location(reg));
- __ lw(a0, MemOperand(frame_pointer(), kStackHighEnd));
- __ Addu(backtrack_stackpointer(), backtrack_stackpointer(), Operand(a0));
+ __ ld(backtrack_stackpointer(), register_location(reg));
+ __ ld(a0, MemOperand(frame_pointer(), kStackHighEnd));
+ __ Daddu(backtrack_stackpointer(), backtrack_stackpointer(), Operand(a0));
}
@@ -996,7 +1042,7 @@ void RegExpMacroAssemblerMIPS::SetCurrentPositionFromEnd(int by) {
void RegExpMacroAssemblerMIPS::SetRegister(int register_index, int to) {
ASSERT(register_index >= num_saved_registers_); // Reserved for positions!
__ li(a0, Operand(to));
- __ sw(a0, register_location(register_index));
+ __ sd(a0, register_location(register_index));
}
@@ -1009,27 +1055,27 @@ bool RegExpMacroAssemblerMIPS::Succeed() {
void RegExpMacroAssemblerMIPS::WriteCurrentPositionToRegister(int reg,
int cp_offset) {
if (cp_offset == 0) {
- __ sw(current_input_offset(), register_location(reg));
+ __ sd(current_input_offset(), register_location(reg));
} else {
- __ Addu(a0, current_input_offset(), Operand(cp_offset * char_size()));
- __ sw(a0, register_location(reg));
+ __ Daddu(a0, current_input_offset(), Operand(cp_offset * char_size()));
+ __ sd(a0, register_location(reg));
}
}
void RegExpMacroAssemblerMIPS::ClearRegisters(int reg_from, int reg_to) {
ASSERT(reg_from <= reg_to);
- __ lw(a0, MemOperand(frame_pointer(), kInputStartMinusOne));
+ __ ld(a0, MemOperand(frame_pointer(), kInputStartMinusOne));
for (int reg = reg_from; reg <= reg_to; reg++) {
- __ sw(a0, register_location(reg));
+ __ sd(a0, register_location(reg));
}
}
void RegExpMacroAssemblerMIPS::WriteStackPointerToRegister(int reg) {
- __ lw(a1, MemOperand(frame_pointer(), kStackHighEnd));
- __ Subu(a0, backtrack_stackpointer(), a1);
- __ sw(a0, register_location(reg));
+ __ ld(a1, MemOperand(frame_pointer(), kStackHighEnd));
+ __ Dsubu(a0, backtrack_stackpointer(), a1);
+ __ sd(a0, register_location(reg));
}
@@ -1045,10 +1091,10 @@ void RegExpMacroAssemblerMIPS::CallCheckStackGuardState(Register scratch) {
// Align the stack pointer and save the original sp value on the stack.
__ mov(scratch, sp);
- __ Subu(sp, sp, Operand(kPointerSize));
+ __ Dsubu(sp, sp, Operand(kPointerSize));
ASSERT(IsPowerOf2(stack_alignment));
__ And(sp, sp, Operand(-stack_alignment));
- __ sw(scratch, MemOperand(sp));
+ __ sd(scratch, MemOperand(sp));
__ mov(a2, frame_pointer());
// Code* of self.
@@ -1056,7 +1102,7 @@ void RegExpMacroAssemblerMIPS::CallCheckStackGuardState(Register scratch) {
// We need to make room for the return address on the stack.
ASSERT(IsAligned(stack_alignment, kPointerSize));
- __ Subu(sp, sp, Operand(stack_alignment));
+ __ Dsubu(sp, sp, Operand(stack_alignment));
// Stack pointer now points to cell where return address is to be written.
// Arguments are in registers, meaning we teat the return address as
@@ -1088,7 +1134,7 @@ void RegExpMacroAssemblerMIPS::CallCheckStackGuardState(Register scratch) {
// [sp + 2] - C argument slot.
// [sp + 1] - C argument slot.
// [sp + 0] - C argument slot.
- __ lw(sp, MemOperand(sp, stack_alignment + kCArgsSlotsSize));
+ __ ld(sp, MemOperand(sp, stack_alignment + kCArgsSlotsSize));
__ li(code_pointer(), Operand(masm_->CodeObject()));
}
@@ -1248,23 +1294,23 @@ void RegExpMacroAssemblerMIPS::SafeCall(Label* to,
void RegExpMacroAssemblerMIPS::SafeReturn() {
__ pop(ra);
- __ Addu(t5, ra, Operand(masm_->CodeObject()));
- __ Jump(t5);
+ __ Daddu(t1, ra, Operand(masm_->CodeObject()));
+ __ Jump(t1);
}
void RegExpMacroAssemblerMIPS::SafeCallTarget(Label* name) {
__ bind(name);
- __ Subu(ra, ra, Operand(masm_->CodeObject()));
+ __ Dsubu(ra, ra, Operand(masm_->CodeObject()));
__ push(ra);
}
void RegExpMacroAssemblerMIPS::Push(Register source) {
ASSERT(!source.is(backtrack_stackpointer()));
- __ Addu(backtrack_stackpointer(),
+ __ Daddu(backtrack_stackpointer(),
backtrack_stackpointer(),
- Operand(-kPointerSize));
+ Operand(-kIntSize));
__ sw(source, MemOperand(backtrack_stackpointer()));
}
@@ -1272,7 +1318,7 @@ void RegExpMacroAssemblerMIPS::Push(Register source) {
void RegExpMacroAssemblerMIPS::Pop(Register target) {
ASSERT(!target.is(backtrack_stackpointer()));
__ lw(target, MemOperand(backtrack_stackpointer()));
- __ Addu(backtrack_stackpointer(), backtrack_stackpointer(), kPointerSize);
+ __ Daddu(backtrack_stackpointer(), backtrack_stackpointer(), kIntSize);
}
@@ -1281,7 +1327,7 @@ void RegExpMacroAssemblerMIPS::CheckPreemption() {
ExternalReference stack_limit =
ExternalReference::address_of_stack_limit(masm_->isolate());
__ li(a0, Operand(stack_limit));
- __ lw(a0, MemOperand(a0));
+ __ ld(a0, MemOperand(a0));
SafeCall(&check_preempt_label_, ls, sp, Operand(a0));
}
@@ -1291,7 +1337,7 @@ void RegExpMacroAssemblerMIPS::CheckStackLimit() {
ExternalReference::address_of_regexp_stack_limit(masm_->isolate());
__ li(a0, Operand(stack_limit));
- __ lw(a0, MemOperand(a0));
+ __ ld(a0, MemOperand(a0));
SafeCall(&stack_overflow_label_, ls, backtrack_stackpointer(), Operand(a0));
}
@@ -1300,27 +1346,26 @@ void RegExpMacroAssemblerMIPS::LoadCurrentCharacterUnchecked(int cp_offset,
int characters) {
Register offset = current_input_offset();
if (cp_offset != 0) {
- // t7 is not being used to store the capture start index at this point.
- __ Addu(t7, current_input_offset(), Operand(cp_offset * char_size()));
- offset = t7;
+ // t3 is not being used to store the capture start index at this point.
+ __ Daddu(t3, current_input_offset(), Operand(cp_offset * char_size()));
+ offset = t3;
}
// We assume that we cannot do unaligned loads on MIPS, so this function
// must only be used to load a single character at a time.
ASSERT(characters == 1);
- __ Addu(t5, end_of_input_address(), Operand(offset));
+ __ Daddu(t1, end_of_input_address(), Operand(offset));
if (mode_ == ASCII) {
- __ lbu(current_character(), MemOperand(t5, 0));
+ __ lbu(current_character(), MemOperand(t1, 0));
} else {
ASSERT(mode_ == UC16);
- __ lhu(current_character(), MemOperand(t5, 0));
+ __ lhu(current_character(), MemOperand(t1, 0));
}
}
-
#undef __
#endif // V8_INTERPRETED_REGEXP
}} // namespace v8::internal
-#endif // V8_TARGET_ARCH_MIPS
+#endif // V8_TARGET_ARCH_MIPS64
« no previous file with comments | « src/mips64/regexp-macro-assembler-mips64.h ('k') | src/mips64/simulator-mips64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698