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

Unified Diff: src/interpreter/bytecode-peephole-optimizer.h

Issue 1947403002: [interpreter] Introduce bytecode generation pipeline. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/interpreter/bytecode-generator.cc ('k') | src/interpreter/bytecode-peephole-optimizer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecode-peephole-optimizer.h
diff --git a/src/interpreter/bytecode-peephole-optimizer.h b/src/interpreter/bytecode-peephole-optimizer.h
new file mode 100644
index 0000000000000000000000000000000000000000..62fa13c7703e9318ff58f45a4d9a20fc94d0cd7f
--- /dev/null
+++ b/src/interpreter/bytecode-peephole-optimizer.h
@@ -0,0 +1,58 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_INTERPRETER_BYTECODE_PEEPHOLE_OPTIMIZER_H_
+#define V8_INTERPRETER_BYTECODE_PEEPHOLE_OPTIMIZER_H_
+
+#include "src/interpreter/bytecode-pipeline.h"
+
+namespace v8 {
+namespace internal {
+namespace interpreter {
+
+class ConstantArrayBuilder;
+
+// An optimization stage for performing peephole optimizations on
+// generated bytecode. The optimizer may buffer one bytecode
+// internally.
+class BytecodePeepholeOptimizer final : public BytecodePipelineStage,
+ public ZoneObject {
+ public:
+ BytecodePeepholeOptimizer(ConstantArrayBuilder* constant_array_builder,
+ BytecodePipelineStage* next_stage);
+
+ void Write(BytecodeNode* node) override;
+ size_t FlushForOffset() override;
+ void FlushBasicBlock() override;
+
+ private:
+ BytecodeNode* Optimize(BytecodeNode* current);
+
+ void UpdateCurrentBytecode(BytecodeNode* const current);
+ bool CanElideCurrent(const BytecodeNode* const current) const;
+ bool CanElideLast(const BytecodeNode* const current) const;
+
+ void InvalidateLast();
+ bool LastIsValid() const;
+ void SetLast(const BytecodeNode* const node);
+
+ bool LastBytecodePutsNameInAccumulator() const;
+
+ Handle<Object> GetConstantForIndexOperand(const BytecodeNode* const node,
+ int index) const;
+
+ ConstantArrayBuilder* constant_array_builder_;
+ BytecodePipelineStage* next_stage_;
+ BytecodeNode last_;
+ bool last_is_valid_;
+ bool last_is_discardable_;
+
+ DISALLOW_COPY_AND_ASSIGN(BytecodePeepholeOptimizer);
+};
+
+} // namespace interpreter
+} // namespace internal
+} // namespace v8
+
+#endif // V8_INTERPRETER_BYTECODE_PEEPHOLE_OPTIMIZER_H_
« no previous file with comments | « src/interpreter/bytecode-generator.cc ('k') | src/interpreter/bytecode-peephole-optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698