Turn LoadIndexedInterceptor into a Turbofan stub

BUG=

Review URL: https://codereview.chromium.org/1820843002

Cr-Commit-Position: refs/heads/master@{#34937}
This commit is contained in:
verwaest 2016-03-21 06:33:02 -07:00 committed by Commit bot
parent 6479d4264a
commit 9536c3886b
12 changed files with 43 additions and 211 deletions

View File

@ -1497,29 +1497,6 @@ void LoadIndexedStringStub::Generate(MacroAssembler* masm) {
}
void LoadIndexedInterceptorStub::Generate(MacroAssembler* masm) {
// Return address is in lr.
Label slow;
Register receiver = LoadDescriptor::ReceiverRegister();
Register key = LoadDescriptor::NameRegister();
// Check that the key is an array index, that is Uint32.
__ NonNegativeSmiTst(key);
__ b(ne, &slow);
// Everything is fine, call runtime.
__ Push(receiver, key); // Receiver, key.
// Perform tail call to the entry.
__ TailCallRuntime(Runtime::kLoadElementWithInterceptor);
__ bind(&slow);
PropertyAccessCompiler::TailCallBuiltin(
masm, PropertyAccessCompiler::MissBuiltin(Code::KEYED_LOAD_IC));
}
void RegExpExecStub::Generate(MacroAssembler* masm) {
// Just jump directly to runtime if native RegExp is not selected at compile
// time or if regexp entry in generated code is turned off runtime switch or

View File

@ -1632,26 +1632,6 @@ void InstanceOfStub::Generate(MacroAssembler* masm) {
}
void LoadIndexedInterceptorStub::Generate(MacroAssembler* masm) {
// Return address is in lr.
Label slow;
Register receiver = LoadDescriptor::ReceiverRegister();
Register key = LoadDescriptor::NameRegister();
// Check that the key is an array index, that is Uint32.
__ TestAndBranchIfAnySet(key, kSmiTagMask | kSmiSignMask, &slow);
// Everything is fine, call runtime.
__ Push(receiver, key);
__ TailCallRuntime(Runtime::kLoadElementWithInterceptor);
__ Bind(&slow);
PropertyAccessCompiler::TailCallBuiltin(
masm, PropertyAccessCompiler::MissBuiltin(Code::KEYED_LOAD_IC));
}
void RegExpExecStub::Generate(MacroAssembler* masm) {
#ifdef V8_INTERPRETED_REGEXP
__ TailCallRuntime(Runtime::kRegExpExec);

View File

@ -2343,6 +2343,28 @@ void StoreInterceptorStub::GenerateAssembly(
receiver, name, value);
}
void LoadIndexedInterceptorStub::GenerateAssembly(
compiler::CodeStubAssembler* assembler) const {
typedef compiler::Node Node;
typedef compiler::CodeStubAssembler::Label Label;
Node* receiver = assembler->Parameter(0);
Node* key = assembler->Parameter(1);
Node* slot = assembler->Parameter(2);
Node* vector = assembler->Parameter(3);
Node* context = assembler->Parameter(4);
Label if_keyispositivesmi(assembler), if_keyisinvalid(assembler);
assembler->Branch(assembler->WordIsPositiveSmi(key), &if_keyispositivesmi,
&if_keyisinvalid);
assembler->Bind(&if_keyispositivesmi);
assembler->TailCallRuntime(Runtime::kLoadElementWithInterceptor, context,
receiver, key);
assembler->Bind(&if_keyisinvalid);
assembler->TailCallRuntime(Runtime::kKeyedLoadIC_Miss, context, receiver, key,
slot, vector);
}
template<class StateType>
void HydrogenCodeStub::TraceTransition(StateType from, StateType to) {
// Note: Although a no-op transition is semantically OK, it is hinting at a

View File

@ -37,7 +37,6 @@ namespace internal {
V(KeyedLoadICTrampoline) \
V(LoadICTrampoline) \
V(CallICTrampoline) \
V(LoadIndexedInterceptor) \
V(LoadIndexedString) \
V(MathPow) \
V(ProfileEntryHook) \
@ -121,6 +120,7 @@ namespace internal {
V(LoadConstant) \
V(LoadFastElement) \
V(LoadField) \
V(LoadIndexedInterceptor) \
V(KeyedLoadSloppyArguments) \
V(KeyedStoreSloppyArguments) \
V(StoreField) \
@ -792,6 +792,17 @@ class StoreInterceptorStub : public TurboFanCodeStub {
DEFINE_CODE_STUB(StoreInterceptor, TurboFanCodeStub);
};
class LoadIndexedInterceptorStub : public TurboFanCodeStub {
public:
explicit LoadIndexedInterceptorStub(Isolate* isolate)
: TurboFanCodeStub(isolate) {}
Code::Kind GetCodeKind() const override { return Code::HANDLER; }
DEFINE_CALL_INTERFACE_DESCRIPTOR(LoadWithVector);
DEFINE_TURBOFAN_CODE_STUB(LoadIndexedInterceptor, TurboFanCodeStub);
};
enum StringAddFlags {
// Omit both parameter checks.
STRING_ADD_CHECK_NONE = 0,
@ -1173,20 +1184,6 @@ class FunctionPrototypeStub : public PlatformCodeStub {
};
// TODO(mvstanton): Translate to hydrogen code stub.
class LoadIndexedInterceptorStub : public PlatformCodeStub {
public:
explicit LoadIndexedInterceptorStub(Isolate* isolate)
: PlatformCodeStub(isolate) {}
Code::Kind GetCodeKind() const override { return Code::HANDLER; }
Code::StubType GetStubType() const override { return Code::FAST; }
DEFINE_CALL_INTERFACE_DESCRIPTOR(Load);
DEFINE_PLATFORM_CODE_STUB(LoadIndexedInterceptor, PlatformCodeStub);
};
class LoadIndexedStringStub : public PlatformCodeStub {
public:
explicit LoadIndexedStringStub(Isolate* isolate)

View File

@ -221,6 +221,12 @@ Node* CodeStubAssembler::WordIsSmi(Node* a) {
IntPtrConstant(0));
}
Node* CodeStubAssembler::WordIsPositiveSmi(Node* a) {
return WordEqual(
raw_assembler_->WordAnd(a, IntPtrConstant(kSmiTagMask | kSmiSignMask)),
IntPtrConstant(0));
}
Node* CodeStubAssembler::LoadBufferObject(Node* buffer, int offset,
MachineType rep) {
return raw_assembler_->Load(rep, buffer, IntPtrConstant(offset));

View File

@ -273,6 +273,9 @@ class CodeStubAssembler {
// Check a value for smi-ness
Node* WordIsSmi(Node* a);
// Check that the value is a positive smi.
Node* WordIsPositiveSmi(Node* a);
// Load an object pointer from a buffer that isn't in the heap.
Node* LoadBufferObject(Node* buffer, int offset,
MachineType rep = MachineType::AnyTagged());

View File

@ -667,34 +667,6 @@ void FunctionPrototypeStub::Generate(MacroAssembler* masm) {
}
void LoadIndexedInterceptorStub::Generate(MacroAssembler* masm) {
// Return address is on the stack.
Label slow;
Register receiver = LoadDescriptor::ReceiverRegister();
Register key = LoadDescriptor::NameRegister();
Register scratch = eax;
DCHECK(!scratch.is(receiver) && !scratch.is(key));
// Check that the key is an array index, that is Uint32.
__ test(key, Immediate(kSmiTagMask | kSmiSignMask));
__ j(not_zero, &slow);
// Everything is fine, call runtime.
__ pop(scratch);
__ push(receiver); // receiver
__ push(key); // key
__ push(scratch); // return address
// Perform tail call to the entry.
__ TailCallRuntime(Runtime::kLoadElementWithInterceptor);
__ bind(&slow);
PropertyAccessCompiler::TailCallBuiltin(
masm, PropertyAccessCompiler::MissBuiltin(Code::KEYED_LOAD_IC));
}
void LoadIndexedStringStub::Generate(MacroAssembler* masm) {
// Return address is on the stack.
Label miss;

View File

@ -1598,29 +1598,6 @@ void FunctionPrototypeStub::Generate(MacroAssembler* masm) {
}
void LoadIndexedInterceptorStub::Generate(MacroAssembler* masm) {
// Return address is in ra.
Label slow;
Register receiver = LoadDescriptor::ReceiverRegister();
Register key = LoadDescriptor::NameRegister();
// Check that the key is an array index, that is Uint32.
__ And(t0, key, Operand(kSmiTagMask | kSmiSignMask));
__ Branch(&slow, ne, t0, Operand(zero_reg));
// Everything is fine, call runtime.
__ Push(receiver, key); // Receiver, key.
// Perform tail call to the entry.
__ TailCallRuntime(Runtime::kLoadElementWithInterceptor);
__ bind(&slow);
PropertyAccessCompiler::TailCallBuiltin(
masm, PropertyAccessCompiler::MissBuiltin(Code::KEYED_LOAD_IC));
}
void RegExpExecStub::Generate(MacroAssembler* masm) {
// Just jump directly to runtime if native RegExp is not selected at compile
// time or if regexp entry in generated code is turned off runtime switch or

View File

@ -1594,29 +1594,6 @@ void FunctionPrototypeStub::Generate(MacroAssembler* masm) {
}
void LoadIndexedInterceptorStub::Generate(MacroAssembler* masm) {
// Return address is in ra.
Label slow;
Register receiver = LoadDescriptor::ReceiverRegister();
Register key = LoadDescriptor::NameRegister();
// Check that the key is an array index, that is Uint32.
__ And(t0, key, Operand(kSmiTagMask | kSmiSignMask));
__ Branch(&slow, ne, t0, Operand(zero_reg));
// Everything is fine, call runtime.
__ Push(receiver, key); // Receiver, key.
// Perform tail call to the entry.
__ TailCallRuntime(Runtime::kLoadElementWithInterceptor);
__ bind(&slow);
PropertyAccessCompiler::TailCallBuiltin(
masm, PropertyAccessCompiler::MissBuiltin(Code::KEYED_LOAD_IC));
}
void RegExpExecStub::Generate(MacroAssembler* masm) {
// Just jump directly to runtime if native RegExp is not selected at compile
// time or if regexp entry in generated code is turned off runtime switch or

View File

@ -1547,29 +1547,6 @@ void LoadIndexedStringStub::Generate(MacroAssembler* masm) {
}
void LoadIndexedInterceptorStub::Generate(MacroAssembler* masm) {
// Return address is in lr.
Label slow;
Register receiver = LoadDescriptor::ReceiverRegister();
Register key = LoadDescriptor::NameRegister();
// Check that the key is an array index, that is Uint32.
__ TestIfPositiveSmi(key, r0);
__ bne(&slow, cr0);
// Everything is fine, call runtime.
__ Push(receiver, key); // Receiver, key.
// Perform tail call to the entry.
__ TailCallRuntime(Runtime::kLoadElementWithInterceptor);
__ bind(&slow);
PropertyAccessCompiler::TailCallBuiltin(
masm, PropertyAccessCompiler::MissBuiltin(Code::KEYED_LOAD_IC));
}
void RegExpExecStub::Generate(MacroAssembler* masm) {
// Just jump directly to runtime if native RegExp is not selected at compile
// time or if regexp entry in generated code is turned off runtime switch or

View File

@ -535,34 +535,6 @@ void FunctionPrototypeStub::Generate(MacroAssembler* masm) {
}
void LoadIndexedInterceptorStub::Generate(MacroAssembler* masm) {
// Return address is on the stack.
Label slow;
Register receiver = LoadDescriptor::ReceiverRegister();
Register key = LoadDescriptor::NameRegister();
Register scratch = rax;
DCHECK(!scratch.is(receiver) && !scratch.is(key));
// Check that the key is an array index, that is Uint32.
STATIC_ASSERT(kSmiValueSize <= 32);
__ JumpUnlessNonNegativeSmi(key, &slow);
// Everything is fine, call runtime.
__ PopReturnAddressTo(scratch);
__ Push(receiver); // receiver
__ Push(key); // key
__ PushReturnAddressFrom(scratch);
// Perform tail call to the entry.
__ TailCallRuntime(Runtime::kLoadElementWithInterceptor);
__ bind(&slow);
PropertyAccessCompiler::TailCallBuiltin(
masm, PropertyAccessCompiler::MissBuiltin(Code::KEYED_LOAD_IC));
}
void LoadIndexedStringStub::Generate(MacroAssembler* masm) {
// Return address is on the stack.
Label miss;

View File

@ -367,34 +367,6 @@ void FunctionPrototypeStub::Generate(MacroAssembler* masm) {
}
void LoadIndexedInterceptorStub::Generate(MacroAssembler* masm) {
// Return address is on the stack.
Label slow;
Register receiver = LoadDescriptor::ReceiverRegister();
Register key = LoadDescriptor::NameRegister();
Register scratch = eax;
DCHECK(!scratch.is(receiver) && !scratch.is(key));
// Check that the key is an array index, that is Uint32.
__ test(key, Immediate(kSmiTagMask | kSmiSignMask));
__ j(not_zero, &slow);
// Everything is fine, call runtime.
__ pop(scratch);
__ push(receiver); // receiver
__ push(key); // key
__ push(scratch); // return address
// Perform tail call to the entry.
__ TailCallRuntime(Runtime::kLoadElementWithInterceptor);
__ bind(&slow);
PropertyAccessCompiler::TailCallBuiltin(
masm, PropertyAccessCompiler::MissBuiltin(Code::KEYED_LOAD_IC));
}
void LoadIndexedStringStub::Generate(MacroAssembler* masm) {
// Return address is on the stack.
Label miss;