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

Side by Side Diff: src/interpreter/bytecode-register-allocator.h

Issue 1997653002: [interpreter] Bytecode register optimizer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Decouple a test from implementation. 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-pipeline.cc ('k') | src/interpreter/bytecode-register-allocator.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_REGISTER_ALLOCATOR_H_ 5 #ifndef V8_INTERPRETER_BYTECODE_REGISTER_ALLOCATOR_H_
6 #define V8_INTERPRETER_BYTECODE_REGISTER_ALLOCATOR_H_ 6 #define V8_INTERPRETER_BYTECODE_REGISTER_ALLOCATOR_H_
7 7
8 #include "src/interpreter/bytecodes.h" 8 #include "src/interpreter/bytecodes.h"
9 #include "src/zone-containers.h" 9 #include "src/zone-containers.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 namespace interpreter { 13 namespace interpreter {
14 14
15 class BytecodeArrayBuilder; 15 class BytecodeArrayBuilder;
16 class Register; 16 class Register;
17 class TemporaryRegisterObserver;
17 18
18 class TemporaryRegisterAllocator final { 19 class TemporaryRegisterAllocator final {
19 public: 20 public:
20 TemporaryRegisterAllocator(Zone* zone, int start_index); 21 TemporaryRegisterAllocator(Zone* zone, int start_index);
21 22
22 // Borrow a temporary register. 23 // Borrow a temporary register.
23 int BorrowTemporaryRegister(); 24 int BorrowTemporaryRegister();
24 25
25 // Borrow a temporary register from the register range outside of 26 // Borrow a temporary register from the register range outside of
26 // |start_index| to |end_index|. 27 // |start_index| to |end_index|.
(...skipping 20 matching lines...) Expand all
47 48
48 // Returns the last register in the range of temporary registers. 49 // Returns the last register in the range of temporary registers.
49 Register last_temporary_register() const; 50 Register last_temporary_register() const;
50 51
51 // Returns the start index of temporary register allocations. 52 // Returns the start index of temporary register allocations.
52 int allocation_base() const { return allocation_base_; } 53 int allocation_base() const { return allocation_base_; }
53 54
54 // Returns the number of temporary register allocations made. 55 // Returns the number of temporary register allocations made.
55 int allocation_count() const { return allocation_count_; } 56 int allocation_count() const { return allocation_count_; }
56 57
58 // Sets an observer for temporary register events.
59 void set_observer(TemporaryRegisterObserver* observer);
60
57 private: 61 private:
58 // Allocate a temporary register. 62 // Allocate a temporary register.
59 int AllocateTemporaryRegister(); 63 int AllocateTemporaryRegister();
60 64
61 ZoneSet<int> free_temporaries_; 65 ZoneSet<int> free_temporaries_;
62 int allocation_base_; 66 int allocation_base_;
63 int allocation_count_; 67 int allocation_count_;
68 TemporaryRegisterObserver* observer_;
64 69
65 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterAllocator); 70 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterAllocator);
66 }; 71 };
67 72
73 class TemporaryRegisterObserver {
74 public:
75 virtual ~TemporaryRegisterObserver() {}
76 virtual void TemporaryRegisterFreeEvent(Register reg) = 0;
77 };
78
68 // A class that allows the instantiator to allocate temporary registers that are 79 // A class that allows the instantiator to allocate temporary registers that are
69 // cleaned up when scope is closed. 80 // cleaned up when scope is closed.
70 class BytecodeRegisterAllocator final { 81 class BytecodeRegisterAllocator final {
71 public: 82 public:
72 explicit BytecodeRegisterAllocator(Zone* zone, 83 explicit BytecodeRegisterAllocator(Zone* zone,
73 TemporaryRegisterAllocator* allocator); 84 TemporaryRegisterAllocator* allocator);
74 ~BytecodeRegisterAllocator(); 85 ~BytecodeRegisterAllocator();
75 Register NewRegister(); 86 Register NewRegister();
76 87
77 // Ensure |count| consecutive allocations are available. 88 // Ensure |count| consecutive allocations are available.
(...skipping 19 matching lines...) Expand all
97 108
98 DISALLOW_COPY_AND_ASSIGN(BytecodeRegisterAllocator); 109 DISALLOW_COPY_AND_ASSIGN(BytecodeRegisterAllocator);
99 }; 110 };
100 111
101 } // namespace interpreter 112 } // namespace interpreter
102 } // namespace internal 113 } // namespace internal
103 } // namespace v8 114 } // namespace v8
104 115
105 116
106 #endif // V8_INTERPRETER_BYTECODE_REGISTER_ALLOCATOR_H_ 117 #endif // V8_INTERPRETER_BYTECODE_REGISTER_ALLOCATOR_H_
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-pipeline.cc ('k') | src/interpreter/bytecode-register-allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698