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 3632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3643 void HCheckNonSmi::Verify() { | 3643 void HCheckNonSmi::Verify() { |
| 3644 HInstruction::Verify(); | 3644 HInstruction::Verify(); |
| 3645 ASSERT(HasNoUses()); | 3645 ASSERT(HasNoUses()); |
| 3646 } | 3646 } |
| 3647 | 3647 |
| 3648 | 3648 |
| 3649 void HCheckFunction::Verify() { | 3649 void HCheckFunction::Verify() { |
| 3650 HInstruction::Verify(); | 3650 HInstruction::Verify(); |
| 3651 ASSERT(HasNoUses()); | 3651 ASSERT(HasNoUses()); |
| 3652 } | 3652 } |
| 3653 | |
|
danno
2013/05/06 15:53:06
Stray whitespace removal, please add back.
titzer
2013/05/07 17:51:03
Done.
| |
| 3654 #endif | 3653 #endif |
| 3655 | 3654 |
| 3655 | |
| 3656 // global accesses that can be shared across instructions | |
| 3657 HObjectAccess elements_pointer_access_( | |
| 3658 HObjectAccess::kElementsPointer, JSObject::kElementsOffset); | |
| 3659 HObjectAccess array_length_access_( | |
| 3660 HObjectAccess::kArrayLengths, JSArray::kLengthOffset); | |
| 3661 HObjectAccess fixed_array_length_access_( | |
| 3662 HObjectAccess::kInobject, FixedArray::kLengthOffset); | |
| 3663 HObjectAccess map_access_( | |
| 3664 HObjectAccess::kMaps, JSObject::kMapOffset); | |
| 3665 | |
| 3666 | |
| 3667 HObjectAccess* HObjectAccess::ForElementsPointer() { | |
| 3668 return &elements_pointer_access_; | |
| 3669 } | |
| 3670 | |
| 3671 | |
| 3672 HObjectAccess* HObjectAccess::ForArrayLength() { | |
| 3673 return &array_length_access_; | |
| 3674 } | |
| 3675 | |
| 3676 | |
| 3677 HObjectAccess* HObjectAccess::ForFixedArrayLength() { | |
| 3678 return &fixed_array_length_access_; | |
| 3679 } | |
| 3680 | |
| 3681 | |
| 3682 HObjectAccess* HObjectAccess::ForMap() { | |
| 3683 return &map_access_; | |
| 3684 } | |
| 3685 | |
|
danno
2013/05/06 15:53:06
nit: two newlines
titzer
2013/05/07 17:51:03
Done.
| |
| 3686 HObjectAccess* HObjectAccess::ForInobjectOffset(Zone *zone, int offset, | |
| 3687 Handle<String> name) { | |
| 3688 | |
| 3689 ASSERT(offset >= 0); | |
| 3690 Portion portion = kInobject; | |
| 3691 | |
| 3692 if (offset == JSObject::kElementsOffset) { | |
| 3693 portion = kElementsPointer; | |
| 3694 } else if (offset == JSArray::kLengthOffset) { | |
| 3695 portion = kArrayLengths; // XXX: only true for arrays? | |
| 3696 } else if (offset == JSObject::kMapOffset) { | |
| 3697 portion = kMaps; | |
| 3698 } | |
| 3699 return new(zone) HObjectAccess(portion, offset, name); | |
| 3700 } | |
| 3701 | |
|
danno
2013/05/06 15:53:06
nit: two lines
titzer
2013/05/07 17:51:03
Done.
| |
| 3702 HObjectAccess* HObjectAccess::ForOffset(Zone *zone, int offset, | |
| 3703 Handle<String> name) { | |
| 3704 return new(zone) HObjectAccess(kInobject, offset, name); | |
| 3705 } | |
| 3706 | |
|
danno
2013/05/06 15:53:06
nit: two lines
titzer
2013/05/07 17:51:03
Done.
| |
| 3707 HObjectAccess* HObjectAccess::ForField(Zone *zone, Handle<Map> map, | |
| 3708 LookupResult *lookup, Handle<String> name) { | |
| 3709 ASSERT(lookup->IsField() || lookup->IsTransitionToField(*map)); | |
| 3710 int index; | |
| 3711 if (lookup->IsField()) { | |
| 3712 index = lookup->GetLocalFieldIndexFromMap(*map); | |
| 3713 } else { | |
| 3714 Map* transition = lookup->GetTransitionMapFromMap(*map); | |
| 3715 int descriptor = transition->LastAdded(); | |
| 3716 index = transition->instance_descriptors()->GetFieldIndex(descriptor) - | |
| 3717 map->inobject_properties(); | |
| 3718 } | |
| 3719 if (index < 0) { | |
| 3720 // Negative property indices are in-object properties, indexed | |
| 3721 // from the end of the fixed part of the object. | |
| 3722 int offset = (index * kPointerSize) + map->instance_size(); | |
| 3723 return new(zone) HObjectAccess(HObjectAccess::kInobject, offset); | |
| 3724 } else { | |
| 3725 // Non-negative property indices are in the properties array. | |
| 3726 int offset = (index * kPointerSize) + FixedArray::kHeaderSize; | |
| 3727 return new(zone) | |
| 3728 HObjectAccess(HObjectAccess::kBackingStore, offset, name); | |
| 3729 } | |
| 3730 } | |
| 3731 | |
| 3732 | |
| 3733 void HObjectAccess::SetGVNFlags(HValue *instr, bool is_store) { | |
| 3734 // set the appropriate GVN flags for a given load or store instruction | |
| 3735 if (is_store) { | |
| 3736 // track dominating allocations in order to eliminate write barriers | |
| 3737 instr->SetGVNFlag(kDependsOnNewSpacePromotion); | |
| 3738 instr->SetFlag(HValue::kTrackSideEffectDominators); | |
| 3739 } else { | |
| 3740 // try to GVN loads, but don't hoist have map changes | |
| 3741 instr->SetFlag(HValue::kUseGVN); | |
| 3742 instr->SetGVNFlag(kDependsOnMaps); | |
| 3743 } | |
| 3744 | |
| 3745 switch (portion_) { | |
| 3746 case kArrayLengths: | |
| 3747 instr->SetGVNFlag(is_store | |
| 3748 ? kChangesArrayLengths : kDependsOnArrayLengths); | |
| 3749 break; | |
| 3750 case kInobject: | |
| 3751 instr->SetGVNFlag(is_store | |
| 3752 ? kChangesInobjectFields : kDependsOnInobjectFields); | |
| 3753 break; | |
| 3754 case kBackingStore: | |
| 3755 instr->SetGVNFlag(is_store | |
| 3756 ? kChangesBackingStoreFields : kDependsOnBackingStoreFields); | |
| 3757 break; | |
| 3758 case kElementsPointer: | |
| 3759 instr->SetGVNFlag(is_store | |
| 3760 ? kChangesElementsPointer : kDependsOnElementsPointer); | |
| 3761 break; | |
| 3762 case kMaps: | |
| 3763 instr->SetGVNFlag(is_store | |
| 3764 ? kChangesMaps : kDependsOnMaps); | |
| 3765 break; | |
| 3766 } | |
| 3767 } | |
| 3768 | |
| 3656 } } // namespace v8::internal | 3769 } } // namespace v8::internal |
| OLD | NEW |