Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 <setjmp.h> // NOLINT | 5 #include <setjmp.h> // NOLINT |
| 6 #include <stdlib.h> | 6 #include <stdlib.h> |
| 7 | 7 |
| 8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
| 9 #if defined(TARGET_ARCH_DBC) | 9 #if defined(TARGET_ARCH_DBC) |
| 10 | 10 |
| (...skipping 1948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1959 ASSERT(array->GetClassId() == kArrayCid); | 1959 ASSERT(array->GetClassId() == kArrayCid); |
| 1960 ASSERT(!index->IsHeapObject()); | 1960 ASSERT(!index->IsHeapObject()); |
| 1961 ASSERT(SimulatorHelpers::CheckIndex(index, array->ptr()->length_)); | 1961 ASSERT(SimulatorHelpers::CheckIndex(index, array->ptr()->length_)); |
| 1962 array->StorePointer(array->ptr()->data() + Smi::Value(index), value); | 1962 array->StorePointer(array->ptr()->data() + Smi::Value(index), value); |
| 1963 DISPATCH(); | 1963 DISPATCH(); |
| 1964 } | 1964 } |
| 1965 | 1965 |
| 1966 { | 1966 { |
| 1967 BYTECODE(Deopt, A_D); | 1967 BYTECODE(Deopt, A_D); |
| 1968 const uint16_t deopt_id = rD; | 1968 const uint16_t deopt_id = rD; |
| 1969 if (deopt_id == 0) { // Lazy deoptimization. | 1969 const bool preserve_result = (deopt_id == 0); |
| 1970 // Preserve result of the previous call. | |
| 1971 // TODO(vegorov) we could have actually included result into the | |
| 1972 // deoptimization environment because it is passed through the stack. | |
| 1973 // If we do then we could remove special result handling from this code. | |
| 1974 RawObject* result = SP[0]; | |
| 1975 | 1970 |
| 1976 // Leaf runtime function DeoptimizeCopyFrame expects a Dart frame. | 1971 // Preserve result of the previous call. |
| 1977 // The code in this frame may not cause GC. | 1972 // TODO(vegorov) we could have actually included result into the |
| 1978 // DeoptimizeCopyFrame and DeoptimizeFillFrame are leaf runtime calls. | 1973 // deoptimization environment because it is passed through the stack. |
| 1979 EnterSyntheticFrame(&FP, &SP, pc - 1); | 1974 // If we do then we could remove special result handling from this code. |
| 1980 const intptr_t frame_size_in_bytes = | 1975 RawObject* result = SP[0]; |
|
Vyacheslav Egorov (Google)
2016/06/08 11:58:53
When not preserving result (non-lazy deopt) we nee
zra
2016/06/08 17:46:30
This and the fix below made things work.
| |
| 1981 DLRT_DeoptimizeCopyFrame(reinterpret_cast<uword>(FP), | |
| 1982 /*is_lazy_deopt=*/1); | |
| 1983 LeaveSyntheticFrame(&FP, &SP); | |
| 1984 | 1976 |
| 1985 SP = FP + (frame_size_in_bytes / kWordSize); | 1977 // Leaf runtime function DeoptimizeCopyFrame expects a Dart frame. |
| 1986 EnterSyntheticFrame(&FP, &SP, pc - 1); | 1978 // The code in this frame may not cause GC. |
| 1987 DLRT_DeoptimizeFillFrame(reinterpret_cast<uword>(FP)); | 1979 // DeoptimizeCopyFrame and DeoptimizeFillFrame are leaf runtime calls. |
| 1980 EnterSyntheticFrame(&FP, &SP, pc - 1); | |
|
zra
2016/06/07 22:31:29
I'm not sure I see how the locals from the optimiz
Vyacheslav Egorov (Google)
2016/06/08 11:58:53
If you look at the disassembled optimized code obj
zra
2016/06/08 17:46:30
Thanks!
| |
| 1981 const intptr_t frame_size_in_bytes = | |
| 1982 DLRT_DeoptimizeCopyFrame(reinterpret_cast<uword>(FP), | |
| 1983 /*is_lazy_deopt=*/ (deopt_id == 0) ? 1 : 0); | |
| 1984 LeaveSyntheticFrame(&FP, &SP); | |
| 1988 | 1985 |
| 1989 // We are now inside a valid frame. | 1986 SP = FP + (frame_size_in_bytes / kWordSize); |
| 1990 { | 1987 EnterSyntheticFrame(&FP, &SP, pc - 1); |
| 1988 DLRT_DeoptimizeFillFrame(reinterpret_cast<uword>(FP)); | |
| 1989 | |
| 1990 // We are now inside a valid frame. | |
| 1991 { | |
| 1992 if (preserve_result) { | |
| 1991 *++SP = result; // Preserve result (call below can cause GC). | 1993 *++SP = result; // Preserve result (call below can cause GC). |
| 1992 *++SP = 0; // Space for the result: number of materialization args. | |
| 1993 Exit(thread, FP, SP + 1, /*pc=*/0); | |
| 1994 NativeArguments native_args(thread, 0, SP, SP); | |
| 1995 INVOKE_RUNTIME(DRT_DeoptimizeMaterialize, native_args); | |
| 1996 } | 1994 } |
| 1997 const intptr_t materialization_arg_count = | 1995 *++SP = 0; // Space for the result: number of materialization args. |
| 1998 Smi::Value(RAW_CAST(Smi, *SP--)); | 1996 Exit(thread, FP, SP + 1, /*pc=*/0); |
| 1999 result = *SP--; // Reload the result. It might have been relocated by GC. | 1997 NativeArguments native_args(thread, 0, SP, SP); |
| 1998 INVOKE_RUNTIME(DRT_DeoptimizeMaterialize, native_args); | |
| 1999 } | |
| 2000 const intptr_t materialization_arg_count = | |
| 2001 Smi::Value(RAW_CAST(Smi, *SP--)); | |
| 2002 if (preserve_result) { | |
| 2003 // Reload the result. It might have been relocated by GC. | |
| 2004 result = *SP--; | |
| 2005 } | |
| 2000 | 2006 |
| 2001 // Restore caller PC. | 2007 // Restore caller PC. |
| 2002 pc = SavedCallerPC(FP); | 2008 pc = SavedCallerPC(FP); |
| 2003 | 2009 |
| 2004 // Check if it is a fake PC marking the entry frame. | 2010 // Check if it is a fake PC marking the entry frame. |
| 2005 ASSERT((reinterpret_cast<uword>(pc) & 2) == 0); | 2011 ASSERT((reinterpret_cast<uword>(pc) & 2) == 0); |
| 2006 | 2012 |
| 2007 // Restore SP, FP and PP. Push result and dispatch. | 2013 // Restore SP, FP and PP. Push result and dispatch. |
| 2008 // Note: unlike in a normal return sequence we don't need to drop | 2014 // Note: unlike in a normal return sequence we don't need to drop |
| 2009 // arguments - those are not part of the innermost deoptimization | 2015 // arguments - those are not part of the innermost deoptimization |
| 2010 // environment they were dropped by FlowGraphCompiler::RecordAfterCall. | 2016 // environment they were dropped by FlowGraphCompiler::RecordAfterCall. |
| 2011 SP = FrameArguments(FP, materialization_arg_count); | 2017 SP = FrameArguments(FP, materialization_arg_count); |
|
Vyacheslav Egorov (Google)
2016/06/08 11:58:53
FrameArguments(FP, argc) points to the first argum
zra
2016/06/08 17:46:30
That makes sense, thanks.
| |
| 2012 FP = SavedCallerFP(FP); | 2018 FP = SavedCallerFP(FP); |
| 2013 pp = SimulatorHelpers::FrameCode(FP)->ptr()->object_pool_->ptr(); | 2019 pp = SimulatorHelpers::FrameCode(FP)->ptr()->object_pool_->ptr(); |
| 2020 if (preserve_result) { | |
| 2014 *SP = result; | 2021 *SP = result; |
| 2015 } else { | |
| 2016 UNIMPLEMENTED(); | |
| 2017 } | 2022 } |
| 2018 DISPATCH(); | 2023 DISPATCH(); |
| 2019 } | 2024 } |
| 2020 | 2025 |
| 2021 { | 2026 { |
| 2022 BYTECODE(Trap, 0); | 2027 BYTECODE(Trap, 0); |
| 2023 UNIMPLEMENTED(); | 2028 UNIMPLEMENTED(); |
| 2024 DISPATCH(); | 2029 DISPATCH(); |
| 2025 } | 2030 } |
| 2026 | 2031 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2122 special_[kExceptionSpecialIndex] = raw_exception; | 2127 special_[kExceptionSpecialIndex] = raw_exception; |
| 2123 special_[kStacktraceSpecialIndex] = raw_stacktrace; | 2128 special_[kStacktraceSpecialIndex] = raw_stacktrace; |
| 2124 buf->Longjmp(); | 2129 buf->Longjmp(); |
| 2125 UNREACHABLE(); | 2130 UNREACHABLE(); |
| 2126 } | 2131 } |
| 2127 | 2132 |
| 2128 } // namespace dart | 2133 } // namespace dart |
| 2129 | 2134 |
| 2130 | 2135 |
| 2131 #endif // defined TARGET_ARCH_DBC | 2136 #endif // defined TARGET_ARCH_DBC |
| OLD | NEW |