Index: src/runtime/runtime-literals.cc |
diff --git a/src/runtime/runtime-literals.cc b/src/runtime/runtime-literals.cc |
index 344466be99a2ddb8966f4c0c6ae5af5892b94599..ce1dc243087c16677de572993c174de1940a45a7 100644 |
--- a/src/runtime/runtime-literals.cc |
+++ b/src/runtime/runtime-literals.cc |
@@ -236,6 +236,25 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate( |
} |
+RUNTIME_FUNCTION(Runtime_CreateRegExpLiteral) { |
+ HandleScope scope(isolate); |
+ DCHECK_EQ(4, args.length()); |
+ CONVERT_ARG_HANDLE_CHECKED(JSFunction, closure, 0); |
+ CONVERT_SMI_ARG_CHECKED(index, 1); |
+ CONVERT_ARG_HANDLE_CHECKED(String, pattern, 2); |
+ CONVERT_ARG_HANDLE_CHECKED(String, flags, 3); |
+ |
+ // Check if boilerplate exists. If not, create it first. |
+ Handle<Object> boilerplate(closure->literals()->literal(index), isolate); |
+ if (boilerplate->IsUndefined()) { |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, boilerplate, |
+ JSRegExp::New(pattern, flags)); |
+ closure->literals()->set_literal(index, *boilerplate); |
+ } |
+ return *JSRegExp::Copy(Handle<JSRegExp>::cast(boilerplate)); |
+} |
+ |
+ |
RUNTIME_FUNCTION(Runtime_CreateObjectLiteral) { |
HandleScope scope(isolate); |
DCHECK_EQ(4, args.length()); |