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