| 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 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 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 M(StoreIndexed) \ | 641 M(StoreIndexed) \ |
| 642 M(StoreInstanceField) \ | 642 M(StoreInstanceField) \ |
| 643 M(LoadStaticField) \ | 643 M(LoadStaticField) \ |
| 644 M(StoreStaticField) \ | 644 M(StoreStaticField) \ |
| 645 M(BooleanNegate) \ | 645 M(BooleanNegate) \ |
| 646 M(InstanceOf) \ | 646 M(InstanceOf) \ |
| 647 M(CreateArray) \ | 647 M(CreateArray) \ |
| 648 M(CreateClosure) \ | 648 M(CreateClosure) \ |
| 649 M(AllocateObject) \ | 649 M(AllocateObject) \ |
| 650 M(LoadField) \ | 650 M(LoadField) \ |
| 651 M(StoreVMField) \ | |
| 652 M(LoadUntagged) \ | 651 M(LoadUntagged) \ |
| 653 M(LoadClassId) \ | 652 M(LoadClassId) \ |
| 654 M(InstantiateType) \ | 653 M(InstantiateType) \ |
| 655 M(InstantiateTypeArguments) \ | 654 M(InstantiateTypeArguments) \ |
| 656 M(AllocateContext) \ | 655 M(AllocateContext) \ |
| 657 M(CloneContext) \ | 656 M(CloneContext) \ |
| 658 M(BinarySmiOp) \ | 657 M(BinarySmiOp) \ |
| 659 M(UnarySmiOp) \ | 658 M(UnarySmiOp) \ |
| 660 M(UnaryDoubleOp) \ | 659 M(UnaryDoubleOp) \ |
| 661 M(CheckStackOverflow) \ | 660 M(CheckStackOverflow) \ |
| (...skipping 2821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3483 | 3482 |
| 3484 | 3483 |
| 3485 class StoreInstanceFieldInstr : public TemplateDefinition<2> { | 3484 class StoreInstanceFieldInstr : public TemplateDefinition<2> { |
| 3486 public: | 3485 public: |
| 3487 StoreInstanceFieldInstr(const Field& field, | 3486 StoreInstanceFieldInstr(const Field& field, |
| 3488 Value* instance, | 3487 Value* instance, |
| 3489 Value* value, | 3488 Value* value, |
| 3490 StoreBarrierType emit_store_barrier, | 3489 StoreBarrierType emit_store_barrier, |
| 3491 bool is_initialization = false) | 3490 bool is_initialization = false) |
| 3492 : field_(field), | 3491 : field_(field), |
| 3492 offset_in_bytes_(field.Offset()), |
| 3493 emit_store_barrier_(emit_store_barrier), |
| 3494 is_initialization_(is_initialization) { |
| 3495 SetInputAt(kInstancePos, instance); |
| 3496 SetInputAt(kValuePos, value); |
| 3497 } |
| 3498 |
| 3499 StoreInstanceFieldInstr(intptr_t offset_in_bytes, |
| 3500 Value* instance, |
| 3501 Value* value, |
| 3502 StoreBarrierType emit_store_barrier, |
| 3503 bool is_initialization = false) |
| 3504 : field_(Field::Handle()), |
| 3505 offset_in_bytes_(offset_in_bytes), |
| 3493 emit_store_barrier_(emit_store_barrier), | 3506 emit_store_barrier_(emit_store_barrier), |
| 3494 is_initialization_(is_initialization) { | 3507 is_initialization_(is_initialization) { |
| 3495 SetInputAt(kInstancePos, instance); | 3508 SetInputAt(kInstancePos, instance); |
| 3496 SetInputAt(kValuePos, value); | 3509 SetInputAt(kValuePos, value); |
| 3497 } | 3510 } |
| 3498 | 3511 |
| 3499 DECLARE_INSTRUCTION(StoreInstanceField) | 3512 DECLARE_INSTRUCTION(StoreInstanceField) |
| 3500 | 3513 |
| 3501 enum { | 3514 enum { |
| 3502 kInstancePos = 0, | 3515 kInstancePos = 0, |
| 3503 kValuePos = 1 | 3516 kValuePos = 1 |
| 3504 }; | 3517 }; |
| 3505 | 3518 |
| 3506 Value* instance() const { return inputs_[kInstancePos]; } | 3519 Value* instance() const { return inputs_[kInstancePos]; } |
| 3507 Value* value() const { return inputs_[kValuePos]; } | 3520 Value* value() const { return inputs_[kValuePos]; } |
| 3508 | 3521 |
| 3509 virtual CompileType* ComputeInitialType() const; | 3522 virtual CompileType* ComputeInitialType() const; |
| 3510 | 3523 |
| 3511 const Field& field() const { return field_; } | 3524 const Field& field() const { return field_; } |
| 3525 intptr_t offset_in_bytes() const { return offset_in_bytes_; } |
| 3512 | 3526 |
| 3513 bool ShouldEmitStoreBarrier() const { | 3527 bool ShouldEmitStoreBarrier() const { |
| 3514 return value()->NeedsStoreBuffer() | 3528 return value()->NeedsStoreBuffer() |
| 3515 && (emit_store_barrier_ == kEmitStoreBarrier); | 3529 && (emit_store_barrier_ == kEmitStoreBarrier); |
| 3516 } | 3530 } |
| 3517 | 3531 |
| 3518 virtual void PrintOperandsTo(BufferFormatter* f) const; | 3532 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 3519 | 3533 |
| 3520 virtual bool CanDeoptimize() const { return false; } | 3534 virtual bool CanDeoptimize() const { return false; } |
| 3521 | 3535 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3541 friend class FlowGraphOptimizer; // For ASSERT(initialization_). | 3555 friend class FlowGraphOptimizer; // For ASSERT(initialization_). |
| 3542 | 3556 |
| 3543 bool CanValueBeSmi() const { | 3557 bool CanValueBeSmi() const { |
| 3544 const intptr_t cid = value()->Type()->ToNullableCid(); | 3558 const intptr_t cid = value()->Type()->ToNullableCid(); |
| 3545 // Write barrier is skipped for nullable and non-nullable smis. | 3559 // Write barrier is skipped for nullable and non-nullable smis. |
| 3546 ASSERT(cid != kSmiCid); | 3560 ASSERT(cid != kSmiCid); |
| 3547 return (cid == kDynamicCid); | 3561 return (cid == kDynamicCid); |
| 3548 } | 3562 } |
| 3549 | 3563 |
| 3550 const Field& field_; | 3564 const Field& field_; |
| 3565 intptr_t offset_in_bytes_; |
| 3551 const StoreBarrierType emit_store_barrier_; | 3566 const StoreBarrierType emit_store_barrier_; |
| 3552 const bool is_initialization_; // Marks stores in the constructor. | 3567 const bool is_initialization_; // Marks stores in the constructor. |
| 3553 | 3568 |
| 3554 DISALLOW_COPY_AND_ASSIGN(StoreInstanceFieldInstr); | 3569 DISALLOW_COPY_AND_ASSIGN(StoreInstanceFieldInstr); |
| 3555 }; | 3570 }; |
| 3556 | 3571 |
| 3557 | 3572 |
| 3558 class GuardFieldInstr : public TemplateInstruction<1> { | 3573 class GuardFieldInstr : public TemplateInstruction<1> { |
| 3559 public: | 3574 public: |
| 3560 GuardFieldInstr(Value* value, | 3575 GuardFieldInstr(Value* value, |
| (...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4238 type_(type), | 4253 type_(type), |
| 4239 result_cid_(kDynamicCid), | 4254 result_cid_(kDynamicCid), |
| 4240 immutable_(immutable), | 4255 immutable_(immutable), |
| 4241 recognized_kind_(MethodRecognizer::kUnknown), | 4256 recognized_kind_(MethodRecognizer::kUnknown), |
| 4242 field_(NULL) { | 4257 field_(NULL) { |
| 4243 ASSERT(offset_in_bytes >= 0); | 4258 ASSERT(offset_in_bytes >= 0); |
| 4244 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance. | 4259 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance. |
| 4245 SetInputAt(0, instance); | 4260 SetInputAt(0, instance); |
| 4246 } | 4261 } |
| 4247 | 4262 |
| 4263 LoadFieldInstr(Value* instance, |
| 4264 const Field* field, |
| 4265 const AbstractType& type, |
| 4266 bool immutable = false) |
| 4267 : offset_in_bytes_(field->Offset()), |
| 4268 type_(type), |
| 4269 result_cid_(kDynamicCid), |
| 4270 immutable_(immutable), |
| 4271 recognized_kind_(MethodRecognizer::kUnknown), |
| 4272 field_(field) { |
| 4273 ASSERT(field->IsZoneHandle()); |
| 4274 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance. |
| 4275 SetInputAt(0, instance); |
| 4276 } |
| 4277 |
| 4248 Value* instance() const { return inputs_[0]; } | 4278 Value* instance() const { return inputs_[0]; } |
| 4249 intptr_t offset_in_bytes() const { return offset_in_bytes_; } | 4279 intptr_t offset_in_bytes() const { return offset_in_bytes_; } |
| 4250 const AbstractType& type() const { return type_; } | 4280 const AbstractType& type() const { return type_; } |
| 4251 void set_result_cid(intptr_t value) { result_cid_ = value; } | 4281 void set_result_cid(intptr_t value) { result_cid_ = value; } |
| 4252 intptr_t result_cid() const { return result_cid_; } | 4282 intptr_t result_cid() const { return result_cid_; } |
| 4253 | 4283 |
| 4254 const Field* field() const { return field_; } | 4284 const Field* field() const { return field_; } |
| 4255 void set_field(const Field* field) { field_ = field; } | |
| 4256 | 4285 |
| 4257 virtual Representation representation() const; | 4286 virtual Representation representation() const; |
| 4258 | 4287 |
| 4259 bool IsUnboxedLoad() const; | 4288 bool IsUnboxedLoad() const; |
| 4260 | 4289 |
| 4261 bool IsPotentialUnboxedLoad() const; | 4290 bool IsPotentialUnboxedLoad() const; |
| 4262 | 4291 |
| 4263 void set_recognized_kind(MethodRecognizer::Kind kind) { | 4292 void set_recognized_kind(MethodRecognizer::Kind kind) { |
| 4264 recognized_kind_ = kind; | 4293 recognized_kind_ = kind; |
| 4265 } | 4294 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4299 const bool immutable_; | 4328 const bool immutable_; |
| 4300 | 4329 |
| 4301 MethodRecognizer::Kind recognized_kind_; | 4330 MethodRecognizer::Kind recognized_kind_; |
| 4302 | 4331 |
| 4303 const Field* field_; | 4332 const Field* field_; |
| 4304 | 4333 |
| 4305 DISALLOW_COPY_AND_ASSIGN(LoadFieldInstr); | 4334 DISALLOW_COPY_AND_ASSIGN(LoadFieldInstr); |
| 4306 }; | 4335 }; |
| 4307 | 4336 |
| 4308 | 4337 |
| 4309 class StoreVMFieldInstr : public TemplateDefinition<2> { | |
| 4310 public: | |
| 4311 StoreVMFieldInstr(Value* dest, | |
| 4312 intptr_t offset_in_bytes, | |
| 4313 Value* value, | |
| 4314 const AbstractType& type) | |
| 4315 : offset_in_bytes_(offset_in_bytes), type_(type) { | |
| 4316 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance. | |
| 4317 SetInputAt(kValuePos, value); | |
| 4318 SetInputAt(kObjectPos, dest); | |
| 4319 } | |
| 4320 | |
| 4321 enum { | |
| 4322 kValuePos = 0, | |
| 4323 kObjectPos = 1 | |
| 4324 }; | |
| 4325 | |
| 4326 DECLARE_INSTRUCTION(StoreVMField) | |
| 4327 virtual CompileType* ComputeInitialType() const; | |
| 4328 | |
| 4329 Value* value() const { return inputs_[kValuePos]; } | |
| 4330 Value* dest() const { return inputs_[kObjectPos]; } | |
| 4331 intptr_t offset_in_bytes() const { return offset_in_bytes_; } | |
| 4332 const AbstractType& type() const { return type_; } | |
| 4333 | |
| 4334 virtual void PrintOperandsTo(BufferFormatter* f) const; | |
| 4335 | |
| 4336 virtual bool CanDeoptimize() const { return false; } | |
| 4337 | |
| 4338 virtual EffectSet Effects() const { return EffectSet::None(); } | |
| 4339 | |
| 4340 virtual bool MayThrow() const { return false; } | |
| 4341 | |
| 4342 private: | |
| 4343 const intptr_t offset_in_bytes_; | |
| 4344 const AbstractType& type_; | |
| 4345 | |
| 4346 DISALLOW_COPY_AND_ASSIGN(StoreVMFieldInstr); | |
| 4347 }; | |
| 4348 | |
| 4349 | |
| 4350 class InstantiateTypeInstr : public TemplateDefinition<1> { | 4338 class InstantiateTypeInstr : public TemplateDefinition<1> { |
| 4351 public: | 4339 public: |
| 4352 InstantiateTypeInstr(intptr_t token_pos, | 4340 InstantiateTypeInstr(intptr_t token_pos, |
| 4353 const AbstractType& type, | 4341 const AbstractType& type, |
| 4354 const Class& instantiator_class, | 4342 const Class& instantiator_class, |
| 4355 Value* instantiator) | 4343 Value* instantiator) |
| 4356 : token_pos_(token_pos), | 4344 : token_pos_(token_pos), |
| 4357 type_(type), | 4345 type_(type), |
| 4358 instantiator_class_(instantiator_class) { | 4346 instantiator_class_(instantiator_class) { |
| 4359 ASSERT(type.IsZoneHandle()); | 4347 ASSERT(type.IsZoneHandle()); |
| (...skipping 2850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7210 ForwardInstructionIterator* current_iterator_; | 7198 ForwardInstructionIterator* current_iterator_; |
| 7211 | 7199 |
| 7212 private: | 7200 private: |
| 7213 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 7201 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 7214 }; | 7202 }; |
| 7215 | 7203 |
| 7216 | 7204 |
| 7217 } // namespace dart | 7205 } // namespace dart |
| 7218 | 7206 |
| 7219 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 7207 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |