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" // Needed here to get TARGET_ARCH_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
7 | 7 |
8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
9 | 9 |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 LocationSummary* NativeCallInstr::MakeLocationSummary(Zone* zone, | 768 LocationSummary* NativeCallInstr::MakeLocationSummary(Zone* zone, |
769 bool opt) const { | 769 bool opt) const { |
770 return MakeCallSummary(zone); | 770 return MakeCallSummary(zone); |
771 } | 771 } |
772 | 772 |
773 | 773 |
774 void NativeCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 774 void NativeCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
775 SetupNative(); | 775 SetupNative(); |
776 Register result = locs()->out(0).reg(); | 776 Register result = locs()->out(0).reg(); |
777 const intptr_t argc_tag = NativeArguments::ComputeArgcTag(function()); | 777 const intptr_t argc_tag = NativeArguments::ComputeArgcTag(function()); |
778 const bool is_leaf_call = | |
779 (argc_tag & NativeArguments::AutoSetupScopeMask()) == 0; | |
780 | 778 |
781 // Push the result place holder initialized to NULL. | 779 // Push the result place holder initialized to NULL. |
782 __ PushObject(Object::null_object()); | 780 __ PushObject(Object::null_object()); |
783 // Pass a pointer to the first argument in RAX. | 781 // Pass a pointer to the first argument in RAX. |
784 if (!function().HasOptionalParameters()) { | 782 if (!function().HasOptionalParameters()) { |
785 __ leaq(RAX, Address(RBP, (kParamEndSlotFromFp + | 783 __ leaq(RAX, Address(RBP, (kParamEndSlotFromFp + |
786 function().NumParameters()) * kWordSize)); | 784 function().NumParameters()) * kWordSize)); |
787 } else { | 785 } else { |
788 __ leaq(RAX, Address(RBP, kFirstLocalSlotFromFp * kWordSize)); | 786 __ leaq(RAX, Address(RBP, kFirstLocalSlotFromFp * kWordSize)); |
789 } | 787 } |
790 __ LoadImmediate(R10, Immediate(argc_tag)); | 788 __ LoadImmediate(R10, Immediate(argc_tag)); |
791 const StubEntry* stub_entry; | 789 const StubEntry* stub_entry; |
792 if (link_lazily()) { | 790 if (link_lazily()) { |
793 stub_entry = StubCode::CallBootstrapCFunction_entry(); | 791 stub_entry = StubCode::CallBootstrapCFunction_entry(); |
794 ExternalLabel label(NativeEntry::LinkNativeCallEntry()); | 792 ExternalLabel label(NativeEntry::LinkNativeCallEntry()); |
795 __ LoadNativeEntry(RBX, &label, kPatchable); | 793 __ LoadNativeEntry(RBX, &label, kPatchable); |
796 } else { | 794 } else { |
797 stub_entry = (is_bootstrap_native() || is_leaf_call) | 795 stub_entry = (is_bootstrap_native()) ? |
798 ? StubCode::CallBootstrapCFunction_entry() | 796 StubCode::CallBootstrapCFunction_entry() : |
799 : StubCode::CallNativeCFunction_entry(); | 797 StubCode::CallNativeCFunction_entry(); |
800 const ExternalLabel label(reinterpret_cast<uword>(native_c_function())); | 798 const ExternalLabel label(reinterpret_cast<uword>(native_c_function())); |
801 __ LoadNativeEntry(RBX, &label, kNotPatchable); | 799 __ LoadNativeEntry(RBX, &label, kNotPatchable); |
802 } | 800 } |
803 compiler->GenerateCall(token_pos(), | 801 compiler->GenerateCall(token_pos(), |
804 *stub_entry, | 802 *stub_entry, |
805 RawPcDescriptors::kOther, | 803 RawPcDescriptors::kOther, |
806 locs()); | 804 locs()); |
807 __ popq(result); | 805 __ popq(result); |
808 } | 806 } |
809 | 807 |
(...skipping 5642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6452 __ Drop(1); | 6450 __ Drop(1); |
6453 __ popq(result); | 6451 __ popq(result); |
6454 } | 6452 } |
6455 | 6453 |
6456 | 6454 |
6457 } // namespace dart | 6455 } // namespace dart |
6458 | 6456 |
6459 #undef __ | 6457 #undef __ |
6460 | 6458 |
6461 #endif // defined TARGET_ARCH_X64 | 6459 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |