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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 // Deletes property from an object. This expects that accumulator contains | 163 // Deletes property from an object. This expects that accumulator contains |
164 // the key to be deleted and the register contains a reference to the object. | 164 // the key to be deleted and the register contains a reference to the object. |
165 BytecodeArrayBuilder& Delete(Register object, LanguageMode language_mode); | 165 BytecodeArrayBuilder& Delete(Register object, LanguageMode language_mode); |
166 | 166 |
167 // Tests. | 167 // Tests. |
168 BytecodeArrayBuilder& CompareOperation(Token::Value op, Register reg, | 168 BytecodeArrayBuilder& CompareOperation(Token::Value op, Register reg, |
169 Strength strength); | 169 Strength strength); |
170 | 170 |
171 // Casts. | 171 // Casts. |
172 BytecodeArrayBuilder& CastAccumulatorToBoolean(); | 172 BytecodeArrayBuilder& CastAccumulatorToBoolean(); |
| 173 BytecodeArrayBuilder& CastAccumulatorToJSObject(); |
173 BytecodeArrayBuilder& CastAccumulatorToName(); | 174 BytecodeArrayBuilder& CastAccumulatorToName(); |
174 BytecodeArrayBuilder& CastAccumulatorToNumber(); | 175 BytecodeArrayBuilder& CastAccumulatorToNumber(); |
175 | 176 |
176 // Flow Control. | 177 // Flow Control. |
177 BytecodeArrayBuilder& Bind(BytecodeLabel* label); | 178 BytecodeArrayBuilder& Bind(BytecodeLabel* label); |
178 BytecodeArrayBuilder& Bind(const BytecodeLabel& target, BytecodeLabel* label); | 179 BytecodeArrayBuilder& Bind(const BytecodeLabel& target, BytecodeLabel* label); |
179 | 180 |
180 BytecodeArrayBuilder& Jump(BytecodeLabel* label); | 181 BytecodeArrayBuilder& Jump(BytecodeLabel* label); |
181 BytecodeArrayBuilder& JumpIfTrue(BytecodeLabel* label); | 182 BytecodeArrayBuilder& JumpIfTrue(BytecodeLabel* label); |
182 BytecodeArrayBuilder& JumpIfFalse(BytecodeLabel* label); | 183 BytecodeArrayBuilder& JumpIfFalse(BytecodeLabel* label); |
| 184 BytecodeArrayBuilder& JumpIfNull(BytecodeLabel* label); |
| 185 BytecodeArrayBuilder& JumpIfUndefined(BytecodeLabel* label); |
183 // TODO(mythria) The following two functions should be merged into | 186 // TODO(mythria) The following two functions should be merged into |
184 // JumpIfTrue/False. These bytecodes should be automatically chosen rather | 187 // JumpIfTrue/False. These bytecodes should be automatically chosen rather |
185 // than explicitly using them. | 188 // than explicitly using them. |
186 BytecodeArrayBuilder& JumpIfToBooleanTrue(BytecodeLabel* label); | 189 BytecodeArrayBuilder& JumpIfToBooleanTrue(BytecodeLabel* label); |
187 BytecodeArrayBuilder& JumpIfToBooleanFalse(BytecodeLabel* label); | 190 BytecodeArrayBuilder& JumpIfToBooleanFalse(BytecodeLabel* label); |
188 | 191 |
189 BytecodeArrayBuilder& Throw(); | 192 BytecodeArrayBuilder& Throw(); |
190 BytecodeArrayBuilder& Return(); | 193 BytecodeArrayBuilder& Return(); |
191 | 194 |
| 195 // Complex flow control. |
| 196 BytecodeArrayBuilder& ForInPrepare(Register receiver); |
| 197 BytecodeArrayBuilder& ForInNext(Register for_in_state, Register index); |
| 198 BytecodeArrayBuilder& ForInDone(Register for_in_state); |
| 199 |
192 BytecodeArrayBuilder& EnterBlock(); | 200 BytecodeArrayBuilder& EnterBlock(); |
193 BytecodeArrayBuilder& LeaveBlock(); | 201 BytecodeArrayBuilder& LeaveBlock(); |
194 | 202 |
195 // Accessors | 203 // Accessors |
196 Zone* zone() const { return zone_; } | 204 Zone* zone() const { return zone_; } |
197 | 205 |
198 private: | 206 private: |
199 ZoneVector<uint8_t>* bytecodes() { return &bytecodes_; } | 207 ZoneVector<uint8_t>* bytecodes() { return &bytecodes_; } |
200 const ZoneVector<uint8_t>* bytecodes() const { return &bytecodes_; } | 208 const ZoneVector<uint8_t>* bytecodes() const { return &bytecodes_; } |
201 Isolate* isolate() const { return isolate_; } | 209 Isolate* isolate() const { return isolate_; } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 | 288 |
281 private: | 289 private: |
282 static const size_t kInvalidOffset = static_cast<size_t>(-1); | 290 static const size_t kInvalidOffset = static_cast<size_t>(-1); |
283 | 291 |
284 INLINE(void bind_to(size_t offset)) { | 292 INLINE(void bind_to(size_t offset)) { |
285 DCHECK(!bound_ && offset != kInvalidOffset); | 293 DCHECK(!bound_ && offset != kInvalidOffset); |
286 offset_ = offset; | 294 offset_ = offset; |
287 bound_ = true; | 295 bound_ = true; |
288 } | 296 } |
289 INLINE(void set_referrer(size_t offset)) { | 297 INLINE(void set_referrer(size_t offset)) { |
290 DCHECK(!bound_ && offset != kInvalidOffset); | 298 DCHECK(!bound_ && offset != kInvalidOffset && offset_ == kInvalidOffset); |
291 offset_ = offset; | 299 offset_ = offset; |
292 } | 300 } |
293 INLINE(size_t offset() const) { return offset_; } | 301 INLINE(size_t offset() const) { return offset_; } |
294 INLINE(bool is_bound() const) { return bound_; } | 302 INLINE(bool is_bound() const) { return bound_; } |
295 INLINE(bool is_forward_target() const) { | 303 INLINE(bool is_forward_target() const) { |
296 return offset() != kInvalidOffset && !is_bound(); | 304 return offset() != kInvalidOffset && !is_bound(); |
297 } | 305 } |
298 | 306 |
299 // There are three states for a label: | 307 // There are three states for a label: |
300 // bound_ offset_ | 308 // bound_ offset_ |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 | 343 |
336 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); | 344 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); |
337 }; | 345 }; |
338 | 346 |
339 | 347 |
340 } // namespace interpreter | 348 } // namespace interpreter |
341 } // namespace internal | 349 } // namespace internal |
342 } // namespace v8 | 350 } // namespace v8 |
343 | 351 |
344 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 352 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
OLD | NEW |