summaryrefslogtreecommitdiff
path: root/deps/v8/src/compiler/linkage.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/compiler/linkage.h')
-rw-r--r--deps/v8/src/compiler/linkage.h119
1 files changed, 92 insertions, 27 deletions
diff --git a/deps/v8/src/compiler/linkage.h b/deps/v8/src/compiler/linkage.h
index 31b9faca2a..f5507a0594 100644
--- a/deps/v8/src/compiler/linkage.h
+++ b/deps/v8/src/compiler/linkage.h
@@ -17,42 +17,89 @@ namespace v8 {
namespace internal {
class CallInterfaceDescriptor;
+class CompilationInfo;
namespace compiler {
+const RegList kNoCalleeSaved = 0;
+
class Node;
class OsrHelper;
// Describes the location for a parameter or a return value to a call.
class LinkageLocation {
public:
- explicit LinkageLocation(int location) : location_(location) {}
+ bool operator==(const LinkageLocation& other) const {
+ return bit_field_ == other.bit_field_;
+ }
- bool is_register() const {
- return 0 <= location_ && location_ <= ANY_REGISTER;
+ bool operator!=(const LinkageLocation& other) const {
+ return !(*this == other);
}
- static const int16_t ANY_REGISTER = 1023;
- static const int16_t MAX_STACK_SLOT = 32767;
+ static LinkageLocation ForAnyRegister() {
+ return LinkageLocation(REGISTER, ANY_REGISTER);
+ }
- static LinkageLocation AnyRegister() { return LinkageLocation(ANY_REGISTER); }
+ static LinkageLocation ForRegister(int32_t reg) {
+ DCHECK(reg >= 0);
+ return LinkageLocation(REGISTER, reg);
+ }
- bool operator==(const LinkageLocation& other) const {
- return location_ == other.location_;
+ static LinkageLocation ForCallerFrameSlot(int32_t slot) {
+ DCHECK(slot < 0);
+ return LinkageLocation(STACK_SLOT, slot);
}
- bool operator!=(const LinkageLocation& other) const {
- return !(*this == other);
+ static LinkageLocation ForCalleeFrameSlot(int32_t slot) {
+ // TODO(titzer): bailout instead of crashing here.
+ DCHECK(slot >= 0 && slot < LinkageLocation::MAX_STACK_SLOT);
+ return LinkageLocation(STACK_SLOT, slot);
}
private:
friend class CallDescriptor;
friend class OperandGenerator;
- // location < 0 -> a stack slot on the caller frame
- // 0 <= location < 1023 -> a specific machine register
- // 1023 <= location < 1024 -> any machine register
- // 1024 <= location -> a stack slot in the callee frame
- int16_t location_;
+
+ enum LocationType { REGISTER, STACK_SLOT };
+
+ class TypeField : public BitField<LocationType, 0, 1> {};
+ class LocationField : public BitField<int32_t, TypeField::kNext, 31> {};
+
+ static const int32_t ANY_REGISTER = -1;
+ static const int32_t MAX_STACK_SLOT = 32767;
+
+ LinkageLocation(LocationType type, int32_t location) {
+ bit_field_ = TypeField::encode(type) |
+ ((location << LocationField::kShift) & LocationField::kMask);
+ }
+
+ int32_t GetLocation() const {
+ return static_cast<int32_t>(bit_field_ & LocationField::kMask) >>
+ LocationField::kShift;
+ }
+
+ bool IsRegister() const { return TypeField::decode(bit_field_) == REGISTER; }
+ bool IsAnyRegister() const {
+ return IsRegister() && GetLocation() == ANY_REGISTER;
+ }
+ bool IsCallerFrameSlot() const { return !IsRegister() && GetLocation() < 0; }
+ bool IsCalleeFrameSlot() const { return !IsRegister() && GetLocation() >= 0; }
+
+ int32_t AsRegister() const {
+ DCHECK(IsRegister());
+ return GetLocation();
+ }
+ int32_t AsCallerFrameSlot() const {
+ DCHECK(IsCallerFrameSlot());
+ return GetLocation();
+ }
+ int32_t AsCalleeFrameSlot() const {
+ DCHECK(IsCalleeFrameSlot());
+ return GetLocation();
+ }
+
+ int32_t bit_field_;
};
typedef Signature<LinkageLocation> LocationSignature;
@@ -63,9 +110,9 @@ class CallDescriptor final : public ZoneObject {
public:
// Describes the kind of this call, which determines the target.
enum Kind {
- kCallCodeObject, // target is a Code object
- kCallJSFunction, // target is a JSFunction object
- kCallAddress // target is a machine pointer
+ kCallCodeObject, // target is a Code object
+ kCallJSFunction, // target is a JSFunction object
+ kCallAddress, // target is a machine pointer
};
enum Flag {
@@ -76,13 +123,14 @@ class CallDescriptor final : public ZoneObject {
kHasExceptionHandler = 1u << 3,
kHasLocalCatchHandler = 1u << 4,
kSupportsTailCalls = 1u << 5,
+ kCanUseRoots = 1u << 6,
kPatchableCallSiteWithNop = kPatchableCallSite | kNeedsNopAfterCall
};
typedef base::Flags<Flag> Flags;
CallDescriptor(Kind kind, MachineType target_type, LinkageLocation target_loc,
const MachineSignature* machine_sig,
- LocationSignature* location_sig, size_t js_param_count,
+ LocationSignature* location_sig, size_t stack_param_count,
Operator::Properties properties,
RegList callee_saved_registers,
RegList callee_saved_fp_registers, Flags flags,
@@ -92,7 +140,7 @@ class CallDescriptor final : public ZoneObject {
target_loc_(target_loc),
machine_sig_(machine_sig),
location_sig_(location_sig),
- js_param_count_(js_param_count),
+ stack_param_count_(stack_param_count),
properties_(properties),
callee_saved_registers_(callee_saved_registers),
callee_saved_fp_registers_(callee_saved_fp_registers),
@@ -117,9 +165,14 @@ class CallDescriptor final : public ZoneObject {
// The number of C parameters to this call.
size_t CParameterCount() const { return machine_sig_->parameter_count(); }
- // The number of JavaScript parameters to this call, including the receiver
- // object.
- size_t JSParameterCount() const { return js_param_count_; }
+ // The number of stack parameters to the call.
+ size_t StackParameterCount() const { return stack_param_count_; }
+
+ // The number of parameters to the JS function call.
+ size_t JSParameterCount() const {
+ DCHECK(IsJSFunctionCall());
+ return stack_param_count_;
+ }
// The total number of inputs to this call, which includes the target,
// receiver, context, etc.
@@ -178,7 +231,7 @@ class CallDescriptor final : public ZoneObject {
const LinkageLocation target_loc_;
const MachineSignature* const machine_sig_;
const LocationSignature* const location_sig_;
- const size_t js_param_count_;
+ const size_t stack_param_count_;
const Operator::Properties properties_;
const RegList callee_saved_registers_;
const RegList callee_saved_fp_registers_;
@@ -235,6 +288,11 @@ class Linkage : public ZoneObject {
static CallDescriptor* GetSimplifiedCDescriptor(Zone* zone,
const MachineSignature* sig);
+ // Creates a call descriptor for interpreter handler code stubs. These are not
+ // intended to be called directly but are instead dispatched to by the
+ // interpreter.
+ static CallDescriptor* GetInterpreterDispatchDescriptor(Zone* zone);
+
// Get the location of an (incoming) parameter to this function.
LinkageLocation GetParameterLocation(int index) const {
return incoming_->GetInputLocation(index + 1); // + 1 to skip target.
@@ -256,9 +314,8 @@ class Linkage : public ZoneObject {
// Get the frame offset for a given spill slot. The location depends on the
// calling convention and the specific frame layout, and may thus be
// architecture-specific. Negative spill slots indicate arguments on the
- // caller's frame. The {extra} parameter indicates an additional offset from
- // the frame offset, e.g. to index into part of a double slot.
- FrameOffset GetFrameOffset(int spill_slot, Frame* frame, int extra = 0) const;
+ // caller's frame.
+ FrameOffset GetFrameOffset(int spill_slot, Frame* frame) const;
static int FrameStateInputCount(Runtime::FunctionId function);
@@ -271,6 +328,14 @@ class Linkage : public ZoneObject {
// A special {OsrValue} index to indicate the context spill slot.
static const int kOsrContextSpillSlotIndex = -1;
+ // Special parameter indices used to pass fixed register data through
+ // interpreter dispatches.
+ static const int kInterpreterAccumulatorParameter = 0;
+ static const int kInterpreterRegisterFileParameter = 1;
+ static const int kInterpreterBytecodeOffsetParameter = 2;
+ static const int kInterpreterBytecodeArrayParameter = 3;
+ static const int kInterpreterDispatchTableParameter = 4;
+
private:
CallDescriptor* const incoming_;