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

Side by Side Diff: src/code-stubs-hydrogen.cc

Issue 19663007: Avoid repeated rewrites of global store to constant IC due to store of same value. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 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 | « no previous file | src/stub-cache.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 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 HValue* CodeStubGraphBuilder<StoreGlobalStub>::BuildCodeInitializedStub() { 843 HValue* CodeStubGraphBuilder<StoreGlobalStub>::BuildCodeInitializedStub() {
844 StoreGlobalStub* stub = casted_stub(); 844 StoreGlobalStub* stub = casted_stub();
845 Handle<Object> hole(isolate()->heap()->the_hole_value(), isolate()); 845 Handle<Object> hole(isolate()->heap()->the_hole_value(), isolate());
846 Handle<Object> placeholer_value(Smi::FromInt(0), isolate()); 846 Handle<Object> placeholer_value(Smi::FromInt(0), isolate());
847 Handle<PropertyCell> placeholder_cell = 847 Handle<PropertyCell> placeholder_cell =
848 isolate()->factory()->NewPropertyCell(placeholer_value); 848 isolate()->factory()->NewPropertyCell(placeholer_value);
849 849
850 HParameter* receiver = GetParameter(0); 850 HParameter* receiver = GetParameter(0);
851 HParameter* value = GetParameter(2); 851 HParameter* value = GetParameter(2);
852 852
853 // Check that the map of the global has not changed: use a placeholder map
854 // that will be replaced later with the global object's map.
855 Handle<Map> placeholder_map = isolate()->factory()->meta_map();
856 AddInstruction(HCheckMaps::New(receiver, placeholder_map, zone()));
857
858 HValue* cell = Add<HConstant>(placeholder_cell, Representation::Tagged());
859 HObjectAccess access(HObjectAccess::ForCellPayload(isolate()));
860 HValue* cell_contents = Add<HLoadNamedField>(cell, access);
861
853 if (stub->is_constant()) { 862 if (stub->is_constant()) {
854 // Assume every store to a constant value changes it. 863 IfBuilder builder(this);
855 current_block()->FinishExitWithDeoptimization(HDeoptimize::kUseAll); 864 builder.If<HCompareObjectEqAndBranch>(cell_contents, value);
856 set_current_block(NULL); 865 builder.Then();
866 builder.ElseDeopt();
867 builder.End();
857 } else { 868 } else {
858 HValue* cell = Add<HConstant>(placeholder_cell, Representation::Tagged());
859
860 // Check that the map of the global has not changed: use a placeholder map
861 // that will be replaced later with the global object's map.
862 Handle<Map> placeholder_map = isolate()->factory()->meta_map();
863 AddInstruction(HCheckMaps::New(receiver, placeholder_map, zone()));
864
865 // Load the payload of the global parameter cell. A hole indicates that the 869 // Load the payload of the global parameter cell. A hole indicates that the
866 // property has been deleted and that the store must be handled by the 870 // property has been deleted and that the store must be handled by the
867 // runtime. 871 // runtime.
868 HObjectAccess access(HObjectAccess::ForCellPayload(isolate()));
869 HValue* cell_contents = Add<HLoadNamedField>(cell, access);
870 IfBuilder builder(this); 872 IfBuilder builder(this);
871 HValue* hole_value = Add<HConstant>(hole, Representation::Tagged()); 873 HValue* hole_value = Add<HConstant>(hole, Representation::Tagged());
872 builder.If<HCompareObjectEqAndBranch>(cell_contents, hole_value); 874 builder.If<HCompareObjectEqAndBranch>(cell_contents, hole_value);
873 builder.Then(); 875 builder.Then();
874 builder.Deopt(); 876 builder.Deopt();
875 builder.Else(); 877 builder.Else();
876 Add<HStoreNamedField>(cell, access, value); 878 Add<HStoreNamedField>(cell, access, value);
877 builder.End(); 879 builder.End();
878 } 880 }
881
879 return value; 882 return value;
880 } 883 }
881 884
882 885
883 Handle<Code> StoreGlobalStub::GenerateCode() { 886 Handle<Code> StoreGlobalStub::GenerateCode() {
884 return DoGenerateCode(this); 887 return DoGenerateCode(this);
885 } 888 }
886 889
887 890
888 template<> 891 template<>
(...skipping 25 matching lines...) Expand all
914 return value; 917 return value;
915 } 918 }
916 919
917 920
918 Handle<Code> ElementsTransitionAndStoreStub::GenerateCode() { 921 Handle<Code> ElementsTransitionAndStoreStub::GenerateCode() {
919 return DoGenerateCode(this); 922 return DoGenerateCode(this);
920 } 923 }
921 924
922 925
923 } } // namespace v8::internal 926 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/stub-cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698