OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_INTERPRETER_BYTECODE_PEEPHOLE_OPTIMIZER_H_ | 5 #ifndef V8_INTERPRETER_BYTECODE_PEEPHOLE_OPTIMIZER_H_ |
6 #define V8_INTERPRETER_BYTECODE_PEEPHOLE_OPTIMIZER_H_ | 6 #define V8_INTERPRETER_BYTECODE_PEEPHOLE_OPTIMIZER_H_ |
7 | 7 |
8 #include "src/interpreter/bytecode-pipeline.h" | 8 #include "src/interpreter/bytecode-pipeline.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 11 matching lines...) Expand all Loading... |
22 BytecodePeepholeOptimizer(ConstantArrayBuilder* constant_array_builder, | 22 BytecodePeepholeOptimizer(ConstantArrayBuilder* constant_array_builder, |
23 BytecodePipelineStage* next_stage); | 23 BytecodePipelineStage* next_stage); |
24 | 24 |
25 void Write(BytecodeNode* node) override; | 25 void Write(BytecodeNode* node) override; |
26 size_t FlushForOffset() override; | 26 size_t FlushForOffset() override; |
27 void FlushBasicBlock() override; | 27 void FlushBasicBlock() override; |
28 | 28 |
29 private: | 29 private: |
30 BytecodeNode* Optimize(BytecodeNode* current); | 30 BytecodeNode* Optimize(BytecodeNode* current); |
31 | 31 |
32 void UpdateLastAndCurrentBytecodes(BytecodeNode* const current); | 32 void TryToRemoveLastExpressionPosition(const BytecodeNode* const current); |
| 33 bool TransformLastAndCurrentBytecodes(BytecodeNode* const current); |
33 bool CanElideCurrent(const BytecodeNode* const current) const; | 34 bool CanElideCurrent(const BytecodeNode* const current) const; |
34 bool CanElideLast(const BytecodeNode* const current) const; | 35 bool CanElideLast(const BytecodeNode* const current) const; |
35 bool CanElideLastBasedOnSourcePosition( | 36 bool CanElideLastBasedOnSourcePosition( |
36 const BytecodeNode* const current) const; | 37 const BytecodeNode* const current) const; |
37 | 38 |
| 39 // Simple substitution methods. |
| 40 bool RemoveToBooleanFromJump(BytecodeNode* const current); |
| 41 bool RemoveToBooleanFromLogicalNot(BytecodeNode* const current); |
| 42 bool ChangeLdaToLdr(BytecodeNode* const current); |
| 43 |
38 void InvalidateLast(); | 44 void InvalidateLast(); |
39 bool LastIsValid() const; | 45 bool LastIsValid() const; |
40 void SetLast(const BytecodeNode* const node); | 46 void SetLast(const BytecodeNode* const node); |
41 | 47 |
42 bool LastBytecodePutsNameInAccumulator() const; | 48 bool LastBytecodePutsNameInAccumulator() const; |
43 | 49 |
44 Handle<Object> GetConstantForIndexOperand(const BytecodeNode* const node, | 50 Handle<Object> GetConstantForIndexOperand(const BytecodeNode* const node, |
45 int index) const; | 51 int index) const; |
46 | 52 |
47 ConstantArrayBuilder* constant_array_builder_; | 53 ConstantArrayBuilder* constant_array_builder_; |
48 BytecodePipelineStage* next_stage_; | 54 BytecodePipelineStage* next_stage_; |
49 BytecodeNode last_; | 55 BytecodeNode last_; |
50 bool last_is_discardable_; | 56 bool last_is_discardable_; |
51 | 57 |
52 DISALLOW_COPY_AND_ASSIGN(BytecodePeepholeOptimizer); | 58 DISALLOW_COPY_AND_ASSIGN(BytecodePeepholeOptimizer); |
53 }; | 59 }; |
54 | 60 |
55 } // namespace interpreter | 61 } // namespace interpreter |
56 } // namespace internal | 62 } // namespace internal |
57 } // namespace v8 | 63 } // namespace v8 |
58 | 64 |
59 #endif // V8_INTERPRETER_BYTECODE_PEEPHOLE_OPTIMIZER_H_ | 65 #endif // V8_INTERPRETER_BYTECODE_PEEPHOLE_OPTIMIZER_H_ |
OLD | NEW |