| 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/flow_graph_compiler.h" | 8 #include "vm/flow_graph_compiler.h" |
| 9 | 9 |
| 10 #include "vm/ast_printer.h" | 10 #include "vm/ast_printer.h" |
| (...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 979 Register new_pp = kNoRegister; | 979 Register new_pp = kNoRegister; |
| 980 Register new_pc = kNoRegister; | 980 Register new_pc = kNoRegister; |
| 981 if (CanOptimizeFunction() && | 981 if (CanOptimizeFunction() && |
| 982 function.IsOptimizable() && | 982 function.IsOptimizable() && |
| 983 (!is_optimizing() || may_reoptimize())) { | 983 (!is_optimizing() || may_reoptimize())) { |
| 984 StubCode* stub_code = isolate()->stub_code(); | 984 StubCode* stub_code = isolate()->stub_code(); |
| 985 const Register function_reg = RDI; | 985 const Register function_reg = RDI; |
| 986 new_pp = R13; | 986 new_pp = R13; |
| 987 new_pc = R12; | 987 new_pc = R12; |
| 988 | 988 |
| 989 Label next; | 989 __ SetupPP(new_pp, new_pc); |
| 990 __ nop(4); // Need a fixed size sequence on frame entry. | |
| 991 __ call(&next); | |
| 992 __ Bind(&next); | |
| 993 | |
| 994 const intptr_t object_pool_pc_dist = | |
| 995 Instructions::HeaderSize() - Instructions::object_pool_offset() + | |
| 996 __ CodeSize(); | |
| 997 const intptr_t offset = | |
| 998 Assembler::EntryPointToPcMarkerOffset() - __ CodeSize(); | |
| 999 __ popq(new_pc); | |
| 1000 if (offset != 0) { | |
| 1001 __ addq(new_pc, Immediate(offset)); | |
| 1002 } | |
| 1003 | |
| 1004 // Load callee's pool pointer. | |
| 1005 __ movq(new_pp, Address(new_pc, -object_pool_pc_dist - offset)); | |
| 1006 | 990 |
| 1007 // Load function object using the callee's pool pointer. | 991 // Load function object using the callee's pool pointer. |
| 1008 __ LoadObject(function_reg, function, new_pp); | 992 __ LoadObject(function_reg, function, new_pp); |
| 1009 | 993 |
| 1010 // Patch point is after the eventually inlined function object. | 994 // Patch point is after the eventually inlined function object. |
| 1011 entry_patch_pc_offset_ = assembler()->CodeSize(); | 995 entry_patch_pc_offset_ = assembler()->CodeSize(); |
| 1012 | 996 |
| 1013 // Reoptimization of an optimized function is triggered by counting in | 997 // Reoptimization of an optimized function is triggered by counting in |
| 1014 // IC stubs, but not at the entry of the function. | 998 // IC stubs, but not at the entry of the function. |
| 1015 if (!is_optimizing()) { | 999 if (!is_optimizing()) { |
| 1016 __ incl(FieldAddress(function_reg, Function::usage_counter_offset())); | 1000 __ incl(FieldAddress(function_reg, Function::usage_counter_offset())); |
| 1017 } | 1001 } |
| 1018 __ cmpl( | 1002 __ cmpl( |
| 1019 FieldAddress(function_reg, Function::usage_counter_offset()), | 1003 FieldAddress(function_reg, Function::usage_counter_offset()), |
| 1020 Immediate(GetOptimizationThreshold())); | 1004 Immediate(GetOptimizationThreshold())); |
| 1021 ASSERT(function_reg == RDI); | 1005 ASSERT(function_reg == RDI); |
| 1022 __ J(GREATER_EQUAL, &stub_code->OptimizeFunctionLabel(), R13); | 1006 __ J(GREATER_EQUAL, &stub_code->OptimizeFunctionLabel(), R13); |
| 1023 } else if (!flow_graph().IsCompiledForOsr()) { | 1007 } else if (!flow_graph().IsCompiledForOsr()) { |
| 1024 // We have to load the PP here too because a load of an external label | 1008 // We have to load the PP here too because a load of an external label |
| 1025 // may be patched at the AddCurrentDescriptor below. | 1009 // may be patched at the AddCurrentDescriptor below. |
| 1026 new_pp = R13; | 1010 new_pp = R13; |
| 1027 new_pc = R12; | 1011 new_pc = R12; |
| 1028 | 1012 |
| 1029 Label next; | 1013 __ SetupPP(new_pp, new_pc); |
| 1030 __ nop(4); // Need a fixed size sequence on frame entry. | |
| 1031 __ call(&next); | |
| 1032 __ Bind(&next); | |
| 1033 | |
| 1034 const intptr_t object_pool_pc_dist = | |
| 1035 Instructions::HeaderSize() - Instructions::object_pool_offset() + | |
| 1036 __ CodeSize(); | |
| 1037 const intptr_t offset = | |
| 1038 Assembler::EntryPointToPcMarkerOffset() - __ CodeSize(); | |
| 1039 __ popq(new_pc); | |
| 1040 if (offset != 0) { | |
| 1041 __ addq(new_pc, Immediate(offset)); | |
| 1042 } | |
| 1043 | |
| 1044 // Load callee's pool pointer. | |
| 1045 __ movq(new_pp, Address(new_pc, -object_pool_pc_dist - offset)); | |
| 1046 | 1014 |
| 1047 entry_patch_pc_offset_ = assembler()->CodeSize(); | 1015 entry_patch_pc_offset_ = assembler()->CodeSize(); |
| 1048 } | 1016 } |
| 1049 __ Comment("Enter frame"); | 1017 __ Comment("Enter frame"); |
| 1050 if (flow_graph().IsCompiledForOsr()) { | 1018 if (flow_graph().IsCompiledForOsr()) { |
| 1051 intptr_t extra_slots = StackSize() | 1019 intptr_t extra_slots = StackSize() |
| 1052 - flow_graph().num_stack_locals() | 1020 - flow_graph().num_stack_locals() |
| 1053 - flow_graph().num_copied_params(); | 1021 - flow_graph().num_copied_params(); |
| 1054 ASSERT(extra_slots >= 0); | 1022 ASSERT(extra_slots >= 0); |
| 1055 __ EnterOsrFrame(extra_slots * kWordSize, new_pp, new_pc); | 1023 __ EnterOsrFrame(extra_slots * kWordSize, new_pp, new_pc); |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1724 __ movups(reg, Address(RSP, 0)); | 1692 __ movups(reg, Address(RSP, 0)); |
| 1725 __ AddImmediate(RSP, Immediate(kFpuRegisterSize), PP); | 1693 __ AddImmediate(RSP, Immediate(kFpuRegisterSize), PP); |
| 1726 } | 1694 } |
| 1727 | 1695 |
| 1728 | 1696 |
| 1729 #undef __ | 1697 #undef __ |
| 1730 | 1698 |
| 1731 } // namespace dart | 1699 } // namespace dart |
| 1732 | 1700 |
| 1733 #endif // defined TARGET_ARCH_X64 | 1701 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |