Chromium Code Reviews| 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_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 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) { |
|
srdjan
2012/07/11 17:22:32
ASSERT in ia32 that deoptimization_env_ == NULL (s
| |
| 33 __ pushl(registers_[i]); | 33 for (intptr_t i = 0; i < registers_.length(); i++) { |
| 34 if (registers_[i] != kNoRegister) { | |
| 35 __ pushl(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 __ leal(ESP, | |
| 42 Address(EBP, 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 __ pushl(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 __ popl(EAX); | 64 __ popl(EAX); |
| 42 __ subl(EAX, | 65 __ subl(EAX, |
| 43 Immediate(offset - AssemblerMacros::kOffsetOfSavedPCfromEntrypoint)); | 66 Immediate(offset - AssemblerMacros::kOffsetOfSavedPCfromEntrypoint)); |
| 44 __ movl(Address(EBP, -kWordSize), EAX); | 67 __ movl(Address(EBP, -kWordSize), EAX); |
| 45 } | 68 } |
| (...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1070 __ jmp(&done); | 1093 __ jmp(&done); |
| 1071 __ Bind(&is_smi); | 1094 __ Bind(&is_smi); |
| 1072 __ movl(temp, reg); | 1095 __ movl(temp, reg); |
| 1073 __ SmiUntag(temp); | 1096 __ SmiUntag(temp); |
| 1074 __ cvtsi2sd(result, temp); | 1097 __ cvtsi2sd(result, temp); |
| 1075 __ Bind(&done); | 1098 __ Bind(&done); |
| 1076 } | 1099 } |
| 1077 | 1100 |
| 1078 | 1101 |
| 1079 #undef __ | 1102 #undef __ |
| 1103 #define __ compiler_->assembler()-> | |
| 1104 | |
| 1105 | |
| 1106 void ParallelMoveResolver::EmitMove(int index) { | |
| 1107 Location source = moves_[index].src(); | |
| 1108 Location destination = moves_[index].dest(); | |
| 1109 | |
| 1110 ASSERT(destination.IsRegister()); | |
| 1111 if (source.IsRegister()) { | |
| 1112 __ movl(destination.reg(), source.reg()); | |
| 1113 } else { | |
| 1114 ASSERT(source.IsConstant()); | |
| 1115 __ LoadObject(destination.reg(), source.constant()); | |
| 1116 } | |
| 1117 moves_[index].Eliminate(); | |
| 1118 } | |
| 1119 | |
| 1120 | |
| 1121 void ParallelMoveResolver::EmitSwap(int index) { | |
| 1122 Location source = moves_[index].src(); | |
| 1123 Location destination = moves_[index].dest(); | |
| 1124 | |
| 1125 ASSERT(source.IsRegister() && destination.IsRegister()); | |
| 1126 __ xchgl(destination.reg(), source.reg()); | |
| 1127 | |
| 1128 // The swap of source and destination has executed a move from source to | |
| 1129 // destination. | |
| 1130 moves_[index].Eliminate(); | |
| 1131 | |
| 1132 // Any unperformed (including pending) move with a source of either | |
| 1133 // this move's source or destination needs to have their source | |
| 1134 // changed to reflect the state of affairs after the swap. | |
| 1135 for (int i = 0; i < moves_.length(); ++i) { | |
| 1136 MoveOperands other_move = moves_[i]; | |
| 1137 if (other_move.Blocks(source)) { | |
| 1138 moves_[i].set_src(destination); | |
| 1139 } else if (other_move.Blocks(destination)) { | |
| 1140 moves_[i].set_src(source); | |
| 1141 } | |
| 1142 } | |
| 1143 } | |
| 1144 | |
| 1145 | |
| 1146 #undef __ | |
| 1080 | 1147 |
| 1081 } // namespace dart | 1148 } // namespace dart |
| 1082 | 1149 |
| 1083 #endif // defined TARGET_ARCH_IA32 | 1150 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |