Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(604)

Side by Side Diff: runtime/vm/simulator_dbc.cc

Issue 2039913006: DBC: Eager deoptimization and CheckSmi instruction. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/intermediate_language_dbc.cc ('k') | tests/language/vm/deopt_smi_check_vm_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 bool is_lazy = rD == 0;
1969 if (deopt_id == 0) { // Lazy deoptimization.
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 1978
1976 // Leaf runtime function DeoptimizeCopyFrame expects a Dart frame. 1979 // Preserve result of the previous call.
1977 // The code in this frame may not cause GC. 1980 // TODO(vegorov) we could have actually included result into the
1978 // DeoptimizeCopyFrame and DeoptimizeFillFrame are leaf runtime calls. 1981 // deoptimization environment because it is passed through the stack.
1979 EnterSyntheticFrame(&FP, &SP, pc - 1); 1982 // If we do then we could remove special result handling from this code.
1980 const intptr_t frame_size_in_bytes = 1983 RawObject* result = SP[0];
1981 DLRT_DeoptimizeCopyFrame(reinterpret_cast<uword>(FP),
1982 /*is_lazy_deopt=*/1);
1983 LeaveSyntheticFrame(&FP, &SP);
1984 1984
1985 SP = FP + (frame_size_in_bytes / kWordSize); 1985 // When not preserving the result, we still need to preserve SP[0] as it
1986 EnterSyntheticFrame(&FP, &SP, pc - 1); 1986 // contains some temporary expression.
1987 DLRT_DeoptimizeFillFrame(reinterpret_cast<uword>(FP)); 1987 if (!is_lazy) {
1988 SP++;
1989 }
1988 1990
1989 // We are now inside a valid frame. 1991 // Leaf runtime function DeoptimizeCopyFrame expects a Dart frame.
1990 { 1992 // The code in this frame may not cause GC.
1993 // DeoptimizeCopyFrame and DeoptimizeFillFrame are leaf runtime calls.
1994 EnterSyntheticFrame(&FP, &SP, pc - (is_lazy ? 1 : 0));
1995 const intptr_t frame_size_in_bytes =
1996 DLRT_DeoptimizeCopyFrame(reinterpret_cast<uword>(FP), is_lazy ? 1 : 0);
1997 LeaveSyntheticFrame(&FP, &SP);
1998
1999 SP = FP + (frame_size_in_bytes / kWordSize);
2000 EnterSyntheticFrame(&FP, &SP, pc - (is_lazy ? 1 : 0));
2001 DLRT_DeoptimizeFillFrame(reinterpret_cast<uword>(FP));
2002
2003 // We are now inside a valid frame.
2004 {
2005 if (is_lazy) {
1991 *++SP = result; // Preserve result (call below can cause GC). 2006 *++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 } 2007 }
1997 const intptr_t materialization_arg_count = 2008 *++SP = 0; // Space for the result: number of materialization args.
1998 Smi::Value(RAW_CAST(Smi, *SP--)); 2009 Exit(thread, FP, SP + 1, /*pc=*/0);
1999 result = *SP--; // Reload the result. It might have been relocated by GC. 2010 NativeArguments native_args(thread, 0, SP, SP);
2011 INVOKE_RUNTIME(DRT_DeoptimizeMaterialize, native_args);
2012 }
2013 const intptr_t materialization_arg_count =
2014 Smi::Value(RAW_CAST(Smi, *SP--));
2015 if (is_lazy) {
2016 // Reload the result. It might have been relocated by GC.
2017 result = *SP--;
2018 }
2000 2019
2001 // Restore caller PC. 2020 // Restore caller PC.
2002 pc = SavedCallerPC(FP); 2021 pc = SavedCallerPC(FP);
2003 2022
2004 // Check if it is a fake PC marking the entry frame. 2023 // Check if it is a fake PC marking the entry frame.
2005 ASSERT((reinterpret_cast<uword>(pc) & 2) == 0); 2024 ASSERT((reinterpret_cast<uword>(pc) & 2) == 0);
2006 2025
2007 // Restore SP, FP and PP. Push result and dispatch. 2026 // Restore SP, FP and PP. Push result and dispatch.
2008 // Note: unlike in a normal return sequence we don't need to drop 2027 // Note: unlike in a normal return sequence we don't need to drop
2009 // arguments - those are not part of the innermost deoptimization 2028 // arguments - those are not part of the innermost deoptimization
2010 // environment they were dropped by FlowGraphCompiler::RecordAfterCall. 2029 // environment they were dropped by FlowGraphCompiler::RecordAfterCall.
2011 SP = FrameArguments(FP, materialization_arg_count); 2030
2012 FP = SavedCallerFP(FP); 2031 // If the result is not preserved, the unoptimized frame ends at the
2013 pp = SimulatorHelpers::FrameCode(FP)->ptr()->object_pool_->ptr(); 2032 // next slot.
2014 *SP = result; 2033 SP = FrameArguments(FP, materialization_arg_count);
2034 FP = SavedCallerFP(FP);
2035 pp = SimulatorHelpers::FrameCode(FP)->ptr()->object_pool_->ptr();
2036 if (is_lazy) {
2037 SP[0] = result; // Put the result on the stack.
2015 } else { 2038 } else {
2016 UNIMPLEMENTED(); 2039 SP--; // No result to push.
2017 } 2040 }
2018 DISPATCH(); 2041 DISPATCH();
2019 } 2042 }
2020 2043
2021 { 2044 {
2022 BYTECODE(Trap, 0); 2045 BYTECODE(Trap, 0);
2023 UNIMPLEMENTED(); 2046 UNIMPLEMENTED();
2024 DISPATCH(); 2047 DISPATCH();
2025 } 2048 }
2026 2049
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
2122 special_[kExceptionSpecialIndex] = raw_exception; 2145 special_[kExceptionSpecialIndex] = raw_exception;
2123 special_[kStacktraceSpecialIndex] = raw_stacktrace; 2146 special_[kStacktraceSpecialIndex] = raw_stacktrace;
2124 buf->Longjmp(); 2147 buf->Longjmp();
2125 UNREACHABLE(); 2148 UNREACHABLE();
2126 } 2149 }
2127 2150
2128 } // namespace dart 2151 } // namespace dart
2129 2152
2130 2153
2131 #endif // defined TARGET_ARCH_DBC 2154 #endif // defined TARGET_ARCH_DBC
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_dbc.cc ('k') | tests/language/vm/deopt_smi_check_vm_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698