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
This commit is contained in:
verwaest@chromium.org 2014-07-29 16:04:07 +00:00
parent 57c315d0b3
commit 0a099371a3
7 changed files with 215 additions and 232 deletions

View File

@ -619,11 +619,11 @@ static void PushInterceptorArguments(MacroAssembler* masm,
Register holder,
Register name,
Handle<JSObject> holder_obj) {
STATIC_ASSERT(StubCache::kInterceptorArgsNameIndex == 0);
STATIC_ASSERT(StubCache::kInterceptorArgsInfoIndex == 1);
STATIC_ASSERT(StubCache::kInterceptorArgsThisIndex == 2);
STATIC_ASSERT(StubCache::kInterceptorArgsHolderIndex == 3);
STATIC_ASSERT(StubCache::kInterceptorArgsLength == 4);
STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex == 0);
STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsInfoIndex == 1);
STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex == 2);
STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex == 3);
STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsLength == 4);
__ push(name);
Handle<InterceptorInfo> interceptor(holder_obj->GetNamedInterceptor());
ASSERT(!masm->isolate()->heap()->InNewSpace(*interceptor));
@ -643,9 +643,8 @@ static void CompileCallLoadPropertyWithInterceptor(
Handle<JSObject> holder_obj,
IC::UtilityId id) {
PushInterceptorArguments(masm, receiver, holder, name, holder_obj);
__ CallExternalReference(
ExternalReference(IC_Utility(id), masm->isolate()),
StubCache::kInterceptorArgsLength);
__ CallExternalReference(ExternalReference(IC_Utility(id), masm->isolate()),
NamedLoadHandlerCompiler::kInterceptorArgsLength);
}
@ -1053,7 +1052,8 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(
ExternalReference ref =
ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptor),
isolate());
__ TailCallExternalReference(ref, StubCache::kInterceptorArgsLength, 1);
__ TailCallExternalReference(
ref, NamedLoadHandlerCompiler::kInterceptorArgsLength, 1);
}
}

View File

@ -567,11 +567,11 @@ static void PushInterceptorArguments(MacroAssembler* masm,
Register holder,
Register name,
Handle<JSObject> holder_obj) {
STATIC_ASSERT(StubCache::kInterceptorArgsNameIndex == 0);
STATIC_ASSERT(StubCache::kInterceptorArgsInfoIndex == 1);
STATIC_ASSERT(StubCache::kInterceptorArgsThisIndex == 2);
STATIC_ASSERT(StubCache::kInterceptorArgsHolderIndex == 3);
STATIC_ASSERT(StubCache::kInterceptorArgsLength == 4);
STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex == 0);
STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsInfoIndex == 1);
STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex == 2);
STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex == 3);
STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsLength == 4);
__ Push(name);
Handle<InterceptorInfo> interceptor(holder_obj->GetNamedInterceptor());
@ -591,9 +591,8 @@ static void CompileCallLoadPropertyWithInterceptor(
IC::UtilityId id) {
PushInterceptorArguments(masm, receiver, holder, name, holder_obj);
__ CallExternalReference(
ExternalReference(IC_Utility(id), masm->isolate()),
StubCache::kInterceptorArgsLength);
__ CallExternalReference(ExternalReference(IC_Utility(id), masm->isolate()),
NamedLoadHandlerCompiler::kInterceptorArgsLength);
}
@ -1015,7 +1014,8 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(
ExternalReference ref =
ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptor),
isolate());
__ TailCallExternalReference(ref, StubCache::kInterceptorArgsLength, 1);
__ TailCallExternalReference(
ref, NamedLoadHandlerCompiler::kInterceptorArgsLength, 1);
}
}

View File

@ -264,11 +264,11 @@ static void PushInterceptorArguments(MacroAssembler* masm,
Register holder,
Register name,
Handle<JSObject> holder_obj) {
STATIC_ASSERT(StubCache::kInterceptorArgsNameIndex == 0);
STATIC_ASSERT(StubCache::kInterceptorArgsInfoIndex == 1);
STATIC_ASSERT(StubCache::kInterceptorArgsThisIndex == 2);
STATIC_ASSERT(StubCache::kInterceptorArgsHolderIndex == 3);
STATIC_ASSERT(StubCache::kInterceptorArgsLength == 4);
STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex == 0);
STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsInfoIndex == 1);
STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex == 2);
STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex == 3);
STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsLength == 4);
__ push(name);
Handle<InterceptorInfo> interceptor(holder_obj->GetNamedInterceptor());
ASSERT(!masm->isolate()->heap()->InNewSpace(*interceptor));
@ -288,9 +288,8 @@ static void CompileCallLoadPropertyWithInterceptor(
Handle<JSObject> holder_obj,
IC::UtilityId id) {
PushInterceptorArguments(masm, receiver, holder, name, holder_obj);
__ CallExternalReference(
ExternalReference(IC_Utility(id), masm->isolate()),
StubCache::kInterceptorArgsLength);
__ CallExternalReference(ExternalReference(IC_Utility(id), masm->isolate()),
NamedLoadHandlerCompiler::kInterceptorArgsLength);
}
@ -1036,7 +1035,8 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(
ExternalReference ref =
ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptor),
isolate());
__ TailCallExternalReference(ref, StubCache::kInterceptorArgsLength, 1);
__ TailCallExternalReference(
ref, NamedLoadHandlerCompiler::kInterceptorArgsLength, 1);
}
}

View File

@ -482,8 +482,8 @@ void LoadIC::Clear(Isolate* isolate,
Code* target,
ConstantPoolArray* constant_pool) {
if (IsCleared(target)) return;
Code* code = target->GetIsolate()->stub_cache()->FindPreMonomorphicIC(
Code::LOAD_IC, target->extra_ic_state());
Code* code = PropertyICCompiler::FindPreMonomorphicIC(
isolate, Code::LOAD_IC, target->extra_ic_state());
SetTargetAtAddress(address, code, constant_pool);
}
@ -493,8 +493,8 @@ void StoreIC::Clear(Isolate* isolate,
Code* target,
ConstantPoolArray* constant_pool) {
if (IsCleared(target)) return;
Code* code = target->GetIsolate()->stub_cache()->FindPreMonomorphicIC(
Code::STORE_IC, target->extra_ic_state());
Code* code = PropertyICCompiler::FindPreMonomorphicIC(
isolate, Code::STORE_IC, target->extra_ic_state());
SetTargetAtAddress(address, code, constant_pool);
}
@ -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;
Handle<Code> ic;
if (number_of_valid_types == 1) {
ic = isolate()->stub_cache()->ComputeMonomorphicIC(kind(), name, type, code,
extra_ic_state());
ic = PropertyICCompiler::ComputeMonomorphicIC(kind(), name, type, code,
extra_ic_state());
} else {
if (handler_to_overwrite >= 0) {
handlers.Set(handler_to_overwrite, code);
@ -672,9 +672,9 @@ bool IC::UpdatePolymorphicIC(Handle<String> name, Handle<Code> code) {
types.Add(type);
handlers.Add(code);
}
ic = isolate()->stub_cache()->ComputePolymorphicIC(
kind(), &types, &handlers, number_of_valid_types, name,
extra_ic_state());
ic = PropertyICCompiler::ComputePolymorphicIC(kind(), &types, &handlers,
number_of_valid_types, name,
extra_ic_state());
}
set_target(*ic);
return true;
@ -725,7 +725,7 @@ Handle<HeapType> IC::MapToType<HeapType>(Handle<Map> map, Isolate* region);
void IC::UpdateMonomorphicIC(Handle<Code> handler, Handle<String> name) {
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());
set_target(*ic);
}
@ -786,13 +786,14 @@ void IC::PatchCache(Handle<String> name, Handle<Code> code) {
Handle<Code> LoadIC::initialize_stub(Isolate* isolate,
ExtraICState extra_state) {
return isolate->stub_cache()->ComputeLoad(UNINITIALIZED, extra_state);
return PropertyICCompiler::ComputeLoad(isolate, UNINITIALIZED, extra_state);
}
Handle<Code> LoadIC::megamorphic_stub() {
if (kind() == Code::LOAD_IC) {
return isolate()->stub_cache()->ComputeLoad(MEGAMORPHIC, extra_ic_state());
return PropertyICCompiler::ComputeLoad(isolate(), MEGAMORPHIC,
extra_ic_state());
} else {
ASSERT_EQ(Code::KEYED_LOAD_IC, kind());
return KeyedLoadIC::generic_stub(isolate());
@ -802,7 +803,7 @@ Handle<Code> LoadIC::megamorphic_stub() {
Handle<Code> LoadIC::pre_monomorphic_stub(Isolate* isolate,
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,
code = slow_stub();
} else if (!lookup->IsProperty()) {
if (kind() == Code::LOAD_IC) {
code = isolate()->stub_cache()->ComputeLoadNonexistent(name,
receiver_type());
code = NamedLoadHandlerCompiler::ComputeLoadNonexistent(name,
receiver_type());
// TODO(jkummerow/verwaest): Introduce a builtin that handles this case.
if (code.is_null()) code = slow_stub();
} else {
@ -1072,7 +1073,7 @@ Handle<Code> KeyedLoadIC::LoadElementStub(Handle<JSObject> receiver) {
TargetMaps(&target_receiver_maps);
}
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
@ -1086,7 +1087,7 @@ Handle<Code> KeyedLoadIC::LoadElementStub(Handle<JSObject> receiver) {
IsMoreGeneralElementsKindTransition(
target_receiver_maps.at(0)->elements_kind(),
receiver->GetElementsKind())) {
return isolate()->stub_cache()->ComputeKeyedLoadElement(receiver_map);
return PropertyICCompiler::ComputeKeyedLoadElement(receiver_map);
}
ASSERT(state() != GENERIC);
@ -1107,7 +1108,7 @@ Handle<Code> KeyedLoadIC::LoadElementStub(Handle<JSObject> receiver) {
return generic_stub();
}
return isolate()->stub_cache()->ComputeLoadElementPolymorphic(
return PropertyICCompiler::ComputeLoadElementPolymorphic(
&target_receiver_maps);
}
@ -1341,26 +1342,27 @@ Handle<Code> CallIC::initialize_stub(Isolate* isolate,
Handle<Code> StoreIC::initialize_stub(Isolate* isolate,
StrictMode strict_mode) {
ExtraICState extra_state = ComputeExtraICState(strict_mode);
Handle<Code> ic = isolate->stub_cache()->ComputeStore(
UNINITIALIZED, extra_state);
Handle<Code> ic =
PropertyICCompiler::ComputeStore(isolate, UNINITIALIZED, extra_state);
return ic;
}
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 {
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,
StrictMode 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,
Handle<Map> monomorphic_map =
ComputeTransitionedMap(receiver_map, store_mode);
store_mode = GetNonTransitioningStoreMode(store_mode);
return isolate()->stub_cache()->ComputeKeyedStoreElement(
return PropertyICCompiler::ComputeKeyedStoreElement(
monomorphic_map, strict_mode(), store_mode);
}
@ -1517,7 +1519,7 @@ Handle<Code> KeyedStoreIC::StoreElementStub(Handle<JSObject> receiver,
// if they at least come from the same origin for a transitioning store,
// stay MONOMORPHIC and use the map for the most generic ElementsKind.
store_mode = GetNonTransitioningStoreMode(store_mode);
return isolate()->stub_cache()->ComputeKeyedStoreElement(
return PropertyICCompiler::ComputeKeyedStoreElement(
transitioned_receiver_map, strict_mode(), store_mode);
} else if (*previous_receiver_map == receiver->map() &&
old_store_mode == STANDARD_STORE &&
@ -1527,7 +1529,7 @@ Handle<Code> KeyedStoreIC::StoreElementStub(Handle<JSObject> receiver,
// 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
// and still stay MONOMORPHIC.
return isolate()->stub_cache()->ComputeKeyedStoreElement(
return PropertyICCompiler::ComputeKeyedStoreElement(
receiver_map, strict_mode(), store_mode);
}
}
@ -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());
}
@ -2955,7 +2957,7 @@ Handle<Object> CompareNilIC::CompareNil(Handle<Object> object) {
Handle<Map> monomorphic_map(already_monomorphic && FirstTargetMap() != NULL
? FirstTargetMap()
: HeapObject::cast(*object)->map());
code = isolate()->stub_cache()->ComputeCompareNil(monomorphic_map, &stub);
code = PropertyICCompiler::ComputeCompareNil(monomorphic_map, &stub);
} else {
code = stub.GetCode();
}

View File

@ -57,7 +57,8 @@ static Code::Flags CommonStubCacheChecks(Name* name, Map* map,
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.
int primary_offset = PrimaryOffset(name, flags, map);
@ -86,7 +87,7 @@ Code* StubCache::Set(Name* name, Map* map, Code* code) {
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);
Entry* primary = entry(primary_, primary_offset);
if (primary->key == name && primary->map == map) {
@ -128,14 +129,12 @@ Handle<Code> PropertyHandlerCompiler::Find(Handle<Name> name,
}
Handle<Code> StubCache::ComputeMonomorphicIC(
Code::Kind kind,
Handle<Name> name,
Handle<HeapType> type,
Handle<Code> handler,
ExtraICState extra_ic_state) {
Handle<Code> PropertyICCompiler::ComputeMonomorphicIC(
Code::Kind kind, Handle<Name> name, Handle<HeapType> type,
Handle<Code> handler, ExtraICState extra_ic_state) {
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;
// There are multiple string maps that all use the same prototype. That
@ -143,8 +142,7 @@ Handle<Code> StubCache::ComputeMonomorphicIC(
// for a single name. Hence, turn off caching of the IC.
bool can_be_cached = !type->Is(HeapType::String());
if (can_be_cached) {
ic =
PropertyICCompiler::Find(name, stub_holder, kind, extra_ic_state, flag);
ic = Find(name, stub_holder, kind, extra_ic_state, flag);
if (!ic.is_null()) return ic;
}
@ -155,7 +153,7 @@ Handle<Code> StubCache::ComputeMonomorphicIC(
}
#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);
if (can_be_cached) Map::UpdateCodeCache(stub_holder, name, ic);
@ -163,9 +161,10 @@ Handle<Code> StubCache::ComputeMonomorphicIC(
}
Handle<Code> StubCache::ComputeLoadNonexistent(Handle<Name> name,
Handle<HeapType> type) {
Handle<Map> receiver_map = IC::TypeToMap(*type, isolate());
Handle<Code> NamedLoadHandlerCompiler::ComputeLoadNonexistent(
Handle<Name> name, Handle<HeapType> type) {
Isolate* isolate = name->GetIsolate();
Handle<Map> receiver_map = IC::TypeToMap(*type, isolate);
if (receiver_map->prototype()->IsNull()) {
// TODO(jkummerow/verwaest): If there is no prototype and the property
// is nonexistent, introduce a builtin to handle this (fast properties
@ -174,7 +173,7 @@ Handle<Code> StubCache::ComputeLoadNonexistent(Handle<Name> name,
}
CacheHolderFlag flag;
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
// 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,
Handle<Name> cache_name =
receiver_map->is_dictionary_map()
? name
: Handle<Name>::cast(isolate()->factory()->nonexistent_symbol());
: Handle<Name>::cast(isolate->factory()->nonexistent_symbol());
Handle<Map> current_map = stub_holder_map;
Handle<JSObject> last(JSObject::cast(receiver_map->prototype()));
while (true) {
@ -199,19 +198,20 @@ Handle<Code> StubCache::ComputeLoadNonexistent(Handle<Name> name,
cache_name, stub_holder_map, Code::LOAD_IC, flag, Code::FAST);
if (!handler.is_null()) return handler;
NamedLoadHandlerCompiler compiler(isolate_, flag);
NamedLoadHandlerCompiler compiler(isolate, flag);
handler = compiler.CompileLoadNonexistent(type, last, cache_name);
Map::UpdateCodeCache(stub_holder_map, cache_name, 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);
Handle<Name> name =
isolate()->factory()->KeyedLoadElementMonomorphic_string();
Handle<Name> name = 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);
ElementsKind elements_kind = receiver_map->elements_kind();
@ -220,27 +220,27 @@ Handle<Code> StubCache::ComputeKeyedLoadElement(Handle<Map> receiver_map) {
receiver_map->has_external_array_elements() ||
receiver_map->has_fixed_typed_array_elements()) {
stub = KeyedLoadFastElementStub(
isolate(), receiver_map->instance_type() == JS_ARRAY_TYPE,
isolate, receiver_map->instance_type() == JS_ARRAY_TYPE,
elements_kind).GetCode();
} else {
stub = FLAG_compiled_keyed_dictionary_loads
? KeyedLoadDictionaryElementStub(isolate()).GetCode()
: KeyedLoadDictionaryElementPlatformStub(isolate()).GetCode();
? KeyedLoadDictionaryElementStub(isolate).GetCode()
: KeyedLoadDictionaryElementPlatformStub(isolate).GetCode();
}
PropertyICCompiler compiler(isolate(), Code::KEYED_LOAD_IC);
PropertyICCompiler compiler(isolate, Code::KEYED_LOAD_IC);
Handle<Code> code =
compiler.CompileMonomorphic(HeapType::Class(receiver_map, isolate()),
stub, factory()->empty_string(), ELEMENT);
compiler.CompileMonomorphic(HeapType::Class(receiver_map, isolate), stub,
isolate->factory()->empty_string(), ELEMENT);
Map::UpdateCodeCache(receiver_map, name, code);
return code;
}
Handle<Code> StubCache::ComputeKeyedStoreElement(
Handle<Map> receiver_map,
StrictMode strict_mode,
Handle<Code> PropertyICCompiler::ComputeKeyedStoreElement(
Handle<Map> receiver_map, StrictMode strict_mode,
KeyedAccessStoreMode store_mode) {
Isolate* isolate = receiver_map->GetIsolate();
ExtraICState extra_state =
KeyedStoreIC::ComputeExtraICState(strict_mode, store_mode);
Code::Flags flags =
@ -252,11 +252,11 @@ Handle<Code> StubCache::ComputeKeyedStoreElement(
store_mode == STORE_NO_TRANSITION_HANDLE_COW);
Handle<String> name =
isolate()->factory()->KeyedStoreElementMonomorphic_string();
Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate_);
isolate->factory()->KeyedStoreElementMonomorphic_string();
Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate);
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 =
compiler.CompileIndexedStoreMonomorphic(receiver_map, store_mode);
@ -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);
UnseededNumberDictionary* dictionary =
isolate()->heap()->non_monomorphic_cache();
int entry = dictionary->FindEntry(isolate(), flags);
isolate->heap()->non_monomorphic_cache();
int entry = dictionary->FindEntry(isolate, flags);
ASSERT(entry != -1);
Object* code = dictionary->ValueAt(entry);
// This might be called during the marking phase of the collector
@ -291,15 +293,16 @@ Code* StubCache::FindPreMonomorphicIC(Code::Kind kind, ExtraICState state) {
}
Handle<Code> StubCache::ComputeLoad(InlineCacheState ic_state,
ExtraICState extra_state) {
Handle<Code> PropertyICCompiler::ComputeLoad(Isolate* isolate,
InlineCacheState ic_state,
ExtraICState extra_state) {
Code::Flags flags = Code::ComputeFlags(Code::LOAD_IC, ic_state, extra_state);
Handle<UnseededNumberDictionary> cache =
isolate_->factory()->non_monomorphic_cache();
int entry = cache->FindEntry(isolate_, flags);
isolate->factory()->non_monomorphic_cache();
int entry = cache->FindEntry(isolate, flags);
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;
if (ic_state == UNINITIALIZED) {
code = compiler.CompileLoadInitialize(flags);
@ -310,20 +313,21 @@ Handle<Code> StubCache::ComputeLoad(InlineCacheState ic_state,
} else {
UNREACHABLE();
}
FillCache(isolate_, code);
FillCache(isolate, code);
return code;
}
Handle<Code> StubCache::ComputeStore(InlineCacheState ic_state,
ExtraICState extra_state) {
Handle<Code> PropertyICCompiler::ComputeStore(Isolate* isolate,
InlineCacheState ic_state,
ExtraICState extra_state) {
Code::Flags flags = Code::ComputeFlags(Code::STORE_IC, ic_state, extra_state);
Handle<UnseededNumberDictionary> cache =
isolate_->factory()->non_monomorphic_cache();
int entry = cache->FindEntry(isolate_, flags);
isolate->factory()->non_monomorphic_cache();
int entry = cache->FindEntry(isolate, flags);
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;
if (ic_state == UNINITIALIZED) {
code = compiler.CompileStoreInitialize(flags);
@ -337,22 +341,23 @@ Handle<Code> StubCache::ComputeStore(InlineCacheState ic_state,
UNREACHABLE();
}
FillCache(isolate_, code);
FillCache(isolate, code);
return code;
}
Handle<Code> StubCache::ComputeCompareNil(Handle<Map> receiver_map,
CompareNilICStub* stub) {
Handle<String> name(isolate_->heap()->empty_string());
Handle<Code> PropertyICCompiler::ComputeCompareNil(Handle<Map> receiver_map,
CompareNilICStub* stub) {
Isolate* isolate = receiver_map->GetIsolate();
Handle<String> name(isolate->heap()->empty_string());
if (!receiver_map->is_shared()) {
Handle<Code> cached_ic = PropertyICCompiler::Find(
name, receiver_map, Code::COMPARE_NIL_IC, stub->GetExtraICState());
Handle<Code> cached_ic =
Find(name, receiver_map, Code::COMPARE_NIL_IC, stub->GetExtraICState());
if (!cached_ic.is_null()) return cached_ic;
}
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);
if (!receiver_map->is_shared()) {
@ -364,58 +369,55 @@ Handle<Code> StubCache::ComputeCompareNil(Handle<Map> receiver_map,
// TODO(verwaest): Change this method so it takes in a TypeHandleList.
Handle<Code> StubCache::ComputeLoadElementPolymorphic(
Handle<Code> PropertyICCompiler::ComputeLoadElementPolymorphic(
MapHandleList* receiver_maps) {
Isolate* isolate = receiver_maps->at(0)->GetIsolate();
Code::Flags flags = Code::ComputeFlags(Code::KEYED_LOAD_IC, POLYMORPHIC);
Handle<PolymorphicCodeCache> cache =
isolate_->factory()->polymorphic_code_cache();
isolate->factory()->polymorphic_code_cache();
Handle<Object> probe = cache->Lookup(receiver_maps, flags);
if (probe->IsCode()) return Handle<Code>::cast(probe);
TypeHandleList types(receiver_maps->length());
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());
IndexedHandlerCompiler compiler(isolate_);
IndexedHandlerCompiler compiler(isolate);
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(
&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);
return code;
}
Handle<Code> StubCache::ComputePolymorphicIC(
Code::Kind kind,
TypeHandleList* types,
CodeHandleList* handlers,
int number_of_valid_types,
Handle<Name> name,
ExtraICState extra_ic_state) {
Handle<Code> PropertyICCompiler::ComputePolymorphicIC(
Code::Kind kind, TypeHandleList* types, CodeHandleList* handlers,
int valid_types, Handle<Name> name, ExtraICState extra_ic_state) {
Handle<Code> handler = handlers->at(0);
Code::StubType type = number_of_valid_types == 1 ? handler->type()
: Code::NORMAL;
Code::StubType type = valid_types == 1 ? handler->type() : Code::NORMAL;
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);
}
Handle<Code> StubCache::ComputeStoreElementPolymorphic(
MapHandleList* receiver_maps,
KeyedAccessStoreMode store_mode,
Handle<Code> PropertyICCompiler::ComputeStoreElementPolymorphic(
MapHandleList* receiver_maps, KeyedAccessStoreMode store_mode,
StrictMode strict_mode) {
Isolate* isolate = receiver_maps->at(0)->GetIsolate();
ASSERT(store_mode == STANDARD_STORE ||
store_mode == STORE_AND_GROW_NO_TRANSITION ||
store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS ||
store_mode == STORE_NO_TRANSITION_HANDLE_COW);
Handle<PolymorphicCodeCache> cache =
isolate_->factory()->polymorphic_code_cache();
isolate->factory()->polymorphic_code_cache();
ExtraICState extra_state = KeyedStoreIC::ComputeExtraICState(
strict_mode, store_mode);
Code::Flags flags =
@ -423,7 +425,7 @@ Handle<Code> StubCache::ComputeStoreElementPolymorphic(
Handle<Object> probe = cache->Lookup(receiver_maps, flags);
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 =
compiler.CompileIndexedStorePolymorphic(receiver_maps, store_mode);
PolymorphicCodeCache::Update(cache, receiver_maps, flags, code);
@ -434,12 +436,12 @@ Handle<Code> StubCache::ComputeStoreElementPolymorphic(
void StubCache::Clear() {
Code* empty = isolate_->builtins()->builtin(Builtins::kIllegal);
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].value = empty;
}
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].value = empty;
}
@ -525,11 +527,11 @@ RUNTIME_FUNCTION(StoreCallbackProperty) {
* provide any value for the given name.
*/
RUNTIME_FUNCTION(LoadPropertyWithInterceptorOnly) {
ASSERT(args.length() == StubCache::kInterceptorArgsLength);
ASSERT(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength);
Handle<Name> name_handle =
args.at<Name>(StubCache::kInterceptorArgsNameIndex);
Handle<InterceptorInfo> interceptor_info =
args.at<InterceptorInfo>(StubCache::kInterceptorArgsInfoIndex);
args.at<Name>(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex);
Handle<InterceptorInfo> interceptor_info = args.at<InterceptorInfo>(
NamedLoadHandlerCompiler::kInterceptorArgsInfoIndex);
// TODO(rossberg): Support symbols in the API.
if (name_handle->IsSymbol())
@ -542,9 +544,9 @@ RUNTIME_FUNCTION(LoadPropertyWithInterceptorOnly) {
ASSERT(getter != NULL);
Handle<JSObject> receiver =
args.at<JSObject>(StubCache::kInterceptorArgsThisIndex);
args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex);
Handle<JSObject> holder =
args.at<JSObject>(StubCache::kInterceptorArgsHolderIndex);
args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex);
PropertyCallbackArguments callback_args(
isolate, interceptor_info->data(), *receiver, *holder);
{
@ -588,13 +590,13 @@ static Object* ThrowReferenceError(Isolate* isolate, Name* name) {
*/
RUNTIME_FUNCTION(LoadPropertyWithInterceptor) {
HandleScope scope(isolate);
ASSERT(args.length() == StubCache::kInterceptorArgsLength);
ASSERT(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength);
Handle<Name> name =
args.at<Name>(StubCache::kInterceptorArgsNameIndex);
args.at<Name>(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex);
Handle<JSObject> receiver =
args.at<JSObject>(StubCache::kInterceptorArgsThisIndex);
args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex);
Handle<JSObject> holder =
args.at<JSObject>(StubCache::kInterceptorArgsHolderIndex);
args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex);
Handle<Object> result;
LookupIterator it(receiver, name, holder);

View File

@ -17,13 +17,10 @@ namespace v8 {
namespace internal {
// The stub cache is used for megamorphic calls and property accesses.
// It maps (map, name, type)->Code*
// The design of the table uses the inline cache stubs used for
// 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.
// The stub cache is used for megamorphic property accesses.
// It maps (map, name, type) to property access handlers. The cache does not
// need explicit invalidation when a prototype chain is modified, since the
// handlers verify the chain.
class CallOptimization;
@ -53,64 +50,17 @@ class StubCache {
};
void Initialize();
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).
// Access cache for entry hash(name, map).
Code* Set(Name* name, Map* map, Code* code);
Code* Get(Name* name, Map* map, Code::Flags flags);
// Clear the lookup table (@ mark compact collection).
void Clear();
// Collect all maps that match the name and flags.
void CollectMatchingMaps(SmallMapList* types,
Handle<Name> name,
Code::Flags flags,
Handle<Context> native_context,
Zone* zone);
// Generate code for probing the stub cache table.
// Arguments extra, extra2 and extra3 may be used to pass additional scratch
// registers. Set to no_reg if not needed.
@ -128,25 +78,21 @@ class StubCache {
kSecondary
};
SCTableReference key_reference(StubCache::Table table) {
return SCTableReference(
reinterpret_cast<Address>(&first_entry(table)->key));
}
SCTableReference map_reference(StubCache::Table table) {
return SCTableReference(
reinterpret_cast<Address>(&first_entry(table)->map));
}
SCTableReference value_reference(StubCache::Table table) {
return SCTableReference(
reinterpret_cast<Address>(&first_entry(table)->value));
}
StubCache::Entry* first_entry(StubCache::Table table) {
switch (table) {
case StubCache::kPrimary: return StubCache::primary_;
@ -157,18 +103,6 @@ class StubCache {
}
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
// is convenient; shifting down the length field (to extract the hash code)
@ -335,6 +269,42 @@ class PropertyAccessCompiler BASE_EMBEDDED {
class PropertyICCompiler : public PropertyAccessCompiler {
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,
ExtraICState extra_ic_state = kNoExtraICState,
CacheHolderFlag cache_holder = kCacheOnReceiver)
@ -356,7 +326,6 @@ class PropertyICCompiler : public PropertyAccessCompiler {
Handle<Code> CompileMonomorphic(Handle<HeapType> type, Handle<Code> handler,
Handle<Name> name, IcCheckType check);
Handle<Code> CompilePolymorphic(TypeHandleList* types,
CodeHandleList* handlers, Handle<Name> name,
Code::StubType type, IcCheckType check);
@ -365,8 +334,10 @@ class PropertyICCompiler : public PropertyAccessCompiler {
KeyedAccessStoreMode store_mode);
Handle<Code> CompileIndexedStorePolymorphic(MapHandleList* receiver_maps,
KeyedAccessStoreMode store_mode);
Handle<Code> CompileIndexedStorePolymorphic(MapHandleList* receiver_maps,
CodeHandleList* handler_stubs,
MapHandleList* transitioned_maps);
private:
bool IncludesNumberType(TypeHandleList* types);
Handle<Code> GetCode(Code::Kind kind, Code::StubType type, Handle<Name> name,
@ -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_;
};
@ -514,9 +482,8 @@ class NamedLoadHandlerCompiler : public PropertyHandlerCompiler {
Handle<Name> name,
Handle<JSFunction> getter);
Handle<Code> CompileLoadNonexistent(Handle<HeapType> type,
Handle<JSObject> last,
Handle<Name> name);
static Handle<Code> ComputeLoadNonexistent(Handle<Name> name,
Handle<HeapType> type);
Handle<Code> CompileLoadGlobal(Handle<HeapType> type,
Handle<GlobalObject> holder,
@ -539,6 +506,16 @@ class NamedLoadHandlerCompiler : public PropertyHandlerCompiler {
Register scratch2,
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:
virtual Register FrontendHeader(Handle<HeapType> type, Register object_reg,
Handle<JSObject> holder, Handle<Name> name,
@ -550,6 +527,8 @@ class NamedLoadHandlerCompiler : public PropertyHandlerCompiler {
Register CallbackFrontend(Handle<HeapType> type, Register object_reg,
Handle<JSObject> holder, Handle<Name> name,
Handle<Object> callback);
Handle<Code> CompileLoadNonexistent(Handle<HeapType> type,
Handle<JSObject> last, Handle<Name> name);
void NonexistentFrontend(Handle<HeapType> type, Handle<JSObject> last,
Handle<Name> name);

View File

@ -232,11 +232,11 @@ static void PushInterceptorArguments(MacroAssembler* masm,
Register holder,
Register name,
Handle<JSObject> holder_obj) {
STATIC_ASSERT(StubCache::kInterceptorArgsNameIndex == 0);
STATIC_ASSERT(StubCache::kInterceptorArgsInfoIndex == 1);
STATIC_ASSERT(StubCache::kInterceptorArgsThisIndex == 2);
STATIC_ASSERT(StubCache::kInterceptorArgsHolderIndex == 3);
STATIC_ASSERT(StubCache::kInterceptorArgsLength == 4);
STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex == 0);
STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsInfoIndex == 1);
STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex == 2);
STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex == 3);
STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsLength == 4);
__ Push(name);
Handle<InterceptorInfo> interceptor(holder_obj->GetNamedInterceptor());
ASSERT(!masm->isolate()->heap()->InNewSpace(*interceptor));
@ -255,9 +255,8 @@ static void CompileCallLoadPropertyWithInterceptor(
Handle<JSObject> holder_obj,
IC::UtilityId id) {
PushInterceptorArguments(masm, receiver, holder, name, holder_obj);
__ CallExternalReference(
ExternalReference(IC_Utility(id), masm->isolate()),
StubCache::kInterceptorArgsLength);
__ CallExternalReference(ExternalReference(IC_Utility(id), masm->isolate()),
NamedLoadHandlerCompiler::kInterceptorArgsLength);
}
@ -959,7 +958,8 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(
ExternalReference ref = ExternalReference(
IC_Utility(IC::kLoadPropertyWithInterceptor), isolate());
__ TailCallExternalReference(ref, StubCache::kInterceptorArgsLength, 1);
__ TailCallExternalReference(
ref, NamedLoadHandlerCompiler::kInterceptorArgsLength, 1);
}
}