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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 case kJSArray: return "array"; | 335 case kJSArray: return "array"; |
336 case kJSObject: return "object"; | 336 case kJSObject: return "object"; |
337 case kUninitialized: return "uninitialized"; | 337 case kUninitialized: return "uninitialized"; |
338 } | 338 } |
339 UNREACHABLE(); | 339 UNREACHABLE(); |
340 return "Unreachable code"; | 340 return "Unreachable code"; |
341 } | 341 } |
342 | 342 |
343 | 343 |
344 HType HType::TypeFromValue(Handle<Object> value) { | 344 HType HType::TypeFromValue(Handle<Object> value) { |
| 345 AllowHandleDereference allow_handle_deref; |
| 346 |
345 HType result = HType::Tagged(); | 347 HType result = HType::Tagged(); |
346 if (value->IsSmi()) { | 348 if (value->IsSmi()) { |
347 result = HType::Smi(); | 349 result = HType::Smi(); |
348 } else if (value->IsHeapNumber()) { | 350 } else if (value->IsHeapNumber()) { |
349 result = HType::HeapNumber(); | 351 result = HType::HeapNumber(); |
350 } else if (value->IsString()) { | 352 } else if (value->IsString()) { |
351 result = HType::String(); | 353 result = HType::String(); |
352 } else if (value->IsBoolean()) { | 354 } else if (value->IsBoolean()) { |
353 result = HType::Boolean(); | 355 result = HType::Boolean(); |
354 } else if (value->IsJSObject()) { | 356 } else if (value->IsJSObject()) { |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 return this; | 1114 return this; |
1113 } | 1115 } |
1114 | 1116 |
1115 | 1117 |
1116 HValue* HCheckInstanceType::Canonicalize() { | 1118 HValue* HCheckInstanceType::Canonicalize() { |
1117 if (check_ == IS_STRING && | 1119 if (check_ == IS_STRING && |
1118 !value()->type().IsUninitialized() && | 1120 !value()->type().IsUninitialized() && |
1119 value()->type().IsString()) { | 1121 value()->type().IsString()) { |
1120 return NULL; | 1122 return NULL; |
1121 } | 1123 } |
1122 if (check_ == IS_SYMBOL && | 1124 |
1123 value()->IsConstant() && | 1125 if (check_ == IS_SYMBOL && value()->IsConstant()) { |
1124 HConstant::cast(value())->handle()->IsSymbol()) { | 1126 AllowHandleDereference allow_handle_deref; |
1125 return NULL; | 1127 if (HConstant::cast(value())->handle()->IsSymbol()) return NULL; |
1126 } | 1128 } |
1127 return this; | 1129 return this; |
1128 } | 1130 } |
1129 | 1131 |
1130 | 1132 |
1131 void HCheckInstanceType::GetCheckInterval(InstanceType* first, | 1133 void HCheckInstanceType::GetCheckInterval(InstanceType* first, |
1132 InstanceType* last) { | 1134 InstanceType* last) { |
1133 ASSERT(is_interval_check()); | 1135 ASSERT(is_interval_check()); |
1134 switch (check_) { | 1136 switch (check_) { |
1135 case IS_SPEC_OBJECT: | 1137 case IS_SPEC_OBJECT: |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1548 static bool IsInteger32(double value) { | 1550 static bool IsInteger32(double value) { |
1549 double roundtrip_value = static_cast<double>(static_cast<int32_t>(value)); | 1551 double roundtrip_value = static_cast<double>(static_cast<int32_t>(value)); |
1550 return BitCast<int64_t>(roundtrip_value) == BitCast<int64_t>(value); | 1552 return BitCast<int64_t>(roundtrip_value) == BitCast<int64_t>(value); |
1551 } | 1553 } |
1552 | 1554 |
1553 | 1555 |
1554 HConstant::HConstant(Handle<Object> handle, Representation r) | 1556 HConstant::HConstant(Handle<Object> handle, Representation r) |
1555 : handle_(handle), | 1557 : handle_(handle), |
1556 has_int32_value_(false), | 1558 has_int32_value_(false), |
1557 has_double_value_(false) { | 1559 has_double_value_(false) { |
| 1560 AllowHandleDereference allow_handle_deref; |
1558 SetFlag(kUseGVN); | 1561 SetFlag(kUseGVN); |
1559 if (handle_->IsNumber()) { | 1562 if (handle_->IsNumber()) { |
1560 double n = handle_->Number(); | 1563 double n = handle_->Number(); |
1561 has_int32_value_ = IsInteger32(n); | 1564 has_int32_value_ = IsInteger32(n); |
1562 int32_value_ = DoubleToInt32(n); | 1565 int32_value_ = DoubleToInt32(n); |
1563 double_value_ = n; | 1566 double_value_ = n; |
1564 has_double_value_ = true; | 1567 has_double_value_ = true; |
1565 } | 1568 } |
1566 if (r.IsNone()) { | 1569 if (r.IsNone()) { |
1567 if (has_int32_value_) { | 1570 if (has_int32_value_) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1626 | 1629 |
1627 | 1630 |
1628 bool HConstant::ToBoolean() { | 1631 bool HConstant::ToBoolean() { |
1629 // Converts the constant's boolean value according to | 1632 // Converts the constant's boolean value according to |
1630 // ECMAScript section 9.2 ToBoolean conversion. | 1633 // ECMAScript section 9.2 ToBoolean conversion. |
1631 if (HasInteger32Value()) return Integer32Value() != 0; | 1634 if (HasInteger32Value()) return Integer32Value() != 0; |
1632 if (HasDoubleValue()) { | 1635 if (HasDoubleValue()) { |
1633 double v = DoubleValue(); | 1636 double v = DoubleValue(); |
1634 return v != 0 && !isnan(v); | 1637 return v != 0 && !isnan(v); |
1635 } | 1638 } |
1636 Handle<Object> literal = handle(); | 1639 AllowHandleDereference allow_handle_deref; |
1637 if (literal->IsTrue()) return true; | 1640 if (handle_->IsTrue()) return true; |
1638 if (literal->IsFalse()) return false; | 1641 if (handle_->IsFalse()) return false; |
1639 if (literal->IsUndefined()) return false; | 1642 if (handle_->IsUndefined()) return false; |
1640 if (literal->IsNull()) return false; | 1643 if (handle_->IsNull()) return false; |
1641 if (literal->IsString() && String::cast(*literal)->length() == 0) { | 1644 if (handle_->IsString() && String::cast(*handle_)->length() == 0) { |
1642 return false; | 1645 return false; |
1643 } | 1646 } |
1644 return true; | 1647 return true; |
1645 } | 1648 } |
1646 | 1649 |
1647 void HConstant::PrintDataTo(StringStream* stream) { | 1650 void HConstant::PrintDataTo(StringStream* stream) { |
1648 if (has_int32_value_) { | 1651 if (has_int32_value_) { |
1649 stream->Add("%d ", int32_value_); | 1652 stream->Add("%d ", int32_value_); |
1650 } else if (has_double_value_) { | 1653 } else if (has_double_value_) { |
1651 stream->Add("%f ", FmtElm(double_value_)); | 1654 stream->Add("%f ", FmtElm(double_value_)); |
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2805 | 2808 |
2806 | 2809 |
2807 void HCheckFunction::Verify() { | 2810 void HCheckFunction::Verify() { |
2808 HInstruction::Verify(); | 2811 HInstruction::Verify(); |
2809 ASSERT(HasNoUses()); | 2812 ASSERT(HasNoUses()); |
2810 } | 2813 } |
2811 | 2814 |
2812 #endif | 2815 #endif |
2813 | 2816 |
2814 } } // namespace v8::internal | 2817 } } // namespace v8::internal |
OLD | NEW |