Reviewers: Kevin Millikin,
Message:
Please take a look.
This is just a quick replacement of raw pointer lists by handle lists.
Full handlification of the polymorphic code cache is complicated because
PolymorphicCodeCacheHashTableKey has to implement raw pointer interface of
HashTableKey. So there is no clean way to separate handlified code from raw
pointer code.
http://codereview.chromium.org/8368024/diff/1/src/objects.cc
File src/objects.cc (right):
http://codereview.chromium.org/8368024/diff/1/src/objects.cc#newcode5204
src/objects.cc:5204: MapHandleList
other_maps(kDefaultListAllocationSize);
Adds new precondition (handle scope) for IsMatch.
http://codereview.chromium.org/8368024/diff/1/src/objects.cc#newcode5243
src/objects.cc:5243: MapHandleList
other_maps(kDefaultListAllocationSize);
Adds new precondition (handle scope) for HashForObject.
Description:
Use handle lists instead of raw pointer lists in polymorphic code cache.
BUG=
TEST=
Please review this at http://codereview.chromium.org/8368024/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/objects.h
M src/objects.cc
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index
8db40f098b7cd1ef6e43ec2e014538fb4aa762b6..fd1ce53fbc760b2afa3fa11bd0b44f79c6aed03a
100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -5146,15 +5146,11 @@ void
PolymorphicCodeCache::Update(Handle<PolymorphicCodeCache> cache,
Code::Flags flags,
Handle<Code> code) {
Isolate* isolate = cache->GetIsolate();
- List<Map*> raw_maps(maps->length());
- CALL_HEAP_FUNCTION_VOID(
- isolate,
- (raw_maps.Clear(),
- cache->Update(UnwrapHandleList(&raw_maps, maps), flags, *code)));
+ CALL_HEAP_FUNCTION_VOID(isolate, cache->Update(maps, flags, *code));
}
-MaybeObject* PolymorphicCodeCache::Update(MapList* maps,
+MaybeObject* PolymorphicCodeCache::Update(MapHandleList* maps,
Code::Flags flags,
Code* code) {
// Initialize cache if necessary.
@@ -5184,18 +5180,12 @@ MaybeObject* PolymorphicCodeCache::Update(MapList*
maps,
Handle<Object> PolymorphicCodeCache::Lookup(MapHandleList* maps,
Code::Flags flags) {
- List<Map*> raw_maps(maps->length());
- return Handle<Object>(Lookup(UnwrapHandleList(&raw_maps, maps), flags));
-}
-
-
-Object* PolymorphicCodeCache::Lookup(MapList* maps, Code::Flags flags) {
if (!cache()->IsUndefined()) {
PolymorphicCodeCacheHashTable* hash_table =
PolymorphicCodeCacheHashTable::cast(cache());
- return hash_table->Lookup(maps, flags);
+ return Handle<Object>(hash_table->Lookup(maps, flags));
} else {
- return GetHeap()->undefined_value();
+ return GetIsolate()->factory()->undefined_value();
}
}
@@ -5206,12 +5196,12 @@ Object* PolymorphicCodeCache::Lookup(MapList* maps,
Code::Flags flags) {
class PolymorphicCodeCacheHashTableKey : public HashTableKey {
public:
// Callers must ensure that |maps| outlives the newly constructed object.
- PolymorphicCodeCacheHashTableKey(MapList* maps, int code_flags)
+ PolymorphicCodeCacheHashTableKey(MapHandleList* maps, int code_flags)
: maps_(maps),
code_flags_(code_flags) {}
bool IsMatch(Object* other) {
- MapList other_maps(kDefaultListAllocationSize);
+ MapHandleList other_maps(kDefaultListAllocationSize);
int other_flags;
FromObject(other, &other_flags, &other_maps);
if (code_flags_ != other_flags) return false;
@@ -5227,7 +5217,7 @@ class PolymorphicCodeCacheHashTableKey : public
HashTableKey {
for (int i = 0; i < maps_->length(); ++i) {
bool match_found = false;
for (int j = 0; j < other_maps.length(); ++j) {
- if (maps_->at(i)->EquivalentTo(other_maps.at(j))) {
+ if (maps_->at(i)->EquivalentTo(*other_maps.at(j))) {
match_found = true;
break;
}
@@ -5237,7 +5227,7 @@ class PolymorphicCodeCacheHashTableKey : public
HashTableKey {
return true;
}
- static uint32_t MapsHashHelper(MapList* maps, int code_flags) {
+ static uint32_t MapsHashHelper(MapHandleList* maps, int code_flags) {
uint32_t hash = code_flags;
for (int i = 0; i < maps->length(); ++i) {
hash ^= maps->at(i)->Hash();
@@ -5250,7 +5240,7 @@ class PolymorphicCodeCacheHashTableKey : public
HashTableKey {
}
uint32_t HashForObject(Object* obj) {
- MapList other_maps(kDefaultListAllocationSize);
+ MapHandleList other_maps(kDefaultListAllocationSize);
int other_flags;
FromObject(obj, &other_flags, &other_maps);
return MapsHashHelper(&other_maps, other_flags);
@@ -5268,29 +5258,32 @@ class PolymorphicCodeCacheHashTableKey : public
HashTableKey {
FixedArray* list = FixedArray::cast(obj);
list->set(0, Smi::FromInt(code_flags_));
for (int i = 0; i < maps_->length(); ++i) {
- list->set(i + 1, maps_->at(i));
+ list->set(i + 1, *maps_->at(i));
}
return list;
}
private:
- static MapList* FromObject(Object* obj, int* code_flags, MapList* maps) {
+ static MapHandleList* FromObject(Object* obj,
+ int* code_flags,
+ MapHandleList* maps) {
FixedArray* list = FixedArray::cast(obj);
maps->Rewind(0);
*code_flags = Smi::cast(list->get(0))->value();
for (int i = 1; i < list->length(); ++i) {
- maps->Add(Map::cast(list->get(i)));
+ maps->Add(Handle<Map>(Map::cast(list->get(i))));
}
return maps;
}
- MapList* maps_; // weak.
+ MapHandleList* maps_; // weak.
int code_flags_;
static const int kDefaultListAllocationSize = kMaxKeyedPolymorphism + 1;
};
-Object* PolymorphicCodeCacheHashTable::Lookup(MapList* maps, int
code_flags) {
+Object* PolymorphicCodeCacheHashTable::Lookup(MapHandleList* maps,
+ int code_flags) {
PolymorphicCodeCacheHashTableKey key(maps, code_flags);
int entry = FindEntry(&key);
if (entry == kNotFound) return GetHeap()->undefined_value();
@@ -5298,7 +5291,7 @@ Object*
PolymorphicCodeCacheHashTable::Lookup(MapList* maps, int code_flags) {
}
-MaybeObject* PolymorphicCodeCacheHashTable::Put(MapList* maps,
+MaybeObject* PolymorphicCodeCacheHashTable::Put(MapHandleList* maps,
int code_flags,
Code* code) {
PolymorphicCodeCacheHashTableKey key(maps, code_flags);
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
87613f0438a2c2e62d5b362edff130cddb25e7db..586df9f9f1ff083e206fd52947d01744d12c9515
100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -5868,15 +5868,13 @@ class PolymorphicCodeCache: public Struct {
Code::Flags flags,
Handle<Code> code);
- MUST_USE_RESULT MaybeObject* Update(MapList* maps,
+ MUST_USE_RESULT MaybeObject* Update(MapHandleList* maps,
Code::Flags flags,
Code* code);
// Returns an undefined value if the entry is not found.
Handle<Object> Lookup(MapHandleList* maps, Code::Flags flags);
- Object* Lookup(MapList* maps, Code::Flags flags);
-
static inline PolymorphicCodeCache* cast(Object* obj);
#ifdef OBJECT_PRINT
@@ -5900,8 +5898,11 @@ class PolymorphicCodeCache: public Struct {
class PolymorphicCodeCacheHashTable
: public HashTable<CodeCacheHashTableShape, HashTableKey*> {
public:
- Object* Lookup(MapList* maps, int code_kind);
- MUST_USE_RESULT MaybeObject* Put(MapList* maps, int code_kind, Code*
code);
+ Object* Lookup(MapHandleList* maps, int code_kind);
+
+ MUST_USE_RESULT MaybeObject* Put(MapHandleList* maps,
+ int code_kind,
+ Code* code);
static inline PolymorphicCodeCacheHashTable* cast(Object* obj);
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev