| 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 3168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3179 private: | 3179 private: |
| 3180 virtual bool IsDeletable() const { return true; } | 3180 virtual bool IsDeletable() const { return true; } |
| 3181 }; | 3181 }; |
| 3182 | 3182 |
| 3183 | 3183 |
| 3184 class HConstant: public HTemplateInstruction<0> { | 3184 class HConstant: public HTemplateInstruction<0> { |
| 3185 public: | 3185 public: |
| 3186 HConstant(Handle<Object> handle, Representation r); | 3186 HConstant(Handle<Object> handle, Representation r); |
| 3187 HConstant(int32_t value, | 3187 HConstant(int32_t value, |
| 3188 Representation r, | 3188 Representation r, |
| 3189 bool is_not_in_new_space = true, |
| 3189 Handle<Object> optional_handle = Handle<Object>::null()); | 3190 Handle<Object> optional_handle = Handle<Object>::null()); |
| 3190 HConstant(double value, | 3191 HConstant(double value, |
| 3191 Representation r, | 3192 Representation r, |
| 3193 bool is_not_in_new_space = true, |
| 3192 Handle<Object> optional_handle = Handle<Object>::null()); | 3194 Handle<Object> optional_handle = Handle<Object>::null()); |
| 3193 HConstant(Handle<Object> handle, | 3195 HConstant(Handle<Object> handle, |
| 3194 UniqueValueId unique_id, | 3196 UniqueValueId unique_id, |
| 3195 Representation r, | 3197 Representation r, |
| 3196 HType type, | 3198 HType type, |
| 3197 bool is_internalized_string, | 3199 bool is_internalized_string, |
| 3200 bool is_not_in_new_space, |
| 3198 bool boolean_value); | 3201 bool boolean_value); |
| 3199 | 3202 |
| 3200 Handle<Object> handle() { | 3203 Handle<Object> handle() { |
| 3201 if (handle_.is_null()) { | 3204 if (handle_.is_null()) { |
| 3202 handle_ = FACTORY->NewNumber(double_value_, pretenure()); | 3205 // Default arguments to is_not_in_new_space depend on this heap number |
| 3206 // to be tenured so that it's guaranteed not be be located in new space. |
| 3207 handle_ = FACTORY->NewNumber(double_value_, TENURED); |
| 3203 } | 3208 } |
| 3204 ALLOW_HANDLE_DEREF(Isolate::Current(), "smi check"); | 3209 ALLOW_HANDLE_DEREF(Isolate::Current(), "smi check"); |
| 3205 ASSERT(has_int32_value_ || !handle_->IsSmi()); | 3210 ASSERT(has_int32_value_ || !handle_->IsSmi()); |
| 3206 return handle_; | 3211 return handle_; |
| 3207 } | 3212 } |
| 3208 | 3213 |
| 3209 bool IsSpecialDouble() const { | 3214 bool IsSpecialDouble() const { |
| 3210 return has_double_value_ && | 3215 return has_double_value_ && |
| 3211 (BitCast<int64_t>(double_value_) == BitCast<int64_t>(-0.0) || | 3216 (BitCast<int64_t>(double_value_) == BitCast<int64_t>(-0.0) || |
| 3212 FixedDoubleArray::is_the_hole_nan(double_value_) || | 3217 FixedDoubleArray::is_the_hole_nan(double_value_) || |
| 3213 std::isnan(double_value_)); | 3218 std::isnan(double_value_)); |
| 3214 } | 3219 } |
| 3215 | 3220 |
| 3216 bool InNewSpace() const { | 3221 bool NotInNewSpace() const { |
| 3217 if (!handle_.is_null()) { | 3222 return is_not_in_new_space_; |
| 3218 ALLOW_HANDLE_DEREF(isolate(), "using raw address"); | |
| 3219 return isolate()->heap()->InNewSpace(*handle_); | |
| 3220 } | |
| 3221 // If the handle wasn't created yet, then we have a number. | |
| 3222 // If the handle is created it'll be tenured in old space. | |
| 3223 ASSERT(pretenure() == TENURED); | |
| 3224 return false; | |
| 3225 } | 3223 } |
| 3226 | 3224 |
| 3227 bool ImmortalImmovable() const { | 3225 bool ImmortalImmovable() const { |
| 3228 if (has_int32_value_) { | 3226 if (has_int32_value_) { |
| 3229 return false; | 3227 return false; |
| 3230 } | 3228 } |
| 3231 if (has_double_value_) { | 3229 if (has_double_value_) { |
| 3232 if (IsSpecialDouble()) { | 3230 if (IsSpecialDouble()) { |
| 3233 return true; | 3231 return true; |
| 3234 } | 3232 } |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3352 | 3350 |
| 3353 private: | 3351 private: |
| 3354 void Initialize(Representation r); | 3352 void Initialize(Representation r); |
| 3355 | 3353 |
| 3356 virtual bool IsDeletable() const { return true; } | 3354 virtual bool IsDeletable() const { return true; } |
| 3357 | 3355 |
| 3358 // If this is a numerical constant, handle_ either points to to the | 3356 // If this is a numerical constant, handle_ either points to to the |
| 3359 // HeapObject the constant originated from or is null. If the | 3357 // HeapObject the constant originated from or is null. If the |
| 3360 // constant is non-numeric, handle_ always points to a valid | 3358 // constant is non-numeric, handle_ always points to a valid |
| 3361 // constant HeapObject. | 3359 // constant HeapObject. |
| 3362 static PretenureFlag pretenure() { return TENURED; } | |
| 3363 | |
| 3364 Handle<Object> handle_; | 3360 Handle<Object> handle_; |
| 3365 UniqueValueId unique_id_; | 3361 UniqueValueId unique_id_; |
| 3366 | 3362 |
| 3367 // We store the HConstant in the most specific form safely possible. | 3363 // We store the HConstant in the most specific form safely possible. |
| 3368 // The two flags, has_int32_value_ and has_double_value_ tell us if | 3364 // The two flags, has_int32_value_ and has_double_value_ tell us if |
| 3369 // int32_value_ and double_value_ hold valid, safe representations | 3365 // int32_value_ and double_value_ hold valid, safe representations |
| 3370 // of the constant. has_int32_value_ implies has_double_value_ but | 3366 // of the constant. has_int32_value_ implies has_double_value_ but |
| 3371 // not the converse. | 3367 // not the converse. |
| 3372 bool has_int32_value_ : 1; | 3368 bool has_int32_value_ : 1; |
| 3373 bool has_double_value_ : 1; | 3369 bool has_double_value_ : 1; |
| 3374 bool is_internalized_string_ : 1; // TODO(yangguo): make this part of HType. | 3370 bool is_internalized_string_ : 1; // TODO(yangguo): make this part of HType. |
| 3371 bool is_not_in_new_space_ : 1; |
| 3375 bool boolean_value_ : 1; | 3372 bool boolean_value_ : 1; |
| 3376 int32_t int32_value_; | 3373 int32_t int32_value_; |
| 3377 double double_value_; | 3374 double double_value_; |
| 3378 HType type_from_value_; | 3375 HType type_from_value_; |
| 3379 }; | 3376 }; |
| 3380 | 3377 |
| 3381 | 3378 |
| 3382 class HBinaryOperation: public HTemplateInstruction<3> { | 3379 class HBinaryOperation: public HTemplateInstruction<3> { |
| 3383 public: | 3380 public: |
| 3384 HBinaryOperation(HValue* context, HValue* left, HValue* right) | 3381 HBinaryOperation(HValue* context, HValue* left, HValue* right) |
| (...skipping 3175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6560 virtual bool IsDeletable() const { return true; } | 6557 virtual bool IsDeletable() const { return true; } |
| 6561 }; | 6558 }; |
| 6562 | 6559 |
| 6563 | 6560 |
| 6564 #undef DECLARE_INSTRUCTION | 6561 #undef DECLARE_INSTRUCTION |
| 6565 #undef DECLARE_CONCRETE_INSTRUCTION | 6562 #undef DECLARE_CONCRETE_INSTRUCTION |
| 6566 | 6563 |
| 6567 } } // namespace v8::internal | 6564 } } // namespace v8::internal |
| 6568 | 6565 |
| 6569 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6566 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
| OLD | NEW |