Commit 303f2ab5 authored by ishell@chromium.org's avatar ishell@chromium.org

WeakHashTable::Lookup() handlified and ObjectHashTable's interface cleaned up.

R=yangguo@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@21060 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 306e9e56
......@@ -5505,11 +5505,11 @@ void Heap::AddWeakObjectToCodeDependency(Handle<Object> obj,
WeakHashTable::cast(weak_object_to_code_table_)->Zap(the_hole_value());
}
set_weak_object_to_code_table(*table);
ASSERT_EQ(*dep, table->Lookup(*obj));
ASSERT_EQ(*dep, table->Lookup(obj));
}
DependentCode* Heap::LookupWeakObjectToCodeDependency(Object* obj) {
DependentCode* Heap::LookupWeakObjectToCodeDependency(Handle<Object> obj) {
Object* dep = WeakHashTable::cast(weak_object_to_code_table_)->Lookup(obj);
if (dep->IsDependentCode()) return DependentCode::cast(dep);
return DependentCode::cast(empty_fixed_array());
......
......@@ -1485,7 +1485,7 @@ class Heap {
void AddWeakObjectToCodeDependency(Handle<Object> obj,
Handle<DependentCode> dep);
DependentCode* LookupWeakObjectToCodeDependency(Object* obj);
DependentCode* LookupWeakObjectToCodeDependency(Handle<Object> obj);
void InitializeWeakObjectToCodeTable() {
set_weak_object_to_code_table(undefined_value());
......
......@@ -155,7 +155,7 @@ static void AddWeakObjectToCodeDependency(Isolate* isolate,
Handle<Code> code) {
Heap* heap = isolate->heap();
heap->EnsureWeakObjectToCodeTable();
Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(*object));
Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(object));
dep = DependentCode::Insert(dep, DependentCode::kWeakCodeGroup, code);
heap->AddWeakObjectToCodeDependency(object, dep);
}
......
......@@ -655,6 +655,9 @@ void Code::CodeVerify() {
void Code::VerifyEmbeddedObjectsDependency() {
if (!CanContainWeakObjects()) return;
DisallowHeapAllocation no_gc;
Isolate* isolate = GetIsolate();
HandleScope scope(isolate);
int mode_mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
for (RelocIterator it(this, mode_mask); !it.done(); it.next()) {
Object* obj = it.rinfo()->target_object();
......@@ -667,7 +670,8 @@ void Code::VerifyEmbeddedObjectsDependency() {
} else if (obj->IsJSObject()) {
Object* raw_table = GetIsolate()->heap()->weak_object_to_code_table();
WeakHashTable* table = WeakHashTable::cast(raw_table);
CHECK(DependentCode::cast(table->Lookup(obj))->Contains(
Handle<Object> key_obj(obj, isolate);
CHECK(DependentCode::cast(table->Lookup(key_obj))->Contains(
DependentCode::kWeakCodeGroup, this));
}
}
......
......@@ -16051,21 +16051,6 @@ Object* ObjectHashTable::Lookup(Handle<Object> key) {
}
// TODO(ishell): Try to remove this when FindEntry(Object* key) is removed
int ObjectHashTable::FindEntry(Handle<Object> key) {
return DerivedHashTable::FindEntry(key);
}
// TODO(ishell): Remove this when all the callers are handlified.
int ObjectHashTable::FindEntry(Object* key) {
DisallowHeapAllocation no_allocation;
Isolate* isolate = GetIsolate();
HandleScope scope(isolate);
return FindEntry(handle(key, isolate));
}
Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table,
Handle<Object> key,
Handle<Object> value) {
......@@ -16114,29 +16099,15 @@ void ObjectHashTable::RemoveEntry(int entry) {
}
Object* WeakHashTable::Lookup(Object* key) {
ASSERT(IsKey(key));
Object* WeakHashTable::Lookup(Handle<Object> key) {
DisallowHeapAllocation no_gc;
ASSERT(IsKey(*key));
int entry = FindEntry(key);
if (entry == kNotFound) return GetHeap()->the_hole_value();
return get(EntryToValueIndex(entry));
}
// TODO(ishell): Try to remove this when FindEntry(Object* key) is removed
int WeakHashTable::FindEntry(Handle<Object> key) {
return DerivedHashTable::FindEntry(key);
}
// TODO(ishell): Remove this when all the callers are handlified.
int WeakHashTable::FindEntry(Object* key) {
DisallowHeapAllocation no_allocation;
Isolate* isolate = GetIsolate();
HandleScope scope(isolate);
return FindEntry(handle(key, isolate));
}
Handle<WeakHashTable> WeakHashTable::Put(Handle<WeakHashTable> table,
Handle<Object> key,
Handle<Object> value) {
......
......@@ -4202,10 +4202,6 @@ class ObjectHashTable: public HashTable<ObjectHashTable,
// returned in case the key is not present.
Object* Lookup(Handle<Object> key);
int FindEntry(Handle<Object> key);
// TODO(ishell): Remove this when all the callers are handlified.
int FindEntry(Object* key);
// Adds (or overwrites) the value associated with the given key. Mapping a
// key to the hole value causes removal of the whole entry.
static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table,
......@@ -4431,11 +4427,7 @@ class WeakHashTable: public HashTable<WeakHashTable,
// Looks up the value associated with the given key. The hole value is
// returned in case the key is not present.
Object* Lookup(Object* key);
int FindEntry(Handle<Object> key);
// TODO(ishell): Remove this when all the callers are handlified.
int FindEntry(Object* key);
Object* Lookup(Handle<Object> key);
// Adds (or overwrites) the value associated with the given key. Mapping a
// key to the hole value causes removal of the whole entry.
......
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