Commit 250dd1ed authored by ulan's avatar ulan Committed by Commit bot

Store weak cell cache for map in the map itself.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#26891}
parent 5c7b7b91
......@@ -802,7 +802,6 @@ Handle<CodeCache> Factory::NewCodeCache() {
Handle<CodeCache>::cast(NewStruct(CODE_CACHE_TYPE));
code_cache->set_default_cache(*empty_fixed_array(), SKIP_WRITE_BARRIER);
code_cache->set_normal_type_cache(*undefined_value(), SKIP_WRITE_BARRIER);
code_cache->set_weak_cell_cache(*undefined_value(), SKIP_WRITE_BARRIER);
return code_cache;
}
......
......@@ -2449,6 +2449,7 @@ AllocationResult Heap::AllocatePartialMap(InstanceType instance_type,
Map::OwnsDescriptors::encode(true) |
Map::Counter::encode(Map::kRetainingCounterStart);
reinterpret_cast<Map*>(result)->set_bit_field3(bit_field3);
reinterpret_cast<Map*>(result)->set_weak_cell_cache(Smi::FromInt(0));
return result;
}
......@@ -2471,6 +2472,7 @@ AllocationResult Heap::AllocateMap(InstanceType instance_type,
map->set_code_cache(empty_fixed_array(), SKIP_WRITE_BARRIER);
map->set_dependent_code(DependentCode::cast(empty_fixed_array()),
SKIP_WRITE_BARRIER);
map->set_weak_cell_cache(Smi::FromInt(0));
map->init_transitions(undefined_value());
map->set_unused_property_fields(0);
map->set_instance_descriptors(empty_descriptor_array());
......
......@@ -5503,6 +5503,7 @@ void Map::SetBackPointer(Object* value, WriteBarrierMode mode) {
ACCESSORS(Map, code_cache, Object, kCodeCacheOffset)
ACCESSORS(Map, dependent_code, DependentCode, kDependentCodeOffset)
ACCESSORS(Map, weak_cell_cache, Object, kWeakCellCacheOffset)
ACCESSORS(Map, constructor_or_backpointer, Object,
kConstructorOrBackPointerOffset)
......@@ -5863,7 +5864,6 @@ BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_default_constructor,
ACCESSORS(CodeCache, default_cache, FixedArray, kDefaultCacheOffset)
ACCESSORS(CodeCache, normal_type_cache, Object, kNormalTypeCacheOffset)
ACCESSORS(CodeCache, weak_cell_cache, Object, kWeakCellCacheOffset)
ACCESSORS(PolymorphicCodeCache, cache, Object, kCacheOffset)
......
......@@ -3637,15 +3637,11 @@ bool Map::IsMapInArrayPrototypeChain() {
Handle<WeakCell> Map::WeakCellForMap(Handle<Map> map) {
Isolate* isolate = map->GetIsolate();
if (map->code_cache()->IsFixedArray()) {
return isolate->factory()->NewWeakCell(map);
}
Handle<CodeCache> code_cache(CodeCache::cast(map->code_cache()), isolate);
if (code_cache->weak_cell_cache()->IsWeakCell()) {
return Handle<WeakCell>(WeakCell::cast(code_cache->weak_cell_cache()));
if (map->weak_cell_cache()->IsWeakCell()) {
return Handle<WeakCell>(WeakCell::cast(map->weak_cell_cache()));
}
Handle<WeakCell> weak_cell = isolate->factory()->NewWeakCell(map);
code_cache->set_weak_cell_cache(*weak_cell);
map->set_weak_cell_cache(*weak_cell);
return weak_cell;
}
......@@ -6867,7 +6863,7 @@ Handle<Map> Map::Normalize(Handle<Map> fast_map, PropertyNormalizationMode mode,
if (FLAG_enable_slow_asserts) {
// The cached map should match newly created normalized map bit-by-bit,
// except for the code cache, which can contain some ics which can be
// applied to the shared map.
// applied to the shared map, dependent code and weak cell cache.
Handle<Map> fresh = Map::CopyNormalized(fast_map, mode);
DCHECK(memcmp(fresh->address(),
......@@ -6875,7 +6871,9 @@ Handle<Map> Map::Normalize(Handle<Map> fast_map, PropertyNormalizationMode mode,
Map::kCodeCacheOffset) == 0);
STATIC_ASSERT(Map::kDependentCodeOffset ==
Map::kCodeCacheOffset + kPointerSize);
int offset = Map::kDependentCodeOffset + kPointerSize;
STATIC_ASSERT(Map::kWeakCellCacheOffset ==
Map::kDependentCodeOffset + kPointerSize);
int offset = Map::kWeakCellCacheOffset + kPointerSize;
DCHECK(memcmp(fresh->address() + offset,
new_map->address() + offset,
Map::kSize - offset) == 0);
......
......@@ -5991,6 +5991,9 @@ class Map: public HeapObject {
// [dependent code]: list of optimized codes that weakly embed this map.
DECL_ACCESSORS(dependent_code, DependentCode)
// [weak cell cache]: cache that stores a weak cell pointing to this map.
DECL_ACCESSORS(weak_cell_cache, Object)
// [prototype transitions]: cache of prototype transitions.
// Prototype transition is a transition that happens
// when we change object's prototype to a new one.
......@@ -6296,7 +6299,8 @@ class Map: public HeapObject {
static const int kCodeCacheOffset = kDescriptorsOffset + kPointerSize;
#endif
static const int kDependentCodeOffset = kCodeCacheOffset + kPointerSize;
static const int kSize = kDependentCodeOffset + kPointerSize;
static const int kWeakCellCacheOffset = kDependentCodeOffset + kPointerSize;
static const int kSize = kWeakCellCacheOffset + kPointerSize;
// Layout of pointer fields. Heap iteration code relies on them
// being continuously allocated.
......@@ -8108,7 +8112,6 @@ class CodeCache: public Struct {
public:
DECL_ACCESSORS(default_cache, FixedArray)
DECL_ACCESSORS(normal_type_cache, Object)
DECL_ACCESSORS(weak_cell_cache, Object)
// Add the code object to the cache.
static void Update(
......@@ -8136,8 +8139,7 @@ class CodeCache: public Struct {
static const int kDefaultCacheOffset = HeapObject::kHeaderSize;
static const int kNormalTypeCacheOffset =
kDefaultCacheOffset + kPointerSize;
static const int kWeakCellCacheOffset = kNormalTypeCacheOffset + kPointerSize;
static const int kSize = kWeakCellCacheOffset + kPointerSize;
static const int kSize = kNormalTypeCacheOffset + kPointerSize;
private:
static void UpdateDefaultCache(
......
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