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

Side by Side Diff: src/interpreter/bytecode-array-builder.h

Issue 1595103006: [Interpreter] Preparation for wide registers. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. Created 4 years, 11 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/compiler/interpreter-assembler.cc ('k') | src/interpreter/bytecode-array-builder.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_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 "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/interpreter/bytecodes.h" 9 #include "src/interpreter/bytecodes.h"
10 #include "src/interpreter/constant-array-builder.h" 10 #include "src/interpreter/constant-array-builder.h"
11 #include "src/zone-containers.h" 11 #include "src/zone-containers.h"
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 15
16 class Isolate; 16 class Isolate;
17 17
18 namespace interpreter { 18 namespace interpreter {
19 19
20 class BytecodeLabel; 20 class BytecodeLabel;
21 class ConstantArrayBuilder;
22 class Register; 21 class Register;
23 22
24 // TODO(rmcilroy): Unify this with CreateArgumentsParameters::Type in Turbofan 23 // TODO(rmcilroy): Unify this with CreateArgumentsParameters::Type in Turbofan
25 // when rest parameters implementation has settled down. 24 // when rest parameters implementation has settled down.
26 enum class CreateArgumentsType { kMappedArguments, kUnmappedArguments }; 25 enum class CreateArgumentsType { kMappedArguments, kUnmappedArguments };
27 26
28 class BytecodeArrayBuilder final { 27 class BytecodeArrayBuilder final {
29 public: 28 public:
30 BytecodeArrayBuilder(Isolate* isolate, Zone* zone); 29 BytecodeArrayBuilder(Isolate* isolate, Zone* zone);
31 ~BytecodeArrayBuilder(); 30 ~BytecodeArrayBuilder();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 90
92 // Stores the object in the accumulator into |slot_index| of |context|. 91 // Stores the object in the accumulator into |slot_index| of |context|.
93 BytecodeArrayBuilder& StoreContextSlot(Register context, int slot_index); 92 BytecodeArrayBuilder& StoreContextSlot(Register context, int slot_index);
94 93
95 // Register-accumulator transfers. 94 // Register-accumulator transfers.
96 BytecodeArrayBuilder& LoadAccumulatorWithRegister(Register reg); 95 BytecodeArrayBuilder& LoadAccumulatorWithRegister(Register reg);
97 BytecodeArrayBuilder& StoreAccumulatorInRegister(Register reg); 96 BytecodeArrayBuilder& StoreAccumulatorInRegister(Register reg);
98 97
99 // Register-register transfer. 98 // Register-register transfer.
100 BytecodeArrayBuilder& MoveRegister(Register from, Register to); 99 BytecodeArrayBuilder& MoveRegister(Register from, Register to);
101 BytecodeArrayBuilder& ExchangeRegisters(Register reg0, Register reg1);
102 100
103 // Named load property. 101 // Named load property.
104 BytecodeArrayBuilder& LoadNamedProperty(Register object, 102 BytecodeArrayBuilder& LoadNamedProperty(Register object,
105 const Handle<String> name, 103 const Handle<String> name,
106 int feedback_slot, 104 int feedback_slot,
107 LanguageMode language_mode); 105 LanguageMode language_mode);
108 // Keyed load property. The key should be in the accumulator. 106 // Keyed load property. The key should be in the accumulator.
109 BytecodeArrayBuilder& LoadKeyedProperty(Register object, int feedback_slot, 107 BytecodeArrayBuilder& LoadKeyedProperty(Register object, int feedback_slot,
110 LanguageMode language_mode); 108 LanguageMode language_mode);
111 109
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 BytecodeArrayBuilder& ForInPrepare(Register cache_info_triple); 222 BytecodeArrayBuilder& ForInPrepare(Register cache_info_triple);
225 BytecodeArrayBuilder& ForInDone(Register index, Register cache_length); 223 BytecodeArrayBuilder& ForInDone(Register index, Register cache_length);
226 BytecodeArrayBuilder& ForInNext(Register receiver, Register index, 224 BytecodeArrayBuilder& ForInNext(Register receiver, Register index,
227 Register cache_type_array_pair); 225 Register cache_type_array_pair);
228 BytecodeArrayBuilder& ForInStep(Register index); 226 BytecodeArrayBuilder& ForInStep(Register index);
229 227
230 // Accessors 228 // Accessors
231 Zone* zone() const { return zone_; } 229 Zone* zone() const { return zone_; }
232 230
233 private: 231 private:
234 ZoneVector<uint8_t>* bytecodes() { return &bytecodes_; } 232 class PreviousBytecodeHelper;
235 const ZoneVector<uint8_t>* bytecodes() const { return &bytecodes_; } 233 friend class BytecodeRegisterAllocator;
236 Isolate* isolate() const { return isolate_; }
237 ConstantArrayBuilder* constant_array_builder() {
238 return &constant_array_builder_;
239 }
240 const ConstantArrayBuilder* constant_array_builder() const {
241 return &constant_array_builder_;
242 }
243 234
244 static Bytecode BytecodeForBinaryOperation(Token::Value op); 235 static Bytecode BytecodeForBinaryOperation(Token::Value op);
245 static Bytecode BytecodeForCountOperation(Token::Value op); 236 static Bytecode BytecodeForCountOperation(Token::Value op);
246 static Bytecode BytecodeForCompareOperation(Token::Value op); 237 static Bytecode BytecodeForCompareOperation(Token::Value op);
247 static Bytecode BytecodeForWideOperands(Bytecode bytecode); 238 static Bytecode BytecodeForWideOperands(Bytecode bytecode);
248 static Bytecode BytecodeForLoadIC(LanguageMode language_mode); 239 static Bytecode BytecodeForLoadIC(LanguageMode language_mode);
249 static Bytecode BytecodeForKeyedLoadIC(LanguageMode language_mode); 240 static Bytecode BytecodeForKeyedLoadIC(LanguageMode language_mode);
250 static Bytecode BytecodeForStoreIC(LanguageMode language_mode); 241 static Bytecode BytecodeForStoreIC(LanguageMode language_mode);
251 static Bytecode BytecodeForKeyedStoreIC(LanguageMode language_mode); 242 static Bytecode BytecodeForKeyedStoreIC(LanguageMode language_mode);
252 static Bytecode BytecodeForLoadGlobal(LanguageMode language_mode, 243 static Bytecode BytecodeForLoadGlobal(LanguageMode language_mode,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 const ZoneVector<uint8_t>::iterator& jump_location, int delta); 280 const ZoneVector<uint8_t>::iterator& jump_location, int delta);
290 void PatchIndirectJumpWith16BitOperand( 281 void PatchIndirectJumpWith16BitOperand(
291 const ZoneVector<uint8_t>::iterator& jump_location, int delta); 282 const ZoneVector<uint8_t>::iterator& jump_location, int delta);
292 283
293 void LeaveBasicBlock(); 284 void LeaveBasicBlock();
294 void EnsureReturn(); 285 void EnsureReturn();
295 286
296 bool OperandIsValid(Bytecode bytecode, int operand_index, 287 bool OperandIsValid(Bytecode bytecode, int operand_index,
297 uint32_t operand_value) const; 288 uint32_t operand_value) const;
298 bool LastBytecodeInSameBlock() const; 289 bool LastBytecodeInSameBlock() const;
290 bool RegisterIsValid(Register reg, OperandType reg_type) const;
299 291
300 bool NeedToBooleanCast(); 292 bool NeedToBooleanCast();
301 bool IsRegisterInAccumulator(Register reg); 293 bool IsRegisterInAccumulator(Register reg);
302 294
303 bool RegisterIsValid(Register reg) const;
304
305 // Temporary register management. 295 // Temporary register management.
306 int BorrowTemporaryRegister(); 296 int BorrowTemporaryRegister();
307 int BorrowTemporaryRegisterNotInRange(int start_index, int end_index); 297 int BorrowTemporaryRegisterNotInRange(int start_index, int end_index);
308 void ReturnTemporaryRegister(int reg_index); 298 void ReturnTemporaryRegister(int reg_index);
309 int PrepareForConsecutiveTemporaryRegisters(size_t count); 299 int PrepareForConsecutiveTemporaryRegisters(size_t count);
310 void BorrowConsecutiveTemporaryRegister(int reg_index); 300 void BorrowConsecutiveTemporaryRegister(int reg_index);
311 bool TemporaryRegisterIsLive(Register reg) const; 301 bool TemporaryRegisterIsLive(Register reg) const;
312 302
313 Register first_temporary_register() const; 303 Register first_temporary_register() const;
314 Register last_temporary_register() const; 304 Register last_temporary_register() const;
315 305
316 // Gets a constant pool entry for the |object|. 306 // Gets a constant pool entry for the |object|.
317 size_t GetConstantPoolEntry(Handle<Object> object); 307 size_t GetConstantPoolEntry(Handle<Object> object);
318 308
309 ZoneVector<uint8_t>* bytecodes() { return &bytecodes_; }
310 const ZoneVector<uint8_t>* bytecodes() const { return &bytecodes_; }
311 Isolate* isolate() const { return isolate_; }
312 ConstantArrayBuilder* constant_array_builder() {
313 return &constant_array_builder_;
314 }
315 const ConstantArrayBuilder* constant_array_builder() const {
316 return &constant_array_builder_;
317 }
318
319 Isolate* isolate_; 319 Isolate* isolate_;
320 Zone* zone_; 320 Zone* zone_;
321 ZoneVector<uint8_t> bytecodes_; 321 ZoneVector<uint8_t> bytecodes_;
322 bool bytecode_generated_; 322 bool bytecode_generated_;
323 ConstantArrayBuilder constant_array_builder_; 323 ConstantArrayBuilder constant_array_builder_;
324 size_t last_block_end_; 324 size_t last_block_end_;
325 size_t last_bytecode_start_; 325 size_t last_bytecode_start_;
326 bool exit_seen_in_block_; 326 bool exit_seen_in_block_;
327 int unbound_jumps_; 327 int unbound_jumps_;
328 328
329 int parameter_count_; 329 int parameter_count_;
330 int local_register_count_; 330 int local_register_count_;
331 int context_register_count_; 331 int context_register_count_;
332 int temporary_register_count_; 332 int temporary_register_count_;
333 ZoneSet<int> free_temporaries_; 333 ZoneSet<int> free_temporaries_;
334 334
335 class PreviousBytecodeHelper;
336 friend class BytecodeRegisterAllocator;
337
338 DISALLOW_COPY_AND_ASSIGN(BytecodeArrayBuilder); 335 DISALLOW_COPY_AND_ASSIGN(BytecodeArrayBuilder);
339 }; 336 };
340 337
341 338
342 // A label representing a branch target in a bytecode array. When a 339 // A label representing a branch target in a bytecode array. When a
343 // label is bound, it represents a known position in the bytecode 340 // label is bound, it represents a known position in the bytecode
344 // array. For labels that are forward references there can be at most 341 // array. For labels that are forward references there can be at most
345 // one reference whilst it is unbound. 342 // one reference whilst it is unbound.
346 class BytecodeLabel final { 343 class BytecodeLabel final {
347 public: 344 public:
(...skipping 29 matching lines...) Expand all
377 size_t offset_; 374 size_t offset_;
378 375
379 friend class BytecodeArrayBuilder; 376 friend class BytecodeArrayBuilder;
380 }; 377 };
381 378
382 } // namespace interpreter 379 } // namespace interpreter
383 } // namespace internal 380 } // namespace internal
384 } // namespace v8 381 } // namespace v8
385 382
386 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ 383 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_
OLDNEW
« no previous file with comments | « src/compiler/interpreter-assembler.cc ('k') | src/interpreter/bytecode-array-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698