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

Side by Side Diff: src/interpreter/bytecode-peephole-optimizer.h

Issue 2035813002: [Interpreter] Move jump processing to bytecode array writer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_fix_bytecode
Patch Set: Address comments Created 4 years, 6 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
« no previous file with comments | « src/interpreter/bytecode-label.h ('k') | src/interpreter/bytecode-peephole-optimizer.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 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 {
11 namespace internal { 11 namespace internal {
12 namespace interpreter { 12 namespace interpreter {
13 13
14 class ConstantArrayBuilder; 14 class ConstantArrayBuilder;
15 15
16 // An optimization stage for performing peephole optimizations on 16 // An optimization stage for performing peephole optimizations on
17 // generated bytecode. The optimizer may buffer one bytecode 17 // generated bytecode. The optimizer may buffer one bytecode
18 // internally. 18 // internally.
19 class BytecodePeepholeOptimizer final : public BytecodePipelineStage, 19 class BytecodePeepholeOptimizer final : public BytecodePipelineStage,
20 public ZoneObject { 20 public ZoneObject {
21 public: 21 public:
22 BytecodePeepholeOptimizer(ConstantArrayBuilder* constant_array_builder, 22 BytecodePeepholeOptimizer(ConstantArrayBuilder* constant_array_builder,
23 BytecodePipelineStage* next_stage); 23 BytecodePipelineStage* next_stage);
24 24
25 // BytecodePipelineStage interface. 25 // BytecodePipelineStage interface.
26 void Write(BytecodeNode* node) override; 26 void Write(BytecodeNode* node) override;
27 size_t FlushForOffset() override; 27 void WriteJump(BytecodeNode* node, BytecodeLabel* label) override;
28 void FlushBasicBlock() override; 28 void BindLabel(BytecodeLabel* label) override;
29 void BindLabel(const BytecodeLabel& target, BytecodeLabel* label) override;
30 Handle<BytecodeArray> ToBytecodeArray(
31 int fixed_register_count, int parameter_count,
32 Handle<FixedArray> handler_table) override;
29 33
30 private: 34 private:
35 BytecodeNode* OptimizeAndEmitLast(BytecodeNode* current);
31 BytecodeNode* Optimize(BytecodeNode* current); 36 BytecodeNode* Optimize(BytecodeNode* current);
37 void Flush();
32 38
33 void TryToRemoveLastExpressionPosition(const BytecodeNode* const current); 39 void TryToRemoveLastExpressionPosition(const BytecodeNode* const current);
34 bool TransformLastAndCurrentBytecodes(BytecodeNode* const current); 40 bool TransformLastAndCurrentBytecodes(BytecodeNode* const current);
35 bool CanElideCurrent(const BytecodeNode* const current) const; 41 bool CanElideCurrent(const BytecodeNode* const current) const;
36 bool CanElideLast(const BytecodeNode* const current) const; 42 bool CanElideLast(const BytecodeNode* const current) const;
37 bool CanElideLastBasedOnSourcePosition( 43 bool CanElideLastBasedOnSourcePosition(
38 const BytecodeNode* const current) const; 44 const BytecodeNode* const current) const;
39 45
40 // Simple substitution methods. 46 // Simple substitution methods.
41 bool RemoveToBooleanFromJump(BytecodeNode* const current); 47 bool RemoveToBooleanFromJump(BytecodeNode* const current);
42 bool RemoveToBooleanFromLogicalNot(BytecodeNode* const current); 48 bool RemoveToBooleanFromLogicalNot(BytecodeNode* const current);
43 bool ChangeLdaToLdr(BytecodeNode* const current); 49 bool ChangeLdaToLdr(BytecodeNode* const current);
44 50
45 void InvalidateLast(); 51 void InvalidateLast();
46 bool LastIsValid() const; 52 bool LastIsValid() const;
47 void SetLast(const BytecodeNode* const node); 53 void SetLast(const BytecodeNode* const node);
48 54
49 bool LastBytecodePutsNameInAccumulator() const; 55 bool LastBytecodePutsNameInAccumulator() const;
50 56
51 Handle<Object> GetConstantForIndexOperand(const BytecodeNode* const node, 57 Handle<Object> GetConstantForIndexOperand(const BytecodeNode* const node,
52 int index) const; 58 int index) const;
53 59
54 ConstantArrayBuilder* constant_array_builder_; 60 ConstantArrayBuilder* constant_array_builder_;
55 BytecodePipelineStage* next_stage_; 61 BytecodePipelineStage* next_stage_;
56 BytecodeNode last_; 62 BytecodeNode last_;
57 bool last_is_discardable_;
58 63
59 DISALLOW_COPY_AND_ASSIGN(BytecodePeepholeOptimizer); 64 DISALLOW_COPY_AND_ASSIGN(BytecodePeepholeOptimizer);
60 }; 65 };
61 66
62 } // namespace interpreter 67 } // namespace interpreter
63 } // namespace internal 68 } // namespace internal
64 } // namespace v8 69 } // namespace v8
65 70
66 #endif // V8_INTERPRETER_BYTECODE_PEEPHOLE_OPTIMIZER_H_ 71 #endif // V8_INTERPRETER_BYTECODE_PEEPHOLE_OPTIMIZER_H_
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-label.h ('k') | src/interpreter/bytecode-peephole-optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698