Commit d7e5f97b authored by lrn@chromium.org's avatar lrn@chromium.org

Made ARM/IA32 handling in Regexp symmetric (although without an ARM implementation yet).


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@848 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 1dd110b8
......@@ -52,7 +52,8 @@ SOURCES = {
],
'arch:arm': ['assembler-arm.cc', 'builtins-arm.cc', 'codegen-arm.cc',
'cpu-arm.cc', 'disasm-arm.cc', 'frames-arm.cc', 'ic-arm.cc',
'macro-assembler-arm.cc', 'stub-cache-arm.cc'],
'macro-assembler-arm.cc', 'regexp-macro-assembler-arm.cc',
'stub-cache-arm.cc'],
'arch:ia32': ['assembler-ia32.cc', 'builtins-ia32.cc', 'codegen-ia32.cc',
'cpu-ia32.cc', 'disasm-ia32.cc', 'frames-ia32.cc', 'ic-ia32.cc',
'macro-assembler-ia32.cc', 'regexp-macro-assembler-ia32.cc',
......
......@@ -59,7 +59,7 @@
// CodeGenerator::FastCaseSwitchMinCaseCount
// CodeGenerator::FastCaseSwitchMaxOverheadFactor
#if defined(ARM)
#ifdef ARM
#include "codegen-arm.h"
#else
#include "codegen-ia32.h"
......
......@@ -32,7 +32,7 @@
#include "api.h"
#include "codegen-inl.h"
#if defined(ARM) || defined (__arm__) || defined(__thumb__)
#ifdef ARM
#include "simulator-arm.h"
#else // ia32
#include "simulator-ia32.h"
......
......@@ -29,7 +29,7 @@
#define V8_FRAMES_INL_H_
#include "frames.h"
#if defined(ARM) || defined (__arm__) || defined(__thumb__)
#ifdef ARM
#include "frames-arm.h"
#else
#include "frames-ia32.h"
......
......@@ -43,11 +43,14 @@
#include "assembler-irregexp.h"
#include "regexp-macro-assembler.h"
#include "regexp-macro-assembler-irregexp.h"
#if defined __arm__ || defined __thumb__ || defined ARM
// include regexp-macro-assembler-arm.h when created.
#else // ia32
#ifdef ARM
#include "regexp-macro-assembler-arm.h"
#else // IA32
#include "macro-assembler-ia32.h"
#include "regexp-macro-assembler-ia32.h"
#endif
#include "interpreter-irregexp.h"
// Including pcre.h undefines DEBUG to avoid getting debug output from
......@@ -2579,18 +2582,17 @@ Handle<FixedArray> RegExpEngine::Compile(RegExpParseResult* input,
return Handle<FixedArray>::null();
}
#if !(defined ARM || defined __arm__ || defined __thumb__)
if (FLAG_irregexp_native) { // Flag only checked in IA32 mode.
// TODO(lrn) Move compilation to a later point in the life-cycle
// of the RegExp. We don't know the type of input string yet.
// For now, always assume two-byte strings.
if (FLAG_irregexp_native) {
#ifdef ARM
UNIMPLEMENTED();
#else // IA32
RegExpMacroAssemblerIA32 macro_assembler(RegExpMacroAssemblerIA32::UC16,
(input->capture_count + 1) * 2);
return compiler.Assemble(&macro_assembler,
node,
input->capture_count);
}
#endif
}
byte codes[1024];
IrregexpAssembler assembler(Vector<byte>(codes, 1024));
RegExpMacroAssemblerIrregexp macro_assembler(&assembler);
......
......@@ -28,7 +28,7 @@
#ifndef V8_MACRO_ASSEMBLER_H_
#define V8_MACRO_ASSEMBLER_H_
#if defined(ARM) || defined (__arm__) || defined(__thumb__)
#ifdef ARM
#include "constants-arm.h"
#include "assembler.h"
......
// Copyright 2006-2008 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "v8.h"
#include "ast.h"
#include "regexp-macro-assembler.h"
#include "regexp-macro-assembler-arm.h"
namespace v8 { namespace internal {
RegExpMacroAssemblerARM::RegExpMacroAssemblerARM() {
UNIMPLEMENTED();
}
RegExpMacroAssemblerARM::~RegExpMacroAssemblerARM() {}
}} // namespace v8::internal
// Copyright 2006-2008 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef REGEXP_MACRO_ASSEMBLER_ARM_H_
#define REGEXP_MACRO_ASSEMBLER_ARM_H_
namespace v8 { namespace internal {
class RegExpMacroAssemblerARM: public RegExpMacroAssembler {
public:
RegExpMacroAssemblerARM();
virtual ~RegExpMacroAssemblerARM();
};
}} // namespace v8::internal
#endif /* REGEXP_MACRO_ASSEMBLER_ARM_H_ */
......@@ -30,9 +30,12 @@
#include "log.h"
#include "ast.h"
#include "macro-assembler.h"
#include "regexp-macro-assembler.h"
#include "macro-assembler-ia32.h"
#include "regexp-macro-assembler-ia32.h"
namespace v8 { namespace internal {
/*
* This assembler uses the following register assignment convention
* - edx : current character. Must be loaded using LoadCurrentCharacter
......@@ -355,7 +358,7 @@ Handle<Object> RegExpMacroAssemblerIA32::GetCode() {
__ bind(&entry_label_);
__ push(esi);
__ push(edi);
__ enter(Immediate(num_registers_ * sizeof(uint32_t)));
__ enter(Immediate(num_registers_ * kPointerSize));
__ mov(esi, Operand(ebp, kInputEndOffset));
__ mov(edi, Operand(ebp, kInputStartOffset));
__ sub(edi, Operand(esi));
......@@ -388,7 +391,7 @@ Handle<Object> RegExpMacroAssemblerIA32::GetCode() {
if (char_size() == 2) {
__ shr(eax);
}
__ mov(Operand(ebx, i * sizeof(int32_t)), eax);
__ mov(Operand(ebx, i * kPointerSize), eax);
}
}
__ mov(eax, Immediate(1));
......@@ -516,7 +519,7 @@ void RegExpMacroAssemblerIA32::WriteStackPointerToRegister(int reg) {
Operand RegExpMacroAssemblerIA32::register_location(
int register_index) {
ASSERT(register_index < (1<<30));
return Operand(ebp, -(register_index + 1) * sizeof(uint32_t));
return Operand(ebp, -(register_index + 1) * kPointerSize);
}
......@@ -629,4 +632,4 @@ void RegExpMacroAssemblerIA32::LoadConstantBufferAddress(Register reg,
}
#undef __
}}
}} // namespace v8::internal
......@@ -28,16 +28,13 @@
#ifndef REGEXP_MACRO_ASSEMBLER_IA32_H_
#define REGEXP_MACRO_ASSEMBLER_IA32_H_
#if !(defined(ARM) || defined(__arm__) || defined(__thumb__))
#include "regexp-macro-assembler.h"
#include "macro-assembler-ia32.h"
namespace v8 { namespace internal {
class RegExpMacroAssemblerIA32: public RegExpMacroAssembler {
public:
// Type of input string to generate code for.
enum Mode {ASCII = 1, UC16 = 2};
RegExpMacroAssemblerIA32(Mode mode, int registers_to_save);
virtual ~RegExpMacroAssemblerIA32();
virtual void AdvanceCurrentPosition(int by);
......@@ -88,6 +85,7 @@ class RegExpMacroAssemblerIA32: public RegExpMacroAssembler {
virtual void Succeed();
virtual void WriteCurrentPositionToRegister(int reg);
virtual void WriteStackPointerToRegister(int reg);
private:
// Offsets from ebp of arguments to function.
static const int kBackup_edi = 1 * sizeof(uint32_t);
......@@ -97,6 +95,15 @@ class RegExpMacroAssemblerIA32: public RegExpMacroAssembler {
static const int kInputEndOffset = 6 * sizeof(uint32_t);
static const int kRegisterOutput = 7 * sizeof(uint32_t);
// Initial size of code buffer.
static const size_t kRegExpCodeSize = 1024;
// Initial size of constant buffers allocated during compilation.
static const int kRegExpConstantsSize = 256;
// Only unroll loops up to this length.
static const int kMaxInlineStringTests = 8;
// Special "character" marking end of input.
static const uint32_t kEndOfInput = ~0;
// The ebp-relative location of a regexp register.
Operand register_location(int register_index);
......@@ -130,16 +137,9 @@ class RegExpMacroAssemblerIA32: public RegExpMacroAssembler {
// (and checks if we have hit the stack limit too).
void CheckStackLimit();
// Initial size of code buffer.
static const size_t kRegExpCodeSize = 1024;
// Initial size of constant buffers allocated during compilation.
static const int kRegExpConstantsSize = 256;
// Only unroll loops up to this length.
static const int kMaxInlineStringTests = 8;
// Special "character" marking end of input.
static const uint32_t kEndOfInput = ~0;
MacroAssembler* masm_;
// Constant buffer provider. Allocates external storage for storing
// constants.
ByteArrayProvider constants_;
// Which mode to generate code for (ASCII or UTF16).
Mode mode_;
......@@ -148,8 +148,7 @@ class RegExpMacroAssemblerIA32: public RegExpMacroAssembler {
// Number of registers to output at the end (the saved registers
// are always 0..num_saved_registers_-1)
int num_saved_registers_;
// Whether to generate code that is case-insensitive. Only relevant for
// back-references.
// Labels used internally.
Label entry_label_;
Label start_label_;
Label success_label_;
......@@ -157,8 +156,7 @@ class RegExpMacroAssemblerIA32: public RegExpMacroAssembler {
// Handle used to represent the generated code object itself.
Handle<Object> self_;
};
}}
#endif // !ARM
}} // namespace v8::internal
#endif /* REGEXP_MACRO_ASSEMBLER_IA32_H_ */
......@@ -39,7 +39,12 @@
#include "assembler-irregexp.h"
#include "regexp-macro-assembler.h"
#include "regexp-macro-assembler-irregexp.h"
#ifdef ARM
#include "regexp-macro-assembler-arm.h"
#else // IA32
#include "macro-assembler-ia32.h"
#include "regexp-macro-assembler-ia32.h"
#endif
#include "interpreter-irregexp.h"
......@@ -720,7 +725,7 @@ TEST(MacroAssembler) {
}
#if !(defined(ARM) || defined(__arm__) || defined(__thumb__))
#ifndef ARM // IA32 only tests.
TEST(MacroAssemblerIA32Success) {
typedef bool (*AsciiTest) (
......@@ -954,7 +959,7 @@ TEST(MacroAssemblerIA32Registers) {
CHECK_EQ(9, output[4]);
}
#endif // !(defined(ARM) || defined(__arm__) || defined(__thumb__))
#endif // !defined ARM
TEST(AddInverseToTable) {
static const int kLimit = 1000;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment