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 10 matching lines...) Expand all Loading... |
21 DECLARE_FLAG(bool, print_ast); | 21 DECLARE_FLAG(bool, print_ast); |
22 DECLARE_FLAG(bool, print_scopes); | 22 DECLARE_FLAG(bool, print_scopes); |
23 DECLARE_FLAG(bool, trace_functions); | 23 DECLARE_FLAG(bool, trace_functions); |
24 | 24 |
25 | 25 |
26 void DeoptimizationStub::GenerateCode(FlowGraphCompiler* compiler) { | 26 void DeoptimizationStub::GenerateCode(FlowGraphCompiler* compiler) { |
27 Assembler* assem = compiler->assembler(); | 27 Assembler* assem = compiler->assembler(); |
28 #define __ assem-> | 28 #define __ assem-> |
29 __ Comment("Deopt stub for id %d", deopt_id_); | 29 __ Comment("Deopt stub for id %d", deopt_id_); |
30 __ Bind(entry_label()); | 30 __ Bind(entry_label()); |
31 for (intptr_t i = 0; i < registers_.length(); i++) { | 31 |
32 if (registers_[i] != kNoRegister) { | 32 if (deoptimization_env_ == NULL) { |
33 __ pushq(registers_[i]); | 33 for (intptr_t i = 0; i < registers_.length(); i++) { |
| 34 if (registers_[i] != kNoRegister) { |
| 35 __ pushq(registers_[i]); |
| 36 } |
| 37 } |
| 38 } else { |
| 39 // We have a deoptimization environment, we have to tear down optimized |
| 40 // frame and recreate non-optimized one. |
| 41 __ leaq(RSP, |
| 42 Address(RBP, ParsedFunction::kFirstLocalSlotIndex * kWordSize)); |
| 43 |
| 44 const ZoneGrowableArray<Value*>& values = deoptimization_env_->values(); |
| 45 const GrowableArray<Location>* locations = deoptimization_env_->locations(); |
| 46 |
| 47 for (intptr_t i = 0; i < values.length(); i++) { |
| 48 Location loc = (*locations)[i]; |
| 49 if (loc.IsInvalid()) { |
| 50 ASSERT(values[i]->IsConstant()); |
| 51 __ PushObject(values[i]->AsConstant()->value()); |
| 52 } else { |
| 53 ASSERT(loc.IsRegister()); |
| 54 __ pushq(loc.reg()); |
| 55 } |
34 } | 56 } |
35 } | 57 } |
| 58 |
36 if (compiler->IsLeaf()) { | 59 if (compiler->IsLeaf()) { |
37 Label L; | 60 Label L; |
38 __ call(&L); | 61 __ call(&L); |
39 const intptr_t offset = assem->CodeSize(); | 62 const intptr_t offset = assem->CodeSize(); |
40 __ Bind(&L); | 63 __ Bind(&L); |
41 __ popq(RAX); | 64 __ popq(RAX); |
42 __ subq(RAX, | 65 __ subq(RAX, |
43 Immediate(offset - AssemblerMacros::kOffsetOfSavedPCfromEntrypoint)); | 66 Immediate(offset - AssemblerMacros::kOffsetOfSavedPCfromEntrypoint)); |
44 __ movq(Address(RBP, -kWordSize), RAX); | 67 __ movq(Address(RBP, -kWordSize), RAX); |
45 } | 68 } |
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1074 __ jmp(&done); | 1097 __ jmp(&done); |
1075 __ Bind(&is_smi); | 1098 __ Bind(&is_smi); |
1076 __ movq(temp, reg); | 1099 __ movq(temp, reg); |
1077 __ SmiUntag(temp); | 1100 __ SmiUntag(temp); |
1078 __ cvtsi2sd(result, temp); | 1101 __ cvtsi2sd(result, temp); |
1079 __ Bind(&done); | 1102 __ Bind(&done); |
1080 } | 1103 } |
1081 | 1104 |
1082 | 1105 |
1083 #undef __ | 1106 #undef __ |
| 1107 #define __ compiler_->assembler()-> |
| 1108 |
| 1109 |
| 1110 void ParallelMoveResolver::EmitMove(int index) { |
| 1111 Location source = moves_[index].src(); |
| 1112 Location destination = moves_[index].dest(); |
| 1113 |
| 1114 ASSERT(destination.IsRegister()); |
| 1115 if (source.IsRegister()) { |
| 1116 __ movq(destination.reg(), source.reg()); |
| 1117 } else { |
| 1118 ASSERT(source.IsConstant()); |
| 1119 __ LoadObject(destination.reg(), source.constant()); |
| 1120 } |
| 1121 moves_[index].Eliminate(); |
| 1122 } |
| 1123 |
| 1124 |
| 1125 void ParallelMoveResolver::EmitSwap(int index) { |
| 1126 Location source = moves_[index].src(); |
| 1127 Location destination = moves_[index].dest(); |
| 1128 |
| 1129 ASSERT(source.IsRegister() && destination.IsRegister()); |
| 1130 __ xchgq(destination.reg(), source.reg()); |
| 1131 |
| 1132 // The swap of source and destination has executed a move from source to |
| 1133 // destination. |
| 1134 moves_[index].Eliminate(); |
| 1135 |
| 1136 // Any unperformed (including pending) move with a source of either |
| 1137 // this move's source or destination needs to have their source |
| 1138 // changed to reflect the state of affairs after the swap. |
| 1139 for (int i = 0; i < moves_.length(); ++i) { |
| 1140 MoveOperands other_move = moves_[i]; |
| 1141 if (other_move.Blocks(source)) { |
| 1142 moves_[i].set_src(destination); |
| 1143 } else if (other_move.Blocks(destination)) { |
| 1144 moves_[i].set_src(source); |
| 1145 } |
| 1146 } |
| 1147 } |
| 1148 |
| 1149 |
| 1150 #undef __ |
1084 | 1151 |
1085 } // namespace dart | 1152 } // namespace dart |
1086 | 1153 |
1087 #endif // defined TARGET_ARCH_X64 | 1154 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |