Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Unified Diff: src/runtime/runtime-literals.cc

Issue 1475823003: [runtime] First step to sanitize regexp literal creation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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());

Powered by Google App Engine
This is Rietveld 408576698