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 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 } | 1056 } |
1057 } | 1057 } |
1058 | 1058 |
1059 | 1059 |
1060 void FlowGraphCompiler::VisitDo(DoInstr* instr) { | 1060 void FlowGraphCompiler::VisitDo(DoInstr* instr) { |
1061 instr->computation()->Accept(this); | 1061 instr->computation()->Accept(this); |
1062 } | 1062 } |
1063 | 1063 |
1064 | 1064 |
1065 void FlowGraphCompiler::VisitBind(BindInstr* instr) { | 1065 void FlowGraphCompiler::VisitBind(BindInstr* instr) { |
1066 ASSERT(instr->locs() == NULL); | 1066 // Moved to intermediate_language_x64.cc. |
1067 | 1067 UNREACHABLE(); |
1068 // If instruction does not have special location requirements | |
1069 // then it returns result in register RAX. | |
1070 instr->computation()->Accept(this); | |
1071 __ pushq(RAX); | |
1072 } | 1068 } |
1073 | 1069 |
1074 | 1070 |
1075 void FlowGraphCompiler::VisitReturn(ReturnInstr* instr) { | 1071 void FlowGraphCompiler::VisitReturn(ReturnInstr* instr) { |
1076 LoadValue(RAX, instr->value()); | 1072 // Moved to intermediate_language_x64.cc. |
1077 if (!is_optimizing()) { | 1073 UNREACHABLE(); |
1078 // Count only in unoptimized code. | |
1079 // TODO(srdjan): Replace the counting code with a type feedback | |
1080 // collection and counting stub. | |
1081 const Function& function = | |
1082 Function::ZoneHandle(parsed_function_.function().raw()); | |
1083 __ LoadObject(RCX, function); | |
1084 __ incq(FieldAddress(RCX, Function::usage_counter_offset())); | |
1085 if (CodeGenerator::CanOptimize()) { | |
1086 // Do not optimize if usage count must be reported. | |
1087 __ cmpl(FieldAddress(RCX, Function::usage_counter_offset()), | |
1088 Immediate(FLAG_optimization_counter_threshold)); | |
1089 Label not_yet_hot; | |
1090 __ j(LESS_EQUAL, ¬_yet_hot, Assembler::kNearJump); | |
1091 __ pushq(RAX); // Preserve result. | |
1092 __ pushq(RCX); // Argument for runtime: function to optimize. | |
1093 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry); | |
1094 __ popq(RCX); // Remove argument. | |
1095 __ popq(RAX); // Restore result. | |
1096 __ Bind(¬_yet_hot); | |
1097 } | |
1098 } | |
1099 | |
1100 if (FLAG_trace_functions) { | |
1101 __ pushq(RAX); // Preserve result. | |
1102 const Function& function = | |
1103 Function::ZoneHandle(parsed_function_.function().raw()); | |
1104 __ LoadObject(RBX, function); | |
1105 __ pushq(RBX); | |
1106 GenerateCallRuntime(AstNode::kNoId, | |
1107 0, | |
1108 CatchClauseNode::kInvalidTryIndex, | |
1109 kTraceFunctionExitRuntimeEntry); | |
1110 __ popq(RAX); // Remove argument. | |
1111 __ popq(RAX); // Restore result. | |
1112 } | |
1113 __ LeaveFrame(); | |
1114 __ ret(); | |
1115 | |
1116 // Generate 8 bytes of NOPs so that the debugger can patch the | |
1117 // return pattern with a call to the debug stub. | |
1118 __ nop(1); | |
1119 __ nop(1); | |
1120 __ nop(1); | |
1121 __ nop(1); | |
1122 __ nop(1); | |
1123 __ nop(1); | |
1124 __ nop(1); | |
1125 __ nop(1); | |
1126 AddCurrentDescriptor(PcDescriptors::kReturn, | |
1127 instr->cid(), | |
1128 instr->token_index(), | |
1129 CatchClauseNode::kInvalidTryIndex); // try-index. | |
1130 } | 1074 } |
1131 | 1075 |
1132 | 1076 |
1133 void FlowGraphCompiler::VisitThrow(ThrowInstr* instr) { | 1077 void FlowGraphCompiler::VisitThrow(ThrowInstr* instr) { |
1134 // Moved to intermediate_language_x64.cc. | 1078 // Moved to intermediate_language_x64.cc. |
1135 UNREACHABLE(); | 1079 UNREACHABLE(); |
1136 } | 1080 } |
1137 | 1081 |
1138 | 1082 |
1139 void FlowGraphCompiler::VisitReThrow(ReThrowInstr* instr) { | 1083 void FlowGraphCompiler::VisitReThrow(ReThrowInstr* instr) { |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1602 | 1546 |
1603 void FlowGraphCompiler::FinalizeComments(const Code& code) { | 1547 void FlowGraphCompiler::FinalizeComments(const Code& code) { |
1604 code.set_comments(assembler_->GetCodeComments()); | 1548 code.set_comments(assembler_->GetCodeComments()); |
1605 } | 1549 } |
1606 | 1550 |
1607 #undef __ | 1551 #undef __ |
1608 | 1552 |
1609 } // namespace dart | 1553 } // namespace dart |
1610 | 1554 |
1611 #endif // defined TARGET_ARCH_X64 | 1555 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |