| 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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 } | 329 } |
| 330 | 330 |
| 331 previous = current; | 331 previous = current; |
| 332 current = current->tail(); | 332 current = current->tail(); |
| 333 } | 333 } |
| 334 | 334 |
| 335 #ifdef DEBUG | 335 #ifdef DEBUG |
| 336 // Do not reuse use list nodes in debug mode, zap them. | 336 // Do not reuse use list nodes in debug mode, zap them. |
| 337 if (current != NULL) { | 337 if (current != NULL) { |
| 338 HUseListNode* temp = | 338 HUseListNode* temp = |
| 339 new HUseListNode(current->value(), current->index(), NULL); | 339 new(block()->zone()) |
| 340 HUseListNode(current->value(), current->index(), NULL); |
| 340 current->Zap(); | 341 current->Zap(); |
| 341 current = temp; | 342 current = temp; |
| 342 } | 343 } |
| 343 #endif | 344 #endif |
| 344 return current; | 345 return current; |
| 345 } | 346 } |
| 346 | 347 |
| 347 | 348 |
| 348 bool HValue::Equals(HValue* other) { | 349 bool HValue::Equals(HValue* other) { |
| 349 if (other->opcode() != opcode()) return false; | 350 if (other->opcode() != opcode()) return false; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 HValue* old_value = OperandAt(index); | 489 HValue* old_value = OperandAt(index); |
| 489 if (old_value == new_value) return; | 490 if (old_value == new_value) return; |
| 490 | 491 |
| 491 HUseListNode* removed = NULL; | 492 HUseListNode* removed = NULL; |
| 492 if (old_value != NULL) { | 493 if (old_value != NULL) { |
| 493 removed = old_value->RemoveUse(this, index); | 494 removed = old_value->RemoveUse(this, index); |
| 494 } | 495 } |
| 495 | 496 |
| 496 if (new_value != NULL) { | 497 if (new_value != NULL) { |
| 497 if (removed == NULL) { | 498 if (removed == NULL) { |
| 498 new_value->use_list_ = | 499 new_value->use_list_ = new(new_value->block()->zone()) HUseListNode( |
| 499 new HUseListNode(this, index, new_value->use_list_); | 500 this, index, new_value->use_list_); |
| 500 } else { | 501 } else { |
| 501 removed->set_tail(new_value->use_list_); | 502 removed->set_tail(new_value->use_list_); |
| 502 new_value->use_list_ = removed; | 503 new_value->use_list_ = removed; |
| 503 } | 504 } |
| 504 } | 505 } |
| 505 } | 506 } |
| 506 | 507 |
| 507 | 508 |
| 508 void HValue::AddNewRange(Range* r, Zone* zone) { | 509 void HValue::AddNewRange(Range* r, Zone* zone) { |
| 509 if (!HasRange()) ComputeInitialRange(zone); | 510 if (!HasRange()) ComputeInitialRange(zone); |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 | 958 |
| 958 // Insert the new values in the graph. | 959 // Insert the new values in the graph. |
| 959 if (new_left->IsInstruction() && | 960 if (new_left->IsInstruction() && |
| 960 !HInstruction::cast(new_left)->IsLinked()) { | 961 !HInstruction::cast(new_left)->IsLinked()) { |
| 961 HInstruction::cast(new_left)->InsertBefore(this); | 962 HInstruction::cast(new_left)->InsertBefore(this); |
| 962 } | 963 } |
| 963 if (new_right->IsInstruction() && | 964 if (new_right->IsInstruction() && |
| 964 !HInstruction::cast(new_right)->IsLinked()) { | 965 !HInstruction::cast(new_right)->IsLinked()) { |
| 965 HInstruction::cast(new_right)->InsertBefore(this); | 966 HInstruction::cast(new_right)->InsertBefore(this); |
| 966 } | 967 } |
| 967 HMathFloorOfDiv* instr = new HMathFloorOfDiv(context(), | 968 HMathFloorOfDiv* instr = new(block()->zone()) HMathFloorOfDiv(context(), |
| 968 new_left, | 969 new_left, |
| 969 new_right); | 970 new_right); |
| 970 // Replace this HMathFloor instruction by the new HMathFloorOfDiv. | 971 // Replace this HMathFloor instruction by the new HMathFloorOfDiv. |
| 971 instr->InsertBefore(this); | 972 instr->InsertBefore(this); |
| 972 ReplaceAllUsesWith(instr); | 973 ReplaceAllUsesWith(instr); |
| 973 Kill(); | 974 Kill(); |
| 974 // We know the division had no other uses than this HMathFloor. Delete it. | 975 // We know the division had no other uses than this HMathFloor. Delete it. |
| 975 // Also delete the arguments of the division if they are not used any | 976 // Also delete the arguments of the division if they are not used any |
| 976 // more. | 977 // more. |
| 977 hdiv->DeleteAndReplaceWith(NULL); | 978 hdiv->DeleteAndReplaceWith(NULL); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1244 int32_non_phi_uses() + int32_indirect_uses(), | 1245 int32_non_phi_uses() + int32_indirect_uses(), |
| 1245 double_non_phi_uses() + double_indirect_uses(), | 1246 double_non_phi_uses() + double_indirect_uses(), |
| 1246 tagged_non_phi_uses() + tagged_indirect_uses()); | 1247 tagged_non_phi_uses() + tagged_indirect_uses()); |
| 1247 stream->Add("%s%s]", | 1248 stream->Add("%s%s]", |
| 1248 is_live() ? "_live" : "", | 1249 is_live() ? "_live" : "", |
| 1249 IsConvertibleToInteger() ? "" : "_ncti"); | 1250 IsConvertibleToInteger() ? "" : "_ncti"); |
| 1250 } | 1251 } |
| 1251 | 1252 |
| 1252 | 1253 |
| 1253 void HPhi::AddInput(HValue* value) { | 1254 void HPhi::AddInput(HValue* value) { |
| 1254 inputs_.Add(NULL); | 1255 inputs_.Add(NULL, value->block()->zone()); |
| 1255 SetOperandAt(OperandCount() - 1, value); | 1256 SetOperandAt(OperandCount() - 1, value); |
| 1256 // Mark phis that may have 'arguments' directly or indirectly as an operand. | 1257 // Mark phis that may have 'arguments' directly or indirectly as an operand. |
| 1257 if (!CheckFlag(kIsArguments) && value->CheckFlag(kIsArguments)) { | 1258 if (!CheckFlag(kIsArguments) && value->CheckFlag(kIsArguments)) { |
| 1258 SetFlag(kIsArguments); | 1259 SetFlag(kIsArguments); |
| 1259 } | 1260 } |
| 1260 } | 1261 } |
| 1261 | 1262 |
| 1262 | 1263 |
| 1263 bool HPhi::HasRealUses() { | 1264 bool HPhi::HasRealUses() { |
| 1264 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { | 1265 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1390 double n = handle_->Number(); | 1391 double n = handle_->Number(); |
| 1391 double roundtrip_value = static_cast<double>(static_cast<int32_t>(n)); | 1392 double roundtrip_value = static_cast<double>(static_cast<int32_t>(n)); |
| 1392 has_int32_value_ = BitCast<int64_t>(roundtrip_value) == BitCast<int64_t>(n); | 1393 has_int32_value_ = BitCast<int64_t>(roundtrip_value) == BitCast<int64_t>(n); |
| 1393 if (has_int32_value_) int32_value_ = static_cast<int32_t>(n); | 1394 if (has_int32_value_) int32_value_ = static_cast<int32_t>(n); |
| 1394 double_value_ = n; | 1395 double_value_ = n; |
| 1395 has_double_value_ = true; | 1396 has_double_value_ = true; |
| 1396 } | 1397 } |
| 1397 } | 1398 } |
| 1398 | 1399 |
| 1399 | 1400 |
| 1400 HConstant* HConstant::CopyToRepresentation(Representation r) const { | 1401 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { |
| 1401 if (r.IsInteger32() && !has_int32_value_) return NULL; | 1402 if (r.IsInteger32() && !has_int32_value_) return NULL; |
| 1402 if (r.IsDouble() && !has_double_value_) return NULL; | 1403 if (r.IsDouble() && !has_double_value_) return NULL; |
| 1403 return new HConstant(handle_, r); | 1404 return new(zone) HConstant(handle_, r); |
| 1404 } | 1405 } |
| 1405 | 1406 |
| 1406 | 1407 |
| 1407 HConstant* HConstant::CopyToTruncatedInt32() const { | 1408 HConstant* HConstant::CopyToTruncatedInt32(Zone* zone) const { |
| 1408 if (!has_double_value_) return NULL; | 1409 if (!has_double_value_) return NULL; |
| 1409 int32_t truncated = NumberToInt32(*handle_); | 1410 int32_t truncated = NumberToInt32(*handle_); |
| 1410 return new HConstant(FACTORY->NewNumberFromInt(truncated), | 1411 return new(zone) HConstant(FACTORY->NewNumberFromInt(truncated), |
| 1411 Representation::Integer32()); | 1412 Representation::Integer32()); |
| 1412 } | 1413 } |
| 1413 | 1414 |
| 1414 | 1415 |
| 1415 bool HConstant::ToBoolean() const { | 1416 bool HConstant::ToBoolean() const { |
| 1416 // Converts the constant's boolean value according to | 1417 // Converts the constant's boolean value according to |
| 1417 // ECMAScript section 9.2 ToBoolean conversion. | 1418 // ECMAScript section 9.2 ToBoolean conversion. |
| 1418 if (HasInteger32Value()) return Integer32Value() != 0; | 1419 if (HasInteger32Value()) return Integer32Value() != 0; |
| 1419 if (HasDoubleValue()) { | 1420 if (HasDoubleValue()) { |
| 1420 double v = DoubleValue(); | 1421 double v = DoubleValue(); |
| 1421 return v != 0 && !isnan(v); | 1422 return v != 0 && !isnan(v); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1613 | 1614 |
| 1614 void HLoadNamedField::PrintDataTo(StringStream* stream) { | 1615 void HLoadNamedField::PrintDataTo(StringStream* stream) { |
| 1615 object()->PrintNameTo(stream); | 1616 object()->PrintNameTo(stream); |
| 1616 stream->Add(" @%d%s", offset(), is_in_object() ? "[in-object]" : ""); | 1617 stream->Add(" @%d%s", offset(), is_in_object() ? "[in-object]" : ""); |
| 1617 } | 1618 } |
| 1618 | 1619 |
| 1619 | 1620 |
| 1620 HLoadNamedFieldPolymorphic::HLoadNamedFieldPolymorphic(HValue* context, | 1621 HLoadNamedFieldPolymorphic::HLoadNamedFieldPolymorphic(HValue* context, |
| 1621 HValue* object, | 1622 HValue* object, |
| 1622 SmallMapList* types, | 1623 SmallMapList* types, |
| 1623 Handle<String> name) | 1624 Handle<String> name, |
| 1624 : types_(Min(types->length(), kMaxLoadPolymorphism)), | 1625 Zone* zone) |
| 1626 : types_(Min(types->length(), kMaxLoadPolymorphism), zone), |
| 1625 name_(name), | 1627 name_(name), |
| 1626 need_generic_(false) { | 1628 need_generic_(false) { |
| 1627 SetOperandAt(0, context); | 1629 SetOperandAt(0, context); |
| 1628 SetOperandAt(1, object); | 1630 SetOperandAt(1, object); |
| 1629 set_representation(Representation::Tagged()); | 1631 set_representation(Representation::Tagged()); |
| 1630 SetGVNFlag(kDependsOnMaps); | 1632 SetGVNFlag(kDependsOnMaps); |
| 1631 int map_transitions = 0; | 1633 int map_transitions = 0; |
| 1632 for (int i = 0; | 1634 for (int i = 0; |
| 1633 i < types->length() && types_.length() < kMaxLoadPolymorphism; | 1635 i < types->length() && types_.length() < kMaxLoadPolymorphism; |
| 1634 ++i) { | 1636 ++i) { |
| 1635 Handle<Map> map = types->at(i); | 1637 Handle<Map> map = types->at(i); |
| 1636 LookupResult lookup(map->GetIsolate()); | 1638 LookupResult lookup(map->GetIsolate()); |
| 1637 map->LookupInDescriptors(NULL, *name, &lookup); | 1639 map->LookupInDescriptors(NULL, *name, &lookup); |
| 1638 if (lookup.IsFound()) { | 1640 if (lookup.IsFound()) { |
| 1639 switch (lookup.type()) { | 1641 switch (lookup.type()) { |
| 1640 case FIELD: { | 1642 case FIELD: { |
| 1641 int index = lookup.GetLocalFieldIndexFromMap(*map); | 1643 int index = lookup.GetLocalFieldIndexFromMap(*map); |
| 1642 if (index < 0) { | 1644 if (index < 0) { |
| 1643 SetGVNFlag(kDependsOnInobjectFields); | 1645 SetGVNFlag(kDependsOnInobjectFields); |
| 1644 } else { | 1646 } else { |
| 1645 SetGVNFlag(kDependsOnBackingStoreFields); | 1647 SetGVNFlag(kDependsOnBackingStoreFields); |
| 1646 } | 1648 } |
| 1647 types_.Add(types->at(i)); | 1649 types_.Add(types->at(i), zone); |
| 1648 break; | 1650 break; |
| 1649 } | 1651 } |
| 1650 case CONSTANT_FUNCTION: | 1652 case CONSTANT_FUNCTION: |
| 1651 types_.Add(types->at(i)); | 1653 types_.Add(types->at(i), zone); |
| 1652 break; | 1654 break; |
| 1653 case MAP_TRANSITION: | 1655 case MAP_TRANSITION: |
| 1654 // We should just ignore these since they are not relevant to a load | 1656 // We should just ignore these since they are not relevant to a load |
| 1655 // operation. This means we will deopt if we actually see this map | 1657 // operation. This means we will deopt if we actually see this map |
| 1656 // from optimized code. | 1658 // from optimized code. |
| 1657 map_transitions++; | 1659 map_transitions++; |
| 1658 break; | 1660 break; |
| 1659 default: | 1661 default: |
| 1660 break; | 1662 break; |
| 1661 } | 1663 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1758 | 1760 |
| 1759 if (names_cache->enumerable() == object()) { | 1761 if (names_cache->enumerable() == object()) { |
| 1760 HForInCacheArray* index_cache = | 1762 HForInCacheArray* index_cache = |
| 1761 names_cache->index_cache(); | 1763 names_cache->index_cache(); |
| 1762 HCheckMapValue* map_check = | 1764 HCheckMapValue* map_check = |
| 1763 new(block()->zone()) HCheckMapValue(object(), names_cache->map()); | 1765 new(block()->zone()) HCheckMapValue(object(), names_cache->map()); |
| 1764 HInstruction* index = new(block()->zone()) HLoadKeyedFastElement( | 1766 HInstruction* index = new(block()->zone()) HLoadKeyedFastElement( |
| 1765 index_cache, | 1767 index_cache, |
| 1766 key_load->key(), | 1768 key_load->key(), |
| 1767 OMIT_HOLE_CHECK); | 1769 OMIT_HOLE_CHECK); |
| 1770 map_check->InsertBefore(this); |
| 1771 index->InsertBefore(this); |
| 1768 HLoadFieldByIndex* load = new(block()->zone()) HLoadFieldByIndex( | 1772 HLoadFieldByIndex* load = new(block()->zone()) HLoadFieldByIndex( |
| 1769 object(), index); | 1773 object(), index); |
| 1770 map_check->InsertBefore(this); | |
| 1771 index->InsertBefore(this); | |
| 1772 load->InsertBefore(this); | 1774 load->InsertBefore(this); |
| 1773 return load; | 1775 return load; |
| 1774 } | 1776 } |
| 1775 } | 1777 } |
| 1776 } | 1778 } |
| 1777 | 1779 |
| 1778 return this; | 1780 return this; |
| 1779 } | 1781 } |
| 1780 | 1782 |
| 1781 | 1783 |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2476 | 2478 |
| 2477 | 2479 |
| 2478 void HCheckPrototypeMaps::Verify() { | 2480 void HCheckPrototypeMaps::Verify() { |
| 2479 HInstruction::Verify(); | 2481 HInstruction::Verify(); |
| 2480 ASSERT(HasNoUses()); | 2482 ASSERT(HasNoUses()); |
| 2481 } | 2483 } |
| 2482 | 2484 |
| 2483 #endif | 2485 #endif |
| 2484 | 2486 |
| 2485 } } // namespace v8::internal | 2487 } } // namespace v8::internal |
| OLD | NEW |