Version 1.3.5
Optimize initialization of some arrays in the builtins.
Fix mac-nm script to support filenames with spaces.
Support for using the V8 profiler when V8 is embedded in a Windows DLL.
Changed typeof RegExp from 'object' to 'function' for compatibility. Fixed bug where regexps were not callable across contexts.
Added context independent script compilation to the API.
Added API call to get the stack trace for an exception.
Added API for getting object mirrors.
Make sure that SSE3 instructions are used whenever possible even when running off a snapshot generated without using SSE3 instructions.
Tweaked the handling of the initial size and growth policy of the heap.
Added native code generation for RegExp to 64-bit version.
Added JavaScript debugger support to 64-bit version.
git-svn-id: http://v8.googlecode.com/svn/trunk@2722 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/src/jsregexp.cc b/src/jsregexp.cc
index bd51102..06208aa 100644
--- a/src/jsregexp.cc
+++ b/src/jsregexp.cc
@@ -43,6 +43,7 @@
#include "regexp-macro-assembler-irregexp.h"
#include "regexp-stack.h"
+#ifdef V8_NATIVE_REGEXP
#if V8_TARGET_ARCH_IA32
#include "ia32/macro-assembler-ia32.h"
#include "ia32/regexp-macro-assembler-ia32.h"
@@ -54,6 +55,7 @@
#else
#error Unsupported target architecture.
#endif
+#endif
#include "interpreter-irregexp.h"
@@ -270,10 +272,11 @@
// If compilation fails, an exception is thrown and this function
// returns false.
bool RegExpImpl::EnsureCompiledIrregexp(Handle<JSRegExp> re, bool is_ascii) {
+ Object* compiled_code = re->DataAt(JSRegExp::code_index(is_ascii));
#ifdef V8_NATIVE_REGEXP
- if (re->DataAt(JSRegExp::code_index(is_ascii))->IsCode()) return true;
+ if (compiled_code->IsCode()) return true;
#else // ! V8_NATIVE_REGEXP (RegExp interpreter code)
- if (re->DataAt(JSRegExp::code_index(is_ascii))->IsByteArray()) return true;
+ if (compiled_code->IsByteArray()) return true;
#endif
return CompileIrregexp(re, is_ascii);
}
@@ -414,33 +417,36 @@
// Dispatch to the correct RegExp implementation.
Handle<FixedArray> regexp(FixedArray::cast(jsregexp->data()));
+
#ifdef V8_NATIVE_REGEXP
-#if V8_TARGET_ARCH_IA32
+#ifdef V8_TARGET_ARCH_ARM
+ UNIMPLEMENTED();
+#else // Native regexp supported.
OffsetsVector captures(number_of_capture_registers);
int* captures_vector = captures.vector();
- RegExpMacroAssemblerIA32::Result res;
+ NativeRegExpMacroAssembler::Result res;
do {
bool is_ascii = subject->IsAsciiRepresentation();
if (!EnsureCompiledIrregexp(jsregexp, is_ascii)) {
return Handle<Object>::null();
}
Handle<Code> code(RegExpImpl::IrregexpNativeCode(*regexp, is_ascii));
- res = RegExpMacroAssemblerIA32::Match(code,
- subject,
- captures_vector,
- captures.length(),
- previous_index);
+ res = NativeRegExpMacroAssembler::Match(code,
+ subject,
+ captures_vector,
+ captures.length(),
+ previous_index);
// If result is RETRY, the string have changed representation, and we
// must restart from scratch.
- } while (res == RegExpMacroAssemblerIA32::RETRY);
- if (res == RegExpMacroAssemblerIA32::EXCEPTION) {
+ } while (res == NativeRegExpMacroAssembler::RETRY);
+ if (res == NativeRegExpMacroAssembler::EXCEPTION) {
ASSERT(Top::has_pending_exception());
return Handle<Object>::null();
}
- ASSERT(res == RegExpMacroAssemblerIA32::SUCCESS
- || res == RegExpMacroAssemblerIA32::FAILURE);
+ ASSERT(res == NativeRegExpMacroAssembler::SUCCESS
+ || res == NativeRegExpMacroAssembler::FAILURE);
- if (res != RegExpMacroAssemblerIA32::SUCCESS) return Factory::null_value();
+ if (res != NativeRegExpMacroAssembler::SUCCESS) return Factory::null_value();
array = Handle<FixedArray>(FixedArray::cast(last_match_info->elements()));
ASSERT(array->length() >= number_of_capture_registers + kLastMatchOverhead);
@@ -449,10 +455,9 @@
SetCapture(*array, i, captures_vector[i]);
SetCapture(*array, i + 1, captures_vector[i + 1]);
}
-#else // !V8_TARGET_ARCH_IA32
- UNREACHABLE();
-#endif // V8_TARGET_ARCH_IA32
-#else // !V8_NATIVE_REGEXP
+#endif // Native regexp supported.
+
+#else // ! V8_NATIVE_REGEXP
bool is_ascii = subject->IsAsciiRepresentation();
if (!EnsureCompiledIrregexp(jsregexp, is_ascii)) {
return Handle<Object>::null();
@@ -4457,38 +4462,36 @@
NodeInfo info = *node->info();
+ // Create the correct assembler for the architecture.
#ifdef V8_NATIVE_REGEXP
-#ifdef V8_TARGET_ARCH_ARM
- // ARM native regexp not implemented yet.
- UNREACHABLE();
-#endif
-#ifdef V8_TARGET_ARCH_X64
- // X64 native regexp not implemented yet.
- UNREACHABLE();
-#endif
+ // Native regexp implementation.
+
+ NativeRegExpMacroAssembler::Mode mode =
+ is_ascii ? NativeRegExpMacroAssembler::ASCII
+ : NativeRegExpMacroAssembler::UC16;
+
#ifdef V8_TARGET_ARCH_IA32
- RegExpMacroAssemblerIA32::Mode mode;
- if (is_ascii) {
- mode = RegExpMacroAssemblerIA32::ASCII;
- } else {
- mode = RegExpMacroAssemblerIA32::UC16;
- }
RegExpMacroAssemblerIA32 macro_assembler(mode,
(data->capture_count + 1) * 2);
- return compiler.Assemble(¯o_assembler,
- node,
- data->capture_count,
- pattern);
#endif
+#ifdef V8_TARGET_ARCH_X64
+ RegExpMacroAssemblerX64 macro_assembler(mode,
+ (data->capture_count + 1) * 2);
+#endif
+#ifdef V8_TARGET_ARCH_ARM
+ UNIMPLEMENTED();
+#endif
+
#else // ! V8_NATIVE_REGEXP
- // Interpreted regexp.
+ // Interpreted regexp implementation.
EmbeddedVector<byte, 1024> codes;
RegExpMacroAssemblerIrregexp macro_assembler(codes);
+#endif
+
return compiler.Assemble(¯o_assembler,
node,
data->capture_count,
pattern);
-#endif // V8_NATIVE_REGEXP
}
}} // namespace v8::internal