Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1113)

Unified Diff: src/objects.cc

Issue 197283017: Refactor GetCodeCopyFromTemplate to get a single point where objects are replaced in code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comment Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index b1251e11c98492307ca254f2f2e3da09916ff73c..aba8a1c4c3d72c3e6cad3ba9e333b3e5dc5fae44 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -10501,21 +10501,20 @@ Map* Code::FindFirstMap() {
}
-void Code::ReplaceNthObject(int n,
- Map* match_map,
- Object* replace_with) {
+void Code::FindAndReplace(const FindAndReplacePattern& pattern) {
ASSERT(is_inline_cache_stub() || is_handler());
DisallowHeapAllocation no_allocation;
int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
+ STATIC_ASSERT(FindAndReplacePattern::kMaxCount < 32);
+ int current_pattern = 0;
for (RelocIterator it(this, mask); !it.done(); it.next()) {
RelocInfo* info = it.rinfo();
Object* object = info->target_object();
if (object->IsHeapObject()) {
- if (HeapObject::cast(object)->map() == match_map) {
- if (--n == 0) {
- info->set_target_object(replace_with);
- return;
- }
+ Map* map = HeapObject::cast(object)->map();
+ if (map == *pattern.find_[current_pattern]) {
+ info->set_target_object(*pattern.replace_[current_pattern]);
+ if (++current_pattern == pattern.count_) return;
}
}
}
@@ -10550,11 +10549,6 @@ void Code::FindAllTypes(TypeHandleList* types) {
}
-void Code::ReplaceFirstMap(Map* replace_with) {
- ReplaceNthObject(1, GetHeap()->meta_map(), replace_with);
-}
-
-
Code* Code::FindFirstHandler() {
ASSERT(is_inline_cache_stub());
DisallowHeapAllocation no_allocation;
@@ -10600,21 +10594,6 @@ 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() {
ClearInlineCaches(NULL);
}
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698