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 1811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1822 Exit(thread, FP, SP + 2, pc); | 1822 Exit(thread, FP, SP + 2, pc); |
| 1823 NativeArguments args(thread, 1, SP + 1, SP); | 1823 NativeArguments args(thread, 1, SP + 1, SP); |
| 1824 INVOKE_RUNTIME(DRT_NonBoolTypeError, args); | 1824 INVOKE_RUNTIME(DRT_NonBoolTypeError, args); |
| 1825 } | 1825 } |
| 1826 | 1826 |
| 1827 AssertBooleanOk: | 1827 AssertBooleanOk: |
| 1828 DISPATCH(); | 1828 DISPATCH(); |
| 1829 } | 1829 } |
| 1830 | 1830 |
| 1831 { | 1831 { |
| 1832 BYTECODE(CheckSmi, 0); | |
| 1833 intptr_t obj = reinterpret_cast<intptr_t>(FP[rA]); | |
| 1834 if ((obj & kSmiTagMask) == kSmiTag) { | |
| 1835 pc++; | |
| 1836 } | |
| 1837 DISPATCH(); | |
| 1838 } | |
| 1839 | |
| 1840 { | |
| 1832 BYTECODE(IfEqStrictTOS, 0); | 1841 BYTECODE(IfEqStrictTOS, 0); |
| 1833 SP -= 2; | 1842 SP -= 2; |
| 1834 if (SP[1] != SP[2]) { | 1843 if (SP[1] != SP[2]) { |
| 1835 pc++; | 1844 pc++; |
| 1836 } | 1845 } |
| 1837 DISPATCH(); | 1846 DISPATCH(); |
| 1838 } | 1847 } |
| 1839 | 1848 |
| 1840 { | 1849 { |
| 1841 BYTECODE(IfNeStrictTOS, 0); | 1850 BYTECODE(IfNeStrictTOS, 0); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1958 RawObject* value = FP[rC]; | 1967 RawObject* value = FP[rC]; |
| 1959 ASSERT(array->GetClassId() == kArrayCid); | 1968 ASSERT(array->GetClassId() == kArrayCid); |
| 1960 ASSERT(!index->IsHeapObject()); | 1969 ASSERT(!index->IsHeapObject()); |
| 1961 ASSERT(SimulatorHelpers::CheckIndex(index, array->ptr()->length_)); | 1970 ASSERT(SimulatorHelpers::CheckIndex(index, array->ptr()->length_)); |
| 1962 array->StorePointer(array->ptr()->data() + Smi::Value(index), value); | 1971 array->StorePointer(array->ptr()->data() + Smi::Value(index), value); |
| 1963 DISPATCH(); | 1972 DISPATCH(); |
| 1964 } | 1973 } |
| 1965 | 1974 |
| 1966 { | 1975 { |
| 1967 BYTECODE(Deopt, A_D); | 1976 BYTECODE(Deopt, A_D); |
| 1968 const uint16_t deopt_id = rD; | 1977 const uint16_t deopt_id = rD; |
|
Vyacheslav Egorov (Google)
2016/06/09 15:09:06
My original idea was to use this value to look up
zra
2016/06/09 16:42:23
Done.
| |
| 1969 if (deopt_id == 0) { // Lazy deoptimization. | 1978 const bool preserve_result = (deopt_id == 0); |
|
Vyacheslav Egorov (Google)
2016/06/09 15:09:06
I suggest removing preserve_result and use either
zra
2016/06/09 16:42:23
Done.
| |
| 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 | 1979 |
| 1976 // Leaf runtime function DeoptimizeCopyFrame expects a Dart frame. | 1980 // Preserve result of the previous call. |
| 1977 // The code in this frame may not cause GC. | 1981 // TODO(vegorov) we could have actually included result into the |
| 1978 // DeoptimizeCopyFrame and DeoptimizeFillFrame are leaf runtime calls. | 1982 // deoptimization environment because it is passed through the stack. |
| 1979 EnterSyntheticFrame(&FP, &SP, pc - 1); | 1983 // If we do then we could remove special result handling from this code. |
| 1980 const intptr_t frame_size_in_bytes = | 1984 RawObject* result = SP[0]; |
| 1981 DLRT_DeoptimizeCopyFrame(reinterpret_cast<uword>(FP), | |
| 1982 /*is_lazy_deopt=*/1); | |
| 1983 LeaveSyntheticFrame(&FP, &SP); | |
| 1984 | 1985 |
| 1985 SP = FP + (frame_size_in_bytes / kWordSize); | 1986 // When not preserving the result, we still need to preserve SP[0] as it |
| 1986 EnterSyntheticFrame(&FP, &SP, pc - 1); | 1987 // contains some temporary expression. |
| 1987 DLRT_DeoptimizeFillFrame(reinterpret_cast<uword>(FP)); | 1988 if (!preserve_result) { |
| 1989 SP++; | |
| 1990 } | |
| 1988 | 1991 |
| 1989 // We are now inside a valid frame. | 1992 // Leaf runtime function DeoptimizeCopyFrame expects a Dart frame. |
| 1990 { | 1993 // The code in this frame may not cause GC. |
| 1994 // DeoptimizeCopyFrame and DeoptimizeFillFrame are leaf runtime calls. | |
| 1995 EnterSyntheticFrame(&FP, &SP, pc - 1); | |
|
Vyacheslav Egorov (Google)
2016/06/09 15:09:06
I overlooked that this should say
pc - is_eager
zra
2016/06/09 16:42:23
Done.
| |
| 1996 const intptr_t frame_size_in_bytes = | |
| 1997 DLRT_DeoptimizeCopyFrame(reinterpret_cast<uword>(FP), | |
| 1998 /*is_lazy_deopt=*/ (deopt_id == 0) ? 1 : 0); | |
| 1999 LeaveSyntheticFrame(&FP, &SP); | |
| 2000 | |
| 2001 SP = FP + (frame_size_in_bytes / kWordSize); | |
| 2002 EnterSyntheticFrame(&FP, &SP, pc - 1); | |
| 2003 DLRT_DeoptimizeFillFrame(reinterpret_cast<uword>(FP)); | |
| 2004 | |
| 2005 // We are now inside a valid frame. | |
| 2006 { | |
| 2007 if (preserve_result) { | |
| 1991 *++SP = result; // Preserve result (call below can cause GC). | 2008 *++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 } | 2009 } |
| 1997 const intptr_t materialization_arg_count = | 2010 *++SP = 0; // Space for the result: number of materialization args. |
| 1998 Smi::Value(RAW_CAST(Smi, *SP--)); | 2011 Exit(thread, FP, SP + 1, /*pc=*/0); |
| 1999 result = *SP--; // Reload the result. It might have been relocated by GC. | 2012 NativeArguments native_args(thread, 0, SP, SP); |
| 2013 INVOKE_RUNTIME(DRT_DeoptimizeMaterialize, native_args); | |
| 2014 } | |
| 2015 const intptr_t materialization_arg_count = | |
| 2016 Smi::Value(RAW_CAST(Smi, *SP--)); | |
| 2017 if (preserve_result) { | |
| 2018 // Reload the result. It might have been relocated by GC. | |
| 2019 result = *SP--; | |
| 2020 } | |
| 2000 | 2021 |
| 2001 // Restore caller PC. | 2022 // Restore caller PC. |
| 2002 pc = SavedCallerPC(FP); | 2023 pc = SavedCallerPC(FP); |
| 2003 | 2024 |
| 2004 // Check if it is a fake PC marking the entry frame. | 2025 // Check if it is a fake PC marking the entry frame. |
| 2005 ASSERT((reinterpret_cast<uword>(pc) & 2) == 0); | 2026 ASSERT((reinterpret_cast<uword>(pc) & 2) == 0); |
| 2006 | 2027 |
| 2007 // Restore SP, FP and PP. Push result and dispatch. | 2028 // Restore SP, FP and PP. Push result and dispatch. |
| 2008 // Note: unlike in a normal return sequence we don't need to drop | 2029 // Note: unlike in a normal return sequence we don't need to drop |
| 2009 // arguments - those are not part of the innermost deoptimization | 2030 // arguments - those are not part of the innermost deoptimization |
| 2010 // environment they were dropped by FlowGraphCompiler::RecordAfterCall. | 2031 // environment they were dropped by FlowGraphCompiler::RecordAfterCall. |
| 2011 SP = FrameArguments(FP, materialization_arg_count); | 2032 |
| 2012 FP = SavedCallerFP(FP); | 2033 // If the result is not preserved, the unoptimized frame ends at the |
| 2013 pp = SimulatorHelpers::FrameCode(FP)->ptr()->object_pool_->ptr(); | 2034 // next slot. |
| 2035 SP = FrameArguments(FP, | |
| 2036 materialization_arg_count + (preserve_result ? 0 : 1)); | |
|
Vyacheslav Egorov (Google)
2016/06/09 15:09:06
I thought about it and it might be more readable t
zra
2016/06/09 16:42:23
Done.
| |
| 2037 FP = SavedCallerFP(FP); | |
| 2038 pp = SimulatorHelpers::FrameCode(FP)->ptr()->object_pool_->ptr(); | |
| 2039 if (preserve_result) { | |
| 2014 *SP = result; | 2040 *SP = result; |
| 2015 } else { | |
| 2016 UNIMPLEMENTED(); | |
| 2017 } | 2041 } |
| 2018 DISPATCH(); | 2042 DISPATCH(); |
| 2019 } | 2043 } |
| 2020 | 2044 |
| 2021 { | 2045 { |
| 2022 BYTECODE(Trap, 0); | 2046 BYTECODE(Trap, 0); |
| 2023 UNIMPLEMENTED(); | 2047 UNIMPLEMENTED(); |
| 2024 DISPATCH(); | 2048 DISPATCH(); |
| 2025 } | 2049 } |
| 2026 | 2050 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2122 special_[kExceptionSpecialIndex] = raw_exception; | 2146 special_[kExceptionSpecialIndex] = raw_exception; |
| 2123 special_[kStacktraceSpecialIndex] = raw_stacktrace; | 2147 special_[kStacktraceSpecialIndex] = raw_stacktrace; |
| 2124 buf->Longjmp(); | 2148 buf->Longjmp(); |
| 2125 UNREACHABLE(); | 2149 UNREACHABLE(); |
| 2126 } | 2150 } |
| 2127 | 2151 |
| 2128 } // namespace dart | 2152 } // namespace dart |
| 2129 | 2153 |
| 2130 | 2154 |
| 2131 #endif // defined TARGET_ARCH_DBC | 2155 #endif // defined TARGET_ARCH_DBC |
| OLD | NEW |