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_ARRAY_BUILDER_H_ | 5 #ifndef V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
6 #define V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 6 #define V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "src/ast.h" | 10 #include "src/ast.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 class Register { | 77 class Register { |
78 public: | 78 public: |
79 static const int kMaxRegisterIndex = 128; | 79 static const int kMaxRegisterIndex = 128; |
80 | 80 |
81 explicit Register(int index) : index_(index) { | 81 explicit Register(int index) : index_(index) { |
82 DCHECK_LE(index_, kMaxRegisterIndex); | 82 DCHECK_LE(index_, kMaxRegisterIndex); |
83 } | 83 } |
84 | 84 |
85 int index() { return index_; } | 85 int index() { return index_; } |
86 uint8_t ToOperand() { return static_cast<uint8_t>(-index_); } | 86 uint8_t ToOperand() { return static_cast<uint8_t>(-index_); } |
87 static Register FromOperand(uint8_t operand) { return Register(-operand); } | 87 static Register FromOperand(uint8_t operand) { |
| 88 return Register(-static_cast<int8_t>(operand)); |
| 89 } |
88 | 90 |
89 private: | 91 private: |
90 void* operator new(size_t size); | 92 void* operator new(size_t size); |
91 void operator delete(void* p); | 93 void operator delete(void* p); |
92 | 94 |
93 int index_; | 95 int index_; |
94 }; | 96 }; |
95 | 97 |
96 // A stack-allocated class than allows the instantiator to allocate | 98 // A stack-allocated class than allows the instantiator to allocate |
97 // temporary registers that are cleaned up when scope is closed. | 99 // temporary registers that are cleaned up when scope is closed. |
(...skipping 13 matching lines...) Expand all Loading... |
111 | 113 |
112 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); | 114 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); |
113 }; | 115 }; |
114 | 116 |
115 | 117 |
116 } // namespace interpreter | 118 } // namespace interpreter |
117 } // namespace internal | 119 } // namespace internal |
118 } // namespace v8 | 120 } // namespace v8 |
119 | 121 |
120 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 122 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
OLD | NEW |