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 3866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3877 | 3877 |
| 3878 | 3878 |
| 3879 HObjectAccess HObjectAccess::ForBackingStoreOffset(int offset, | 3879 HObjectAccess HObjectAccess::ForBackingStoreOffset(int offset, |
| 3880 Representation representation) { | 3880 Representation representation) { |
| 3881 ASSERT(offset >= 0); | 3881 ASSERT(offset >= 0); |
| 3882 return HObjectAccess(kBackingStore, offset, representation); | 3882 return HObjectAccess(kBackingStore, offset, representation); |
| 3883 } | 3883 } |
| 3884 | 3884 |
| 3885 | 3885 |
| 3886 HObjectAccess HObjectAccess::ForField(Handle<Map> map, | 3886 HObjectAccess HObjectAccess::ForField(Handle<Map> map, |
| 3887 LookupResult *lookup, Handle<String> name) { | 3887 LookupResult *lookup, |
| 3888 Handle<String> name) { | |
| 3888 ASSERT(lookup->IsField() || lookup->IsTransitionToField(*map)); | 3889 ASSERT(lookup->IsField() || lookup->IsTransitionToField(*map)); |
| 3889 int index; | 3890 int index; |
| 3890 Representation representation; | 3891 Representation representation; |
| 3892 FieldType field_type; | |
| 3891 if (lookup->IsField()) { | 3893 if (lookup->IsField()) { |
| 3892 index = lookup->GetLocalFieldIndexFromMap(*map); | 3894 index = lookup->GetLocalFieldIndexFromMap(*map); |
| 3893 representation = lookup->representation(); | 3895 representation = lookup->representation(); |
| 3896 field_type = MUTABLE; | |
| 3894 } else { | 3897 } else { |
| 3895 Map* transition = lookup->GetTransitionMapFromMap(*map); | 3898 Map* transition = lookup->GetTransitionMapFromMap(*map); |
| 3896 int descriptor = transition->LastAdded(); | 3899 int descriptor = transition->LastAdded(); |
| 3897 index = transition->instance_descriptors()->GetFieldIndex(descriptor) - | 3900 index = transition->instance_descriptors()->GetFieldIndex(descriptor) - |
| 3898 map->inobject_properties(); | 3901 map->inobject_properties(); |
| 3899 PropertyDetails details = | 3902 PropertyDetails details = |
| 3900 transition->instance_descriptors()->GetDetails(descriptor); | 3903 transition->instance_descriptors()->GetDetails(descriptor); |
| 3901 representation = details.representation(); | 3904 representation = details.representation(); |
| 3905 field_type = CONSTANT; | |
| 3902 } | 3906 } |
| 3907 int offset = index * kPointerSize; | |
| 3908 Portion portion; | |
| 3903 if (index < 0) { | 3909 if (index < 0) { |
| 3904 // Negative property indices are in-object properties, indexed | 3910 // Negative property indices are in-object properties, indexed from the end |
| 3905 // from the end of the fixed part of the object. | 3911 // of the fixed part of the object. |
| 3906 int offset = (index * kPointerSize) + map->instance_size(); | 3912 offset += map->instance_size(); |
| 3907 return HObjectAccess(kInobject, offset, representation); | 3913 portion = kInobject; |
| 3908 } else { | 3914 } else { |
| 3909 // Non-negative property indices are in the properties array. | 3915 // Non-negative property indices are in the properties array. |
| 3910 int offset = (index * kPointerSize) + FixedArray::kHeaderSize; | 3916 offset += FixedArray::kHeaderSize; |
| 3911 return HObjectAccess(kBackingStore, offset, representation, name); | 3917 portion = kBackingStore; |
| 3912 } | 3918 } |
| 3919 return HObjectAccess(portion, offset, representation, name, field_type); | |
| 3913 } | 3920 } |
| 3914 | 3921 |
| 3915 | 3922 |
| 3916 HObjectAccess HObjectAccess::ForCellPayload(Isolate* isolate) { | 3923 HObjectAccess HObjectAccess::ForCellPayload(Isolate* isolate) { |
| 3917 return HObjectAccess( | 3924 return HObjectAccess( |
| 3918 kInobject, Cell::kValueOffset, Representation::Tagged(), | 3925 kInobject, Cell::kValueOffset, Representation::Tagged(), |
| 3919 Handle<String>(isolate->heap()->cell_value_string())); | 3926 Handle<String>(isolate->heap()->cell_value_string())); |
| 3920 } | 3927 } |
| 3921 | 3928 |
| 3922 | 3929 |
| 3923 void HObjectAccess::SetGVNFlags(HValue *instr, bool is_store) { | 3930 void HObjectAccess::SetGVNFlags(HValue *instr, bool is_store) { |
| 3924 // set the appropriate GVN flags for a given load or store instruction | 3931 // set the appropriate GVN flags for a given load or store instruction |
| 3925 if (is_store) { | 3932 if (is_store) { |
| 3926 // track dominating allocations in order to eliminate write barriers | 3933 // track dominating allocations in order to eliminate write barriers |
| 3927 instr->SetGVNFlag(kDependsOnNewSpacePromotion); | 3934 instr->SetGVNFlag(kDependsOnNewSpacePromotion); |
| 3928 instr->SetFlag(HValue::kTrackSideEffectDominators); | 3935 instr->SetFlag(HValue::kTrackSideEffectDominators); |
| 3929 } else { | 3936 } else { |
| 3930 // try to GVN loads, but don't hoist above map changes | |
| 3931 instr->SetFlag(HValue::kUseGVN); | 3937 instr->SetFlag(HValue::kUseGVN); |
| 3932 instr->SetGVNFlag(kDependsOnMaps); | |
| 3933 } | 3938 } |
| 3934 | 3939 |
| 3940 if (FieldTypeField::decode(value_) == CONSTANT) return; | |
|
titzer
2013/08/26 15:33:47
Mmmm, this is starting to make me feel uncomfortab
| |
| 3941 | |
| 3935 switch (portion()) { | 3942 switch (portion()) { |
| 3936 case kArrayLengths: | 3943 case kArrayLengths: |
| 3937 instr->SetGVNFlag(is_store | 3944 instr->SetGVNFlag(is_store |
| 3938 ? kChangesArrayLengths : kDependsOnArrayLengths); | 3945 ? kChangesArrayLengths : kDependsOnArrayLengths); |
| 3939 break; | 3946 break; |
| 3940 case kStringLengths: | 3947 case kStringLengths: |
| 3941 instr->SetGVNFlag(is_store | 3948 instr->SetGVNFlag(is_store |
| 3942 ? kChangesStringLengths : kDependsOnStringLengths); | 3949 ? kChangesStringLengths : kDependsOnStringLengths); |
| 3943 break; | 3950 break; |
| 3944 case kInobject: | 3951 case kInobject: |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3994 break; | 4001 break; |
| 3995 case kExternalMemory: | 4002 case kExternalMemory: |
| 3996 stream->Add("[external-memory]"); | 4003 stream->Add("[external-memory]"); |
| 3997 break; | 4004 break; |
| 3998 } | 4005 } |
| 3999 | 4006 |
| 4000 stream->Add("@%d", offset()); | 4007 stream->Add("@%d", offset()); |
| 4001 } | 4008 } |
| 4002 | 4009 |
| 4003 } } // namespace v8::internal | 4010 } } // namespace v8::internal |
| OLD | NEW |