| 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 2002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2013 } | 2013 } |
| 2014 const Code& unoptimized_code = | 2014 const Code& unoptimized_code = |
| 2015 Code::Handle(zone, function.unoptimized_code()); | 2015 Code::Handle(zone, function.unoptimized_code()); |
| 2016 ASSERT(!unoptimized_code.IsNull()); | 2016 ASSERT(!unoptimized_code.IsNull()); |
| 2017 // The switch to unoptimized code may have already occurred. | 2017 // The switch to unoptimized code may have already occurred. |
| 2018 if (function.HasOptimizedCode()) { | 2018 if (function.HasOptimizedCode()) { |
| 2019 function.SwitchToUnoptimizedCode(); | 2019 function.SwitchToUnoptimizedCode(); |
| 2020 } | 2020 } |
| 2021 // Patch call site (lazy deoptimization is quite rare, patching it twice | 2021 // Patch call site (lazy deoptimization is quite rare, patching it twice |
| 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_return = optimized_code.GetLazyDeoptReturnPc(); |
| 2024 uword lazy_deopt_jump_throw = optimized_code.GetLazyDeoptThrowPc(); |
| 2024 #if !defined(TARGET_ARCH_DBC) | 2025 #if !defined(TARGET_ARCH_DBC) |
| 2025 ASSERT(lazy_deopt_jump != 0); | 2026 ASSERT(lazy_deopt_jump_return != 0); |
| 2027 ASSERT(lazy_deopt_jump_throw != 0); |
| 2026 #endif | 2028 #endif |
| 2027 const Instructions& instrs = | 2029 const Instructions& instrs = |
| 2028 Instructions::Handle(zone, optimized_code.instructions()); | 2030 Instructions::Handle(zone, optimized_code.instructions()); |
| 2029 { | 2031 { |
| 2030 WritableInstructionsScope writable(instrs.PayloadStart(), instrs.size()); | 2032 WritableInstructionsScope writable(instrs.PayloadStart(), instrs.size()); |
| 2031 CodePatcher::InsertDeoptimizationCallAt(pc, lazy_deopt_jump); | 2033 CodePatcher::InsertDeoptimizationCallAt(pc, lazy_deopt_jump_return); |
| 2032 if (FLAG_trace_patching) { | 2034 if (FLAG_trace_patching) { |
| 2033 const String& name = String::Handle(function.name()); | 2035 const String& name = String::Handle(function.name()); |
| 2034 OS::PrintErr( | 2036 OS::PrintErr( |
| 2035 "InsertDeoptimizationCallAt: 0x%" Px " to 0x%" Px " for %s\n", | 2037 "InsertDeoptimizationCallAt: 0x%" Px " to 0x%" Px " for %s\n", |
| 2036 pc, lazy_deopt_jump, name.ToCString()); | 2038 pc, lazy_deopt_jump_return, name.ToCString()); |
| 2037 } | 2039 } |
| 2038 const ExceptionHandlers& handlers = | 2040 const ExceptionHandlers& handlers = |
| 2039 ExceptionHandlers::Handle(zone, optimized_code.exception_handlers()); | 2041 ExceptionHandlers::Handle(zone, optimized_code.exception_handlers()); |
| 2040 RawExceptionHandlers::HandlerInfo info; | 2042 RawExceptionHandlers::HandlerInfo info; |
| 2041 for (intptr_t i = 0; i < handlers.num_entries(); ++i) { | 2043 for (intptr_t i = 0; i < handlers.num_entries(); ++i) { |
| 2042 handlers.GetHandlerInfo(i, &info); | 2044 handlers.GetHandlerInfo(i, &info); |
| 2043 const uword patch_pc = instrs.PayloadStart() + info.handler_pc_offset; | 2045 const uword patch_pc = instrs.PayloadStart() + info.handler_pc_offset; |
| 2044 CodePatcher::InsertDeoptimizationCallAt(patch_pc, lazy_deopt_jump); | 2046 CodePatcher::InsertDeoptimizationCallAt(patch_pc, lazy_deopt_jump_throw); |
| 2045 if (FLAG_trace_patching) { | 2047 if (FLAG_trace_patching) { |
| 2046 OS::PrintErr(" at handler 0x%" Px "\n", patch_pc); | 2048 OS::PrintErr(" at handler 0x%" Px "\n", patch_pc); |
| 2047 } | 2049 } |
| 2048 } | 2050 } |
| 2049 } | 2051 } |
| 2050 // Mark code as dead (do not GC its embedded objects). | 2052 // Mark code as dead (do not GC its embedded objects). |
| 2051 optimized_code.set_is_alive(false); | 2053 optimized_code.set_is_alive(false); |
| 2052 } | 2054 } |
| 2053 | 2055 |
| 2054 | 2056 |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2308 const intptr_t elm_size = old_data.ElementSizeInBytes(); | 2310 const intptr_t elm_size = old_data.ElementSizeInBytes(); |
| 2309 const TypedData& new_data = | 2311 const TypedData& new_data = |
| 2310 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); | 2312 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); |
| 2311 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); | 2313 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); |
| 2312 typed_data_cell.SetAt(0, new_data); | 2314 typed_data_cell.SetAt(0, new_data); |
| 2313 arguments.SetReturn(new_data); | 2315 arguments.SetReturn(new_data); |
| 2314 } | 2316 } |
| 2315 | 2317 |
| 2316 | 2318 |
| 2317 } // namespace dart | 2319 } // namespace dart |
| OLD | NEW |