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

Side by Side Diff: src/interpreter/bytecodes.h

Issue 1613163002: [interpreter] Wide register support. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Compilation fixes for gcc/msvc. 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
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_BYTECODES_H_ 5 #ifndef V8_INTERPRETER_BYTECODES_H_
6 #define V8_INTERPRETER_BYTECODES_H_ 6 #define V8_INTERPRETER_BYTECODES_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 9
10 // Clients of this interface shouldn't depend on lots of interpreter internals. 10 // Clients of this interface shouldn't depend on lots of interpreter internals.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 \ 97 \
98 /* Register-register transfers */ \ 98 /* Register-register transfers */ \
99 V(Mov, OperandType::kReg8, OperandType::kReg8) \ 99 V(Mov, OperandType::kReg8, OperandType::kReg8) \
100 V(MovWide, OperandType::kReg16, OperandType::kReg16) \ 100 V(MovWide, OperandType::kReg16, OperandType::kReg16) \
101 \ 101 \
102 /* LoadIC operations */ \ 102 /* LoadIC operations */ \
103 V(LoadICSloppy, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ 103 V(LoadICSloppy, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \
104 V(LoadICStrict, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ 104 V(LoadICStrict, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \
105 V(KeyedLoadICSloppy, OperandType::kReg8, OperandType::kIdx8) \ 105 V(KeyedLoadICSloppy, OperandType::kReg8, OperandType::kIdx8) \
106 V(KeyedLoadICStrict, OperandType::kReg8, OperandType::kIdx8) \ 106 V(KeyedLoadICStrict, OperandType::kReg8, OperandType::kIdx8) \
107 /* TODO(rmcilroy): Wide register operands too? */ \
108 V(LoadICSloppyWide, OperandType::kReg8, OperandType::kIdx16, \ 107 V(LoadICSloppyWide, OperandType::kReg8, OperandType::kIdx16, \
109 OperandType::kIdx16) \ 108 OperandType::kIdx16) \
110 V(LoadICStrictWide, OperandType::kReg8, OperandType::kIdx16, \ 109 V(LoadICStrictWide, OperandType::kReg8, OperandType::kIdx16, \
111 OperandType::kIdx16) \ 110 OperandType::kIdx16) \
112 V(KeyedLoadICSloppyWide, OperandType::kReg8, OperandType::kIdx16) \ 111 V(KeyedLoadICSloppyWide, OperandType::kReg8, OperandType::kIdx16) \
113 V(KeyedLoadICStrictWide, OperandType::kReg8, OperandType::kIdx16) \ 112 V(KeyedLoadICStrictWide, OperandType::kReg8, OperandType::kIdx16) \
114 \ 113 \
115 /* StoreIC operations */ \ 114 /* StoreIC operations */ \
116 V(StoreICSloppy, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ 115 V(StoreICSloppy, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \
117 V(StoreICStrict, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \ 116 V(StoreICStrict, OperandType::kReg8, OperandType::kIdx8, OperandType::kIdx8) \
118 V(KeyedStoreICSloppy, OperandType::kReg8, OperandType::kReg8, \ 117 V(KeyedStoreICSloppy, OperandType::kReg8, OperandType::kReg8, \
119 OperandType::kIdx8) \ 118 OperandType::kIdx8) \
120 V(KeyedStoreICStrict, OperandType::kReg8, OperandType::kReg8, \ 119 V(KeyedStoreICStrict, OperandType::kReg8, OperandType::kReg8, \
121 OperandType::kIdx8) \ 120 OperandType::kIdx8) \
122 /* TODO(rmcilroy): Wide register operands too? */ \
123 V(StoreICSloppyWide, OperandType::kReg8, OperandType::kIdx16, \ 121 V(StoreICSloppyWide, OperandType::kReg8, OperandType::kIdx16, \
124 OperandType::kIdx16) \ 122 OperandType::kIdx16) \
125 V(StoreICStrictWide, OperandType::kReg8, OperandType::kIdx16, \ 123 V(StoreICStrictWide, OperandType::kReg8, OperandType::kIdx16, \
126 OperandType::kIdx16) \ 124 OperandType::kIdx16) \
127 V(KeyedStoreICSloppyWide, OperandType::kReg8, OperandType::kReg8, \ 125 V(KeyedStoreICSloppyWide, OperandType::kReg8, OperandType::kReg8, \
128 OperandType::kIdx16) \ 126 OperandType::kIdx16) \
129 V(KeyedStoreICStrictWide, OperandType::kReg8, OperandType::kReg8, \ 127 V(KeyedStoreICStrictWide, OperandType::kReg8, OperandType::kReg8, \
130 OperandType::kIdx16) \ 128 OperandType::kIdx16) \
131 \ 129 \
132 /* Binary Operators */ \ 130 /* Binary Operators */ \
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 // evaluate to the same value as the last real bytecode. 280 // evaluate to the same value as the last real bytecode.
283 kLast = -1 BYTECODE_LIST(COUNT_BYTECODE) 281 kLast = -1 BYTECODE_LIST(COUNT_BYTECODE)
284 #undef COUNT_BYTECODE 282 #undef COUNT_BYTECODE
285 }; 283 };
286 284
287 285
288 // An interpreter Register which is located in the function's Register file 286 // An interpreter Register which is located in the function's Register file
289 // in its stack-frame. Register hold parameters, this, and expression values. 287 // in its stack-frame. Register hold parameters, this, and expression values.
290 class Register { 288 class Register {
291 public: 289 public:
292 Register() : index_(kIllegalIndex) {} 290 explicit Register(int index = kInvalidIndex) : index_(index) {}
293
294 explicit Register(int index) : index_(index) {}
295 291
296 int index() const { 292 int index() const {
297 DCHECK(index_ != kIllegalIndex); 293 DCHECK(index_ != kInvalidIndex);
298 return index_; 294 return index_;
299 } 295 }
300 bool is_parameter() const { return index() < 0; } 296 bool is_parameter() const { return index() < 0; }
301 bool is_valid() const { return index_ != kIllegalIndex; } 297 bool is_valid() const { return index_ != kInvalidIndex; }
298 bool is_byte_operand() const;
299 bool is_short_operand() const;
302 300
303 static Register FromParameterIndex(int index, int parameter_count); 301 static Register FromParameterIndex(int index, int parameter_count);
304 int ToParameterIndex(int parameter_count) const; 302 int ToParameterIndex(int parameter_count) const;
305 static int MaxParameterIndex(); 303 static int MaxParameterIndex();
304 static int MaxRegisterIndex();
305 static int MaxRegisterIndexForByteOperand();
306 306
307 // Returns the register for the function's closure object. 307 // Returns the register for the function's closure object.
308 static Register function_closure(); 308 static Register function_closure();
309 bool is_function_closure() const; 309 bool is_function_closure() const;
310 310
311 // Returns the register which holds the current context object. 311 // Returns the register which holds the current context object.
312 static Register current_context(); 312 static Register current_context();
313 bool is_current_context() const; 313 bool is_current_context() const;
314 314
315 // Returns the register for the incoming new target value. 315 // Returns the register for the incoming new target value.
(...skipping 27 matching lines...) Expand all
343 return index() <= other.index(); 343 return index() <= other.index();
344 } 344 }
345 bool operator>(const Register& other) const { 345 bool operator>(const Register& other) const {
346 return index() > other.index(); 346 return index() > other.index();
347 } 347 }
348 bool operator>=(const Register& other) const { 348 bool operator>=(const Register& other) const {
349 return index() >= other.index(); 349 return index() >= other.index();
350 } 350 }
351 351
352 private: 352 private:
353 static const int kIllegalIndex = kMaxInt; 353 static const int kInvalidIndex = kMaxInt;
354 354
355 void* operator new(size_t size); 355 void* operator new(size_t size);
356 void operator delete(void* p); 356 void operator delete(void* p);
357 357
358 int index_; 358 int index_;
359 }; 359 };
360 360
361 361
362 class Bytecodes { 362 class Bytecodes {
363 public: 363 public:
364 // Returns string representation of |bytecode|. 364 // Returns string representation of |bytecode|.
365 static const char* ToString(Bytecode bytecode); 365 static const char* ToString(Bytecode bytecode);
366 366
367 // Returns string representation of |operand_type|. 367 // Returns string representation of |operand_type|.
368 static const char* OperandTypeToString(OperandType operand_type); 368 static const char* OperandTypeToString(OperandType operand_type);
369 369
370 // Returns string representation of |operand_size|. 370 // Returns string representation of |operand_size|.
371 static const char* OperandSizeToString(OperandSize operand_size); 371 static const char* OperandSizeToString(OperandSize operand_size);
372 372
373 // Returns byte value of bytecode. 373 // Returns byte value of bytecode.
374 static uint8_t ToByte(Bytecode bytecode); 374 static uint8_t ToByte(Bytecode bytecode);
375 375
376 // Returns bytecode for |value|. 376 // Returns bytecode for |value|.
377 static Bytecode FromByte(uint8_t value); 377 static Bytecode FromByte(uint8_t value);
378 378
379 // Returns the number of operands expected by |bytecode|. 379 // Returns the number of operands expected by |bytecode|.
380 static int NumberOfOperands(Bytecode bytecode); 380 static int NumberOfOperands(Bytecode bytecode);
381 381
382 // Returns the number of register operands expected by |bytecode|.
383 static int NumberOfRegisterOperands(Bytecode bytecode);
384
382 // Return the i-th operand of |bytecode|. 385 // Return the i-th operand of |bytecode|.
383 static OperandType GetOperandType(Bytecode bytecode, int i); 386 static OperandType GetOperandType(Bytecode bytecode, int i);
384 387
385 // Return the size of the i-th operand of |bytecode|. 388 // Return the size of the i-th operand of |bytecode|.
386 static OperandSize GetOperandSize(Bytecode bytecode, int i); 389 static OperandSize GetOperandSize(Bytecode bytecode, int i);
387 390
388 // Returns the offset of the i-th operand of |bytecode| relative to the start 391 // Returns the offset of the i-th operand of |bytecode| relative to the start
389 // of the bytecode. 392 // of the bytecode.
390 static int GetOperandOffset(Bytecode bytecode, int i); 393 static int GetOperandOffset(Bytecode bytecode, int i);
391 394
395 // Returns a zero-based bit of the register operand positions of |bitmap|.
rmcilroy 2016/01/25 12:12:05 /s/bit/bitmap/ and /s/|bitmap|/|bytecode|
oth 2016/01/25 16:51:56 Done.
396 static int GetRegisterOperandBitmap(Bytecode bytecode);
397
392 // Returns the size of the bytecode including its operands. 398 // Returns the size of the bytecode including its operands.
393 static int Size(Bytecode bytecode); 399 static int Size(Bytecode bytecode);
394 400
395 // Returns the size of |operand|. 401 // Returns the size of |operand|.
396 static OperandSize SizeOfOperand(OperandType operand); 402 static OperandSize SizeOfOperand(OperandType operand);
397 403
398 // Return true if the bytecode is a conditional jump taking 404 // Returns true if the bytecode is a conditional jump taking
399 // an immediate byte operand (OperandType::kImm8). 405 // an immediate byte operand (OperandType::kImm8).
400 static bool IsConditionalJumpImmediate(Bytecode bytecode); 406 static bool IsConditionalJumpImmediate(Bytecode bytecode);
401 407
402 // Return true if the bytecode is a conditional jump taking 408 // Returns true if the bytecode is a conditional jump taking
403 // a constant pool entry (OperandType::kIdx8). 409 // a constant pool entry (OperandType::kIdx8).
404 static bool IsConditionalJumpConstant(Bytecode bytecode); 410 static bool IsConditionalJumpConstant(Bytecode bytecode);
405 411
406 // Return true if the bytecode is a conditional jump taking 412 // Returns true if the bytecode is a conditional jump taking
407 // a constant pool entry (OperandType::kIdx16). 413 // a constant pool entry (OperandType::kIdx16).
408 static bool IsConditionalJumpConstantWide(Bytecode bytecode); 414 static bool IsConditionalJumpConstantWide(Bytecode bytecode);
409 415
410 // Return true if the bytecode is a conditional jump taking 416 // Returns true if the bytecode is a conditional jump taking
411 // any kind of operand. 417 // any kind of operand.
412 static bool IsConditionalJump(Bytecode bytecode); 418 static bool IsConditionalJump(Bytecode bytecode);
413 419
414 // Return true if the bytecode is a jump or a conditional jump taking 420 // Returns true if the bytecode is a jump or a conditional jump taking
415 // an immediate byte operand (OperandType::kImm8). 421 // an immediate byte operand (OperandType::kImm8).
416 static bool IsJumpImmediate(Bytecode bytecode); 422 static bool IsJumpImmediate(Bytecode bytecode);
417 423
418 // Return true if the bytecode is a jump or conditional jump taking a 424 // Returns true if the bytecode is a jump or conditional jump taking a
419 // constant pool entry (OperandType::kIdx8). 425 // constant pool entry (OperandType::kIdx8).
420 static bool IsJumpConstant(Bytecode bytecode); 426 static bool IsJumpConstant(Bytecode bytecode);
421 427
422 // Return true if the bytecode is a jump or conditional jump taking a 428 // Returns true if the bytecode is a jump or conditional jump taking a
423 // constant pool entry (OperandType::kIdx16). 429 // constant pool entry (OperandType::kIdx16).
424 static bool IsJumpConstantWide(Bytecode bytecode); 430 static bool IsJumpConstantWide(Bytecode bytecode);
425 431
426 // Return true if the bytecode is a jump or conditional jump taking 432 // Return true if the bytecode is a jump or conditional jump taking
427 // any kind of operand. 433 // any kind of operand.
428 static bool IsJump(Bytecode bytecode); 434 static bool IsJump(Bytecode bytecode);
429 435
430 // Return true if the bytecode is a conditional jump, a jump, or a return. 436 // Return true if the bytecode is a conditional jump, a jump, or a return.
431 static bool IsJumpOrReturn(Bytecode bytecode); 437 static bool IsJumpOrReturn(Bytecode bytecode);
432 438
433 // Decode a single bytecode and operands to |os|. 439 // Decode a single bytecode and operands to |os|.
434 static std::ostream& Decode(std::ostream& os, const uint8_t* bytecode_start, 440 static std::ostream& Decode(std::ostream& os, const uint8_t* bytecode_start,
435 int number_of_parameters); 441 int number_of_parameters);
436 442
437 private: 443 private:
438 DISALLOW_IMPLICIT_CONSTRUCTORS(Bytecodes); 444 DISALLOW_IMPLICIT_CONSTRUCTORS(Bytecodes);
439 }; 445 };
440 446
441 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode); 447 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode);
442 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type); 448 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type);
443 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_type); 449 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_type);
444 450
445 } // namespace interpreter 451 } // namespace interpreter
446 } // namespace internal 452 } // namespace internal
447 } // namespace v8 453 } // namespace v8
448 454
449 #endif // V8_INTERPRETER_BYTECODES_H_ 455 #endif // V8_INTERPRETER_BYTECODES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698