| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ | 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ |
| 6 #define VM_INTERMEDIATE_LANGUAGE_H_ | 6 #define VM_INTERMEDIATE_LANGUAGE_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/ast.h" | 9 #include "vm/ast.h" |
| 10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 virtual Value* InputAt(intptr_t i) const = 0; | 140 virtual Value* InputAt(intptr_t i) const = 0; |
| 141 virtual void SetInputAt(intptr_t i, Value* value) = 0; | 141 virtual void SetInputAt(intptr_t i, Value* value) = 0; |
| 142 | 142 |
| 143 // Call computations override this function and return the | 143 // Call computations override this function and return the |
| 144 // number of pushed arguments. | 144 // number of pushed arguments. |
| 145 virtual intptr_t ArgumentCount() const = 0; | 145 virtual intptr_t ArgumentCount() const = 0; |
| 146 | 146 |
| 147 // Returns true, if this computation can deoptimize. | 147 // Returns true, if this computation can deoptimize. |
| 148 virtual bool CanDeoptimize() const = 0; | 148 virtual bool CanDeoptimize() const = 0; |
| 149 | 149 |
| 150 // Compile time type of the computation, which typically depends on the | 150 // Static type of the computation. |
| 151 // compile time types (and possibly propagated types) of its inputs. | 151 virtual RawAbstractType* StaticType() const = 0; |
| 152 virtual RawAbstractType* CompileType() const = 0; | |
| 153 | 152 |
| 154 // Mutate assigned_vars to add the local variable index for all | 153 // Mutate assigned_vars to add the local variable index for all |
| 155 // frame-allocated locals assigned to by the computation. | 154 // frame-allocated locals assigned to by the computation. |
| 156 virtual void RecordAssignedVars(BitVector* assigned_vars, | 155 virtual void RecordAssignedVars(BitVector* assigned_vars, |
| 157 intptr_t fixed_parameter_count); | 156 intptr_t fixed_parameter_count); |
| 158 | 157 |
| 159 virtual const char* DebugName() const = 0; | 158 virtual const char* DebugName() const = 0; |
| 160 | 159 |
| 161 // Printing support. These functions are sometimes overridden for custom | 160 // Printing support. These functions are sometimes overridden for custom |
| 162 // formatting. Otherwise, it prints in the format "opcode(op1, op2, op3)". | 161 // formatting. Otherwise, it prints in the format "opcode(op1, op2, op3)". |
| (...skipping 14 matching lines...) Expand all Loading... |
| 177 // Create a location summary for this computation. | 176 // Create a location summary for this computation. |
| 178 // TODO(fschneider): Temporarily returns NULL for instructions | 177 // TODO(fschneider): Temporarily returns NULL for instructions |
| 179 // that are not yet converted to the location based code generation. | 178 // that are not yet converted to the location based code generation. |
| 180 virtual LocationSummary* MakeLocationSummary() const = 0; | 179 virtual LocationSummary* MakeLocationSummary() const = 0; |
| 181 | 180 |
| 182 // TODO(fschneider): Make EmitNativeCode and locs const. | 181 // TODO(fschneider): Make EmitNativeCode and locs const. |
| 183 virtual void EmitNativeCode(FlowGraphCompiler* compiler) = 0; | 182 virtual void EmitNativeCode(FlowGraphCompiler* compiler) = 0; |
| 184 | 183 |
| 185 static LocationSummary* MakeCallSummary(); | 184 static LocationSummary* MakeCallSummary(); |
| 186 | 185 |
| 187 // Declare an enum value used to define kind-test predicates. | 186 // Declare an enum value used to define type-test predicates. |
| 188 enum ComputationKind { | 187 enum ComputationType { |
| 189 #define DECLARE_COMPUTATION_KIND(ShortName, ClassName) k##ShortName, | 188 #define DECLARE_COMPUTATION_TYPE(ShortName, ClassName) k##ShortName, |
| 190 | 189 |
| 191 FOR_EACH_COMPUTATION(DECLARE_COMPUTATION_KIND) | 190 FOR_EACH_COMPUTATION(DECLARE_COMPUTATION_TYPE) |
| 192 | 191 |
| 193 #undef DECLARE_COMPUTATION_KIND | 192 #undef DECLARE_COMPUTATION_TYPE |
| 194 }; | 193 }; |
| 195 | 194 |
| 196 virtual ComputationKind computation_kind() const = 0; | 195 virtual ComputationType computation_type() const = 0; |
| 197 | 196 |
| 198 // Declare predicate for each computation. | 197 // Declare predicate for each computation. |
| 199 #define DECLARE_PREDICATE(ShortName, ClassName) \ | 198 #define DECLARE_PREDICATE(ShortName, ClassName) \ |
| 200 inline bool Is##ShortName() const; \ | 199 inline bool Is##ShortName() const; \ |
| 201 inline const ClassName* As##ShortName() const; \ | 200 inline const ClassName* As##ShortName() const; \ |
| 202 inline ClassName* As##ShortName(); | 201 inline ClassName* As##ShortName(); |
| 203 FOR_EACH_COMPUTATION(DECLARE_PREDICATE) | 202 FOR_EACH_COMPUTATION(DECLARE_PREDICATE) |
| 204 #undef DECLARE_PREDICATE | 203 #undef DECLARE_PREDICATE |
| 205 | 204 |
| 206 private: | 205 private: |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 | 271 |
| 273 protected: | 272 protected: |
| 274 EmbeddedArray<Value*, N> inputs_; | 273 EmbeddedArray<Value*, N> inputs_; |
| 275 }; | 274 }; |
| 276 | 275 |
| 277 | 276 |
| 278 class Value : public TemplateComputation<0> { | 277 class Value : public TemplateComputation<0> { |
| 279 public: | 278 public: |
| 280 Value() { } | 279 Value() { } |
| 281 | 280 |
| 282 bool CompileTypeIsMoreSpecificThan(const AbstractType& dst_type) const; | 281 bool StaticTypeIsMoreSpecificThan(const AbstractType& dst_type) const; |
| 283 | 282 |
| 284 private: | 283 private: |
| 285 DISALLOW_COPY_AND_ASSIGN(Value); | 284 DISALLOW_COPY_AND_ASSIGN(Value); |
| 286 }; | 285 }; |
| 287 | 286 |
| 288 | 287 |
| 289 // Functions defined in all concrete computation classes. | 288 // Functions defined in all concrete computation classes. |
| 290 #define DECLARE_COMPUTATION(ShortName) \ | 289 #define DECLARE_COMPUTATION(ShortName) \ |
| 291 virtual void Accept(FlowGraphVisitor* visitor, BindInstr* instr); \ | 290 virtual void Accept(FlowGraphVisitor* visitor, BindInstr* instr); \ |
| 292 virtual ComputationKind computation_kind() const { \ | 291 virtual ComputationType computation_type() const { \ |
| 293 return Computation::k##ShortName; \ | 292 return Computation::k##ShortName; \ |
| 294 } \ | 293 } \ |
| 295 virtual intptr_t ArgumentCount() const { return 0; } \ | 294 virtual intptr_t ArgumentCount() const { return 0; } \ |
| 296 virtual const char* DebugName() const { return #ShortName; } \ | 295 virtual const char* DebugName() const { return #ShortName; } \ |
| 297 virtual RawAbstractType* CompileType() const; \ | 296 virtual RawAbstractType* StaticType() const; \ |
| 298 virtual LocationSummary* MakeLocationSummary() const; \ | 297 virtual LocationSummary* MakeLocationSummary() const; \ |
| 299 virtual void EmitNativeCode(FlowGraphCompiler* compiler); | 298 virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
| 300 | 299 |
| 301 // Functions defined in all concrete value classes. | 300 // Functions defined in all concrete value classes. |
| 302 #define DECLARE_VALUE(ShortName) \ | 301 #define DECLARE_VALUE(ShortName) \ |
| 303 DECLARE_COMPUTATION(ShortName) \ | 302 DECLARE_COMPUTATION(ShortName) \ |
| 304 virtual void PrintTo(BufferFormatter* f) const; | 303 virtual void PrintTo(BufferFormatter* f) const; |
| 305 | 304 |
| 306 | 305 |
| 307 // Function defined in all call computation classes. | 306 // Function defined in all call computation classes. |
| 308 #define DECLARE_CALL_COMPUTATION(ShortName) \ | 307 #define DECLARE_CALL_COMPUTATION(ShortName) \ |
| 309 virtual void Accept(FlowGraphVisitor* visitor, BindInstr* instr); \ | 308 virtual void Accept(FlowGraphVisitor* visitor, BindInstr* instr); \ |
| 310 virtual ComputationKind computation_kind() const { \ | 309 virtual ComputationType computation_type() const { \ |
| 311 return Computation::k##ShortName; \ | 310 return Computation::k##ShortName; \ |
| 312 } \ | 311 } \ |
| 313 virtual const char* DebugName() const { return #ShortName; } \ | 312 virtual const char* DebugName() const { return #ShortName; } \ |
| 314 virtual RawAbstractType* CompileType() const; \ | 313 virtual RawAbstractType* StaticType() const; \ |
| 315 virtual LocationSummary* MakeLocationSummary() const; \ | 314 virtual LocationSummary* MakeLocationSummary() const; \ |
| 316 virtual void EmitNativeCode(FlowGraphCompiler* compiler); | 315 virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
| 317 | 316 |
| 318 | 317 |
| 319 class Definition; | 318 class Definition; |
| 320 class PhiInstr; | 319 class PhiInstr; |
| 321 | 320 |
| 322 class UseVal : public Value { | 321 class UseVal : public Value { |
| 323 public: | 322 public: |
| 324 explicit UseVal(Definition* definition) : definition_(definition) {} | 323 explicit UseVal(Definition* definition) : definition_(definition) {} |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 AssertAssignableComp(intptr_t token_pos, | 366 AssertAssignableComp(intptr_t token_pos, |
| 368 intptr_t try_index, | 367 intptr_t try_index, |
| 369 Value* value, | 368 Value* value, |
| 370 Value* instantiator, | 369 Value* instantiator, |
| 371 Value* instantiator_type_arguments, | 370 Value* instantiator_type_arguments, |
| 372 const AbstractType& dst_type, | 371 const AbstractType& dst_type, |
| 373 const String& dst_name) | 372 const String& dst_name) |
| 374 : token_pos_(token_pos), | 373 : token_pos_(token_pos), |
| 375 try_index_(try_index), | 374 try_index_(try_index), |
| 376 dst_type_(dst_type), | 375 dst_type_(dst_type), |
| 377 dst_name_(dst_name), | 376 dst_name_(dst_name) { |
| 378 eliminated_(false) { | |
| 379 ASSERT(value != NULL); | 377 ASSERT(value != NULL); |
| 380 ASSERT(instantiator != NULL); | 378 ASSERT(instantiator != NULL); |
| 381 ASSERT(instantiator_type_arguments != NULL); | 379 ASSERT(instantiator_type_arguments != NULL); |
| 382 ASSERT(!dst_type.IsNull()); | 380 ASSERT(!dst_type.IsNull()); |
| 383 ASSERT(!dst_name.IsNull()); | 381 ASSERT(!dst_name.IsNull()); |
| 384 inputs_[0] = value; | 382 inputs_[0] = value; |
| 385 inputs_[1] = instantiator; | 383 inputs_[1] = instantiator; |
| 386 inputs_[2] = instantiator_type_arguments; | 384 inputs_[2] = instantiator_type_arguments; |
| 387 } | 385 } |
| 388 | 386 |
| 389 DECLARE_COMPUTATION(AssertAssignable) | 387 DECLARE_COMPUTATION(AssertAssignable) |
| 390 | 388 |
| 391 Value* value() const { return inputs_[0]; } | 389 Value* value() const { return inputs_[0]; } |
| 392 Value* instantiator() const { return inputs_[1]; } | 390 Value* instantiator() const { return inputs_[1]; } |
| 393 Value* instantiator_type_arguments() const { return inputs_[2]; } | 391 Value* instantiator_type_arguments() const { return inputs_[2]; } |
| 394 | 392 |
| 395 intptr_t token_pos() const { return token_pos_; } | 393 intptr_t token_pos() const { return token_pos_; } |
| 396 intptr_t try_index() const { return try_index_; } | 394 intptr_t try_index() const { return try_index_; } |
| 397 const AbstractType& dst_type() const { return dst_type_; } | 395 const AbstractType& dst_type() const { return dst_type_; } |
| 398 const String& dst_name() const { return dst_name_; } | 396 const String& dst_name() const { return dst_name_; } |
| 399 | 397 |
| 400 bool IsEliminated() const { | |
| 401 return eliminated_; | |
| 402 } | |
| 403 void Eliminate() { | |
| 404 ASSERT(!eliminated_); | |
| 405 eliminated_ = true; | |
| 406 } | |
| 407 | |
| 408 virtual void PrintOperandsTo(BufferFormatter* f) const; | 398 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 409 | 399 |
| 410 virtual bool CanDeoptimize() const { return false; } | 400 virtual bool CanDeoptimize() const { return false; } |
| 411 | 401 |
| 412 private: | 402 private: |
| 413 const intptr_t token_pos_; | 403 const intptr_t token_pos_; |
| 414 const intptr_t try_index_; | 404 const intptr_t try_index_; |
| 415 const AbstractType& dst_type_; | 405 const AbstractType& dst_type_; |
| 416 const String& dst_name_; | 406 const String& dst_name_; |
| 417 bool eliminated_; | |
| 418 | 407 |
| 419 DISALLOW_COPY_AND_ASSIGN(AssertAssignableComp); | 408 DISALLOW_COPY_AND_ASSIGN(AssertAssignableComp); |
| 420 }; | 409 }; |
| 421 | 410 |
| 422 | 411 |
| 423 class AssertBooleanComp : public TemplateComputation<1> { | 412 class AssertBooleanComp : public TemplateComputation<1> { |
| 424 public: | 413 public: |
| 425 AssertBooleanComp(intptr_t token_pos, | 414 AssertBooleanComp(intptr_t token_pos, |
| 426 intptr_t try_index, | 415 intptr_t try_index, |
| 427 Value* value) | 416 Value* value) |
| (...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1681 DISALLOW_COPY_AND_ASSIGN(ToDoubleComp); | 1670 DISALLOW_COPY_AND_ASSIGN(ToDoubleComp); |
| 1682 }; | 1671 }; |
| 1683 | 1672 |
| 1684 | 1673 |
| 1685 #undef DECLARE_COMPUTATION | 1674 #undef DECLARE_COMPUTATION |
| 1686 | 1675 |
| 1687 | 1676 |
| 1688 // Implementation of type testers and cast functins. | 1677 // Implementation of type testers and cast functins. |
| 1689 #define DEFINE_PREDICATE(ShortName, ClassName) \ | 1678 #define DEFINE_PREDICATE(ShortName, ClassName) \ |
| 1690 bool Computation::Is##ShortName() const { \ | 1679 bool Computation::Is##ShortName() const { \ |
| 1691 return computation_kind() == k##ShortName; \ | 1680 return computation_type() == k##ShortName; \ |
| 1692 } \ | 1681 } \ |
| 1693 const ClassName* Computation::As##ShortName() const { \ | 1682 const ClassName* Computation::As##ShortName() const { \ |
| 1694 if (!Is##ShortName()) return NULL; \ | 1683 if (!Is##ShortName()) return NULL; \ |
| 1695 return static_cast<const ClassName*>(this); \ | 1684 return static_cast<const ClassName*>(this); \ |
| 1696 } \ | 1685 } \ |
| 1697 ClassName* Computation::As##ShortName() { \ | 1686 ClassName* Computation::As##ShortName() { \ |
| 1698 if (!Is##ShortName()) return NULL; \ | 1687 if (!Is##ShortName()) return NULL; \ |
| 1699 return static_cast<ClassName*>(this); \ | 1688 return static_cast<ClassName*>(this); \ |
| 1700 } | 1689 } |
| 1701 FOR_EACH_COMPUTATION(DEFINE_PREDICATE) | 1690 FOR_EACH_COMPUTATION(DEFINE_PREDICATE) |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2278 BlockEntryInstr* predecessor_; | 2267 BlockEntryInstr* predecessor_; |
| 2279 const intptr_t try_index_; | 2268 const intptr_t try_index_; |
| 2280 | 2269 |
| 2281 DISALLOW_COPY_AND_ASSIGN(TargetEntryInstr); | 2270 DISALLOW_COPY_AND_ASSIGN(TargetEntryInstr); |
| 2282 }; | 2271 }; |
| 2283 | 2272 |
| 2284 | 2273 |
| 2285 // Abstract super-class of all instructions that define a value (Bind, Phi). | 2274 // Abstract super-class of all instructions that define a value (Bind, Phi). |
| 2286 class Definition : public Instruction { | 2275 class Definition : public Instruction { |
| 2287 public: | 2276 public: |
| 2288 Definition() | 2277 Definition() : temp_index_(-1), ssa_temp_index_(-1) { } |
| 2289 : temp_index_(-1), | |
| 2290 ssa_temp_index_(-1), | |
| 2291 propagated_type_(AbstractType::Handle()) { } | |
| 2292 | 2278 |
| 2293 virtual bool IsDefinition() const { return true; } | 2279 virtual bool IsDefinition() const { return true; } |
| 2294 virtual Definition* AsDefinition() { return this; } | 2280 virtual Definition* AsDefinition() { return this; } |
| 2295 | 2281 |
| 2296 intptr_t temp_index() const { return temp_index_; } | 2282 intptr_t temp_index() const { return temp_index_; } |
| 2297 void set_temp_index(intptr_t index) { temp_index_ = index; } | 2283 void set_temp_index(intptr_t index) { temp_index_ = index; } |
| 2298 | 2284 |
| 2299 intptr_t ssa_temp_index() const { return ssa_temp_index_; } | 2285 intptr_t ssa_temp_index() const { return ssa_temp_index_; } |
| 2300 void set_ssa_temp_index(intptr_t index) { | 2286 void set_ssa_temp_index(intptr_t index) { |
| 2301 ASSERT(index >= 0); | 2287 ASSERT(index >= 0); |
| 2302 ssa_temp_index_ = index; | 2288 ssa_temp_index_ = index; |
| 2303 } | 2289 } |
| 2304 bool HasSSATemp() const { return ssa_temp_index_ >= 0; } | 2290 bool HasSSATemp() const { return ssa_temp_index_ >= 0; } |
| 2305 | 2291 |
| 2306 // Compile time type of the definition, which may be requested before type | 2292 // Static type of the definition. |
| 2307 // propagation during graph building. | 2293 virtual RawAbstractType* StaticType() const = 0; |
| 2308 virtual RawAbstractType* CompileType() const = 0; | |
| 2309 | |
| 2310 bool HasPropagatedType() const { | |
| 2311 return !propagated_type_.IsNull(); | |
| 2312 } | |
| 2313 RawAbstractType* PropagatedType() const { | |
| 2314 ASSERT(HasPropagatedType()); | |
| 2315 return propagated_type_.raw(); | |
| 2316 } | |
| 2317 // Returns true if the propagated type has changed. | |
| 2318 bool SetPropagatedType(const AbstractType& propagated_type) { | |
| 2319 if (propagated_type.IsNull()) { | |
| 2320 // Not a typed definition, e.g. access to a VM field. | |
| 2321 return false; | |
| 2322 } | |
| 2323 const bool changed = | |
| 2324 propagated_type_.IsNull() || !propagated_type.Equals(propagated_type_); | |
| 2325 propagated_type_ = propagated_type.raw(); | |
| 2326 return changed; | |
| 2327 } | |
| 2328 | 2294 |
| 2329 private: | 2295 private: |
| 2330 intptr_t temp_index_; | 2296 intptr_t temp_index_; |
| 2331 intptr_t ssa_temp_index_; | 2297 intptr_t ssa_temp_index_; |
| 2332 // TODO(regis): GrowableArray<const AbstractType*> propagated_types_; | |
| 2333 // For now: | |
| 2334 AbstractType& propagated_type_; | |
| 2335 | 2298 |
| 2336 DISALLOW_COPY_AND_ASSIGN(Definition); | 2299 DISALLOW_COPY_AND_ASSIGN(Definition); |
| 2337 }; | 2300 }; |
| 2338 | 2301 |
| 2339 | 2302 |
| 2340 Definition* UseVal::definition() const { | 2303 Definition* UseVal::definition() const { |
| 2341 // Check that the definition is either a Phi or a linked in the the IR. | 2304 // Check that the definition is either a Phi or a linked in the the IR. |
| 2342 ASSERT(definition_ != NULL); | 2305 ASSERT(definition_ != NULL); |
| 2343 return definition_; | 2306 return definition_; |
| 2344 } | 2307 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2365 void SetInputAt(intptr_t i, Value* value) { | 2328 void SetInputAt(intptr_t i, Value* value) { |
| 2366 computation()->SetInputAt(i, value); | 2329 computation()->SetInputAt(i, value); |
| 2367 } | 2330 } |
| 2368 | 2331 |
| 2369 virtual bool CanDeoptimize() const { return computation()->CanDeoptimize(); } | 2332 virtual bool CanDeoptimize() const { return computation()->CanDeoptimize(); } |
| 2370 | 2333 |
| 2371 Computation* computation() const { return computation_; } | 2334 Computation* computation() const { return computation_; } |
| 2372 void set_computation(Computation* value) { computation_ = value; } | 2335 void set_computation(Computation* value) { computation_ = value; } |
| 2373 bool is_used() const { return is_used_; } | 2336 bool is_used() const { return is_used_; } |
| 2374 | 2337 |
| 2375 virtual RawAbstractType* CompileType() const; | 2338 // Static type of the underlying computation. |
| 2339 virtual RawAbstractType* StaticType() const { |
| 2340 return computation()->StaticType(); |
| 2341 } |
| 2376 | 2342 |
| 2377 virtual void RecordAssignedVars(BitVector* assigned_vars, | 2343 virtual void RecordAssignedVars(BitVector* assigned_vars, |
| 2378 intptr_t fixed_parameter_count); | 2344 intptr_t fixed_parameter_count); |
| 2379 | 2345 |
| 2380 virtual LocationSummary* locs() { | 2346 virtual LocationSummary* locs() { |
| 2381 return computation()->locs(); | 2347 return computation()->locs(); |
| 2382 } | 2348 } |
| 2383 | 2349 |
| 2384 virtual void EmitNativeCode(FlowGraphCompiler* compiler); | 2350 virtual void EmitNativeCode(FlowGraphCompiler* compiler); |
| 2385 | 2351 |
| 2386 private: | 2352 private: |
| 2387 Computation* computation_; | 2353 Computation* computation_; |
| 2388 const bool is_used_; | 2354 const bool is_used_; |
| 2389 | 2355 |
| 2390 DISALLOW_COPY_AND_ASSIGN(BindInstr); | 2356 DISALLOW_COPY_AND_ASSIGN(BindInstr); |
| 2391 }; | 2357 }; |
| 2392 | 2358 |
| 2393 | 2359 |
| 2394 class PhiInstr : public Definition { | 2360 class PhiInstr : public Definition { |
| 2395 public: | 2361 public: |
| 2396 explicit PhiInstr(intptr_t num_inputs) | 2362 explicit PhiInstr(intptr_t num_inputs) |
| 2397 : inputs_(num_inputs), is_alive_(false) { | 2363 : inputs_(num_inputs), is_alive_(false) { |
| 2398 for (intptr_t i = 0; i < num_inputs; ++i) { | 2364 for (intptr_t i = 0; i < num_inputs; ++i) { |
| 2399 inputs_.Add(NULL); | 2365 inputs_.Add(NULL); |
| 2400 } | 2366 } |
| 2401 } | 2367 } |
| 2402 | 2368 |
| 2403 virtual RawAbstractType* CompileType() const; | 2369 // Least upper bound of the static types of the inputs. |
| 2370 virtual RawAbstractType* StaticType() const; |
| 2404 | 2371 |
| 2405 virtual intptr_t ArgumentCount() const { return 0; } | 2372 virtual intptr_t ArgumentCount() const { return 0; } |
| 2406 | 2373 |
| 2407 intptr_t InputCount() const { return inputs_.length(); } | 2374 intptr_t InputCount() const { return inputs_.length(); } |
| 2408 | 2375 |
| 2409 Value* InputAt(intptr_t i) const { return inputs_[i]; } | 2376 Value* InputAt(intptr_t i) const { return inputs_[i]; } |
| 2410 | 2377 |
| 2411 void SetInputAt(intptr_t i, Value* value) { inputs_[i] = value; } | 2378 void SetInputAt(intptr_t i, Value* value) { inputs_[i] = value; } |
| 2412 | 2379 |
| 2413 virtual bool CanDeoptimize() const { return false; } | 2380 virtual bool CanDeoptimize() const { return false; } |
| 2414 | 2381 |
| 2415 // TODO(regis): This helper will be removed once we support type sets. | |
| 2416 RawAbstractType* LeastSpecificInputType() const; | |
| 2417 | |
| 2418 // Phi is alive if it reaches a non-environment use. | 2382 // Phi is alive if it reaches a non-environment use. |
| 2419 bool is_alive() const { return is_alive_; } | 2383 bool is_alive() const { return is_alive_; } |
| 2420 void mark_alive() { is_alive_ = true; } | 2384 void mark_alive() { is_alive_ = true; } |
| 2421 | 2385 |
| 2422 DECLARE_INSTRUCTION(Phi) | 2386 DECLARE_INSTRUCTION(Phi) |
| 2423 | 2387 |
| 2424 private: | 2388 private: |
| 2425 GrowableArray<Value*> inputs_; | 2389 GrowableArray<Value*> inputs_; |
| 2426 bool is_alive_; | 2390 bool is_alive_; |
| 2427 | 2391 |
| 2428 DISALLOW_COPY_AND_ASSIGN(PhiInstr); | 2392 DISALLOW_COPY_AND_ASSIGN(PhiInstr); |
| 2429 }; | 2393 }; |
| 2430 | 2394 |
| 2431 | 2395 |
| 2432 class ParameterInstr : public Definition { | 2396 class ParameterInstr : public Definition { |
| 2433 public: | 2397 public: |
| 2434 explicit ParameterInstr(intptr_t index) : index_(index) { } | 2398 explicit ParameterInstr(intptr_t index) : index_(index) { } |
| 2435 | 2399 |
| 2436 DECLARE_INSTRUCTION(Parameter) | 2400 DECLARE_INSTRUCTION(Parameter) |
| 2437 | 2401 |
| 2438 intptr_t index() const { return index_; } | 2402 intptr_t index() const { return index_; } |
| 2439 | 2403 |
| 2440 // Compile type of the passed-in parameter. | 2404 // Static type of the passed-in parameter. |
| 2441 virtual RawAbstractType* CompileType() const; | 2405 virtual RawAbstractType* StaticType() const; |
| 2442 | 2406 |
| 2443 virtual intptr_t ArgumentCount() const { return 0; } | 2407 virtual intptr_t ArgumentCount() const { return 0; } |
| 2444 | 2408 |
| 2445 intptr_t InputCount() const { return 0; } | 2409 intptr_t InputCount() const { return 0; } |
| 2446 Value* InputAt(intptr_t i) const { | 2410 Value* InputAt(intptr_t i) const { |
| 2447 UNREACHABLE(); | 2411 UNREACHABLE(); |
| 2448 return NULL; | 2412 return NULL; |
| 2449 } | 2413 } |
| 2450 void SetInputAt(intptr_t i, Value* value) { UNREACHABLE(); } | 2414 void SetInputAt(intptr_t i, Value* value) { UNREACHABLE(); } |
| 2451 | 2415 |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2796 const GrowableArray<BlockEntryInstr*>& block_order_; | 2760 const GrowableArray<BlockEntryInstr*>& block_order_; |
| 2797 | 2761 |
| 2798 private: | 2762 private: |
| 2799 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 2763 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 2800 }; | 2764 }; |
| 2801 | 2765 |
| 2802 | 2766 |
| 2803 } // namespace dart | 2767 } // namespace dart |
| 2804 | 2768 |
| 2805 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 2769 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |