Commit 3c873c43 authored by verwaest@chromium.org's avatar verwaest@chromium.org

Restructure the IC / Handler compilers

BUG=
R=ishell@chromium.org, mvstanton@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22622 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 553e069f
...@@ -1845,20 +1845,12 @@ void InstanceofStub::Generate(MacroAssembler* masm) { ...@@ -1845,20 +1845,12 @@ void InstanceofStub::Generate(MacroAssembler* masm) {
void FunctionPrototypeStub::Generate(MacroAssembler* masm) { void FunctionPrototypeStub::Generate(MacroAssembler* masm) {
Label miss; Label miss;
Register receiver = LoadIC::ReceiverRegister(); Register receiver = LoadIC::ReceiverRegister();
Register name = LoadIC::NameRegister();
ASSERT(kind() == Code::LOAD_IC || NamedLoadHandlerCompiler::GenerateLoadFunctionPrototype(masm, receiver, r3,
kind() == Code::KEYED_LOAD_IC); r4, &miss);
if (kind() == Code::KEYED_LOAD_IC) {
__ cmp(name, Operand(isolate()->factory()->prototype_string()));
__ b(ne, &miss);
}
StubCompiler::GenerateLoadFunctionPrototype(masm, receiver, r3, r4, &miss);
__ bind(&miss); __ bind(&miss);
StubCompiler::TailCallBuiltin( PropertyAccessCompiler::TailCallBuiltin(
masm, BaseLoadStoreStubCompiler::MissBuiltin(kind())); masm, PropertyAccessCompiler::MissBuiltin(Code::LOAD_IC));
} }
......
This diff is collapsed.
...@@ -1703,21 +1703,13 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { ...@@ -1703,21 +1703,13 @@ void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) {
void FunctionPrototypeStub::Generate(MacroAssembler* masm) { void FunctionPrototypeStub::Generate(MacroAssembler* masm) {
Label miss; Label miss;
Register receiver = LoadIC::ReceiverRegister(); Register receiver = LoadIC::ReceiverRegister();
Register name = LoadIC::NameRegister();
ASSERT(kind() == Code::LOAD_IC || NamedLoadHandlerCompiler::GenerateLoadFunctionPrototype(masm, receiver, x10,
kind() == Code::KEYED_LOAD_IC); x11, &miss);
if (kind() == Code::KEYED_LOAD_IC) {
__ Cmp(name, Operand(isolate()->factory()->prototype_string()));
__ B(ne, &miss);
}
StubCompiler::GenerateLoadFunctionPrototype(masm, receiver, x10, x11, &miss);
__ Bind(&miss); __ Bind(&miss);
StubCompiler::TailCallBuiltin(masm, PropertyAccessCompiler::TailCallBuiltin(
BaseLoadStoreStubCompiler::MissBuiltin(kind())); masm, PropertyAccessCompiler::MissBuiltin(Code::LOAD_IC));
} }
......
This diff is collapsed.
...@@ -1313,7 +1313,7 @@ static void Generate_LoadIC_Normal(MacroAssembler* masm) { ...@@ -1313,7 +1313,7 @@ static void Generate_LoadIC_Normal(MacroAssembler* masm) {
static void Generate_LoadIC_Getter_ForDeopt(MacroAssembler* masm) { static void Generate_LoadIC_Getter_ForDeopt(MacroAssembler* masm) {
LoadStubCompiler::GenerateLoadViaGetterForDeopt(masm); NamedLoadHandlerCompiler::GenerateLoadViaGetterForDeopt(masm);
} }
...@@ -1378,7 +1378,7 @@ static void Generate_StoreIC_Normal(MacroAssembler* masm) { ...@@ -1378,7 +1378,7 @@ static void Generate_StoreIC_Normal(MacroAssembler* masm) {
static void Generate_StoreIC_Setter_ForDeopt(MacroAssembler* masm) { static void Generate_StoreIC_Setter_ForDeopt(MacroAssembler* masm) {
StoreStubCompiler::GenerateStoreViaSetterForDeopt(masm); NamedStoreHandlerCompiler::GenerateStoreViaSetterForDeopt(masm);
} }
......
...@@ -236,6 +236,8 @@ const char* CodeStub::MajorName(CodeStub::Major major_key, ...@@ -236,6 +236,8 @@ const char* CodeStub::MajorName(CodeStub::Major major_key,
CODE_STUB_LIST(DEF_CASE) CODE_STUB_LIST(DEF_CASE)
#undef DEF_CASE #undef DEF_CASE
case UninitializedMajorKey: return "<UninitializedMajorKey>Stub"; case UninitializedMajorKey: return "<UninitializedMajorKey>Stub";
case NoCache:
return "<NoCache>Stub";
default: default:
if (!allow_unknown_keys) { if (!allow_unknown_keys) {
UNREACHABLE(); UNREACHABLE();
...@@ -671,7 +673,7 @@ void StoreGlobalStub::InitializeInterfaceDescriptor( ...@@ -671,7 +673,7 @@ void StoreGlobalStub::InitializeInterfaceDescriptor(
void KeyedLoadDictionaryElementPlatformStub::Generate( void KeyedLoadDictionaryElementPlatformStub::Generate(
MacroAssembler* masm) { MacroAssembler* masm) {
KeyedLoadStubCompiler::GenerateLoadDictionaryElement(masm); IndexedHandlerCompiler::GenerateLoadDictionaryElement(masm);
} }
...@@ -698,7 +700,7 @@ void KeyedStoreElementStub::Generate(MacroAssembler* masm) { ...@@ -698,7 +700,7 @@ void KeyedStoreElementStub::Generate(MacroAssembler* masm) {
UNREACHABLE(); UNREACHABLE();
break; break;
case DICTIONARY_ELEMENTS: case DICTIONARY_ELEMENTS:
KeyedStoreStubCompiler::GenerateStoreDictionaryElement(masm); IndexedHandlerCompiler::GenerateStoreDictionaryElement(masm);
break; break;
case SLOPPY_ARGUMENTS_ELEMENTS: case SLOPPY_ARGUMENTS_ELEMENTS:
UNREACHABLE(); UNREACHABLE();
......
...@@ -900,23 +900,14 @@ class CallIC_ArrayStub: public CallICStub { ...@@ -900,23 +900,14 @@ class CallIC_ArrayStub: public CallICStub {
// TODO(verwaest): Translate to hydrogen code stub. // TODO(verwaest): Translate to hydrogen code stub.
class FunctionPrototypeStub : public PlatformCodeStub { class FunctionPrototypeStub : public PlatformCodeStub {
public: public:
FunctionPrototypeStub(Isolate* isolate, Code::Kind kind) explicit FunctionPrototypeStub(Isolate* isolate)
: PlatformCodeStub(isolate) { : PlatformCodeStub(isolate) {}
bit_field_ = KindBits::encode(kind);
}
virtual void Generate(MacroAssembler* masm); virtual void Generate(MacroAssembler* masm);
virtual Code::Kind GetCodeKind() const { return Code::HANDLER; } virtual Code::Kind GetCodeKind() const { return Code::HANDLER; }
virtual InlineCacheState GetICState() { return MONOMORPHIC; }
virtual ExtraICState GetExtraICState() const { return kind(); }
protected:
class KindBits : public BitField<Code::Kind, 0, 4> {};
virtual Code::Kind kind() const { return KindBits::decode(bit_field_); }
private: private:
virtual CodeStub::Major MajorKey() const { return FunctionPrototype; } virtual CodeStub::Major MajorKey() const { return FunctionPrototype; }
virtual int MinorKey() const { return bit_field_; } virtual int MinorKey() const { return 0; }
int bit_field_;
}; };
......
...@@ -885,22 +885,14 @@ void MathPowStub::Generate(MacroAssembler* masm) { ...@@ -885,22 +885,14 @@ void MathPowStub::Generate(MacroAssembler* masm) {
void FunctionPrototypeStub::Generate(MacroAssembler* masm) { void FunctionPrototypeStub::Generate(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- ecx : name
// -- edx : receiver
// -- esp[0] : return address
// -----------------------------------
Label miss; Label miss;
Register receiver = LoadIC::ReceiverRegister();
if (kind() == Code::KEYED_LOAD_IC) { NamedLoadHandlerCompiler::GenerateLoadFunctionPrototype(masm, receiver, eax,
__ cmp(ecx, Immediate(isolate()->factory()->prototype_string())); ebx, &miss);
__ j(not_equal, &miss);
}
StubCompiler::GenerateLoadFunctionPrototype(masm, edx, eax, ebx, &miss);
__ bind(&miss); __ bind(&miss);
StubCompiler::TailCallBuiltin( PropertyAccessCompiler::TailCallBuiltin(
masm, BaseLoadStoreStubCompiler::MissBuiltin(kind())); masm, PropertyAccessCompiler::MissBuiltin(Code::LOAD_IC));
} }
......
This diff is collapsed.
...@@ -877,7 +877,7 @@ Handle<Code> IC::ComputeHandler(LookupResult* lookup, ...@@ -877,7 +877,7 @@ Handle<Code> IC::ComputeHandler(LookupResult* lookup,
Handle<Map> stub_holder_map = IC::GetHandlerCacheHolder( Handle<Map> stub_holder_map = IC::GetHandlerCacheHolder(
*receiver_type(), receiver_is_holder, isolate(), &flag); *receiver_type(), receiver_is_holder, isolate(), &flag);
Handle<Code> code = isolate()->stub_cache()->FindHandler( Handle<Code> code = PropertyHandlerCompiler::Find(
name, stub_holder_map, handler_kind(), flag, name, stub_holder_map, handler_kind(), flag,
lookup->holder()->HasFastProperties() ? Code::FAST : Code::NORMAL); lookup->holder()->HasFastProperties() ? Code::FAST : Code::NORMAL);
// Use the cached value if it exists, and if it is different from the // Use the cached value if it exists, and if it is different from the
...@@ -934,14 +934,14 @@ Handle<Code> LoadIC::CompileHandler(LookupResult* lookup, Handle<Object> object, ...@@ -934,14 +934,14 @@ Handle<Code> LoadIC::CompileHandler(LookupResult* lookup, Handle<Object> object,
Handle<JSFunction>::cast(object)->should_have_prototype() && Handle<JSFunction>::cast(object)->should_have_prototype() &&
!Handle<JSFunction>::cast(object)->map()->has_non_instance_prototype()) { !Handle<JSFunction>::cast(object)->map()->has_non_instance_prototype()) {
Handle<Code> stub; Handle<Code> stub;
FunctionPrototypeStub function_prototype_stub(isolate(), kind()); FunctionPrototypeStub function_prototype_stub(isolate());
return function_prototype_stub.GetCode(); return function_prototype_stub.GetCode();
} }
Handle<HeapType> type = receiver_type(); Handle<HeapType> type = receiver_type();
Handle<JSObject> holder(lookup->holder()); Handle<JSObject> holder(lookup->holder());
bool receiver_is_holder = object.is_identical_to(holder); bool receiver_is_holder = object.is_identical_to(holder);
LoadStubCompiler compiler(isolate(), handler_kind(), kNoExtraICState, NamedLoadHandlerCompiler compiler(isolate(), handler_kind(), kNoExtraICState,
cache_holder); cache_holder);
switch (lookup->type()) { switch (lookup->type()) {
...@@ -1392,8 +1392,8 @@ Handle<Code> StoreIC::CompileHandler(LookupResult* lookup, ...@@ -1392,8 +1392,8 @@ Handle<Code> StoreIC::CompileHandler(LookupResult* lookup,
Handle<JSObject> receiver = Handle<JSObject>::cast(object); Handle<JSObject> receiver = Handle<JSObject>::cast(object);
Handle<JSObject> holder(lookup->holder()); Handle<JSObject> holder(lookup->holder());
// Handlers do not use strict mode. NamedStoreHandlerCompiler compiler(isolate(), kind());
StoreStubCompiler compiler(isolate(), SLOPPY, kind());
if (lookup->IsTransition()) { if (lookup->IsTransition()) {
// Explicitly pass in the receiver map since LookupForWrite may have // Explicitly pass in the receiver map since LookupForWrite may have
// stored something else than the receiver in the holder. // stored something else than the receiver in the holder.
...@@ -1746,13 +1746,15 @@ MaybeHandle<Object> KeyedStoreIC::Store(Handle<Object> object, ...@@ -1746,13 +1746,15 @@ MaybeHandle<Object> KeyedStoreIC::Store(Handle<Object> object,
value, value,
JSReceiver::MAY_BE_STORE_FROM_KEYED), JSReceiver::MAY_BE_STORE_FROM_KEYED),
Object); Object);
} else { TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "set generic");
bool use_ic = FLAG_use_ic && set_target(*stub);
!object->IsStringWrapper() && return store_handle;
!object->IsAccessCheckNeeded() && }
!object->IsJSGlobalProxy() &&
!(object->IsJSObject() && bool use_ic =
JSObject::cast(*object)->map()->is_observed()); FLAG_use_ic && !object->IsStringWrapper() &&
!object->IsAccessCheckNeeded() && !object->IsJSGlobalProxy() &&
!(object->IsJSObject() && JSObject::cast(*object)->map()->is_observed());
if (use_ic && !object->IsSmi()) { if (use_ic && !object->IsSmi()) {
// Don't use ICs for maps of the objects in Array's prototype chain. We // Don't use ICs for maps of the objects in Array's prototype chain. We
// expect to be able to trap element sets to objects with those maps in // expect to be able to trap element sets to objects with those maps in
...@@ -1779,14 +1781,12 @@ MaybeHandle<Object> KeyedStoreIC::Store(Handle<Object> object, ...@@ -1779,14 +1781,12 @@ MaybeHandle<Object> KeyedStoreIC::Store(Handle<Object> object,
// other non-dictionary receivers in the polymorphic case benefit // other non-dictionary receivers in the polymorphic case benefit
// from fast path keyed stores. // from fast path keyed stores.
if (!(receiver->map()->DictionaryElementsInPrototypeChainOnly())) { if (!(receiver->map()->DictionaryElementsInPrototypeChainOnly())) {
KeyedAccessStoreMode store_mode = KeyedAccessStoreMode store_mode = GetStoreMode(receiver, key, value);
GetStoreMode(receiver, key, value);
stub = StoreElementStub(receiver, store_mode); stub = StoreElementStub(receiver, store_mode);
} }
} }
} }
} }
}
if (store_handle.is_null()) { if (store_handle.is_null()) {
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
...@@ -1797,7 +1797,7 @@ MaybeHandle<Object> KeyedStoreIC::Store(Handle<Object> object, ...@@ -1797,7 +1797,7 @@ MaybeHandle<Object> KeyedStoreIC::Store(Handle<Object> object,
Object); Object);
} }
if (!is_target_set()) { ASSERT(!is_target_set());
Code* generic = *generic_stub(); Code* generic = *generic_stub();
if (*stub == generic) { if (*stub == generic) {
TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "set generic"); TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "set generic");
...@@ -1805,7 +1805,6 @@ MaybeHandle<Object> KeyedStoreIC::Store(Handle<Object> object, ...@@ -1805,7 +1805,6 @@ MaybeHandle<Object> KeyedStoreIC::Store(Handle<Object> object,
ASSERT(!stub.is_null()); ASSERT(!stub.is_null());
set_target(*stub); set_target(*stub);
TRACE_IC("StoreIC", key); TRACE_IC("StoreIC", key);
}
return store_handle; return store_handle;
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -764,20 +764,12 @@ void MathPowStub::Generate(MacroAssembler* masm) { ...@@ -764,20 +764,12 @@ void MathPowStub::Generate(MacroAssembler* masm) {
void FunctionPrototypeStub::Generate(MacroAssembler* masm) { void FunctionPrototypeStub::Generate(MacroAssembler* masm) {
Label miss; Label miss;
Register receiver = LoadIC::ReceiverRegister(); Register receiver = LoadIC::ReceiverRegister();
Register name = LoadIC::NameRegister();
ASSERT(kind() == Code::LOAD_IC || NamedLoadHandlerCompiler::GenerateLoadFunctionPrototype(masm, receiver, r8,
kind() == Code::KEYED_LOAD_IC); r9, &miss);
if (kind() == Code::KEYED_LOAD_IC) {
__ Cmp(name, isolate()->factory()->prototype_string());
__ j(not_equal, &miss);
}
StubCompiler::GenerateLoadFunctionPrototype(masm, receiver, r8, r9, &miss);
__ bind(&miss); __ bind(&miss);
StubCompiler::TailCallBuiltin( PropertyAccessCompiler::TailCallBuiltin(
masm, BaseLoadStoreStubCompiler::MissBuiltin(kind())); masm, PropertyAccessCompiler::MissBuiltin(Code::LOAD_IC));
} }
......
This diff is collapsed.
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