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

Side by Side Diff: src/crankshaft/mips/lithium-codegen-mips.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.7 1 // Copyright 2012 the V8 project authors. All rights reserved.7
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 5306 matching lines...) Expand 10 before | Expand all | Expand 10 after
5317 5317
5318 5318
5319 void LCodeGen::DoToFastProperties(LToFastProperties* instr) { 5319 void LCodeGen::DoToFastProperties(LToFastProperties* instr) {
5320 DCHECK(ToRegister(instr->value()).is(a0)); 5320 DCHECK(ToRegister(instr->value()).is(a0));
5321 DCHECK(ToRegister(instr->result()).is(v0)); 5321 DCHECK(ToRegister(instr->result()).is(v0));
5322 __ push(a0); 5322 __ push(a0);
5323 CallRuntime(Runtime::kToFastProperties, 1, instr); 5323 CallRuntime(Runtime::kToFastProperties, 1, instr);
5324 } 5324 }
5325 5325
5326 5326
5327 void LCodeGen::DoRegExpLiteral(LRegExpLiteral* instr) {
5328 DCHECK(ToRegister(instr->context()).is(cp));
5329 Label materialized;
5330 // Registers will be used as follows:
5331 // t3 = literals array.
5332 // a1 = regexp literal.
5333 // a0 = regexp literal clone.
5334 // a2 and t0-t2 are used as temporaries.
5335 int literal_offset =
5336 LiteralsArray::OffsetOfLiteralAt(instr->hydrogen()->literal_index());
5337 __ li(t3, instr->hydrogen()->literals());
5338 __ lw(a1, FieldMemOperand(t3, literal_offset));
5339 __ LoadRoot(at, Heap::kUndefinedValueRootIndex);
5340 __ Branch(&materialized, ne, a1, Operand(at));
5341
5342 // Create regexp literal using runtime function
5343 // Result will be in v0.
5344 __ li(t2, Operand(Smi::FromInt(instr->hydrogen()->literal_index())));
5345 __ li(t1, Operand(instr->hydrogen()->pattern()));
5346 __ li(t0, Operand(instr->hydrogen()->flags()));
5347 __ Push(t3, t2, t1, t0);
5348 CallRuntime(Runtime::kMaterializeRegExpLiteral, 4, instr);
5349 __ mov(a1, v0);
5350
5351 __ bind(&materialized);
5352 int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
5353 Label allocated, runtime_allocate;
5354
5355 __ Allocate(size, v0, a2, a3, &runtime_allocate, TAG_OBJECT);
5356 __ jmp(&allocated);
5357
5358 __ bind(&runtime_allocate);
5359 __ li(a0, Operand(Smi::FromInt(size)));
5360 __ Push(a1, a0);
5361 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr);
5362 __ pop(a1);
5363
5364 __ bind(&allocated);
5365 // Copy the content into the newly allocated memory.
5366 // (Unroll copy loop once for better throughput).
5367 for (int i = 0; i < size - kPointerSize; i += 2 * kPointerSize) {
5368 __ lw(a3, FieldMemOperand(a1, i));
5369 __ lw(a2, FieldMemOperand(a1, i + kPointerSize));
5370 __ sw(a3, FieldMemOperand(v0, i));
5371 __ sw(a2, FieldMemOperand(v0, i + kPointerSize));
5372 }
5373 if ((size % (2 * kPointerSize)) != 0) {
5374 __ lw(a3, FieldMemOperand(a1, size - kPointerSize));
5375 __ sw(a3, FieldMemOperand(v0, size - kPointerSize));
5376 }
5377 }
5378
5379
5380 void LCodeGen::DoTypeof(LTypeof* instr) { 5327 void LCodeGen::DoTypeof(LTypeof* instr) {
5381 DCHECK(ToRegister(instr->value()).is(a3)); 5328 DCHECK(ToRegister(instr->value()).is(a3));
5382 DCHECK(ToRegister(instr->result()).is(v0)); 5329 DCHECK(ToRegister(instr->result()).is(v0));
5383 Label end, do_call; 5330 Label end, do_call;
5384 Register value_register = ToRegister(instr->value()); 5331 Register value_register = ToRegister(instr->value());
5385 __ JumpIfNotSmi(value_register, &do_call); 5332 __ JumpIfNotSmi(value_register, &do_call);
5386 __ li(v0, Operand(isolate()->factory()->number_string())); 5333 __ li(v0, Operand(isolate()->factory()->number_string()));
5387 __ jmp(&end); 5334 __ jmp(&end);
5388 __ bind(&do_call); 5335 __ bind(&do_call);
5389 TypeofStub stub(isolate()); 5336 TypeofStub stub(isolate());
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
5819 __ Push(at, ToRegister(instr->function())); 5766 __ Push(at, ToRegister(instr->function()));
5820 CallRuntime(Runtime::kPushBlockContext, 2, instr); 5767 CallRuntime(Runtime::kPushBlockContext, 2, instr);
5821 RecordSafepoint(Safepoint::kNoLazyDeopt); 5768 RecordSafepoint(Safepoint::kNoLazyDeopt);
5822 } 5769 }
5823 5770
5824 5771
5825 #undef __ 5772 #undef __
5826 5773
5827 } // namespace internal 5774 } // namespace internal
5828 } // namespace v8 5775 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698