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/code_generator.h" | 5 #include "vm/code_generator.h" |
6 | 6 |
7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
8 #include "vm/ast.h" | 8 #include "vm/ast.h" |
9 #include "vm/code_patcher.h" | 9 #include "vm/code_patcher.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 2011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2022 // is not a performance issue). | 2022 // is not a performance issue). |
2023 uword lazy_deopt_jump = optimized_code.GetLazyDeoptPc(); | 2023 uword lazy_deopt_jump = optimized_code.GetLazyDeoptPc(); |
2024 #if !defined(TARGET_ARCH_DBC) | 2024 #if !defined(TARGET_ARCH_DBC) |
2025 ASSERT(lazy_deopt_jump != 0); | 2025 ASSERT(lazy_deopt_jump != 0); |
2026 #endif | 2026 #endif |
2027 const Instructions& instrs = | 2027 const Instructions& instrs = |
2028 Instructions::Handle(zone, optimized_code.instructions()); | 2028 Instructions::Handle(zone, optimized_code.instructions()); |
2029 { | 2029 { |
2030 WritableInstructionsScope writable(instrs.PayloadStart(), instrs.size()); | 2030 WritableInstructionsScope writable(instrs.PayloadStart(), instrs.size()); |
2031 CodePatcher::InsertDeoptimizationCallAt(pc, lazy_deopt_jump); | 2031 CodePatcher::InsertDeoptimizationCallAt(pc, lazy_deopt_jump); |
2032 } | 2032 if (FLAG_trace_patching) { |
2033 if (FLAG_trace_patching) { | 2033 const String& name = String::Handle(function.name()); |
2034 const String& name = String::Handle(function.name()); | 2034 OS::PrintErr( |
2035 OS::PrintErr("InsertDeoptimizationCallAt: %" Px " to %" Px " for %s\n", pc, | 2035 "InsertDeoptimizationCallAt: 0x%" Px " to 0x%" Px " for %s\n", |
2036 lazy_deopt_jump, name.ToCString()); | 2036 pc, lazy_deopt_jump, name.ToCString()); |
| 2037 } |
| 2038 const ExceptionHandlers& handlers = |
| 2039 ExceptionHandlers::Handle(zone, optimized_code.exception_handlers()); |
| 2040 RawExceptionHandlers::HandlerInfo info; |
| 2041 for (intptr_t i = 0; i < handlers.num_entries(); ++i) { |
| 2042 handlers.GetHandlerInfo(i, &info); |
| 2043 const uword patch_pc = instrs.PayloadStart() + info.handler_pc_offset; |
| 2044 CodePatcher::InsertDeoptimizationCallAt(patch_pc, lazy_deopt_jump); |
| 2045 if (FLAG_trace_patching) { |
| 2046 OS::PrintErr(" at handler 0x%" Px "\n", patch_pc); |
| 2047 } |
| 2048 } |
2037 } | 2049 } |
2038 // Mark code as dead (do not GC its embedded objects). | 2050 // Mark code as dead (do not GC its embedded objects). |
2039 optimized_code.set_is_alive(false); | 2051 optimized_code.set_is_alive(false); |
2040 } | 2052 } |
2041 | 2053 |
2042 | 2054 |
2043 // Currently checks only that all optimized frames have kDeoptIndex | 2055 // Currently checks only that all optimized frames have kDeoptIndex |
2044 // and unoptimized code has the kDeoptAfter. | 2056 // and unoptimized code has the kDeoptAfter. |
2045 void DeoptimizeFunctionsOnStack() { | 2057 void DeoptimizeFunctionsOnStack() { |
2046 DartFrameIterator iterator; | 2058 DartFrameIterator iterator; |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2296 const intptr_t elm_size = old_data.ElementSizeInBytes(); | 2308 const intptr_t elm_size = old_data.ElementSizeInBytes(); |
2297 const TypedData& new_data = | 2309 const TypedData& new_data = |
2298 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); | 2310 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); |
2299 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); | 2311 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); |
2300 typed_data_cell.SetAt(0, new_data); | 2312 typed_data_cell.SetAt(0, new_data); |
2301 arguments.SetReturn(new_data); | 2313 arguments.SetReturn(new_data); |
2302 } | 2314 } |
2303 | 2315 |
2304 | 2316 |
2305 } // namespace dart | 2317 } // namespace dart |
OLD | NEW |