| 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_MIPS) | 6 #if defined(TARGET_ARCH_MIPS) |
| 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/compiler.h" | 10 #include "vm/compiler.h" |
| 11 #include "vm/dart_entry.h" | 11 #include "vm/dart_entry.h" |
| 12 #include "vm/flow_graph_compiler.h" | 12 #include "vm/flow_graph_compiler.h" |
| 13 #include "vm/heap.h" | 13 #include "vm/heap.h" |
| 14 #include "vm/instructions.h" | 14 #include "vm/instructions.h" |
| 15 #include "vm/object_store.h" | 15 #include "vm/object_store.h" |
| 16 #include "vm/stack_frame.h" | 16 #include "vm/stack_frame.h" |
| 17 #include "vm/stub_code.h" | 17 #include "vm/stub_code.h" |
| 18 #include "vm/tags.h" | 18 #include "vm/tags.h" |
| 19 | 19 |
| 20 #define __ assembler-> | 20 #define __ assembler-> |
| 21 | 21 |
| 22 namespace dart { | 22 namespace dart { |
| 23 | 23 |
| 24 DEFINE_FLAG(bool, inline_alloc, true, "Inline allocation of objects."); | 24 DEFINE_FLAG(bool, inline_alloc, true, "Inline allocation of objects."); |
| 25 DEFINE_FLAG(bool, use_slow_path, false, | 25 DEFINE_FLAG(bool, use_slow_path, false, |
| 26 "Set to true for debugging & verifying the slow paths."); | 26 "Set to true for debugging & verifying the slow paths."); |
| 27 DECLARE_FLAG(bool, trace_optimized_ic_calls); | 27 DECLARE_FLAG(bool, trace_optimized_ic_calls); |
| 28 DECLARE_FLAG(int, optimization_counter_threshold); | 28 DECLARE_FLAG(int, optimization_counter_threshold); |
| 29 DECLARE_FLAG(bool, support_debugger); | 29 DECLARE_FLAG(bool, support_debugger); |
| 30 DECLARE_FLAG(bool, lazy_dispatchers); |
| 30 | 31 |
| 31 // Input parameters: | 32 // Input parameters: |
| 32 // RA : return address. | 33 // RA : return address. |
| 33 // SP : address of last argument in argument array. | 34 // SP : address of last argument in argument array. |
| 34 // SP + 4*S4 - 4 : address of first argument in argument array. | 35 // SP + 4*S4 - 4 : address of first argument in argument array. |
| 35 // SP + 4*S4 : address of return value. | 36 // SP + 4*S4 : address of return value. |
| 36 // S5 : address of the runtime function to call. | 37 // S5 : address of the runtime function to call. |
| 37 // S4 : number of arguments to the call. | 38 // S4 : number of arguments to the call. |
| 38 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { | 39 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { |
| 39 const intptr_t thread_offset = NativeArguments::thread_offset(); | 40 const intptr_t thread_offset = NativeArguments::thread_offset(); |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 __ AddImmediate(RA, -CallPattern::kFixedLengthInBytes); | 618 __ AddImmediate(RA, -CallPattern::kFixedLengthInBytes); |
| 618 GenerateDeoptimizationSequence(assembler, true); // Preserve V0. | 619 GenerateDeoptimizationSequence(assembler, true); // Preserve V0. |
| 619 } | 620 } |
| 620 | 621 |
| 621 | 622 |
| 622 void StubCode::GenerateDeoptimizeStub(Assembler* assembler) { | 623 void StubCode::GenerateDeoptimizeStub(Assembler* assembler) { |
| 623 GenerateDeoptimizationSequence(assembler, false); // Don't preserve V0. | 624 GenerateDeoptimizationSequence(assembler, false); // Don't preserve V0. |
| 624 } | 625 } |
| 625 | 626 |
| 626 | 627 |
| 628 static void GenerateDispatcherCode(Assembler* assembler, |
| 629 Label* call_target_function) { |
| 630 __ Comment("NoSuchMethodDispatch"); |
| 631 // When lazily generated invocation dispatchers are disabled, the |
| 632 // miss-handler may return null. |
| 633 __ BranchNotEqual(T0, Object::null_object(), call_target_function); |
| 634 __ EnterStubFrame(); |
| 635 // Load the receiver. |
| 636 __ lw(A1, FieldAddress(S4, ArgumentsDescriptor::count_offset())); |
| 637 __ sll(TMP, A1, 1); // A1 is a Smi. |
| 638 __ addu(TMP, FP, TMP); |
| 639 __ lw(T6, Address(TMP, kParamEndSlotFromFp * kWordSize)); |
| 640 |
| 641 // Push space for the return value. |
| 642 // Push the receiver. |
| 643 // Push IC data object. |
| 644 // Push arguments descriptor array. |
| 645 // Push original arguments array. |
| 646 __ addiu(SP, SP, Immediate(-4 * kWordSize)); |
| 647 __ LoadImmediate(TMP, reinterpret_cast<intptr_t>(Object::null())); |
| 648 __ sw(TMP, Address(SP, 3 * kWordSize)); |
| 649 __ sw(T6, Address(SP, 2 * kWordSize)); |
| 650 __ sw(S5, Address(SP, 1 * kWordSize)); |
| 651 __ sw(S4, Address(SP, 0 * kWordSize)); |
| 652 // A1: Smi-tagged arguments array length. |
| 653 PushArgumentsArray(assembler); |
| 654 const intptr_t kNumArgs = 4; |
| 655 __ CallRuntime(kInvokeNoSuchMethodDispatcherRuntimeEntry, kNumArgs); |
| 656 __ lw(V0, Address(SP, 4 * kWordSize)); // Return value. |
| 657 __ addiu(SP, SP, Immediate(5 * kWordSize)); |
| 658 __ LeaveStubFrame(); |
| 659 __ Ret(); |
| 660 } |
| 661 |
| 662 |
| 627 void StubCode::GenerateMegamorphicMissStub(Assembler* assembler) { | 663 void StubCode::GenerateMegamorphicMissStub(Assembler* assembler) { |
| 628 __ EnterStubFrame(); | 664 __ EnterStubFrame(); |
| 629 | 665 |
| 630 // Load the receiver. | 666 // Load the receiver. |
| 631 __ lw(T2, FieldAddress(S4, ArgumentsDescriptor::count_offset())); | 667 __ lw(T2, FieldAddress(S4, ArgumentsDescriptor::count_offset())); |
| 632 __ sll(T2, T2, 1); // T2 is a Smi. | 668 __ sll(T2, T2, 1); // T2 is a Smi. |
| 633 __ addu(TMP, FP, T2); | 669 __ addu(TMP, FP, T2); |
| 634 __ lw(T6, Address(TMP, kParamEndSlotFromFp * kWordSize)); | 670 __ lw(T6, Address(TMP, kParamEndSlotFromFp * kWordSize)); |
| 635 | 671 |
| 636 // Preserve IC data and arguments descriptor. | 672 // Preserve IC data and arguments descriptor. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 650 | 686 |
| 651 __ CallRuntime(kMegamorphicCacheMissHandlerRuntimeEntry, 3); | 687 __ CallRuntime(kMegamorphicCacheMissHandlerRuntimeEntry, 3); |
| 652 | 688 |
| 653 __ lw(T0, Address(SP, 3 * kWordSize)); // Get result function. | 689 __ lw(T0, Address(SP, 3 * kWordSize)); // Get result function. |
| 654 __ lw(S4, Address(SP, 4 * kWordSize)); // Restore argument descriptor. | 690 __ lw(S4, Address(SP, 4 * kWordSize)); // Restore argument descriptor. |
| 655 __ lw(S5, Address(SP, 5 * kWordSize)); // Restore IC data. | 691 __ lw(S5, Address(SP, 5 * kWordSize)); // Restore IC data. |
| 656 __ addiu(SP, SP, Immediate(6 * kWordSize)); | 692 __ addiu(SP, SP, Immediate(6 * kWordSize)); |
| 657 | 693 |
| 658 __ LeaveStubFrame(); | 694 __ LeaveStubFrame(); |
| 659 | 695 |
| 696 if (!FLAG_lazy_dispatchers) { |
| 697 Label call_target_function; |
| 698 GenerateDispatcherCode(assembler, &call_target_function); |
| 699 __ Bind(&call_target_function); |
| 700 } |
| 701 |
| 660 __ lw(T2, FieldAddress(T0, Function::instructions_offset())); | 702 __ lw(T2, FieldAddress(T0, Function::instructions_offset())); |
| 661 __ AddImmediate(T2, Instructions::HeaderSize() - kHeapObjectTag); | 703 __ AddImmediate(T2, Instructions::HeaderSize() - kHeapObjectTag); |
| 662 __ jr(T2); | 704 __ jr(T2); |
| 663 } | 705 } |
| 664 | 706 |
| 665 | 707 |
| 666 // Called for inline allocation of arrays. | 708 // Called for inline allocation of arrays. |
| 667 // Input parameters: | 709 // Input parameters: |
| 668 // RA: return address. | 710 // RA: return address. |
| 669 // A1: Array length as Smi (must be preserved). | 711 // A1: Array length as Smi (must be preserved). |
| (...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1585 // Restore arguments descriptor array and IC data array. | 1627 // Restore arguments descriptor array and IC data array. |
| 1586 __ lw(T3, Address(SP, (num_slots - 3) * kWordSize)); | 1628 __ lw(T3, Address(SP, (num_slots - 3) * kWordSize)); |
| 1587 __ lw(S4, Address(SP, (num_slots - 2) * kWordSize)); | 1629 __ lw(S4, Address(SP, (num_slots - 2) * kWordSize)); |
| 1588 __ lw(S5, Address(SP, (num_slots - 1) * kWordSize)); | 1630 __ lw(S5, Address(SP, (num_slots - 1) * kWordSize)); |
| 1589 // Remove the call arguments pushed earlier, including the IC data object | 1631 // Remove the call arguments pushed earlier, including the IC data object |
| 1590 // and the arguments descriptor array. | 1632 // and the arguments descriptor array. |
| 1591 __ addiu(SP, SP, Immediate(num_slots * kWordSize)); | 1633 __ addiu(SP, SP, Immediate(num_slots * kWordSize)); |
| 1592 __ LeaveStubFrame(); | 1634 __ LeaveStubFrame(); |
| 1593 | 1635 |
| 1594 Label call_target_function; | 1636 Label call_target_function; |
| 1595 __ b(&call_target_function); | 1637 if (!FLAG_lazy_dispatchers) { |
| 1638 __ mov(T0, T3); |
| 1639 GenerateDispatcherCode(assembler, &call_target_function); |
| 1640 } else { |
| 1641 __ b(&call_target_function); |
| 1642 } |
| 1596 | 1643 |
| 1597 __ Bind(&found); | 1644 __ Bind(&found); |
| 1598 __ Comment("Update caller's counter"); | 1645 __ Comment("Update caller's counter"); |
| 1599 // T0: Pointer to an IC data check group. | 1646 // T0: Pointer to an IC data check group. |
| 1600 const intptr_t target_offset = ICData::TargetIndexFor(num_args) * kWordSize; | 1647 const intptr_t target_offset = ICData::TargetIndexFor(num_args) * kWordSize; |
| 1601 const intptr_t count_offset = ICData::CountIndexFor(num_args) * kWordSize; | 1648 const intptr_t count_offset = ICData::CountIndexFor(num_args) * kWordSize; |
| 1602 __ lw(T3, Address(T0, target_offset)); | 1649 __ lw(T3, Address(T0, target_offset)); |
| 1603 | 1650 |
| 1604 if (FLAG_optimization_counter_threshold >= 0) { | 1651 if (FLAG_optimization_counter_threshold >= 0) { |
| 1605 // Update counter. | 1652 // Update counter. |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2289 // Result: | 2336 // Result: |
| 2290 // T1: entry point. | 2337 // T1: entry point. |
| 2291 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { | 2338 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { |
| 2292 EmitMegamorphicLookup(assembler, T0, T1, T1); | 2339 EmitMegamorphicLookup(assembler, T0, T1, T1); |
| 2293 __ Ret(); | 2340 __ Ret(); |
| 2294 } | 2341 } |
| 2295 | 2342 |
| 2296 } // namespace dart | 2343 } // namespace dart |
| 2297 | 2344 |
| 2298 #endif // defined TARGET_ARCH_MIPS | 2345 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |