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

Side by Side Diff: src/ic.h

Issue 2928: Propagate the information that a monomorphic prototype failure has... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 3 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/ic.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 }; 74 };
75 75
76 // Construct the IC structure with the given number of extra 76 // Construct the IC structure with the given number of extra
77 // JavaScript frames on the stack. 77 // JavaScript frames on the stack.
78 explicit IC(FrameDepth depth); 78 explicit IC(FrameDepth depth);
79 79
80 // Get the call-site target; used for determining the state. 80 // Get the call-site target; used for determining the state.
81 Code* target() { return GetTargetAtAddress(address()); } 81 Code* target() { return GetTargetAtAddress(address()); }
82 inline Address address(); 82 inline Address address();
83 83
84 // Compute the current IC state based on the target stub and the receiver. 84 // Compute the state of the current inline cache. If the current
85 static State StateFrom(Code* target, Object* receiver); 85 // inline cache is monomorphic, this might change the code cache in
86 // the receiver map and it might return a code object from the code
87 // cache in the receiver map that should be used as the new target.
88 static State ComputeCacheState(Code* target, Object* receiver,
89 Object* name, Object** new_target);
86 90
87 // Clear the inline cache to initial state. 91 // Clear the inline cache to initial state.
88 static void Clear(Address address); 92 static void Clear(Address address);
89 93
90 // Computes the reloc info for this IC. This is a fairly expensive 94 // Computes the reloc info for this IC. This is a fairly expensive
91 // operation as it has to search through the heap to find the code 95 // operation as it has to search through the heap to find the code
92 // object that contains this IC site. 96 // object that contains this IC site.
93 RelocMode ComputeMode(); 97 RelocMode ComputeMode();
94 98
95 // Returns if this IC is for contextual (no explicit receiver) 99 // Returns if this IC is for contextual (no explicit receiver)
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 private: 158 private:
155 Address address_; 159 Address address_;
156 IC::UtilityId id_; 160 IC::UtilityId id_;
157 }; 161 };
158 162
159 163
160 class CallIC: public IC { 164 class CallIC: public IC {
161 public: 165 public:
162 CallIC() : IC(EXTRA_CALL_FRAME) { ASSERT(target()->is_call_stub()); } 166 CallIC() : IC(EXTRA_CALL_FRAME) { ASSERT(target()->is_call_stub()); }
163 167
164 Object* LoadFunction(State state, Handle<Object> object, Handle<String> name); 168 Object* LoadFunction(Handle<Object> object, Handle<String> name);
165 169
166 170
167 // Code generator routines. 171 // Code generator routines.
168 static void GenerateInitialize(MacroAssembler* masm, int argc); 172 static void GenerateInitialize(MacroAssembler* masm, int argc);
169 static void GeneratePreMonomorphic(MacroAssembler* masm, int argc); 173 static void GeneratePreMonomorphic(MacroAssembler* masm, int argc);
170 static void GenerateMiss(MacroAssembler* masm, int argc); 174 static void GenerateMiss(MacroAssembler* masm, int argc);
171 static void GenerateMegamorphic(MacroAssembler* masm, int argc); 175 static void GenerateMegamorphic(MacroAssembler* masm, int argc);
172 static void GenerateNormal(MacroAssembler* masm, int argc); 176 static void GenerateNormal(MacroAssembler* masm, int argc);
173 177
174 private: 178 private:
175 static void Generate(MacroAssembler* masm, 179 static void Generate(MacroAssembler* masm,
176 int argc, 180 int argc,
177 const ExternalReference& f); 181 const ExternalReference& f);
178 182
179 // Update the inline cache and the global stub cache based on the 183 // Update the inline cache and the global stub cache based on the
180 // lookup result. 184 // lookup result.
181 void UpdateCaches(LookupResult* lookup, 185 void UpdateCaches(LookupResult* lookup,
182 State state,
183 Handle<Object> object, 186 Handle<Object> object,
184 Handle<String> name); 187 Handle<String> name);
185 188
186 // Returns a JSFunction if the object can be called as a function, 189 // Returns a JSFunction if the object can be called as a function,
187 // and patches the stack to be ready for the call. 190 // and patches the stack to be ready for the call.
188 // Otherwise, it returns the undefined value. 191 // Otherwise, it returns the undefined value.
189 Object* TryCallAsFunction(Object* object); 192 Object* TryCallAsFunction(Object* object);
190 193
191 static void Clear(Address address, Code* target); 194 static void Clear(Address address, Code* target);
192 friend class IC; 195 friend class IC;
193 }; 196 };
194 197
195 198
196 class LoadIC: public IC { 199 class LoadIC: public IC {
197 public: 200 public:
198 LoadIC() : IC(NO_EXTRA_FRAME) { ASSERT(target()->is_load_stub()); } 201 LoadIC() : IC(NO_EXTRA_FRAME) { ASSERT(target()->is_load_stub()); }
199 202
200 Object* Load(State state, Handle<Object> object, Handle<String> name); 203 Object* Load(Handle<Object> object, Handle<String> name);
201 204
202 // Code generator routines. 205 // Code generator routines.
203 static void GenerateInitialize(MacroAssembler* masm); 206 static void GenerateInitialize(MacroAssembler* masm);
204 static void GeneratePreMonomorphic(MacroAssembler* masm); 207 static void GeneratePreMonomorphic(MacroAssembler* masm);
205 static void GenerateMiss(MacroAssembler* masm); 208 static void GenerateMiss(MacroAssembler* masm);
206 static void GenerateMegamorphic(MacroAssembler* masm); 209 static void GenerateMegamorphic(MacroAssembler* masm);
207 static void GenerateNormal(MacroAssembler* masm); 210 static void GenerateNormal(MacroAssembler* masm);
208 211
209 // Specialized code generator routines. 212 // Specialized code generator routines.
210 static void GenerateArrayLength(MacroAssembler* masm); 213 static void GenerateArrayLength(MacroAssembler* masm);
211 static void GenerateShortStringLength(MacroAssembler* masm); 214 static void GenerateShortStringLength(MacroAssembler* masm);
212 static void GenerateMediumStringLength(MacroAssembler* masm); 215 static void GenerateMediumStringLength(MacroAssembler* masm);
213 static void GenerateLongStringLength(MacroAssembler* masm); 216 static void GenerateLongStringLength(MacroAssembler* masm);
214 static void GenerateFunctionPrototype(MacroAssembler* masm); 217 static void GenerateFunctionPrototype(MacroAssembler* masm);
215 218
216 private: 219 private:
217 static void Generate(MacroAssembler* masm, const ExternalReference& f); 220 static void Generate(MacroAssembler* masm, const ExternalReference& f);
218 221
219 // Update the inline cache and the global stub cache based on the 222 // Update the inline cache and the global stub cache based on the
220 // lookup result. 223 // lookup result.
221 void UpdateCaches(LookupResult* lookup, 224 void UpdateCaches(LookupResult* lookup,
222 State state,
223 Handle<Object> object, 225 Handle<Object> object,
224 Handle<String> name); 226 Handle<String> name);
225 227
226 // Stub accessors. 228 // Stub accessors.
227 static Code* megamorphic_stub() { 229 static Code* megamorphic_stub() {
228 return Builtins::builtin(Builtins::LoadIC_Megamorphic); 230 return Builtins::builtin(Builtins::LoadIC_Megamorphic);
229 } 231 }
230 static Code* initialize_stub() { 232 static Code* initialize_stub() {
231 return Builtins::builtin(Builtins::LoadIC_Initialize); 233 return Builtins::builtin(Builtins::LoadIC_Initialize);
232 } 234 }
233 static Code* pre_monomorphic_stub() { 235 static Code* pre_monomorphic_stub() {
234 return Builtins::builtin(Builtins::LoadIC_PreMonomorphic); 236 return Builtins::builtin(Builtins::LoadIC_PreMonomorphic);
235 } 237 }
236 238
237 static void Clear(Address address, Code* target); 239 static void Clear(Address address, Code* target);
238 friend class IC; 240 friend class IC;
239 }; 241 };
240 242
241 243
242 class KeyedLoadIC: public IC { 244 class KeyedLoadIC: public IC {
243 public: 245 public:
244 KeyedLoadIC() : IC(NO_EXTRA_FRAME) { ASSERT(target()->is_keyed_load_stub()); } 246 KeyedLoadIC() : IC(NO_EXTRA_FRAME) { ASSERT(target()->is_keyed_load_stub()); }
245 247
246 Object* Load(State state, Handle<Object> object, Handle<Object> key); 248 Object* Load(Handle<Object> object, Handle<Object> key);
247 249
248 // Code generator routines. 250 // Code generator routines.
249 static void GenerateMiss(MacroAssembler* masm); 251 static void GenerateMiss(MacroAssembler* masm);
250 static void GenerateInitialize(MacroAssembler* masm); 252 static void GenerateInitialize(MacroAssembler* masm);
251 static void GeneratePreMonomorphic(MacroAssembler* masm); 253 static void GeneratePreMonomorphic(MacroAssembler* masm);
252 static void GenerateGeneric(MacroAssembler* masm); 254 static void GenerateGeneric(MacroAssembler* masm);
253 255
254 private: 256 private:
255 static void Generate(MacroAssembler* masm, const ExternalReference& f); 257 static void Generate(MacroAssembler* masm, const ExternalReference& f);
256 258
257 // Update the inline cache. 259 // Update the inline cache.
258 void UpdateCaches(LookupResult* lookup, 260 void UpdateCaches(LookupResult* lookup,
259 State state,
260 Handle<Object> object, 261 Handle<Object> object,
261 Handle<String> name); 262 Handle<String> name);
262 263
263 // Stub accessors. 264 // Stub accessors.
264 static Code* initialize_stub() { 265 static Code* initialize_stub() {
265 return Builtins::builtin(Builtins::KeyedLoadIC_Initialize); 266 return Builtins::builtin(Builtins::KeyedLoadIC_Initialize);
266 } 267 }
267 static Code* megamorphic_stub() { 268 static Code* megamorphic_stub() {
268 return Builtins::builtin(Builtins::KeyedLoadIC_Generic); 269 return Builtins::builtin(Builtins::KeyedLoadIC_Generic);
269 } 270 }
270 static Code* generic_stub() { 271 static Code* generic_stub() {
271 return Builtins::builtin(Builtins::KeyedLoadIC_Generic); 272 return Builtins::builtin(Builtins::KeyedLoadIC_Generic);
272 } 273 }
273 static Code* pre_monomorphic_stub() { 274 static Code* pre_monomorphic_stub() {
274 return Builtins::builtin(Builtins::KeyedLoadIC_PreMonomorphic); 275 return Builtins::builtin(Builtins::KeyedLoadIC_PreMonomorphic);
275 } 276 }
276 277
277 static void Clear(Address address, Code* target); 278 static void Clear(Address address, Code* target);
278 friend class IC; 279 friend class IC;
279 }; 280 };
280 281
281 282
282 class StoreIC: public IC { 283 class StoreIC: public IC {
283 public: 284 public:
284 StoreIC() : IC(NO_EXTRA_FRAME) { ASSERT(target()->is_store_stub()); } 285 StoreIC() : IC(NO_EXTRA_FRAME) { ASSERT(target()->is_store_stub()); }
285 286
286 Object* Store(State state, 287 Object* Store(Handle<Object> object,
287 Handle<Object> object,
288 Handle<String> name, 288 Handle<String> name,
289 Handle<Object> value); 289 Handle<Object> value);
290 290
291 // Code generators for stub routines. Only called once at startup. 291 // Code generators for stub routines. Only called once at startup.
292 static void GenerateInitialize(MacroAssembler* masm); 292 static void GenerateInitialize(MacroAssembler* masm);
293 static void GenerateMiss(MacroAssembler* masm); 293 static void GenerateMiss(MacroAssembler* masm);
294 static void GenerateMegamorphic(MacroAssembler* masm); 294 static void GenerateMegamorphic(MacroAssembler* masm);
295 295
296 private: 296 private:
297 static void Generate(MacroAssembler* masm, const ExternalReference& f); 297 static void Generate(MacroAssembler* masm, const ExternalReference& f);
298 298
299 // Update the inline cache and the global stub cache based on the 299 // Update the inline cache and the global stub cache based on the
300 // lookup result. 300 // lookup result.
301 void UpdateCaches(LookupResult* lookup, 301 void UpdateCaches(LookupResult* lookup,
302 State state, Handle<JSObject> receiver, 302 Handle<JSObject> receiver,
303 Handle<String> name, 303 Handle<String> name,
304 Handle<Object> value); 304 Handle<Object> value);
305 305
306 // Stub accessors. 306 // Stub accessors.
307 static Code* megamorphic_stub() { 307 static Code* megamorphic_stub() {
308 return Builtins::builtin(Builtins::StoreIC_Megamorphic); 308 return Builtins::builtin(Builtins::StoreIC_Megamorphic);
309 } 309 }
310 static Code* initialize_stub() { 310 static Code* initialize_stub() {
311 return Builtins::builtin(Builtins::StoreIC_Initialize); 311 return Builtins::builtin(Builtins::StoreIC_Initialize);
312 } 312 }
313 313
314 static void Clear(Address address, Code* target); 314 static void Clear(Address address, Code* target);
315 friend class IC; 315 friend class IC;
316 }; 316 };
317 317
318 318
319 class KeyedStoreIC: public IC { 319 class KeyedStoreIC: public IC {
320 public: 320 public:
321 KeyedStoreIC() : IC(NO_EXTRA_FRAME) { } 321 KeyedStoreIC() : IC(NO_EXTRA_FRAME) { }
322 322
323 Object* Store(State state, 323 Object* Store(Handle<Object> object,
324 Handle<Object> object,
325 Handle<Object> name, 324 Handle<Object> name,
326 Handle<Object> value); 325 Handle<Object> value);
327 326
328 // Code generators for stub routines. Only called once at startup. 327 // Code generators for stub routines. Only called once at startup.
329 static void GenerateInitialize(MacroAssembler* masm); 328 static void GenerateInitialize(MacroAssembler* masm);
330 static void GenerateMiss(MacroAssembler* masm); 329 static void GenerateMiss(MacroAssembler* masm);
331 static void GenerateGeneric(MacroAssembler* masm); 330 static void GenerateGeneric(MacroAssembler* masm);
332 331
333 private: 332 private:
334 static void Generate(MacroAssembler* masm, const ExternalReference& f); 333 static void Generate(MacroAssembler* masm, const ExternalReference& f);
335 334
336 // Update the inline cache. 335 // Update the inline cache.
337 void UpdateCaches(LookupResult* lookup, 336 void UpdateCaches(LookupResult* lookup,
338 State state,
339 Handle<JSObject> receiver, 337 Handle<JSObject> receiver,
340 Handle<String> name, 338 Handle<String> name,
341 Handle<Object> value); 339 Handle<Object> value);
342 340
343 // Stub accessors. 341 // Stub accessors.
344 static Code* initialize_stub() { 342 static Code* initialize_stub() {
345 return Builtins::builtin(Builtins::KeyedStoreIC_Initialize); 343 return Builtins::builtin(Builtins::KeyedStoreIC_Initialize);
346 } 344 }
347 static Code* megamorphic_stub() { 345 static Code* megamorphic_stub() {
348 return Builtins::builtin(Builtins::KeyedStoreIC_Generic); 346 return Builtins::builtin(Builtins::KeyedStoreIC_Generic);
349 } 347 }
350 static Code* generic_stub() { 348 static Code* generic_stub() {
351 return Builtins::builtin(Builtins::KeyedStoreIC_Generic); 349 return Builtins::builtin(Builtins::KeyedStoreIC_Generic);
352 } 350 }
353 351
354 static void Clear(Address address, Code* target); 352 static void Clear(Address address, Code* target);
355 friend class IC; 353 friend class IC;
356 }; 354 };
357 355
358 356
359 } } // namespace v8::internal 357 } } // namespace v8::internal
360 358
361 #endif // V8_IC_H_ 359 #endif // V8_IC_H_
OLDNEW
« no previous file with comments | « no previous file | src/ic.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698