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

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

Issue 7778013: NewGC: Merge bleeding edge up to 9009. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 3 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 | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 V(CompareObjectEqAndBranch) \ 97 V(CompareObjectEqAndBranch) \
98 V(CompareMap) \ 98 V(CompareMap) \
99 V(CompareConstantEqAndBranch) \ 99 V(CompareConstantEqAndBranch) \
100 V(Constant) \ 100 V(Constant) \
101 V(Context) \ 101 V(Context) \
102 V(DeleteProperty) \ 102 V(DeleteProperty) \
103 V(Deoptimize) \ 103 V(Deoptimize) \
104 V(Div) \ 104 V(Div) \
105 V(ElementsKind) \ 105 V(ElementsKind) \
106 V(EnterInlined) \ 106 V(EnterInlined) \
107 V(ExternalArrayLength) \ 107 V(FixedArrayBaseLength) \
108 V(FixedArrayLength) \
109 V(ForceRepresentation) \ 108 V(ForceRepresentation) \
110 V(FunctionLiteral) \ 109 V(FunctionLiteral) \
111 V(GetCachedArrayIndex) \ 110 V(GetCachedArrayIndex) \
112 V(GlobalObject) \ 111 V(GlobalObject) \
113 V(GlobalReceiver) \ 112 V(GlobalReceiver) \
114 V(Goto) \ 113 V(Goto) \
115 V(HasCachedArrayIndexAndBranch) \ 114 V(HasCachedArrayIndexAndBranch) \
116 V(HasInstanceTypeAndBranch) \ 115 V(HasInstanceTypeAndBranch) \
117 V(In) \ 116 V(In) \
118 V(InstanceOf) \ 117 V(InstanceOf) \
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 : lower_(lower), 220 : lower_(lower),
222 upper_(upper), 221 upper_(upper),
223 next_(NULL), 222 next_(NULL),
224 can_be_minus_zero_(false) { } 223 can_be_minus_zero_(false) { }
225 224
226 int32_t upper() const { return upper_; } 225 int32_t upper() const { return upper_; }
227 int32_t lower() const { return lower_; } 226 int32_t lower() const { return lower_; }
228 Range* next() const { return next_; } 227 Range* next() const { return next_; }
229 Range* CopyClearLower() const { return new Range(kMinInt, upper_); } 228 Range* CopyClearLower() const { return new Range(kMinInt, upper_); }
230 Range* CopyClearUpper() const { return new Range(lower_, kMaxInt); } 229 Range* CopyClearUpper() const { return new Range(lower_, kMaxInt); }
231 Range* Copy() const { return new Range(lower_, upper_); } 230 Range* Copy() const {
231 Range* result = new Range(lower_, upper_);
232 result->set_can_be_minus_zero(CanBeMinusZero());
233 return result;
234 }
232 int32_t Mask() const; 235 int32_t Mask() const;
233 void set_can_be_minus_zero(bool b) { can_be_minus_zero_ = b; } 236 void set_can_be_minus_zero(bool b) { can_be_minus_zero_ = b; }
234 bool CanBeMinusZero() const { return CanBeZero() && can_be_minus_zero_; } 237 bool CanBeMinusZero() const { return CanBeZero() && can_be_minus_zero_; }
235 bool CanBeZero() const { return upper_ >= 0 && lower_ <= 0; } 238 bool CanBeZero() const { return upper_ >= 0 && lower_ <= 0; }
236 bool CanBeNegative() const { return lower_ < 0; } 239 bool CanBeNegative() const { return lower_ < 0; }
237 bool Includes(int value) const { return lower_ <= value && upper_ >= value; } 240 bool Includes(int value) const { return lower_ <= value && upper_ >= value; }
238 bool IsMostGeneric() const { return lower_ == kMinInt && upper_ == kMaxInt; } 241 bool IsMostGeneric() const {
242 return lower_ == kMinInt && upper_ == kMaxInt && CanBeMinusZero();
243 }
239 bool IsInSmiRange() const { 244 bool IsInSmiRange() const {
240 return lower_ >= Smi::kMinValue && upper_ <= Smi::kMaxValue; 245 return lower_ >= Smi::kMinValue && upper_ <= Smi::kMaxValue;
241 } 246 }
242 void KeepOrder(); 247 void KeepOrder();
243 void Verify() const; 248 void Verify() const;
244 249
245 void StackUpon(Range* other) { 250 void StackUpon(Range* other) {
246 Intersect(other); 251 Intersect(other);
247 next_ = other; 252 next_ = other;
248 } 253 }
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 ASSERT(!r.IsNone()); 577 ASSERT(!r.IsNone());
573 ASSERT(CheckFlag(kFlexibleRepresentation)); 578 ASSERT(CheckFlag(kFlexibleRepresentation));
574 RepresentationChanged(r); 579 RepresentationChanged(r);
575 representation_ = r; 580 representation_ = r;
576 } 581 }
577 void AssumeRepresentation(Representation r); 582 void AssumeRepresentation(Representation r);
578 583
579 virtual bool IsConvertibleToInteger() const { return true; } 584 virtual bool IsConvertibleToInteger() const { return true; }
580 585
581 HType type() const { return type_; } 586 HType type() const { return type_; }
582 void set_type(HType type) { 587 void set_type(HType new_type) {
583 ASSERT(HasNoUses()); 588 ASSERT(new_type.IsSubtypeOf(type_));
584 type_ = type; 589 type_ = new_type;
585 } 590 }
586 591
587 // An operation needs to override this function iff: 592 // An operation needs to override this function iff:
588 // 1) it can produce an int32 output. 593 // 1) it can produce an int32 output.
589 // 2) the true value of its output can potentially be minus zero. 594 // 2) the true value of its output can potentially be minus zero.
590 // The implementation must set a flag so that it bails out in the case where 595 // The implementation must set a flag so that it bails out in the case where
591 // it would otherwise output what should be a minus zero as an int32 zero. 596 // it would otherwise output what should be a minus zero as an int32 zero.
592 // If the operation also exists in a form that takes int32 and outputs int32 597 // If the operation also exists in a form that takes int32 and outputs int32
593 // then the operation should return its input value so that we can propagate 598 // then the operation should return its input value so that we can propagate
594 // back. There are three operations that need to propagate back to more than 599 // back. There are three operations that need to propagate back to more than
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 bool is_truncating, 1099 bool is_truncating,
1095 bool deoptimize_on_undefined) 1100 bool deoptimize_on_undefined)
1096 : HUnaryOperation(value), 1101 : HUnaryOperation(value),
1097 from_(from), 1102 from_(from),
1098 deoptimize_on_undefined_(deoptimize_on_undefined) { 1103 deoptimize_on_undefined_(deoptimize_on_undefined) {
1099 ASSERT(!from.IsNone() && !to.IsNone()); 1104 ASSERT(!from.IsNone() && !to.IsNone());
1100 ASSERT(!from.Equals(to)); 1105 ASSERT(!from.Equals(to));
1101 set_representation(to); 1106 set_representation(to);
1102 SetFlag(kUseGVN); 1107 SetFlag(kUseGVN);
1103 if (is_truncating) SetFlag(kTruncatingToInt32); 1108 if (is_truncating) SetFlag(kTruncatingToInt32);
1104 if (from.IsInteger32() && to.IsTagged() && value->range() != NULL &&
1105 value->range()->IsInSmiRange()) {
1106 set_type(HType::Smi());
1107 }
1108 } 1109 }
1109 1110
1110 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 1111 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
1111 1112
1112 Representation from() const { return from_; } 1113 Representation from() const { return from_; }
1113 Representation to() const { return representation(); } 1114 Representation to() const { return representation(); }
1114 bool deoptimize_on_undefined() const { return deoptimize_on_undefined_; } 1115 bool deoptimize_on_undefined() const { return deoptimize_on_undefined_; }
1115 virtual Representation RequiredInputRepresentation(int index) const { 1116 virtual Representation RequiredInputRepresentation(int index) const {
1116 return from_; 1117 return from_;
1117 } 1118 }
1118 1119
1120 virtual Range* InferRange();
1121
1119 virtual void PrintDataTo(StringStream* stream); 1122 virtual void PrintDataTo(StringStream* stream);
1120 1123
1121 DECLARE_CONCRETE_INSTRUCTION(Change) 1124 DECLARE_CONCRETE_INSTRUCTION(Change)
1122 1125
1123 protected: 1126 protected:
1124 virtual bool DataEquals(HValue* other) { 1127 virtual bool DataEquals(HValue* other) {
1125 if (!other->IsChange()) return false; 1128 if (!other->IsChange()) return false;
1126 HChange* change = HChange::cast(other); 1129 HChange* change = HChange::cast(other);
1127 return to().Equals(change->to()) 1130 return to().Equals(change->to())
1128 && deoptimize_on_undefined() == change->deoptimize_on_undefined(); 1131 && deoptimize_on_undefined() == change->deoptimize_on_undefined();
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 1698
1696 HValue* value() { return OperandAt(0); } 1699 HValue* value() { return OperandAt(0); }
1697 1700
1698 DECLARE_CONCRETE_INSTRUCTION(JSArrayLength) 1701 DECLARE_CONCRETE_INSTRUCTION(JSArrayLength)
1699 1702
1700 protected: 1703 protected:
1701 virtual bool DataEquals(HValue* other) { return true; } 1704 virtual bool DataEquals(HValue* other) { return true; }
1702 }; 1705 };
1703 1706
1704 1707
1705 class HFixedArrayLength: public HUnaryOperation { 1708 class HFixedArrayBaseLength: public HUnaryOperation {
1706 public: 1709 public:
1707 explicit HFixedArrayLength(HValue* value) : HUnaryOperation(value) { 1710 explicit HFixedArrayBaseLength(HValue* value) : HUnaryOperation(value) {
1708 set_representation(Representation::Tagged()); 1711 set_representation(Representation::Tagged());
1709 SetFlag(kUseGVN); 1712 SetFlag(kUseGVN);
1710 SetFlag(kDependsOnArrayLengths); 1713 SetFlag(kDependsOnArrayLengths);
1711 } 1714 }
1712 1715
1713 virtual Representation RequiredInputRepresentation(int index) const { 1716 virtual Representation RequiredInputRepresentation(int index) const {
1714 return Representation::Tagged(); 1717 return Representation::Tagged();
1715 } 1718 }
1716 1719
1717 DECLARE_CONCRETE_INSTRUCTION(FixedArrayLength) 1720 DECLARE_CONCRETE_INSTRUCTION(FixedArrayBaseLength)
1718
1719 protected:
1720 virtual bool DataEquals(HValue* other) { return true; }
1721 };
1722
1723
1724 class HExternalArrayLength: public HUnaryOperation {
1725 public:
1726 explicit HExternalArrayLength(HValue* value) : HUnaryOperation(value) {
1727 set_representation(Representation::Integer32());
1728 // The result of this instruction is idempotent as long as its inputs don't
1729 // change. The length of a pixel array cannot change once set, so it's not
1730 // necessary to introduce a kDependsOnArrayLengths or any other dependency.
1731 SetFlag(kUseGVN);
1732 }
1733
1734 virtual Representation RequiredInputRepresentation(int index) const {
1735 return Representation::Tagged();
1736 }
1737
1738 DECLARE_CONCRETE_INSTRUCTION(ExternalArrayLength)
1739 1721
1740 protected: 1722 protected:
1741 virtual bool DataEquals(HValue* other) { return true; } 1723 virtual bool DataEquals(HValue* other) { return true; }
1742 }; 1724 };
1743 1725
1744 1726
1745 class HElementsKind: public HUnaryOperation { 1727 class HElementsKind: public HUnaryOperation {
1746 public: 1728 public:
1747 explicit HElementsKind(HValue* value) : HUnaryOperation(value) { 1729 explicit HElementsKind(HValue* value) : HUnaryOperation(value) {
1748 set_representation(Representation::Integer32()); 1730 set_representation(Representation::Integer32());
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
2464 SetOperandAt(0, index); 2446 SetOperandAt(0, index);
2465 SetOperandAt(1, length); 2447 SetOperandAt(1, length);
2466 set_representation(Representation::Integer32()); 2448 set_representation(Representation::Integer32());
2467 SetFlag(kUseGVN); 2449 SetFlag(kUseGVN);
2468 } 2450 }
2469 2451
2470 virtual Representation RequiredInputRepresentation(int index) const { 2452 virtual Representation RequiredInputRepresentation(int index) const {
2471 return Representation::Integer32(); 2453 return Representation::Integer32();
2472 } 2454 }
2473 2455
2456 virtual void PrintDataTo(StringStream* stream);
2457
2474 HValue* index() { return OperandAt(0); } 2458 HValue* index() { return OperandAt(0); }
2475 HValue* length() { return OperandAt(1); } 2459 HValue* length() { return OperandAt(1); }
2476 2460
2477 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck) 2461 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck)
2478 2462
2479 protected: 2463 protected:
2480 virtual bool DataEquals(HValue* other) { return true; } 2464 virtual bool DataEquals(HValue* other) { return true; }
2481 }; 2465 };
2482 2466
2483 2467
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
3419 private: 3403 private:
3420 bool is_in_object_; 3404 bool is_in_object_;
3421 int offset_; 3405 int offset_;
3422 }; 3406 };
3423 3407
3424 3408
3425 class HLoadNamedFieldPolymorphic: public HTemplateInstruction<2> { 3409 class HLoadNamedFieldPolymorphic: public HTemplateInstruction<2> {
3426 public: 3410 public:
3427 HLoadNamedFieldPolymorphic(HValue* context, 3411 HLoadNamedFieldPolymorphic(HValue* context,
3428 HValue* object, 3412 HValue* object,
3429 ZoneMapList* types, 3413 SmallMapList* types,
3430 Handle<String> name); 3414 Handle<String> name);
3431 3415
3432 HValue* context() { return OperandAt(0); } 3416 HValue* context() { return OperandAt(0); }
3433 HValue* object() { return OperandAt(1); } 3417 HValue* object() { return OperandAt(1); }
3434 ZoneMapList* types() { return &types_; } 3418 SmallMapList* types() { return &types_; }
3435 Handle<String> name() { return name_; } 3419 Handle<String> name() { return name_; }
3436 bool need_generic() { return need_generic_; } 3420 bool need_generic() { return need_generic_; }
3437 3421
3438 virtual Representation RequiredInputRepresentation(int index) const { 3422 virtual Representation RequiredInputRepresentation(int index) const {
3439 return Representation::Tagged(); 3423 return Representation::Tagged();
3440 } 3424 }
3441 3425
3426 virtual void PrintDataTo(StringStream* stream);
3427
3442 DECLARE_CONCRETE_INSTRUCTION(LoadNamedFieldPolymorphic) 3428 DECLARE_CONCRETE_INSTRUCTION(LoadNamedFieldPolymorphic)
3443 3429
3444 static const int kMaxLoadPolymorphism = 4; 3430 static const int kMaxLoadPolymorphism = 4;
3445 3431
3446 protected: 3432 protected:
3447 virtual bool DataEquals(HValue* value); 3433 virtual bool DataEquals(HValue* value);
3448 3434
3449 private: 3435 private:
3450 ZoneMapList types_; 3436 SmallMapList types_;
3451 Handle<String> name_; 3437 Handle<String> name_;
3452 bool need_generic_; 3438 bool need_generic_;
3453 }; 3439 };
3454 3440
3455 3441
3456 3442
3457 class HLoadNamedGeneric: public HTemplateInstruction<2> { 3443 class HLoadNamedGeneric: public HTemplateInstruction<2> {
3458 public: 3444 public:
3459 HLoadNamedGeneric(HValue* context, HValue* object, Handle<Object> name) 3445 HLoadNamedGeneric(HValue* context, HValue* object, Handle<Object> name)
3460 : name_(name) { 3446 : name_(name) {
3461 SetOperandAt(0, context); 3447 SetOperandAt(0, context);
3462 SetOperandAt(1, object); 3448 SetOperandAt(1, object);
3463 set_representation(Representation::Tagged()); 3449 set_representation(Representation::Tagged());
3464 SetAllSideEffects(); 3450 SetAllSideEffects();
3465 } 3451 }
3466 3452
3467 HValue* context() { return OperandAt(0); } 3453 HValue* context() { return OperandAt(0); }
3468 HValue* object() { return OperandAt(1); } 3454 HValue* object() { return OperandAt(1); }
3469 Handle<Object> name() const { return name_; } 3455 Handle<Object> name() const { return name_; }
3470 3456
3471 virtual Representation RequiredInputRepresentation(int index) const { 3457 virtual Representation RequiredInputRepresentation(int index) const {
3472 return Representation::Tagged(); 3458 return Representation::Tagged();
3473 } 3459 }
3474 3460
3461 virtual void PrintDataTo(StringStream* stream);
3462
3475 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric) 3463 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric)
3476 3464
3477 private: 3465 private:
3478 Handle<Object> name_; 3466 Handle<Object> name_;
3479 }; 3467 };
3480 3468
3481 3469
3482 class HLoadFunctionPrototype: public HUnaryOperation { 3470 class HLoadFunctionPrototype: public HUnaryOperation {
3483 public: 3471 public:
3484 explicit HLoadFunctionPrototype(HValue* function) 3472 explicit HLoadFunctionPrototype(HValue* function)
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
4204 4192
4205 DECLARE_CONCRETE_INSTRUCTION(In) 4193 DECLARE_CONCRETE_INSTRUCTION(In)
4206 }; 4194 };
4207 4195
4208 #undef DECLARE_INSTRUCTION 4196 #undef DECLARE_INSTRUCTION
4209 #undef DECLARE_CONCRETE_INSTRUCTION 4197 #undef DECLARE_CONCRETE_INSTRUCTION
4210 4198
4211 } } // namespace v8::internal 4199 } } // namespace v8::internal
4212 4200
4213 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 4201 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698