OLD | NEW |
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 3228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3239 }; | 3239 }; |
3240 | 3240 |
3241 | 3241 |
3242 class HConstant: public HTemplateInstruction<0> { | 3242 class HConstant: public HTemplateInstruction<0> { |
3243 public: | 3243 public: |
3244 HConstant(Handle<Object> handle, Representation r = Representation::None()); | 3244 HConstant(Handle<Object> handle, Representation r = Representation::None()); |
3245 HConstant(int32_t value, | 3245 HConstant(int32_t value, |
3246 Representation r = Representation::None(), | 3246 Representation r = Representation::None(), |
3247 bool is_not_in_new_space = true, | 3247 bool is_not_in_new_space = true, |
3248 Handle<Object> optional_handle = Handle<Object>::null()); | 3248 Handle<Object> optional_handle = Handle<Object>::null()); |
| 3249 |
3249 HConstant(double value, | 3250 HConstant(double value, |
3250 Representation r = Representation::None(), | 3251 Representation r = Representation::None(), |
3251 bool is_not_in_new_space = true, | 3252 bool is_not_in_new_space = true, |
3252 Handle<Object> optional_handle = Handle<Object>::null()); | 3253 Handle<Object> optional_handle = Handle<Object>::null()); |
| 3254 |
3253 HConstant(Handle<Object> handle, | 3255 HConstant(Handle<Object> handle, |
3254 UniqueValueId unique_id, | 3256 UniqueValueId unique_id, |
3255 Representation r, | 3257 Representation r, |
3256 HType type, | 3258 HType type, |
3257 bool is_internalized_string, | 3259 bool is_internalized_string, |
3258 bool is_not_in_new_space, | 3260 bool is_not_in_new_space, |
3259 bool boolean_value); | 3261 bool boolean_value); |
3260 | 3262 |
3261 Handle<Object> handle() { | 3263 Handle<Object> handle() { |
3262 if (handle_.is_null()) { | 3264 if (handle_.is_null()) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3297 ASSERT(unique_id_ != UniqueValueId(heap->minus_zero_value())); | 3299 ASSERT(unique_id_ != UniqueValueId(heap->minus_zero_value())); |
3298 ASSERT(unique_id_ != UniqueValueId(heap->nan_value())); | 3300 ASSERT(unique_id_ != UniqueValueId(heap->nan_value())); |
3299 return unique_id_ == UniqueValueId(heap->undefined_value()) || | 3301 return unique_id_ == UniqueValueId(heap->undefined_value()) || |
3300 unique_id_ == UniqueValueId(heap->null_value()) || | 3302 unique_id_ == UniqueValueId(heap->null_value()) || |
3301 unique_id_ == UniqueValueId(heap->true_value()) || | 3303 unique_id_ == UniqueValueId(heap->true_value()) || |
3302 unique_id_ == UniqueValueId(heap->false_value()) || | 3304 unique_id_ == UniqueValueId(heap->false_value()) || |
3303 unique_id_ == UniqueValueId(heap->the_hole_value()) || | 3305 unique_id_ == UniqueValueId(heap->the_hole_value()) || |
3304 unique_id_ == UniqueValueId(heap->empty_string()); | 3306 unique_id_ == UniqueValueId(heap->empty_string()); |
3305 } | 3307 } |
3306 | 3308 |
| 3309 bool IsCell() const { |
| 3310 return is_cell_; |
| 3311 } |
| 3312 |
3307 virtual Representation RequiredInputRepresentation(int index) { | 3313 virtual Representation RequiredInputRepresentation(int index) { |
3308 return Representation::None(); | 3314 return Representation::None(); |
3309 } | 3315 } |
3310 | 3316 |
3311 virtual Representation KnownOptimalRepresentation() { | 3317 virtual Representation KnownOptimalRepresentation() { |
3312 if (HasSmiValue()) return Representation::Smi(); | 3318 if (HasSmiValue()) return Representation::Smi(); |
3313 if (HasInteger32Value()) return Representation::Integer32(); | 3319 if (HasInteger32Value()) return Representation::Integer32(); |
3314 if (HasNumberValue()) return Representation::Double(); | 3320 if (HasNumberValue()) return Representation::Double(); |
3315 return Representation::Tagged(); | 3321 return Representation::Tagged(); |
3316 } | 3322 } |
3317 | 3323 |
3318 virtual bool EmitAtUses() { return !representation().IsDouble(); } | 3324 virtual bool EmitAtUses(); |
3319 virtual void PrintDataTo(StringStream* stream); | 3325 virtual void PrintDataTo(StringStream* stream); |
3320 virtual HType CalculateInferredType(); | 3326 virtual HType CalculateInferredType(); |
3321 bool IsInteger() { return handle()->IsSmi(); } | 3327 bool IsInteger() { return handle()->IsSmi(); } |
3322 HConstant* CopyToRepresentation(Representation r, Zone* zone) const; | 3328 HConstant* CopyToRepresentation(Representation r, Zone* zone) const; |
3323 HConstant* CopyToTruncatedInt32(Zone* zone) const; | 3329 HConstant* CopyToTruncatedInt32(Zone* zone) const; |
3324 bool HasInteger32Value() const { return has_int32_value_; } | 3330 bool HasInteger32Value() const { return has_int32_value_; } |
3325 int32_t Integer32Value() const { | 3331 int32_t Integer32Value() const { |
3326 ASSERT(HasInteger32Value()); | 3332 ASSERT(HasInteger32Value()); |
3327 return int32_value_; | 3333 return int32_value_; |
3328 } | 3334 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3423 // We store the HConstant in the most specific form safely possible. | 3429 // We store the HConstant in the most specific form safely possible. |
3424 // The two flags, has_int32_value_ and has_double_value_ tell us if | 3430 // The two flags, has_int32_value_ and has_double_value_ tell us if |
3425 // int32_value_ and double_value_ hold valid, safe representations | 3431 // int32_value_ and double_value_ hold valid, safe representations |
3426 // of the constant. has_int32_value_ implies has_double_value_ but | 3432 // of the constant. has_int32_value_ implies has_double_value_ but |
3427 // not the converse. | 3433 // not the converse. |
3428 bool has_smi_value_ : 1; | 3434 bool has_smi_value_ : 1; |
3429 bool has_int32_value_ : 1; | 3435 bool has_int32_value_ : 1; |
3430 bool has_double_value_ : 1; | 3436 bool has_double_value_ : 1; |
3431 bool is_internalized_string_ : 1; // TODO(yangguo): make this part of HType. | 3437 bool is_internalized_string_ : 1; // TODO(yangguo): make this part of HType. |
3432 bool is_not_in_new_space_ : 1; | 3438 bool is_not_in_new_space_ : 1; |
| 3439 bool is_cell_ : 1; |
3433 bool boolean_value_ : 1; | 3440 bool boolean_value_ : 1; |
3434 int32_t int32_value_; | 3441 int32_t int32_value_; |
3435 double double_value_; | 3442 double double_value_; |
3436 HType type_from_value_; | 3443 HType type_from_value_; |
3437 }; | 3444 }; |
3438 | 3445 |
3439 | 3446 |
3440 class HBinaryOperation: public HTemplateInstruction<3> { | 3447 class HBinaryOperation: public HTemplateInstruction<3> { |
3441 public: | 3448 public: |
3442 HBinaryOperation(HValue* context, HValue* left, HValue* right) | 3449 HBinaryOperation(HValue* context, HValue* left, HValue* right) |
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5050 } | 5057 } |
5051 | 5058 |
5052 | 5059 |
5053 inline bool ReceiverObjectNeedsWriteBarrier(HValue* object, | 5060 inline bool ReceiverObjectNeedsWriteBarrier(HValue* object, |
5054 HValue* new_space_dominator) { | 5061 HValue* new_space_dominator) { |
5055 if (object->IsInnerAllocatedObject()) { | 5062 if (object->IsInnerAllocatedObject()) { |
5056 return ReceiverObjectNeedsWriteBarrier( | 5063 return ReceiverObjectNeedsWriteBarrier( |
5057 HInnerAllocatedObject::cast(object)->base_object(), | 5064 HInnerAllocatedObject::cast(object)->base_object(), |
5058 new_space_dominator); | 5065 new_space_dominator); |
5059 } | 5066 } |
| 5067 if (object->IsConstant() && HConstant::cast(object)->IsCell()) { |
| 5068 return false; |
| 5069 } |
5060 if (object != new_space_dominator) return true; | 5070 if (object != new_space_dominator) return true; |
5061 if (object->IsAllocate()) { | 5071 if (object->IsAllocate()) { |
5062 return !HAllocate::cast(object)->GuaranteedInNewSpace(); | 5072 return !HAllocate::cast(object)->GuaranteedInNewSpace(); |
5063 } | 5073 } |
5064 return true; | 5074 return true; |
5065 } | 5075 } |
5066 | 5076 |
5067 | 5077 |
5068 class HStoreGlobalCell: public HUnaryOperation { | 5078 class HStoreGlobalCell: public HUnaryOperation { |
5069 public: | 5079 public: |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5310 // Create an access to an in-object property in a JSArray. | 5320 // Create an access to an in-object property in a JSArray. |
5311 static HObjectAccess ForJSArrayOffset(int offset); | 5321 static HObjectAccess ForJSArrayOffset(int offset); |
5312 | 5322 |
5313 // Create an access to the backing store of an object. | 5323 // Create an access to the backing store of an object. |
5314 static HObjectAccess ForBackingStoreOffset(int offset); | 5324 static HObjectAccess ForBackingStoreOffset(int offset); |
5315 | 5325 |
5316 // Create an access to a resolved field (in-object or backing store). | 5326 // Create an access to a resolved field (in-object or backing store). |
5317 static HObjectAccess ForField(Handle<Map> map, | 5327 static HObjectAccess ForField(Handle<Map> map, |
5318 LookupResult *lookup, Handle<String> name = Handle<String>::null()); | 5328 LookupResult *lookup, Handle<String> name = Handle<String>::null()); |
5319 | 5329 |
| 5330 // Create an access for the payload of a Cell or JSGlobalPropertyCell. |
| 5331 static HObjectAccess ForCellPayload(Isolate* isolate); |
| 5332 |
5320 void PrintTo(StringStream* stream); | 5333 void PrintTo(StringStream* stream); |
5321 | 5334 |
5322 inline bool Equals(HObjectAccess that) const { | 5335 inline bool Equals(HObjectAccess that) const { |
5323 return value_ == that.value_; // portion and offset must match | 5336 return value_ == that.value_; // portion and offset must match |
5324 } | 5337 } |
5325 | 5338 |
5326 protected: | 5339 protected: |
5327 void SetGVNFlags(HValue *instr, bool is_store); | 5340 void SetGVNFlags(HValue *instr, bool is_store); |
5328 | 5341 |
5329 private: | 5342 private: |
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6608 virtual bool IsDeletable() const { return true; } | 6621 virtual bool IsDeletable() const { return true; } |
6609 }; | 6622 }; |
6610 | 6623 |
6611 | 6624 |
6612 #undef DECLARE_INSTRUCTION | 6625 #undef DECLARE_INSTRUCTION |
6613 #undef DECLARE_CONCRETE_INSTRUCTION | 6626 #undef DECLARE_CONCRETE_INSTRUCTION |
6614 | 6627 |
6615 } } // namespace v8::internal | 6628 } } // namespace v8::internal |
6616 | 6629 |
6617 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6630 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |