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