Chromium Code Reviews| 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 Handle<String> name) { | |
| 3632 return HObjectAccess(is_inobject ? kInobject : kBackingStore, offset, name); | |
| 3633 } | |
| 3634 | |
| 3635 | |
| 3636 HObjectAccess HObjectAccess::ForFixedArrayOffset(int offset) { | |
| 3637 return HObjectAccess(kInobject, offset); | |
|
danno
2013/05/08 15:40:18
If think you might want to check offset == FixedAr
titzer
2013/05/13 11:23:19
Done.
| |
| 3638 } | |
| 3639 | |
| 3640 | |
| 3641 HObjectAccess HObjectAccess::ForJSObjectOffset(int offset, | |
| 3642 Handle<String> name) { | |
| 3643 | |
| 3644 ASSERT(offset >= 0); | |
| 3645 Portion portion = kInobject; | |
| 3646 | |
| 3647 if (offset == JSObject::kElementsOffset) { | |
| 3648 portion = kElementsPointer; | |
| 3649 } else if (offset == JSObject::kMapOffset) { | |
| 3650 portion = kMaps; | |
| 3651 } | |
| 3652 return HObjectAccess(portion, offset, name); | |
| 3653 } | |
| 3654 | |
| 3655 | |
| 3656 HObjectAccess HObjectAccess::ForJSArrayOffset(int offset, | |
| 3657 Handle<String> name) { | |
| 3658 | |
| 3659 ASSERT(offset >= 0); | |
| 3660 Portion portion = kInobject; | |
| 3661 | |
| 3662 if (offset == JSObject::kElementsOffset) { | |
| 3663 portion = kElementsPointer; | |
| 3664 } else if (offset == JSArray::kLengthOffset) { | |
| 3665 portion = kArrayLengths; | |
| 3666 } else if (offset == JSObject::kMapOffset) { | |
| 3667 portion = kMaps; | |
| 3668 } | |
| 3669 return HObjectAccess(portion, offset, name); | |
| 3670 } | |
| 3671 | |
| 3672 | |
| 3673 HObjectAccess HObjectAccess::ForField(Handle<Map> map, | |
| 3674 LookupResult *lookup, Handle<String> name) { | |
| 3675 ASSERT(lookup->IsField() || lookup->IsTransitionToField(*map)); | |
| 3676 int index; | |
| 3677 if (lookup->IsField()) { | |
| 3678 index = lookup->GetLocalFieldIndexFromMap(*map); | |
| 3679 } else { | |
| 3680 Map* transition = lookup->GetTransitionMapFromMap(*map); | |
| 3681 int descriptor = transition->LastAdded(); | |
| 3682 index = transition->instance_descriptors()->GetFieldIndex(descriptor) - | |
| 3683 map->inobject_properties(); | |
| 3684 } | |
| 3685 if (index < 0) { | |
| 3686 // Negative property indices are in-object properties, indexed | |
| 3687 // from the end of the fixed part of the object. | |
| 3688 int offset = (index * kPointerSize) + map->instance_size(); | |
| 3689 return HObjectAccess(kInobject, offset); | |
| 3690 } else { | |
| 3691 // Non-negative property indices are in the properties array. | |
| 3692 int offset = (index * kPointerSize) + FixedArray::kHeaderSize; | |
| 3693 return HObjectAccess(kBackingStore, offset, name); | |
| 3694 } | |
| 3695 } | |
| 3696 | |
| 3697 | |
| 3698 void HObjectAccess::SetGVNFlags(HValue *instr, bool is_store) { | |
| 3699 // set the appropriate GVN flags for a given load or store instruction | |
| 3700 if (is_store) { | |
| 3701 // track dominating allocations in order to eliminate write barriers | |
| 3702 instr->SetGVNFlag(kDependsOnNewSpacePromotion); | |
| 3703 instr->SetFlag(HValue::kTrackSideEffectDominators); | |
| 3704 } else { | |
| 3705 // try to GVN loads, but don't hoist have map changes | |
| 3706 instr->SetFlag(HValue::kUseGVN); | |
| 3707 instr->SetGVNFlag(kDependsOnMaps); | |
| 3708 } | |
| 3709 | |
| 3710 switch (portion_) { | |
| 3711 case kArrayLengths: | |
| 3712 instr->SetGVNFlag(is_store | |
| 3713 ? kChangesArrayLengths : kDependsOnArrayLengths); | |
| 3714 break; | |
| 3715 case kInobject: | |
| 3716 instr->SetGVNFlag(is_store | |
| 3717 ? kChangesInobjectFields : kDependsOnInobjectFields); | |
| 3718 break; | |
| 3719 case kBackingStore: | |
| 3720 instr->SetGVNFlag(is_store | |
| 3721 ? kChangesBackingStoreFields : kDependsOnBackingStoreFields); | |
| 3722 break; | |
| 3723 case kElementsPointer: | |
| 3724 instr->SetGVNFlag(is_store | |
| 3725 ? kChangesElementsPointer : kDependsOnElementsPointer); | |
| 3726 break; | |
| 3727 case kMaps: | |
| 3728 instr->SetGVNFlag(is_store | |
| 3729 ? kChangesMaps : kDependsOnMaps); | |
| 3730 break; | |
| 3731 } | |
| 3732 } | |
| 3733 | |
| 3734 | |
| 3735 void HObjectAccess::PrintTo(StringStream* stream) { | |
| 3736 stream->Add(".@%d", offset_); | |
| 3737 | |
| 3738 // several portions have well-known names | |
| 3739 switch (portion_) { | |
| 3740 case kArrayLengths: | |
| 3741 stream->Add("[array-length]"); | |
| 3742 return; | |
| 3743 case kElementsPointer: | |
| 3744 stream->Add("[elements]"); | |
| 3745 return; | |
| 3746 case kMaps: | |
| 3747 stream->Add("[map]"); | |
| 3748 return; | |
| 3749 case kInobject: | |
| 3750 stream->Add("[in-object]"); | |
| 3751 break; // also print the name if possible | |
| 3752 } | |
| 3753 | |
| 3754 // otherwise, add the name if it is known | |
| 3755 if (!name_.is_null()) { | |
| 3756 stream->Add(" name["); | |
| 3757 stream->Add(*String::cast(*name_)->ToCString()); | |
| 3758 stream->Add("]"); | |
| 3759 } | |
| 3760 } | |
| 3761 | |
| 3631 } } // namespace v8::internal | 3762 } } // namespace v8::internal |
| OLD | NEW |