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

Side by Side Diff: src/full-codegen/mips64/full-codegen-mips64.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_MIPS64 5 #if V8_TARGET_ARCH_MIPS64
6 6
7 // Note on Mips implementation: 7 // Note on Mips implementation:
8 // 8 //
9 // The result_register() for mips is the 'v0' register, which is defined 9 // The result_register() for mips is the 'v0' register, which is defined
10 // by the ABI to contain function return values. However, the first 10 // by the ABI to contain function return values. However, the first
(...skipping 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 __ CallRuntime(function_id, 2); 1452 __ CallRuntime(function_id, 2);
1453 __ bind(&done); 1453 __ bind(&done);
1454 context()->Plug(v0); 1454 context()->Plug(v0);
1455 } 1455 }
1456 } 1456 }
1457 } 1457 }
1458 1458
1459 1459
1460 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { 1460 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
1461 Comment cmnt(masm_, "[ RegExpLiteral"); 1461 Comment cmnt(masm_, "[ RegExpLiteral");
1462 Label materialized; 1462 __ ld(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1463 // Registers will be used as follows: 1463 __ li(a2, Operand(Smi::FromInt(expr->literal_index())));
1464 // a5 = materialized value (RegExp literal) 1464 __ li(a1, Operand(expr->pattern()));
1465 // a4 = JS function, literals array 1465 __ li(a0, Operand(expr->flags()));
1466 // a3 = literal index 1466 FastCloneRegExpStub stub(isolate());
1467 // a2 = RegExp pattern 1467 __ CallStub(&stub);
1468 // a1 = RegExp flags
1469 // a0 = RegExp literal clone
1470 __ ld(a0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1471 __ ld(a4, FieldMemOperand(a0, JSFunction::kLiteralsOffset));
1472 int literal_offset = LiteralsArray::OffsetOfLiteralAt(expr->literal_index());
1473 __ ld(a5, FieldMemOperand(a4, literal_offset));
1474 __ LoadRoot(at, Heap::kUndefinedValueRootIndex);
1475 __ Branch(&materialized, ne, a5, Operand(at));
1476
1477 // Create regexp literal using runtime function.
1478 // Result will be in v0.
1479 __ li(a3, Operand(Smi::FromInt(expr->literal_index())));
1480 __ li(a2, Operand(expr->pattern()));
1481 __ li(a1, Operand(expr->flags()));
1482 __ Push(a4, a3, a2, a1);
1483 __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4);
1484 __ mov(a5, v0);
1485
1486 __ bind(&materialized);
1487 int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
1488 Label allocated, runtime_allocate;
1489 __ Allocate(size, v0, a2, a3, &runtime_allocate, TAG_OBJECT);
1490 __ jmp(&allocated);
1491
1492 __ bind(&runtime_allocate);
1493 __ li(a0, Operand(Smi::FromInt(size)));
1494 __ Push(a5, a0);
1495 __ CallRuntime(Runtime::kAllocateInNewSpace, 1);
1496 __ pop(a5);
1497
1498 __ bind(&allocated);
1499
1500 // After this, registers are used as follows:
1501 // v0: Newly allocated regexp.
1502 // a5: Materialized regexp.
1503 // a2: temp.
1504 __ CopyFields(v0, a5, a2.bit(), size / kPointerSize);
1505 context()->Plug(v0); 1468 context()->Plug(v0);
1506 } 1469 }
1507 1470
1508 1471
1509 void FullCodeGenerator::EmitAccessor(ObjectLiteralProperty* property) { 1472 void FullCodeGenerator::EmitAccessor(ObjectLiteralProperty* property) {
1510 Expression* expression = (property == NULL) ? NULL : property->value(); 1473 Expression* expression = (property == NULL) ? NULL : property->value();
1511 if (expression == NULL) { 1474 if (expression == NULL) {
1512 __ LoadRoot(a1, Heap::kNullValueRootIndex); 1475 __ LoadRoot(a1, Heap::kNullValueRootIndex);
1513 __ push(a1); 1476 __ push(a1);
1514 } else { 1477 } else {
(...skipping 3505 matching lines...) Expand 10 before | Expand all | Expand 10 after
5020 reinterpret_cast<uint64_t>( 4983 reinterpret_cast<uint64_t>(
5021 isolate->builtins()->OsrAfterStackCheck()->entry())); 4984 isolate->builtins()->OsrAfterStackCheck()->entry()));
5022 return OSR_AFTER_STACK_CHECK; 4985 return OSR_AFTER_STACK_CHECK;
5023 } 4986 }
5024 4987
5025 4988
5026 } // namespace internal 4989 } // namespace internal
5027 } // namespace v8 4990 } // namespace v8
5028 4991
5029 #endif // V8_TARGET_ARCH_MIPS64 4992 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698