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 2447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2458 } | 2458 } |
2459 | 2459 |
2460 | 2460 |
2461 void HParameter::PrintDataTo(StringStream* stream) { | 2461 void HParameter::PrintDataTo(StringStream* stream) { |
2462 stream->Add("%u", index()); | 2462 stream->Add("%u", index()); |
2463 } | 2463 } |
2464 | 2464 |
2465 | 2465 |
2466 void HLoadNamedField::PrintDataTo(StringStream* stream) { | 2466 void HLoadNamedField::PrintDataTo(StringStream* stream) { |
2467 object()->PrintNameTo(stream); | 2467 object()->PrintNameTo(stream); |
2468 stream->Add(" @%d%s", offset(), is_in_object() ? "[in-object]" : ""); | 2468 access_.PrintTo(stream); |
2469 if (HasTypeCheck()) { | 2469 if (HasTypeCheck()) { |
2470 stream->Add(" "); | 2470 stream->Add(" "); |
2471 typecheck()->PrintNameTo(stream); | 2471 typecheck()->PrintNameTo(stream); |
2472 } | 2472 } |
2473 } | 2473 } |
2474 | 2474 |
2475 | 2475 |
2476 // Returns true if an instance of this map can never find a property with this | 2476 // Returns true if an instance of this map can never find a property with this |
2477 // name in its prototype chain. This means all prototypes up to the top are | 2477 // name in its prototype chain. This means all prototypes up to the top are |
2478 // fast and don't have the name in them. It would be good if we could optimize | 2478 // fast and don't have the name in them. It would be good if we could optimize |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2759 stream->Add("."); | 2759 stream->Add("."); |
2760 ASSERT(name()->IsString()); | 2760 ASSERT(name()->IsString()); |
2761 stream->Add(*String::cast(*name())->ToCString()); | 2761 stream->Add(*String::cast(*name())->ToCString()); |
2762 stream->Add(" = "); | 2762 stream->Add(" = "); |
2763 value()->PrintNameTo(stream); | 2763 value()->PrintNameTo(stream); |
2764 } | 2764 } |
2765 | 2765 |
2766 | 2766 |
2767 void HStoreNamedField::PrintDataTo(StringStream* stream) { | 2767 void HStoreNamedField::PrintDataTo(StringStream* stream) { |
2768 object()->PrintNameTo(stream); | 2768 object()->PrintNameTo(stream); |
2769 stream->Add("."); | 2769 access_.PrintTo(stream); |
2770 stream->Add(*String::cast(*name())->ToCString()); | |
2771 stream->Add(" = "); | 2770 stream->Add(" = "); |
2772 value()->PrintNameTo(stream); | 2771 value()->PrintNameTo(stream); |
2773 stream->Add(" @%d%s", offset(), is_in_object() ? "[in-object]" : ""); | |
2774 if (NeedsWriteBarrier()) { | 2772 if (NeedsWriteBarrier()) { |
2775 stream->Add(" (write-barrier)"); | 2773 stream->Add(" (write-barrier)"); |
2776 } | 2774 } |
2777 if (!transition().is_null()) { | 2775 if (!transition().is_null()) { |
2778 stream->Add(" (transition map %p)", *transition()); | 2776 stream->Add(" (transition map %p)", *transition()); |
2779 } | 2777 } |
2780 } | 2778 } |
2781 | 2779 |
2782 | 2780 |
2783 void HStoreKeyed::PrintDataTo(StringStream* stream) { | 2781 void HStoreKeyed::PrintDataTo(StringStream* stream) { |
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3620 } | 3618 } |
3621 | 3619 |
3622 | 3620 |
3623 void HCheckFunction::Verify() { | 3621 void HCheckFunction::Verify() { |
3624 HInstruction::Verify(); | 3622 HInstruction::Verify(); |
3625 ASSERT(HasNoUses()); | 3623 ASSERT(HasNoUses()); |
3626 } | 3624 } |
3627 | 3625 |
3628 #endif | 3626 #endif |
3629 | 3627 |
| 3628 |
| 3629 HObjectAccess HObjectAccess::ForFixedArrayHeader(int offset) { |
| 3630 ASSERT(offset >= 0); |
| 3631 ASSERT(offset < FixedArray::kHeaderSize); |
| 3632 if (offset == FixedArray::kLengthOffset) return ForFixedArrayLength(); |
| 3633 return HObjectAccess(kInobject, offset); |
| 3634 } |
| 3635 |
| 3636 |
| 3637 HObjectAccess HObjectAccess::ForJSObjectOffset(int offset) { |
| 3638 ASSERT(offset >= 0); |
| 3639 Portion portion = kInobject; |
| 3640 |
| 3641 if (offset == JSObject::kElementsOffset) { |
| 3642 portion = kElementsPointer; |
| 3643 } else if (offset == JSObject::kMapOffset) { |
| 3644 portion = kMaps; |
| 3645 } |
| 3646 return HObjectAccess(portion, offset, Handle<String>::null()); |
| 3647 } |
| 3648 |
| 3649 |
| 3650 HObjectAccess HObjectAccess::ForJSArrayOffset(int offset) { |
| 3651 ASSERT(offset >= 0); |
| 3652 Portion portion = kInobject; |
| 3653 |
| 3654 if (offset == JSObject::kElementsOffset) { |
| 3655 portion = kElementsPointer; |
| 3656 } else if (offset == JSArray::kLengthOffset) { |
| 3657 portion = kArrayLengths; |
| 3658 } else if (offset == JSObject::kMapOffset) { |
| 3659 portion = kMaps; |
| 3660 } |
| 3661 return HObjectAccess(portion, offset, Handle<String>::null()); |
| 3662 } |
| 3663 |
| 3664 |
| 3665 HObjectAccess HObjectAccess::ForBackingStoreOffset(int offset) { |
| 3666 ASSERT(offset >= 0); |
| 3667 return HObjectAccess(kBackingStore, offset, Handle<String>::null()); |
| 3668 } |
| 3669 |
| 3670 |
| 3671 HObjectAccess HObjectAccess::ForField(Handle<Map> map, |
| 3672 LookupResult *lookup, Handle<String> name) { |
| 3673 ASSERT(lookup->IsField() || lookup->IsTransitionToField(*map)); |
| 3674 int index; |
| 3675 if (lookup->IsField()) { |
| 3676 index = lookup->GetLocalFieldIndexFromMap(*map); |
| 3677 } else { |
| 3678 Map* transition = lookup->GetTransitionMapFromMap(*map); |
| 3679 int descriptor = transition->LastAdded(); |
| 3680 index = transition->instance_descriptors()->GetFieldIndex(descriptor) - |
| 3681 map->inobject_properties(); |
| 3682 } |
| 3683 if (index < 0) { |
| 3684 // Negative property indices are in-object properties, indexed |
| 3685 // from the end of the fixed part of the object. |
| 3686 int offset = (index * kPointerSize) + map->instance_size(); |
| 3687 return HObjectAccess(kInobject, offset); |
| 3688 } else { |
| 3689 // Non-negative property indices are in the properties array. |
| 3690 int offset = (index * kPointerSize) + FixedArray::kHeaderSize; |
| 3691 return HObjectAccess(kBackingStore, offset, name); |
| 3692 } |
| 3693 } |
| 3694 |
| 3695 |
| 3696 void HObjectAccess::SetGVNFlags(HValue *instr, bool is_store) { |
| 3697 // set the appropriate GVN flags for a given load or store instruction |
| 3698 if (is_store) { |
| 3699 // track dominating allocations in order to eliminate write barriers |
| 3700 instr->SetGVNFlag(kDependsOnNewSpacePromotion); |
| 3701 instr->SetFlag(HValue::kTrackSideEffectDominators); |
| 3702 } else { |
| 3703 // try to GVN loads, but don't hoist above map changes |
| 3704 instr->SetFlag(HValue::kUseGVN); |
| 3705 instr->SetGVNFlag(kDependsOnMaps); |
| 3706 } |
| 3707 |
| 3708 switch (portion_) { |
| 3709 case kArrayLengths: |
| 3710 instr->SetGVNFlag(is_store |
| 3711 ? kChangesArrayLengths : kDependsOnArrayLengths); |
| 3712 break; |
| 3713 case kInobject: |
| 3714 instr->SetGVNFlag(is_store |
| 3715 ? kChangesInobjectFields : kDependsOnInobjectFields); |
| 3716 break; |
| 3717 case kBackingStore: |
| 3718 instr->SetGVNFlag(is_store |
| 3719 ? kChangesBackingStoreFields : kDependsOnBackingStoreFields); |
| 3720 break; |
| 3721 case kElementsPointer: |
| 3722 instr->SetGVNFlag(is_store |
| 3723 ? kChangesElementsPointer : kDependsOnElementsPointer); |
| 3724 break; |
| 3725 case kMaps: |
| 3726 instr->SetGVNFlag(is_store |
| 3727 ? kChangesMaps : kDependsOnMaps); |
| 3728 break; |
| 3729 } |
| 3730 } |
| 3731 |
| 3732 |
| 3733 void HObjectAccess::PrintTo(StringStream* stream) { |
| 3734 stream->Add("."); |
| 3735 |
| 3736 switch (portion_) { |
| 3737 case kArrayLengths: |
| 3738 stream->Add("%length"); |
| 3739 break; |
| 3740 case kElementsPointer: |
| 3741 stream->Add("%elements"); |
| 3742 break; |
| 3743 case kMaps: |
| 3744 stream->Add("%map"); |
| 3745 break; |
| 3746 case kInobject: |
| 3747 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); |
| 3748 stream->Add("[in-object]"); |
| 3749 break; |
| 3750 case kBackingStore: |
| 3751 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); |
| 3752 stream->Add("[backing-store]"); |
| 3753 break; |
| 3754 } |
| 3755 |
| 3756 stream->Add("@%d", offset_); |
| 3757 } |
| 3758 |
3630 } } // namespace v8::internal | 3759 } } // namespace v8::internal |
OLD | NEW |