| 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 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 | 597 |
| 598 | 598 |
| 599 void HValue::PrintChangesTo(StringStream* stream) { | 599 void HValue::PrintChangesTo(StringStream* stream) { |
| 600 GVNFlagSet changes_flags = ChangesFlags(); | 600 GVNFlagSet changes_flags = ChangesFlags(); |
| 601 if (changes_flags.IsEmpty()) return; | 601 if (changes_flags.IsEmpty()) return; |
| 602 stream->Add(" changes["); | 602 stream->Add(" changes["); |
| 603 if (changes_flags == AllSideEffectsFlagSet()) { | 603 if (changes_flags == AllSideEffectsFlagSet()) { |
| 604 stream->Add("*"); | 604 stream->Add("*"); |
| 605 } else { | 605 } else { |
| 606 bool add_comma = false; | 606 bool add_comma = false; |
| 607 #define PRINT_DO(Type) \ | 607 #define PRINT_DO(type) \ |
| 608 if (changes_flags.Contains(k##Type)) { \ | 608 if (changes_flags.Contains(kChanges##type)) { \ |
| 609 if (add_comma) stream->Add(","); \ | 609 if (add_comma) stream->Add(","); \ |
| 610 add_comma = true; \ | 610 add_comma = true; \ |
| 611 stream->Add(#Type); \ | 611 stream->Add(#type); \ |
| 612 } | 612 } |
| 613 GVN_TRACKED_FLAG_LIST(PRINT_DO); | 613 GVN_TRACKED_FLAG_LIST(PRINT_DO); |
| 614 GVN_UNTRACKED_FLAG_LIST(PRINT_DO); | 614 GVN_UNTRACKED_FLAG_LIST(PRINT_DO); |
| 615 #undef PRINT_DO | 615 #undef PRINT_DO |
| 616 } | 616 } |
| 617 stream->Add("]"); | 617 stream->Add("]"); |
| 618 } | 618 } |
| 619 | 619 |
| 620 | 620 |
| 621 void HValue::PrintNameTo(StringStream* stream) { | 621 void HValue::PrintNameTo(StringStream* stream) { |
| (...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1509 *tag = kInternalizedTag; | 1509 *tag = kInternalizedTag; |
| 1510 return; | 1510 return; |
| 1511 default: | 1511 default: |
| 1512 UNREACHABLE(); | 1512 UNREACHABLE(); |
| 1513 } | 1513 } |
| 1514 } | 1514 } |
| 1515 | 1515 |
| 1516 | 1516 |
| 1517 bool HCheckMaps::HandleSideEffectDominator(GVNFlag side_effect, | 1517 bool HCheckMaps::HandleSideEffectDominator(GVNFlag side_effect, |
| 1518 HValue* dominator) { | 1518 HValue* dominator) { |
| 1519 ASSERT(side_effect == kMaps); | 1519 ASSERT(side_effect == kChangesMaps); |
| 1520 // TODO(mstarzinger): For now we specialize on HStoreNamedField, but once | 1520 // TODO(mstarzinger): For now we specialize on HStoreNamedField, but once |
| 1521 // type information is rich enough we should generalize this to any HType | 1521 // type information is rich enough we should generalize this to any HType |
| 1522 // for which the map is known. | 1522 // for which the map is known. |
| 1523 if (HasNoUses() && dominator->IsStoreNamedField()) { | 1523 if (HasNoUses() && dominator->IsStoreNamedField()) { |
| 1524 HStoreNamedField* store = HStoreNamedField::cast(dominator); | 1524 HStoreNamedField* store = HStoreNamedField::cast(dominator); |
| 1525 if (!store->has_transition() || store->object() != value()) return false; | 1525 if (!store->has_transition() || store->object() != value()) return false; |
| 1526 HConstant* transition = HConstant::cast(store->transition()); | 1526 HConstant* transition = HConstant::cast(store->transition()); |
| 1527 if (map_set_.Contains(transition->GetUnique())) { | 1527 if (map_set_.Contains(transition->GetUnique())) { |
| 1528 DeleteAndReplaceWith(NULL); | 1528 DeleteAndReplaceWith(NULL); |
| 1529 return true; | 1529 return true; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1617 | 1617 |
| 1618 | 1618 |
| 1619 Range* HChange::InferRange(Zone* zone) { | 1619 Range* HChange::InferRange(Zone* zone) { |
| 1620 Range* input_range = value()->range(); | 1620 Range* input_range = value()->range(); |
| 1621 if (from().IsInteger32() && !value()->CheckFlag(HInstruction::kUint32) && | 1621 if (from().IsInteger32() && !value()->CheckFlag(HInstruction::kUint32) && |
| 1622 (to().IsSmi() || | 1622 (to().IsSmi() || |
| 1623 (to().IsTagged() && | 1623 (to().IsTagged() && |
| 1624 input_range != NULL && | 1624 input_range != NULL && |
| 1625 input_range->IsInSmiRange()))) { | 1625 input_range->IsInSmiRange()))) { |
| 1626 set_type(HType::Smi()); | 1626 set_type(HType::Smi()); |
| 1627 ClearChangesFlag(kNewSpacePromotion); | 1627 ClearGVNFlag(kChangesNewSpacePromotion); |
| 1628 } | 1628 } |
| 1629 Range* result = (input_range != NULL) | 1629 Range* result = (input_range != NULL) |
| 1630 ? input_range->Copy(zone) | 1630 ? input_range->Copy(zone) |
| 1631 : HValue::InferRange(zone); | 1631 : HValue::InferRange(zone); |
| 1632 result->set_can_be_minus_zero(!to().IsSmiOrInteger32() || | 1632 result->set_can_be_minus_zero(!to().IsSmiOrInteger32() || |
| 1633 !(CheckFlag(kAllUsesTruncatingToInt32) || | 1633 !(CheckFlag(kAllUsesTruncatingToInt32) || |
| 1634 CheckFlag(kAllUsesTruncatingToSmi))); | 1634 CheckFlag(kAllUsesTruncatingToSmi))); |
| 1635 if (to().IsSmi()) result->ClampToSmi(); | 1635 if (to().IsSmi()) result->ClampToSmi(); |
| 1636 return result; | 1636 return result; |
| 1637 } | 1637 } |
| (...skipping 1767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3405 Representation input_rep = value()->representation(); | 3405 Representation input_rep = value()->representation(); |
| 3406 if (!input_rep.IsTagged()) { | 3406 if (!input_rep.IsTagged()) { |
| 3407 rep = rep.generalize(input_rep); | 3407 rep = rep.generalize(input_rep); |
| 3408 } | 3408 } |
| 3409 return rep; | 3409 return rep; |
| 3410 } | 3410 } |
| 3411 | 3411 |
| 3412 | 3412 |
| 3413 bool HAllocate::HandleSideEffectDominator(GVNFlag side_effect, | 3413 bool HAllocate::HandleSideEffectDominator(GVNFlag side_effect, |
| 3414 HValue* dominator) { | 3414 HValue* dominator) { |
| 3415 ASSERT(side_effect == kNewSpacePromotion); | 3415 ASSERT(side_effect == kChangesNewSpacePromotion); |
| 3416 Zone* zone = block()->zone(); | 3416 Zone* zone = block()->zone(); |
| 3417 if (!FLAG_use_allocation_folding) return false; | 3417 if (!FLAG_use_allocation_folding) return false; |
| 3418 | 3418 |
| 3419 // Try to fold allocations together with their dominating allocations. | 3419 // Try to fold allocations together with their dominating allocations. |
| 3420 if (!dominator->IsAllocate()) { | 3420 if (!dominator->IsAllocate()) { |
| 3421 if (FLAG_trace_allocation_folding) { | 3421 if (FLAG_trace_allocation_folding) { |
| 3422 PrintF("#%d (%s) cannot fold into #%d (%s)\n", | 3422 PrintF("#%d (%s) cannot fold into #%d (%s)\n", |
| 3423 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); | 3423 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); |
| 3424 } | 3424 } |
| 3425 return false; | 3425 return false; |
| (...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4387 return HObjectAccess( | 4387 return HObjectAccess( |
| 4388 kInobject, Cell::kValueOffset, Representation::Tagged(), | 4388 kInobject, Cell::kValueOffset, Representation::Tagged(), |
| 4389 Handle<String>(isolate->heap()->cell_value_string())); | 4389 Handle<String>(isolate->heap()->cell_value_string())); |
| 4390 } | 4390 } |
| 4391 | 4391 |
| 4392 | 4392 |
| 4393 void HObjectAccess::SetGVNFlags(HValue *instr, PropertyAccessType access_type) { | 4393 void HObjectAccess::SetGVNFlags(HValue *instr, PropertyAccessType access_type) { |
| 4394 // set the appropriate GVN flags for a given load or store instruction | 4394 // set the appropriate GVN flags for a given load or store instruction |
| 4395 if (access_type == STORE) { | 4395 if (access_type == STORE) { |
| 4396 // track dominating allocations in order to eliminate write barriers | 4396 // track dominating allocations in order to eliminate write barriers |
| 4397 instr->SetDependsOnFlag(::v8::internal::kNewSpacePromotion); | 4397 instr->SetGVNFlag(kDependsOnNewSpacePromotion); |
| 4398 instr->SetFlag(HValue::kTrackSideEffectDominators); | 4398 instr->SetFlag(HValue::kTrackSideEffectDominators); |
| 4399 } else { | 4399 } else { |
| 4400 // try to GVN loads, but don't hoist above map changes | 4400 // try to GVN loads, but don't hoist above map changes |
| 4401 instr->SetFlag(HValue::kUseGVN); | 4401 instr->SetFlag(HValue::kUseGVN); |
| 4402 instr->SetDependsOnFlag(::v8::internal::kMaps); | 4402 instr->SetGVNFlag(kDependsOnMaps); |
| 4403 } | 4403 } |
| 4404 | 4404 |
| 4405 switch (portion()) { | 4405 switch (portion()) { |
| 4406 case kArrayLengths: | 4406 case kArrayLengths: |
| 4407 if (access_type == STORE) { | 4407 instr->SetGVNFlag(access_type == STORE |
| 4408 instr->SetChangesFlag(::v8::internal::kArrayLengths); | 4408 ? kChangesArrayLengths : kDependsOnArrayLengths); |
| 4409 } else { | |
| 4410 instr->SetDependsOnFlag(::v8::internal::kArrayLengths); | |
| 4411 } | |
| 4412 break; | 4409 break; |
| 4413 case kStringLengths: | 4410 case kStringLengths: |
| 4414 if (access_type == STORE) { | 4411 instr->SetGVNFlag(access_type == STORE |
| 4415 instr->SetChangesFlag(::v8::internal::kStringLengths); | 4412 ? kChangesStringLengths : kDependsOnStringLengths); |
| 4416 } else { | |
| 4417 instr->SetDependsOnFlag(::v8::internal::kStringLengths); | |
| 4418 } | |
| 4419 break; | 4413 break; |
| 4420 case kInobject: | 4414 case kInobject: |
| 4421 if (access_type == STORE) { | 4415 instr->SetGVNFlag(access_type == STORE |
| 4422 instr->SetChangesFlag(::v8::internal::kInobjectFields); | 4416 ? kChangesInobjectFields : kDependsOnInobjectFields); |
| 4423 } else { | |
| 4424 instr->SetDependsOnFlag(::v8::internal::kInobjectFields); | |
| 4425 } | |
| 4426 break; | 4417 break; |
| 4427 case kDouble: | 4418 case kDouble: |
| 4428 if (access_type == STORE) { | 4419 instr->SetGVNFlag(access_type == STORE |
| 4429 instr->SetChangesFlag(::v8::internal::kDoubleFields); | 4420 ? kChangesDoubleFields : kDependsOnDoubleFields); |
| 4430 } else { | |
| 4431 instr->SetDependsOnFlag(::v8::internal::kDoubleFields); | |
| 4432 } | |
| 4433 break; | 4421 break; |
| 4434 case kBackingStore: | 4422 case kBackingStore: |
| 4435 if (access_type == STORE) { | 4423 instr->SetGVNFlag(access_type == STORE |
| 4436 instr->SetChangesFlag(::v8::internal::kBackingStoreFields); | 4424 ? kChangesBackingStoreFields : kDependsOnBackingStoreFields); |
| 4437 } else { | |
| 4438 instr->SetDependsOnFlag(::v8::internal::kBackingStoreFields); | |
| 4439 } | |
| 4440 break; | 4425 break; |
| 4441 case kElementsPointer: | 4426 case kElementsPointer: |
| 4442 if (access_type == STORE) { | 4427 instr->SetGVNFlag(access_type == STORE |
| 4443 instr->SetChangesFlag(::v8::internal::kElementsPointer); | 4428 ? kChangesElementsPointer : kDependsOnElementsPointer); |
| 4444 } else { | |
| 4445 instr->SetDependsOnFlag(::v8::internal::kElementsPointer); | |
| 4446 } | |
| 4447 break; | 4429 break; |
| 4448 case kMaps: | 4430 case kMaps: |
| 4449 if (access_type == STORE) { | 4431 instr->SetGVNFlag(access_type == STORE |
| 4450 instr->SetChangesFlag(::v8::internal::kMaps); | 4432 ? kChangesMaps : kDependsOnMaps); |
| 4451 } else { | |
| 4452 instr->SetDependsOnFlag(::v8::internal::kMaps); | |
| 4453 } | |
| 4454 break; | 4433 break; |
| 4455 case kExternalMemory: | 4434 case kExternalMemory: |
| 4456 if (access_type == STORE) { | 4435 instr->SetGVNFlag(access_type == STORE |
| 4457 instr->SetChangesFlag(::v8::internal::kExternalMemory); | 4436 ? kChangesExternalMemory : kDependsOnExternalMemory); |
| 4458 } else { | |
| 4459 instr->SetDependsOnFlag(::v8::internal::kExternalMemory); | |
| 4460 } | |
| 4461 break; | 4437 break; |
| 4462 } | 4438 } |
| 4463 } | 4439 } |
| 4464 | 4440 |
| 4465 | 4441 |
| 4466 void HObjectAccess::PrintTo(StringStream* stream) const { | 4442 void HObjectAccess::PrintTo(StringStream* stream) { |
| 4467 stream->Add("."); | 4443 stream->Add("."); |
| 4468 | 4444 |
| 4469 switch (portion()) { | 4445 switch (portion()) { |
| 4470 case kArrayLengths: | 4446 case kArrayLengths: |
| 4471 case kStringLengths: | 4447 case kStringLengths: |
| 4472 stream->Add("%length"); | 4448 stream->Add("%length"); |
| 4473 break; | 4449 break; |
| 4474 case kElementsPointer: | 4450 case kElementsPointer: |
| 4475 stream->Add("%elements"); | 4451 stream->Add("%elements"); |
| 4476 break; | 4452 break; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 4492 break; | 4468 break; |
| 4493 case kExternalMemory: | 4469 case kExternalMemory: |
| 4494 stream->Add("[external-memory]"); | 4470 stream->Add("[external-memory]"); |
| 4495 break; | 4471 break; |
| 4496 } | 4472 } |
| 4497 | 4473 |
| 4498 stream->Add("@%d", offset()); | 4474 stream->Add("@%d", offset()); |
| 4499 } | 4475 } |
| 4500 | 4476 |
| 4501 } } // namespace v8::internal | 4477 } } // namespace v8::internal |
| OLD | NEW |