Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: src/hydrogen-instructions.h

Issue 26712002: Only set binary operation side effects flags, when observable. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix the gvn flags Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-binop.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 3929 matching lines...) Expand 10 before | Expand all | Expand 10 after
3940 HBitwiseBinaryOperation(HValue* context, HValue* left, HValue* right, 3940 HBitwiseBinaryOperation(HValue* context, HValue* left, HValue* right,
3941 HType type = HType::Tagged()) 3941 HType type = HType::Tagged())
3942 : HBinaryOperation(context, left, right, type) { 3942 : HBinaryOperation(context, left, right, type) {
3943 SetFlag(kFlexibleRepresentation); 3943 SetFlag(kFlexibleRepresentation);
3944 SetFlag(kTruncatingToInt32); 3944 SetFlag(kTruncatingToInt32);
3945 SetFlag(kAllowUndefinedAsNaN); 3945 SetFlag(kAllowUndefinedAsNaN);
3946 SetAllSideEffects(); 3946 SetAllSideEffects();
3947 } 3947 }
3948 3948
3949 virtual void RepresentationChanged(Representation to) V8_OVERRIDE { 3949 virtual void RepresentationChanged(Representation to) V8_OVERRIDE {
3950 if (to.IsTagged()) { 3950 if (to.IsTagged()) SetGVNFlag(kChangesNewSpacePromotion);
3951 if (to.IsTagged() &&
3952 (left()->ToNumberCanBeObserved() || right()->ToNumberCanBeObserved())) {
3951 SetAllSideEffects(); 3953 SetAllSideEffects();
3952 ClearFlag(kUseGVN); 3954 ClearFlag(kUseGVN);
3953 } else { 3955 } else {
3954 ASSERT(to.IsSmiOrInteger32());
3955 ClearAllSideEffects(); 3956 ClearAllSideEffects();
3956 SetFlag(kUseGVN); 3957 SetFlag(kUseGVN);
3957 } 3958 }
3958 } 3959 }
3959 3960
3960 virtual void UpdateRepresentation(Representation new_rep, 3961 virtual void UpdateRepresentation(Representation new_rep,
3961 HInferRepresentationPhase* h_infer, 3962 HInferRepresentationPhase* h_infer,
3962 const char* reason) V8_OVERRIDE { 3963 const char* reason) V8_OVERRIDE {
3963 // We only generate either int32 or generic tagged bitwise operations. 3964 // We only generate either int32 or generic tagged bitwise operations.
3964 if (new_rep.IsDouble()) new_rep = Representation::Integer32(); 3965 if (new_rep.IsDouble()) new_rep = Representation::Integer32();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
4016 class HArithmeticBinaryOperation : public HBinaryOperation { 4017 class HArithmeticBinaryOperation : public HBinaryOperation {
4017 public: 4018 public:
4018 HArithmeticBinaryOperation(HValue* context, HValue* left, HValue* right) 4019 HArithmeticBinaryOperation(HValue* context, HValue* left, HValue* right)
4019 : HBinaryOperation(context, left, right, HType::TaggedNumber()) { 4020 : HBinaryOperation(context, left, right, HType::TaggedNumber()) {
4020 SetAllSideEffects(); 4021 SetAllSideEffects();
4021 SetFlag(kFlexibleRepresentation); 4022 SetFlag(kFlexibleRepresentation);
4022 SetFlag(kAllowUndefinedAsNaN); 4023 SetFlag(kAllowUndefinedAsNaN);
4023 } 4024 }
4024 4025
4025 virtual void RepresentationChanged(Representation to) V8_OVERRIDE { 4026 virtual void RepresentationChanged(Representation to) V8_OVERRIDE {
4026 if (to.IsTagged()) { 4027 if (to.IsTagged()) SetGVNFlag(kChangesNewSpacePromotion);
4028 if (to.IsTagged() &&
4029 (left()->ToNumberCanBeObserved() || right()->ToNumberCanBeObserved())) {
4027 SetAllSideEffects(); 4030 SetAllSideEffects();
4028 ClearFlag(kUseGVN); 4031 ClearFlag(kUseGVN);
4029 } else { 4032 } else {
4030 ClearAllSideEffects(); 4033 ClearAllSideEffects();
4031 SetFlag(kUseGVN); 4034 SetFlag(kUseGVN);
4032 } 4035 }
4033 } 4036 }
4034 4037
4035 DECLARE_ABSTRACT_INSTRUCTION(ArithmeticBinaryOperation) 4038 DECLARE_ABSTRACT_INSTRUCTION(ArithmeticBinaryOperation)
4036 private: 4039 private:
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
4555 return true; 4558 return true;
4556 } else if (right()->IsInteger32Constant()) { 4559 } else if (right()->IsInteger32Constant()) {
4557 decomposition->Apply(left(), right()->GetInteger32Constant()); 4560 decomposition->Apply(left(), right()->GetInteger32Constant());
4558 return true; 4561 return true;
4559 } else { 4562 } else {
4560 return false; 4563 return false;
4561 } 4564 }
4562 } 4565 }
4563 4566
4564 virtual void RepresentationChanged(Representation to) V8_OVERRIDE { 4567 virtual void RepresentationChanged(Representation to) V8_OVERRIDE {
4565 if (to.IsTagged()) ClearFlag(kAllowUndefinedAsNaN); 4568 if (to.IsTagged()) {
4566 HArithmeticBinaryOperation::RepresentationChanged(to); 4569 SetGVNFlag(kChangesNewSpacePromotion);
4570 ClearFlag(kAllowUndefinedAsNaN);
4571 }
4572 if (to.IsTagged() &&
4573 (left()->ToNumberCanBeObserved() || right()->ToNumberCanBeObserved() ||
4574 left()->ToStringCanBeObserved() || right()->ToStringCanBeObserved())) {
4575 SetAllSideEffects();
4576 ClearFlag(kUseGVN);
4577 } else {
4578 ClearAllSideEffects();
4579 SetFlag(kUseGVN);
4580 }
4567 } 4581 }
4568 4582
4569 DECLARE_CONCRETE_INSTRUCTION(Add) 4583 DECLARE_CONCRETE_INSTRUCTION(Add)
4570 4584
4571 protected: 4585 protected:
4572 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; } 4586 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
4573 4587
4574 virtual Range* InferRange(Zone* zone) V8_OVERRIDE; 4588 virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
4575 4589
4576 private: 4590 private:
(...skipping 2048 matching lines...) Expand 10 before | Expand all | Expand 10 after
6625 6639
6626 DECLARE_CONCRETE_INSTRUCTION(StringAdd) 6640 DECLARE_CONCRETE_INSTRUCTION(StringAdd)
6627 6641
6628 protected: 6642 protected:
6629 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; } 6643 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
6630 6644
6631 private: 6645 private:
6632 HStringAdd(HValue* context, HValue* left, HValue* right, StringAddFlags flags) 6646 HStringAdd(HValue* context, HValue* left, HValue* right, StringAddFlags flags)
6633 : HBinaryOperation(context, left, right, HType::String()), flags_(flags) { 6647 : HBinaryOperation(context, left, right, HType::String()), flags_(flags) {
6634 set_representation(Representation::Tagged()); 6648 set_representation(Representation::Tagged());
6635 if (flags_ == STRING_ADD_CHECK_NONE) { 6649 if (MightHaveSideEffects()) {
6650 SetAllSideEffects();
6651 } else {
6636 SetFlag(kUseGVN); 6652 SetFlag(kUseGVN);
6637 SetGVNFlag(kDependsOnMaps); 6653 SetGVNFlag(kDependsOnMaps);
6638 SetGVNFlag(kChangesNewSpacePromotion); 6654 SetGVNFlag(kChangesNewSpacePromotion);
6639 } else {
6640 SetAllSideEffects();
6641 } 6655 }
6642 } 6656 }
6643 6657
6658 bool MightHaveSideEffects() const {
6659 return flags_ != STRING_ADD_CHECK_NONE &&
6660 (left()->ToStringCanBeObserved() || right()->ToStringCanBeObserved());
6661 }
6662
6644 // No side-effects except possible allocation: 6663 // No side-effects except possible allocation:
6645 // NOTE: this instruction does not call ToString() on its inputs, when flags_ 6664 // NOTE: this instruction does not call ToString() on its inputs, when flags_
6646 // is set to STRING_ADD_CHECK_NONE. 6665 // is set to STRING_ADD_CHECK_NONE.
6647 virtual bool IsDeletable() const V8_OVERRIDE { 6666 virtual bool IsDeletable() const V8_OVERRIDE {
6648 return flags_ == STRING_ADD_CHECK_NONE; 6667 return !MightHaveSideEffects();
6649 } 6668 }
6650 6669
6651 const StringAddFlags flags_; 6670 const StringAddFlags flags_;
6652 }; 6671 };
6653 6672
6654 6673
6655 class HStringCharCodeAt V8_FINAL : public HTemplateInstruction<3> { 6674 class HStringCharCodeAt V8_FINAL : public HTemplateInstruction<3> {
6656 public: 6675 public:
6657 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P2(HStringCharCodeAt, 6676 DECLARE_INSTRUCTION_WITH_CONTEXT_FACTORY_P2(HStringCharCodeAt,
6658 HValue*, 6677 HValue*,
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
7119 virtual bool IsDeletable() const V8_OVERRIDE { return true; } 7138 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
7120 }; 7139 };
7121 7140
7122 7141
7123 #undef DECLARE_INSTRUCTION 7142 #undef DECLARE_INSTRUCTION
7124 #undef DECLARE_CONCRETE_INSTRUCTION 7143 #undef DECLARE_CONCRETE_INSTRUCTION
7125 7144
7126 } } // namespace v8::internal 7145 } } // namespace v8::internal
7127 7146
7128 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 7147 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-binop.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698