Revision: 15357
Author: [email protected]
Date: Thu Jun 27 06:36:15 2013
Log: Generalize utilities to allow code templatization
[email protected]
Review URL: https://codereview.chromium.org/17853004
http://code.google.com/p/v8/source/detail?r=15357
Modified:
/branches/bleeding_edge/src/objects.cc
/branches/bleeding_edge/src/objects.h
=======================================
--- /branches/bleeding_edge/src/objects.cc Wed Jun 26 09:17:12 2013
+++ /branches/bleeding_edge/src/objects.cc Thu Jun 27 06:36:15 2013
@@ -10109,29 +10109,45 @@
}
-Map* Code::FindFirstMap() {
+Object* Code::FindNthObject(int n, Map* match_map) {
ASSERT(is_inline_cache_stub());
DisallowHeapAllocation no_allocation;
int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
for (RelocIterator it(this, mask); !it.done(); it.next()) {
RelocInfo* info = it.rinfo();
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;
}
-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());
DisallowHeapAllocation no_allocation;
int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
for (RelocIterator it(this, mask); !it.done(); it.next()) {
RelocInfo* info = it.rinfo();
Object* object = info->target_object();
- if (object->IsMap()) {
- info->set_target_object(replace_with);
- return;
+ if (object->IsHeapObject()) {
+ if (HeapObject::cast(object)->map() == match_map) {
+ if (--n == 0) {
+ info->set_target_object(replace_with);
+ return;
+ }
+ }
}
}
UNREACHABLE();
@@ -10148,6 +10164,11 @@
if (object->IsMap()) maps->Add(Handle<Map>(Map::cast(object)));
}
}
+
+
+void Code::ReplaceFirstMap(Map* replace_with) {
+ ReplaceNthObject(1, GetHeap()->meta_map(), replace_with);
+}
Code* Code::FindFirstCode() {
@@ -10189,6 +10210,21 @@
}
return NULL;
}
+
+
+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() {
=======================================
--- /branches/bleeding_edge/src/objects.h Wed Jun 26 09:17:12 2013
+++ /branches/bleeding_edge/src/objects.h Thu Jun 27 06:36:15 2013
@@ -4685,6 +4685,10 @@
// Get the safepoint entry for the given 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.
Map* FindFirstMap();
void FindAllMaps(MapHandleList* maps);
@@ -4697,6 +4701,8 @@
// Find the first name in an IC stub.
Name* FindFirstName();
+ void ReplaceNthCell(int n, Cell* replace_with);
+
class ExtraICStateStrictMode: public BitField<StrictModeFlag, 0, 1> {};
class ExtraICStateKeyedAccessStoreMode:
public BitField<KeyedAccessStoreMode, 1, 4> {}; // NOLINT
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.