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

Side by Side Diff: src/crankshaft/mips64/lithium-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 #include "src/crankshaft/mips64/lithium-codegen-mips64.h" 5 #include "src/crankshaft/mips64/lithium-codegen-mips64.h"
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/crankshaft/hydrogen-osr.h" 9 #include "src/crankshaft/hydrogen-osr.h"
10 #include "src/crankshaft/mips64/lithium-gap-resolver-mips64.h" 10 #include "src/crankshaft/mips64/lithium-gap-resolver-mips64.h"
(...skipping 5491 matching lines...) Expand 10 before | Expand all | Expand 10 after
5502 5502
5503 5503
5504 void LCodeGen::DoToFastProperties(LToFastProperties* instr) { 5504 void LCodeGen::DoToFastProperties(LToFastProperties* instr) {
5505 DCHECK(ToRegister(instr->value()).is(a0)); 5505 DCHECK(ToRegister(instr->value()).is(a0));
5506 DCHECK(ToRegister(instr->result()).is(v0)); 5506 DCHECK(ToRegister(instr->result()).is(v0));
5507 __ push(a0); 5507 __ push(a0);
5508 CallRuntime(Runtime::kToFastProperties, 1, instr); 5508 CallRuntime(Runtime::kToFastProperties, 1, instr);
5509 } 5509 }
5510 5510
5511 5511
5512 void LCodeGen::DoRegExpLiteral(LRegExpLiteral* instr) {
5513 DCHECK(ToRegister(instr->context()).is(cp));
5514 Label materialized;
5515 // Registers will be used as follows:
5516 // a7 = literals array.
5517 // a1 = regexp literal.
5518 // a0 = regexp literal clone.
5519 // a2 and a4-a6 are used as temporaries.
5520 int literal_offset =
5521 LiteralsArray::OffsetOfLiteralAt(instr->hydrogen()->literal_index());
5522 __ li(a7, instr->hydrogen()->literals());
5523 __ ld(a1, FieldMemOperand(a7, literal_offset));
5524 __ LoadRoot(at, Heap::kUndefinedValueRootIndex);
5525 __ Branch(&materialized, ne, a1, Operand(at));
5526
5527 // Create regexp literal using runtime function
5528 // Result will be in v0.
5529 __ li(a6, Operand(Smi::FromInt(instr->hydrogen()->literal_index())));
5530 __ li(a5, Operand(instr->hydrogen()->pattern()));
5531 __ li(a4, Operand(instr->hydrogen()->flags()));
5532 __ Push(a7, a6, a5, a4);
5533 CallRuntime(Runtime::kMaterializeRegExpLiteral, 4, instr);
5534 __ mov(a1, v0);
5535
5536 __ bind(&materialized);
5537 int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
5538 Label allocated, runtime_allocate;
5539
5540 __ Allocate(size, v0, a2, a3, &runtime_allocate, TAG_OBJECT);
5541 __ jmp(&allocated);
5542
5543 __ bind(&runtime_allocate);
5544 __ li(a0, Operand(Smi::FromInt(size)));
5545 __ Push(a1, a0);
5546 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr);
5547 __ pop(a1);
5548
5549 __ bind(&allocated);
5550 // Copy the content into the newly allocated memory.
5551 // (Unroll copy loop once for better throughput).
5552 for (int i = 0; i < size - kPointerSize; i += 2 * kPointerSize) {
5553 __ ld(a3, FieldMemOperand(a1, i));
5554 __ ld(a2, FieldMemOperand(a1, i + kPointerSize));
5555 __ sd(a3, FieldMemOperand(v0, i));
5556 __ sd(a2, FieldMemOperand(v0, i + kPointerSize));
5557 }
5558 if ((size % (2 * kPointerSize)) != 0) {
5559 __ ld(a3, FieldMemOperand(a1, size - kPointerSize));
5560 __ sd(a3, FieldMemOperand(v0, size - kPointerSize));
5561 }
5562 }
5563
5564
5565 void LCodeGen::DoTypeof(LTypeof* instr) { 5512 void LCodeGen::DoTypeof(LTypeof* instr) {
5566 DCHECK(ToRegister(instr->value()).is(a3)); 5513 DCHECK(ToRegister(instr->value()).is(a3));
5567 DCHECK(ToRegister(instr->result()).is(v0)); 5514 DCHECK(ToRegister(instr->result()).is(v0));
5568 Label end, do_call; 5515 Label end, do_call;
5569 Register value_register = ToRegister(instr->value()); 5516 Register value_register = ToRegister(instr->value());
5570 __ JumpIfNotSmi(value_register, &do_call); 5517 __ JumpIfNotSmi(value_register, &do_call);
5571 __ li(v0, Operand(isolate()->factory()->number_string())); 5518 __ li(v0, Operand(isolate()->factory()->number_string()));
5572 __ jmp(&end); 5519 __ jmp(&end);
5573 __ bind(&do_call); 5520 __ bind(&do_call);
5574 TypeofStub stub(isolate()); 5521 TypeofStub stub(isolate());
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
6004 __ Push(at, ToRegister(instr->function())); 5951 __ Push(at, ToRegister(instr->function()));
6005 CallRuntime(Runtime::kPushBlockContext, 2, instr); 5952 CallRuntime(Runtime::kPushBlockContext, 2, instr);
6006 RecordSafepoint(Safepoint::kNoLazyDeopt); 5953 RecordSafepoint(Safepoint::kNoLazyDeopt);
6007 } 5954 }
6008 5955
6009 5956
6010 #undef __ 5957 #undef __
6011 5958
6012 } // namespace internal 5959 } // namespace internal
6013 } // namespace v8 5960 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698