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

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

Issue 2135273002: [interpreter] Reduce dependencies in bytecodes.{h,cc} (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix static const Register definitions for bot in roll for Windows. Created 4 years, 5 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.h ('k') | src/interpreter/bytecode-register.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef V8_INTERPRETER_BYTECODE_REGISTER_H_
6 #define V8_INTERPRETER_BYTECODE_REGISTER_H_
7
8 #include "src/interpreter/bytecodes.h"
9
10 #include "src/frames.h"
11
12 namespace v8 {
13 namespace internal {
14 namespace interpreter {
15
16 // An interpreter Register which is located in the function's Register file
17 // in its stack-frame. Register hold parameters, this, and expression values.
18 class Register final {
19 public:
20 explicit Register(int index = kInvalidIndex) : index_(index) {}
21
22 int index() const { return index_; }
23 bool is_parameter() const { return index() < 0; }
24 bool is_valid() const { return index_ != kInvalidIndex; }
25
26 static Register FromParameterIndex(int index, int parameter_count);
27 int ToParameterIndex(int parameter_count) const;
28
29 // Returns an invalid register.
30 static Register invalid_value() { return Register(); }
31
32 // Returns the register for the function's closure object.
33 static Register function_closure();
34 bool is_function_closure() const;
35
36 // Returns the register which holds the current context object.
37 static Register current_context();
38 bool is_current_context() const;
39
40 // Returns the register for the incoming new target value.
41 static Register new_target();
42 bool is_new_target() const;
43
44 // Returns the register for the bytecode array.
45 static Register bytecode_array();
46 bool is_bytecode_array() const;
47
48 // Returns the register for the saved bytecode offset.
49 static Register bytecode_offset();
50 bool is_bytecode_offset() const;
51
52 // Returns a register that can be used to represent the accumulator
53 // within code in the interpreter, but should never be emitted in
54 // bytecode.
55 static Register virtual_accumulator();
56
57 OperandSize SizeOfOperand() const;
58
59 int32_t ToOperand() const { return kRegisterFileStartOffset - index_; }
60 static Register FromOperand(int32_t operand) {
61 return Register(kRegisterFileStartOffset - operand);
62 }
63
64 static bool AreContiguous(Register reg1, Register reg2,
65 Register reg3 = Register(),
66 Register reg4 = Register(),
67 Register reg5 = Register());
68
69 std::string ToString(int parameter_count);
70
71 bool operator==(const Register& other) const {
72 return index() == other.index();
73 }
74 bool operator!=(const Register& other) const {
75 return index() != other.index();
76 }
77 bool operator<(const Register& other) const {
78 return index() < other.index();
79 }
80 bool operator<=(const Register& other) const {
81 return index() <= other.index();
82 }
83 bool operator>(const Register& other) const {
84 return index() > other.index();
85 }
86 bool operator>=(const Register& other) const {
87 return index() >= other.index();
88 }
89
90 private:
91 static const int kInvalidIndex = kMaxInt;
92 static const int kRegisterFileStartOffset =
93 InterpreterFrameConstants::kRegisterFileFromFp / kPointerSize;
94
95 void* operator new(size_t size) = delete;
96 void operator delete(void* p) = delete;
97
98 int index_;
99 };
100
101 } // namespace interpreter
102 } // namespace internal
103 } // namespace v8
104
105 #endif // V8_INTERPRETER_BYTECODE_REGISTER_H_
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-pipeline.h ('k') | src/interpreter/bytecode-register.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698