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

Side by Side Diff: src/full-codegen/ppc/full-codegen-ppc.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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_PPC 5 #if V8_TARGET_ARCH_PPC
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 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 __ CallRuntime(function_id, 2); 1419 __ CallRuntime(function_id, 2);
1420 __ bind(&done); 1420 __ bind(&done);
1421 context()->Plug(r3); 1421 context()->Plug(r3);
1422 } 1422 }
1423 } 1423 }
1424 } 1424 }
1425 1425
1426 1426
1427 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { 1427 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
1428 Comment cmnt(masm_, "[ RegExpLiteral"); 1428 Comment cmnt(masm_, "[ RegExpLiteral");
1429 Label materialized; 1429 __ LoadP(r6, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1430 // Registers will be used as follows: 1430 __ LoadSmiLiteral(r5, Smi::FromInt(expr->literal_index()));
1431 // r8 = materialized value (RegExp literal) 1431 __ mov(r4, Operand(expr->pattern()));
1432 // r7 = JS function, literals array 1432 __ mov(r3, Operand(expr->flags()));
1433 // r6 = literal index 1433 FastCloneRegExpStub stub(isolate());
1434 // r5 = RegExp pattern 1434 __ CallStub(&stub);
1435 // r4 = RegExp flags
1436 // r3 = RegExp literal clone
1437 __ LoadP(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1438 __ LoadP(r7, FieldMemOperand(r3, JSFunction::kLiteralsOffset));
1439 int literal_offset = LiteralsArray::OffsetOfLiteralAt(expr->literal_index());
1440 __ LoadP(r8, FieldMemOperand(r7, literal_offset), r0);
1441 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex);
1442 __ cmp(r8, ip);
1443 __ bne(&materialized);
1444
1445 // Create regexp literal using runtime function.
1446 // Result will be in r3.
1447 __ LoadSmiLiteral(r6, Smi::FromInt(expr->literal_index()));
1448 __ mov(r5, Operand(expr->pattern()));
1449 __ mov(r4, Operand(expr->flags()));
1450 __ Push(r7, r6, r5, r4);
1451 __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4);
1452 __ mr(r8, r3);
1453
1454 __ bind(&materialized);
1455 int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
1456 Label allocated, runtime_allocate;
1457 __ Allocate(size, r3, r5, r6, &runtime_allocate, TAG_OBJECT);
1458 __ b(&allocated);
1459
1460 __ bind(&runtime_allocate);
1461 __ LoadSmiLiteral(r3, Smi::FromInt(size));
1462 __ Push(r8, r3);
1463 __ CallRuntime(Runtime::kAllocateInNewSpace, 1);
1464 __ pop(r8);
1465
1466 __ bind(&allocated);
1467 // After this, registers are used as follows:
1468 // r3: Newly allocated regexp.
1469 // r8: Materialized regexp.
1470 // r5: temp.
1471 __ CopyFields(r3, r8, r5.bit(), size / kPointerSize);
1472 context()->Plug(r3); 1435 context()->Plug(r3);
1473 } 1436 }
1474 1437
1475 1438
1476 void FullCodeGenerator::EmitAccessor(ObjectLiteralProperty* property) { 1439 void FullCodeGenerator::EmitAccessor(ObjectLiteralProperty* property) {
1477 Expression* expression = (property == NULL) ? NULL : property->value(); 1440 Expression* expression = (property == NULL) ? NULL : property->value();
1478 if (expression == NULL) { 1441 if (expression == NULL) {
1479 __ LoadRoot(r4, Heap::kNullValueRootIndex); 1442 __ LoadRoot(r4, Heap::kNullValueRootIndex);
1480 __ push(r4); 1443 __ push(r4);
1481 } else { 1444 } else {
(...skipping 3515 matching lines...) Expand 10 before | Expand all | Expand 10 after
4997 return ON_STACK_REPLACEMENT; 4960 return ON_STACK_REPLACEMENT;
4998 } 4961 }
4999 4962
5000 DCHECK(interrupt_address == 4963 DCHECK(interrupt_address ==
5001 isolate->builtins()->OsrAfterStackCheck()->entry()); 4964 isolate->builtins()->OsrAfterStackCheck()->entry());
5002 return OSR_AFTER_STACK_CHECK; 4965 return OSR_AFTER_STACK_CHECK;
5003 } 4966 }
5004 } // namespace internal 4967 } // namespace internal
5005 } // namespace v8 4968 } // namespace v8
5006 #endif // V8_TARGET_ARCH_PPC 4969 #endif // V8_TARGET_ARCH_PPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698