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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1365 double n = handle_->Number(); | 1366 double n = handle_->Number(); |
1366 double roundtrip_value = static_cast<double>(static_cast<int32_t>(n)); | 1367 double roundtrip_value = static_cast<double>(static_cast<int32_t>(n)); |
1367 has_int32_value_ = BitCast<int64_t>(roundtrip_value) == BitCast<int64_t>(n); | 1368 has_int32_value_ = BitCast<int64_t>(roundtrip_value) == BitCast<int64_t>(n); |
1368 if (has_int32_value_) int32_value_ = static_cast<int32_t>(n); | 1369 if (has_int32_value_) int32_value_ = static_cast<int32_t>(n); |
1369 double_value_ = n; | 1370 double_value_ = n; |
1370 has_double_value_ = true; | 1371 has_double_value_ = true; |
1371 } | 1372 } |
1372 } | 1373 } |
1373 | 1374 |
1374 | 1375 |
1375 HConstant* HConstant::CopyToRepresentation(Representation r) const { | 1376 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { |
1376 if (r.IsInteger32() && !has_int32_value_) return NULL; | 1377 if (r.IsInteger32() && !has_int32_value_) return NULL; |
1377 if (r.IsDouble() && !has_double_value_) return NULL; | 1378 if (r.IsDouble() && !has_double_value_) return NULL; |
1378 return new HConstant(handle_, r); | 1379 return new(zone) HConstant(handle_, r); |
1379 } | 1380 } |
1380 | 1381 |
1381 | 1382 |
1382 HConstant* HConstant::CopyToTruncatedInt32() const { | 1383 HConstant* HConstant::CopyToTruncatedInt32(Zone* zone) const { |
1383 if (!has_double_value_) return NULL; | 1384 if (!has_double_value_) return NULL; |
1384 int32_t truncated = NumberToInt32(*handle_); | 1385 int32_t truncated = NumberToInt32(*handle_); |
1385 return new HConstant(FACTORY->NewNumberFromInt(truncated), | 1386 return new(zone) HConstant(FACTORY->NewNumberFromInt(truncated), |
1386 Representation::Integer32()); | 1387 Representation::Integer32()); |
1387 } | 1388 } |
1388 | 1389 |
1389 | 1390 |
1390 bool HConstant::ToBoolean() const { | 1391 bool HConstant::ToBoolean() const { |
1391 // Converts the constant's boolean value according to | 1392 // Converts the constant's boolean value according to |
1392 // ECMAScript section 9.2 ToBoolean conversion. | 1393 // ECMAScript section 9.2 ToBoolean conversion. |
1393 if (HasInteger32Value()) return Integer32Value() != 0; | 1394 if (HasInteger32Value()) return Integer32Value() != 0; |
1394 if (HasDoubleValue()) { | 1395 if (HasDoubleValue()) { |
1395 double v = DoubleValue(); | 1396 double v = DoubleValue(); |
1396 return v != 0 && !isnan(v); | 1397 return v != 0 && !isnan(v); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1588 | 1589 |
1589 void HLoadNamedField::PrintDataTo(StringStream* stream) { | 1590 void HLoadNamedField::PrintDataTo(StringStream* stream) { |
1590 object()->PrintNameTo(stream); | 1591 object()->PrintNameTo(stream); |
1591 stream->Add(" @%d%s", offset(), is_in_object() ? "[in-object]" : ""); | 1592 stream->Add(" @%d%s", offset(), is_in_object() ? "[in-object]" : ""); |
1592 } | 1593 } |
1593 | 1594 |
1594 | 1595 |
1595 HLoadNamedFieldPolymorphic::HLoadNamedFieldPolymorphic(HValue* context, | 1596 HLoadNamedFieldPolymorphic::HLoadNamedFieldPolymorphic(HValue* context, |
1596 HValue* object, | 1597 HValue* object, |
1597 SmallMapList* types, | 1598 SmallMapList* types, |
1598 Handle<String> name) | 1599 Handle<String> name, |
1599 : types_(Min(types->length(), kMaxLoadPolymorphism)), | 1600 Zone* zone) |
| 1601 : types_(Min(types->length(), kMaxLoadPolymorphism), zone), |
1600 name_(name), | 1602 name_(name), |
1601 need_generic_(false) { | 1603 need_generic_(false) { |
1602 SetOperandAt(0, context); | 1604 SetOperandAt(0, context); |
1603 SetOperandAt(1, object); | 1605 SetOperandAt(1, object); |
1604 set_representation(Representation::Tagged()); | 1606 set_representation(Representation::Tagged()); |
1605 SetGVNFlag(kDependsOnMaps); | 1607 SetGVNFlag(kDependsOnMaps); |
1606 int map_transitions = 0; | 1608 int map_transitions = 0; |
1607 for (int i = 0; | 1609 for (int i = 0; |
1608 i < types->length() && types_.length() < kMaxLoadPolymorphism; | 1610 i < types->length() && types_.length() < kMaxLoadPolymorphism; |
1609 ++i) { | 1611 ++i) { |
1610 Handle<Map> map = types->at(i); | 1612 Handle<Map> map = types->at(i); |
1611 LookupResult lookup(map->GetIsolate()); | 1613 LookupResult lookup(map->GetIsolate()); |
1612 map->LookupInDescriptors(NULL, *name, &lookup); | 1614 map->LookupInDescriptors(NULL, *name, &lookup); |
1613 if (lookup.IsFound()) { | 1615 if (lookup.IsFound()) { |
1614 switch (lookup.type()) { | 1616 switch (lookup.type()) { |
1615 case FIELD: { | 1617 case FIELD: { |
1616 int index = lookup.GetLocalFieldIndexFromMap(*map); | 1618 int index = lookup.GetLocalFieldIndexFromMap(*map); |
1617 if (index < 0) { | 1619 if (index < 0) { |
1618 SetGVNFlag(kDependsOnInobjectFields); | 1620 SetGVNFlag(kDependsOnInobjectFields); |
1619 } else { | 1621 } else { |
1620 SetGVNFlag(kDependsOnBackingStoreFields); | 1622 SetGVNFlag(kDependsOnBackingStoreFields); |
1621 } | 1623 } |
1622 types_.Add(types->at(i)); | 1624 types_.Add(types->at(i), zone); |
1623 break; | 1625 break; |
1624 } | 1626 } |
1625 case CONSTANT_FUNCTION: | 1627 case CONSTANT_FUNCTION: |
1626 types_.Add(types->at(i)); | 1628 types_.Add(types->at(i), zone); |
1627 break; | 1629 break; |
1628 case MAP_TRANSITION: | 1630 case MAP_TRANSITION: |
1629 // We should just ignore these since they are not relevant to a load | 1631 // We should just ignore these since they are not relevant to a load |
1630 // operation. This means we will deopt if we actually see this map | 1632 // operation. This means we will deopt if we actually see this map |
1631 // from optimized code. | 1633 // from optimized code. |
1632 map_transitions++; | 1634 map_transitions++; |
1633 break; | 1635 break; |
1634 default: | 1636 default: |
1635 break; | 1637 break; |
1636 } | 1638 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1733 | 1735 |
1734 if (names_cache->enumerable() == object()) { | 1736 if (names_cache->enumerable() == object()) { |
1735 HForInCacheArray* index_cache = | 1737 HForInCacheArray* index_cache = |
1736 names_cache->index_cache(); | 1738 names_cache->index_cache(); |
1737 HCheckMapValue* map_check = | 1739 HCheckMapValue* map_check = |
1738 new(block()->zone()) HCheckMapValue(object(), names_cache->map()); | 1740 new(block()->zone()) HCheckMapValue(object(), names_cache->map()); |
1739 HInstruction* index = new(block()->zone()) HLoadKeyedFastElement( | 1741 HInstruction* index = new(block()->zone()) HLoadKeyedFastElement( |
1740 index_cache, | 1742 index_cache, |
1741 key_load->key(), | 1743 key_load->key(), |
1742 OMIT_HOLE_CHECK); | 1744 OMIT_HOLE_CHECK); |
| 1745 map_check->InsertBefore(this); |
| 1746 index->InsertBefore(this); |
1743 HLoadFieldByIndex* load = new(block()->zone()) HLoadFieldByIndex( | 1747 HLoadFieldByIndex* load = new(block()->zone()) HLoadFieldByIndex( |
1744 object(), index); | 1748 object(), index); |
1745 map_check->InsertBefore(this); | |
1746 index->InsertBefore(this); | |
1747 load->InsertBefore(this); | 1749 load->InsertBefore(this); |
1748 return load; | 1750 return load; |
1749 } | 1751 } |
1750 } | 1752 } |
1751 } | 1753 } |
1752 | 1754 |
1753 return this; | 1755 return this; |
1754 } | 1756 } |
1755 | 1757 |
1756 | 1758 |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2451 | 2453 |
2452 | 2454 |
2453 void HCheckPrototypeMaps::Verify() { | 2455 void HCheckPrototypeMaps::Verify() { |
2454 HInstruction::Verify(); | 2456 HInstruction::Verify(); |
2455 ASSERT(HasNoUses()); | 2457 ASSERT(HasNoUses()); |
2456 } | 2458 } |
2457 | 2459 |
2458 #endif | 2460 #endif |
2459 | 2461 |
2460 } } // namespace v8::internal | 2462 } } // namespace v8::internal |
OLD | NEW |