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

Unified Diff: src/full-codegen/mips/full-codegen-mips.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/full-codegen/mips/full-codegen-mips.cc
diff --git a/src/full-codegen/mips/full-codegen-mips.cc b/src/full-codegen/mips/full-codegen-mips.cc
index 40ee4374a10e3cbbb1f25387cce40e92537f0c1a..eb63f882b155d6b2820e912c2edd18d89d72035a 100644
--- a/src/full-codegen/mips/full-codegen-mips.cc
+++ b/src/full-codegen/mips/full-codegen-mips.cc
@@ -1459,49 +1459,12 @@ void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy,
void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
Comment cmnt(masm_, "[ RegExpLiteral");
- Label materialized;
- // Registers will be used as follows:
- // t1 = materialized value (RegExp literal)
- // t0 = JS function, literals array
- // a3 = literal index
- // a2 = RegExp pattern
- // a1 = RegExp flags
- // a0 = RegExp literal clone
- __ lw(a0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
- __ lw(t0, FieldMemOperand(a0, JSFunction::kLiteralsOffset));
- int literal_offset = LiteralsArray::OffsetOfLiteralAt(expr->literal_index());
- __ lw(t1, FieldMemOperand(t0, literal_offset));
- __ LoadRoot(at, Heap::kUndefinedValueRootIndex);
- __ Branch(&materialized, ne, t1, Operand(at));
-
- // Create regexp literal using runtime function.
- // Result will be in v0.
- __ li(a3, Operand(Smi::FromInt(expr->literal_index())));
- __ li(a2, Operand(expr->pattern()));
- __ li(a1, Operand(expr->flags()));
- __ Push(t0, a3, a2, a1);
- __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4);
- __ mov(t1, v0);
-
- __ bind(&materialized);
- int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
- Label allocated, runtime_allocate;
- __ Allocate(size, v0, a2, a3, &runtime_allocate, TAG_OBJECT);
- __ jmp(&allocated);
-
- __ bind(&runtime_allocate);
- __ li(a0, Operand(Smi::FromInt(size)));
- __ Push(t1, a0);
- __ CallRuntime(Runtime::kAllocateInNewSpace, 1);
- __ pop(t1);
-
- __ bind(&allocated);
-
- // After this, registers are used as follows:
- // v0: Newly allocated regexp.
- // t1: Materialized regexp.
- // a2: temp.
- __ CopyFields(v0, t1, a2.bit(), size / kPointerSize);
+ __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
+ __ li(a2, Operand(Smi::FromInt(expr->literal_index())));
+ __ li(a1, Operand(expr->pattern()));
+ __ li(a0, Operand(expr->flags()));
+ FastCloneRegExpStub stub(isolate());
+ __ CallStub(&stub);
context()->Plug(v0);
}

Powered by Google App Engine
This is Rietveld 408576698