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