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

Unified Diff: src/interpreter/bytecodes.h

Issue 2149093002: Reland "[interpreter] Reduce dependencies in bytecodes.{h,cc}" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/interpreter/bytecode-register.cc ('k') | src/interpreter/bytecodes.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecodes.h
diff --git a/src/interpreter/bytecodes.h b/src/interpreter/bytecodes.h
index 36041cb97e5bc59b27a5be846787275ef2844395..43aeb30d3bb500ce3ed5dff2ad033aeb568fb0bb 100644
--- a/src/interpreter/bytecodes.h
+++ b/src/interpreter/bytecodes.h
@@ -5,12 +5,13 @@
#ifndef V8_INTERPRETER_BYTECODES_H_
#define V8_INTERPRETER_BYTECODES_H_
+#include <cstdint>
#include <iosfwd>
+#include <string>
-// Clients of this interface shouldn't depend on lots of interpreter internals.
-// Do not include anything from src/interpreter here!
-#include "src/frames.h"
-#include "src/utils.h"
+// This interface and it's implementation are independent of the
+// libv8_base library as they are used by the interpreter and the
+// standalone mkpeephole table generator program.
namespace v8 {
namespace internal {
@@ -286,12 +287,12 @@ enum class AccumulatorUse : uint8_t {
kReadWrite = kRead | kWrite
};
-V8_INLINE AccumulatorUse operator&(AccumulatorUse lhs, AccumulatorUse rhs) {
+inline AccumulatorUse operator&(AccumulatorUse lhs, AccumulatorUse rhs) {
int result = static_cast<int>(lhs) & static_cast<int>(rhs);
return static_cast<AccumulatorUse>(result);
}
-V8_INLINE AccumulatorUse operator|(AccumulatorUse lhs, AccumulatorUse rhs) {
+inline AccumulatorUse operator|(AccumulatorUse lhs, AccumulatorUse rhs) {
int result = static_cast<int>(lhs) | static_cast<int>(rhs);
return static_cast<AccumulatorUse>(result);
}
@@ -348,7 +349,6 @@ enum class OperandType : uint8_t {
#undef COUNT_OPERAND_TYPES
};
-
// Enumeration of interpreter bytecodes.
enum class Bytecode : uint8_t {
#define DECLARE_BYTECODE(Name, ...) k##Name,
@@ -361,94 +361,7 @@ enum class Bytecode : uint8_t {
#undef COUNT_BYTECODE
};
-
-// An interpreter Register which is located in the function's Register file
-// in its stack-frame. Register hold parameters, this, and expression values.
-class Register final {
- public:
- explicit Register(int index = kInvalidIndex) : index_(index) {}
-
- int index() const { return index_; }
- bool is_parameter() const { return index() < 0; }
- bool is_valid() const { return index_ != kInvalidIndex; }
-
- static Register FromParameterIndex(int index, int parameter_count);
- int ToParameterIndex(int parameter_count) const;
-
- // Returns an invalid register.
- static Register invalid_value() { return Register(); }
-
- // Returns the register for the function's closure object.
- static Register function_closure();
- bool is_function_closure() const;
-
- // Returns the register which holds the current context object.
- static Register current_context();
- bool is_current_context() const;
-
- // Returns the register for the incoming new target value.
- static Register new_target();
- bool is_new_target() const;
-
- // Returns the register for the bytecode array.
- static Register bytecode_array();
- bool is_bytecode_array() const;
-
- // Returns the register for the saved bytecode offset.
- static Register bytecode_offset();
- bool is_bytecode_offset() const;
-
- // Returns a register that can be used to represent the accumulator
- // within code in the interpreter, but should never be emitted in
- // bytecode.
- static Register virtual_accumulator();
-
- OperandSize SizeOfOperand() const;
-
- int32_t ToOperand() const { return kRegisterFileStartOffset - index_; }
- static Register FromOperand(int32_t operand) {
- return Register(kRegisterFileStartOffset - operand);
- }
-
- static bool AreContiguous(Register reg1, Register reg2,
- Register reg3 = Register(),
- Register reg4 = Register(),
- Register reg5 = Register());
-
- std::string ToString(int parameter_count);
-
- bool operator==(const Register& other) const {
- return index() == other.index();
- }
- bool operator!=(const Register& other) const {
- return index() != other.index();
- }
- bool operator<(const Register& other) const {
- return index() < other.index();
- }
- bool operator<=(const Register& other) const {
- return index() <= other.index();
- }
- bool operator>(const Register& other) const {
- return index() > other.index();
- }
- bool operator>=(const Register& other) const {
- return index() >= other.index();
- }
-
- private:
- static const int kInvalidIndex = kMaxInt;
- static const int kRegisterFileStartOffset =
- InterpreterFrameConstants::kRegisterFileFromFp / kPointerSize;
-
- void* operator new(size_t size);
- void operator delete(void* p);
-
- int index_;
-};
-
-
-class Bytecodes {
+class Bytecodes final {
public:
// The maximum number of operands a bytecode may have.
static const int kMaxOperands = 4;
@@ -472,10 +385,7 @@ class Bytecodes {
static const char* OperandSizeToString(OperandSize operand_size);
// Returns byte value of bytecode.
- static uint8_t ToByte(Bytecode bytecode) {
- DCHECK_LE(bytecode, Bytecode::kLast);
- return static_cast<uint8_t>(bytecode);
- }
+ static uint8_t ToByte(Bytecode bytecode);
// Returns bytecode for |value|.
static Bytecode FromByte(uint8_t value);
@@ -636,25 +546,6 @@ class Bytecodes {
// Returns true if |operand_type| is unsigned, false if signed.
static bool IsUnsignedOperandType(OperandType operand_type);
- // Decodes a register operand in a byte array.
- static Register DecodeRegisterOperand(const uint8_t* operand_start,
- OperandType operand_type,
- OperandScale operand_scale);
-
- // Decodes a signed operand in a byte array.
- static int32_t DecodeSignedOperand(const uint8_t* operand_start,
- OperandType operand_type,
- OperandScale operand_scale);
-
- // Decodes an unsigned operand in a byte array.
- static uint32_t DecodeUnsignedOperand(const uint8_t* operand_start,
- OperandType operand_type,
- OperandScale operand_scale);
-
- // Decode a single bytecode and operands to |os|.
- static std::ostream& Decode(std::ostream& os, const uint8_t* bytecode_start,
- int number_of_parameters);
-
// Returns true if a handler is generated for a bytecode at a given
// operand scale. All bytecodes have handlers at OperandScale::kSingle,
// but only bytecodes with scalable operands have handlers with larger
@@ -666,33 +557,6 @@ class Bytecodes {
// Return the operand size required to hold an unsigned operand.
static OperandSize SizeForUnsignedOperand(uint32_t value);
-
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(Bytecodes);
-};
-
-class CreateObjectLiteralFlags {
- public:
- class FlagsBits : public BitField8<int, 0, 3> {};
- class FastClonePropertiesCountBits
- : public BitField8<int, FlagsBits::kNext, 3> {};
-
- static uint8_t Encode(bool fast_clone_supported, int properties_count,
- int runtime_flags);
-
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(CreateObjectLiteralFlags);
-};
-
-class CreateClosureFlags {
- public:
- class PretenuredBit : public BitField8<bool, 0, 1> {};
- class FastNewClosureBit : public BitField8<bool, PretenuredBit::kNext, 1> {};
-
- static uint8_t Encode(bool pretenure, bool is_function_scope);
-
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(CreateClosureFlags);
};
std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode);
« no previous file with comments | « src/interpreter/bytecode-register.cc ('k') | src/interpreter/bytecodes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698