1 // Copyright 2016 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef V8_COMPILER_STORE_STORE_ELIMINATION_H_ 6 #define V8_COMPILER_STORE_STORE_ELIMINATION_H_ 7 8 #include "src/common/globals.h" 9 10 namespace v8 { 11 namespace internal { 12 13 class TickCounter; 14 class Zone; 15 16 namespace compiler { 17 18 class JSGraph; 19 20 // Store-store elimination. 21 // 22 // The aim of this optimization is to detect the following pattern in the 23 // effect graph: 24 // 25 // - StoreField[+24, kRepTagged](263, ...) 26 // 27 // ... lots of nodes from which the field at offset 24 of the object 28 // returned by node #263 cannot be observed ... 29 // 30 // - StoreField[+24, kRepTagged](263, ...) 31 // 32 // In such situations, the earlier StoreField cannot be observed, and can be 33 // eliminated. This optimization should work for any offset and input node, of 34 // course. 35 // 36 // The optimization also works across splits. It currently does not work for 37 // loops, because we tend to put a stack check in loops, and like deopts, 38 // stack checks can observe anything. 39 40 // Assumption: every byte of a JS object is only ever accessed through one 41 // offset. For instance, byte 15 of a given object may be accessed using a 42 // two-byte read at offset 14, or a four-byte read at offset 12, but never 43 // both in the same program. 44 // 45 // This implementation needs all dead nodes removed from the graph, and the 46 // graph should be trimmed. 47 class StoreStoreElimination final : public AllStatic { 48 public: 49 static void Run(JSGraph* js_graph, TickCounter* tick_counter, 50 Zone* temp_zone); 51 }; 52 53 } // namespace compiler 54 } // namespace internal 55 } // namespace v8 56 57 #endif // V8_COMPILER_STORE_STORE_ELIMINATION_H_ 58