Commit 13aa1d02 authored by ishell's avatar ishell Committed by Commit bot

[stubs] Call interface descriptors cleanup.

This is a first step towards a perfect world where a call interface descriptor is the only place that defines calling convention for a particular code stub.

Review-Url: https://codereview.chromium.org/2172223002
Cr-Commit-Position: refs/heads/master@{#38059}
parent ae752848
......@@ -28,9 +28,10 @@ void Generate_NonPrimitiveToPrimitive(CodeStubAssembler* assembler,
ToPrimitiveHint hint) {
typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node;
typedef TypeConversionDescriptor Descriptor;
Node* input = assembler->Parameter(0);
Node* context = assembler->Parameter(1);
Node* input = assembler->Parameter(Descriptor::kArgument);
Node* context = assembler->Parameter(Descriptor::kContext);
// Lookup the @@toPrimitive property on the {input}.
Callable callable = CodeFactory::GetProperty(assembler->isolate());
......@@ -113,9 +114,10 @@ void Builtins::Generate_NonNumberToNumber(CodeStubAssembler* assembler) {
typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node;
typedef CodeStubAssembler::Variable Variable;
typedef TypeConversionDescriptor Descriptor;
Node* input = assembler->Parameter(0);
Node* context = assembler->Parameter(1);
Node* input = assembler->Parameter(Descriptor::kArgument);
Node* context = assembler->Parameter(Descriptor::kContext);
// We might need to loop once here due to ToPrimitive conversions.
Variable var_input(assembler, MachineRepresentation::kTagged);
......@@ -224,9 +226,10 @@ void Generate_OrdinaryToPrimitive(CodeStubAssembler* assembler,
typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node;
typedef CodeStubAssembler::Variable Variable;
typedef TypeConversionDescriptor Descriptor;
Node* input = assembler->Parameter(0);
Node* context = assembler->Parameter(1);
Node* input = assembler->Parameter(Descriptor::kArgument);
Node* context = assembler->Parameter(Descriptor::kContext);
Variable var_result(assembler, MachineRepresentation::kTagged);
Label return_result(assembler, &var_result);
......@@ -304,8 +307,9 @@ void Builtins::Generate_OrdinaryToPrimitive_String(
void Builtins::Generate_ToBoolean(CodeStubAssembler* assembler) {
typedef compiler::Node Node;
typedef CodeStubAssembler::Label Label;
typedef TypeConversionDescriptor Descriptor;
Node* value = assembler->Parameter(0);
Node* value = assembler->Parameter(Descriptor::kArgument);
Label return_true(assembler), return_false(assembler);
assembler->BranchIfToBooleanIsTrue(value, &return_true, &return_false);
......
......@@ -39,10 +39,11 @@ void Builtins::Generate_KeyedStoreIC_Slow(MacroAssembler* masm) {
void Builtins::Generate_LoadGlobalIC_Miss(CodeStubAssembler* assembler) {
typedef compiler::Node Node;
typedef LoadGlobalWithVectorDescriptor Descriptor;
Node* slot = assembler->Parameter(0);
Node* vector = assembler->Parameter(1);
Node* context = assembler->Parameter(2);
Node* slot = assembler->Parameter(Descriptor::kSlot);
Node* vector = assembler->Parameter(Descriptor::kVector);
Node* context = assembler->Parameter(Descriptor::kContext);
assembler->TailCallRuntime(Runtime::kLoadGlobalIC_Miss, context, slot,
vector);
......@@ -51,10 +52,11 @@ void Builtins::Generate_LoadGlobalIC_Miss(CodeStubAssembler* assembler) {
namespace {
void Generate_LoadGlobalIC_Slow(CodeStubAssembler* assembler, TypeofMode mode) {
typedef compiler::Node Node;
typedef LoadGlobalWithVectorDescriptor Descriptor;
Node* slot = assembler->Parameter(0);
Node* vector = assembler->Parameter(1);
Node* context = assembler->Parameter(2);
Node* slot = assembler->Parameter(Descriptor::kSlot);
Node* vector = assembler->Parameter(Descriptor::kVector);
Node* context = assembler->Parameter(Descriptor::kContext);
Node* typeof_mode = assembler->SmiConstant(Smi::FromInt(mode));
assembler->TailCallRuntime(Runtime::kGetGlobal, context, slot, vector,
......@@ -78,12 +80,13 @@ void Builtins::Generate_LoadIC_Getter_ForDeopt(MacroAssembler* masm) {
void Builtins::Generate_LoadIC_Miss(CodeStubAssembler* assembler) {
typedef compiler::Node Node;
typedef LoadWithVectorDescriptor Descriptor;
Node* receiver = assembler->Parameter(0);
Node* name = assembler->Parameter(1);
Node* slot = assembler->Parameter(2);
Node* vector = assembler->Parameter(3);
Node* context = assembler->Parameter(4);
Node* receiver = assembler->Parameter(Descriptor::kReceiver);
Node* name = assembler->Parameter(Descriptor::kName);
Node* slot = assembler->Parameter(Descriptor::kSlot);
Node* vector = assembler->Parameter(Descriptor::kVector);
Node* context = assembler->Parameter(Descriptor::kContext);
assembler->TailCallRuntime(Runtime::kLoadIC_Miss, context, receiver, name,
slot, vector);
......@@ -95,25 +98,25 @@ void Builtins::Generate_LoadIC_Normal(MacroAssembler* masm) {
void Builtins::Generate_LoadIC_Slow(CodeStubAssembler* assembler) {
typedef compiler::Node Node;
typedef LoadWithVectorDescriptor Descriptor;
Node* receiver = assembler->Parameter(0);
Node* name = assembler->Parameter(1);
// Node* slot = assembler->Parameter(2);
// Node* vector = assembler->Parameter(3);
Node* context = assembler->Parameter(4);
Node* receiver = assembler->Parameter(Descriptor::kReceiver);
Node* name = assembler->Parameter(Descriptor::kName);
Node* context = assembler->Parameter(Descriptor::kContext);
assembler->TailCallRuntime(Runtime::kGetProperty, context, receiver, name);
}
void Builtins::Generate_StoreIC_Miss(CodeStubAssembler* assembler) {
typedef compiler::Node Node;
typedef StoreWithVectorDescriptor Descriptor;
Node* receiver = assembler->Parameter(0);
Node* name = assembler->Parameter(1);
Node* value = assembler->Parameter(2);
Node* slot = assembler->Parameter(3);
Node* vector = assembler->Parameter(4);
Node* context = assembler->Parameter(5);
Node* receiver = assembler->Parameter(Descriptor::kReceiver);
Node* name = assembler->Parameter(Descriptor::kName);
Node* value = assembler->Parameter(Descriptor::kValue);
Node* slot = assembler->Parameter(Descriptor::kSlot);
Node* vector = assembler->Parameter(Descriptor::kVector);
Node* context = assembler->Parameter(Descriptor::kContext);
assembler->TailCallRuntime(Runtime::kStoreIC_Miss, context, receiver, name,
value, slot, vector);
......@@ -131,13 +134,12 @@ namespace {
void Generate_StoreIC_Slow(CodeStubAssembler* assembler,
LanguageMode language_mode) {
typedef compiler::Node Node;
typedef StoreWithVectorDescriptor Descriptor;
Node* receiver = assembler->Parameter(0);
Node* name = assembler->Parameter(1);
Node* value = assembler->Parameter(2);
// Node* slot = assembler->Parameter(3);
// Node* vector = assembler->Parameter(4);
Node* context = assembler->Parameter(5);
Node* receiver = assembler->Parameter(Descriptor::kReceiver);
Node* name = assembler->Parameter(Descriptor::kName);
Node* value = assembler->Parameter(Descriptor::kValue);
Node* context = assembler->Parameter(Descriptor::kContext);
Node* lang_mode = assembler->SmiConstant(Smi::FromInt(language_mode));
// The slow case calls into the runtime to complete the store without causing
......
......@@ -3045,9 +3045,12 @@ void CodeStubAssembler::LoadIC(const LoadICParameters* p) {
// |handler| is a heap object. Must be code, call it.
Bind(&call_handler);
LoadWithVectorDescriptor descriptor(isolate());
TailCallStub(descriptor, handler, p->context, p->receiver, p->name, p->slot,
p->vector);
typedef LoadWithVectorDescriptor Descriptor;
TailCallStub(Descriptor(isolate()), var_handler.value(), p->context,
Arg(Descriptor::kReceiver, p->receiver),
Arg(Descriptor::kName, p->name),
Arg(Descriptor::kSlot, p->slot),
Arg(Descriptor::kVector, p->vector));
}
Bind(&try_polymorphic);
......
This diff is collapsed.
This diff is collapsed.
......@@ -431,8 +431,9 @@ class CodeStub BASE_EMBEDDED {
#define DEFINE_CALL_INTERFACE_DESCRIPTOR(NAME) \
public: \
typedef NAME##Descriptor Descriptor; \
CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { \
return NAME##Descriptor(isolate()); \
return Descriptor(isolate()); \
}
#define DEFINE_ON_STACK_CALL_INTERFACE_DESCRIPTOR(PARAMETER_COUNT) \
......@@ -1023,9 +1024,6 @@ class NumberToStringStub final : public HydrogenCodeStub {
public:
explicit NumberToStringStub(Isolate* isolate) : HydrogenCodeStub(isolate) {}
// Parameters accessed via CodeStubGraphBuilder::GetParameter()
static const int kNumber = 0;
DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion);
DEFINE_HYDROGEN_CODE_STUB(NumberToString, HydrogenCodeStub);
};
......@@ -1035,9 +1033,6 @@ class TypeofStub final : public HydrogenCodeStub {
public:
explicit TypeofStub(Isolate* isolate) : HydrogenCodeStub(isolate) {}
// Parameters accessed via CodeStubGraphBuilder::GetParameter()
static const int kObject = 0;
static void GenerateAheadOfTime(Isolate* isolate);
DEFINE_CALL_INTERFACE_DESCRIPTOR(Typeof);
......@@ -1448,6 +1443,8 @@ class LoadFieldStub: public HandlerStub {
private:
class LoadFieldByIndexBits : public BitField<int, 0, 13> {};
// TODO(ishell): The stub uses only kReceiver parameter.
DEFINE_CALL_INTERFACE_DESCRIPTOR(LoadWithVector);
DEFINE_HANDLER_CODE_STUB(LoadField, HandlerStub);
};
......@@ -1460,7 +1457,7 @@ class KeyedLoadSloppyArgumentsStub : public HandlerStub {
protected:
Code::Kind kind() const override { return Code::KEYED_LOAD_IC; }
private:
DEFINE_CALL_INTERFACE_DESCRIPTOR(LoadWithVector);
DEFINE_HANDLER_CODE_STUB(KeyedLoadSloppyArguments, HandlerStub);
};
......@@ -1478,7 +1475,7 @@ class KeyedStoreSloppyArgumentsStub : public HandlerStub {
protected:
Code::Kind kind() const override { return Code::KEYED_STORE_IC; }
private:
DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreWithVector);
DEFINE_HANDLER_CODE_STUB(KeyedStoreSloppyArguments, HandlerStub);
};
......@@ -1500,6 +1497,8 @@ class LoadConstantStub : public HandlerStub {
private:
class ConstantIndexBits : public BitField<int, 0, kSubMinorKeyBits> {};
// TODO(ishell): The stub uses only kReceiver parameter.
DEFINE_CALL_INTERFACE_DESCRIPTOR(LoadWithVector);
DEFINE_HANDLER_CODE_STUB(LoadConstant, HandlerStub);
};
......@@ -1558,6 +1557,8 @@ class StoreFieldStub : public HandlerStub {
class StoreFieldByIndexBits : public BitField<int, 0, 13> {};
class RepresentationBits : public BitField<uint8_t, 13, 4> {};
// TODO(ishell): The stub uses only kReceiver and kValue parameters.
DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreWithVector);
DEFINE_HANDLER_CODE_STUB(StoreField, HandlerStub);
};
......@@ -1591,25 +1592,23 @@ class StoreTransitionHelper {
return VectorStoreTransitionDescriptor::MapRegister();
}
static int ReceiverIndex() {
return StoreTransitionDescriptor::kReceiverIndex;
}
static int ReceiverIndex() { return StoreTransitionDescriptor::kReceiver; }
static int NameIndex() { return StoreTransitionDescriptor::kReceiverIndex; }
static int NameIndex() { return StoreTransitionDescriptor::kReceiver; }
static int ValueIndex() { return StoreTransitionDescriptor::kValueIndex; }
static int ValueIndex() { return StoreTransitionDescriptor::kValue; }
static int MapIndex() {
DCHECK(static_cast<int>(VectorStoreTransitionDescriptor::kMapIndex) ==
static_cast<int>(StoreTransitionDescriptor::kMapIndex));
return StoreTransitionDescriptor::kMapIndex;
DCHECK(static_cast<int>(VectorStoreTransitionDescriptor::kMap) ==
static_cast<int>(StoreTransitionDescriptor::kMap));
return StoreTransitionDescriptor::kMap;
}
static int VectorIndex() {
if (HasVirtualSlotArg()) {
return VectorStoreTransitionDescriptor::kVirtualSlotVectorIndex;
return VectorStoreTransitionDescriptor::kVirtualSlotVector;
}
return VectorStoreTransitionDescriptor::kVectorIndex;
return VectorStoreTransitionDescriptor::kVector;
}
// Some platforms don't have a slot arg.
......@@ -1658,16 +1657,16 @@ class StoreTransitionStub : public HandlerStub {
return StoreModeBits::decode(sub_minor_key());
}
CallInterfaceDescriptor GetCallInterfaceDescriptor() const override;
protected:
Code::Kind kind() const override { return Code::STORE_IC; }
void InitializeDescriptor(CodeStubDescriptor* descriptor) override;
private:
class StoreFieldByIndexBits : public BitField<int, 0, 13> {};
class RepresentationBits : public BitField<uint8_t, 13, 4> {};
class StoreModeBits : public BitField<StoreMode, 17, 2> {};
DEFINE_CALL_INTERFACE_DESCRIPTOR(VectorStoreTransition);
DEFINE_HANDLER_CODE_STUB(StoreTransition, HandlerStub);
};
......@@ -1733,10 +1732,12 @@ class StoreGlobalStub : public HandlerStub {
class RepresentationBits : public BitField<Representation::Kind, 4, 8> {};
class CheckGlobalBits : public BitField<bool, 12, 1> {};
// TODO(ishell): The stub uses only kValue parameter.
DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreWithVector);
DEFINE_HANDLER_CODE_STUB(StoreGlobal, HandlerStub);
};
// TODO(ishell): remove, once StoreGlobalIC is implemented.
class StoreGlobalViaContextStub final : public PlatformCodeStub {
public:
static const int kMaximumDepth = 15;
......@@ -1847,10 +1848,6 @@ class BinaryOpICStub : public HydrogenCodeStub {
void PrintState(std::ostream& os) const final; // NOLINT
// Parameters accessed via CodeStubGraphBuilder::GetParameter()
static const int kLeft = 0;
static const int kRight = 1;
private:
static void GenerateAheadOfTime(Isolate* isolate,
const BinaryOpICState& state);
......@@ -1909,11 +1906,6 @@ class BinaryOpWithAllocationSiteStub final : public BinaryOpICStub {
Code::Kind GetCodeKind() const final { return Code::STUB; }
// Parameters accessed via CodeStubGraphBuilder::GetParameter()
static const int kAllocationSite = 0;
static const int kLeft = 1;
static const int kRight = 2;
DEFINE_CALL_INTERFACE_DESCRIPTOR(BinaryOpWithAllocationSite);
DEFINE_HYDROGEN_CODE_STUB(BinaryOpWithAllocationSite, BinaryOpICStub);
};
......@@ -1936,10 +1928,6 @@ class StringAddStub final : public HydrogenCodeStub {
return PretenureFlagBits::decode(sub_minor_key());
}
// Parameters accessed via CodeStubGraphBuilder::GetParameter()
static const int kLeft = 0;
static const int kRight = 1;
private:
class StringAddFlagsBits : public BitField<StringAddFlags, 0, 3> {};
class PretenureFlagBits : public BitField<PretenureFlag, 3, 1> {};
......@@ -2103,11 +2091,6 @@ class RegExpConstructResultStub final : public HydrogenCodeStub {
explicit RegExpConstructResultStub(Isolate* isolate)
: HydrogenCodeStub(isolate) { }
// Parameters accessed via CodeStubGraphBuilder::GetParameter()
static const int kLength = 0;
static const int kIndex = 1;
static const int kInput = 2;
DEFINE_CALL_INTERFACE_DESCRIPTOR(RegExpConstructResult);
DEFINE_HYDROGEN_CODE_STUB(RegExpConstructResult, HydrogenCodeStub);
};
......@@ -2309,7 +2292,7 @@ class KeyedLoadGenericStub : public HydrogenCodeStub {
Code::Kind GetCodeKind() const override { return Code::KEYED_LOAD_IC; }
DEFINE_CALL_INTERFACE_DESCRIPTOR(Load);
DEFINE_CALL_INTERFACE_DESCRIPTOR(LoadWithVector);
DEFINE_HYDROGEN_CODE_STUB(KeyedLoadGeneric, HydrogenCodeStub);
};
......@@ -2619,6 +2602,7 @@ class LoadScriptContextFieldStub : public ScriptContextFieldStub {
private:
Code::Kind kind() const override { return Code::LOAD_IC; }
DEFINE_CALL_INTERFACE_DESCRIPTOR(LoadWithVector);
DEFINE_HANDLER_CODE_STUB(LoadScriptContextField, ScriptContextFieldStub);
};
......@@ -2632,6 +2616,7 @@ class StoreScriptContextFieldStub : public ScriptContextFieldStub {
private:
Code::Kind kind() const override { return Code::STORE_IC; }
DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreWithVector);
DEFINE_HANDLER_CODE_STUB(StoreScriptContextField, ScriptContextFieldStub);
};
......@@ -2664,6 +2649,7 @@ class LoadFastElementStub : public HandlerStub {
class IsJSArrayBits: public BitField<bool, 8, 1> {};
class CanConvertHoleToUndefined : public BitField<bool, 9, 1> {};
DEFINE_CALL_INTERFACE_DESCRIPTOR(LoadWithVector);
DEFINE_HANDLER_CODE_STUB(LoadFastElement, HandlerStub);
};
......@@ -2690,10 +2676,6 @@ class StoreFastElementStub : public HydrogenCodeStub {
return CommonStoreModeBits::decode(sub_minor_key());
}
CallInterfaceDescriptor GetCallInterfaceDescriptor() const override {
return StoreWithVectorDescriptor(isolate());
}
Code::Kind GetCodeKind() const override { return Code::HANDLER; }
ExtraICState GetExtraICState() const override { return Code::KEYED_STORE_IC; }
......@@ -2701,6 +2683,7 @@ class StoreFastElementStub : public HydrogenCodeStub {
class ElementsKindBits : public BitField<ElementsKind, 3, 8> {};
class IsJSArrayBits : public BitField<bool, 11, 1> {};
DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreWithVector);
DEFINE_HYDROGEN_CODE_STUB(StoreFastElement, HydrogenCodeStub);
};
......@@ -2996,7 +2979,6 @@ class ElementsTransitionAndStoreStub : public HydrogenCodeStub {
return CommonStoreModeBits::decode(sub_minor_key());
}
CallInterfaceDescriptor GetCallInterfaceDescriptor() const override;
Code::Kind GetCodeKind() const override { return Code::HANDLER; }
ExtraICState GetExtraICState() const override { return Code::KEYED_STORE_IC; }
......@@ -3005,6 +2987,7 @@ class ElementsTransitionAndStoreStub : public HydrogenCodeStub {
class ToBits : public BitField<ElementsKind, 11, 8> {};
class IsJSArrayBits : public BitField<bool, 19, 1> {};
DEFINE_CALL_INTERFACE_DESCRIPTOR(VectorStoreTransition);
DEFINE_HYDROGEN_CODE_STUB(ElementsTransitionAndStore, HydrogenCodeStub);
};
......
......@@ -536,6 +536,91 @@ Node* CodeAssembler::CallStub(const CallInterfaceDescriptor& descriptor,
return CallN(call_descriptor, target, args);
}
Node* CodeAssembler::CallStub(const CallInterfaceDescriptor& descriptor,
Node* target, Node* context, const Arg& arg1,
const Arg& arg2, size_t result_size) {
CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
isolate(), zone(), descriptor, descriptor.GetStackParameterCount(),
CallDescriptor::kNoFlags, Operator::kNoProperties,
MachineType::AnyTagged(), result_size);
const int kArgsCount = 3;
Node** args = zone()->NewArray<Node*>(kArgsCount);
DCHECK((std::fill(&args[0], &args[kArgsCount], nullptr), true));
args[arg1.index] = arg1.value;
args[arg2.index] = arg2.value;
args[kArgsCount - 1] = context;
DCHECK_EQ(0, std::count(&args[0], &args[kArgsCount], nullptr));
return CallN(call_descriptor, target, args);
}
Node* CodeAssembler::CallStub(const CallInterfaceDescriptor& descriptor,
Node* target, Node* context, const Arg& arg1,
const Arg& arg2, const Arg& arg3,
size_t result_size) {
CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
isolate(), zone(), descriptor, descriptor.GetStackParameterCount(),
CallDescriptor::kNoFlags, Operator::kNoProperties,
MachineType::AnyTagged(), result_size);
const int kArgsCount = 4;
Node** args = zone()->NewArray<Node*>(kArgsCount);
DCHECK((std::fill(&args[0], &args[kArgsCount], nullptr), true));
args[arg1.index] = arg1.value;
args[arg2.index] = arg2.value;
args[arg3.index] = arg3.value;
args[kArgsCount - 1] = context;
DCHECK_EQ(0, std::count(&args[0], &args[kArgsCount], nullptr));
return CallN(call_descriptor, target, args);
}
Node* CodeAssembler::CallStub(const CallInterfaceDescriptor& descriptor,
Node* target, Node* context, const Arg& arg1,
const Arg& arg2, const Arg& arg3, const Arg& arg4,
size_t result_size) {
CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
isolate(), zone(), descriptor, descriptor.GetStackParameterCount(),
CallDescriptor::kNoFlags, Operator::kNoProperties,
MachineType::AnyTagged(), result_size);
const int kArgsCount = 5;
Node** args = zone()->NewArray<Node*>(kArgsCount);
DCHECK((std::fill(&args[0], &args[kArgsCount], nullptr), true));
args[arg1.index] = arg1.value;
args[arg2.index] = arg2.value;
args[arg3.index] = arg3.value;
args[arg4.index] = arg4.value;
args[kArgsCount - 1] = context;
DCHECK_EQ(0, std::count(&args[0], &args[kArgsCount], nullptr));
return CallN(call_descriptor, target, args);
}
Node* CodeAssembler::CallStub(const CallInterfaceDescriptor& descriptor,
Node* target, Node* context, const Arg& arg1,
const Arg& arg2, const Arg& arg3, const Arg& arg4,
const Arg& arg5, size_t result_size) {
CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
isolate(), zone(), descriptor, descriptor.GetStackParameterCount(),
CallDescriptor::kNoFlags, Operator::kNoProperties,
MachineType::AnyTagged(), result_size);
const int kArgsCount = 6;
Node** args = zone()->NewArray<Node*>(kArgsCount);
DCHECK((std::fill(&args[0], &args[kArgsCount], nullptr), true));
args[arg1.index] = arg1.value;
args[arg2.index] = arg2.value;
args[arg3.index] = arg3.value;
args[arg4.index] = arg4.value;
args[arg5.index] = arg5.value;
args[kArgsCount - 1] = context;
DCHECK_EQ(0, std::count(&args[0], &args[kArgsCount], nullptr));
return CallN(call_descriptor, target, args);
}
Node* CodeAssembler::CallStubN(const CallInterfaceDescriptor& descriptor,
Node* target, Node** args, size_t result_size) {
CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
......@@ -635,6 +720,52 @@ Node* CodeAssembler::TailCallStub(const CallInterfaceDescriptor& descriptor,
return raw_assembler_->TailCallN(call_descriptor, target, args);
}
Node* CodeAssembler::TailCallStub(const CallInterfaceDescriptor& descriptor,
Node* target, Node* context, const Arg& arg1,
const Arg& arg2, const Arg& arg3,
const Arg& arg4, size_t result_size) {
CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
isolate(), zone(), descriptor, descriptor.GetStackParameterCount(),
CallDescriptor::kSupportsTailCalls, Operator::kNoProperties,
MachineType::AnyTagged(), result_size);
const int kArgsCount = 5;
Node** args = zone()->NewArray<Node*>(kArgsCount);
DCHECK((std::fill(&args[0], &args[kArgsCount], nullptr), true));
args[arg1.index] = arg1.value;
args[arg2.index] = arg2.value;
args[arg3.index] = arg3.value;
args[arg4.index] = arg4.value;
args[kArgsCount - 1] = context;
DCHECK_EQ(0, std::count(&args[0], &args[kArgsCount], nullptr));
return raw_assembler_->TailCallN(call_descriptor, target, args);
}
Node* CodeAssembler::TailCallStub(const CallInterfaceDescriptor& descriptor,
Node* target, Node* context, const Arg& arg1,
const Arg& arg2, const Arg& arg3,
const Arg& arg4, const Arg& arg5,
size_t result_size) {
CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
isolate(), zone(), descriptor, descriptor.GetStackParameterCount(),
CallDescriptor::kSupportsTailCalls, Operator::kNoProperties,
MachineType::AnyTagged(), result_size);
const int kArgsCount = 6;
Node** args = zone()->NewArray<Node*>(kArgsCount);
DCHECK((std::fill(&args[0], &args[kArgsCount], nullptr), true));
args[arg1.index] = arg1.value;
args[arg2.index] = arg2.value;
args[arg3.index] = arg3.value;
args[arg4.index] = arg4.value;
args[arg5.index] = arg5.value;
args[kArgsCount - 1] = context;
DCHECK_EQ(0, std::count(&args[0], &args[kArgsCount], nullptr));
return raw_assembler_->TailCallN(call_descriptor, target, args);
}
Node* CodeAssembler::TailCallBytecodeDispatch(
const CallInterfaceDescriptor& interface_descriptor,
Node* code_target_address, Node** args) {
......
......@@ -326,6 +326,15 @@ class CodeAssembler {
Node* arg1, Node* arg2, Node* arg3, Node* arg4,
Node* arg5);
// A pair of a zero-based argument index and a value.
// It helps writing arguments order independent code.
struct Arg {
Arg(int index, Node* value) : index(index), value(value) {}
int const index;
Node* const value;
};
Node* CallStub(Callable const& callable, Node* context, Node* arg1,
size_t result_size = 1);
Node* CallStub(Callable const& callable, Node* context, Node* arg1,
......@@ -350,6 +359,21 @@ class CodeAssembler {
Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target,
Node* context, Node* arg1, Node* arg2, Node* arg3, Node* arg4,
Node* arg5, size_t result_size = 1);
Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target,
Node* context, const Arg& arg1, const Arg& arg2,
size_t result_size = 1);
Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target,
Node* context, const Arg& arg1, const Arg& arg2,
const Arg& arg3, size_t result_size = 1);
Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target,
Node* context, const Arg& arg1, const Arg& arg2,
const Arg& arg3, const Arg& arg4, size_t result_size = 1);
Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target,
Node* context, const Arg& arg1, const Arg& arg2,
const Arg& arg3, const Arg& arg4, const Arg& arg5,
size_t result_size = 1);
Node* CallStubN(const CallInterfaceDescriptor& descriptor, Node* target,
Node** args, size_t result_size = 1);
......@@ -371,6 +395,14 @@ class CodeAssembler {
Node* context, Node* arg1, Node* arg2, Node* arg3,
Node* arg4, size_t result_size = 1);
Node* TailCallStub(const CallInterfaceDescriptor& descriptor, Node* target,
Node* context, const Arg& arg1, const Arg& arg2,
const Arg& arg3, const Arg& arg4, size_t result_size = 1);
Node* TailCallStub(const CallInterfaceDescriptor& descriptor, Node* target,
Node* context, const Arg& arg1, const Arg& arg2,
const Arg& arg3, const Arg& arg4, const Arg& arg5,
size_t result_size = 1);
Node* TailCallBytecodeDispatch(const CallInterfaceDescriptor& descriptor,
Node* code_target_address, Node** args);
......
......@@ -224,6 +224,9 @@ void JSGenericLowering::LowerJSLoadGlobal(Node* node) {
void JSGenericLowering::LowerJSStoreProperty(Node* node) {
Node* receiver = NodeProperties::GetValueInput(node, 0);
Node* key = NodeProperties::GetValueInput(node, 1);
Node* value = NodeProperties::GetValueInput(node, 2);
Node* closure = NodeProperties::GetValueInput(node, 3);
Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node);
......@@ -242,14 +245,22 @@ void JSGenericLowering::LowerJSStoreProperty(Node* node) {
jsgraph()->IntPtrConstant(LiteralsArray::kFeedbackVectorOffset -
kHeapObjectTag),
effect, control);
node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
node->ReplaceInput(4, vector);
typedef StoreWithVectorDescriptor Descriptor;
node->InsertInputs(zone(), 0, 1);
node->ReplaceInput(Descriptor::kReceiver, receiver);
node->ReplaceInput(Descriptor::kName, key);
node->ReplaceInput(Descriptor::kValue, value);
node->ReplaceInput(Descriptor::kSlot,
jsgraph()->SmiConstant(p.feedback().index()));
node->ReplaceInput(Descriptor::kVector, vector);
node->ReplaceInput(7, effect);
ReplaceWithStubCall(node, callable, flags);
}
void JSGenericLowering::LowerJSStoreNamed(Node* node) {
Node* receiver = NodeProperties::GetValueInput(node, 0);
Node* value = NodeProperties::GetValueInput(node, 1);
Node* closure = NodeProperties::GetValueInput(node, 2);
Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node);
......@@ -267,15 +278,21 @@ void JSGenericLowering::LowerJSStoreNamed(Node* node) {
jsgraph()->IntPtrConstant(LiteralsArray::kFeedbackVectorOffset -
kHeapObjectTag),
effect, control);
node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
node->ReplaceInput(4, vector);
typedef StoreWithVectorDescriptor Descriptor;
node->InsertInputs(zone(), 0, 2);
node->ReplaceInput(Descriptor::kReceiver, receiver);
node->ReplaceInput(Descriptor::kName, jsgraph()->HeapConstant(p.name()));
node->ReplaceInput(Descriptor::kValue, value);
node->ReplaceInput(Descriptor::kSlot,
jsgraph()->SmiConstant(p.feedback().index()));
node->ReplaceInput(Descriptor::kVector, vector);
node->ReplaceInput(7, effect);
ReplaceWithStubCall(node, callable, flags);
}
void JSGenericLowering::LowerJSStoreGlobal(Node* node) {
Node* value = NodeProperties::GetValueInput(node, 0);
Node* closure = NodeProperties::GetValueInput(node, 1);
Node* context = NodeProperties::GetContextInput(node);
Node* effect = NodeProperties::GetEffectInput(node);
......@@ -304,10 +321,14 @@ void JSGenericLowering::LowerJSStoreGlobal(Node* node) {
machine()->Load(MachineType::AnyTagged()), native_context,
jsgraph()->IntPtrConstant(Context::SlotOffset(Context::EXTENSION_INDEX)),
effect, control);
node->InsertInput(zone(), 0, global);
node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
node->ReplaceInput(4, vector);
typedef StoreWithVectorDescriptor Descriptor;
node->InsertInputs(zone(), 0, 3);
node->ReplaceInput(Descriptor::kReceiver, global);
node->ReplaceInput(Descriptor::kName, jsgraph()->HeapConstant(p.name()));
node->ReplaceInput(Descriptor::kValue, value);
node->ReplaceInput(Descriptor::kSlot,
jsgraph()->SmiConstant(p.feedback().index()));
node->ReplaceInput(Descriptor::kVector, vector);
node->ReplaceInput(7, effect);
ReplaceWithStubCall(node, callable, flags);
}
......
......@@ -193,6 +193,22 @@ void Node::InsertInput(Zone* zone, int index, Node* new_to) {
Verify();
}
void Node::InsertInputs(Zone* zone, int index, int count) {
DCHECK_NOT_NULL(zone);
DCHECK_LE(0, index);
DCHECK_LT(0, count);
DCHECK_LT(index, InputCount());
for (int i = 0; i < count; i++) {
AppendInput(zone, InputAt(Max(InputCount() - count, 0)));
}
for (int i = InputCount() - count - 1; i >= Max(index, count); --i) {
ReplaceInput(i, InputAt(i - count));
}
for (int i = 0; i < count; i++) {
ReplaceInput(index + i, nullptr);
}
Verify();
}
void Node::RemoveInput(int index) {
DCHECK_LE(0, index);
......
......@@ -100,6 +100,7 @@ class Node final {
void AppendInput(Zone* zone, Node* new_to);
void InsertInput(Zone* zone, int index, Node* new_to);
void InsertInputs(Zone* zone, int index, int count);
void RemoveInput(int index);
void NullAllInputs();
void TrimInputCount(int new_input_count);
......
......@@ -2378,12 +2378,13 @@ RUNTIME_FUNCTION(Runtime_KeyedLoadIC_MissFromStubFailure) {
TimerEventScope<TimerEventIcMiss> timer(isolate);
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8"), "V8.IcMiss");
HandleScope scope(isolate);
Handle<Object> receiver = args.at<Object>(0);
Handle<Object> key = args.at<Object>(1);
DCHECK(args.length() == 4);
Handle<Smi> slot = args.at<Smi>(2);
Handle<TypeFeedbackVector> vector = args.at<TypeFeedbackVector>(3);
DCHECK_EQ(4, args.length());
typedef LoadWithVectorDescriptor Descriptor;
Handle<Object> receiver = args.at<Object>(Descriptor::kReceiver);
Handle<Object> key = args.at<Object>(Descriptor::kName);
Handle<Smi> slot = args.at<Smi>(Descriptor::kSlot);
Handle<TypeFeedbackVector> vector =
args.at<TypeFeedbackVector>(Descriptor::kVector);
FeedbackVectorSlot vector_slot = vector->ToSlot(slot->value());
KeyedLoadICNexus nexus(vector, vector_slot);
KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus);
......@@ -2422,6 +2423,35 @@ RUNTIME_FUNCTION(Runtime_StoreIC_Miss) {
RUNTIME_FUNCTION(Runtime_StoreIC_MissFromStubFailure) {
TimerEventScope<TimerEventIcMiss> timer(isolate);
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8"), "V8.IcMiss");
HandleScope scope(isolate);
DCHECK_EQ(5, args.length());
typedef StoreWithVectorDescriptor Descriptor;
Handle<Object> receiver = args.at<Object>(Descriptor::kReceiver);
Handle<Name> key = args.at<Name>(Descriptor::kName);
Handle<Object> value = args.at<Object>(Descriptor::kValue);
Handle<Smi> slot = args.at<Smi>(Descriptor::kSlot);
Handle<TypeFeedbackVector> vector =
args.at<TypeFeedbackVector>(Descriptor::kVector);
FeedbackVectorSlot vector_slot = vector->ToSlot(slot->value());
if (vector->GetKind(vector_slot) == FeedbackVectorSlotKind::STORE_IC) {
StoreICNexus nexus(vector, vector_slot);
StoreIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus);
ic.UpdateState(receiver, key);
RETURN_RESULT_OR_FAILURE(isolate, ic.Store(receiver, key, value));
} else {
DCHECK_EQ(FeedbackVectorSlotKind::KEYED_STORE_IC,
vector->GetKind(vector_slot));
KeyedStoreICNexus nexus(vector, vector_slot);
KeyedStoreIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus);
ic.UpdateState(receiver, key);
RETURN_RESULT_OR_FAILURE(isolate, ic.Store(receiver, key, value));
}
}
RUNTIME_FUNCTION(Runtime_TransitionStoreIC_MissFromStubFailure) {
TimerEventScope<TimerEventIcMiss> timer(isolate);
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8"), "V8.IcMiss");
HandleScope scope(isolate);
......@@ -2431,6 +2461,9 @@ RUNTIME_FUNCTION(Runtime_StoreIC_MissFromStubFailure) {
int length = args.length();
DCHECK(length == 5 || length == 6);
// TODO(ishell): use VectorStoreTransitionDescriptor indices here and update
// this comment:
//
// We might have slot and vector, for a normal miss (slot(3), vector(4)).
// Or, map and vector for a transitioning store miss (map(3), vector(4)).
// In this case, we need to recover the slot from a virtual register.
......@@ -2438,15 +2471,10 @@ RUNTIME_FUNCTION(Runtime_StoreIC_MissFromStubFailure) {
Handle<Smi> slot;
Handle<TypeFeedbackVector> vector;
if (length == 5) {
if (args.at<Object>(3)->IsMap()) {
vector = args.at<TypeFeedbackVector>(4);
slot = handle(
*reinterpret_cast<Smi**>(isolate->virtual_slot_register_address()),
isolate);
} else {
vector = args.at<TypeFeedbackVector>(4);
slot = args.at<Smi>(3);
}
} else {
vector = args.at<TypeFeedbackVector>(5);
slot = args.at<Smi>(4);
......@@ -2468,17 +2496,15 @@ RUNTIME_FUNCTION(Runtime_StoreIC_MissFromStubFailure) {
}
}
// Used from ic-<arch>.cc.
RUNTIME_FUNCTION(Runtime_KeyedStoreIC_Miss) {
TimerEventScope<TimerEventIcMiss> timer(isolate);
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8"), "V8.IcMiss");
HandleScope scope(isolate);
DCHECK_EQ(5, args.length());
Handle<Object> receiver = args.at<Object>(0);
Handle<Object> key = args.at<Object>(1);
Handle<Object> value = args.at<Object>(2);
DCHECK(args.length() == 5);
Handle<Smi> slot = args.at<Smi>(3);
Handle<TypeFeedbackVector> vector = args.at<TypeFeedbackVector>(4);
FeedbackVectorSlot vector_slot = vector->ToSlot(slot->value());
......@@ -2493,13 +2519,14 @@ RUNTIME_FUNCTION(Runtime_KeyedStoreIC_MissFromStubFailure) {
TimerEventScope<TimerEventIcMiss> timer(isolate);
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8"), "V8.IcMiss");
HandleScope scope(isolate);
Handle<Object> receiver = args.at<Object>(0);
Handle<Object> key = args.at<Object>(1);
Handle<Object> value = args.at<Object>(2);
DCHECK(args.length() == 5);
Handle<Smi> slot = args.at<Smi>(3);
Handle<TypeFeedbackVector> vector = args.at<TypeFeedbackVector>(4);
DCHECK_EQ(5, args.length());
typedef StoreWithVectorDescriptor Descriptor;
Handle<Object> receiver = args.at<Object>(Descriptor::kReceiver);
Handle<Object> key = args.at<Object>(Descriptor::kName);
Handle<Object> value = args.at<Object>(Descriptor::kValue);
Handle<Smi> slot = args.at<Smi>(Descriptor::kSlot);
Handle<TypeFeedbackVector> vector =
args.at<TypeFeedbackVector>(Descriptor::kVector);
FeedbackVectorSlot vector_slot = vector->ToSlot(slot->value());
KeyedStoreICNexus nexus(vector, vector_slot);
KeyedStoreIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus);
......@@ -2510,7 +2537,7 @@ RUNTIME_FUNCTION(Runtime_KeyedStoreIC_MissFromStubFailure) {
RUNTIME_FUNCTION(Runtime_KeyedStoreIC_Slow) {
HandleScope scope(isolate);
DCHECK(args.length() == 5);
DCHECK_EQ(5, args.length());
Handle<Object> object = args.at<Object>(0);
Handle<Object> key = args.at<Object>(1);
Handle<Object> value = args.at<Object>(2);
......@@ -2671,8 +2698,9 @@ RUNTIME_FUNCTION(Runtime_BinaryOpIC_Miss) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8"), "V8.IcMiss");
HandleScope scope(isolate);
DCHECK_EQ(2, args.length());
Handle<Object> left = args.at<Object>(BinaryOpICStub::kLeft);
Handle<Object> right = args.at<Object>(BinaryOpICStub::kRight);
typedef BinaryOpDescriptor Descriptor;
Handle<Object> left = args.at<Object>(Descriptor::kLeft);
Handle<Object> right = args.at<Object>(Descriptor::kRight);
BinaryOpIC ic(isolate);
RETURN_RESULT_OR_FAILURE(
isolate, ic.Transition(Handle<AllocationSite>::null(), left, right));
......@@ -2684,11 +2712,11 @@ RUNTIME_FUNCTION(Runtime_BinaryOpIC_MissWithAllocationSite) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8"), "V8.IcMiss");
HandleScope scope(isolate);
DCHECK_EQ(3, args.length());
typedef BinaryOpWithAllocationSiteDescriptor Descriptor;
Handle<AllocationSite> allocation_site =
args.at<AllocationSite>(BinaryOpWithAllocationSiteStub::kAllocationSite);
Handle<Object> left = args.at<Object>(BinaryOpWithAllocationSiteStub::kLeft);
Handle<Object> right =
args.at<Object>(BinaryOpWithAllocationSiteStub::kRight);
args.at<AllocationSite>(Descriptor::kAllocationSite);
Handle<Object> left = args.at<Object>(Descriptor::kLeft);
Handle<Object> right = args.at<Object>(Descriptor::kRight);
BinaryOpIC ic(isolate);
RETURN_RESULT_OR_FAILURE(isolate,
ic.Transition(allocation_site, left, right));
......@@ -2993,12 +3021,13 @@ RUNTIME_FUNCTION(Runtime_LoadIC_MissFromStubFailure) {
TimerEventScope<TimerEventIcMiss> timer(isolate);
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8"), "V8.IcMiss");
HandleScope scope(isolate);
Handle<Object> receiver = args.at<Object>(0);
Handle<Name> key = args.at<Name>(1);
DCHECK(args.length() == 4);
Handle<Smi> slot = args.at<Smi>(2);
Handle<TypeFeedbackVector> vector = args.at<TypeFeedbackVector>(3);
DCHECK_EQ(4, args.length());
typedef LoadWithVectorDescriptor Descriptor;
Handle<Object> receiver = args.at<Object>(Descriptor::kReceiver);
Handle<Name> key = args.at<Name>(Descriptor::kName);
Handle<Smi> slot = args.at<Smi>(Descriptor::kSlot);
Handle<TypeFeedbackVector> vector =
args.at<TypeFeedbackVector>(Descriptor::kVector);
FeedbackVectorSlot vector_slot = vector->ToSlot(slot->value());
// A monomorphic or polymorphic KeyedLoadIC with a string key can call the
// LoadIC miss handler if the handler misses. Since the vector Nexus is
......
This diff is collapsed.
This diff is collapsed.
......@@ -38,10 +38,9 @@ InterpreterAssembler::InterpreterAssembler(Isolate* isolate, Zone* zone,
made_call_(false),
disable_stack_check_across_call_(false),
stack_pointer_before_call_(nullptr) {
accumulator_.Bind(
Parameter(InterpreterDispatchDescriptor::kAccumulatorParameter));
accumulator_.Bind(Parameter(InterpreterDispatchDescriptor::kAccumulator));
bytecode_offset_.Bind(
Parameter(InterpreterDispatchDescriptor::kBytecodeOffsetParameter));
Parameter(InterpreterDispatchDescriptor::kBytecodeOffset));
if (FLAG_trace_ignition) {
TraceBytecode(Runtime::kInterpreterTraceBytecodeEntry);
}
......@@ -95,12 +94,12 @@ Node* InterpreterAssembler::BytecodeArrayTaggedPointer() {
// the debugger has swapped us to the patched debugger bytecode array.
return LoadRegister(Register::bytecode_array());
} else {
return Parameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter);
return Parameter(InterpreterDispatchDescriptor::kBytecodeArray);
}
}
Node* InterpreterAssembler::DispatchTableRawPointer() {
return Parameter(InterpreterDispatchDescriptor::kDispatchTableParameter);
return Parameter(InterpreterDispatchDescriptor::kDispatchTable);
}
Node* InterpreterAssembler::RegisterLocation(Node* reg_index) {
......
......@@ -26,6 +26,7 @@ namespace interpreter {
using compiler::Node;
typedef CodeStubAssembler::Label Label;
typedef CodeStubAssembler::Variable Variable;
typedef InterpreterAssembler::Arg Arg;
#define __ assembler->
......@@ -383,6 +384,7 @@ void Interpreter::DoMov(InterpreterAssembler* assembler) {
Node* Interpreter::BuildLoadGlobal(Callable ic,
InterpreterAssembler* assembler) {
typedef LoadGlobalWithVectorDescriptor Descriptor;
// Get the global object.
Node* context = __ GetContext();
......@@ -391,8 +393,9 @@ Node* Interpreter::BuildLoadGlobal(Callable ic,
Node* raw_slot = __ BytecodeOperandIdx(0);
Node* smi_slot = __ SmiTag(raw_slot);
Node* type_feedback_vector = __ LoadTypeFeedbackVector();
return __ CallStub(ic.descriptor(), code_target, context, smi_slot,
type_feedback_vector);
return __ CallStub(ic.descriptor(), code_target, context,
Arg(Descriptor::kSlot, smi_slot),
Arg(Descriptor::kVector, type_feedback_vector));
}
// LdaGlobal <slot>
......@@ -433,6 +436,7 @@ void Interpreter::DoLdaGlobalInsideTypeof(InterpreterAssembler* assembler) {
}
void Interpreter::DoStaGlobal(Callable ic, InterpreterAssembler* assembler) {
typedef StoreWithVectorDescriptor Descriptor;
// Get the global object.
Node* context = __ GetContext();
Node* native_context =
......@@ -447,8 +451,10 @@ void Interpreter::DoStaGlobal(Callable ic, InterpreterAssembler* assembler) {
Node* raw_slot = __ BytecodeOperandIdx(1);
Node* smi_slot = __ SmiTag(raw_slot);
Node* type_feedback_vector = __ LoadTypeFeedbackVector();
__ CallStub(ic.descriptor(), code_target, context, global, name, value,
smi_slot, type_feedback_vector);
__ CallStub(ic.descriptor(), code_target, context,
Arg(Descriptor::kReceiver, global), Arg(Descriptor::kName, name),
Arg(Descriptor::kValue, value), Arg(Descriptor::kSlot, smi_slot),
Arg(Descriptor::kVector, type_feedback_vector));
__ Dispatch();
}
......@@ -567,6 +573,7 @@ void Interpreter::DoStaLookupSlotStrict(InterpreterAssembler* assembler) {
Node* Interpreter::BuildLoadNamedProperty(Callable ic,
InterpreterAssembler* assembler) {
typedef LoadWithVectorDescriptor Descriptor;
Node* code_target = __ HeapConstant(ic.code());
Node* register_index = __ BytecodeOperandReg(0);
Node* object = __ LoadRegister(register_index);
......@@ -576,8 +583,10 @@ Node* Interpreter::BuildLoadNamedProperty(Callable ic,
Node* smi_slot = __ SmiTag(raw_slot);
Node* type_feedback_vector = __ LoadTypeFeedbackVector();
Node* context = __ GetContext();
return __ CallStub(ic.descriptor(), code_target, context, object, name,
smi_slot, type_feedback_vector);
return __ CallStub(
ic.descriptor(), code_target, context, Arg(Descriptor::kReceiver, object),
Arg(Descriptor::kName, name), Arg(Descriptor::kSlot, smi_slot),
Arg(Descriptor::kVector, type_feedback_vector));
}
// LdaNamedProperty <object> <name_index> <slot>
......@@ -605,6 +614,7 @@ void Interpreter::DoLdrNamedProperty(InterpreterAssembler* assembler) {
Node* Interpreter::BuildLoadKeyedProperty(Callable ic,
InterpreterAssembler* assembler) {
typedef LoadWithVectorDescriptor Descriptor;
Node* code_target = __ HeapConstant(ic.code());
Node* reg_index = __ BytecodeOperandReg(0);
Node* object = __ LoadRegister(reg_index);
......@@ -613,8 +623,10 @@ Node* Interpreter::BuildLoadKeyedProperty(Callable ic,
Node* smi_slot = __ SmiTag(raw_slot);
Node* type_feedback_vector = __ LoadTypeFeedbackVector();
Node* context = __ GetContext();
return __ CallStub(ic.descriptor(), code_target, context, object, name,
smi_slot, type_feedback_vector);
return __ CallStub(
ic.descriptor(), code_target, context, Arg(Descriptor::kReceiver, object),
Arg(Descriptor::kName, name), Arg(Descriptor::kSlot, smi_slot),
Arg(Descriptor::kVector, type_feedback_vector));
}
// KeyedLoadIC <object> <slot>
......@@ -641,6 +653,7 @@ void Interpreter::DoLdrKeyedProperty(InterpreterAssembler* assembler) {
}
void Interpreter::DoStoreIC(Callable ic, InterpreterAssembler* assembler) {
typedef StoreWithVectorDescriptor Descriptor;
Node* code_target = __ HeapConstant(ic.code());
Node* object_reg_index = __ BytecodeOperandReg(0);
Node* object = __ LoadRegister(object_reg_index);
......@@ -651,8 +664,10 @@ void Interpreter::DoStoreIC(Callable ic, InterpreterAssembler* assembler) {
Node* smi_slot = __ SmiTag(raw_slot);
Node* type_feedback_vector = __ LoadTypeFeedbackVector();
Node* context = __ GetContext();
__ CallStub(ic.descriptor(), code_target, context, object, name, value,
smi_slot, type_feedback_vector);
__ CallStub(ic.descriptor(), code_target, context,
Arg(Descriptor::kReceiver, object), Arg(Descriptor::kName, name),
Arg(Descriptor::kValue, value), Arg(Descriptor::kSlot, smi_slot),
Arg(Descriptor::kVector, type_feedback_vector));
__ Dispatch();
}
......@@ -677,6 +692,7 @@ void Interpreter::DoStaNamedPropertyStrict(InterpreterAssembler* assembler) {
}
void Interpreter::DoKeyedStoreIC(Callable ic, InterpreterAssembler* assembler) {
typedef StoreWithVectorDescriptor Descriptor;
Node* code_target = __ HeapConstant(ic.code());
Node* object_reg_index = __ BytecodeOperandReg(0);
Node* object = __ LoadRegister(object_reg_index);
......@@ -687,8 +703,10 @@ void Interpreter::DoKeyedStoreIC(Callable ic, InterpreterAssembler* assembler) {
Node* smi_slot = __ SmiTag(raw_slot);
Node* type_feedback_vector = __ LoadTypeFeedbackVector();
Node* context = __ GetContext();
__ CallStub(ic.descriptor(), code_target, context, object, name, value,
smi_slot, type_feedback_vector);
__ CallStub(ic.descriptor(), code_target, context,
Arg(Descriptor::kReceiver, object), Arg(Descriptor::kName, name),
Arg(Descriptor::kValue, value), Arg(Descriptor::kSlot, smi_slot),
Arg(Descriptor::kVector, type_feedback_vector));
__ Dispatch();
}
......
......@@ -944,6 +944,7 @@ namespace internal {
F(StoreCallbackProperty, 6, 1) \
F(StoreIC_Miss, 5, 1) \
F(StoreIC_MissFromStubFailure, 5, 1) \
F(TransitionStoreIC_MissFromStubFailure, 6, 1) \
F(StorePropertyWithInterceptor, 3, 1) \
F(ToBooleanIC_Miss, 1, 1) \
F(Unreachable, 0, 1)
......
......@@ -320,6 +320,80 @@ TEST(Inputs) {
CHECK_USES(n4, n3, n3, n5);
}
TEST(InsertInputs) {
base::AccountingAllocator allocator;
Zone zone(&allocator);
Graph graph(&zone);
Node* n0 = graph.NewNode(&dummy_operator0);
Node* n1 = graph.NewNode(&dummy_operator1, n0);
Node* n2 = graph.NewNode(&dummy_operator1, n0);
{
Node* node = graph.NewNode(&dummy_operator1, n0);
node->InsertInputs(graph.zone(), 0, 1);
node->ReplaceInput(0, n1);
CHECK_INPUTS(node, n1, n0);
}
{
Node* node = graph.NewNode(&dummy_operator1, n0);
node->InsertInputs(graph.zone(), 0, 2);
node->ReplaceInput(0, node);
node->ReplaceInput(1, n2);
CHECK_INPUTS(node, node, n2, n0);
}
{
Node* node = graph.NewNode(&dummy_operator3, n0, n1, n2);
node->InsertInputs(graph.zone(), 0, 1);
node->ReplaceInput(0, node);
CHECK_INPUTS(node, node, n0, n1, n2);
}
{
Node* node = graph.NewNode(&dummy_operator3, n0, n1, n2);
node->InsertInputs(graph.zone(), 1, 1);
node->ReplaceInput(1, node);
CHECK_INPUTS(node, n0, node, n1, n2);
}
{
Node* node = graph.NewNode(&dummy_operator3, n0, n1, n2);
node->InsertInputs(graph.zone(), 2, 1);
node->ReplaceInput(2, node);
CHECK_INPUTS(node, n0, n1, node, n2);
}
{
Node* node = graph.NewNode(&dummy_operator3, n0, n1, n2);
node->InsertInputs(graph.zone(), 2, 1);
node->ReplaceInput(2, node);
CHECK_INPUTS(node, n0, n1, node, n2);
}
{
Node* node = graph.NewNode(&dummy_operator3, n0, n1, n2);
node->InsertInputs(graph.zone(), 0, 4);
node->ReplaceInput(0, node);
node->ReplaceInput(1, node);
node->ReplaceInput(2, node);
node->ReplaceInput(3, node);
CHECK_INPUTS(node, node, node, node, node, n0, n1, n2);
}
{
Node* node = graph.NewNode(&dummy_operator3, n0, n1, n2);
node->InsertInputs(graph.zone(), 1, 4);
node->ReplaceInput(1, node);
node->ReplaceInput(2, node);
node->ReplaceInput(3, node);
node->ReplaceInput(4, node);
CHECK_INPUTS(node, n0, node, node, node, node, n1, n2);
}
{
Node* node = graph.NewNode(&dummy_operator3, n0, n1, n2);
node->InsertInputs(graph.zone(), 2, 4);
node->ReplaceInput(2, node);
node->ReplaceInput(3, node);
node->ReplaceInput(4, node);
node->ReplaceInput(5, node);
CHECK_INPUTS(node, n0, n1, node, node, node, node, n2);
}
}
TEST(RemoveInput) {
base::AccountingAllocator allocator;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment