OLD | NEW |
---|---|
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 24 matching lines...) Expand all Loading... | |
35 | 35 |
36 | 36 |
37 const int kMaxKeyedPolymorphism = 4; | 37 const int kMaxKeyedPolymorphism = 4; |
38 | 38 |
39 | 39 |
40 // IC_UTIL_LIST defines all utility functions called from generated | 40 // IC_UTIL_LIST defines all utility functions called from generated |
41 // inline caching code. The argument for the macro, ICU, is the function name. | 41 // inline caching code. The argument for the macro, ICU, is the function name. |
42 #define IC_UTIL_LIST(ICU) \ | 42 #define IC_UTIL_LIST(ICU) \ |
43 ICU(LoadIC_Miss) \ | 43 ICU(LoadIC_Miss) \ |
44 ICU(KeyedLoadIC_Miss) \ | 44 ICU(KeyedLoadIC_Miss) \ |
45 ICU(CallIC_Miss) \ | |
45 ICU(StoreIC_Miss) \ | 46 ICU(StoreIC_Miss) \ |
46 ICU(StoreIC_ArrayLength) \ | 47 ICU(StoreIC_ArrayLength) \ |
47 ICU(StoreIC_Slow) \ | 48 ICU(StoreIC_Slow) \ |
48 ICU(SharedStoreIC_ExtendStorage) \ | 49 ICU(SharedStoreIC_ExtendStorage) \ |
49 ICU(KeyedStoreIC_Miss) \ | 50 ICU(KeyedStoreIC_Miss) \ |
50 ICU(KeyedStoreIC_Slow) \ | 51 ICU(KeyedStoreIC_Slow) \ |
51 /* Utilities for IC stubs. */ \ | 52 /* Utilities for IC stubs. */ \ |
52 ICU(StoreCallbackProperty) \ | 53 ICU(StoreCallbackProperty) \ |
53 ICU(LoadPropertyWithInterceptorOnly) \ | 54 ICU(LoadPropertyWithInterceptorOnly) \ |
54 ICU(LoadPropertyWithInterceptorForLoad) \ | 55 ICU(LoadPropertyWithInterceptorForLoad) \ |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 static void Clear(Isolate* isolate, Address address); | 105 static void Clear(Isolate* isolate, Address address); |
105 | 106 |
106 #ifdef DEBUG | 107 #ifdef DEBUG |
107 bool IsLoadStub() const { | 108 bool IsLoadStub() const { |
108 return target()->is_load_stub() || target()->is_keyed_load_stub(); | 109 return target()->is_load_stub() || target()->is_keyed_load_stub(); |
109 } | 110 } |
110 | 111 |
111 bool IsStoreStub() const { | 112 bool IsStoreStub() const { |
112 return target()->is_store_stub() || target()->is_keyed_store_stub(); | 113 return target()->is_store_stub() || target()->is_keyed_store_stub(); |
113 } | 114 } |
115 | |
116 bool IsCallStub() const { | |
117 return target()->is_call_stub(); | |
118 } | |
114 #endif | 119 #endif |
115 | 120 |
116 // Determines which map must be used for keeping the code stub. | 121 // Determines which map must be used for keeping the code stub. |
117 // These methods should not be called with undefined or null. | 122 // These methods should not be called with undefined or null. |
118 static inline InlineCacheHolderFlag GetCodeCacheForObject(Object* object); | 123 static inline InlineCacheHolderFlag GetCodeCacheForObject(Object* object); |
119 // TODO(verwaest): This currently returns a HeapObject rather than JSObject* | 124 // TODO(verwaest): This currently returns a HeapObject rather than JSObject* |
120 // since loading the IC for loading the length from strings are stored on | 125 // since loading the IC for loading the length from strings are stored on |
121 // the string map directly, rather than on the JSObject-typed prototype. | 126 // the string map directly, rather than on the JSObject-typed prototype. |
122 static inline HeapObject* GetCodeCacheHolder(Isolate* isolate, | 127 static inline HeapObject* GetCodeCacheHolder(Isolate* isolate, |
123 Object* object, | 128 Object* object, |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
273 | 278 |
274 Address address() const { return address_; } | 279 Address address() const { return address_; } |
275 | 280 |
276 IC::UtilityId id() const { return id_; } | 281 IC::UtilityId id() const { return id_; } |
277 private: | 282 private: |
278 Address address_; | 283 Address address_; |
279 IC::UtilityId id_; | 284 IC::UtilityId id_; |
280 }; | 285 }; |
281 | 286 |
282 | 287 |
288 class CallIC: public IC { | |
289 public: | |
290 class State V8_FINAL BASE_EMBEDDED { | |
291 public: | |
292 explicit State(ExtraICState extra_ic_state); | |
293 | |
294 State(int argc, | |
295 bool call_as_method, | |
296 bool monomorphic = false, | |
297 bool args_match = true, | |
298 bool strict_native = false) | |
299 : argc_(argc), | |
300 call_as_method_(call_as_method), | |
301 monomorphic_(monomorphic), | |
302 args_match_(args_match), | |
303 strict_native_(strict_native) { | |
304 } | |
305 | |
306 InlineCacheState GetICState() const { | |
307 return monomorphic_ | |
308 ? ::v8::internal::MONOMORPHIC | |
309 : ::v8::internal::GENERIC; | |
310 } | |
311 | |
312 ExtraICState GetExtraICState() const; | |
313 | |
314 static int ExtractArgcFromMinorKey(int minor_key) { | |
Toon Verwaest
2014/03/10 13:50:44
minor key -> ExtraICState? Only code stubs have ma
| |
315 return ArgBits::decode(minor_key); | |
316 } | |
317 | |
318 static void GenerateAheadOfTime( | |
319 Isolate*, void (*Generate)(Isolate*, const State&)); | |
320 | |
321 int arg_count() const { return argc_; } | |
322 bool call_as_method() const { return call_as_method_; } | |
323 bool monomorphic() const { return monomorphic_; } | |
324 bool args_match() const { return args_match_; } | |
325 bool strict_native() const { return strict_native_; } | |
326 | |
327 void Print(StringStream* stream) const; | |
328 | |
329 private: | |
330 STATIC_ASSERT(Code::kArgumentsBits == 16); | |
Toon Verwaest
2014/03/10 13:50:44
What about just using kArgumentsBits in the counts
mvstanton
2014/03/20 15:51:53
Done.
| |
331 class ArgBits: public BitField<int, 0, 16> {}; | |
332 class CallAsMethodBits: public BitField<bool, 16, 1> {}; | |
333 class MonomorphicBits: public BitField<bool, 17, 1> {}; | |
334 class ArgsMatchBits: public BitField<bool, 18, 1> {}; | |
335 class StrictNativeBits: public BitField<bool, 19, 1> {}; | |
336 // We have a few extra bits. | |
Toon Verwaest
2014/03/10 13:50:44
Not sure how many you have left. Aren't these enco
mvstanton
2014/03/20 15:51:53
Old comment, removed.
| |
337 | |
338 int argc_; | |
339 bool call_as_method_; | |
340 bool monomorphic_; | |
341 bool args_match_; | |
342 bool strict_native_; | |
343 }; | |
344 | |
345 explicit CallIC(Isolate* isolate) | |
346 : IC(EXTRA_CALL_FRAME, isolate) { | |
347 } | |
348 | |
349 void HandleMiss(Handle<Object> receiver, | |
350 Handle<Object> function, | |
351 Handle<FixedArray> vector, | |
352 Handle<Smi> slot); | |
353 | |
354 // Code generator routines. | |
355 static void GenerateNormal(MacroAssembler* masm, int argc, | |
356 bool call_as_method); | |
357 static Handle<Code> initialize_stub(Isolate* isolate, | |
358 int argc, | |
359 bool call_as_method); | |
360 | |
361 static void Clear(Address address, Code* target); | |
362 | |
363 private: | |
364 void PatchMegamorphic(int arg_count, bool call_as_method); | |
365 }; | |
366 | |
367 | |
283 class LoadIC: public IC { | 368 class LoadIC: public IC { |
284 public: | 369 public: |
285 // ExtraICState bits | 370 // ExtraICState bits |
286 class ContextualModeBits: public BitField<ContextualMode, 0, 1> {}; | 371 class ContextualModeBits: public BitField<ContextualMode, 0, 1> {}; |
287 STATIC_ASSERT(static_cast<int>(NOT_CONTEXTUAL) == 0); | 372 STATIC_ASSERT(static_cast<int>(NOT_CONTEXTUAL) == 0); |
288 | 373 |
289 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode) { | 374 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode) { |
290 return ContextualModeBits::encode(contextual_mode); | 375 return ContextualModeBits::encode(contextual_mode); |
291 } | 376 } |
292 | 377 |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
890 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss); | 975 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss); |
891 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss); | 976 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss); |
892 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_MissWithAllocationSite); | 977 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_MissWithAllocationSite); |
893 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss); | 978 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss); |
894 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss); | 979 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss); |
895 | 980 |
896 | 981 |
897 } } // namespace v8::internal | 982 } } // namespace v8::internal |
898 | 983 |
899 #endif // V8_IC_H_ | 984 #endif // V8_IC_H_ |
OLD | NEW |