From 2364f20cc51240fc3f409c16a2524986004eb666 Mon Sep 17 00:00:00 2001 From: "lrn@chromium.org" Date: Fri, 4 Sep 2009 11:00:07 +0000 Subject: [PATCH] X64 RegExp - fix RegExp on WIN64. Use the correct ifdef to detect Win64 (_WIN64, not __MSVC__). Review URL: http://codereview.chromium.org/195014 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2823 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/runtime.cc | 2 +- src/x64/regexp-macro-assembler-x64.cc | 4 ++-- src/x64/regexp-macro-assembler-x64.h | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/runtime.cc b/src/runtime.cc index f772d32d9d..c26783ad5a 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -4612,7 +4612,7 @@ static JSObject* ComputeReceiverForNonGlobal(JSObject* holder) { static ObjectPair LoadContextSlotHelper(Arguments args, bool throw_error) { HandleScope scope; - ASSERT(args.length() == 2); + ASSERT_EQ(2, args.length()); if (!args[0]->IsContext() || !args[1]->IsString()) { return MakePair(Top::ThrowIllegalOperation(), NULL); diff --git a/src/x64/regexp-macro-assembler-x64.cc b/src/x64/regexp-macro-assembler-x64.cc index 373f359496..963d80ebda 100644 --- a/src/x64/regexp-macro-assembler-x64.cc +++ b/src/x64/regexp-macro-assembler-x64.cc @@ -612,7 +612,7 @@ Handle RegExpMacroAssemblerX64::GetCode(Handle source) { // 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); + __ movzxlq(Operand(rbp, kStartIndex), rdx); // Passed as int in eax. __ movq(Operand(rbp, kInputStart), r8); __ movq(Operand(rbp, kInputEnd), r9); // Callee-save on Win64. @@ -711,7 +711,7 @@ Handle RegExpMacroAssemblerX64::GetCode(Handle source) { __ Move(code_object_pointer(), masm_->CodeObject()); // Load previous char as initial value of current-character. Label at_start; - __ cmpq(Operand(rbp, kAtStart), Immediate(0)); + __ cmpb(Operand(rbp, kAtStart), Immediate(0)); __ j(not_equal, &at_start); LoadCurrentCharacterUnchecked(-1, 1); // Load previous char. __ jmp(&start_label_); diff --git a/src/x64/regexp-macro-assembler-x64.h b/src/x64/regexp-macro-assembler-x64.h index ab9647704b..3e6720dc0d 100644 --- a/src/x64/regexp-macro-assembler-x64.h +++ b/src/x64/regexp-macro-assembler-x64.h @@ -129,16 +129,18 @@ class RegExpMacroAssemblerX64: public NativeRegExpMacroAssembler { static const int kReturn_eip = kFramePointer + kPointerSize; static const int kFrameAlign = kReturn_eip + kPointerSize; -#ifdef __MSVC__ +#ifdef _WIN64 // Parameters (first four passed as registers, but with room on stack). // In Microsoft 64-bit Calling Convention, there is room on the callers // stack (before the return address) to spill parameter registers. We // use this space to store the register passed parameters. static const int kInputString = kFrameAlign; + // StartIndex is passed as 32 bit int. static const int kStartIndex = kInputString + kPointerSize; static const int kInputStart = kStartIndex + kPointerSize; static const int kInputEnd = kInputStart + kPointerSize; static const int kRegisterOutput = kInputEnd + kPointerSize; + // AtStart is passed as 32 bit int (values 0 or 1). static const int kAtStart = kRegisterOutput + kPointerSize; static const int kStackHighEnd = kAtStart + kPointerSize; #else @@ -154,7 +156,7 @@ class RegExpMacroAssemblerX64: public NativeRegExpMacroAssembler { static const int kStackHighEnd = kFrameAlign; #endif -#ifdef __MSVC__ +#ifdef _WIN64 // Microsoft calling convention has three callee-saved registers // (that we are using). We push these after the frame pointer. static const int kBackup_rsi = kFramePointer - kPointerSize;