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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/code-stubs.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 CODE_STUB_LIST(DEF_ENUM) 138 CODE_STUB_LIST(DEF_ENUM)
139 #undef DEF_ENUM 139 #undef DEF_ENUM
140 NoCache, // marker for stubs that do custom caching 140 NoCache, // marker for stubs that do custom caching
141 NUMBER_OF_IDS 141 NUMBER_OF_IDS
142 }; 142 };
143 143
144 // Retrieve the code for the stub. Generate the code if needed. 144 // Retrieve the code for the stub. Generate the code if needed.
145 Handle<Code> GetCode(Isolate* isolate); 145 Handle<Code> GetCode(Isolate* isolate);
146 146
147 // Retrieve the code for the stub, make and return a copy of the code. 147 // Retrieve the code for the stub, make and return a copy of the code.
148 Handle<Code> GetCodeCopyFromTemplate(Isolate* isolate); 148 Handle<Code> GetCodeCopy(
149 Isolate* isolate, const Code::FindAndReplacePattern& pattern);
150
149 static Major MajorKeyFromKey(uint32_t key) { 151 static Major MajorKeyFromKey(uint32_t key) {
150 return static_cast<Major>(MajorKeyBits::decode(key)); 152 return static_cast<Major>(MajorKeyBits::decode(key));
151 } 153 }
152 static int MinorKeyFromKey(uint32_t key) { 154 static int MinorKeyFromKey(uint32_t key) {
153 return MinorKeyBits::decode(key); 155 return MinorKeyBits::decode(key);
154 } 156 }
155 157
156 // Gets the major key from a code object that is a code stub or binary op IC. 158 // Gets the major key from a code object that is a code stub or binary op IC.
157 static Major GetMajorKey(Code* code_stub) { 159 static Major GetMajorKey(Code* code_stub) {
158 return static_cast<Major>(code_stub->major_key()); 160 return static_cast<Major>(code_stub->major_key());
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 explicit StoreGlobalStub(bool is_constant, bool check_global) { 994 explicit StoreGlobalStub(bool is_constant, bool check_global) {
993 bit_field_ = IsConstantBits::encode(is_constant) | 995 bit_field_ = IsConstantBits::encode(is_constant) |
994 CheckGlobalBits::encode(check_global); 996 CheckGlobalBits::encode(check_global);
995 } 997 }
996 998
997 static Handle<HeapObject> global_placeholder(Isolate* isolate) { 999 static Handle<HeapObject> global_placeholder(Isolate* isolate) {
998 return isolate->factory()->uninitialized_value(); 1000 return isolate->factory()->uninitialized_value();
999 } 1001 }
1000 1002
1001 Handle<Code> GetCodeCopyFromTemplate(Isolate* isolate, 1003 Handle<Code> GetCodeCopyFromTemplate(Isolate* isolate,
1002 GlobalObject* global, 1004 Handle<GlobalObject> global,
1003 PropertyCell* cell) { 1005 Handle<PropertyCell> cell) {
1004 Handle<Code> code = CodeStub::GetCodeCopyFromTemplate(isolate);
1005 if (check_global()) { 1006 if (check_global()) {
1006 // Replace the placeholder cell and global object map with the actual 1007 Code::FindAndReplacePattern pattern;
1007 // global cell and receiver map. 1008 pattern.Add(Handle<Map>(global_placeholder(isolate)->map()), global);
1008 code->ReplaceNthObject(1, global_placeholder(isolate)->map(), global); 1009 pattern.Add(isolate->factory()->meta_map(), Handle<Map>(global->map()));
1009 code->ReplaceNthObject(1, isolate->heap()->meta_map(), global->map()); 1010 pattern.Add(isolate->factory()->global_property_cell_map(), cell);
1011 return CodeStub::GetCodeCopy(isolate, pattern);
1012 } else {
1013 Code::FindAndReplacePattern pattern;
1014 pattern.Add(isolate->factory()->global_property_cell_map(), cell);
1015 return CodeStub::GetCodeCopy(isolate, pattern);
1010 } 1016 }
1011 Map* cell_map = isolate->heap()->global_property_cell_map();
1012 code->ReplaceNthObject(1, cell_map, cell);
1013 return code;
1014 } 1017 }
1015 1018
1016 virtual Code::Kind kind() const { return Code::STORE_IC; } 1019 virtual Code::Kind kind() const { return Code::STORE_IC; }
1017 1020
1018 virtual Handle<Code> GenerateCode(Isolate* isolate); 1021 virtual Handle<Code> GenerateCode(Isolate* isolate);
1019 1022
1020 virtual void InitializeInterfaceDescriptor( 1023 virtual void InitializeInterfaceDescriptor(
1021 Isolate* isolate, 1024 Isolate* isolate,
1022 CodeStubInterfaceDescriptor* descriptor); 1025 CodeStubInterfaceDescriptor* descriptor);
1023 1026
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 // call support for stubs in Hydrogen. 1191 // call support for stubs in Hydrogen.
1189 class BinaryOpICWithAllocationSiteStub V8_FINAL : public PlatformCodeStub { 1192 class BinaryOpICWithAllocationSiteStub V8_FINAL : public PlatformCodeStub {
1190 public: 1193 public:
1191 explicit BinaryOpICWithAllocationSiteStub(const BinaryOpIC::State& state) 1194 explicit BinaryOpICWithAllocationSiteStub(const BinaryOpIC::State& state)
1192 : state_(state) {} 1195 : state_(state) {}
1193 1196
1194 static void GenerateAheadOfTime(Isolate* isolate); 1197 static void GenerateAheadOfTime(Isolate* isolate);
1195 1198
1196 Handle<Code> GetCodeCopyFromTemplate(Isolate* isolate, 1199 Handle<Code> GetCodeCopyFromTemplate(Isolate* isolate,
1197 Handle<AllocationSite> allocation_site) { 1200 Handle<AllocationSite> allocation_site) {
1198 Handle<Code> code = CodeStub::GetCodeCopyFromTemplate(isolate); 1201 Code::FindAndReplacePattern pattern;
1199 // Replace the placeholder oddball with the actual allocation site. 1202 pattern.Add(isolate->factory()->oddball_map(), allocation_site);
1200 code->ReplaceNthObject(1, isolate->heap()->oddball_map(), *allocation_site); 1203 return CodeStub::GetCodeCopy(isolate, pattern);
1201 return code;
1202 } 1204 }
1203 1205
1204 virtual Code::Kind GetCodeKind() const V8_OVERRIDE { 1206 virtual Code::Kind GetCodeKind() const V8_OVERRIDE {
1205 return Code::BINARY_OP_IC; 1207 return Code::BINARY_OP_IC;
1206 } 1208 }
1207 1209
1208 virtual InlineCacheState GetICState() V8_OVERRIDE { 1210 virtual InlineCacheState GetICState() V8_OVERRIDE {
1209 return state_.GetICState(); 1211 return state_.GetICState();
1210 } 1212 }
1211 1213
(...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after
2514 2516
2515 2517
2516 class CallDescriptors { 2518 class CallDescriptors {
2517 public: 2519 public:
2518 static void InitializeForIsolate(Isolate* isolate); 2520 static void InitializeForIsolate(Isolate* isolate);
2519 }; 2521 };
2520 2522
2521 } } // namespace v8::internal 2523 } } // namespace v8::internal
2522 2524
2523 #endif // V8_CODE_STUBS_H_ 2525 #endif // V8_CODE_STUBS_H_
OLDNEW
« 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