Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: src/hydrogen-instructions.cc

Issue 14284010: Introduce HObjectAccess, which is used by LoadNamedField and StoreNamedField to denote what parts (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Use BitField utility instead of C-language bitfield for portion and offset in HObjectAccess. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/ia32/lithium-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2456 matching lines...) Expand 10 before | Expand all | Expand 10 after
2467 } 2467 }
2468 2468
2469 2469
2470 void HParameter::PrintDataTo(StringStream* stream) { 2470 void HParameter::PrintDataTo(StringStream* stream) {
2471 stream->Add("%u", index()); 2471 stream->Add("%u", index());
2472 } 2472 }
2473 2473
2474 2474
2475 void HLoadNamedField::PrintDataTo(StringStream* stream) { 2475 void HLoadNamedField::PrintDataTo(StringStream* stream) {
2476 object()->PrintNameTo(stream); 2476 object()->PrintNameTo(stream);
2477 stream->Add(" @%d%s", offset(), is_in_object() ? "[in-object]" : ""); 2477 access_.PrintTo(stream);
2478 if (HasTypeCheck()) { 2478 if (HasTypeCheck()) {
2479 stream->Add(" "); 2479 stream->Add(" ");
2480 typecheck()->PrintNameTo(stream); 2480 typecheck()->PrintNameTo(stream);
2481 } 2481 }
2482 } 2482 }
2483 2483
2484 2484
2485 // Returns true if an instance of this map can never find a property with this 2485 // Returns true if an instance of this map can never find a property with this
2486 // name in its prototype chain. This means all prototypes up to the top are 2486 // name in its prototype chain. This means all prototypes up to the top are
2487 // fast and don't have the name in them. It would be good if we could optimize 2487 // fast and don't have the name in them. It would be good if we could optimize
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
2789 stream->Add("."); 2789 stream->Add(".");
2790 ASSERT(name()->IsString()); 2790 ASSERT(name()->IsString());
2791 stream->Add(*String::cast(*name())->ToCString()); 2791 stream->Add(*String::cast(*name())->ToCString());
2792 stream->Add(" = "); 2792 stream->Add(" = ");
2793 value()->PrintNameTo(stream); 2793 value()->PrintNameTo(stream);
2794 } 2794 }
2795 2795
2796 2796
2797 void HStoreNamedField::PrintDataTo(StringStream* stream) { 2797 void HStoreNamedField::PrintDataTo(StringStream* stream) {
2798 object()->PrintNameTo(stream); 2798 object()->PrintNameTo(stream);
2799 stream->Add("."); 2799 access_.PrintTo(stream);
2800 stream->Add(*String::cast(*name())->ToCString());
2801 stream->Add(" = "); 2800 stream->Add(" = ");
2802 value()->PrintNameTo(stream); 2801 value()->PrintNameTo(stream);
2803 stream->Add(" @%d%s", offset(), is_in_object() ? "[in-object]" : "");
2804 if (NeedsWriteBarrier()) { 2802 if (NeedsWriteBarrier()) {
2805 stream->Add(" (write-barrier)"); 2803 stream->Add(" (write-barrier)");
2806 } 2804 }
2807 if (!transition().is_null()) { 2805 if (!transition().is_null()) {
2808 stream->Add(" (transition map %p)", *transition()); 2806 stream->Add(" (transition map %p)", *transition());
2809 } 2807 }
2810 } 2808 }
2811 2809
2812 2810
2813 void HStoreKeyed::PrintDataTo(StringStream* stream) { 2811 void HStoreKeyed::PrintDataTo(StringStream* stream) {
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
3653 } 3651 }
3654 3652
3655 3653
3656 void HCheckFunction::Verify() { 3654 void HCheckFunction::Verify() {
3657 HInstruction::Verify(); 3655 HInstruction::Verify();
3658 ASSERT(HasNoUses()); 3656 ASSERT(HasNoUses());
3659 } 3657 }
3660 3658
3661 #endif 3659 #endif
3662 3660
3661
3662 HObjectAccess HObjectAccess::ForFixedArrayHeader(int offset) {
3663 ASSERT(offset >= 0);
3664 ASSERT(offset < FixedArray::kHeaderSize);
3665 if (offset == FixedArray::kLengthOffset) return ForFixedArrayLength();
3666 return HObjectAccess(kInobject, offset);
3667 }
3668
3669
3670 HObjectAccess HObjectAccess::ForJSObjectOffset(int offset) {
3671 ASSERT(offset >= 0);
3672 Portion portion = kInobject;
3673
3674 if (offset == JSObject::kElementsOffset) {
3675 portion = kElementsPointer;
3676 } else if (offset == JSObject::kMapOffset) {
3677 portion = kMaps;
3678 }
3679 return HObjectAccess(portion, offset, Handle<String>::null());
3680 }
3681
3682
3683 HObjectAccess HObjectAccess::ForJSArrayOffset(int offset) {
3684 ASSERT(offset >= 0);
3685 Portion portion = kInobject;
3686
3687 if (offset == JSObject::kElementsOffset) {
3688 portion = kElementsPointer;
3689 } else if (offset == JSArray::kLengthOffset) {
3690 portion = kArrayLengths;
3691 } else if (offset == JSObject::kMapOffset) {
3692 portion = kMaps;
3693 }
3694 return HObjectAccess(portion, offset, Handle<String>::null());
3695 }
3696
3697
3698 HObjectAccess HObjectAccess::ForBackingStoreOffset(int offset) {
3699 ASSERT(offset >= 0);
3700 return HObjectAccess(kBackingStore, offset, Handle<String>::null());
3701 }
3702
3703
3704 HObjectAccess HObjectAccess::ForField(Handle<Map> map,
3705 LookupResult *lookup, Handle<String> name) {
3706 ASSERT(lookup->IsField() || lookup->IsTransitionToField(*map));
3707 int index;
3708 if (lookup->IsField()) {
3709 index = lookup->GetLocalFieldIndexFromMap(*map);
3710 } else {
3711 Map* transition = lookup->GetTransitionMapFromMap(*map);
3712 int descriptor = transition->LastAdded();
3713 index = transition->instance_descriptors()->GetFieldIndex(descriptor) -
3714 map->inobject_properties();
3715 }
3716 if (index < 0) {
3717 // Negative property indices are in-object properties, indexed
3718 // from the end of the fixed part of the object.
3719 int offset = (index * kPointerSize) + map->instance_size();
3720 return HObjectAccess(kInobject, offset);
3721 } else {
3722 // Non-negative property indices are in the properties array.
3723 int offset = (index * kPointerSize) + FixedArray::kHeaderSize;
3724 return HObjectAccess(kBackingStore, offset, name);
3725 }
3726 }
3727
3728
3729 void HObjectAccess::SetGVNFlags(HValue *instr, bool is_store) {
3730 // set the appropriate GVN flags for a given load or store instruction
3731 if (is_store) {
3732 // track dominating allocations in order to eliminate write barriers
3733 instr->SetGVNFlag(kDependsOnNewSpacePromotion);
3734 instr->SetFlag(HValue::kTrackSideEffectDominators);
3735 } else {
3736 // try to GVN loads, but don't hoist above map changes
3737 instr->SetFlag(HValue::kUseGVN);
3738 instr->SetGVNFlag(kDependsOnMaps);
3739 }
3740
3741 switch (portion()) {
3742 case kArrayLengths:
3743 instr->SetGVNFlag(is_store
3744 ? kChangesArrayLengths : kDependsOnArrayLengths);
3745 break;
3746 case kInobject:
3747 instr->SetGVNFlag(is_store
3748 ? kChangesInobjectFields : kDependsOnInobjectFields);
3749 break;
3750 case kBackingStore:
3751 instr->SetGVNFlag(is_store
3752 ? kChangesBackingStoreFields : kDependsOnBackingStoreFields);
3753 break;
3754 case kElementsPointer:
3755 instr->SetGVNFlag(is_store
3756 ? kChangesElementsPointer : kDependsOnElementsPointer);
3757 break;
3758 case kMaps:
3759 instr->SetGVNFlag(is_store
3760 ? kChangesMaps : kDependsOnMaps);
3761 break;
3762 }
3763 }
3764
3765
3766 void HObjectAccess::PrintTo(StringStream* stream) {
3767 stream->Add(".");
3768
3769 switch (portion()) {
3770 case kArrayLengths:
3771 stream->Add("%length");
3772 break;
3773 case kElementsPointer:
3774 stream->Add("%elements");
3775 break;
3776 case kMaps:
3777 stream->Add("%map");
3778 break;
3779 case kInobject:
3780 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString());
3781 stream->Add("[in-object]");
3782 break;
3783 case kBackingStore:
3784 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString());
3785 stream->Add("[backing-store]");
3786 break;
3787 }
3788
3789 stream->Add("@%d", offset());
3790 }
3791
3663 } } // namespace v8::internal 3792 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/ia32/lithium-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698