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 enum CallType { METHOD, FUNCTION }; |
| 291 enum StubType { GENERIC, MONOMORPHIC }; |
| 292 enum ArgumentCheck { ARGUMENTS_MATCH, ARGUMENTS_DONT_MATCH }; |
| 293 enum FunctionAttributes { NOT_STRICT_OR_NATIVE, STRICT_OR_NATIVE }; |
| 294 |
| 295 class State V8_FINAL BASE_EMBEDDED { |
| 296 public: |
| 297 explicit State(ExtraICState extra_ic_state); |
| 298 |
| 299 State(int argc, |
| 300 CallType call_type, |
| 301 StubType stub_type = GENERIC, |
| 302 ArgumentCheck argument_check = ARGUMENTS_MATCH, |
| 303 FunctionAttributes attributes = NOT_STRICT_OR_NATIVE) |
| 304 : argc_(argc), |
| 305 call_type_(call_type), |
| 306 stub_type_(stub_type), |
| 307 argument_check_(argument_check), |
| 308 function_attributes_(attributes) { |
| 309 } |
| 310 |
| 311 InlineCacheState GetICState() const { |
| 312 return stub_type_ == CallIC::MONOMORPHIC |
| 313 ? ::v8::internal::MONOMORPHIC |
| 314 : ::v8::internal::GENERIC; |
| 315 } |
| 316 |
| 317 ExtraICState GetExtraICState() const; |
| 318 |
| 319 static void GenerateAheadOfTime( |
| 320 Isolate*, void (*Generate)(Isolate*, const State&)); |
| 321 |
| 322 int arg_count() const { return argc_; } |
| 323 |
| 324 CallType call_type() const { return call_type_; } |
| 325 StubType stub_type() const { return stub_type_; } |
| 326 ArgumentCheck argument_check() const { return argument_check_; } |
| 327 FunctionAttributes function_attributes() const { |
| 328 return function_attributes_; |
| 329 } |
| 330 |
| 331 void Print(StringStream* stream) const; |
| 332 |
| 333 private: |
| 334 class ArgBits: public BitField<int, 0, Code::kArgumentsBits> {}; |
| 335 class CallTypeBits: public BitField<CallType, Code::kArgumentsBits, 1> {}; |
| 336 class StubTypeBits: |
| 337 public BitField<StubType, Code::kArgumentsBits + 1, 1> {}; // NOLINT |
| 338 class ArgumentCheckBits: |
| 339 public BitField<ArgumentCheck, |
| 340 Code::kArgumentsBits + 2, 1> {}; // NOLINT |
| 341 class FunctionAttributeBits: |
| 342 public BitField<FunctionAttributes, |
| 343 Code::kArgumentsBits + 3, 1> {}; // NOLINT |
| 344 |
| 345 int argc_; |
| 346 CallType call_type_; |
| 347 StubType stub_type_; |
| 348 ArgumentCheck argument_check_; |
| 349 FunctionAttributes function_attributes_; |
| 350 }; |
| 351 |
| 352 explicit CallIC(Isolate* isolate) |
| 353 : IC(EXTRA_CALL_FRAME, isolate) { |
| 354 } |
| 355 |
| 356 void HandleMiss(Handle<Object> receiver, |
| 357 Handle<Object> function, |
| 358 Handle<FixedArray> vector, |
| 359 Handle<Smi> slot); |
| 360 |
| 361 // Code generator routines. |
| 362 static void GenerateNormal(MacroAssembler* masm, int argc, |
| 363 CallType call_type); |
| 364 static Handle<Code> initialize_stub(Isolate* isolate, |
| 365 int argc, |
| 366 CallType call_type); |
| 367 |
| 368 static void Clear(Isolate* isolate, Address address, Code* target); |
| 369 |
| 370 private: |
| 371 void PatchMegamorphic(int arg_count, CallType call_type); |
| 372 }; |
| 373 |
| 374 |
283 class LoadIC: public IC { | 375 class LoadIC: public IC { |
284 public: | 376 public: |
285 // ExtraICState bits | 377 // ExtraICState bits |
286 class ContextualModeBits: public BitField<ContextualMode, 0, 1> {}; | 378 class ContextualModeBits: public BitField<ContextualMode, 0, 1> {}; |
287 STATIC_ASSERT(static_cast<int>(NOT_CONTEXTUAL) == 0); | 379 STATIC_ASSERT(static_cast<int>(NOT_CONTEXTUAL) == 0); |
288 | 380 |
289 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode) { | 381 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode) { |
290 return ContextualModeBits::encode(contextual_mode); | 382 return ContextualModeBits::encode(contextual_mode); |
291 } | 383 } |
292 | 384 |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss); | 982 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss); |
891 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss); | 983 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss); |
892 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_MissWithAllocationSite); | 984 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_MissWithAllocationSite); |
893 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss); | 985 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss); |
894 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss); | 986 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss); |
895 | 987 |
896 | 988 |
897 } } // namespace v8::internal | 989 } } // namespace v8::internal |
898 | 990 |
899 #endif // V8_IC_H_ | 991 #endif // V8_IC_H_ |
OLD | NEW |