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

Unified Diff: src/code-stubs.h

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 | « no previous file | src/code-stubs.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stubs.h
diff --git a/src/code-stubs.h b/src/code-stubs.h
index b65f085d3d70711ae4aad75ce9f1ec2bfd2198da..7365cf89a73074f64f4d8f33f4c7347a7fcf92d2 100644
--- a/src/code-stubs.h
+++ b/src/code-stubs.h
@@ -145,7 +145,9 @@ class CodeStub BASE_EMBEDDED {
Handle<Code> GetCode(Isolate* isolate);
// Retrieve the code for the stub, make and return a copy of the code.
- Handle<Code> GetCodeCopyFromTemplate(Isolate* isolate);
+ Handle<Code> GetCodeCopy(
+ Isolate* isolate, const Code::FindAndReplacePattern& pattern);
+
static Major MajorKeyFromKey(uint32_t key) {
return static_cast<Major>(MajorKeyBits::decode(key));
}
@@ -999,18 +1001,19 @@ class StoreGlobalStub : public HandlerStub {
}
Handle<Code> GetCodeCopyFromTemplate(Isolate* isolate,
- GlobalObject* global,
- PropertyCell* cell) {
- Handle<Code> code = CodeStub::GetCodeCopyFromTemplate(isolate);
+ Handle<GlobalObject> global,
+ Handle<PropertyCell> cell) {
if (check_global()) {
- // Replace the placeholder cell and global object map with the actual
- // global cell and receiver map.
- code->ReplaceNthObject(1, global_placeholder(isolate)->map(), global);
- code->ReplaceNthObject(1, isolate->heap()->meta_map(), global->map());
+ Code::FindAndReplacePattern pattern;
+ pattern.Add(Handle<Map>(global_placeholder(isolate)->map()), global);
+ pattern.Add(isolate->factory()->meta_map(), Handle<Map>(global->map()));
+ pattern.Add(isolate->factory()->global_property_cell_map(), cell);
+ return CodeStub::GetCodeCopy(isolate, pattern);
+ } else {
+ Code::FindAndReplacePattern pattern;
+ pattern.Add(isolate->factory()->global_property_cell_map(), cell);
+ return CodeStub::GetCodeCopy(isolate, pattern);
}
- Map* cell_map = isolate->heap()->global_property_cell_map();
- code->ReplaceNthObject(1, cell_map, cell);
- return code;
}
virtual Code::Kind kind() const { return Code::STORE_IC; }
@@ -1195,10 +1198,9 @@ class BinaryOpICWithAllocationSiteStub V8_FINAL : public PlatformCodeStub {
Handle<Code> GetCodeCopyFromTemplate(Isolate* isolate,
Handle<AllocationSite> allocation_site) {
- Handle<Code> code = CodeStub::GetCodeCopyFromTemplate(isolate);
- // Replace the placeholder oddball with the actual allocation site.
- code->ReplaceNthObject(1, isolate->heap()->oddball_map(), *allocation_site);
- return code;
+ Code::FindAndReplacePattern pattern;
+ pattern.Add(isolate->factory()->oddball_map(), allocation_site);
+ return CodeStub::GetCodeCopy(isolate, pattern);
}
virtual Code::Kind GetCodeKind() const V8_OVERRIDE {
« no previous file with comments | « no previous file | src/code-stubs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698