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

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

Issue 2393683004: [Interpreter] Optimize the Register Optimizer. (Closed)
Patch Set: Rebase Created 4 years, 2 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-pipeline.cc ('k') | src/interpreter/bytecode-register-optimizer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecode-register-optimizer.h
diff --git a/src/interpreter/bytecode-register-optimizer.h b/src/interpreter/bytecode-register-optimizer.h
index b5e326c3718e675a26e92c21cc44d0db68e1e3f6..885f10f3441e9159c5a6a24063d0de5480adfdcb 100644
--- a/src/interpreter/bytecode-register-optimizer.h
+++ b/src/interpreter/bytecode-register-optimizer.h
@@ -18,8 +18,7 @@ namespace interpreter {
// liberally for correctness and convenience and this stage removes
// transfers that are not required and preserves correctness.
class V8_EXPORT_PRIVATE BytecodeRegisterOptimizer final
- : public NON_EXPORTED_BASE(BytecodePipelineStage),
- public NON_EXPORTED_BASE(BytecodeRegisterAllocator::Observer),
+ : public NON_EXPORTED_BASE(BytecodeRegisterAllocator::Observer),
public NON_EXPORTED_BASE(ZoneObject) {
public:
BytecodeRegisterOptimizer(Zone* zone,
@@ -28,14 +27,41 @@ class V8_EXPORT_PRIVATE BytecodeRegisterOptimizer final
BytecodePipelineStage* next_stage);
virtual ~BytecodeRegisterOptimizer() {}
- // BytecodePipelineStage interface.
- void Write(BytecodeNode* node) override;
- void WriteJump(BytecodeNode* node, BytecodeLabel* label) override;
- void BindLabel(BytecodeLabel* label) override;
- void BindLabel(const BytecodeLabel& target, BytecodeLabel* label) override;
- Handle<BytecodeArray> ToBytecodeArray(
- Isolate* isolate, int register_count, int parameter_count,
- Handle<FixedArray> handler_table) override;
+ // Perform explicit register transfer operations.
+ void DoLdar(Register input, BytecodeSourceInfo source_info) {
+ RegisterInfo* input_info = GetRegisterInfo(input);
+ RegisterTransfer(input_info, accumulator_info_, source_info);
+ }
+ void DoStar(Register output, BytecodeSourceInfo source_info) {
+ RegisterInfo* output_info = GetRegisterInfo(output);
+ RegisterTransfer(accumulator_info_, output_info, source_info);
+ }
+ void DoMov(Register input, Register output, BytecodeSourceInfo source_info) {
+ RegisterInfo* input_info = GetRegisterInfo(input);
+ RegisterInfo* output_info = GetRegisterInfo(output);
+ RegisterTransfer(input_info, output_info, source_info);
+ }
+
+ // Materialize all live registers and flush equivalence sets.
+ void Flush();
+
+ // Prepares for |bytecode|.
+ void PrepareForBytecode(Bytecode bytecode);
+
+ // Prepares |reg| for being used as an output operand.
+ void PrepareOutputRegister(Register reg);
+
+ // Prepares registers in |reg_list| for being used as an output operand.
+ void PrepareOutputRegisterList(RegisterList reg_list);
+
+ // Returns an equivalent register to |reg| to be used as an input operand.
+ Register GetInputRegister(Register reg);
+
+ // Returns an equivalent register list to |reg_list| to be used as an input
+ // operand.
+ RegisterList GetInputRegisterList(RegisterList reg_list);
+
+ int maxiumum_register_index() const { return max_register_index_; }
private:
static const uint32_t kInvalidEquivalenceId;
@@ -47,48 +73,20 @@ class V8_EXPORT_PRIVATE BytecodeRegisterOptimizer final
void RegisterListAllocateEvent(RegisterList reg_list) override;
void RegisterListFreeEvent(RegisterList reg) override;
- // Helpers for BytecodePipelineStage interface.
- void FlushState();
-
// Update internal state for register transfer from |input| to
// |output| using |source_info| as source position information if
// any bytecodes are emitted due to transfer.
void RegisterTransfer(RegisterInfo* input, RegisterInfo* output,
- BytecodeSourceInfo* source_info);
+ BytecodeSourceInfo source_info);
// Emit a register transfer bytecode from |input| to |output|.
- void OutputRegisterTransfer(RegisterInfo* input, RegisterInfo* output,
- BytecodeSourceInfo* source_info = nullptr);
+ void OutputRegisterTransfer(
+ RegisterInfo* input, RegisterInfo* output,
+ BytecodeSourceInfo source_info = BytecodeSourceInfo());
// Emits a Nop to preserve source position information in the
// bytecode pipeline.
- void EmitNopForSourceInfo(BytecodeSourceInfo* source_info) const;
-
- // Handlers for bytecode nodes for register to register transfers.
- void DoLdar(BytecodeNode* node);
- void DoMov(BytecodeNode* node);
- void DoStar(BytecodeNode* node);
-
- // Operand processing methods for bytecodes other than those
- // performing register to register transfers.
- void PrepareOperands(BytecodeNode* const node);
- void PrepareAccumulator(BytecodeNode* const node);
- void PrepareRegisterOperands(BytecodeNode* const node);
-
- void PrepareRegisterOutputOperand(RegisterInfo* reg_info);
- void PrepareRegisterRangeOutputOperand(Register start, int count);
- void PrepareRegisterInputOperand(BytecodeNode* const node, Register reg,
- int operand_index);
- void PrepareRegisterRangeInputOperand(Register start, int count);
-
- Register GetEquivalentRegisterForInputOperand(Register reg);
-
- static Register GetRegisterInputOperand(int index, Bytecode bytecode,
- const uint32_t* operands,
- int operand_count);
- static Register GetRegisterOutputOperand(int index, Bytecode bytecode,
- const uint32_t* operands,
- int operand_count);
+ void EmitNopForSourceInfo(BytecodeSourceInfo source_info) const;
void CreateMaterializedEquivalent(RegisterInfo* info);
RegisterInfo* GetMaterializedEquivalent(RegisterInfo* info);
@@ -98,9 +96,23 @@ class V8_EXPORT_PRIVATE BytecodeRegisterOptimizer final
RegisterInfo* non_set_member);
// Methods for finding and creating metadata for each register.
- RegisterInfo* GetOrCreateRegisterInfo(Register reg);
- RegisterInfo* GetRegisterInfo(Register reg);
- RegisterInfo* NewRegisterInfo(Register reg);
+ RegisterInfo* GetRegisterInfo(Register reg) {
+ size_t index = GetRegisterInfoTableIndex(reg);
+ DCHECK_LT(index, register_info_table_.size());
+ return register_info_table_[index];
+ }
+ RegisterInfo* GetOrCreateRegisterInfo(Register reg) {
+ size_t index = GetRegisterInfoTableIndex(reg);
+ return index < register_info_table_.size() ? register_info_table_[index]
+ : NewRegisterInfo(reg);
+ }
+ RegisterInfo* NewRegisterInfo(Register reg) {
+ size_t index = GetRegisterInfoTableIndex(reg);
+ DCHECK_GE(index, register_info_table_.size());
+ GrowRegisterMap(reg);
+ return register_info_table_[index];
+ }
+
void GrowRegisterMap(Register reg);
bool RegisterIsTemporary(Register reg) const {
« no previous file with comments | « src/interpreter/bytecode-pipeline.cc ('k') | src/interpreter/bytecode-register-optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698