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

Side by Side Diff: src/full-codegen/ia32/full-codegen-ia32.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_IA32 5 #if V8_TARGET_ARCH_IA32
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 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 __ bind(&done); 1378 __ bind(&done);
1379 context()->Plug(eax); 1379 context()->Plug(eax);
1380 break; 1380 break;
1381 } 1381 }
1382 } 1382 }
1383 } 1383 }
1384 1384
1385 1385
1386 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { 1386 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
1387 Comment cmnt(masm_, "[ RegExpLiteral"); 1387 Comment cmnt(masm_, "[ RegExpLiteral");
1388 Label materialized;
1389 // Registers will be used as follows:
1390 // edi = JS function.
1391 // ecx = literals array.
1392 // ebx = regexp literal.
1393 // eax = regexp literal clone.
1394 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); 1388 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
1395 __ mov(ecx, FieldOperand(edi, JSFunction::kLiteralsOffset)); 1389 __ Move(eax, Immediate(Smi::FromInt(expr->literal_index())));
1396 int literal_offset = LiteralsArray::OffsetOfLiteralAt(expr->literal_index()); 1390 __ Move(ecx, Immediate(expr->pattern()));
1397 __ mov(ebx, FieldOperand(ecx, literal_offset)); 1391 __ Move(edx, Immediate(expr->flags()));
1398 __ cmp(ebx, isolate()->factory()->undefined_value()); 1392 FastCloneRegExpStub stub(isolate());
1399 __ j(not_equal, &materialized, Label::kNear); 1393 __ CallStub(&stub);
1400
1401 // Create regexp literal using runtime function
1402 // Result will be in eax.
1403 __ push(ecx);
1404 __ push(Immediate(Smi::FromInt(expr->literal_index())));
1405 __ push(Immediate(expr->pattern()));
1406 __ push(Immediate(expr->flags()));
1407 __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4);
1408 __ mov(ebx, eax);
1409
1410 __ bind(&materialized);
1411 int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
1412 Label allocated, runtime_allocate;
1413 __ Allocate(size, eax, ecx, edx, &runtime_allocate, TAG_OBJECT);
1414 __ jmp(&allocated);
1415
1416 __ bind(&runtime_allocate);
1417 __ push(ebx);
1418 __ push(Immediate(Smi::FromInt(size)));
1419 __ CallRuntime(Runtime::kAllocateInNewSpace, 1);
1420 __ pop(ebx);
1421
1422 __ bind(&allocated);
1423 // Copy the content into the newly allocated memory.
1424 // (Unroll copy loop once for better throughput).
1425 for (int i = 0; i < size - kPointerSize; i += 2 * kPointerSize) {
1426 __ mov(edx, FieldOperand(ebx, i));
1427 __ mov(ecx, FieldOperand(ebx, i + kPointerSize));
1428 __ mov(FieldOperand(eax, i), edx);
1429 __ mov(FieldOperand(eax, i + kPointerSize), ecx);
1430 }
1431 if ((size % (2 * kPointerSize)) != 0) {
1432 __ mov(edx, FieldOperand(ebx, size - kPointerSize));
1433 __ mov(FieldOperand(eax, size - kPointerSize), edx);
1434 }
1435 context()->Plug(eax); 1394 context()->Plug(eax);
1436 } 1395 }
1437 1396
1438 1397
1439 void FullCodeGenerator::EmitAccessor(ObjectLiteralProperty* property) { 1398 void FullCodeGenerator::EmitAccessor(ObjectLiteralProperty* property) {
1440 Expression* expression = (property == NULL) ? NULL : property->value(); 1399 Expression* expression = (property == NULL) ? NULL : property->value();
1441 if (expression == NULL) { 1400 if (expression == NULL) {
1442 __ push(Immediate(isolate()->factory()->null_value())); 1401 __ push(Immediate(isolate()->factory()->null_value()));
1443 } else { 1402 } else {
1444 VisitForStackValue(expression); 1403 VisitForStackValue(expression);
(...skipping 3467 matching lines...) Expand 10 before | Expand all | Expand 10 after
4912 Assembler::target_address_at(call_target_address, 4871 Assembler::target_address_at(call_target_address,
4913 unoptimized_code)); 4872 unoptimized_code));
4914 return OSR_AFTER_STACK_CHECK; 4873 return OSR_AFTER_STACK_CHECK;
4915 } 4874 }
4916 4875
4917 4876
4918 } // namespace internal 4877 } // namespace internal
4919 } // namespace v8 4878 } // namespace v8
4920 4879
4921 #endif // V8_TARGET_ARCH_IA32 4880 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698