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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // Call the runtime function with |function_id|. The first argument should be | 124 // Call the runtime function with |function_id|. The first argument should be |
125 // in |first_arg| and all subsequent arguments should be in registers | 125 // in |first_arg| and all subsequent arguments should be in registers |
126 // <first_arg + 1> to <first_arg + 1 + arg_count>. | 126 // <first_arg + 1> to <first_arg + 1 + arg_count>. |
127 BytecodeArrayBuilder& CallRuntime(Runtime::FunctionId function_id, | 127 BytecodeArrayBuilder& CallRuntime(Runtime::FunctionId function_id, |
128 Register first_arg, size_t arg_count); | 128 Register first_arg, size_t arg_count); |
129 | 129 |
130 // Operators (register holds the lhs value, accumulator holds the rhs value). | 130 // Operators (register holds the lhs value, accumulator holds the rhs value). |
131 BytecodeArrayBuilder& BinaryOperation(Token::Value binop, Register reg, | 131 BytecodeArrayBuilder& BinaryOperation(Token::Value binop, Register reg, |
132 Strength strength); | 132 Strength strength); |
133 | 133 |
| 134 // Count Operators (value stored in accumulator). |
| 135 BytecodeArrayBuilder& CountOperation(Token::Value op, Strength strength); |
| 136 |
134 // Unary Operators. | 137 // Unary Operators. |
135 BytecodeArrayBuilder& LogicalNot(); | 138 BytecodeArrayBuilder& LogicalNot(); |
136 BytecodeArrayBuilder& TypeOf(); | 139 BytecodeArrayBuilder& TypeOf(); |
137 | 140 |
138 // Tests. | 141 // Tests. |
139 BytecodeArrayBuilder& CompareOperation(Token::Value op, Register reg, | 142 BytecodeArrayBuilder& CompareOperation(Token::Value op, Register reg, |
140 Strength strength); | 143 Strength strength); |
141 | 144 |
142 // Casts | 145 // Casts |
143 BytecodeArrayBuilder& CastAccumulatorToBoolean(); | 146 BytecodeArrayBuilder& CastAccumulatorToBoolean(); |
144 BytecodeArrayBuilder& CastAccumulatorToName(); | 147 BytecodeArrayBuilder& CastAccumulatorToName(); |
| 148 BytecodeArrayBuilder& CastAccumulatorToNumber(); |
145 | 149 |
146 // Flow Control. | 150 // Flow Control. |
147 BytecodeArrayBuilder& Bind(BytecodeLabel* label); | 151 BytecodeArrayBuilder& Bind(BytecodeLabel* label); |
148 BytecodeArrayBuilder& Bind(const BytecodeLabel& target, BytecodeLabel* label); | 152 BytecodeArrayBuilder& Bind(const BytecodeLabel& target, BytecodeLabel* label); |
149 | 153 |
150 BytecodeArrayBuilder& Jump(BytecodeLabel* label); | 154 BytecodeArrayBuilder& Jump(BytecodeLabel* label); |
151 BytecodeArrayBuilder& JumpIfTrue(BytecodeLabel* label); | 155 BytecodeArrayBuilder& JumpIfTrue(BytecodeLabel* label); |
152 BytecodeArrayBuilder& JumpIfFalse(BytecodeLabel* label); | 156 BytecodeArrayBuilder& JumpIfFalse(BytecodeLabel* label); |
153 // TODO(mythria) The following two functions should be merged into | 157 // TODO(mythria) The following two functions should be merged into |
154 // JumpIfTrue/False. These bytecodes should be automatically chosen rather | 158 // JumpIfTrue/False. These bytecodes should be automatically chosen rather |
155 // than explicitly using them. | 159 // than explicitly using them. |
156 BytecodeArrayBuilder& JumpIfToBooleanTrue(BytecodeLabel* label); | 160 BytecodeArrayBuilder& JumpIfToBooleanTrue(BytecodeLabel* label); |
157 BytecodeArrayBuilder& JumpIfToBooleanFalse(BytecodeLabel* label); | 161 BytecodeArrayBuilder& JumpIfToBooleanFalse(BytecodeLabel* label); |
158 BytecodeArrayBuilder& Return(); | 162 BytecodeArrayBuilder& Return(); |
159 | 163 |
160 BytecodeArrayBuilder& EnterBlock(); | 164 BytecodeArrayBuilder& EnterBlock(); |
161 BytecodeArrayBuilder& LeaveBlock(); | 165 BytecodeArrayBuilder& LeaveBlock(); |
162 | 166 |
163 // Accessors | 167 // Accessors |
164 Zone* zone() const { return zone_; } | 168 Zone* zone() const { return zone_; } |
165 | 169 |
166 private: | 170 private: |
167 ZoneVector<uint8_t>* bytecodes() { return &bytecodes_; } | 171 ZoneVector<uint8_t>* bytecodes() { return &bytecodes_; } |
168 const ZoneVector<uint8_t>* bytecodes() const { return &bytecodes_; } | 172 const ZoneVector<uint8_t>* bytecodes() const { return &bytecodes_; } |
169 Isolate* isolate() const { return isolate_; } | 173 Isolate* isolate() const { return isolate_; } |
170 | 174 |
171 static Bytecode BytecodeForBinaryOperation(Token::Value op); | 175 static Bytecode BytecodeForBinaryOperation(Token::Value op); |
| 176 static Bytecode BytecodeForCountOperation(Token::Value op); |
172 static Bytecode BytecodeForCompareOperation(Token::Value op); | 177 static Bytecode BytecodeForCompareOperation(Token::Value op); |
173 static Bytecode BytecodeForLoadIC(LanguageMode language_mode); | 178 static Bytecode BytecodeForLoadIC(LanguageMode language_mode); |
174 static Bytecode BytecodeForKeyedLoadIC(LanguageMode language_mode); | 179 static Bytecode BytecodeForKeyedLoadIC(LanguageMode language_mode); |
175 static Bytecode BytecodeForStoreIC(LanguageMode language_mode); | 180 static Bytecode BytecodeForStoreIC(LanguageMode language_mode); |
176 static Bytecode BytecodeForKeyedStoreIC(LanguageMode language_mode); | 181 static Bytecode BytecodeForKeyedStoreIC(LanguageMode language_mode); |
177 static Bytecode BytecodeForStoreGlobal(LanguageMode language_mode); | 182 static Bytecode BytecodeForStoreGlobal(LanguageMode language_mode); |
178 | 183 |
179 static bool FitsInIdx8Operand(int value); | 184 static bool FitsInIdx8Operand(int value); |
180 static bool FitsInIdx8Operand(size_t value); | 185 static bool FitsInIdx8Operand(size_t value); |
181 static bool FitsInImm8Operand(int value); | 186 static bool FitsInImm8Operand(int value); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 | 291 |
287 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); | 292 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); |
288 }; | 293 }; |
289 | 294 |
290 | 295 |
291 } // namespace interpreter | 296 } // namespace interpreter |
292 } // namespace internal | 297 } // namespace internal |
293 } // namespace v8 | 298 } // namespace v8 |
294 | 299 |
295 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 300 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
OLD | NEW |