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

Side by Side Diff: src/full-codegen/arm64/full-codegen-arm64.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 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_ARM64 5 #if V8_TARGET_ARCH_ARM64
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/codegen.h" 9 #include "src/codegen.h"
10 #include "src/debug/debug.h" 10 #include "src/debug/debug.h"
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 __ Bind(&done); 1443 __ Bind(&done);
1444 context()->Plug(x0); 1444 context()->Plug(x0);
1445 break; 1445 break;
1446 } 1446 }
1447 } 1447 }
1448 } 1448 }
1449 1449
1450 1450
1451 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { 1451 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
1452 Comment cmnt(masm_, "[ RegExpLiteral"); 1452 Comment cmnt(masm_, "[ RegExpLiteral");
1453 Label materialized; 1453 __ Ldr(x3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1454 // Registers will be used as follows: 1454 __ Mov(x2, Smi::FromInt(expr->literal_index()));
1455 // x5 = materialized value (RegExp literal) 1455 __ Mov(x1, Operand(expr->pattern()));
1456 // x4 = JS function, literals array 1456 __ Mov(x0, Operand(expr->flags()));
1457 // x3 = literal index 1457 FastCloneRegExpStub stub(isolate());
1458 // x2 = RegExp pattern 1458 __ CallStub(&stub);
1459 // x1 = RegExp flags
1460 // x0 = RegExp literal clone
1461 __ Ldr(x10, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1462 __ Ldr(x4, FieldMemOperand(x10, JSFunction::kLiteralsOffset));
1463 int literal_offset = LiteralsArray::OffsetOfLiteralAt(expr->literal_index());
1464 __ Ldr(x5, FieldMemOperand(x4, literal_offset));
1465 __ JumpIfNotRoot(x5, Heap::kUndefinedValueRootIndex, &materialized);
1466
1467 // Create regexp literal using runtime function.
1468 // Result will be in x0.
1469 __ Mov(x3, Smi::FromInt(expr->literal_index()));
1470 __ Mov(x2, Operand(expr->pattern()));
1471 __ Mov(x1, Operand(expr->flags()));
1472 __ Push(x4, x3, x2, x1);
1473 __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4);
1474 __ Mov(x5, x0);
1475
1476 __ Bind(&materialized);
1477 int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
1478 Label allocated, runtime_allocate;
1479 __ Allocate(size, x0, x2, x3, &runtime_allocate, TAG_OBJECT);
1480 __ B(&allocated);
1481
1482 __ Bind(&runtime_allocate);
1483 __ Mov(x10, Smi::FromInt(size));
1484 __ Push(x5, x10);
1485 __ CallRuntime(Runtime::kAllocateInNewSpace, 1);
1486 __ Pop(x5);
1487
1488 __ Bind(&allocated);
1489 // After this, registers are used as follows:
1490 // x0: Newly allocated regexp.
1491 // x5: Materialized regexp.
1492 // x10, x11, x12: temps.
1493 __ CopyFields(x0, x5, CPURegList(x10, x11, x12), size / kPointerSize);
1494 context()->Plug(x0); 1459 context()->Plug(x0);
1495 } 1460 }
1496 1461
1497 1462
1498 void FullCodeGenerator::EmitAccessor(ObjectLiteralProperty* property) { 1463 void FullCodeGenerator::EmitAccessor(ObjectLiteralProperty* property) {
1499 Expression* expression = (property == NULL) ? NULL : property->value(); 1464 Expression* expression = (property == NULL) ? NULL : property->value();
1500 if (expression == NULL) { 1465 if (expression == NULL) {
1501 __ LoadRoot(x10, Heap::kNullValueRootIndex); 1466 __ LoadRoot(x10, Heap::kNullValueRootIndex);
1502 __ Push(x10); 1467 __ Push(x10);
1503 } else { 1468 } else {
(...skipping 3532 matching lines...) Expand 10 before | Expand all | Expand 10 after
5036 } 5001 }
5037 5002
5038 return INTERRUPT; 5003 return INTERRUPT;
5039 } 5004 }
5040 5005
5041 5006
5042 } // namespace internal 5007 } // namespace internal
5043 } // namespace v8 5008 } // namespace v8
5044 5009
5045 #endif // V8_TARGET_ARCH_ARM64 5010 #endif // V8_TARGET_ARCH_ARM64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698