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