| 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 #ifndef RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_ | 5 #ifndef RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_ |
| 6 #define RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_ | 6 #define RUNTIME_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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 186 |
| 187 CompileType* ToCompileType() { return &type_; } | 187 CompileType* ToCompileType() { return &type_; } |
| 188 | 188 |
| 189 protected: | 189 protected: |
| 190 explicit ZoneCompileType(const CompileType& type) : type_(type) {} | 190 explicit ZoneCompileType(const CompileType& type) : type_(type) {} |
| 191 | 191 |
| 192 CompileType type_; | 192 CompileType type_; |
| 193 }; | 193 }; |
| 194 | 194 |
| 195 | 195 |
| 196 // ConstrainedCompileType represents a compile type that is computed from | |
| 197 // another compile type. | |
| 198 class ConstrainedCompileType : public ZoneCompileType { | |
| 199 public: | |
| 200 virtual ~ConstrainedCompileType() {} | |
| 201 | |
| 202 // Recompute compile type. | |
| 203 virtual void Update() = 0; | |
| 204 | |
| 205 protected: | |
| 206 explicit ConstrainedCompileType(const CompileType& type) | |
| 207 : ZoneCompileType(type) {} | |
| 208 }; | |
| 209 | |
| 210 | |
| 211 // NotNullConstrainedCompileType represents not-null constraint applied to | |
| 212 // the source compile type. Result is non-nullable version of the incoming | |
| 213 // compile type. It is used to represent compile type propagated downwards | |
| 214 // from strict comparison with the null constant. | |
| 215 class NotNullConstrainedCompileType : public ConstrainedCompileType { | |
| 216 public: | |
| 217 explicit NotNullConstrainedCompileType(CompileType* source) | |
| 218 : ConstrainedCompileType(source->CopyNonNullable()), source_(source) {} | |
| 219 | |
| 220 virtual void Update() { type_ = source_->CopyNonNullable(); } | |
| 221 | |
| 222 private: | |
| 223 CompileType* source_; | |
| 224 }; | |
| 225 | |
| 226 | |
| 227 class EffectSet : public ValueObject { | 196 class EffectSet : public ValueObject { |
| 228 public: | 197 public: |
| 229 enum Effects { | 198 enum Effects { |
| 230 kNoEffects = 0, | 199 kNoEffects = 0, |
| 231 kExternalization = 1, | 200 kExternalization = 1, |
| 232 kLastEffect = kExternalization | 201 kLastEffect = kExternalization |
| 233 }; | 202 }; |
| 234 | 203 |
| 235 EffectSet(const EffectSet& other) : ValueObject(), effects_(other.effects_) {} | 204 EffectSet(const EffectSet& other) : ValueObject(), effects_(other.effects_) {} |
| 236 | 205 |
| (...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2348 private: | 2317 private: |
| 2349 virtual void RawSetInputAt(intptr_t i, Value* value) { inputs_[i] = value; } | 2318 virtual void RawSetInputAt(intptr_t i, Value* value) { inputs_[i] = value; } |
| 2350 }; | 2319 }; |
| 2351 | 2320 |
| 2352 | 2321 |
| 2353 class BranchInstr : public Instruction { | 2322 class BranchInstr : public Instruction { |
| 2354 public: | 2323 public: |
| 2355 explicit BranchInstr(ComparisonInstr* comparison) | 2324 explicit BranchInstr(ComparisonInstr* comparison) |
| 2356 : Instruction(Thread::Current()->GetNextDeoptId()), | 2325 : Instruction(Thread::Current()->GetNextDeoptId()), |
| 2357 comparison_(comparison), | 2326 comparison_(comparison), |
| 2358 is_checked_(false), | |
| 2359 constrained_type_(NULL), | |
| 2360 constant_target_(NULL) { | 2327 constant_target_(NULL) { |
| 2361 ASSERT(comparison->env() == NULL); | 2328 ASSERT(comparison->env() == NULL); |
| 2362 for (intptr_t i = comparison->InputCount() - 1; i >= 0; --i) { | 2329 for (intptr_t i = comparison->InputCount() - 1; i >= 0; --i) { |
| 2363 comparison->InputAt(i)->set_instruction(this); | 2330 comparison->InputAt(i)->set_instruction(this); |
| 2364 } | 2331 } |
| 2365 } | 2332 } |
| 2366 | 2333 |
| 2367 DECLARE_INSTRUCTION(Branch) | 2334 DECLARE_INSTRUCTION(Branch) |
| 2368 | 2335 |
| 2369 virtual intptr_t ArgumentCount() const { | 2336 virtual intptr_t ArgumentCount() const { |
| 2370 return comparison()->ArgumentCount(); | 2337 return comparison()->ArgumentCount(); |
| 2371 } | 2338 } |
| 2372 | 2339 |
| 2373 intptr_t InputCount() const { return comparison()->InputCount(); } | 2340 intptr_t InputCount() const { return comparison()->InputCount(); } |
| 2374 | 2341 |
| 2375 Value* InputAt(intptr_t i) const { return comparison()->InputAt(i); } | 2342 Value* InputAt(intptr_t i) const { return comparison()->InputAt(i); } |
| 2376 | 2343 |
| 2377 virtual TokenPosition token_pos() const { return comparison_->token_pos(); } | 2344 virtual TokenPosition token_pos() const { return comparison_->token_pos(); } |
| 2378 | 2345 |
| 2379 virtual bool CanDeoptimize() const { | 2346 virtual bool CanDeoptimize() const { return comparison()->CanDeoptimize(); } |
| 2380 // Branches need a deoptimization info in checked mode if they | |
| 2381 // can throw a type check error. | |
| 2382 return comparison()->CanDeoptimize() || is_checked(); | |
| 2383 } | |
| 2384 | 2347 |
| 2385 virtual bool CanBecomeDeoptimizationTarget() const { | 2348 virtual bool CanBecomeDeoptimizationTarget() const { |
| 2386 return comparison()->CanBecomeDeoptimizationTarget(); | 2349 return comparison()->CanBecomeDeoptimizationTarget(); |
| 2387 } | 2350 } |
| 2388 | 2351 |
| 2389 virtual EffectSet Effects() const { return comparison()->Effects(); } | 2352 virtual EffectSet Effects() const { return comparison()->Effects(); } |
| 2390 | 2353 |
| 2391 ComparisonInstr* comparison() const { return comparison_; } | 2354 ComparisonInstr* comparison() const { return comparison_; } |
| 2392 void SetComparison(ComparisonInstr* comp); | 2355 void SetComparison(ComparisonInstr* comp); |
| 2393 | 2356 |
| 2394 void set_is_checked(bool value) { is_checked_ = value; } | |
| 2395 bool is_checked() const { return is_checked_; } | |
| 2396 | |
| 2397 virtual intptr_t DeoptimizationTarget() const { | 2357 virtual intptr_t DeoptimizationTarget() const { |
| 2398 return comparison()->DeoptimizationTarget(); | 2358 return comparison()->DeoptimizationTarget(); |
| 2399 } | 2359 } |
| 2400 | 2360 |
| 2401 virtual Representation RequiredInputRepresentation(intptr_t i) const { | 2361 virtual Representation RequiredInputRepresentation(intptr_t i) const { |
| 2402 return comparison()->RequiredInputRepresentation(i); | 2362 return comparison()->RequiredInputRepresentation(i); |
| 2403 } | 2363 } |
| 2404 | 2364 |
| 2405 virtual Instruction* Canonicalize(FlowGraph* flow_graph); | 2365 virtual Instruction* Canonicalize(FlowGraph* flow_graph); |
| 2406 | 2366 |
| 2407 // Set compile type constrained by the comparison of this branch. | |
| 2408 // FlowGraphPropagator propagates it downwards into either true or false | |
| 2409 // successor. | |
| 2410 void set_constrained_type(ConstrainedCompileType* type) { | |
| 2411 constrained_type_ = type; | |
| 2412 } | |
| 2413 | |
| 2414 // Return compile type constrained by the comparison of this branch. | |
| 2415 ConstrainedCompileType* constrained_type() const { return constrained_type_; } | |
| 2416 | |
| 2417 void set_constant_target(TargetEntryInstr* target) { | 2367 void set_constant_target(TargetEntryInstr* target) { |
| 2418 ASSERT(target == true_successor() || target == false_successor()); | 2368 ASSERT(target == true_successor() || target == false_successor()); |
| 2419 constant_target_ = target; | 2369 constant_target_ = target; |
| 2420 } | 2370 } |
| 2421 TargetEntryInstr* constant_target() const { return constant_target_; } | 2371 TargetEntryInstr* constant_target() const { return constant_target_; } |
| 2422 | 2372 |
| 2423 virtual void InheritDeoptTarget(Zone* zone, Instruction* other); | 2373 virtual void InheritDeoptTarget(Zone* zone, Instruction* other); |
| 2424 | 2374 |
| 2425 virtual bool MayThrow() const { return comparison()->MayThrow(); } | 2375 virtual bool MayThrow() const { return comparison()->MayThrow(); } |
| 2426 | 2376 |
| 2427 TargetEntryInstr* true_successor() const { return true_successor_; } | 2377 TargetEntryInstr* true_successor() const { return true_successor_; } |
| 2428 TargetEntryInstr* false_successor() const { return false_successor_; } | 2378 TargetEntryInstr* false_successor() const { return false_successor_; } |
| 2429 | 2379 |
| 2430 TargetEntryInstr** true_successor_address() { return &true_successor_; } | 2380 TargetEntryInstr** true_successor_address() { return &true_successor_; } |
| 2431 TargetEntryInstr** false_successor_address() { return &false_successor_; } | 2381 TargetEntryInstr** false_successor_address() { return &false_successor_; } |
| 2432 | 2382 |
| 2433 virtual intptr_t SuccessorCount() const; | 2383 virtual intptr_t SuccessorCount() const; |
| 2434 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; | 2384 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; |
| 2435 | 2385 |
| 2436 PRINT_TO_SUPPORT | 2386 PRINT_TO_SUPPORT |
| 2437 | 2387 |
| 2438 private: | 2388 private: |
| 2439 virtual void RawSetInputAt(intptr_t i, Value* value) { | 2389 virtual void RawSetInputAt(intptr_t i, Value* value) { |
| 2440 comparison()->RawSetInputAt(i, value); | 2390 comparison()->RawSetInputAt(i, value); |
| 2441 } | 2391 } |
| 2442 | 2392 |
| 2443 TargetEntryInstr* true_successor_; | 2393 TargetEntryInstr* true_successor_; |
| 2444 TargetEntryInstr* false_successor_; | 2394 TargetEntryInstr* false_successor_; |
| 2445 ComparisonInstr* comparison_; | 2395 ComparisonInstr* comparison_; |
| 2446 bool is_checked_; | |
| 2447 ConstrainedCompileType* constrained_type_; | |
| 2448 TargetEntryInstr* constant_target_; | 2396 TargetEntryInstr* constant_target_; |
| 2449 | 2397 |
| 2450 DISALLOW_COPY_AND_ASSIGN(BranchInstr); | 2398 DISALLOW_COPY_AND_ASSIGN(BranchInstr); |
| 2451 }; | 2399 }; |
| 2452 | 2400 |
| 2453 | 2401 |
| 2454 class DeoptimizeInstr : public TemplateInstruction<0, NoThrow, Pure> { | 2402 class DeoptimizeInstr : public TemplateInstruction<0, NoThrow, Pure> { |
| 2455 public: | 2403 public: |
| 2456 DeoptimizeInstr(ICData::DeoptReasonId deopt_reason, intptr_t deopt_id) | 2404 DeoptimizeInstr(ICData::DeoptReasonId deopt_reason, intptr_t deopt_id) |
| 2457 : TemplateInstruction(deopt_id), deopt_reason_(deopt_reason) {} | 2405 : TemplateInstruction(deopt_id), deopt_reason_(deopt_reason) {} |
| (...skipping 5630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8088 LocationSummary* Name::MakeLocationSummary(Zone* zone, bool opt) const { \ | 8036 LocationSummary* Name::MakeLocationSummary(Zone* zone, bool opt) const { \ |
| 8089 UNIMPLEMENTED(); \ | 8037 UNIMPLEMENTED(); \ |
| 8090 return NULL; \ | 8038 return NULL; \ |
| 8091 } \ | 8039 } \ |
| 8092 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } | 8040 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } |
| 8093 | 8041 |
| 8094 | 8042 |
| 8095 } // namespace dart | 8043 } // namespace dart |
| 8096 | 8044 |
| 8097 #endif // RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_ | 8045 #endif // RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |