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 |
11 #if !defined(USING_SIMULATOR) | 11 #if !defined(USING_SIMULATOR) |
12 #error "DBC is a simulated architecture" | 12 #error "DBC is a simulated architecture" |
13 #endif | 13 #endif |
14 | 14 |
15 #include "vm/simulator.h" | 15 #include "vm/simulator.h" |
16 | 16 |
17 #include "vm/assembler.h" | 17 #include "vm/assembler.h" |
18 #include "vm/compiler.h" | 18 #include "vm/compiler.h" |
19 #include "vm/constants_dbc.h" | 19 #include "vm/constants_dbc.h" |
20 #include "vm/cpu.h" | 20 #include "vm/cpu.h" |
21 #include "vm/dart_entry.h" | 21 #include "vm/dart_entry.h" |
22 #include "vm/debugger.h" | 22 #include "vm/debugger.h" |
23 #include "vm/disassembler.h" | 23 #include "vm/disassembler.h" |
24 #include "vm/flow_graph_compiler.h" | |
24 #include "vm/lockers.h" | 25 #include "vm/lockers.h" |
25 #include "vm/native_arguments.h" | 26 #include "vm/native_arguments.h" |
26 #include "vm/native_entry.h" | 27 #include "vm/native_entry.h" |
27 #include "vm/object.h" | 28 #include "vm/object.h" |
28 #include "vm/object_store.h" | 29 #include "vm/object_store.h" |
29 #include "vm/os_thread.h" | 30 #include "vm/os_thread.h" |
30 #include "vm/stack_frame.h" | 31 #include "vm/stack_frame.h" |
31 | 32 |
32 namespace dart { | 33 namespace dart { |
33 | 34 |
(...skipping 1937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1971 const RawSmi* actual_cid = | 1972 const RawSmi* actual_cid = |
1972 SimulatorHelpers::GetClassIdAsSmi(static_cast<RawObject*>(FP[rA])); | 1973 SimulatorHelpers::GetClassIdAsSmi(static_cast<RawObject*>(FP[rA])); |
1973 const RawSmi* desired_cid = RAW_CAST(Smi, LOAD_CONSTANT(rD)); | 1974 const RawSmi* desired_cid = RAW_CAST(Smi, LOAD_CONSTANT(rD)); |
1974 if (actual_cid == desired_cid) { | 1975 if (actual_cid == desired_cid) { |
1975 pc++; | 1976 pc++; |
1976 } | 1977 } |
1977 DISPATCH(); | 1978 DISPATCH(); |
1978 } | 1979 } |
1979 | 1980 |
1980 { | 1981 { |
1982 BYTECODE(CheckNull, A_D); | |
Vyacheslav Egorov (Google)
2016/06/28 13:03:10
Consider splitting this instruction into two and n
zra
2016/06/28 19:31:40
Done.
| |
1983 RawObject* obj = FP[rA]; | |
1984 if (((rD == 1) && (obj != null_value)) || | |
1985 ((rD == 0) && (obj == null_value))) { | |
1986 pc++; | |
1987 } | |
1988 DISPATCH(); | |
1989 } | |
1990 | |
1991 { | |
1992 BYTECODE(CheckDenseSwitchTOS, A_D); | |
1993 const intptr_t cid_mask = Smi::Value(RAW_CAST(Smi, *SP--)); | |
1994 const intptr_t cid_min = Smi::Value(RAW_CAST(Smi, *SP--)); | |
1995 const ICData& ic_data = | |
1996 ICData::Handle(RAW_CAST(ICData, LOAD_CONSTANT(rD))); | |
Vyacheslav Egorov (Google)
2016/06/28 13:03:10
No handle allocation in the interpreter loop! Plea
zra
2016/06/28 19:31:40
Done.
| |
1997 const intptr_t value = reinterpret_cast<intptr_t>(FP[rA]); | |
1998 const bool is_smi = ((value & kSmiTagMask) == kSmiTag); | |
1999 if (is_smi) { | |
2000 if (ic_data.GetReceiverClassIdAt(0) == kSmiCid) { | |
Vyacheslav Egorov (Google)
2016/06/28 13:03:10
this case is unlikely for dense switches. I sugges
zra
2016/06/28 19:31:40
Done.
| |
2001 pc++; | |
2002 } | |
2003 } else { | |
2004 const intptr_t cid_max = Utils::HighestBit(cid_mask) + cid_min; | |
2005 const intptr_t cid = SimulatorHelpers::GetClassId(FP[rA]); | |
2006 // The cid is in-bounds, and the bit is set in the mask. | |
2007 if ((cid >= cid_min) && (cid <= cid_max) && | |
2008 ((cid_mask & (1 << (cid - cid_min))) != 0)) { | |
2009 pc++; | |
2010 } | |
2011 } | |
2012 DISPATCH(); | |
2013 } | |
2014 | |
2015 { | |
2016 BYTECODE(CheckForCid, A_D); | |
2017 const ICData& ic_data = | |
Vyacheslav Egorov (Google)
2016/06/28 13:03:10
No Handles.
zra
2016/06/28 19:31:40
Done.
| |
2018 ICData::Handle(RAW_CAST(ICData, LOAD_CONSTANT(rD))); | |
2019 const intptr_t value = reinterpret_cast<intptr_t>(FP[rA]); | |
2020 const bool is_smi = ((value & kSmiTagMask) == kSmiTag); | |
2021 if (is_smi) { | |
2022 if (ic_data.GetReceiverClassIdAt(0) == kSmiCid) { | |
2023 pc++; | |
2024 } | |
2025 } else { | |
2026 const intptr_t cid = SimulatorHelpers::GetClassId(FP[rA]); | |
2027 GrowableArray<CidTarget> sorted_ic_data; | |
2028 FlowGraphCompiler::SortICDataByCount(ic_data, | |
Vyacheslav Egorov (Google)
2016/06/28 13:03:10
This should all be done in compile time. Sorting i
zra
2016/06/28 19:31:40
Done.
| |
2029 &sorted_ic_data, | |
2030 /* drop_smi = */ true); | |
2031 const intptr_t num_checks = sorted_ic_data.length(); | |
2032 for (intptr_t i = 0; i < num_checks; i++) { | |
2033 const intptr_t data_cid = sorted_ic_data[i].cid; | |
2034 ASSERT(cid != kSmiCid); | |
2035 if (cid == data_cid) { | |
2036 pc++; | |
2037 break; | |
2038 } | |
2039 } | |
2040 } | |
2041 DISPATCH(); | |
2042 } | |
2043 | |
2044 { | |
1981 BYTECODE(IfEqStrictTOS, 0); | 2045 BYTECODE(IfEqStrictTOS, 0); |
1982 SP -= 2; | 2046 SP -= 2; |
1983 if (SP[1] != SP[2]) { | 2047 if (SP[1] != SP[2]) { |
1984 pc++; | 2048 pc++; |
1985 } | 2049 } |
1986 DISPATCH(); | 2050 DISPATCH(); |
1987 } | 2051 } |
1988 | 2052 |
1989 { | 2053 { |
1990 BYTECODE(IfNeStrictTOS, 0); | 2054 BYTECODE(IfNeStrictTOS, 0); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2144 { | 2208 { |
2145 if (is_lazy) { | 2209 if (is_lazy) { |
2146 *++SP = result; // Preserve result (call below can cause GC). | 2210 *++SP = result; // Preserve result (call below can cause GC). |
2147 } | 2211 } |
2148 *++SP = 0; // Space for the result: number of materialization args. | 2212 *++SP = 0; // Space for the result: number of materialization args. |
2149 Exit(thread, FP, SP + 1, /*pc=*/0); | 2213 Exit(thread, FP, SP + 1, /*pc=*/0); |
2150 NativeArguments native_args(thread, 0, SP, SP); | 2214 NativeArguments native_args(thread, 0, SP, SP); |
2151 INVOKE_RUNTIME(DRT_DeoptimizeMaterialize, native_args); | 2215 INVOKE_RUNTIME(DRT_DeoptimizeMaterialize, native_args); |
2152 } | 2216 } |
2153 const intptr_t materialization_arg_count = | 2217 const intptr_t materialization_arg_count = |
2154 Smi::Value(RAW_CAST(Smi, *SP--)); | 2218 Smi::Value(RAW_CAST(Smi, *SP--)) / kWordSize; |
2155 if (is_lazy) { | 2219 if (is_lazy) { |
2156 // Reload the result. It might have been relocated by GC. | 2220 // Reload the result. It might have been relocated by GC. |
2157 result = *SP--; | 2221 result = *SP--; |
2158 } | 2222 } |
2159 | 2223 |
2160 // Restore caller PC. | 2224 // Restore caller PC. |
2161 pc = SavedCallerPC(FP); | 2225 pc = SavedCallerPC(FP); |
2162 | 2226 |
2163 // Check if it is a fake PC marking the entry frame. | 2227 // Check if it is a fake PC marking the entry frame. |
2164 ASSERT((reinterpret_cast<uword>(pc) & 2) == 0); | 2228 ASSERT((reinterpret_cast<uword>(pc) & 2) == 0); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2290 special_[kExceptionSpecialIndex] = raw_exception; | 2354 special_[kExceptionSpecialIndex] = raw_exception; |
2291 special_[kStacktraceSpecialIndex] = raw_stacktrace; | 2355 special_[kStacktraceSpecialIndex] = raw_stacktrace; |
2292 buf->Longjmp(); | 2356 buf->Longjmp(); |
2293 UNREACHABLE(); | 2357 UNREACHABLE(); |
2294 } | 2358 } |
2295 | 2359 |
2296 } // namespace dart | 2360 } // namespace dart |
2297 | 2361 |
2298 | 2362 |
2299 #endif // defined TARGET_ARCH_DBC | 2363 #endif // defined TARGET_ARCH_DBC |
OLD | NEW |