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