Commit cce56a3f authored by ishell's avatar ishell Committed by Commit bot

[stubs] Port StoreFastElementsStub to TurboFan.

This CL adds CSA::Retain() operation that ensures that the value is kept alive even during GC.

BUG=v8:5269

Review-Url: https://codereview.chromium.org/2330063002
Cr-Commit-Position: refs/heads/master@{#39407}
parent d7ee8124
This diff is collapsed.
......@@ -662,6 +662,30 @@ class CodeStubAssembler : public compiler::CodeAssembler {
// Loads script context from the script context table.
compiler::Node* LoadScriptContext(compiler::Node* context, int context_index);
compiler::Node* ClampedToUint8(compiler::Node* int32_value);
// Store value to an elements array with given elements kind.
void StoreElement(compiler::Node* elements, ElementsKind kind,
compiler::Node* index, compiler::Node* value,
ParameterMode mode);
void EmitElementStore(compiler::Node* object, compiler::Node* key,
compiler::Node* value, bool is_jsarray,
ElementsKind elements_kind,
KeyedAccessStoreMode store_mode, Label* bailout);
compiler::Node* CheckForCapacityGrow(compiler::Node* object,
compiler::Node* elements,
ElementsKind kind,
compiler::Node* length,
compiler::Node* key, ParameterMode mode,
bool is_js_array, Label* bailout);
compiler::Node* CopyElementsOnWrite(compiler::Node* object,
compiler::Node* elements,
ElementsKind kind, compiler::Node* length,
ParameterMode mode, Label* bailout);
void LoadIC(const LoadICParameters* p);
void LoadGlobalIC(const LoadICParameters* p);
void KeyedLoadIC(const LoadICParameters* p);
......
......@@ -976,23 +976,6 @@ Handle<Code> StoreTransitionStub::GenerateCode() {
}
template <>
HValue* CodeStubGraphBuilder<StoreFastElementStub>::BuildCodeStub() {
BuildUncheckedMonomorphicElementAccess(
GetParameter(Descriptor::kReceiver), GetParameter(Descriptor::kName),
GetParameter(Descriptor::kValue), casted_stub()->is_js_array(),
casted_stub()->elements_kind(), STORE, NEVER_RETURN_HOLE,
casted_stub()->store_mode());
return GetParameter(Descriptor::kValue);
}
Handle<Code> StoreFastElementStub::GenerateCode() {
return DoGenerateCode(this);
}
template <>
HValue* CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() {
ElementsKind const from_kind = casted_stub()->from_kind();
......
......@@ -5122,13 +5122,6 @@ CallInterfaceDescriptor HandlerStub::GetCallInterfaceDescriptor() const {
}
void StoreFastElementStub::InitializeDescriptor(
CodeStubDescriptor* descriptor) {
descriptor->Initialize(
FUNCTION_ADDR(Runtime_KeyedStoreIC_MissFromStubFailure));
}
void ElementsTransitionAndStoreStub::InitializeDescriptor(
CodeStubDescriptor* descriptor) {
descriptor->Initialize(
......@@ -5680,6 +5673,35 @@ void StoreElementStub::Generate(MacroAssembler* masm) {
ElementHandlerCompiler::GenerateStoreSlow(masm);
}
void StoreFastElementStub::GenerateAssembly(
CodeStubAssembler* assembler) const {
typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node;
assembler->Comment(
"StoreFastElementStub: js_array=%d, elements_kind=%s, store_mode=%d",
is_js_array(), ElementsKindToString(elements_kind()), store_mode());
Node* receiver = assembler->Parameter(Descriptor::kReceiver);
Node* key = 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);
Label miss(assembler);
assembler->EmitElementStore(receiver, key, value, is_js_array(),
elements_kind(), store_mode(), &miss);
assembler->Return(value);
assembler->Bind(&miss);
{
assembler->Comment("Miss");
assembler->TailCallRuntime(Runtime::kKeyedStoreIC_Miss, context, receiver,
key, value, slot, vector);
}
}
// static
void StoreFastElementStub::GenerateAheadOfTime(Isolate* isolate) {
......
......@@ -86,7 +86,6 @@ class ObjectLiteral;
V(LoadDictionaryElement) \
V(LoadFastElement) \
V(LoadField) \
V(StoreFastElement) \
V(StoreTransition) \
/* These should never be ported to TF */ \
/* because they are either used only by */ \
......@@ -165,6 +164,7 @@ class ObjectLiteral;
V(GetProperty) \
V(LoadICTF) \
V(KeyedLoadICTF) \
V(StoreFastElement) \
V(StoreField) \
V(StoreGlobal) \
V(StoreInterceptor) \
......@@ -2774,38 +2774,38 @@ class LoadFastElementStub : public HandlerStub {
DEFINE_HANDLER_CODE_STUB(LoadFastElement, HandlerStub);
};
class StoreFastElementStub : public HydrogenCodeStub {
class StoreFastElementStub : public TurboFanCodeStub {
public:
StoreFastElementStub(Isolate* isolate, bool is_js_array,
ElementsKind elements_kind, KeyedAccessStoreMode mode)
: HydrogenCodeStub(isolate) {
set_sub_minor_key(CommonStoreModeBits::encode(mode) |
: TurboFanCodeStub(isolate) {
minor_key_ = CommonStoreModeBits::encode(mode) |
ElementsKindBits::encode(elements_kind) |
IsJSArrayBits::encode(is_js_array));
IsJSArrayBits::encode(is_js_array);
}
static void GenerateAheadOfTime(Isolate* isolate);
bool is_js_array() const { return IsJSArrayBits::decode(sub_minor_key()); }
bool is_js_array() const { return IsJSArrayBits::decode(minor_key_); }
ElementsKind elements_kind() const {
return ElementsKindBits::decode(sub_minor_key());
return ElementsKindBits::decode(minor_key_);
}
KeyedAccessStoreMode store_mode() const {
return CommonStoreModeBits::decode(sub_minor_key());
return CommonStoreModeBits::decode(minor_key_);
}
Code::Kind GetCodeKind() const override { return Code::HANDLER; }
ExtraICState GetExtraICState() const override { return Code::KEYED_STORE_IC; }
private:
class ElementsKindBits : public BitField<ElementsKind, 3, 8> {};
class IsJSArrayBits : public BitField<bool, 11, 1> {};
class ElementsKindBits
: public BitField<ElementsKind, CommonStoreModeBits::kNext, 8> {};
class IsJSArrayBits : public BitField<bool, ElementsKindBits::kNext, 1> {};
DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreWithVector);
DEFINE_HYDROGEN_CODE_STUB(StoreFastElement, HydrogenCodeStub);
DEFINE_TURBOFAN_CODE_STUB(StoreFastElement, TurboFanCodeStub);
};
......@@ -3004,7 +3004,8 @@ class StoreElementStub : public PlatformCodeStub {
return ElementsKindBits::decode(minor_key_);
}
class ElementsKindBits : public BitField<ElementsKind, 3, 8> {};
class ElementsKindBits
: public BitField<ElementsKind, CommonStoreModeBits::kNext, 8> {};
DEFINE_PLATFORM_CODE_STUB(StoreElement, PlatformCodeStub);
};
......@@ -3104,7 +3105,8 @@ class ElementsTransitionAndStoreStub : public HydrogenCodeStub {
ExtraICState GetExtraICState() const override { return Code::KEYED_STORE_IC; }
private:
class FromBits : public BitField<ElementsKind, 3, 8> {};
class FromBits
: public BitField<ElementsKind, CommonStoreModeBits::kNext, 8> {};
class ToBits : public BitField<ElementsKind, 11, 8> {};
class IsJSArrayBits : public BitField<bool, 19, 1> {};
......
......@@ -306,6 +306,10 @@ Node* CodeAssembler::StoreRoot(Heap::RootListIndex root_index, Node* value) {
IntPtrConstant(root_index * kPointerSize), value);
}
Node* CodeAssembler::Retain(Node* value) {
return raw_assembler_->Retain(value);
}
Node* CodeAssembler::Projection(int index, Node* value) {
return raw_assembler_->Projection(index, value);
}
......
......@@ -54,6 +54,7 @@ class RawMachineLabel;
V(IntPtrGreaterThanOrEqual) \
V(IntPtrEqual) \
V(Uint32LessThan) \
V(Uint32LessThanOrEqual) \
V(Uint32GreaterThanOrEqual) \
V(UintPtrLessThan) \
V(UintPtrGreaterThan) \
......@@ -145,6 +146,7 @@ class RawMachineLabel;
V(ChangeUint32ToFloat64) \
V(ChangeUint32ToUint64) \
V(RoundFloat64ToInt32) \
V(Float64SilenceNaN) \
V(Float64RoundDown) \
V(Float64RoundUp) \
V(Float64RoundTruncate) \
......@@ -294,6 +296,10 @@ class CodeAssembler {
// No-op on 32-bit, otherwise sign extend.
Node* ChangeInt32ToIntPtr(Node* value);
// No-op that guarantees that the value is kept alive till this point even
// if GC happens.
Node* Retain(Node* value);
// Projections
Node* Projection(int index, Node* value);
......
......@@ -135,6 +135,7 @@ class RawMachineAssembler {
return AddNode(machine()->Store(StoreRepresentation(rep, write_barrier)),
base, index, value);
}
Node* Retain(Node* value) { return AddNode(common()->Retain(), value); }
// Unaligned memory operations
Node* UnalignedLoad(MachineType rep, Node* base) {
......@@ -659,6 +660,9 @@ class RawMachineAssembler {
Node* Float64InsertHighWord32(Node* a, Node* b) {
return AddNode(machine()->Float64InsertHighWord32(), a, b);
}
Node* Float64SilenceNaN(Node* a) {
return AddNode(machine()->Float64SilenceNaN(), a);
}
// Stack operations.
Node* LoadStackPointer() { return AddNode(machine()->LoadStackPointer()); }
......
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