OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
6 #if defined(TARGET_ARCH_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/code_generator.h" | 9 #include "vm/code_generator.h" |
10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 #define __ assembler-> | 21 #define __ assembler-> |
22 | 22 |
23 namespace dart { | 23 namespace dart { |
24 | 24 |
25 DEFINE_FLAG(bool, inline_alloc, true, "Inline allocation of objects."); | 25 DEFINE_FLAG(bool, inline_alloc, true, "Inline allocation of objects."); |
26 DEFINE_FLAG(bool, use_slow_path, false, | 26 DEFINE_FLAG(bool, use_slow_path, false, |
27 "Set to true for debugging & verifying the slow paths."); | 27 "Set to true for debugging & verifying the slow paths."); |
28 DECLARE_FLAG(bool, trace_optimized_ic_calls); | 28 DECLARE_FLAG(bool, trace_optimized_ic_calls); |
29 DECLARE_FLAG(int, optimization_counter_threshold); | 29 DECLARE_FLAG(int, optimization_counter_threshold); |
30 DECLARE_FLAG(bool, support_debugger); | 30 DECLARE_FLAG(bool, support_debugger); |
31 DECLARE_FLAG(bool, lazy_dispatchers); | |
31 | 32 |
32 // Input parameters: | 33 // Input parameters: |
33 // LR : return address. | 34 // LR : return address. |
34 // SP : address of last argument in argument array. | 35 // SP : address of last argument in argument array. |
35 // SP + 4*R4 - 4 : address of first argument in argument array. | 36 // SP + 4*R4 - 4 : address of first argument in argument array. |
36 // SP + 4*R4 : address of return value. | 37 // SP + 4*R4 : address of return value. |
37 // R5 : address of the runtime function to call. | 38 // R5 : address of the runtime function to call. |
38 // R4 : number of arguments to the call. | 39 // R4 : number of arguments to the call. |
39 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { | 40 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { |
40 const intptr_t thread_offset = NativeArguments::thread_offset(); | 41 const intptr_t thread_offset = NativeArguments::thread_offset(); |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
559 __ AddImmediate(LR, -CallPattern::LengthInBytes()); | 560 __ AddImmediate(LR, -CallPattern::LengthInBytes()); |
560 GenerateDeoptimizationSequence(assembler, true); // Preserve R0. | 561 GenerateDeoptimizationSequence(assembler, true); // Preserve R0. |
561 } | 562 } |
562 | 563 |
563 | 564 |
564 void StubCode::GenerateDeoptimizeStub(Assembler* assembler) { | 565 void StubCode::GenerateDeoptimizeStub(Assembler* assembler) { |
565 GenerateDeoptimizationSequence(assembler, false); // Don't preserve R0. | 566 GenerateDeoptimizationSequence(assembler, false); // Don't preserve R0. |
566 } | 567 } |
567 | 568 |
568 | 569 |
570 static void GenerateDispatcherCode(Assembler* assembler, | |
571 Label* call_target_function) { | |
572 __ Comment("NoSuchMethodDispatch"); | |
573 // When lazily generated invocation dispatchers are disabled, the | |
574 // miss-handler may return null. | |
575 __ CompareObject(R0, Object::null_object()); | |
576 __ b(call_target_function, NE); | |
577 __ EnterStubFrame(); | |
578 // Load the receiver. | |
579 __ ldr(R2, FieldAddress(R4, ArgumentsDescriptor::count_offset())); | |
580 __ add(IP, FP, Operand(R2, LSL, 1)); // R2 is Smi. | |
581 __ ldr(R6, Address(IP, kParamEndSlotFromFp * kWordSize)); | |
582 __ PushObject(Object::null_object()); | |
583 __ Push(R6); | |
584 __ Push(R5); | |
585 __ Push(R4); | |
586 // R2: Smi-tagged arguments array length. | |
587 PushArgumentsArray(assembler); | |
588 const intptr_t kNumArgs = 4; | |
589 __ CallRuntime(kInvokeNoSuchMethodDispatcherRuntimeEntry, kNumArgs); | |
590 __ Pop(R0); | |
Florian Schneider
2015/06/17 08:01:34
I would use
__ Drop(4);
__ Pop(R0);
for smaller
rmacnak
2015/06/17 17:42:20
Done.
| |
591 __ Pop(R0); | |
592 __ Pop(R0); | |
593 __ Pop(R0); | |
594 __ Pop(R0); // Return value. | |
595 __ LeaveStubFrame(); | |
596 __ Ret(); | |
597 } | |
598 | |
599 | |
569 void StubCode::GenerateMegamorphicMissStub(Assembler* assembler) { | 600 void StubCode::GenerateMegamorphicMissStub(Assembler* assembler) { |
570 __ EnterStubFrame(); | 601 __ EnterStubFrame(); |
571 | 602 |
572 // Load the receiver. | 603 // Load the receiver. |
573 __ ldr(R2, FieldAddress(R4, ArgumentsDescriptor::count_offset())); | 604 __ ldr(R2, FieldAddress(R4, ArgumentsDescriptor::count_offset())); |
574 __ add(IP, FP, Operand(R2, LSL, 1)); // R2 is Smi. | 605 __ add(IP, FP, Operand(R2, LSL, 1)); // R2 is Smi. |
575 __ ldr(R6, Address(IP, kParamEndSlotFromFp * kWordSize)); | 606 __ ldr(R6, Address(IP, kParamEndSlotFromFp * kWordSize)); |
576 | 607 |
577 // Preserve IC data and arguments descriptor. | 608 // Preserve IC data and arguments descriptor. |
578 __ PushList((1 << R4) | (1 << R5)); | 609 __ PushList((1 << R4) | (1 << R5)); |
579 | 610 |
580 // Push space for the return value. | 611 // Push space for the return value. |
581 // Push the receiver. | 612 // Push the receiver. |
582 // Push IC data object. | 613 // Push IC data object. |
583 // Push arguments descriptor array. | 614 // Push arguments descriptor array. |
584 __ LoadImmediate(IP, reinterpret_cast<intptr_t>(Object::null())); | 615 __ LoadImmediate(IP, reinterpret_cast<intptr_t>(Object::null())); |
585 __ PushList((1 << R4) | (1 << R5) | (1 << R6) | (1 << IP)); | 616 __ PushList((1 << R4) | (1 << R5) | (1 << R6) | (1 << IP)); |
586 __ CallRuntime(kMegamorphicCacheMissHandlerRuntimeEntry, 3); | 617 __ CallRuntime(kMegamorphicCacheMissHandlerRuntimeEntry, 3); |
587 // Remove arguments. | 618 // Remove arguments. |
588 __ Drop(3); | 619 __ Drop(3); |
589 __ Pop(R0); // Get result into R0 (target function). | 620 __ Pop(R0); // Get result into R0 (target function). |
590 | 621 |
591 // Restore IC data and arguments descriptor. | 622 // Restore IC data and arguments descriptor. |
592 __ PopList((1 << R4) | (1 << R5)); | 623 __ PopList((1 << R4) | (1 << R5)); |
593 | 624 |
594 __ LeaveStubFrame(); | 625 __ LeaveStubFrame(); |
595 | 626 |
627 if (!FLAG_lazy_dispatchers) { | |
628 Label call_target_function; | |
629 GenerateDispatcherCode(assembler, &call_target_function); | |
630 __ Bind(&call_target_function); | |
631 } | |
632 | |
596 // Tail-call to target function. | 633 // Tail-call to target function. |
597 __ ldr(R2, FieldAddress(R0, Function::instructions_offset())); | 634 __ ldr(R2, FieldAddress(R0, Function::instructions_offset())); |
598 __ AddImmediate(R2, Instructions::HeaderSize() - kHeapObjectTag); | 635 __ AddImmediate(R2, Instructions::HeaderSize() - kHeapObjectTag); |
599 __ bx(R2); | 636 __ bx(R2); |
600 } | 637 } |
601 | 638 |
602 | 639 |
603 // Called for inline allocation of arrays. | 640 // Called for inline allocation of arrays. |
604 // Input parameters: | 641 // Input parameters: |
605 // LR: return address. | 642 // LR: return address. |
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1451 // Pass IC data object. | 1488 // Pass IC data object. |
1452 __ Push(R5); | 1489 __ Push(R5); |
1453 __ CallRuntime(handle_ic_miss, num_args + 1); | 1490 __ CallRuntime(handle_ic_miss, num_args + 1); |
1454 // Remove the call arguments pushed earlier, including the IC data object. | 1491 // Remove the call arguments pushed earlier, including the IC data object. |
1455 __ Drop(num_args + 1); | 1492 __ Drop(num_args + 1); |
1456 // Pop returned function object into R0. | 1493 // Pop returned function object into R0. |
1457 // Restore arguments descriptor array and IC data array. | 1494 // Restore arguments descriptor array and IC data array. |
1458 __ PopList((1 << R0) | (1 << R4) | (1 << R5)); | 1495 __ PopList((1 << R0) | (1 << R4) | (1 << R5)); |
1459 __ LeaveStubFrame(); | 1496 __ LeaveStubFrame(); |
1460 Label call_target_function; | 1497 Label call_target_function; |
1461 __ b(&call_target_function); | 1498 if (!FLAG_lazy_dispatchers) { |
1499 GenerateDispatcherCode(assembler, &call_target_function); | |
1500 } else { | |
1501 __ b(&call_target_function); | |
1502 } | |
1462 | 1503 |
1463 __ Bind(&found); | 1504 __ Bind(&found); |
1464 // R6: pointer to an IC data check group. | 1505 // R6: pointer to an IC data check group. |
1465 const intptr_t target_offset = ICData::TargetIndexFor(num_args) * kWordSize; | 1506 const intptr_t target_offset = ICData::TargetIndexFor(num_args) * kWordSize; |
1466 const intptr_t count_offset = ICData::CountIndexFor(num_args) * kWordSize; | 1507 const intptr_t count_offset = ICData::CountIndexFor(num_args) * kWordSize; |
1467 __ LoadFromOffset(kWord, R0, R6, target_offset); | 1508 __ LoadFromOffset(kWord, R0, R6, target_offset); |
1468 | 1509 |
1469 if (FLAG_optimization_counter_threshold >= 0) { | 1510 if (FLAG_optimization_counter_threshold >= 0) { |
1470 __ Comment("Update caller's counter"); | 1511 __ Comment("Update caller's counter"); |
1471 __ LoadFromOffset(kWord, R1, R6, count_offset); | 1512 __ LoadFromOffset(kWord, R1, R6, count_offset); |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2096 // Result: | 2137 // Result: |
2097 // R1: entry point. | 2138 // R1: entry point. |
2098 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { | 2139 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { |
2099 EmitMegamorphicLookup(assembler, R0, R1, R1); | 2140 EmitMegamorphicLookup(assembler, R0, R1, R1); |
2100 __ Ret(); | 2141 __ Ret(); |
2101 } | 2142 } |
2102 | 2143 |
2103 } // namespace dart | 2144 } // namespace dart |
2104 | 2145 |
2105 #endif // defined TARGET_ARCH_ARM | 2146 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |