Commit baa34fae authored by verwaest's avatar verwaest Committed by Commit bot

Speed up accessing default code caches in maps.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#35133}
parent 037f7f62
...@@ -1098,9 +1098,8 @@ Handle<Code> IC::ComputeHandler(LookupIterator* lookup, Handle<Object> value) { ...@@ -1098,9 +1098,8 @@ Handle<Code> IC::ComputeHandler(LookupIterator* lookup, Handle<Object> value) {
// TODO(mvstanton): we'd only like to cache code on the map when it's custom // TODO(mvstanton): we'd only like to cache code on the map when it's custom
// code compiled for this map, otherwise it's already cached in the global // code compiled for this map, otherwise it's already cached in the global
// code // code cache. We are also guarding against installing code with flags that
// cache. We are also guarding against installing code with flags that don't // don't match the desired CacheHolderFlag computed above, which would lead to
// match the desired CacheHolderFlag computed above, which would lead to
// invalid lookups later. // invalid lookups later.
if (code->type() != Code::NORMAL && if (code->type() != Code::NORMAL &&
Code::ExtractCacheHolderFromFlags(code->flags()) == flag) { Code::ExtractCacheHolderFromFlags(code->flags()) == flag) {
......
...@@ -10123,6 +10123,7 @@ void CodeCache::Update( ...@@ -10123,6 +10123,7 @@ void CodeCache::Update(
void CodeCache::UpdateDefaultCache( void CodeCache::UpdateDefaultCache(
Handle<CodeCache> code_cache, Handle<Name> name, Handle<Code> code) { Handle<CodeCache> code_cache, Handle<Name> name, Handle<Code> code) {
Isolate* isolate = code_cache->GetIsolate();
// When updating the default code cache we disregard the type encoded in the // When updating the default code cache we disregard the type encoded in the
// flags. This allows call constant stubs to overwrite call field // flags. This allows call constant stubs to overwrite call field
// stubs, etc. // stubs, etc.
...@@ -10135,19 +10136,23 @@ void CodeCache::UpdateDefaultCache( ...@@ -10135,19 +10136,23 @@ void CodeCache::UpdateDefaultCache(
{ {
DisallowHeapAllocation no_alloc; DisallowHeapAllocation no_alloc;
int deleted_index = -1; int deleted_index = -1;
Object* null = isolate->heap()->null_value();
Object* undefined = isolate->heap()->undefined_value();
DCHECK(name->IsUniqueName());
for (int i = 0; i < length; i += kCodeCacheEntrySize) { for (int i = 0; i < length; i += kCodeCacheEntrySize) {
Object* key = cache->get(i); Object* key = cache->get(i);
if (key->IsNull()) { if (key == null) {
if (deleted_index < 0) deleted_index = i; if (deleted_index < 0) deleted_index = i;
continue; continue;
} }
if (key->IsUndefined()) { if (key == undefined) {
if (deleted_index >= 0) i = deleted_index; if (deleted_index >= 0) i = deleted_index;
cache->set(i + kCodeCacheEntryNameOffset, *name); cache->set(i + kCodeCacheEntryNameOffset, *name);
cache->set(i + kCodeCacheEntryCodeOffset, *code); cache->set(i + kCodeCacheEntryCodeOffset, *code);
return; return;
} }
if (name->Equals(Name::cast(key))) { DCHECK(key->IsUniqueName());
if (*name == key) {
Code::Flags found = Code::Flags found =
Code::cast(cache->get(i + kCodeCacheEntryCodeOffset))->flags(); Code::cast(cache->get(i + kCodeCacheEntryCodeOffset))->flags();
if (Code::RemoveTypeFromFlags(found) == flags) { if (Code::RemoveTypeFromFlags(found) == flags) {
...@@ -10168,7 +10173,6 @@ void CodeCache::UpdateDefaultCache( ...@@ -10168,7 +10173,6 @@ void CodeCache::UpdateDefaultCache(
// Extend the code cache with some new entries (at least one). Must be a // Extend the code cache with some new entries (at least one). Must be a
// multiple of the entry size. // multiple of the entry size.
Isolate* isolate = cache->GetIsolate();
int new_length = length + (length >> 1) + kCodeCacheEntrySize; int new_length = length + (length >> 1) + kCodeCacheEntrySize;
new_length = new_length - new_length % kCodeCacheEntrySize; new_length = new_length - new_length % kCodeCacheEntrySize;
DCHECK((new_length % kCodeCacheEntrySize) == 0); DCHECK((new_length % kCodeCacheEntrySize) == 0);
...@@ -10203,13 +10207,18 @@ Object* CodeCache::Lookup(Name* name, Code::Flags flags) { ...@@ -10203,13 +10207,18 @@ Object* CodeCache::Lookup(Name* name, Code::Flags flags) {
Object* CodeCache::LookupDefaultCache(Name* name, Code::Flags flags) { Object* CodeCache::LookupDefaultCache(Name* name, Code::Flags flags) {
FixedArray* cache = default_cache(); FixedArray* cache = default_cache();
Heap* heap = GetHeap();
Object* null = heap->null_value();
Object* undefined = heap->undefined_value();
int length = cache->length(); int length = cache->length();
DCHECK(name->IsUniqueName());
for (int i = 0; i < length; i += kCodeCacheEntrySize) { for (int i = 0; i < length; i += kCodeCacheEntrySize) {
Object* key = cache->get(i + kCodeCacheEntryNameOffset); Object* key = cache->get(i + kCodeCacheEntryNameOffset);
// Skip deleted elements. // Skip deleted elements.
if (key->IsNull()) continue; if (key == null) continue;
if (key->IsUndefined()) return key; if (key == undefined) return key;
if (name->Equals(Name::cast(key))) { DCHECK(key->IsUniqueName());
if (name == key) {
Code* code = Code::cast(cache->get(i + kCodeCacheEntryCodeOffset)); Code* code = Code::cast(cache->get(i + kCodeCacheEntryCodeOffset));
if (Code::RemoveTypeFromFlags(code->flags()) == flags) { if (Code::RemoveTypeFromFlags(code->flags()) == flags) {
return code; return code;
......
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