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 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1075 ASSERT(assembler()->constant_pool_allowed()); | 1075 ASSERT(assembler()->constant_pool_allowed()); |
1076 GenerateDeferredCode(); | 1076 GenerateDeferredCode(); |
1077 } | 1077 } |
1078 | 1078 |
1079 | 1079 |
1080 void FlowGraphCompiler::GenerateCall(TokenPosition token_pos, | 1080 void FlowGraphCompiler::GenerateCall(TokenPosition token_pos, |
1081 const StubEntry& stub_entry, | 1081 const StubEntry& stub_entry, |
1082 RawPcDescriptors::Kind kind, | 1082 RawPcDescriptors::Kind kind, |
1083 LocationSummary* locs) { | 1083 LocationSummary* locs) { |
1084 __ Call(stub_entry); | 1084 __ Call(stub_entry); |
1085 AddCurrentDescriptor(kind, Thread::kNoDeoptId, token_pos); | 1085 EmitCallsiteMetaData(token_pos, Thread::kNoDeoptId, kind, locs); |
1086 RecordSafepoint(locs); | |
1087 } | 1086 } |
1088 | 1087 |
1089 | 1088 |
1090 void FlowGraphCompiler::GeneratePatchableCall(TokenPosition token_pos, | 1089 void FlowGraphCompiler::GeneratePatchableCall(TokenPosition token_pos, |
1091 const StubEntry& stub_entry, | 1090 const StubEntry& stub_entry, |
1092 RawPcDescriptors::Kind kind, | 1091 RawPcDescriptors::Kind kind, |
1093 LocationSummary* locs) { | 1092 LocationSummary* locs) { |
1094 __ CallPatchable(stub_entry); | 1093 __ CallPatchable(stub_entry); |
1095 AddCurrentDescriptor(kind, Thread::kNoDeoptId, token_pos); | 1094 EmitCallsiteMetaData(token_pos, Thread::kNoDeoptId, kind, locs); |
1096 RecordSafepoint(locs); | |
1097 } | 1095 } |
1098 | 1096 |
1099 | 1097 |
1100 void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id, | 1098 void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id, |
1101 TokenPosition token_pos, | 1099 TokenPosition token_pos, |
1102 const StubEntry& stub_entry, | 1100 const StubEntry& stub_entry, |
1103 RawPcDescriptors::Kind kind, | 1101 RawPcDescriptors::Kind kind, |
1104 LocationSummary* locs) { | 1102 LocationSummary* locs) { |
1105 __ CallPatchable(stub_entry); | 1103 __ CallPatchable(stub_entry); |
1106 AddCurrentDescriptor(kind, deopt_id, token_pos); | 1104 EmitCallsiteMetaData(token_pos, deopt_id, kind, locs); |
1107 RecordSafepoint(locs); | |
1108 // Marks either the continuation point in unoptimized code or the | 1105 // Marks either the continuation point in unoptimized code or the |
1109 // deoptimization point in optimized code, after call. | 1106 // deoptimization point in optimized code, after call. |
1110 const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id); | 1107 const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id); |
1111 if (is_optimizing()) { | 1108 if (is_optimizing()) { |
1112 AddDeoptIndexAtCall(deopt_id_after); | 1109 AddDeoptIndexAtCall(deopt_id_after); |
1113 } else { | 1110 } else { |
1114 // Add deoptimization continuation point after the call and before the | 1111 // Add deoptimization continuation point after the call and before the |
1115 // arguments are removed. | 1112 // arguments are removed. |
1116 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); | 1113 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); |
1117 } | 1114 } |
1118 } | 1115 } |
1119 | 1116 |
1120 | 1117 |
1121 void FlowGraphCompiler::GenerateStaticDartCall(intptr_t deopt_id, | 1118 void FlowGraphCompiler::GenerateStaticDartCall(intptr_t deopt_id, |
1122 TokenPosition token_pos, | 1119 TokenPosition token_pos, |
1123 const StubEntry& stub_entry, | 1120 const StubEntry& stub_entry, |
1124 RawPcDescriptors::Kind kind, | 1121 RawPcDescriptors::Kind kind, |
1125 LocationSummary* locs, | 1122 LocationSummary* locs, |
1126 const Function& target) { | 1123 const Function& target) { |
1127 // Call sites to the same target can share object pool entries. These | 1124 // Call sites to the same target can share object pool entries. These |
1128 // call sites are never patched for breakpoints: the function is deoptimized | 1125 // call sites are never patched for breakpoints: the function is deoptimized |
1129 // and the unoptimized code with IC calls for static calls is patched instead. | 1126 // and the unoptimized code with IC calls for static calls is patched instead. |
1130 ASSERT(is_optimizing()); | 1127 ASSERT(is_optimizing()); |
1131 __ CallWithEquivalence(stub_entry, target); | 1128 __ CallWithEquivalence(stub_entry, target); |
1132 | 1129 |
1133 AddCurrentDescriptor(kind, deopt_id, token_pos); | 1130 EmitCallsiteMetaData(token_pos, deopt_id, kind, locs); |
1134 RecordSafepoint(locs); | |
1135 // Marks either the continuation point in unoptimized code or the | 1131 // Marks either the continuation point in unoptimized code or the |
1136 // deoptimization point in optimized code, after call. | 1132 // deoptimization point in optimized code, after call. |
1137 const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id); | 1133 const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id); |
1138 if (is_optimizing()) { | 1134 if (is_optimizing()) { |
1139 AddDeoptIndexAtCall(deopt_id_after); | 1135 AddDeoptIndexAtCall(deopt_id_after); |
1140 } else { | 1136 } else { |
1141 // Add deoptimization continuation point after the call and before the | 1137 // Add deoptimization continuation point after the call and before the |
1142 // arguments are removed. | 1138 // arguments are removed. |
1143 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); | 1139 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); |
1144 } | 1140 } |
1145 AddStaticCallTarget(target); | 1141 AddStaticCallTarget(target); |
1146 } | 1142 } |
1147 | 1143 |
1148 | 1144 |
1149 void FlowGraphCompiler::GenerateRuntimeCall(TokenPosition token_pos, | 1145 void FlowGraphCompiler::GenerateRuntimeCall(TokenPosition token_pos, |
1150 intptr_t deopt_id, | 1146 intptr_t deopt_id, |
1151 const RuntimeEntry& entry, | 1147 const RuntimeEntry& entry, |
1152 intptr_t argument_count, | 1148 intptr_t argument_count, |
1153 LocationSummary* locs) { | 1149 LocationSummary* locs) { |
1154 __ CallRuntime(entry, argument_count); | 1150 __ CallRuntime(entry, argument_count); |
1155 AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id, token_pos); | 1151 EmitCallsiteMetaData(token_pos, deopt_id, RawPcDescriptors::kOther, locs); |
1156 RecordSafepoint(locs); | |
1157 if (deopt_id != Thread::kNoDeoptId) { | 1152 if (deopt_id != Thread::kNoDeoptId) { |
1158 // Marks either the continuation point in unoptimized code or the | 1153 // Marks either the continuation point in unoptimized code or the |
1159 // deoptimization point in optimized code, after call. | 1154 // deoptimization point in optimized code, after call. |
1160 const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id); | 1155 const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id); |
1161 if (is_optimizing()) { | 1156 if (is_optimizing()) { |
1162 AddDeoptIndexAtCall(deopt_id_after); | 1157 AddDeoptIndexAtCall(deopt_id_after); |
1163 } else { | 1158 } else { |
1164 // Add deoptimization continuation point after the call and before the | 1159 // Add deoptimization continuation point after the call and before the |
1165 // arguments are removed. | 1160 // arguments are removed. |
1166 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); | 1161 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 AddCurrentDescriptor(RawPcDescriptors::kOther, Thread::kNoDeoptId, | 1280 AddCurrentDescriptor(RawPcDescriptors::kOther, Thread::kNoDeoptId, |
1286 token_pos); | 1281 token_pos); |
1287 AddDeoptIndexAtCall(deopt_id_after); | 1282 AddDeoptIndexAtCall(deopt_id_after); |
1288 } else { | 1283 } else { |
1289 AddCurrentDescriptor(RawPcDescriptors::kOther, Thread::kNoDeoptId, | 1284 AddCurrentDescriptor(RawPcDescriptors::kOther, Thread::kNoDeoptId, |
1290 token_pos); | 1285 token_pos); |
1291 // Add deoptimization continuation point after the call and before the | 1286 // Add deoptimization continuation point after the call and before the |
1292 // arguments are removed. | 1287 // arguments are removed. |
1293 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); | 1288 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); |
1294 } | 1289 } |
| 1290 EmitCatchEntryState(pending_deoptimization_env_, try_index); |
1295 __ Drop(argument_count, RCX); | 1291 __ Drop(argument_count, RCX); |
1296 } | 1292 } |
1297 | 1293 |
1298 | 1294 |
1299 void FlowGraphCompiler::EmitSwitchableInstanceCall(const ICData& ic_data, | 1295 void FlowGraphCompiler::EmitSwitchableInstanceCall(const ICData& ic_data, |
1300 intptr_t argument_count, | 1296 intptr_t argument_count, |
1301 intptr_t deopt_id, | 1297 intptr_t deopt_id, |
1302 TokenPosition token_pos, | 1298 TokenPosition token_pos, |
1303 LocationSummary* locs) { | 1299 LocationSummary* locs) { |
1304 ASSERT(ic_data.NumArgsTested() == 1); | 1300 ASSERT(ic_data.NumArgsTested() == 1); |
1305 const Code& initial_stub = | 1301 const Code& initial_stub = |
1306 Code::ZoneHandle(StubCode::ICCallThroughFunction_entry()->code()); | 1302 Code::ZoneHandle(StubCode::ICCallThroughFunction_entry()->code()); |
1307 | 1303 |
1308 __ Comment("SwitchableCall"); | 1304 __ Comment("SwitchableCall"); |
1309 __ movq(RDI, Address(RSP, (argument_count - 1) * kWordSize)); | 1305 __ movq(RDI, Address(RSP, (argument_count - 1) * kWordSize)); |
1310 __ LoadUniqueObject(CODE_REG, initial_stub); | 1306 __ LoadUniqueObject(CODE_REG, initial_stub); |
1311 __ movq(RCX, FieldAddress(CODE_REG, Code::checked_entry_point_offset())); | 1307 __ movq(RCX, FieldAddress(CODE_REG, Code::checked_entry_point_offset())); |
1312 __ LoadUniqueObject(RBX, ic_data); | 1308 __ LoadUniqueObject(RBX, ic_data); |
1313 __ call(RCX); | 1309 __ call(RCX); |
1314 | 1310 |
1315 AddCurrentDescriptor(RawPcDescriptors::kOther, Thread::kNoDeoptId, token_pos); | 1311 |
1316 RecordSafepoint(locs); | 1312 EmitCallsiteMetaData(token_pos, deopt_id, RawPcDescriptors::kOther, locs); |
1317 const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id); | 1313 const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id); |
1318 if (is_optimizing()) { | 1314 if (is_optimizing()) { |
1319 AddDeoptIndexAtCall(deopt_id_after); | 1315 AddDeoptIndexAtCall(deopt_id_after); |
1320 } else { | 1316 } else { |
1321 // Add deoptimization continuation point after the call and before the | 1317 // Add deoptimization continuation point after the call and before the |
1322 // arguments are removed. | 1318 // arguments are removed. |
1323 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); | 1319 AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); |
1324 } | 1320 } |
1325 __ Drop(argument_count, RCX); | 1321 __ Drop(argument_count, RCX); |
1326 } | 1322 } |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1772 __ movups(reg, Address(RSP, 0)); | 1768 __ movups(reg, Address(RSP, 0)); |
1773 __ AddImmediate(RSP, Immediate(kFpuRegisterSize)); | 1769 __ AddImmediate(RSP, Immediate(kFpuRegisterSize)); |
1774 } | 1770 } |
1775 | 1771 |
1776 | 1772 |
1777 #undef __ | 1773 #undef __ |
1778 | 1774 |
1779 } // namespace dart | 1775 } // namespace dart |
1780 | 1776 |
1781 #endif // defined TARGET_ARCH_X64 | 1777 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |