OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "lib/error.h" | 10 #include "lib/error.h" |
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1082 } | 1082 } |
1083 } | 1083 } |
1084 | 1084 |
1085 | 1085 |
1086 void FlowGraphCompiler::VisitDo(DoInstr* instr) { | 1086 void FlowGraphCompiler::VisitDo(DoInstr* instr) { |
1087 instr->computation()->Accept(this); | 1087 instr->computation()->Accept(this); |
1088 } | 1088 } |
1089 | 1089 |
1090 | 1090 |
1091 void FlowGraphCompiler::VisitBind(BindInstr* instr) { | 1091 void FlowGraphCompiler::VisitBind(BindInstr* instr) { |
1092 ASSERT(instr->locs() == NULL); | 1092 // Moved to intermediate_language_x64.cc. |
1093 | 1093 UNREACHABLE(); |
1094 // If instruction does not have special location requirements | |
1095 // then it returns result in register RAX. | |
1096 instr->computation()->Accept(this); | |
1097 __ pushq(RAX); | |
1098 } | 1094 } |
1099 | 1095 |
1100 | 1096 |
1101 void FlowGraphCompiler::VisitReturn(ReturnInstr* instr) { | 1097 void FlowGraphCompiler::VisitReturn(ReturnInstr* instr) { |
1102 LoadValue(RAX, instr->value()); | 1098 // Moved to intermediate_language_x64.cc. |
1103 if (!is_optimizing()) { | 1099 UNREACHABLE(); |
1104 // Count only in unoptimized code. | |
1105 // TODO(srdjan): Replace the counting code with a type feedback | |
1106 // collection and counting stub. | |
1107 const Function& function = | |
1108 Function::ZoneHandle(parsed_function_.function().raw()); | |
1109 __ LoadObject(RCX, function); | |
1110 __ incq(FieldAddress(RCX, Function::usage_counter_offset())); | |
1111 if (CodeGenerator::CanOptimize()) { | |
1112 // Do not optimize if usage count must be reported. | |
1113 __ cmpl(FieldAddress(RCX, Function::usage_counter_offset()), | |
1114 Immediate(FLAG_optimization_counter_threshold)); | |
1115 Label not_yet_hot; | |
1116 __ j(LESS_EQUAL, ¬_yet_hot, Assembler::kNearJump); | |
1117 __ pushq(RAX); // Preserve result. | |
1118 __ pushq(RCX); // Argument for runtime: function to optimize. | |
1119 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry); | |
1120 __ popq(RCX); // Remove argument. | |
1121 __ popq(RAX); // Restore result. | |
1122 __ Bind(¬_yet_hot); | |
1123 } | |
1124 } | |
1125 | |
1126 if (FLAG_trace_functions) { | |
1127 __ pushq(RAX); // Preserve result. | |
1128 const Function& function = | |
1129 Function::ZoneHandle(parsed_function_.function().raw()); | |
1130 __ LoadObject(RBX, function); | |
1131 __ pushq(RBX); | |
1132 GenerateCallRuntime(AstNode::kNoId, | |
1133 0, | |
1134 CatchClauseNode::kInvalidTryIndex, | |
1135 kTraceFunctionExitRuntimeEntry); | |
1136 __ popq(RAX); // Remove argument. | |
1137 __ popq(RAX); // Restore result. | |
1138 } | |
1139 __ LeaveFrame(); | |
1140 __ ret(); | |
1141 | |
1142 // Generate 8 bytes of NOPs so that the debugger can patch the | |
1143 // return pattern with a call to the debug stub. | |
1144 __ nop(1); | |
1145 __ nop(1); | |
1146 __ nop(1); | |
1147 __ nop(1); | |
1148 __ nop(1); | |
1149 __ nop(1); | |
1150 __ nop(1); | |
1151 __ nop(1); | |
1152 AddCurrentDescriptor(PcDescriptors::kReturn, | |
1153 instr->cid(), | |
1154 instr->token_index(), | |
1155 CatchClauseNode::kInvalidTryIndex); // try-index. | |
1156 } | 1100 } |
1157 | 1101 |
1158 | 1102 |
1159 void FlowGraphCompiler::VisitThrow(ThrowInstr* instr) { | 1103 void FlowGraphCompiler::VisitThrow(ThrowInstr* instr) { |
1160 ASSERT(instr->exception()->IsUse()); | 1104 ASSERT(instr->exception()->IsUse()); |
1161 GenerateCallRuntime(instr->cid(), | 1105 GenerateCallRuntime(instr->cid(), |
1162 instr->token_index(), | 1106 instr->token_index(), |
1163 instr->try_index(), | 1107 instr->try_index(), |
1164 kThrowRuntimeEntry); | 1108 kThrowRuntimeEntry); |
1165 __ int3(); | 1109 __ int3(); |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1651 | 1595 |
1652 void FlowGraphCompiler::FinalizeComments(const Code& code) { | 1596 void FlowGraphCompiler::FinalizeComments(const Code& code) { |
1653 code.set_comments(assembler_->GetCodeComments()); | 1597 code.set_comments(assembler_->GetCodeComments()); |
1654 } | 1598 } |
1655 | 1599 |
1656 #undef __ | 1600 #undef __ |
1657 | 1601 |
1658 } // namespace dart | 1602 } // namespace dart |
1659 | 1603 |
1660 #endif // defined TARGET_ARCH_X64 | 1604 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |