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/deferred_objects.h" | 5 #include "vm/deferred_objects.h" |
6 | 6 |
7 #include "vm/code_patcher.h" | 7 #include "vm/code_patcher.h" |
8 #include "vm/compiler.h" | 8 #include "vm/compiler.h" |
9 #include "vm/deopt_instructions.h" | 9 #include "vm/deopt_instructions.h" |
10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 } | 154 } |
155 } | 155 } |
156 | 156 |
157 | 157 |
158 void DeferredPcMarker::Materialize(DeoptContext* deopt_context) { | 158 void DeferredPcMarker::Materialize(DeoptContext* deopt_context) { |
159 Thread* thread = deopt_context->thread(); | 159 Thread* thread = deopt_context->thread(); |
160 Zone* zone = deopt_context->zone(); | 160 Zone* zone = deopt_context->zone(); |
161 uword* dest_addr = reinterpret_cast<uword*>(slot()); | 161 uword* dest_addr = reinterpret_cast<uword*>(slot()); |
162 Function& function = Function::Handle(zone); | 162 Function& function = Function::Handle(zone); |
163 function ^= deopt_context->ObjectAt(index_); | 163 function ^= deopt_context->ObjectAt(index_); |
164 if (function.IsNull()) { | 164 ASSERT(!function.IsNull()); |
165 // Callee's PC marker is not used (pc of Deoptimize stub). Set to 0. | |
166 *dest_addr = 0; | |
167 return; | |
168 } | |
169 const Error& error = Error::Handle(zone, | 165 const Error& error = Error::Handle(zone, |
170 Compiler::EnsureUnoptimizedCode(thread, function)); | 166 Compiler::EnsureUnoptimizedCode(thread, function)); |
171 if (!error.IsNull()) { | 167 if (!error.IsNull()) { |
172 Exceptions::PropagateError(error); | 168 Exceptions::PropagateError(error); |
173 } | 169 } |
174 const Code& code = Code::Handle(zone, function.unoptimized_code()); | 170 const Code& code = Code::Handle(zone, function.unoptimized_code()); |
175 ASSERT(!code.IsNull()); | 171 ASSERT(!code.IsNull()); |
176 ASSERT(function.HasCode()); | 172 ASSERT(function.HasCode()); |
177 const intptr_t pc_marker = | 173 *reinterpret_cast<RawObject**>(dest_addr) = code.raw(); |
178 code.EntryPoint() + Assembler::EntryPointToPcMarkerOffset(); | |
179 *dest_addr = pc_marker; | |
180 | 174 |
181 if (FLAG_trace_deoptimization_verbose) { | 175 if (FLAG_trace_deoptimization_verbose) { |
182 OS::PrintErr("materializing pc marker at 0x%" Px ": %s, %s\n", | 176 OS::PrintErr("materializing pc marker at 0x%" Px ": %s, %s\n", |
183 reinterpret_cast<uword>(slot()), code.ToCString(), | 177 reinterpret_cast<uword>(slot()), code.ToCString(), |
184 function.ToCString()); | 178 function.ToCString()); |
185 } | 179 } |
186 | 180 |
187 // Increment the deoptimization counter. This effectively increments each | 181 // Increment the deoptimization counter. This effectively increments each |
188 // function occurring in the optimized frame. | 182 // function occurring in the optimized frame. |
189 function.set_deoptimization_counter(function.deoptimization_counter() + 1); | 183 function.set_deoptimization_counter(function.deoptimization_counter() + 1); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 OS::PrintErr(" null Field @ offset(%" Pd ") <- %s\n", | 329 OS::PrintErr(" null Field @ offset(%" Pd ") <- %s\n", |
336 offset.Value(), | 330 offset.Value(), |
337 value.ToCString()); | 331 value.ToCString()); |
338 } | 332 } |
339 } | 333 } |
340 } | 334 } |
341 } | 335 } |
342 } | 336 } |
343 | 337 |
344 } // namespace dart | 338 } // namespace dart |
OLD | NEW |