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

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: Address comments 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 2040 matching lines...) Expand 10 before | Expand all | Expand 10 after
2051 BYTECODE(CheckSmi, 0); 2051 BYTECODE(CheckSmi, 0);
2052 intptr_t obj = reinterpret_cast<intptr_t>(FP[rA]); 2052 intptr_t obj = reinterpret_cast<intptr_t>(FP[rA]);
2053 if ((obj & kSmiTagMask) == kSmiTag) { 2053 if ((obj & kSmiTagMask) == kSmiTag) {
2054 pc++; 2054 pc++;
2055 } 2055 }
2056 DISPATCH(); 2056 DISPATCH();
2057 } 2057 }
2058 2058
2059 { 2059 {
2060 BYTECODE(CheckClassId, A_D); 2060 BYTECODE(CheckClassId, A_D);
2061 const RawSmi* actual_cid = 2061 const intptr_t actual_cid = SimulatorHelpers::GetClassId(FP[rA]);
2062 SimulatorHelpers::GetClassIdAsSmi(static_cast<RawObject*>(FP[rA])); 2062 const intptr_t desired_cid = rD;
2063 const RawSmi* desired_cid = RAW_CAST(Smi, LOAD_CONSTANT(rD)); 2063 pc += (actual_cid == desired_cid) ? 1 : 0;
2064 if (actual_cid == desired_cid) { 2064 DISPATCH();
2065 pc++; 2065 }
2066
2067 {
2068 BYTECODE(CheckDenseSwitch, A_D);
2069 const intptr_t raw_value = reinterpret_cast<intptr_t>(FP[rA]);
2070 const bool is_smi = ((raw_value & kSmiTagMask) == kSmiTag);
2071 const intptr_t cid_min = Bytecode::DecodeD(*pc);
2072 const intptr_t cid_mask =
2073 Smi::Value(RAW_CAST(Smi, LOAD_CONSTANT(Bytecode::DecodeD(*(pc + 1)))));
2074 if (LIKELY(!is_smi)) {
2075 const intptr_t cid_max = Utils::HighestBit(cid_mask) + cid_min;
2076 const intptr_t cid = SimulatorHelpers::GetClassId(FP[rA]);
2077 // The cid is in-bounds, and the bit is set in the mask.
2078 if ((cid >= cid_min) && (cid <= cid_max) &&
2079 ((cid_mask & (1 << (cid - cid_min))) != 0)) {
2080 pc += 3;
2081 } else {
2082 pc += 2;
2083 }
2084 } else {
2085 const bool may_be_smi = (rD == 1);
2086 pc += (may_be_smi ? 3 : 2);
2066 } 2087 }
2067 DISPATCH(); 2088 DISPATCH();
2068 } 2089 }
2090
2091 {
2092 BYTECODE(CheckCids, A_B_C);
2093 const intptr_t raw_value = reinterpret_cast<intptr_t>(FP[rA]);
2094 const bool is_smi = ((raw_value & kSmiTagMask) == kSmiTag);
2095 const bool may_be_smi = (rB == 1);
2096 const intptr_t cids_length = rC;
2097 if (LIKELY(!is_smi)) {
2098 const intptr_t cid = SimulatorHelpers::GetClassId(FP[rA]);
2099 for (intptr_t i = 0; i < cids_length; i++) {
2100 const intptr_t desired_cid = Bytecode::DecodeD(*(pc + i));
2101 if (cid == desired_cid) {
2102 pc++;
2103 break;
2104 }
2105 // The cids are sorted.
2106 if (cid < desired_cid) {
2107 break;
2108 }
2109 }
2110 pc += cids_length;
2111 } else {
2112 pc += cids_length;
2113 pc += (may_be_smi ? 1 : 0);
2114 }
2115 DISPATCH();
2116 }
2069 2117
2070 { 2118 {
2071 BYTECODE(IfEqStrictTOS, 0); 2119 BYTECODE(IfEqStrictTOS, 0);
2072 SP -= 2; 2120 SP -= 2;
2073 if (SP[1] != SP[2]) { 2121 if (SP[1] != SP[2]) {
2074 pc++; 2122 pc++;
2075 } 2123 }
2076 DISPATCH(); 2124 DISPATCH();
2077 } 2125 }
2078 2126
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2149 BYTECODE(IfNeStrictNum, A_D); 2197 BYTECODE(IfNeStrictNum, A_D);
2150 RawObject* lhs = FP[rA]; 2198 RawObject* lhs = FP[rA];
2151 RawObject* rhs = FP[rD]; 2199 RawObject* rhs = FP[rD];
2152 if (SimulatorHelpers::IsStrictEqualWithNumberCheck(lhs, rhs)) { 2200 if (SimulatorHelpers::IsStrictEqualWithNumberCheck(lhs, rhs)) {
2153 pc++; 2201 pc++;
2154 } 2202 }
2155 DISPATCH(); 2203 DISPATCH();
2156 } 2204 }
2157 2205
2158 { 2206 {
2207 BYTECODE(IfEqNull, A);
2208 if (FP[rA] != null_value) {
2209 pc++;
2210 }
2211 DISPATCH();
2212 }
2213
2214 {
2215 BYTECODE(IfNeNull, A_D);
2216 if (FP[rA] == null_value) {
2217 pc++;
2218 }
2219 DISPATCH();
2220 }
2221
2222 {
2159 BYTECODE(Jump, 0); 2223 BYTECODE(Jump, 0);
2160 const int32_t target = static_cast<int32_t>(op) >> 8; 2224 const int32_t target = static_cast<int32_t>(op) >> 8;
2161 pc += (target - 1); 2225 pc += (target - 1);
2162 DISPATCH(); 2226 DISPATCH();
2163 } 2227 }
2164 2228
2165 { 2229 {
2166 BYTECODE(LoadClassId, A_D); 2230 BYTECODE(LoadClassId, A_D);
2167 const uint16_t object_reg = rD; 2231 const uint16_t object_reg = rD;
2168 RawObject* obj = static_cast<RawObject*>(FP[object_reg]); 2232 RawObject* obj = static_cast<RawObject*>(FP[object_reg]);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2234 { 2298 {
2235 if (is_lazy) { 2299 if (is_lazy) {
2236 *++SP = result; // Preserve result (call below can cause GC). 2300 *++SP = result; // Preserve result (call below can cause GC).
2237 } 2301 }
2238 *++SP = 0; // Space for the result: number of materialization args. 2302 *++SP = 0; // Space for the result: number of materialization args.
2239 Exit(thread, FP, SP + 1, /*pc=*/0); 2303 Exit(thread, FP, SP + 1, /*pc=*/0);
2240 NativeArguments native_args(thread, 0, SP, SP); 2304 NativeArguments native_args(thread, 0, SP, SP);
2241 INVOKE_RUNTIME(DRT_DeoptimizeMaterialize, native_args); 2305 INVOKE_RUNTIME(DRT_DeoptimizeMaterialize, native_args);
2242 } 2306 }
2243 const intptr_t materialization_arg_count = 2307 const intptr_t materialization_arg_count =
2244 Smi::Value(RAW_CAST(Smi, *SP--)); 2308 Smi::Value(RAW_CAST(Smi, *SP--)) / kWordSize;
2245 if (is_lazy) { 2309 if (is_lazy) {
2246 // Reload the result. It might have been relocated by GC. 2310 // Reload the result. It might have been relocated by GC.
2247 result = *SP--; 2311 result = *SP--;
2248 } 2312 }
2249 2313
2250 // Restore caller PC. 2314 // Restore caller PC.
2251 pc = SavedCallerPC(FP); 2315 pc = SavedCallerPC(FP);
2252 2316
2253 // Check if it is a fake PC marking the entry frame. 2317 // Check if it is a fake PC marking the entry frame.
2254 ASSERT((reinterpret_cast<uword>(pc) & 2) == 0); 2318 ASSERT((reinterpret_cast<uword>(pc) & 2) == 0);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
2380 special_[kExceptionSpecialIndex] = raw_exception; 2444 special_[kExceptionSpecialIndex] = raw_exception;
2381 special_[kStacktraceSpecialIndex] = raw_stacktrace; 2445 special_[kStacktraceSpecialIndex] = raw_stacktrace;
2382 buf->Longjmp(); 2446 buf->Longjmp();
2383 UNREACHABLE(); 2447 UNREACHABLE();
2384 } 2448 }
2385 2449
2386 } // namespace dart 2450 } // namespace dart
2387 2451
2388 2452
2389 #endif // defined TARGET_ARCH_DBC 2453 #endif // defined TARGET_ARCH_DBC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698