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

Side by Side Diff: src/full-codegen/arm/full-codegen-arm.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_ARM 5 #if V8_TARGET_ARCH_ARM
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 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after
1454 __ CallRuntime(function_id, 2); 1454 __ CallRuntime(function_id, 2);
1455 __ bind(&done); 1455 __ bind(&done);
1456 context()->Plug(r0); 1456 context()->Plug(r0);
1457 } 1457 }
1458 } 1458 }
1459 } 1459 }
1460 1460
1461 1461
1462 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { 1462 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
1463 Comment cmnt(masm_, "[ RegExpLiteral"); 1463 Comment cmnt(masm_, "[ RegExpLiteral");
1464 Label materialized; 1464 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1465 // Registers will be used as follows: 1465 __ mov(r2, Operand(Smi::FromInt(expr->literal_index())));
1466 // r5 = materialized value (RegExp literal) 1466 __ mov(r1, Operand(expr->pattern()));
1467 // r4 = JS function, literals array 1467 __ mov(r0, Operand(expr->flags()));
1468 // r3 = literal index 1468 FastCloneRegExpStub stub(isolate());
1469 // r2 = RegExp pattern 1469 __ CallStub(&stub);
1470 // r1 = RegExp flags
1471 // r0 = RegExp literal clone
1472 __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1473 __ ldr(r4, FieldMemOperand(r0, JSFunction::kLiteralsOffset));
1474 int literal_offset = LiteralsArray::OffsetOfLiteralAt(expr->literal_index());
1475 __ ldr(r5, FieldMemOperand(r4, literal_offset));
1476 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex);
1477 __ cmp(r5, ip);
1478 __ b(ne, &materialized);
1479
1480 // Create regexp literal using runtime function.
1481 // Result will be in r0.
1482 __ mov(r3, Operand(Smi::FromInt(expr->literal_index())));
1483 __ mov(r2, Operand(expr->pattern()));
1484 __ mov(r1, Operand(expr->flags()));
1485 __ Push(r4, r3, r2, r1);
1486 __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4);
1487 __ mov(r5, r0);
1488
1489 __ bind(&materialized);
1490 int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
1491 Label allocated, runtime_allocate;
1492 __ Allocate(size, r0, r2, r3, &runtime_allocate, TAG_OBJECT);
1493 __ jmp(&allocated);
1494
1495 __ bind(&runtime_allocate);
1496 __ mov(r0, Operand(Smi::FromInt(size)));
1497 __ Push(r5, r0);
1498 __ CallRuntime(Runtime::kAllocateInNewSpace, 1);
1499 __ pop(r5);
1500
1501 __ bind(&allocated);
1502 // After this, registers are used as follows:
1503 // r0: Newly allocated regexp.
1504 // r5: Materialized regexp.
1505 // r2: temp.
1506 __ CopyFields(r0, r5, d0, size / kPointerSize);
1507 context()->Plug(r0); 1470 context()->Plug(r0);
1508 } 1471 }
1509 1472
1510 1473
1511 void FullCodeGenerator::EmitAccessor(ObjectLiteralProperty* property) { 1474 void FullCodeGenerator::EmitAccessor(ObjectLiteralProperty* property) {
1512 Expression* expression = (property == NULL) ? NULL : property->value(); 1475 Expression* expression = (property == NULL) ? NULL : property->value();
1513 if (expression == NULL) { 1476 if (expression == NULL) {
1514 __ LoadRoot(r1, Heap::kNullValueRootIndex); 1477 __ LoadRoot(r1, Heap::kNullValueRootIndex);
1515 __ push(r1); 1478 __ push(r1);
1516 } else { 1479 } else {
(...skipping 3531 matching lines...) Expand 10 before | Expand all | Expand 10 after
5048 DCHECK(interrupt_address == 5011 DCHECK(interrupt_address ==
5049 isolate->builtins()->OsrAfterStackCheck()->entry()); 5012 isolate->builtins()->OsrAfterStackCheck()->entry());
5050 return OSR_AFTER_STACK_CHECK; 5013 return OSR_AFTER_STACK_CHECK;
5051 } 5014 }
5052 5015
5053 5016
5054 } // namespace internal 5017 } // namespace internal
5055 } // namespace v8 5018 } // namespace v8
5056 5019
5057 #endif // V8_TARGET_ARCH_ARM 5020 #endif // V8_TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698