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

Side by Side Diff: src/crankshaft/arm/lithium-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 #include "src/crankshaft/arm/lithium-codegen-arm.h" 5 #include "src/crankshaft/arm/lithium-codegen-arm.h"
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/crankshaft/arm/lithium-gap-resolver-arm.h" 10 #include "src/crankshaft/arm/lithium-gap-resolver-arm.h"
(...skipping 5292 matching lines...) Expand 10 before | Expand all | Expand 10 after
5303 } 5303 }
5304 5304
5305 5305
5306 void LCodeGen::DoToFastProperties(LToFastProperties* instr) { 5306 void LCodeGen::DoToFastProperties(LToFastProperties* instr) {
5307 DCHECK(ToRegister(instr->value()).is(r0)); 5307 DCHECK(ToRegister(instr->value()).is(r0));
5308 __ push(r0); 5308 __ push(r0);
5309 CallRuntime(Runtime::kToFastProperties, 1, instr); 5309 CallRuntime(Runtime::kToFastProperties, 1, instr);
5310 } 5310 }
5311 5311
5312 5312
5313 void LCodeGen::DoRegExpLiteral(LRegExpLiteral* instr) {
5314 DCHECK(ToRegister(instr->context()).is(cp));
5315 Label materialized;
5316 // Registers will be used as follows:
5317 // r6 = literals array.
5318 // r1 = regexp literal.
5319 // r0 = regexp literal clone.
5320 // r2-5 are used as temporaries.
5321 int literal_offset =
5322 LiteralsArray::OffsetOfLiteralAt(instr->hydrogen()->literal_index());
5323 __ Move(r6, instr->hydrogen()->literals());
5324 __ ldr(r1, FieldMemOperand(r6, literal_offset));
5325 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex);
5326 __ cmp(r1, ip);
5327 __ b(ne, &materialized);
5328
5329 // Create regexp literal using runtime function
5330 // Result will be in r0.
5331 __ mov(r5, Operand(Smi::FromInt(instr->hydrogen()->literal_index())));
5332 __ mov(r4, Operand(instr->hydrogen()->pattern()));
5333 __ mov(r3, Operand(instr->hydrogen()->flags()));
5334 __ Push(r6, r5, r4, r3);
5335 CallRuntime(Runtime::kMaterializeRegExpLiteral, 4, instr);
5336 __ mov(r1, r0);
5337
5338 __ bind(&materialized);
5339 int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
5340 Label allocated, runtime_allocate;
5341
5342 __ Allocate(size, r0, r2, r3, &runtime_allocate, TAG_OBJECT);
5343 __ jmp(&allocated);
5344
5345 __ bind(&runtime_allocate);
5346 __ mov(r0, Operand(Smi::FromInt(size)));
5347 __ Push(r1, r0);
5348 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr);
5349 __ pop(r1);
5350
5351 __ bind(&allocated);
5352 // Copy the content into the newly allocated memory.
5353 __ CopyFields(r0, r1, double_scratch0(), size / kPointerSize);
5354 }
5355
5356
5357 void LCodeGen::DoTypeof(LTypeof* instr) { 5313 void LCodeGen::DoTypeof(LTypeof* instr) {
5358 DCHECK(ToRegister(instr->value()).is(r3)); 5314 DCHECK(ToRegister(instr->value()).is(r3));
5359 DCHECK(ToRegister(instr->result()).is(r0)); 5315 DCHECK(ToRegister(instr->result()).is(r0));
5360 Label end, do_call; 5316 Label end, do_call;
5361 Register value_register = ToRegister(instr->value()); 5317 Register value_register = ToRegister(instr->value());
5362 __ JumpIfNotSmi(value_register, &do_call); 5318 __ JumpIfNotSmi(value_register, &do_call);
5363 __ mov(r0, Operand(isolate()->factory()->number_string())); 5319 __ mov(r0, Operand(isolate()->factory()->number_string()));
5364 __ jmp(&end); 5320 __ jmp(&end);
5365 __ bind(&do_call); 5321 __ bind(&do_call);
5366 TypeofStub stub(isolate()); 5322 TypeofStub stub(isolate());
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
5763 __ push(ToRegister(instr->function())); 5719 __ push(ToRegister(instr->function()));
5764 CallRuntime(Runtime::kPushBlockContext, 2, instr); 5720 CallRuntime(Runtime::kPushBlockContext, 2, instr);
5765 RecordSafepoint(Safepoint::kNoLazyDeopt); 5721 RecordSafepoint(Safepoint::kNoLazyDeopt);
5766 } 5722 }
5767 5723
5768 5724
5769 #undef __ 5725 #undef __
5770 5726
5771 } // namespace internal 5727 } // namespace internal
5772 } // namespace v8 5728 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698