Commit 28cc20ee authored by jgruber's avatar jgruber Committed by Commit bot

[regexp] Migrate constructor and compile to CSA

Microbenchmarks show 25% improvement over C++, 11% improvement over JS
for the constructor. We don't have a microbenchmark covering the compile
method.

Locally, octane/regexp improved by 2%.

BUG=v8:5339

Review-Url: https://codereview.chromium.org/2551443002
Cr-Commit-Position: refs/heads/master@{#41490}
parent 84ea200a
......@@ -1869,9 +1869,9 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Context::REGEXP_FUNCTION_INDEX);
Handle<SharedFunctionInfo> shared(regexp_fun->shared(), isolate);
shared->SetConstructStub(*isolate->builtins()->RegExpConstructor());
shared->SetConstructStub(*isolate->builtins()->JSBuiltinsConstructStub());
shared->set_instance_class_name(isolate->heap()->RegExp_string());
shared->DontAdaptArguments();
shared->set_internal_formal_parameter_count(2);
shared->set_length(2);
{
......@@ -1904,7 +1904,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Builtins::kRegExpPrototypeUnicodeGetter, true);
SimpleInstallFunction(prototype, "compile",
Builtins::kRegExpPrototypeCompile, 2, false,
Builtins::kRegExpPrototypeCompile, 2, true,
DONT_ENUM);
SimpleInstallFunction(prototype, factory->toString_string(),
Builtins::kRegExpPrototypeToString, 0, false,
......
This diff is collapsed.
......@@ -597,14 +597,14 @@ namespace internal {
CPP(RegExpCapture7Getter) \
CPP(RegExpCapture8Getter) \
CPP(RegExpCapture9Getter) \
CPP(RegExpConstructor) \
TFJ(RegExpConstructor, 2) \
TFJ(RegExpInternalMatch, 2) \
CPP(RegExpInputGetter) \
CPP(RegExpInputSetter) \
CPP(RegExpLastMatchGetter) \
CPP(RegExpLastParenGetter) \
CPP(RegExpLeftContextGetter) \
CPP(RegExpPrototypeCompile) \
TFJ(RegExpPrototypeCompile, 2) \
TFJ(RegExpPrototypeExec, 1) \
TFJ(RegExpPrototypeFlagsGetter, 0) \
TFJ(RegExpPrototypeGlobalGetter, 0) \
......
......@@ -706,6 +706,11 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
IntPtrConstant(0));
}
// Returns true if any of the mask's bits in given |word| are set.
Node* IsSetWord(Node* word, uint32_t mask) {
return WordNotEqual(WordAnd(word, Int32Constant(mask)), Int32Constant(0));
}
void SetCounter(StatsCounter* counter, int value);
void IncrementCounter(StatsCounter* counter, int delta);
void DecrementCounter(StatsCounter* counter, int delta);
......
......@@ -118,12 +118,6 @@ Maybe<bool> RegExpUtils::IsRegExp(Isolate* isolate, Handle<Object> object) {
Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(object);
if (isolate->regexp_function()->initial_map() == receiver->map()) {
// Fast-path for unmodified JSRegExp instances.
// TODO(ishell): Adapt for new fast-path logic.
return Just(true);
}
Handle<Object> match;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, match,
......
......@@ -1665,6 +1665,18 @@ RUNTIME_FUNCTION(Runtime_RegExpExecReThrow) {
return isolate->ReThrow(exception);
}
RUNTIME_FUNCTION(Runtime_RegExpInitializeAndCompile) {
HandleScope scope(isolate);
DCHECK(args.length() == 3);
CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0);
CONVERT_ARG_HANDLE_CHECKED(String, source, 1);
CONVERT_ARG_HANDLE_CHECKED(String, flags, 2);
RETURN_FAILURE_ON_EXCEPTION(isolate,
JSRegExp::Initialize(regexp, source, flags));
return *regexp;
}
RUNTIME_FUNCTION(Runtime_IsRegExp) {
SealHandleScope shs(isolate);
......
......@@ -462,6 +462,7 @@ namespace internal {
F(RegExpExec, 4, 1) \
F(RegExpExecMultiple, 4, 1) \
F(RegExpExecReThrow, 4, 1) \
F(RegExpInitializeAndCompile, 3, 1) \
F(RegExpInternalReplace, 3, 1) \
F(RegExpReplace, 3, 1) \
F(RegExpSplit, 3, 1) \
......
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