Commit 72de7ab7 authored by lrn@chromium.org's avatar lrn@chromium.org

Separate native and interpreted regexp by compile time flag, not runtime.

Clean-up of RegExp code.

Review URL: http://codereview.chromium.org/155085


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2366 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 1bee2d8a
......@@ -95,7 +95,12 @@ ANDROID_LINKFLAGS = ['-nostdlib',
LIBRARY_FLAGS = {
'all': {
'CPPDEFINES': ['ENABLE_LOGGING_AND_PROFILING'],
'CPPPATH': [join(root_dir, 'src')]
'CPPPATH': [join(root_dir, 'src')],
'regexp:native': {
'arch:ia32' : {
'CPPDEFINES': ['V8_NATIVE_REGEXP']
}
}
},
'gcc': {
'all': {
......@@ -546,6 +551,11 @@ SIMPLE_OPTIONS = {
'default': ARCH_GUESS,
'help': 'the architecture to build for (' + ARCH_GUESS + ')'
},
'regexp': {
'values': ['native', 'interpreted'],
'default': 'native',
'help': 'Whether to use native or interpreted regexp implementation'
},
'snapshot': {
'values': ['on', 'off', 'nobuild'],
'default': 'off',
......@@ -677,6 +687,8 @@ def VerifyOptions(env):
return False
if not IsLegal(env, 'sample', ["shell", "process"]):
return False
if not IsLegal(env, 'regexp', ["native", "interpreted"]):
return False
if env['os'] == 'win32' and env['library'] == 'shared' and env['prof'] == 'on':
Abort("Profiling on windows only supported for static library.")
if env['prof'] == 'oprofile' and env['os'] != 'linux':
......
......@@ -208,8 +208,6 @@ DEFINE_bool(preemption, false,
// Regexp
DEFINE_bool(trace_regexps, false, "trace regexp execution")
DEFINE_bool(regexp_native, true,
"use native code regexp implementation (IA32 only)")
DEFINE_bool(regexp_optimization, true, "generate optimized regexp code")
// Testing flags test/cctest/test-{flags,api,serialization}.cc
......
This diff is collapsed.
......@@ -37,13 +37,15 @@ class RegExpMacroAssembler;
class RegExpImpl {
public:
static inline bool UseNativeRegexp() {
#ifdef V8_TARGET_ARCH_IA32
return FLAG_regexp_native;
// Whether V8 is compiled with native regexp support or not.
static bool UsesNativeRegExp() {
#ifdef V8_NATIVE_REGEXP
return true;
#else
return false;
return false;
#endif
}
// Creates a regular expression literal in the old space.
// This function calls the garbage collector if necessary.
static Handle<Object> CreateRegExpLiteral(Handle<JSFunction> constructor,
......@@ -148,7 +150,8 @@ class RegExpImpl {
static String* last_ascii_string_;
static String* two_byte_cached_string_;
static bool EnsureCompiledIrregexp(Handle<JSRegExp> re, bool is_ascii);
static bool CompileIrregexp(Handle<JSRegExp> re, bool is_ascii);
static inline bool EnsureCompiledIrregexp(Handle<JSRegExp> re, bool is_ascii);
// Set the subject cache. The previous string buffer is not deleted, so the
......
......@@ -714,7 +714,7 @@ void JSRegExp::JSRegExpVerify() {
break;
}
case JSRegExp::IRREGEXP: {
bool is_native = RegExpImpl::UseNativeRegexp();
bool is_native = RegExpImpl::UsesNativeRegExp();
FixedArray* arr = FixedArray::cast(data());
Object* ascii_data = arr->get(JSRegExp::kIrregexpASCIICodeIndex);
......
......@@ -3270,6 +3270,9 @@ class JSRegExp: public JSObject {
inline Object* DataAt(int index);
// Set implementation data after the object has been prepared.
inline void SetDataAt(int index, Object* value);
static int code_index(bool is_ascii) {
return is_ascii ? kIrregexpASCIICodeIndex : kIrregexpUC16CodeIndex;
}
static inline JSRegExp* cast(Object* obj);
......
......@@ -1016,16 +1016,16 @@ static Object* Runtime_RegExpExec(Arguments args) {
ASSERT(args.length() == 4);
CONVERT_ARG_CHECKED(JSRegExp, regexp, 0);
CONVERT_ARG_CHECKED(String, subject, 1);
// Due to the way the JS files are constructed this must be less than the
// Due to the way the JS calls are constructed this must be less than the
// length of a string, i.e. it is always a Smi. We check anyway for security.
CONVERT_CHECKED(Smi, index, args[2]);
CONVERT_SMI_CHECKED(index, args[2]);
CONVERT_ARG_CHECKED(JSArray, last_match_info, 3);
RUNTIME_ASSERT(last_match_info->HasFastElements());
RUNTIME_ASSERT(index->value() >= 0);
RUNTIME_ASSERT(index->value() <= subject->length());
RUNTIME_ASSERT(index >= 0);
RUNTIME_ASSERT(index <= subject->length());
Handle<Object> result = RegExpImpl::Exec(regexp,
subject,
index->value(),
index,
last_match_info);
if (result.is_null()) return Failure::Exception();
return *result;
......
......@@ -4892,6 +4892,7 @@ TEST(DebugBreakInMessageHandler) {
}
#ifdef V8_NATIVE_REGEXP
// Debug event handler which gets the function on the top frame and schedules a
// break a number of times.
static void DebugEventDebugBreak(
......@@ -4928,11 +4929,10 @@ static void DebugEventDebugBreak(
TEST(RegExpDebugBreak) {
// This test only applies to native regexps.
v8::HandleScope scope;
DebugLocalContext env;
i::FLAG_regexp_native = true;
// Create a function for checking the function when hitting a break point.
frame_function_name = CompileFunction(&env,
frame_function_name_source,
......@@ -4957,6 +4957,7 @@ TEST(RegExpDebugBreak) {
CHECK_EQ(20, break_point_hit_count);
CHECK_EQ("exec", last_function_hit);
}
#endif // V8_NATIVE_REGEXP
// Common part of EvalContextData and NestedBreakEventContextData tests.
......
......@@ -597,6 +597,8 @@ TEST(DispatchTableConstruction) {
}
// Tests of interpreter.
TEST(MacroAssembler) {
V8::Initialize(NULL);
byte codes[1024];
......@@ -660,8 +662,8 @@ TEST(MacroAssembler) {
CHECK_EQ(42, captures[0]);
}
#ifdef V8_TARGET_ARCH_IA32 // IA32 only tests.
#ifdef V8_TARGET_ARCH_IA32 // IA32 Native Regexp only tests.
#ifdef V8_NATIVE_REGEXP
class ContextInitializer {
public:
......@@ -1284,10 +1286,10 @@ TEST(MacroAssemblerIA32LotsOfRegisters) {
Top::clear_pending_exception();
}
#endif // V8_REGEXP_NATIVE
#endif // V8_TARGET_ARCH_IA32
#endif // !defined ARM
TEST(AddInverseToTable) {
static const int kLimit = 1000;
static const int kRangeCount = 16;
......
......@@ -419,7 +419,8 @@
'target_name': 'v8_base',
'type': '<(library)',
'defines': [
'V8_TARGET_ARCH_IA32'
'V8_TARGET_ARCH_IA32',
'V8_NATIVE_REGEXP'
],
'include_dirs+': [
'../../src',
......@@ -477,7 +478,8 @@
'target_name': 'v8_nosnapshot',
'type': '<(library)',
'defines': [
'V8_TARGET_ARCH_IA32'
'V8_TARGET_ARCH_IA32',
'V8_NATIVE_REGEXP'
],
'dependencies': [
'js2c',
......@@ -509,7 +511,8 @@
'target_name': 'v8',
'type': '<(library)',
'defines': [
'V8_TARGET_ARCH_IA32'
'V8_TARGET_ARCH_IA32',
'V8_NATIVE_REGEXP'
],
'dependencies': [
'js2c',
......@@ -549,7 +552,8 @@
'target_name': 'v8_shell',
'type': 'executable',
'defines': [
'V8_TARGET_ARCH_IA32'
'V8_TARGET_ARCH_IA32',
'V8_NATIVE_REGEXP'
],
'dependencies': [
'v8',
......@@ -579,7 +583,8 @@
'v8',
],
'defines': [
'V8_TARGET_ARCH_IA32'
'V8_TARGET_ARCH_IA32',
'V8_NATIVE_REGEXP'
],
'include_dirs': [
'../../src',
......
......@@ -1449,6 +1449,7 @@
GCC_PREPROCESSOR_DEFINITIONS = (
"$(GCC_PREPROCESSOR_DEFINITIONS)",
V8_TARGET_ARCH_IA32,
V8_NATIVE_REGEXP,
DEBUG,
);
HEADER_SEARCH_PATHS = ../src;
......@@ -1462,6 +1463,7 @@
GCC_PREPROCESSOR_DEFINITIONS = (
"$(GCC_PREPROCESSOR_DEFINITIONS)",
V8_TARGET_ARCH_IA32,
V8_NATIVE_REGEXP,
NDEBUG,
);
HEADER_SEARCH_PATHS = ../src;
......@@ -1477,6 +1479,7 @@
"$(GCC_PREPROCESSOR_DEFINITIONS)",
ENABLE_DISASSEMBLER,
V8_TARGET_ARCH_IA32,
V8_NATIVE_REGEXP,
ENABLE_LOGGING_AND_PROFILING,
);
HEADER_SEARCH_PATHS = ../src;
......@@ -1492,6 +1495,7 @@
GCC_PREPROCESSOR_DEFINITIONS = (
"$(GCC_PREPROCESSOR_DEFINITIONS)",
V8_TARGET_ARCH_IA32,
V8_NATIVE_REGEXP,
NDEBUG,
);
HEADER_SEARCH_PATHS = ../src;
......
......@@ -6,6 +6,6 @@
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="V8_TARGET_ARCH_IA32"
PreprocessorDefinitions="V8_TARGET_ARCH_IA32;V8_NATIVE_REGEXP"
/>
</VisualStudioPropertySheet>
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