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.h120
1 files changed, 77 insertions, 43 deletions
diff --git a/deps/v8/src/compiler/linkage.h b/deps/v8/src/compiler/linkage.h
index a0434f8aff..1c025081c4 100644
--- a/deps/v8/src/compiler/linkage.h
+++ b/deps/v8/src/compiler/linkage.h
@@ -37,56 +37,63 @@ class LinkageLocation {
return !(*this == other);
}
- static LinkageLocation ForAnyRegister() {
- return LinkageLocation(REGISTER, ANY_REGISTER);
+ static LinkageLocation ForAnyRegister(
+ MachineType type = MachineType::None()) {
+ return LinkageLocation(REGISTER, ANY_REGISTER, type);
}
- static LinkageLocation ForRegister(int32_t reg) {
+ static LinkageLocation ForRegister(int32_t reg,
+ MachineType type = MachineType::None()) {
DCHECK(reg >= 0);
- return LinkageLocation(REGISTER, reg);
+ return LinkageLocation(REGISTER, reg, type);
}
- static LinkageLocation ForCallerFrameSlot(int32_t slot) {
+ static LinkageLocation ForCallerFrameSlot(int32_t slot, MachineType type) {
DCHECK(slot < 0);
- return LinkageLocation(STACK_SLOT, slot);
+ return LinkageLocation(STACK_SLOT, slot, type);
}
- static LinkageLocation ForCalleeFrameSlot(int32_t slot) {
+ static LinkageLocation ForCalleeFrameSlot(int32_t slot, MachineType type) {
// TODO(titzer): bailout instead of crashing here.
DCHECK(slot >= 0 && slot < LinkageLocation::MAX_STACK_SLOT);
- return LinkageLocation(STACK_SLOT, slot);
+ return LinkageLocation(STACK_SLOT, slot, type);
}
static LinkageLocation ForSavedCallerReturnAddress() {
return ForCalleeFrameSlot((StandardFrameConstants::kCallerPCOffset -
StandardFrameConstants::kCallerPCOffset) /
- kPointerSize);
+ kPointerSize,
+ MachineType::Pointer());
}
static LinkageLocation ForSavedCallerFramePtr() {
return ForCalleeFrameSlot((StandardFrameConstants::kCallerPCOffset -
StandardFrameConstants::kCallerFPOffset) /
- kPointerSize);
+ kPointerSize,
+ MachineType::Pointer());
}
static LinkageLocation ForSavedCallerConstantPool() {
DCHECK(V8_EMBEDDED_CONSTANT_POOL);
return ForCalleeFrameSlot((StandardFrameConstants::kCallerPCOffset -
StandardFrameConstants::kConstantPoolOffset) /
- kPointerSize);
+ kPointerSize,
+ MachineType::AnyTagged());
}
static LinkageLocation ForSavedCallerFunction() {
return ForCalleeFrameSlot((StandardFrameConstants::kCallerPCOffset -
StandardFrameConstants::kFunctionOffset) /
- kPointerSize);
+ kPointerSize,
+ MachineType::AnyTagged());
}
static LinkageLocation ConvertToTailCallerLocation(
LinkageLocation caller_location, int stack_param_delta) {
if (!caller_location.IsRegister()) {
return LinkageLocation(STACK_SLOT,
- caller_location.GetLocation() - stack_param_delta);
+ caller_location.GetLocation() + stack_param_delta,
+ caller_location.GetType());
}
return caller_location;
}
@@ -103,9 +110,22 @@ class LinkageLocation {
static const int32_t ANY_REGISTER = -1;
static const int32_t MAX_STACK_SLOT = 32767;
- LinkageLocation(LocationType type, int32_t location) {
+ LinkageLocation(LocationType type, int32_t location,
+ MachineType machine_type) {
bit_field_ = TypeField::encode(type) |
((location << LocationField::kShift) & LocationField::kMask);
+ machine_type_ = machine_type;
+ }
+
+ MachineType GetType() const { return machine_type_; }
+
+ int GetSize() const {
+ return 1 << ElementSizeLog2Of(GetType().representation());
+ }
+
+ int GetSizeInPointers() const {
+ // Round up
+ return (GetSize() + kPointerSize - 1) / kPointerSize;
}
int32_t GetLocation() const {
@@ -134,6 +154,7 @@ class LinkageLocation {
}
int32_t bit_field_;
+ MachineType machine_type_;
};
typedef Signature<LinkageLocation> LocationSignature;
@@ -152,25 +173,22 @@ class CallDescriptor final : public ZoneObject {
enum Flag {
kNoFlags = 0u,
kNeedsFrameState = 1u << 0,
- kPatchableCallSite = 1u << 1,
- kNeedsNopAfterCall = 1u << 2,
- kHasExceptionHandler = 1u << 3,
- kHasLocalCatchHandler = 1u << 4,
- kSupportsTailCalls = 1u << 5,
- kCanUseRoots = 1u << 6,
+ kHasExceptionHandler = 1u << 1,
+ kSupportsTailCalls = 1u << 2,
+ kCanUseRoots = 1u << 3,
// (arm64 only) native stack should be used for arguments.
- kUseNativeStack = 1u << 7,
+ kUseNativeStack = 1u << 4,
// (arm64 only) call instruction has to restore JSSP or CSP.
- kRestoreJSSP = 1u << 8,
- kRestoreCSP = 1u << 9,
+ kRestoreJSSP = 1u << 5,
+ kRestoreCSP = 1u << 6,
// Causes the code generator to initialize the root register.
- kInitializeRootRegister = 1u << 10,
- kPatchableCallSiteWithNop = kPatchableCallSite | kNeedsNopAfterCall
+ kInitializeRootRegister = 1u << 7,
+ // Does not ever try to allocate space on our heap.
+ kNoAllocate = 1u << 8
};
typedef base::Flags<Flag> Flags;
CallDescriptor(Kind kind, MachineType target_type, LinkageLocation target_loc,
- const MachineSignature* machine_sig,
LocationSignature* location_sig, size_t stack_param_count,
Operator::Properties properties,
RegList callee_saved_registers,
@@ -179,7 +197,6 @@ class CallDescriptor final : public ZoneObject {
: kind_(kind),
target_type_(target_type),
target_loc_(target_loc),
- machine_sig_(machine_sig),
location_sig_(location_sig),
stack_param_count_(stack_param_count),
properties_(properties),
@@ -187,8 +204,6 @@ class CallDescriptor final : public ZoneObject {
callee_saved_fp_registers_(callee_saved_fp_registers),
flags_(flags),
debug_name_(debug_name) {
- DCHECK(machine_sig->return_count() == location_sig->return_count());
- DCHECK(machine_sig->parameter_count() == location_sig->parameter_count());
}
// Returns the kind of this call.
@@ -205,10 +220,10 @@ class CallDescriptor final : public ZoneObject {
}
// The number of return values from this call.
- size_t ReturnCount() const { return machine_sig_->return_count(); }
+ size_t ReturnCount() const { return location_sig_->return_count(); }
// The number of C parameters to this call.
- size_t CParameterCount() const { return machine_sig_->parameter_count(); }
+ size_t ParameterCount() const { return location_sig_->parameter_count(); }
// The number of stack parameters to the call.
size_t StackParameterCount() const { return stack_param_count_; }
@@ -222,7 +237,7 @@ class CallDescriptor final : public ZoneObject {
// The total number of inputs to this call, which includes the target,
// receiver, context, etc.
// TODO(titzer): this should input the framestate input too.
- size_t InputCount() const { return 1 + machine_sig_->parameter_count(); }
+ size_t InputCount() const { return 1 + location_sig_->parameter_count(); }
size_t FrameStateCount() const { return NeedsFrameState() ? 1 : 0; }
@@ -244,15 +259,19 @@ class CallDescriptor final : public ZoneObject {
return location_sig_->GetParam(index - 1);
}
- const MachineSignature* GetMachineSignature() const { return machine_sig_; }
+ MachineSignature* GetMachineSignature(Zone* zone) const;
MachineType GetReturnType(size_t index) const {
- return machine_sig_->GetReturn(index);
+ return location_sig_->GetReturn(index).GetType();
}
MachineType GetInputType(size_t index) const {
if (index == 0) return target_type_;
- return machine_sig_->GetParam(index - 1);
+ return location_sig_->GetParam(index - 1).GetType();
+ }
+
+ MachineType GetParameterType(size_t index) const {
+ return location_sig_->GetParam(index).GetType();
}
// Operator properties describe how this call can be optimized, if at all.
@@ -270,7 +289,9 @@ class CallDescriptor final : public ZoneObject {
bool HasSameReturnLocationsAs(const CallDescriptor* other) const;
- bool CanTailCall(const Node* call, int* stack_param_delta) const;
+ int GetStackParameterDelta(const CallDescriptor* tail_caller = nullptr) const;
+
+ bool CanTailCall(const Node* call) const;
private:
friend class Linkage;
@@ -278,7 +299,6 @@ class CallDescriptor final : public ZoneObject {
const Kind kind_;
const MachineType target_type_;
const LinkageLocation target_loc_;
- const MachineSignature* const machine_sig_;
const LocationSignature* const location_sig_;
const size_t stack_param_count_;
const Operator::Properties properties_;
@@ -304,10 +324,11 @@ std::ostream& operator<<(std::ostream& os, const CallDescriptor::Kind& k);
// representing the architecture-specific location. The following call node
// layouts are supported (where {n} is the number of value inputs):
//
-// #0 #1 #2 #3 [...] #n
-// Call[CodeStub] code, arg 1, arg 2, arg 3, [...], context
-// Call[JSFunction] function, rcvr, arg 1, arg 2, [...], new, #arg, context
-// Call[Runtime] CEntryStub, arg 1, arg 2, arg 3, [...], fun, #arg, context
+// #0 #1 #2 [...] #n
+// Call[CodeStub] code, arg 1, arg 2, [...], context
+// Call[JSFunction] function, rcvr, arg 1, [...], new, #arg, context
+// Call[Runtime] CEntryStub, arg 1, arg 2, [...], fun, #arg, context
+// Call[BytecodeDispatch] address, arg 1, arg 2, [...]
class Linkage : public ZoneObject {
public:
explicit Linkage(CallDescriptor* incoming) : incoming_(incoming) {}
@@ -322,9 +343,14 @@ class Linkage : public ZoneObject {
CallDescriptor::Flags flags);
static CallDescriptor* GetRuntimeCallDescriptor(
- Zone* zone, Runtime::FunctionId function, int parameter_count,
+ Zone* zone, Runtime::FunctionId function, int js_parameter_count,
Operator::Properties properties, CallDescriptor::Flags flags);
+ static CallDescriptor* GetCEntryStubCallDescriptor(
+ Zone* zone, int return_count, int js_parameter_count,
+ const char* debug_name, Operator::Properties properties,
+ CallDescriptor::Flags flags);
+
static CallDescriptor* GetStubCallDescriptor(
Isolate* isolate, Zone* zone, const CallInterfaceDescriptor& descriptor,
int stack_parameter_count, CallDescriptor::Flags flags,
@@ -332,6 +358,11 @@ class Linkage : public ZoneObject {
MachineType return_type = MachineType::AnyTagged(),
size_t return_count = 1);
+ static CallDescriptor* GetAllocateCallDescriptor(Zone* zone);
+ static CallDescriptor* GetBytecodeDispatchCallDescriptor(
+ Isolate* isolate, Zone* zone, const CallInterfaceDescriptor& descriptor,
+ int stack_parameter_count);
+
// Creates a call descriptor for simplified C calls that is appropriate
// for the host platform. This simplified calling convention only supports
// integers and pointers of one word size each, i.e. no floating point,
@@ -363,7 +394,7 @@ class Linkage : public ZoneObject {
bool ParameterHasSecondaryLocation(int index) const;
LinkageLocation GetParameterSecondaryLocation(int index) const;
- static int FrameStateInputCount(Runtime::FunctionId function);
+ static bool NeedsFrameStateInput(Runtime::FunctionId function);
// Get the location where an incoming OSR value is stored.
LinkageLocation GetOsrValueLocation(int index) const;
@@ -394,6 +425,9 @@ class Linkage : public ZoneObject {
// A special {OsrValue} index to indicate the context spill slot.
static const int kOsrContextSpillSlotIndex = -1;
+ // A special {OsrValue} index to indicate the accumulator register.
+ static const int kOsrAccumulatorRegisterIndex = -1;
+
private:
CallDescriptor* const incoming_;