OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "vm/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
6 | 6 |
7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
8 #include "vm/bit_vector.h" | 8 #include "vm/bit_vector.h" |
9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 1593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1604 } | 1604 } |
1605 return this; | 1605 return this; |
1606 } | 1606 } |
1607 | 1607 |
1608 | 1608 |
1609 Definition* InstantiateTypeArgumentsInstr::Canonicalize(FlowGraph* flow_graph) { | 1609 Definition* InstantiateTypeArgumentsInstr::Canonicalize(FlowGraph* flow_graph) { |
1610 return (FLAG_enable_type_checks || HasUses()) ? this : NULL; | 1610 return (FLAG_enable_type_checks || HasUses()) ? this : NULL; |
1611 } | 1611 } |
1612 | 1612 |
1613 | 1613 |
1614 LocationSummary* DebugStepCheckInstr::MakeLocationSummary(bool opt) const { | 1614 LocationSummary* DebugStepCheckInstr::MakeLocationSummary(Isolate* isolate, |
| 1615 bool opt) const { |
1615 const intptr_t kNumInputs = 0; | 1616 const intptr_t kNumInputs = 0; |
1616 const intptr_t kNumTemps = 0; | 1617 const intptr_t kNumTemps = 0; |
1617 LocationSummary* locs = | 1618 LocationSummary* locs = new(isolate) LocationSummary( |
1618 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | 1619 isolate, kNumInputs, kNumTemps, LocationSummary::kCall); |
1619 return locs; | 1620 return locs; |
1620 } | 1621 } |
1621 | 1622 |
1622 | 1623 |
1623 void DebugStepCheckInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 1624 void DebugStepCheckInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
1624 ASSERT(!compiler->is_optimizing()); | 1625 ASSERT(!compiler->is_optimizing()); |
1625 const ExternalLabel label("debug_step_check", | 1626 const ExternalLabel label("debug_step_check", |
1626 StubCode::DebugStepCheckEntryPoint()); | 1627 StubCode::DebugStepCheckEntryPoint()); |
1627 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); | 1628 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); |
1628 } | 1629 } |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2017 } | 2018 } |
2018 | 2019 |
2019 | 2020 |
2020 // Shared code generation methods (EmitNativeCode and | 2021 // Shared code generation methods (EmitNativeCode and |
2021 // MakeLocationSummary). Only assembly code that can be shared across all | 2022 // MakeLocationSummary). Only assembly code that can be shared across all |
2022 // architectures can be used. Machine specific register allocation and code | 2023 // architectures can be used. Machine specific register allocation and code |
2023 // generation is located in intermediate_language_<arch>.cc | 2024 // generation is located in intermediate_language_<arch>.cc |
2024 | 2025 |
2025 #define __ compiler->assembler()-> | 2026 #define __ compiler->assembler()-> |
2026 | 2027 |
2027 LocationSummary* GraphEntryInstr::MakeLocationSummary(bool optimizing) const { | 2028 LocationSummary* GraphEntryInstr::MakeLocationSummary(Isolate* isolate, |
| 2029 bool optimizing) const { |
2028 UNREACHABLE(); | 2030 UNREACHABLE(); |
2029 return NULL; | 2031 return NULL; |
2030 } | 2032 } |
2031 | 2033 |
2032 | 2034 |
2033 LocationSummary* JoinEntryInstr::MakeLocationSummary(bool optimizing) const { | 2035 LocationSummary* JoinEntryInstr::MakeLocationSummary(Isolate* isolate, |
| 2036 bool optimizing) const { |
2034 UNREACHABLE(); | 2037 UNREACHABLE(); |
2035 return NULL; | 2038 return NULL; |
2036 } | 2039 } |
2037 | 2040 |
2038 | 2041 |
2039 void JoinEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2042 void JoinEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
2040 __ Bind(compiler->GetJumpLabel(this)); | 2043 __ Bind(compiler->GetJumpLabel(this)); |
2041 if (!compiler->is_optimizing()) { | 2044 if (!compiler->is_optimizing()) { |
2042 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, | 2045 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, |
2043 deopt_id_, | 2046 deopt_id_, |
2044 Scanner::kNoSourcePos); | 2047 Scanner::kNoSourcePos); |
2045 } | 2048 } |
2046 if (HasParallelMove()) { | 2049 if (HasParallelMove()) { |
2047 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); | 2050 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); |
2048 } | 2051 } |
2049 } | 2052 } |
2050 | 2053 |
2051 | 2054 |
2052 LocationSummary* TargetEntryInstr::MakeLocationSummary(bool optimizing) const { | 2055 LocationSummary* TargetEntryInstr::MakeLocationSummary(Isolate* isolate, |
| 2056 bool optimizing) const { |
2053 // FlowGraphCompiler::EmitInstructionPrologue is not called for block | 2057 // FlowGraphCompiler::EmitInstructionPrologue is not called for block |
2054 // entry instructions, so this function is unused. If it becomes | 2058 // entry instructions, so this function is unused. If it becomes |
2055 // reachable, note that the deoptimization descriptor in unoptimized code | 2059 // reachable, note that the deoptimization descriptor in unoptimized code |
2056 // comes after the point of local register allocation due to pattern | 2060 // comes after the point of local register allocation due to pattern |
2057 // matching the edge counter code backwards (as a code reuse convenience | 2061 // matching the edge counter code backwards (as a code reuse convenience |
2058 // on some platforms). | 2062 // on some platforms). |
2059 UNREACHABLE(); | 2063 UNREACHABLE(); |
2060 return NULL; | 2064 return NULL; |
2061 } | 2065 } |
2062 | 2066 |
2063 | 2067 |
2064 LocationSummary* PhiInstr::MakeLocationSummary(bool optimizing) const { | 2068 LocationSummary* PhiInstr::MakeLocationSummary(Isolate* isolate, |
| 2069 bool optimizing) const { |
2065 UNREACHABLE(); | 2070 UNREACHABLE(); |
2066 return NULL; | 2071 return NULL; |
2067 } | 2072 } |
2068 | 2073 |
2069 | 2074 |
2070 void PhiInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2075 void PhiInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
2071 UNREACHABLE(); | 2076 UNREACHABLE(); |
2072 } | 2077 } |
2073 | 2078 |
2074 | 2079 |
2075 LocationSummary* RedefinitionInstr::MakeLocationSummary(bool optimizing) const { | 2080 LocationSummary* RedefinitionInstr::MakeLocationSummary(Isolate* isolate, |
| 2081 bool optimizing) const { |
2076 UNREACHABLE(); | 2082 UNREACHABLE(); |
2077 return NULL; | 2083 return NULL; |
2078 } | 2084 } |
2079 | 2085 |
2080 | 2086 |
2081 void RedefinitionInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2087 void RedefinitionInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
2082 UNREACHABLE(); | 2088 UNREACHABLE(); |
2083 } | 2089 } |
2084 | 2090 |
2085 | 2091 |
2086 LocationSummary* ParameterInstr::MakeLocationSummary(bool optimizing) const { | 2092 LocationSummary* ParameterInstr::MakeLocationSummary(Isolate* isolate, |
| 2093 bool optimizing) const { |
2087 UNREACHABLE(); | 2094 UNREACHABLE(); |
2088 return NULL; | 2095 return NULL; |
2089 } | 2096 } |
2090 | 2097 |
2091 | 2098 |
2092 void ParameterInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2099 void ParameterInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
2093 UNREACHABLE(); | 2100 UNREACHABLE(); |
2094 } | 2101 } |
2095 | 2102 |
2096 | 2103 |
2097 LocationSummary* ParallelMoveInstr::MakeLocationSummary(bool optimizing) const { | 2104 LocationSummary* ParallelMoveInstr::MakeLocationSummary(Isolate* isolate, |
| 2105 bool optimizing) const { |
2098 return NULL; | 2106 return NULL; |
2099 } | 2107 } |
2100 | 2108 |
2101 | 2109 |
2102 void ParallelMoveInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2110 void ParallelMoveInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
2103 UNREACHABLE(); | 2111 UNREACHABLE(); |
2104 } | 2112 } |
2105 | 2113 |
2106 | 2114 |
2107 LocationSummary* ConstraintInstr::MakeLocationSummary(bool optimizing) const { | 2115 LocationSummary* ConstraintInstr::MakeLocationSummary(Isolate* isolate, |
| 2116 bool optimizing) const { |
2108 UNREACHABLE(); | 2117 UNREACHABLE(); |
2109 return NULL; | 2118 return NULL; |
2110 } | 2119 } |
2111 | 2120 |
2112 | 2121 |
2113 void ConstraintInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2122 void ConstraintInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
2114 UNREACHABLE(); | 2123 UNREACHABLE(); |
2115 } | 2124 } |
2116 | 2125 |
2117 | 2126 |
2118 LocationSummary* MaterializeObjectInstr::MakeLocationSummary( | 2127 LocationSummary* MaterializeObjectInstr::MakeLocationSummary( |
2119 bool optimizing) const { | 2128 Isolate* isolate, bool optimizing) const { |
2120 UNREACHABLE(); | 2129 UNREACHABLE(); |
2121 return NULL; | 2130 return NULL; |
2122 } | 2131 } |
2123 | 2132 |
2124 | 2133 |
2125 void MaterializeObjectInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2134 void MaterializeObjectInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
2126 UNREACHABLE(); | 2135 UNREACHABLE(); |
2127 } | 2136 } |
2128 | 2137 |
2129 | 2138 |
(...skipping 28 matching lines...) Expand all Loading... |
2158 } else if (loc.IsInvalid()) { | 2167 } else if (loc.IsInvalid()) { |
2159 // We currently only perform one iteration of allocation | 2168 // We currently only perform one iteration of allocation |
2160 // sinking, so we do not expect to find materialized objects | 2169 // sinking, so we do not expect to find materialized objects |
2161 // here. | 2170 // here. |
2162 ASSERT(!InputAt(i)->definition()->IsMaterializeObject()); | 2171 ASSERT(!InputAt(i)->definition()->IsMaterializeObject()); |
2163 } | 2172 } |
2164 } | 2173 } |
2165 } | 2174 } |
2166 | 2175 |
2167 | 2176 |
2168 LocationSummary* StoreContextInstr::MakeLocationSummary(bool optimizing) const { | 2177 LocationSummary* StoreContextInstr::MakeLocationSummary(Isolate* isolate, |
| 2178 bool optimizing) const { |
2169 const intptr_t kNumInputs = 1; | 2179 const intptr_t kNumInputs = 1; |
2170 const intptr_t kNumTemps = 0; | 2180 const intptr_t kNumTemps = 0; |
2171 LocationSummary* summary = | 2181 LocationSummary* summary = new(isolate) LocationSummary( |
2172 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 2182 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
2173 summary->set_in(0, Location::RegisterLocation(CTX)); | 2183 summary->set_in(0, Location::RegisterLocation(CTX)); |
2174 return summary; | 2184 return summary; |
2175 } | 2185 } |
2176 | 2186 |
2177 | 2187 |
2178 LocationSummary* PushTempInstr::MakeLocationSummary(bool optimizing) const { | 2188 LocationSummary* PushTempInstr::MakeLocationSummary(Isolate* isolate, |
| 2189 bool optimizing) const { |
2179 return LocationSummary::Make(1, | 2190 return LocationSummary::Make(1, |
2180 Location::NoLocation(), | 2191 Location::NoLocation(), |
2181 LocationSummary::kNoCall); | 2192 LocationSummary::kNoCall); |
2182 } | 2193 } |
2183 | 2194 |
2184 | 2195 |
2185 void PushTempInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2196 void PushTempInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
2186 ASSERT(!compiler->is_optimizing()); | 2197 ASSERT(!compiler->is_optimizing()); |
2187 // Nothing to do. | 2198 // Nothing to do. |
2188 } | 2199 } |
2189 | 2200 |
2190 | 2201 |
2191 LocationSummary* DropTempsInstr::MakeLocationSummary(bool optimizing) const { | 2202 LocationSummary* DropTempsInstr::MakeLocationSummary(Isolate* isolate, |
| 2203 bool optimizing) const { |
2192 return (InputCount() == 1) | 2204 return (InputCount() == 1) |
2193 ? LocationSummary::Make(1, | 2205 ? LocationSummary::Make(1, |
2194 Location::SameAsFirstInput(), | 2206 Location::SameAsFirstInput(), |
2195 LocationSummary::kNoCall) | 2207 LocationSummary::kNoCall) |
2196 : LocationSummary::Make(0, | 2208 : LocationSummary::Make(0, |
2197 Location::NoLocation(), | 2209 Location::NoLocation(), |
2198 LocationSummary::kNoCall); | 2210 LocationSummary::kNoCall); |
2199 } | 2211 } |
2200 | 2212 |
2201 | 2213 |
(...skipping 15 matching lines...) Expand all Loading... |
2217 Token::Kind kind, | 2229 Token::Kind kind, |
2218 Value* left, | 2230 Value* left, |
2219 Value* right, | 2231 Value* right, |
2220 bool needs_number_check) | 2232 bool needs_number_check) |
2221 : ComparisonInstr(token_pos, kind, left, right), | 2233 : ComparisonInstr(token_pos, kind, left, right), |
2222 needs_number_check_(needs_number_check) { | 2234 needs_number_check_(needs_number_check) { |
2223 ASSERT((kind == Token::kEQ_STRICT) || (kind == Token::kNE_STRICT)); | 2235 ASSERT((kind == Token::kEQ_STRICT) || (kind == Token::kNE_STRICT)); |
2224 } | 2236 } |
2225 | 2237 |
2226 | 2238 |
2227 LocationSummary* InstanceCallInstr::MakeLocationSummary(bool optimizing) const { | 2239 LocationSummary* InstanceCallInstr::MakeLocationSummary(Isolate* isolate, |
| 2240 bool optimizing) const { |
2228 return MakeCallSummary(); | 2241 return MakeCallSummary(); |
2229 } | 2242 } |
2230 | 2243 |
2231 | 2244 |
2232 void InstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2245 void InstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
2233 ICData& call_ic_data = ICData::ZoneHandle(ic_data()->raw()); | 2246 ICData& call_ic_data = ICData::ZoneHandle(ic_data()->raw()); |
2234 if (!FLAG_propagate_ic_data || !compiler->is_optimizing()) { | 2247 if (!FLAG_propagate_ic_data || !compiler->is_optimizing()) { |
2235 const Array& arguments_descriptor = | 2248 const Array& arguments_descriptor = |
2236 Array::Handle(ArgumentsDescriptor::New(ArgumentCount(), | 2249 Array::Handle(ArgumentsDescriptor::New(ArgumentCount(), |
2237 argument_names())); | 2250 argument_names())); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2290 const Function& target = Function::Handle(ic_data().GetTargetAt(i)); | 2303 const Function& target = Function::Handle(ic_data().GetTargetAt(i)); |
2291 if (!target.IsNoSuchMethodDispatcher() && | 2304 if (!target.IsNoSuchMethodDispatcher() && |
2292 !target.IsInvokeFieldDispatcher()) { | 2305 !target.IsInvokeFieldDispatcher()) { |
2293 return false; | 2306 return false; |
2294 } | 2307 } |
2295 } | 2308 } |
2296 return true; | 2309 return true; |
2297 } | 2310 } |
2298 | 2311 |
2299 | 2312 |
2300 LocationSummary* StaticCallInstr::MakeLocationSummary(bool optimizing) const { | 2313 LocationSummary* StaticCallInstr::MakeLocationSummary(Isolate* isolate, |
| 2314 bool optimizing) const { |
2301 return MakeCallSummary(); | 2315 return MakeCallSummary(); |
2302 } | 2316 } |
2303 | 2317 |
2304 | 2318 |
2305 void StaticCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2319 void StaticCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
2306 if (!compiler->is_optimizing()) { | 2320 if (!compiler->is_optimizing()) { |
2307 // Some static calls can be optimized by the optimizing compiler (e.g. sqrt) | 2321 // Some static calls can be optimized by the optimizing compiler (e.g. sqrt) |
2308 // and therefore need a deoptimization descriptor. | 2322 // and therefore need a deoptimization descriptor. |
2309 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, | 2323 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, |
2310 deopt_id(), | 2324 deopt_id(), |
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3436 case Token::kTRUNCDIV: return 0; | 3450 case Token::kTRUNCDIV: return 0; |
3437 case Token::kMOD: return 1; | 3451 case Token::kMOD: return 1; |
3438 default: UNIMPLEMENTED(); return -1; | 3452 default: UNIMPLEMENTED(); return -1; |
3439 } | 3453 } |
3440 } | 3454 } |
3441 | 3455 |
3442 | 3456 |
3443 #undef __ | 3457 #undef __ |
3444 | 3458 |
3445 } // namespace dart | 3459 } // namespace dart |
OLD | NEW |