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

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

Issue 2098573004: DBC: CheckClassInstr (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Clean up comment Created 4 years, 5 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
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 1960 matching lines...) Expand 10 before | Expand all | Expand 10 after
1971 const RawSmi* actual_cid = 1971 const RawSmi* actual_cid =
1972 SimulatorHelpers::GetClassIdAsSmi(static_cast<RawObject*>(FP[rA])); 1972 SimulatorHelpers::GetClassIdAsSmi(static_cast<RawObject*>(FP[rA]));
1973 const RawSmi* desired_cid = RAW_CAST(Smi, LOAD_CONSTANT(rD)); 1973 const RawSmi* desired_cid = RAW_CAST(Smi, LOAD_CONSTANT(rD));
1974 if (actual_cid == desired_cid) { 1974 if (actual_cid == desired_cid) {
1975 pc++; 1975 pc++;
1976 } 1976 }
1977 DISPATCH(); 1977 DISPATCH();
1978 } 1978 }
1979 1979
1980 { 1980 {
1981 BYTECODE(CheckDenseSwitch, A_D);
1982 const intptr_t raw_value = reinterpret_cast<intptr_t>(FP[rA]);
1983 const bool is_smi = ((raw_value & kSmiTagMask) == kSmiTag);
1984 const intptr_t cid_min =
1985 Smi::Value(RAW_CAST(Smi, LOAD_CONSTANT(Bytecode::DecodeD(*pc))));
1986 const intptr_t cid_mask =
1987 Smi::Value(RAW_CAST(Smi, LOAD_CONSTANT(Bytecode::DecodeD(*(pc + 1)))));
1988 if (LIKELY(!is_smi)) {
1989 const intptr_t cid_max = Utils::HighestBit(cid_mask) + cid_min;
1990 const intptr_t cid = SimulatorHelpers::GetClassId(FP[rA]);
1991 // The cid is in-bounds, and the bit is set in the mask.
1992 if ((cid >= cid_min) && (cid <= cid_max) &&
1993 ((cid_mask & (1 << (cid - cid_min))) != 0)) {
1994 pc += 3;
1995 } else {
1996 pc += 2;
1997 }
1998 } else {
1999 const bool may_be_smi = (rD == 1);
2000 pc += (may_be_smi ? 3 : 2);
2001 }
2002 DISPATCH();
2003 }
2004
2005 {
2006 BYTECODE(CheckCid, A_D);
2007 const intptr_t raw_value = reinterpret_cast<intptr_t>(FP[rA]);
2008 const bool is_smi = ((raw_value & kSmiTagMask) == kSmiTag);
2009 const bool may_be_smi = (rD == 1);
2010 if (is_smi) {
2011 pc += (may_be_smi ? 2 : 1);
2012 } else {
2013 const intptr_t cid = SimulatorHelpers::GetClassId(FP[rA]);
2014 const intptr_t desired_cid =
2015 Smi::Value(RAW_CAST(Smi, LOAD_CONSTANT(Bytecode::DecodeD(*pc))));
2016 pc += ((cid == desired_cid) ? 2 : 1);
2017 }
2018 DISPATCH();
2019 }
2020
2021 {
2022 BYTECODE(CheckCids, A_D);
2023 const intptr_t raw_value = reinterpret_cast<intptr_t>(FP[rA]);
2024 const bool is_smi = ((raw_value & kSmiTagMask) == kSmiTag);
2025 const bool may_be_smi = (rD == 1);
2026 if (is_smi) {
Vyacheslav Egorov (Google) 2016/06/29 17:11:06 Flip this conditions to match CheckDenseSwitch if
zra 2016/06/29 22:19:19 Done.
2027 pc += (may_be_smi ? 2 : 1);
2028 } else {
2029 const intptr_t cid = SimulatorHelpers::GetClassId(FP[rA]);
2030 const RawArray* cid_array =
2031 RAW_CAST(Array, LOAD_CONSTANT(Bytecode::DecodeD(*pc)));
2032 RawObject** cids = cid_array->ptr()->data();
2033 const intptr_t cids_length = Smi::Value(cid_array->ptr()->length_);
2034 for (intptr_t i = 0; i < cids_length; i++) {
2035 const intptr_t desired_cid = Smi::Value(RAW_CAST(Smi, cids[i]));
Vyacheslav Egorov (Google) 2016/06/29 18:33:10 the array of cids is sorted so you can exit the lo
zra 2016/06/29 22:19:19 Done.
2036 if (cid == desired_cid) {
2037 pc++;
2038 break;
2039 }
2040 }
2041 pc++;
2042 }
2043 DISPATCH();
2044 }
2045
2046 {
1981 BYTECODE(IfEqStrictTOS, 0); 2047 BYTECODE(IfEqStrictTOS, 0);
1982 SP -= 2; 2048 SP -= 2;
1983 if (SP[1] != SP[2]) { 2049 if (SP[1] != SP[2]) {
1984 pc++; 2050 pc++;
1985 } 2051 }
1986 DISPATCH(); 2052 DISPATCH();
1987 } 2053 }
1988 2054
1989 { 2055 {
1990 BYTECODE(IfNeStrictTOS, 0); 2056 BYTECODE(IfNeStrictTOS, 0);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2059 BYTECODE(IfNeStrictNum, A_D); 2125 BYTECODE(IfNeStrictNum, A_D);
2060 RawObject* lhs = FP[rA]; 2126 RawObject* lhs = FP[rA];
2061 RawObject* rhs = FP[rD]; 2127 RawObject* rhs = FP[rD];
2062 if (SimulatorHelpers::IsStrictEqualWithNumberCheck(lhs, rhs)) { 2128 if (SimulatorHelpers::IsStrictEqualWithNumberCheck(lhs, rhs)) {
2063 pc++; 2129 pc++;
2064 } 2130 }
2065 DISPATCH(); 2131 DISPATCH();
2066 } 2132 }
2067 2133
2068 { 2134 {
2135 BYTECODE(IfEqNull, A);
2136 if (FP[rA] != null_value) {
2137 pc++;
2138 }
2139 DISPATCH();
2140 }
2141
2142 {
2143 BYTECODE(IfNeNull, A_D);
2144 if (FP[rA] == null_value) {
2145 pc++;
2146 }
2147 DISPATCH();
2148 }
2149
2150 {
2069 BYTECODE(Jump, 0); 2151 BYTECODE(Jump, 0);
2070 const int32_t target = static_cast<int32_t>(op) >> 8; 2152 const int32_t target = static_cast<int32_t>(op) >> 8;
2071 pc += (target - 1); 2153 pc += (target - 1);
2072 DISPATCH(); 2154 DISPATCH();
2073 } 2155 }
2074 2156
2075 { 2157 {
2076 BYTECODE(LoadClassId, A_D); 2158 BYTECODE(LoadClassId, A_D);
2077 const uint16_t object_reg = rD; 2159 const uint16_t object_reg = rD;
2078 RawObject* obj = static_cast<RawObject*>(FP[object_reg]); 2160 RawObject* obj = static_cast<RawObject*>(FP[object_reg]);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2144 { 2226 {
2145 if (is_lazy) { 2227 if (is_lazy) {
2146 *++SP = result; // Preserve result (call below can cause GC). 2228 *++SP = result; // Preserve result (call below can cause GC).
2147 } 2229 }
2148 *++SP = 0; // Space for the result: number of materialization args. 2230 *++SP = 0; // Space for the result: number of materialization args.
2149 Exit(thread, FP, SP + 1, /*pc=*/0); 2231 Exit(thread, FP, SP + 1, /*pc=*/0);
2150 NativeArguments native_args(thread, 0, SP, SP); 2232 NativeArguments native_args(thread, 0, SP, SP);
2151 INVOKE_RUNTIME(DRT_DeoptimizeMaterialize, native_args); 2233 INVOKE_RUNTIME(DRT_DeoptimizeMaterialize, native_args);
2152 } 2234 }
2153 const intptr_t materialization_arg_count = 2235 const intptr_t materialization_arg_count =
2154 Smi::Value(RAW_CAST(Smi, *SP--)); 2236 Smi::Value(RAW_CAST(Smi, *SP--)) / kWordSize;
2155 if (is_lazy) { 2237 if (is_lazy) {
2156 // Reload the result. It might have been relocated by GC. 2238 // Reload the result. It might have been relocated by GC.
2157 result = *SP--; 2239 result = *SP--;
2158 } 2240 }
2159 2241
2160 // Restore caller PC. 2242 // Restore caller PC.
2161 pc = SavedCallerPC(FP); 2243 pc = SavedCallerPC(FP);
2162 2244
2163 // Check if it is a fake PC marking the entry frame. 2245 // Check if it is a fake PC marking the entry frame.
2164 ASSERT((reinterpret_cast<uword>(pc) & 2) == 0); 2246 ASSERT((reinterpret_cast<uword>(pc) & 2) == 0);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
2290 special_[kExceptionSpecialIndex] = raw_exception; 2372 special_[kExceptionSpecialIndex] = raw_exception;
2291 special_[kStacktraceSpecialIndex] = raw_stacktrace; 2373 special_[kStacktraceSpecialIndex] = raw_stacktrace;
2292 buf->Longjmp(); 2374 buf->Longjmp();
2293 UNREACHABLE(); 2375 UNREACHABLE();
2294 } 2376 }
2295 2377
2296 } // namespace dart 2378 } // namespace dart
2297 2379
2298 2380
2299 #endif // defined TARGET_ARCH_DBC 2381 #endif // defined TARGET_ARCH_DBC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698