Commit c35dbc30 authored by danno@chromium.org's avatar danno@chromium.org

Generalize utilities to allow code templatization

R=mvstanton@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15357 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 2f81a79d
...@@ -10109,31 +10109,47 @@ SafepointEntry Code::GetSafepointEntry(Address pc) { ...@@ -10109,31 +10109,47 @@ SafepointEntry Code::GetSafepointEntry(Address pc) {
} }
Map* Code::FindFirstMap() { Object* Code::FindNthObject(int n, Map* match_map) {
ASSERT(is_inline_cache_stub()); ASSERT(is_inline_cache_stub());
DisallowHeapAllocation no_allocation; DisallowHeapAllocation no_allocation;
int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
for (RelocIterator it(this, mask); !it.done(); it.next()) { for (RelocIterator it(this, mask); !it.done(); it.next()) {
RelocInfo* info = it.rinfo(); RelocInfo* info = it.rinfo();
Object* object = info->target_object(); Object* object = info->target_object();
if (object->IsMap()) return Map::cast(object); if (object->IsHeapObject()) {
if (HeapObject::cast(object)->map() == match_map) {
if (--n == 0) return object;
}
}
} }
return NULL; return NULL;
} }
void Code::ReplaceFirstMap(Map* replace_with) { Map* Code::FindFirstMap() {
Object* result = FindNthObject(1, GetHeap()->meta_map());
return (result != NULL) ? Map::cast(result) : NULL;
}
void Code::ReplaceNthObject(int n,
Map* match_map,
Object* replace_with) {
ASSERT(is_inline_cache_stub()); ASSERT(is_inline_cache_stub());
DisallowHeapAllocation no_allocation; DisallowHeapAllocation no_allocation;
int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
for (RelocIterator it(this, mask); !it.done(); it.next()) { for (RelocIterator it(this, mask); !it.done(); it.next()) {
RelocInfo* info = it.rinfo(); RelocInfo* info = it.rinfo();
Object* object = info->target_object(); Object* object = info->target_object();
if (object->IsMap()) { if (object->IsHeapObject()) {
if (HeapObject::cast(object)->map() == match_map) {
if (--n == 0) {
info->set_target_object(replace_with); info->set_target_object(replace_with);
return; return;
} }
} }
}
}
UNREACHABLE(); UNREACHABLE();
} }
...@@ -10150,6 +10166,11 @@ void Code::FindAllMaps(MapHandleList* maps) { ...@@ -10150,6 +10166,11 @@ void Code::FindAllMaps(MapHandleList* maps) {
} }
void Code::ReplaceFirstMap(Map* replace_with) {
ReplaceNthObject(1, GetHeap()->meta_map(), replace_with);
}
Code* Code::FindFirstCode() { Code* Code::FindFirstCode() {
ASSERT(is_inline_cache_stub()); ASSERT(is_inline_cache_stub());
DisallowHeapAllocation no_allocation; DisallowHeapAllocation no_allocation;
...@@ -10191,6 +10212,21 @@ Name* Code::FindFirstName() { ...@@ -10191,6 +10212,21 @@ Name* Code::FindFirstName() {
} }
void Code::ReplaceNthCell(int n, Cell* replace_with) {
ASSERT(is_inline_cache_stub());
DisallowHeapAllocation no_allocation;
int mask = RelocInfo::ModeMask(RelocInfo::CELL);
for (RelocIterator it(this, mask); !it.done(); it.next()) {
RelocInfo* info = it.rinfo();
if (--n == 0) {
info->set_target_cell(replace_with);
return;
}
}
UNREACHABLE();
}
void Code::ClearInlineCaches() { void Code::ClearInlineCaches() {
int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) | int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) |
RelocInfo::ModeMask(RelocInfo::CONSTRUCT_CALL) | RelocInfo::ModeMask(RelocInfo::CONSTRUCT_CALL) |
......
...@@ -4685,6 +4685,10 @@ class Code: public HeapObject { ...@@ -4685,6 +4685,10 @@ class Code: public HeapObject {
// Get the safepoint entry for the given pc. // Get the safepoint entry for the given pc.
SafepointEntry GetSafepointEntry(Address pc); SafepointEntry GetSafepointEntry(Address pc);
// Find an object in a stub with a specified map
Object* FindNthObject(int n, Map* match_map);
void ReplaceNthObject(int n, Map* match_map, Object* replace_with);
// Find the first map in an IC stub. // Find the first map in an IC stub.
Map* FindFirstMap(); Map* FindFirstMap();
void FindAllMaps(MapHandleList* maps); void FindAllMaps(MapHandleList* maps);
...@@ -4697,6 +4701,8 @@ class Code: public HeapObject { ...@@ -4697,6 +4701,8 @@ class Code: public HeapObject {
// Find the first name in an IC stub. // Find the first name in an IC stub.
Name* FindFirstName(); Name* FindFirstName();
void ReplaceNthCell(int n, Cell* replace_with);
class ExtraICStateStrictMode: public BitField<StrictModeFlag, 0, 1> {}; class ExtraICStateStrictMode: public BitField<StrictModeFlag, 0, 1> {};
class ExtraICStateKeyedAccessStoreMode: class ExtraICStateKeyedAccessStoreMode:
public BitField<KeyedAccessStoreMode, 1, 4> {}; // NOLINT public BitField<KeyedAccessStoreMode, 1, 4> {}; // NOLINT
......
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