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

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

Issue 23241027: Avoid setting / depending on flags when transitioning, and when fields are known to be constant. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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
« src/hydrogen-instructions.h ('K') | « src/hydrogen-instructions.h ('k') | no next file » | 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 3866 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
3903 if (index < 0) { 3907 // Negative property indices are in-object properties, indexed
titzer 2013/08/26 13:06:45 I think I prefer the if; the logic gets too twiste
Toon Verwaest 2013/08/26 13:39:16 Ok, I'll revert to it. On 2013/08/26 13:06:45, ti
3904 // Negative property indices are in-object properties, indexed 3908 // from the end of the fixed part of the object.
3905 // from the end of the fixed part of the object. 3909 // Non-negative property indices are in the properties array.
3906 int offset = (index * kPointerSize) + map->instance_size(); 3910 int offset = index * kPointerSize;
3907 return HObjectAccess(kInobject, offset, representation); 3911 offset += index < 0 ? map->instance_size() : FixedArray::kHeaderSize;
3908 } else { 3912 Portion portion = index < 0 ? kInobject : kBackingStore;
3909 // Non-negative property indices are in the properties array. 3913 return HObjectAccess(portion, offset, representation, name, field_type);
3910 int offset = (index * kPointerSize) + FixedArray::kHeaderSize;
3911 return HObjectAccess(kBackingStore, offset, representation, name);
3912 }
3913 } 3914 }
3914 3915
3915 3916
3916 HObjectAccess HObjectAccess::ForCellPayload(Isolate* isolate) { 3917 HObjectAccess HObjectAccess::ForCellPayload(Isolate* isolate) {
3917 return HObjectAccess( 3918 return HObjectAccess(
3918 kInobject, Cell::kValueOffset, Representation::Tagged(), 3919 kInobject, Cell::kValueOffset, Representation::Tagged(),
3919 Handle<String>(isolate->heap()->cell_value_string())); 3920 Handle<String>(isolate->heap()->cell_value_string()));
3920 } 3921 }
3921 3922
3922 3923
3923 void HObjectAccess::SetGVNFlags(HValue *instr, bool is_store) { 3924 void HObjectAccess::SetGVNFlags(HValue *instr, bool is_store) {
3924 // set the appropriate GVN flags for a given load or store instruction 3925 // set the appropriate GVN flags for a given load or store instruction
3925 if (is_store) { 3926 if (is_store) {
3926 // track dominating allocations in order to eliminate write barriers 3927 // track dominating allocations in order to eliminate write barriers
3927 instr->SetGVNFlag(kDependsOnNewSpacePromotion); 3928 instr->SetGVNFlag(kDependsOnNewSpacePromotion);
3928 instr->SetFlag(HValue::kTrackSideEffectDominators); 3929 instr->SetFlag(HValue::kTrackSideEffectDominators);
3929 } else { 3930 } else {
3930 // try to GVN loads, but don't hoist above map changes
3931 instr->SetFlag(HValue::kUseGVN); 3931 instr->SetFlag(HValue::kUseGVN);
3932 instr->SetGVNFlag(kDependsOnMaps);
titzer 2013/08/26 13:06:45 Can a map transition have side effects other than
Toon Verwaest 2013/08/26 13:39:16 No. We are transitioning because that property did
3933 } 3932 }
3934 3933
3934 if (FieldTypeField::decode(value_) == CONSTANT) return;
3935
3935 switch (portion()) { 3936 switch (portion()) {
3936 case kArrayLengths: 3937 case kArrayLengths:
3937 instr->SetGVNFlag(is_store 3938 instr->SetGVNFlag(is_store
3938 ? kChangesArrayLengths : kDependsOnArrayLengths); 3939 ? kChangesArrayLengths : kDependsOnArrayLengths);
3939 break; 3940 break;
3940 case kStringLengths: 3941 case kStringLengths:
3941 instr->SetGVNFlag(is_store 3942 instr->SetGVNFlag(is_store
3942 ? kChangesStringLengths : kDependsOnStringLengths); 3943 ? kChangesStringLengths : kDependsOnStringLengths);
3943 break; 3944 break;
3944 case kInobject: 3945 case kInobject:
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
3994 break; 3995 break;
3995 case kExternalMemory: 3996 case kExternalMemory:
3996 stream->Add("[external-memory]"); 3997 stream->Add("[external-memory]");
3997 break; 3998 break;
3998 } 3999 }
3999 4000
4000 stream->Add("@%d", offset()); 4001 stream->Add("@%d", offset());
4001 } 4002 }
4002 4003
4003 } } // namespace v8::internal 4004 } } // namespace v8::internal
OLDNEW
« src/hydrogen-instructions.h ('K') | « src/hydrogen-instructions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698