Commit 0a099371 authored by verwaest@chromium.org's avatar verwaest@chromium.org

Remove all compilation related interface from the StubCache

BUG=
R=ishell@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22678 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 57c315d0
...@@ -619,11 +619,11 @@ static void PushInterceptorArguments(MacroAssembler* masm, ...@@ -619,11 +619,11 @@ static void PushInterceptorArguments(MacroAssembler* masm,
Register holder, Register holder,
Register name, Register name,
Handle<JSObject> holder_obj) { Handle<JSObject> holder_obj) {
STATIC_ASSERT(StubCache::kInterceptorArgsNameIndex == 0); STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex == 0);
STATIC_ASSERT(StubCache::kInterceptorArgsInfoIndex == 1); STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsInfoIndex == 1);
STATIC_ASSERT(StubCache::kInterceptorArgsThisIndex == 2); STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex == 2);
STATIC_ASSERT(StubCache::kInterceptorArgsHolderIndex == 3); STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex == 3);
STATIC_ASSERT(StubCache::kInterceptorArgsLength == 4); STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsLength == 4);
__ push(name); __ push(name);
Handle<InterceptorInfo> interceptor(holder_obj->GetNamedInterceptor()); Handle<InterceptorInfo> interceptor(holder_obj->GetNamedInterceptor());
ASSERT(!masm->isolate()->heap()->InNewSpace(*interceptor)); ASSERT(!masm->isolate()->heap()->InNewSpace(*interceptor));
...@@ -643,9 +643,8 @@ static void CompileCallLoadPropertyWithInterceptor( ...@@ -643,9 +643,8 @@ static void CompileCallLoadPropertyWithInterceptor(
Handle<JSObject> holder_obj, Handle<JSObject> holder_obj,
IC::UtilityId id) { IC::UtilityId id) {
PushInterceptorArguments(masm, receiver, holder, name, holder_obj); PushInterceptorArguments(masm, receiver, holder, name, holder_obj);
__ CallExternalReference( __ CallExternalReference(ExternalReference(IC_Utility(id), masm->isolate()),
ExternalReference(IC_Utility(id), masm->isolate()), NamedLoadHandlerCompiler::kInterceptorArgsLength);
StubCache::kInterceptorArgsLength);
} }
...@@ -1053,7 +1052,8 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor( ...@@ -1053,7 +1052,8 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(
ExternalReference ref = ExternalReference ref =
ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptor), ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptor),
isolate()); isolate());
__ TailCallExternalReference(ref, StubCache::kInterceptorArgsLength, 1); __ TailCallExternalReference(
ref, NamedLoadHandlerCompiler::kInterceptorArgsLength, 1);
} }
} }
......
...@@ -567,11 +567,11 @@ static void PushInterceptorArguments(MacroAssembler* masm, ...@@ -567,11 +567,11 @@ static void PushInterceptorArguments(MacroAssembler* masm,
Register holder, Register holder,
Register name, Register name,
Handle<JSObject> holder_obj) { Handle<JSObject> holder_obj) {
STATIC_ASSERT(StubCache::kInterceptorArgsNameIndex == 0); STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex == 0);
STATIC_ASSERT(StubCache::kInterceptorArgsInfoIndex == 1); STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsInfoIndex == 1);
STATIC_ASSERT(StubCache::kInterceptorArgsThisIndex == 2); STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex == 2);
STATIC_ASSERT(StubCache::kInterceptorArgsHolderIndex == 3); STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex == 3);
STATIC_ASSERT(StubCache::kInterceptorArgsLength == 4); STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsLength == 4);
__ Push(name); __ Push(name);
Handle<InterceptorInfo> interceptor(holder_obj->GetNamedInterceptor()); Handle<InterceptorInfo> interceptor(holder_obj->GetNamedInterceptor());
...@@ -591,9 +591,8 @@ static void CompileCallLoadPropertyWithInterceptor( ...@@ -591,9 +591,8 @@ static void CompileCallLoadPropertyWithInterceptor(
IC::UtilityId id) { IC::UtilityId id) {
PushInterceptorArguments(masm, receiver, holder, name, holder_obj); PushInterceptorArguments(masm, receiver, holder, name, holder_obj);
__ CallExternalReference( __ CallExternalReference(ExternalReference(IC_Utility(id), masm->isolate()),
ExternalReference(IC_Utility(id), masm->isolate()), NamedLoadHandlerCompiler::kInterceptorArgsLength);
StubCache::kInterceptorArgsLength);
} }
...@@ -1015,7 +1014,8 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor( ...@@ -1015,7 +1014,8 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(
ExternalReference ref = ExternalReference ref =
ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptor), ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptor),
isolate()); isolate());
__ TailCallExternalReference(ref, StubCache::kInterceptorArgsLength, 1); __ TailCallExternalReference(
ref, NamedLoadHandlerCompiler::kInterceptorArgsLength, 1);
} }
} }
......
...@@ -264,11 +264,11 @@ static void PushInterceptorArguments(MacroAssembler* masm, ...@@ -264,11 +264,11 @@ static void PushInterceptorArguments(MacroAssembler* masm,
Register holder, Register holder,
Register name, Register name,
Handle<JSObject> holder_obj) { Handle<JSObject> holder_obj) {
STATIC_ASSERT(StubCache::kInterceptorArgsNameIndex == 0); STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex == 0);
STATIC_ASSERT(StubCache::kInterceptorArgsInfoIndex == 1); STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsInfoIndex == 1);
STATIC_ASSERT(StubCache::kInterceptorArgsThisIndex == 2); STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex == 2);
STATIC_ASSERT(StubCache::kInterceptorArgsHolderIndex == 3); STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex == 3);
STATIC_ASSERT(StubCache::kInterceptorArgsLength == 4); STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsLength == 4);
__ push(name); __ push(name);
Handle<InterceptorInfo> interceptor(holder_obj->GetNamedInterceptor()); Handle<InterceptorInfo> interceptor(holder_obj->GetNamedInterceptor());
ASSERT(!masm->isolate()->heap()->InNewSpace(*interceptor)); ASSERT(!masm->isolate()->heap()->InNewSpace(*interceptor));
...@@ -288,9 +288,8 @@ static void CompileCallLoadPropertyWithInterceptor( ...@@ -288,9 +288,8 @@ static void CompileCallLoadPropertyWithInterceptor(
Handle<JSObject> holder_obj, Handle<JSObject> holder_obj,
IC::UtilityId id) { IC::UtilityId id) {
PushInterceptorArguments(masm, receiver, holder, name, holder_obj); PushInterceptorArguments(masm, receiver, holder, name, holder_obj);
__ CallExternalReference( __ CallExternalReference(ExternalReference(IC_Utility(id), masm->isolate()),
ExternalReference(IC_Utility(id), masm->isolate()), NamedLoadHandlerCompiler::kInterceptorArgsLength);
StubCache::kInterceptorArgsLength);
} }
...@@ -1036,7 +1035,8 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor( ...@@ -1036,7 +1035,8 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(
ExternalReference ref = ExternalReference ref =
ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptor), ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptor),
isolate()); isolate());
__ TailCallExternalReference(ref, StubCache::kInterceptorArgsLength, 1); __ TailCallExternalReference(
ref, NamedLoadHandlerCompiler::kInterceptorArgsLength, 1);
} }
} }
......
...@@ -482,8 +482,8 @@ void LoadIC::Clear(Isolate* isolate, ...@@ -482,8 +482,8 @@ void LoadIC::Clear(Isolate* isolate,
Code* target, Code* target,
ConstantPoolArray* constant_pool) { ConstantPoolArray* constant_pool) {
if (IsCleared(target)) return; if (IsCleared(target)) return;
Code* code = target->GetIsolate()->stub_cache()->FindPreMonomorphicIC( Code* code = PropertyICCompiler::FindPreMonomorphicIC(
Code::LOAD_IC, target->extra_ic_state()); isolate, Code::LOAD_IC, target->extra_ic_state());
SetTargetAtAddress(address, code, constant_pool); SetTargetAtAddress(address, code, constant_pool);
} }
...@@ -493,8 +493,8 @@ void StoreIC::Clear(Isolate* isolate, ...@@ -493,8 +493,8 @@ void StoreIC::Clear(Isolate* isolate,
Code* target, Code* target,
ConstantPoolArray* constant_pool) { ConstantPoolArray* constant_pool) {
if (IsCleared(target)) return; if (IsCleared(target)) return;
Code* code = target->GetIsolate()->stub_cache()->FindPreMonomorphicIC( Code* code = PropertyICCompiler::FindPreMonomorphicIC(
Code::STORE_IC, target->extra_ic_state()); isolate, Code::STORE_IC, target->extra_ic_state());
SetTargetAtAddress(address, code, constant_pool); SetTargetAtAddress(address, code, constant_pool);
} }
...@@ -660,8 +660,8 @@ bool IC::UpdatePolymorphicIC(Handle<String> name, Handle<Code> code) { ...@@ -660,8 +660,8 @@ bool IC::UpdatePolymorphicIC(Handle<String> name, Handle<Code> code) {
if (number_of_valid_types > 1 && target()->is_keyed_stub()) return false; if (number_of_valid_types > 1 && target()->is_keyed_stub()) return false;
Handle<Code> ic; Handle<Code> ic;
if (number_of_valid_types == 1) { if (number_of_valid_types == 1) {
ic = isolate()->stub_cache()->ComputeMonomorphicIC(kind(), name, type, code, ic = PropertyICCompiler::ComputeMonomorphicIC(kind(), name, type, code,
extra_ic_state()); extra_ic_state());
} else { } else {
if (handler_to_overwrite >= 0) { if (handler_to_overwrite >= 0) {
handlers.Set(handler_to_overwrite, code); handlers.Set(handler_to_overwrite, code);
...@@ -672,9 +672,9 @@ bool IC::UpdatePolymorphicIC(Handle<String> name, Handle<Code> code) { ...@@ -672,9 +672,9 @@ bool IC::UpdatePolymorphicIC(Handle<String> name, Handle<Code> code) {
types.Add(type); types.Add(type);
handlers.Add(code); handlers.Add(code);
} }
ic = isolate()->stub_cache()->ComputePolymorphicIC( ic = PropertyICCompiler::ComputePolymorphicIC(kind(), &types, &handlers,
kind(), &types, &handlers, number_of_valid_types, name, number_of_valid_types, name,
extra_ic_state()); extra_ic_state());
} }
set_target(*ic); set_target(*ic);
return true; return true;
...@@ -725,7 +725,7 @@ Handle<HeapType> IC::MapToType<HeapType>(Handle<Map> map, Isolate* region); ...@@ -725,7 +725,7 @@ Handle<HeapType> IC::MapToType<HeapType>(Handle<Map> map, Isolate* region);
void IC::UpdateMonomorphicIC(Handle<Code> handler, Handle<String> name) { void IC::UpdateMonomorphicIC(Handle<Code> handler, Handle<String> name) {
if (!handler->is_handler()) return set_target(*handler); if (!handler->is_handler()) return set_target(*handler);
Handle<Code> ic = isolate()->stub_cache()->ComputeMonomorphicIC( Handle<Code> ic = PropertyICCompiler::ComputeMonomorphicIC(
kind(), name, receiver_type(), handler, extra_ic_state()); kind(), name, receiver_type(), handler, extra_ic_state());
set_target(*ic); set_target(*ic);
} }
...@@ -786,13 +786,14 @@ void IC::PatchCache(Handle<String> name, Handle<Code> code) { ...@@ -786,13 +786,14 @@ void IC::PatchCache(Handle<String> name, Handle<Code> code) {
Handle<Code> LoadIC::initialize_stub(Isolate* isolate, Handle<Code> LoadIC::initialize_stub(Isolate* isolate,
ExtraICState extra_state) { ExtraICState extra_state) {
return isolate->stub_cache()->ComputeLoad(UNINITIALIZED, extra_state); return PropertyICCompiler::ComputeLoad(isolate, UNINITIALIZED, extra_state);
} }
Handle<Code> LoadIC::megamorphic_stub() { Handle<Code> LoadIC::megamorphic_stub() {
if (kind() == Code::LOAD_IC) { if (kind() == Code::LOAD_IC) {
return isolate()->stub_cache()->ComputeLoad(MEGAMORPHIC, extra_ic_state()); return PropertyICCompiler::ComputeLoad(isolate(), MEGAMORPHIC,
extra_ic_state());
} else { } else {
ASSERT_EQ(Code::KEYED_LOAD_IC, kind()); ASSERT_EQ(Code::KEYED_LOAD_IC, kind());
return KeyedLoadIC::generic_stub(isolate()); return KeyedLoadIC::generic_stub(isolate());
...@@ -802,7 +803,7 @@ Handle<Code> LoadIC::megamorphic_stub() { ...@@ -802,7 +803,7 @@ Handle<Code> LoadIC::megamorphic_stub() {
Handle<Code> LoadIC::pre_monomorphic_stub(Isolate* isolate, Handle<Code> LoadIC::pre_monomorphic_stub(Isolate* isolate,
ExtraICState extra_state) { ExtraICState extra_state) {
return isolate->stub_cache()->ComputeLoad(PREMONOMORPHIC, extra_state); return PropertyICCompiler::ComputeLoad(isolate, PREMONOMORPHIC, extra_state);
} }
...@@ -845,8 +846,8 @@ void LoadIC::UpdateCaches(LookupResult* lookup, ...@@ -845,8 +846,8 @@ void LoadIC::UpdateCaches(LookupResult* lookup,
code = slow_stub(); code = slow_stub();
} else if (!lookup->IsProperty()) { } else if (!lookup->IsProperty()) {
if (kind() == Code::LOAD_IC) { if (kind() == Code::LOAD_IC) {
code = isolate()->stub_cache()->ComputeLoadNonexistent(name, code = NamedLoadHandlerCompiler::ComputeLoadNonexistent(name,
receiver_type()); receiver_type());
// TODO(jkummerow/verwaest): Introduce a builtin that handles this case. // TODO(jkummerow/verwaest): Introduce a builtin that handles this case.
if (code.is_null()) code = slow_stub(); if (code.is_null()) code = slow_stub();
} else { } else {
...@@ -1072,7 +1073,7 @@ Handle<Code> KeyedLoadIC::LoadElementStub(Handle<JSObject> receiver) { ...@@ -1072,7 +1073,7 @@ Handle<Code> KeyedLoadIC::LoadElementStub(Handle<JSObject> receiver) {
TargetMaps(&target_receiver_maps); TargetMaps(&target_receiver_maps);
} }
if (target_receiver_maps.length() == 0) { if (target_receiver_maps.length() == 0) {
return isolate()->stub_cache()->ComputeKeyedLoadElement(receiver_map); return PropertyICCompiler::ComputeKeyedLoadElement(receiver_map);
} }
// The first time a receiver is seen that is a transitioned version of the // The first time a receiver is seen that is a transitioned version of the
...@@ -1086,7 +1087,7 @@ Handle<Code> KeyedLoadIC::LoadElementStub(Handle<JSObject> receiver) { ...@@ -1086,7 +1087,7 @@ Handle<Code> KeyedLoadIC::LoadElementStub(Handle<JSObject> receiver) {
IsMoreGeneralElementsKindTransition( IsMoreGeneralElementsKindTransition(
target_receiver_maps.at(0)->elements_kind(), target_receiver_maps.at(0)->elements_kind(),
receiver->GetElementsKind())) { receiver->GetElementsKind())) {
return isolate()->stub_cache()->ComputeKeyedLoadElement(receiver_map); return PropertyICCompiler::ComputeKeyedLoadElement(receiver_map);
} }
ASSERT(state() != GENERIC); ASSERT(state() != GENERIC);
...@@ -1107,7 +1108,7 @@ Handle<Code> KeyedLoadIC::LoadElementStub(Handle<JSObject> receiver) { ...@@ -1107,7 +1108,7 @@ Handle<Code> KeyedLoadIC::LoadElementStub(Handle<JSObject> receiver) {
return generic_stub(); return generic_stub();
} }
return isolate()->stub_cache()->ComputeLoadElementPolymorphic( return PropertyICCompiler::ComputeLoadElementPolymorphic(
&target_receiver_maps); &target_receiver_maps);
} }
...@@ -1341,26 +1342,27 @@ Handle<Code> CallIC::initialize_stub(Isolate* isolate, ...@@ -1341,26 +1342,27 @@ Handle<Code> CallIC::initialize_stub(Isolate* isolate,
Handle<Code> StoreIC::initialize_stub(Isolate* isolate, Handle<Code> StoreIC::initialize_stub(Isolate* isolate,
StrictMode strict_mode) { StrictMode strict_mode) {
ExtraICState extra_state = ComputeExtraICState(strict_mode); ExtraICState extra_state = ComputeExtraICState(strict_mode);
Handle<Code> ic = isolate->stub_cache()->ComputeStore( Handle<Code> ic =
UNINITIALIZED, extra_state); PropertyICCompiler::ComputeStore(isolate, UNINITIALIZED, extra_state);
return ic; return ic;
} }
Handle<Code> StoreIC::megamorphic_stub() { Handle<Code> StoreIC::megamorphic_stub() {
return isolate()->stub_cache()->ComputeStore(MEGAMORPHIC, extra_ic_state()); return PropertyICCompiler::ComputeStore(isolate(), MEGAMORPHIC,
extra_ic_state());
} }
Handle<Code> StoreIC::generic_stub() const { Handle<Code> StoreIC::generic_stub() const {
return isolate()->stub_cache()->ComputeStore(GENERIC, extra_ic_state()); return PropertyICCompiler::ComputeStore(isolate(), GENERIC, extra_ic_state());
} }
Handle<Code> StoreIC::pre_monomorphic_stub(Isolate* isolate, Handle<Code> StoreIC::pre_monomorphic_stub(Isolate* isolate,
StrictMode strict_mode) { StrictMode strict_mode) {
ExtraICState state = ComputeExtraICState(strict_mode); ExtraICState state = ComputeExtraICState(strict_mode);
return isolate->stub_cache()->ComputeStore(PREMONOMORPHIC, state); return PropertyICCompiler::ComputeStore(isolate, PREMONOMORPHIC, state);
} }
...@@ -1492,7 +1494,7 @@ Handle<Code> KeyedStoreIC::StoreElementStub(Handle<JSObject> receiver, ...@@ -1492,7 +1494,7 @@ Handle<Code> KeyedStoreIC::StoreElementStub(Handle<JSObject> receiver,
Handle<Map> monomorphic_map = Handle<Map> monomorphic_map =
ComputeTransitionedMap(receiver_map, store_mode); ComputeTransitionedMap(receiver_map, store_mode);
store_mode = GetNonTransitioningStoreMode(store_mode); store_mode = GetNonTransitioningStoreMode(store_mode);
return isolate()->stub_cache()->ComputeKeyedStoreElement( return PropertyICCompiler::ComputeKeyedStoreElement(
monomorphic_map, strict_mode(), store_mode); monomorphic_map, strict_mode(), store_mode);
} }
...@@ -1517,7 +1519,7 @@ Handle<Code> KeyedStoreIC::StoreElementStub(Handle<JSObject> receiver, ...@@ -1517,7 +1519,7 @@ Handle<Code> KeyedStoreIC::StoreElementStub(Handle<JSObject> receiver,
// if they at least come from the same origin for a transitioning store, // if they at least come from the same origin for a transitioning store,
// stay MONOMORPHIC and use the map for the most generic ElementsKind. // stay MONOMORPHIC and use the map for the most generic ElementsKind.
store_mode = GetNonTransitioningStoreMode(store_mode); store_mode = GetNonTransitioningStoreMode(store_mode);
return isolate()->stub_cache()->ComputeKeyedStoreElement( return PropertyICCompiler::ComputeKeyedStoreElement(
transitioned_receiver_map, strict_mode(), store_mode); transitioned_receiver_map, strict_mode(), store_mode);
} else if (*previous_receiver_map == receiver->map() && } else if (*previous_receiver_map == receiver->map() &&
old_store_mode == STANDARD_STORE && old_store_mode == STANDARD_STORE &&
...@@ -1527,7 +1529,7 @@ Handle<Code> KeyedStoreIC::StoreElementStub(Handle<JSObject> receiver, ...@@ -1527,7 +1529,7 @@ Handle<Code> KeyedStoreIC::StoreElementStub(Handle<JSObject> receiver,
// A "normal" IC that handles stores can switch to a version that can // A "normal" IC that handles stores can switch to a version that can
// grow at the end of the array, handle OOB accesses or copy COW arrays // grow at the end of the array, handle OOB accesses or copy COW arrays
// and still stay MONOMORPHIC. // and still stay MONOMORPHIC.
return isolate()->stub_cache()->ComputeKeyedStoreElement( return PropertyICCompiler::ComputeKeyedStoreElement(
receiver_map, strict_mode(), store_mode); receiver_map, strict_mode(), store_mode);
} }
} }
...@@ -1589,7 +1591,7 @@ Handle<Code> KeyedStoreIC::StoreElementStub(Handle<JSObject> receiver, ...@@ -1589,7 +1591,7 @@ Handle<Code> KeyedStoreIC::StoreElementStub(Handle<JSObject> receiver,
} }
} }
return isolate()->stub_cache()->ComputeStoreElementPolymorphic( return PropertyICCompiler::ComputeStoreElementPolymorphic(
&target_receiver_maps, store_mode, strict_mode()); &target_receiver_maps, store_mode, strict_mode());
} }
...@@ -2955,7 +2957,7 @@ Handle<Object> CompareNilIC::CompareNil(Handle<Object> object) { ...@@ -2955,7 +2957,7 @@ Handle<Object> CompareNilIC::CompareNil(Handle<Object> object) {
Handle<Map> monomorphic_map(already_monomorphic && FirstTargetMap() != NULL Handle<Map> monomorphic_map(already_monomorphic && FirstTargetMap() != NULL
? FirstTargetMap() ? FirstTargetMap()
: HeapObject::cast(*object)->map()); : HeapObject::cast(*object)->map());
code = isolate()->stub_cache()->ComputeCompareNil(monomorphic_map, &stub); code = PropertyICCompiler::ComputeCompareNil(monomorphic_map, &stub);
} else { } else {
code = stub.GetCode(); code = stub.GetCode();
} }
......
...@@ -57,7 +57,8 @@ static Code::Flags CommonStubCacheChecks(Name* name, Map* map, ...@@ -57,7 +57,8 @@ static Code::Flags CommonStubCacheChecks(Name* name, Map* map,
Code* StubCache::Set(Name* name, Map* map, Code* code) { Code* StubCache::Set(Name* name, Map* map, Code* code) {
Code::Flags flags = CommonStubCacheChecks(name, map, code->flags(), heap()); Code::Flags flags =
CommonStubCacheChecks(name, map, code->flags(), isolate()->heap());
// Compute the primary entry. // Compute the primary entry.
int primary_offset = PrimaryOffset(name, flags, map); int primary_offset = PrimaryOffset(name, flags, map);
...@@ -86,7 +87,7 @@ Code* StubCache::Set(Name* name, Map* map, Code* code) { ...@@ -86,7 +87,7 @@ Code* StubCache::Set(Name* name, Map* map, Code* code) {
Code* StubCache::Get(Name* name, Map* map, Code::Flags flags) { Code* StubCache::Get(Name* name, Map* map, Code::Flags flags) {
flags = CommonStubCacheChecks(name, map, flags, heap()); flags = CommonStubCacheChecks(name, map, flags, isolate()->heap());
int primary_offset = PrimaryOffset(name, flags, map); int primary_offset = PrimaryOffset(name, flags, map);
Entry* primary = entry(primary_, primary_offset); Entry* primary = entry(primary_, primary_offset);
if (primary->key == name && primary->map == map) { if (primary->key == name && primary->map == map) {
...@@ -128,14 +129,12 @@ Handle<Code> PropertyHandlerCompiler::Find(Handle<Name> name, ...@@ -128,14 +129,12 @@ Handle<Code> PropertyHandlerCompiler::Find(Handle<Name> name,
} }
Handle<Code> StubCache::ComputeMonomorphicIC( Handle<Code> PropertyICCompiler::ComputeMonomorphicIC(
Code::Kind kind, Code::Kind kind, Handle<Name> name, Handle<HeapType> type,
Handle<Name> name, Handle<Code> handler, ExtraICState extra_ic_state) {
Handle<HeapType> type,
Handle<Code> handler,
ExtraICState extra_ic_state) {
CacheHolderFlag flag; CacheHolderFlag flag;
Handle<Map> stub_holder = IC::GetICCacheHolder(*type, isolate(), &flag); Isolate* isolate = name->GetIsolate();
Handle<Map> stub_holder = IC::GetICCacheHolder(*type, isolate, &flag);
Handle<Code> ic; Handle<Code> ic;
// There are multiple string maps that all use the same prototype. That // There are multiple string maps that all use the same prototype. That
...@@ -143,8 +142,7 @@ Handle<Code> StubCache::ComputeMonomorphicIC( ...@@ -143,8 +142,7 @@ Handle<Code> StubCache::ComputeMonomorphicIC(
// for a single name. Hence, turn off caching of the IC. // for a single name. Hence, turn off caching of the IC.
bool can_be_cached = !type->Is(HeapType::String()); bool can_be_cached = !type->Is(HeapType::String());
if (can_be_cached) { if (can_be_cached) {
ic = ic = Find(name, stub_holder, kind, extra_ic_state, flag);
PropertyICCompiler::Find(name, stub_holder, kind, extra_ic_state, flag);
if (!ic.is_null()) return ic; if (!ic.is_null()) return ic;
} }
...@@ -155,7 +153,7 @@ Handle<Code> StubCache::ComputeMonomorphicIC( ...@@ -155,7 +153,7 @@ Handle<Code> StubCache::ComputeMonomorphicIC(
} }
#endif #endif
PropertyICCompiler ic_compiler(isolate(), kind, extra_ic_state, flag); PropertyICCompiler ic_compiler(isolate, kind, extra_ic_state, flag);
ic = ic_compiler.CompileMonomorphic(type, handler, name, PROPERTY); ic = ic_compiler.CompileMonomorphic(type, handler, name, PROPERTY);
if (can_be_cached) Map::UpdateCodeCache(stub_holder, name, ic); if (can_be_cached) Map::UpdateCodeCache(stub_holder, name, ic);
...@@ -163,9 +161,10 @@ Handle<Code> StubCache::ComputeMonomorphicIC( ...@@ -163,9 +161,10 @@ Handle<Code> StubCache::ComputeMonomorphicIC(
} }
Handle<Code> StubCache::ComputeLoadNonexistent(Handle<Name> name, Handle<Code> NamedLoadHandlerCompiler::ComputeLoadNonexistent(
Handle<HeapType> type) { Handle<Name> name, Handle<HeapType> type) {
Handle<Map> receiver_map = IC::TypeToMap(*type, isolate()); Isolate* isolate = name->GetIsolate();
Handle<Map> receiver_map = IC::TypeToMap(*type, isolate);
if (receiver_map->prototype()->IsNull()) { if (receiver_map->prototype()->IsNull()) {
// TODO(jkummerow/verwaest): If there is no prototype and the property // TODO(jkummerow/verwaest): If there is no prototype and the property
// is nonexistent, introduce a builtin to handle this (fast properties // is nonexistent, introduce a builtin to handle this (fast properties
...@@ -174,7 +173,7 @@ Handle<Code> StubCache::ComputeLoadNonexistent(Handle<Name> name, ...@@ -174,7 +173,7 @@ Handle<Code> StubCache::ComputeLoadNonexistent(Handle<Name> name,
} }
CacheHolderFlag flag; CacheHolderFlag flag;
Handle<Map> stub_holder_map = Handle<Map> stub_holder_map =
IC::GetHandlerCacheHolder(*type, false, isolate(), &flag); IC::GetHandlerCacheHolder(*type, false, isolate, &flag);
// If no dictionary mode objects are present in the prototype chain, the load // If no dictionary mode objects are present in the prototype chain, the load
// nonexistent IC stub can be shared for all names for a given map and we use // nonexistent IC stub can be shared for all names for a given map and we use
...@@ -184,7 +183,7 @@ Handle<Code> StubCache::ComputeLoadNonexistent(Handle<Name> name, ...@@ -184,7 +183,7 @@ Handle<Code> StubCache::ComputeLoadNonexistent(Handle<Name> name,
Handle<Name> cache_name = Handle<Name> cache_name =
receiver_map->is_dictionary_map() receiver_map->is_dictionary_map()
? name ? name
: Handle<Name>::cast(isolate()->factory()->nonexistent_symbol()); : Handle<Name>::cast(isolate->factory()->nonexistent_symbol());
Handle<Map> current_map = stub_holder_map; Handle<Map> current_map = stub_holder_map;
Handle<JSObject> last(JSObject::cast(receiver_map->prototype())); Handle<JSObject> last(JSObject::cast(receiver_map->prototype()));
while (true) { while (true) {
...@@ -199,19 +198,20 @@ Handle<Code> StubCache::ComputeLoadNonexistent(Handle<Name> name, ...@@ -199,19 +198,20 @@ Handle<Code> StubCache::ComputeLoadNonexistent(Handle<Name> name,
cache_name, stub_holder_map, Code::LOAD_IC, flag, Code::FAST); cache_name, stub_holder_map, Code::LOAD_IC, flag, Code::FAST);
if (!handler.is_null()) return handler; if (!handler.is_null()) return handler;
NamedLoadHandlerCompiler compiler(isolate_, flag); NamedLoadHandlerCompiler compiler(isolate, flag);
handler = compiler.CompileLoadNonexistent(type, last, cache_name); handler = compiler.CompileLoadNonexistent(type, last, cache_name);
Map::UpdateCodeCache(stub_holder_map, cache_name, handler); Map::UpdateCodeCache(stub_holder_map, cache_name, handler);
return handler; return handler;
} }
Handle<Code> StubCache::ComputeKeyedLoadElement(Handle<Map> receiver_map) { Handle<Code> PropertyICCompiler::ComputeKeyedLoadElement(
Handle<Map> receiver_map) {
Isolate* isolate = receiver_map->GetIsolate();
Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC); Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC);
Handle<Name> name = Handle<Name> name = isolate->factory()->KeyedLoadElementMonomorphic_string();
isolate()->factory()->KeyedLoadElementMonomorphic_string();
Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate_); Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate);
if (probe->IsCode()) return Handle<Code>::cast(probe); if (probe->IsCode()) return Handle<Code>::cast(probe);
ElementsKind elements_kind = receiver_map->elements_kind(); ElementsKind elements_kind = receiver_map->elements_kind();
...@@ -220,27 +220,27 @@ Handle<Code> StubCache::ComputeKeyedLoadElement(Handle<Map> receiver_map) { ...@@ -220,27 +220,27 @@ Handle<Code> StubCache::ComputeKeyedLoadElement(Handle<Map> receiver_map) {
receiver_map->has_external_array_elements() || receiver_map->has_external_array_elements() ||
receiver_map->has_fixed_typed_array_elements()) { receiver_map->has_fixed_typed_array_elements()) {
stub = KeyedLoadFastElementStub( stub = KeyedLoadFastElementStub(
isolate(), receiver_map->instance_type() == JS_ARRAY_TYPE, isolate, receiver_map->instance_type() == JS_ARRAY_TYPE,
elements_kind).GetCode(); elements_kind).GetCode();
} else { } else {
stub = FLAG_compiled_keyed_dictionary_loads stub = FLAG_compiled_keyed_dictionary_loads
? KeyedLoadDictionaryElementStub(isolate()).GetCode() ? KeyedLoadDictionaryElementStub(isolate).GetCode()
: KeyedLoadDictionaryElementPlatformStub(isolate()).GetCode(); : KeyedLoadDictionaryElementPlatformStub(isolate).GetCode();
} }
PropertyICCompiler compiler(isolate(), Code::KEYED_LOAD_IC); PropertyICCompiler compiler(isolate, Code::KEYED_LOAD_IC);
Handle<Code> code = Handle<Code> code =
compiler.CompileMonomorphic(HeapType::Class(receiver_map, isolate()), compiler.CompileMonomorphic(HeapType::Class(receiver_map, isolate), stub,
stub, factory()->empty_string(), ELEMENT); isolate->factory()->empty_string(), ELEMENT);
Map::UpdateCodeCache(receiver_map, name, code); Map::UpdateCodeCache(receiver_map, name, code);
return code; return code;
} }
Handle<Code> StubCache::ComputeKeyedStoreElement( Handle<Code> PropertyICCompiler::ComputeKeyedStoreElement(
Handle<Map> receiver_map, Handle<Map> receiver_map, StrictMode strict_mode,
StrictMode strict_mode,
KeyedAccessStoreMode store_mode) { KeyedAccessStoreMode store_mode) {
Isolate* isolate = receiver_map->GetIsolate();
ExtraICState extra_state = ExtraICState extra_state =
KeyedStoreIC::ComputeExtraICState(strict_mode, store_mode); KeyedStoreIC::ComputeExtraICState(strict_mode, store_mode);
Code::Flags flags = Code::Flags flags =
...@@ -252,11 +252,11 @@ Handle<Code> StubCache::ComputeKeyedStoreElement( ...@@ -252,11 +252,11 @@ Handle<Code> StubCache::ComputeKeyedStoreElement(
store_mode == STORE_NO_TRANSITION_HANDLE_COW); store_mode == STORE_NO_TRANSITION_HANDLE_COW);
Handle<String> name = Handle<String> name =
isolate()->factory()->KeyedStoreElementMonomorphic_string(); isolate->factory()->KeyedStoreElementMonomorphic_string();
Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate_); Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate);
if (probe->IsCode()) return Handle<Code>::cast(probe); if (probe->IsCode()) return Handle<Code>::cast(probe);
PropertyICCompiler compiler(isolate(), Code::KEYED_STORE_IC, extra_state); PropertyICCompiler compiler(isolate, Code::KEYED_STORE_IC, extra_state);
Handle<Code> code = Handle<Code> code =
compiler.CompileIndexedStoreMonomorphic(receiver_map, store_mode); compiler.CompileIndexedStoreMonomorphic(receiver_map, store_mode);
...@@ -278,11 +278,13 @@ static void FillCache(Isolate* isolate, Handle<Code> code) { ...@@ -278,11 +278,13 @@ static void FillCache(Isolate* isolate, Handle<Code> code) {
} }
Code* StubCache::FindPreMonomorphicIC(Code::Kind kind, ExtraICState state) { Code* PropertyICCompiler::FindPreMonomorphicIC(Isolate* isolate,
Code::Kind kind,
ExtraICState state) {
Code::Flags flags = Code::ComputeFlags(kind, PREMONOMORPHIC, state); Code::Flags flags = Code::ComputeFlags(kind, PREMONOMORPHIC, state);
UnseededNumberDictionary* dictionary = UnseededNumberDictionary* dictionary =
isolate()->heap()->non_monomorphic_cache(); isolate->heap()->non_monomorphic_cache();
int entry = dictionary->FindEntry(isolate(), flags); int entry = dictionary->FindEntry(isolate, flags);
ASSERT(entry != -1); ASSERT(entry != -1);
Object* code = dictionary->ValueAt(entry); Object* code = dictionary->ValueAt(entry);
// This might be called during the marking phase of the collector // This might be called during the marking phase of the collector
...@@ -291,15 +293,16 @@ Code* StubCache::FindPreMonomorphicIC(Code::Kind kind, ExtraICState state) { ...@@ -291,15 +293,16 @@ Code* StubCache::FindPreMonomorphicIC(Code::Kind kind, ExtraICState state) {
} }
Handle<Code> StubCache::ComputeLoad(InlineCacheState ic_state, Handle<Code> PropertyICCompiler::ComputeLoad(Isolate* isolate,
ExtraICState extra_state) { InlineCacheState ic_state,
ExtraICState extra_state) {
Code::Flags flags = Code::ComputeFlags(Code::LOAD_IC, ic_state, extra_state); Code::Flags flags = Code::ComputeFlags(Code::LOAD_IC, ic_state, extra_state);
Handle<UnseededNumberDictionary> cache = Handle<UnseededNumberDictionary> cache =
isolate_->factory()->non_monomorphic_cache(); isolate->factory()->non_monomorphic_cache();
int entry = cache->FindEntry(isolate_, flags); int entry = cache->FindEntry(isolate, flags);
if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry)));
PropertyICCompiler compiler(isolate_, Code::LOAD_IC); PropertyICCompiler compiler(isolate, Code::LOAD_IC);
Handle<Code> code; Handle<Code> code;
if (ic_state == UNINITIALIZED) { if (ic_state == UNINITIALIZED) {
code = compiler.CompileLoadInitialize(flags); code = compiler.CompileLoadInitialize(flags);
...@@ -310,20 +313,21 @@ Handle<Code> StubCache::ComputeLoad(InlineCacheState ic_state, ...@@ -310,20 +313,21 @@ Handle<Code> StubCache::ComputeLoad(InlineCacheState ic_state,
} else { } else {
UNREACHABLE(); UNREACHABLE();
} }
FillCache(isolate_, code); FillCache(isolate, code);
return code; return code;
} }
Handle<Code> StubCache::ComputeStore(InlineCacheState ic_state, Handle<Code> PropertyICCompiler::ComputeStore(Isolate* isolate,
ExtraICState extra_state) { InlineCacheState ic_state,
ExtraICState extra_state) {
Code::Flags flags = Code::ComputeFlags(Code::STORE_IC, ic_state, extra_state); Code::Flags flags = Code::ComputeFlags(Code::STORE_IC, ic_state, extra_state);
Handle<UnseededNumberDictionary> cache = Handle<UnseededNumberDictionary> cache =
isolate_->factory()->non_monomorphic_cache(); isolate->factory()->non_monomorphic_cache();
int entry = cache->FindEntry(isolate_, flags); int entry = cache->FindEntry(isolate, flags);
if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry)));
PropertyICCompiler compiler(isolate_, Code::STORE_IC); PropertyICCompiler compiler(isolate, Code::STORE_IC);
Handle<Code> code; Handle<Code> code;
if (ic_state == UNINITIALIZED) { if (ic_state == UNINITIALIZED) {
code = compiler.CompileStoreInitialize(flags); code = compiler.CompileStoreInitialize(flags);
...@@ -337,22 +341,23 @@ Handle<Code> StubCache::ComputeStore(InlineCacheState ic_state, ...@@ -337,22 +341,23 @@ Handle<Code> StubCache::ComputeStore(InlineCacheState ic_state,
UNREACHABLE(); UNREACHABLE();
} }
FillCache(isolate_, code); FillCache(isolate, code);
return code; return code;
} }
Handle<Code> StubCache::ComputeCompareNil(Handle<Map> receiver_map, Handle<Code> PropertyICCompiler::ComputeCompareNil(Handle<Map> receiver_map,
CompareNilICStub* stub) { CompareNilICStub* stub) {
Handle<String> name(isolate_->heap()->empty_string()); Isolate* isolate = receiver_map->GetIsolate();
Handle<String> name(isolate->heap()->empty_string());
if (!receiver_map->is_shared()) { if (!receiver_map->is_shared()) {
Handle<Code> cached_ic = PropertyICCompiler::Find( Handle<Code> cached_ic =
name, receiver_map, Code::COMPARE_NIL_IC, stub->GetExtraICState()); Find(name, receiver_map, Code::COMPARE_NIL_IC, stub->GetExtraICState());
if (!cached_ic.is_null()) return cached_ic; if (!cached_ic.is_null()) return cached_ic;
} }
Code::FindAndReplacePattern pattern; Code::FindAndReplacePattern pattern;
pattern.Add(isolate_->factory()->meta_map(), receiver_map); pattern.Add(isolate->factory()->meta_map(), receiver_map);
Handle<Code> ic = stub->GetCodeCopy(pattern); Handle<Code> ic = stub->GetCodeCopy(pattern);
if (!receiver_map->is_shared()) { if (!receiver_map->is_shared()) {
...@@ -364,58 +369,55 @@ Handle<Code> StubCache::ComputeCompareNil(Handle<Map> receiver_map, ...@@ -364,58 +369,55 @@ Handle<Code> StubCache::ComputeCompareNil(Handle<Map> receiver_map,
// TODO(verwaest): Change this method so it takes in a TypeHandleList. // TODO(verwaest): Change this method so it takes in a TypeHandleList.
Handle<Code> StubCache::ComputeLoadElementPolymorphic( Handle<Code> PropertyICCompiler::ComputeLoadElementPolymorphic(
MapHandleList* receiver_maps) { MapHandleList* receiver_maps) {
Isolate* isolate = receiver_maps->at(0)->GetIsolate();
Code::Flags flags = Code::ComputeFlags(Code::KEYED_LOAD_IC, POLYMORPHIC); Code::Flags flags = Code::ComputeFlags(Code::KEYED_LOAD_IC, POLYMORPHIC);
Handle<PolymorphicCodeCache> cache = Handle<PolymorphicCodeCache> cache =
isolate_->factory()->polymorphic_code_cache(); isolate->factory()->polymorphic_code_cache();
Handle<Object> probe = cache->Lookup(receiver_maps, flags); Handle<Object> probe = cache->Lookup(receiver_maps, flags);
if (probe->IsCode()) return Handle<Code>::cast(probe); if (probe->IsCode()) return Handle<Code>::cast(probe);
TypeHandleList types(receiver_maps->length()); TypeHandleList types(receiver_maps->length());
for (int i = 0; i < receiver_maps->length(); i++) { for (int i = 0; i < receiver_maps->length(); i++) {
types.Add(HeapType::Class(receiver_maps->at(i), isolate())); types.Add(HeapType::Class(receiver_maps->at(i), isolate));
} }
CodeHandleList handlers(receiver_maps->length()); CodeHandleList handlers(receiver_maps->length());
IndexedHandlerCompiler compiler(isolate_); IndexedHandlerCompiler compiler(isolate);
compiler.CompileElementHandlers(receiver_maps, &handlers); compiler.CompileElementHandlers(receiver_maps, &handlers);
PropertyICCompiler ic_compiler(isolate_, Code::KEYED_LOAD_IC); PropertyICCompiler ic_compiler(isolate, Code::KEYED_LOAD_IC);
Handle<Code> code = ic_compiler.CompilePolymorphic( Handle<Code> code = ic_compiler.CompilePolymorphic(
&types, &handlers, factory()->empty_string(), Code::NORMAL, ELEMENT); &types, &handlers, isolate->factory()->empty_string(), Code::NORMAL,
ELEMENT);
isolate()->counters()->keyed_load_polymorphic_stubs()->Increment(); isolate->counters()->keyed_load_polymorphic_stubs()->Increment();
PolymorphicCodeCache::Update(cache, receiver_maps, flags, code); PolymorphicCodeCache::Update(cache, receiver_maps, flags, code);
return code; return code;
} }
Handle<Code> StubCache::ComputePolymorphicIC( Handle<Code> PropertyICCompiler::ComputePolymorphicIC(
Code::Kind kind, Code::Kind kind, TypeHandleList* types, CodeHandleList* handlers,
TypeHandleList* types, int valid_types, Handle<Name> name, ExtraICState extra_ic_state) {
CodeHandleList* handlers,
int number_of_valid_types,
Handle<Name> name,
ExtraICState extra_ic_state) {
Handle<Code> handler = handlers->at(0); Handle<Code> handler = handlers->at(0);
Code::StubType type = number_of_valid_types == 1 ? handler->type() Code::StubType type = valid_types == 1 ? handler->type() : Code::NORMAL;
: Code::NORMAL;
ASSERT(kind == Code::LOAD_IC || kind == Code::STORE_IC); ASSERT(kind == Code::LOAD_IC || kind == Code::STORE_IC);
PropertyICCompiler ic_compiler(isolate_, kind, extra_ic_state); PropertyICCompiler ic_compiler(name->GetIsolate(), kind, extra_ic_state);
return ic_compiler.CompilePolymorphic(types, handlers, name, type, PROPERTY); return ic_compiler.CompilePolymorphic(types, handlers, name, type, PROPERTY);
} }
Handle<Code> StubCache::ComputeStoreElementPolymorphic( Handle<Code> PropertyICCompiler::ComputeStoreElementPolymorphic(
MapHandleList* receiver_maps, MapHandleList* receiver_maps, KeyedAccessStoreMode store_mode,
KeyedAccessStoreMode store_mode,
StrictMode strict_mode) { StrictMode strict_mode) {
Isolate* isolate = receiver_maps->at(0)->GetIsolate();
ASSERT(store_mode == STANDARD_STORE || ASSERT(store_mode == STANDARD_STORE ||
store_mode == STORE_AND_GROW_NO_TRANSITION || store_mode == STORE_AND_GROW_NO_TRANSITION ||
store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS ||
store_mode == STORE_NO_TRANSITION_HANDLE_COW); store_mode == STORE_NO_TRANSITION_HANDLE_COW);
Handle<PolymorphicCodeCache> cache = Handle<PolymorphicCodeCache> cache =
isolate_->factory()->polymorphic_code_cache(); isolate->factory()->polymorphic_code_cache();
ExtraICState extra_state = KeyedStoreIC::ComputeExtraICState( ExtraICState extra_state = KeyedStoreIC::ComputeExtraICState(
strict_mode, store_mode); strict_mode, store_mode);
Code::Flags flags = Code::Flags flags =
...@@ -423,7 +425,7 @@ Handle<Code> StubCache::ComputeStoreElementPolymorphic( ...@@ -423,7 +425,7 @@ Handle<Code> StubCache::ComputeStoreElementPolymorphic(
Handle<Object> probe = cache->Lookup(receiver_maps, flags); Handle<Object> probe = cache->Lookup(receiver_maps, flags);
if (probe->IsCode()) return Handle<Code>::cast(probe); if (probe->IsCode()) return Handle<Code>::cast(probe);
PropertyICCompiler compiler(isolate_, Code::KEYED_STORE_IC, extra_state); PropertyICCompiler compiler(isolate, Code::KEYED_STORE_IC, extra_state);
Handle<Code> code = Handle<Code> code =
compiler.CompileIndexedStorePolymorphic(receiver_maps, store_mode); compiler.CompileIndexedStorePolymorphic(receiver_maps, store_mode);
PolymorphicCodeCache::Update(cache, receiver_maps, flags, code); PolymorphicCodeCache::Update(cache, receiver_maps, flags, code);
...@@ -434,12 +436,12 @@ Handle<Code> StubCache::ComputeStoreElementPolymorphic( ...@@ -434,12 +436,12 @@ Handle<Code> StubCache::ComputeStoreElementPolymorphic(
void StubCache::Clear() { void StubCache::Clear() {
Code* empty = isolate_->builtins()->builtin(Builtins::kIllegal); Code* empty = isolate_->builtins()->builtin(Builtins::kIllegal);
for (int i = 0; i < kPrimaryTableSize; i++) { for (int i = 0; i < kPrimaryTableSize; i++) {
primary_[i].key = heap()->empty_string(); primary_[i].key = isolate()->heap()->empty_string();
primary_[i].map = NULL; primary_[i].map = NULL;
primary_[i].value = empty; primary_[i].value = empty;
} }
for (int j = 0; j < kSecondaryTableSize; j++) { for (int j = 0; j < kSecondaryTableSize; j++) {
secondary_[j].key = heap()->empty_string(); secondary_[j].key = isolate()->heap()->empty_string();
secondary_[j].map = NULL; secondary_[j].map = NULL;
secondary_[j].value = empty; secondary_[j].value = empty;
} }
...@@ -525,11 +527,11 @@ RUNTIME_FUNCTION(StoreCallbackProperty) { ...@@ -525,11 +527,11 @@ RUNTIME_FUNCTION(StoreCallbackProperty) {
* provide any value for the given name. * provide any value for the given name.
*/ */
RUNTIME_FUNCTION(LoadPropertyWithInterceptorOnly) { RUNTIME_FUNCTION(LoadPropertyWithInterceptorOnly) {
ASSERT(args.length() == StubCache::kInterceptorArgsLength); ASSERT(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength);
Handle<Name> name_handle = Handle<Name> name_handle =
args.at<Name>(StubCache::kInterceptorArgsNameIndex); args.at<Name>(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex);
Handle<InterceptorInfo> interceptor_info = Handle<InterceptorInfo> interceptor_info = args.at<InterceptorInfo>(
args.at<InterceptorInfo>(StubCache::kInterceptorArgsInfoIndex); NamedLoadHandlerCompiler::kInterceptorArgsInfoIndex);
// TODO(rossberg): Support symbols in the API. // TODO(rossberg): Support symbols in the API.
if (name_handle->IsSymbol()) if (name_handle->IsSymbol())
...@@ -542,9 +544,9 @@ RUNTIME_FUNCTION(LoadPropertyWithInterceptorOnly) { ...@@ -542,9 +544,9 @@ RUNTIME_FUNCTION(LoadPropertyWithInterceptorOnly) {
ASSERT(getter != NULL); ASSERT(getter != NULL);
Handle<JSObject> receiver = Handle<JSObject> receiver =
args.at<JSObject>(StubCache::kInterceptorArgsThisIndex); args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex);
Handle<JSObject> holder = Handle<JSObject> holder =
args.at<JSObject>(StubCache::kInterceptorArgsHolderIndex); args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex);
PropertyCallbackArguments callback_args( PropertyCallbackArguments callback_args(
isolate, interceptor_info->data(), *receiver, *holder); isolate, interceptor_info->data(), *receiver, *holder);
{ {
...@@ -588,13 +590,13 @@ static Object* ThrowReferenceError(Isolate* isolate, Name* name) { ...@@ -588,13 +590,13 @@ static Object* ThrowReferenceError(Isolate* isolate, Name* name) {
*/ */
RUNTIME_FUNCTION(LoadPropertyWithInterceptor) { RUNTIME_FUNCTION(LoadPropertyWithInterceptor) {
HandleScope scope(isolate); HandleScope scope(isolate);
ASSERT(args.length() == StubCache::kInterceptorArgsLength); ASSERT(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength);
Handle<Name> name = Handle<Name> name =
args.at<Name>(StubCache::kInterceptorArgsNameIndex); args.at<Name>(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex);
Handle<JSObject> receiver = Handle<JSObject> receiver =
args.at<JSObject>(StubCache::kInterceptorArgsThisIndex); args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex);
Handle<JSObject> holder = Handle<JSObject> holder =
args.at<JSObject>(StubCache::kInterceptorArgsHolderIndex); args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex);
Handle<Object> result; Handle<Object> result;
LookupIterator it(receiver, name, holder); LookupIterator it(receiver, name, holder);
......
...@@ -17,13 +17,10 @@ namespace v8 { ...@@ -17,13 +17,10 @@ namespace v8 {
namespace internal { namespace internal {
// The stub cache is used for megamorphic calls and property accesses. // The stub cache is used for megamorphic property accesses.
// It maps (map, name, type)->Code* // It maps (map, name, type) to property access handlers. The cache does not
// need explicit invalidation when a prototype chain is modified, since the
// The design of the table uses the inline cache stubs used for // handlers verify the chain.
// mono-morphic calls. The beauty of this, we do not have to
// invalidate the cache whenever a prototype map is changed. The stub
// validates the map chain as in the mono-morphic case.
class CallOptimization; class CallOptimization;
...@@ -53,64 +50,17 @@ class StubCache { ...@@ -53,64 +50,17 @@ class StubCache {
}; };
void Initialize(); void Initialize();
// Access cache for entry hash(name, map).
Handle<Code> ComputeMonomorphicIC(Code::Kind kind,
Handle<Name> name,
Handle<HeapType> type,
Handle<Code> handler,
ExtraICState extra_ic_state);
Handle<Code> ComputeLoadNonexistent(Handle<Name> name, Handle<HeapType> type);
Handle<Code> ComputeKeyedLoadElement(Handle<Map> receiver_map);
Handle<Code> ComputeKeyedStoreElement(Handle<Map> receiver_map,
StrictMode strict_mode,
KeyedAccessStoreMode store_mode);
// ---
Handle<Code> ComputeLoad(InlineCacheState ic_state, ExtraICState extra_state);
Handle<Code> ComputeStore(InlineCacheState ic_state,
ExtraICState extra_state);
// ---
Handle<Code> ComputeCompareNil(Handle<Map> receiver_map,
CompareNilICStub* stub);
// ---
Handle<Code> ComputeLoadElementPolymorphic(MapHandleList* receiver_maps);
Handle<Code> ComputeStoreElementPolymorphic(MapHandleList* receiver_maps,
KeyedAccessStoreMode store_mode,
StrictMode strict_mode);
Handle<Code> ComputePolymorphicIC(Code::Kind kind,
TypeHandleList* types,
CodeHandleList* handlers,
int number_of_valid_maps,
Handle<Name> name,
ExtraICState extra_ic_state);
// Finds the Code object stored in the Heap::non_monomorphic_cache().
Code* FindPreMonomorphicIC(Code::Kind kind, ExtraICState extra_ic_state);
// Update cache for entry hash(name, map).
Code* Set(Name* name, Map* map, Code* code); Code* Set(Name* name, Map* map, Code* code);
Code* Get(Name* name, Map* map, Code::Flags flags); Code* Get(Name* name, Map* map, Code::Flags flags);
// Clear the lookup table (@ mark compact collection). // Clear the lookup table (@ mark compact collection).
void Clear(); void Clear();
// Collect all maps that match the name and flags. // Collect all maps that match the name and flags.
void CollectMatchingMaps(SmallMapList* types, void CollectMatchingMaps(SmallMapList* types,
Handle<Name> name, Handle<Name> name,
Code::Flags flags, Code::Flags flags,
Handle<Context> native_context, Handle<Context> native_context,
Zone* zone); Zone* zone);
// Generate code for probing the stub cache table. // Generate code for probing the stub cache table.
// Arguments extra, extra2 and extra3 may be used to pass additional scratch // Arguments extra, extra2 and extra3 may be used to pass additional scratch
// registers. Set to no_reg if not needed. // registers. Set to no_reg if not needed.
...@@ -128,25 +78,21 @@ class StubCache { ...@@ -128,25 +78,21 @@ class StubCache {
kSecondary kSecondary
}; };
SCTableReference key_reference(StubCache::Table table) { SCTableReference key_reference(StubCache::Table table) {
return SCTableReference( return SCTableReference(
reinterpret_cast<Address>(&first_entry(table)->key)); reinterpret_cast<Address>(&first_entry(table)->key));
} }
SCTableReference map_reference(StubCache::Table table) { SCTableReference map_reference(StubCache::Table table) {
return SCTableReference( return SCTableReference(
reinterpret_cast<Address>(&first_entry(table)->map)); reinterpret_cast<Address>(&first_entry(table)->map));
} }
SCTableReference value_reference(StubCache::Table table) { SCTableReference value_reference(StubCache::Table table) {
return SCTableReference( return SCTableReference(
reinterpret_cast<Address>(&first_entry(table)->value)); reinterpret_cast<Address>(&first_entry(table)->value));
} }
StubCache::Entry* first_entry(StubCache::Table table) { StubCache::Entry* first_entry(StubCache::Table table) {
switch (table) { switch (table) {
case StubCache::kPrimary: return StubCache::primary_; case StubCache::kPrimary: return StubCache::primary_;
...@@ -157,18 +103,6 @@ class StubCache { ...@@ -157,18 +103,6 @@ class StubCache {
} }
Isolate* isolate() { return isolate_; } Isolate* isolate() { return isolate_; }
Heap* heap() { return isolate()->heap(); }
Factory* factory() { return isolate()->factory(); }
// These constants describe the structure of the interceptor arguments on the
// stack. The arguments are pushed by the (platform-specific)
// PushInterceptorArguments and read by LoadPropertyWithInterceptorOnly and
// LoadWithInterceptor.
static const int kInterceptorArgsNameIndex = 0;
static const int kInterceptorArgsInfoIndex = 1;
static const int kInterceptorArgsThisIndex = 2;
static const int kInterceptorArgsHolderIndex = 3;
static const int kInterceptorArgsLength = 4;
// Setting the entry size such that the index is shifted by Name::kHashShift // Setting the entry size such that the index is shifted by Name::kHashShift
// is convenient; shifting down the length field (to extract the hash code) // is convenient; shifting down the length field (to extract the hash code)
...@@ -335,6 +269,42 @@ class PropertyAccessCompiler BASE_EMBEDDED { ...@@ -335,6 +269,42 @@ class PropertyAccessCompiler BASE_EMBEDDED {
class PropertyICCompiler : public PropertyAccessCompiler { class PropertyICCompiler : public PropertyAccessCompiler {
public: public:
// Finds the Code object stored in the Heap::non_monomorphic_cache().
static Code* FindPreMonomorphicIC(Isolate* isolate, Code::Kind kind,
ExtraICState extra_ic_state);
// Named
static Handle<Code> ComputeLoad(Isolate* isolate, InlineCacheState ic_state,
ExtraICState extra_state);
static Handle<Code> ComputeStore(Isolate* isolate, InlineCacheState ic_state,
ExtraICState extra_state);
static Handle<Code> ComputeMonomorphicIC(Code::Kind kind, Handle<Name> name,
Handle<HeapType> type,
Handle<Code> handler,
ExtraICState extra_ic_state);
static Handle<Code> ComputePolymorphicIC(
Code::Kind kind, TypeHandleList* types, CodeHandleList* handlers,
int number_of_valid_maps, Handle<Name> name, ExtraICState extra_ic_state);
// Keyed
static Handle<Code> ComputeKeyedLoadElement(Handle<Map> receiver_map);
static Handle<Code> ComputeKeyedStoreElement(Handle<Map> receiver_map,
StrictMode strict_mode,
KeyedAccessStoreMode store_mode);
static Handle<Code> ComputeLoadElementPolymorphic(
MapHandleList* receiver_maps);
static Handle<Code> ComputeStoreElementPolymorphic(
MapHandleList* receiver_maps, KeyedAccessStoreMode store_mode,
StrictMode strict_mode);
// Compare nil
static Handle<Code> ComputeCompareNil(Handle<Map> receiver_map,
CompareNilICStub* stub);
private:
PropertyICCompiler(Isolate* isolate, Code::Kind kind, PropertyICCompiler(Isolate* isolate, Code::Kind kind,
ExtraICState extra_ic_state = kNoExtraICState, ExtraICState extra_ic_state = kNoExtraICState,
CacheHolderFlag cache_holder = kCacheOnReceiver) CacheHolderFlag cache_holder = kCacheOnReceiver)
...@@ -356,7 +326,6 @@ class PropertyICCompiler : public PropertyAccessCompiler { ...@@ -356,7 +326,6 @@ class PropertyICCompiler : public PropertyAccessCompiler {
Handle<Code> CompileMonomorphic(Handle<HeapType> type, Handle<Code> handler, Handle<Code> CompileMonomorphic(Handle<HeapType> type, Handle<Code> handler,
Handle<Name> name, IcCheckType check); Handle<Name> name, IcCheckType check);
Handle<Code> CompilePolymorphic(TypeHandleList* types, Handle<Code> CompilePolymorphic(TypeHandleList* types,
CodeHandleList* handlers, Handle<Name> name, CodeHandleList* handlers, Handle<Name> name,
Code::StubType type, IcCheckType check); Code::StubType type, IcCheckType check);
...@@ -365,8 +334,10 @@ class PropertyICCompiler : public PropertyAccessCompiler { ...@@ -365,8 +334,10 @@ class PropertyICCompiler : public PropertyAccessCompiler {
KeyedAccessStoreMode store_mode); KeyedAccessStoreMode store_mode);
Handle<Code> CompileIndexedStorePolymorphic(MapHandleList* receiver_maps, Handle<Code> CompileIndexedStorePolymorphic(MapHandleList* receiver_maps,
KeyedAccessStoreMode store_mode); KeyedAccessStoreMode store_mode);
Handle<Code> CompileIndexedStorePolymorphic(MapHandleList* receiver_maps,
CodeHandleList* handler_stubs,
MapHandleList* transitioned_maps);
private:
bool IncludesNumberType(TypeHandleList* types); bool IncludesNumberType(TypeHandleList* types);
Handle<Code> GetCode(Code::Kind kind, Code::StubType type, Handle<Name> name, Handle<Code> GetCode(Code::Kind kind, Code::StubType type, Handle<Name> name,
...@@ -391,9 +362,6 @@ class PropertyICCompiler : public PropertyAccessCompiler { ...@@ -391,9 +362,6 @@ class PropertyICCompiler : public PropertyAccessCompiler {
} }
} }
Handle<Code> CompileIndexedStorePolymorphic(MapHandleList* receiver_maps,
CodeHandleList* handler_stubs,
MapHandleList* transitioned_maps);
const ExtraICState extra_ic_state_; const ExtraICState extra_ic_state_;
}; };
...@@ -514,9 +482,8 @@ class NamedLoadHandlerCompiler : public PropertyHandlerCompiler { ...@@ -514,9 +482,8 @@ class NamedLoadHandlerCompiler : public PropertyHandlerCompiler {
Handle<Name> name, Handle<Name> name,
Handle<JSFunction> getter); Handle<JSFunction> getter);
Handle<Code> CompileLoadNonexistent(Handle<HeapType> type, static Handle<Code> ComputeLoadNonexistent(Handle<Name> name,
Handle<JSObject> last, Handle<HeapType> type);
Handle<Name> name);
Handle<Code> CompileLoadGlobal(Handle<HeapType> type, Handle<Code> CompileLoadGlobal(Handle<HeapType> type,
Handle<GlobalObject> holder, Handle<GlobalObject> holder,
...@@ -539,6 +506,16 @@ class NamedLoadHandlerCompiler : public PropertyHandlerCompiler { ...@@ -539,6 +506,16 @@ class NamedLoadHandlerCompiler : public PropertyHandlerCompiler {
Register scratch2, Register scratch2,
Label* miss_label); Label* miss_label);
// These constants describe the structure of the interceptor arguments on the
// stack. The arguments are pushed by the (platform-specific)
// PushInterceptorArguments and read by LoadPropertyWithInterceptorOnly and
// LoadWithInterceptor.
static const int kInterceptorArgsNameIndex = 0;
static const int kInterceptorArgsInfoIndex = 1;
static const int kInterceptorArgsThisIndex = 2;
static const int kInterceptorArgsHolderIndex = 3;
static const int kInterceptorArgsLength = 4;
protected: protected:
virtual Register FrontendHeader(Handle<HeapType> type, Register object_reg, virtual Register FrontendHeader(Handle<HeapType> type, Register object_reg,
Handle<JSObject> holder, Handle<Name> name, Handle<JSObject> holder, Handle<Name> name,
...@@ -550,6 +527,8 @@ class NamedLoadHandlerCompiler : public PropertyHandlerCompiler { ...@@ -550,6 +527,8 @@ class NamedLoadHandlerCompiler : public PropertyHandlerCompiler {
Register CallbackFrontend(Handle<HeapType> type, Register object_reg, Register CallbackFrontend(Handle<HeapType> type, Register object_reg,
Handle<JSObject> holder, Handle<Name> name, Handle<JSObject> holder, Handle<Name> name,
Handle<Object> callback); Handle<Object> callback);
Handle<Code> CompileLoadNonexistent(Handle<HeapType> type,
Handle<JSObject> last, Handle<Name> name);
void NonexistentFrontend(Handle<HeapType> type, Handle<JSObject> last, void NonexistentFrontend(Handle<HeapType> type, Handle<JSObject> last,
Handle<Name> name); Handle<Name> name);
......
...@@ -232,11 +232,11 @@ static void PushInterceptorArguments(MacroAssembler* masm, ...@@ -232,11 +232,11 @@ static void PushInterceptorArguments(MacroAssembler* masm,
Register holder, Register holder,
Register name, Register name,
Handle<JSObject> holder_obj) { Handle<JSObject> holder_obj) {
STATIC_ASSERT(StubCache::kInterceptorArgsNameIndex == 0); STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex == 0);
STATIC_ASSERT(StubCache::kInterceptorArgsInfoIndex == 1); STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsInfoIndex == 1);
STATIC_ASSERT(StubCache::kInterceptorArgsThisIndex == 2); STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex == 2);
STATIC_ASSERT(StubCache::kInterceptorArgsHolderIndex == 3); STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex == 3);
STATIC_ASSERT(StubCache::kInterceptorArgsLength == 4); STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsLength == 4);
__ Push(name); __ Push(name);
Handle<InterceptorInfo> interceptor(holder_obj->GetNamedInterceptor()); Handle<InterceptorInfo> interceptor(holder_obj->GetNamedInterceptor());
ASSERT(!masm->isolate()->heap()->InNewSpace(*interceptor)); ASSERT(!masm->isolate()->heap()->InNewSpace(*interceptor));
...@@ -255,9 +255,8 @@ static void CompileCallLoadPropertyWithInterceptor( ...@@ -255,9 +255,8 @@ static void CompileCallLoadPropertyWithInterceptor(
Handle<JSObject> holder_obj, Handle<JSObject> holder_obj,
IC::UtilityId id) { IC::UtilityId id) {
PushInterceptorArguments(masm, receiver, holder, name, holder_obj); PushInterceptorArguments(masm, receiver, holder, name, holder_obj);
__ CallExternalReference( __ CallExternalReference(ExternalReference(IC_Utility(id), masm->isolate()),
ExternalReference(IC_Utility(id), masm->isolate()), NamedLoadHandlerCompiler::kInterceptorArgsLength);
StubCache::kInterceptorArgsLength);
} }
...@@ -959,7 +958,8 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor( ...@@ -959,7 +958,8 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(
ExternalReference ref = ExternalReference( ExternalReference ref = ExternalReference(
IC_Utility(IC::kLoadPropertyWithInterceptor), isolate()); IC_Utility(IC::kLoadPropertyWithInterceptor), isolate());
__ TailCallExternalReference(ref, StubCache::kInterceptorArgsLength, 1); __ TailCallExternalReference(
ref, NamedLoadHandlerCompiler::kInterceptorArgsLength, 1);
} }
} }
......
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