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) \ | |
46 ICU(StoreIC_Miss) \ | 45 ICU(StoreIC_Miss) \ |
47 ICU(StoreIC_ArrayLength) \ | 46 ICU(StoreIC_ArrayLength) \ |
48 ICU(StoreIC_Slow) \ | 47 ICU(StoreIC_Slow) \ |
49 ICU(SharedStoreIC_ExtendStorage) \ | 48 ICU(SharedStoreIC_ExtendStorage) \ |
50 ICU(KeyedStoreIC_Miss) \ | 49 ICU(KeyedStoreIC_Miss) \ |
51 ICU(KeyedStoreIC_Slow) \ | 50 ICU(KeyedStoreIC_Slow) \ |
52 /* Utilities for IC stubs. */ \ | 51 /* Utilities for IC stubs. */ \ |
53 ICU(StoreCallbackProperty) \ | 52 ICU(StoreCallbackProperty) \ |
54 ICU(LoadPropertyWithInterceptorOnly) \ | 53 ICU(LoadPropertyWithInterceptorOnly) \ |
55 ICU(LoadPropertyWithInterceptorForLoad) \ | 54 ICU(LoadPropertyWithInterceptorForLoad) \ |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 ConstantPoolArray* constant_pool); | 112 ConstantPoolArray* constant_pool); |
114 | 113 |
115 #ifdef DEBUG | 114 #ifdef DEBUG |
116 bool IsLoadStub() const { | 115 bool IsLoadStub() const { |
117 return target()->is_load_stub() || target()->is_keyed_load_stub(); | 116 return target()->is_load_stub() || target()->is_keyed_load_stub(); |
118 } | 117 } |
119 | 118 |
120 bool IsStoreStub() const { | 119 bool IsStoreStub() const { |
121 return target()->is_store_stub() || target()->is_keyed_store_stub(); | 120 return target()->is_store_stub() || target()->is_keyed_store_stub(); |
122 } | 121 } |
123 | |
124 bool IsCallStub() const { | |
125 return target()->is_call_stub(); | |
126 } | |
127 #endif | 122 #endif |
128 | 123 |
129 // Determines which map must be used for keeping the code stub. | 124 // Determines which map must be used for keeping the code stub. |
130 // These methods should not be called with undefined or null. | 125 // These methods should not be called with undefined or null. |
131 static inline InlineCacheHolderFlag GetCodeCacheForObject(Object* object); | 126 static inline InlineCacheHolderFlag GetCodeCacheForObject(Object* object); |
132 // TODO(verwaest): This currently returns a HeapObject rather than JSObject* | 127 // TODO(verwaest): This currently returns a HeapObject rather than JSObject* |
133 // since loading the IC for loading the length from strings are stored on | 128 // since loading the IC for loading the length from strings are stored on |
134 // the string map directly, rather than on the JSObject-typed prototype. | 129 // the string map directly, rather than on the JSObject-typed prototype. |
135 static inline HeapObject* GetCodeCacheHolder(Isolate* isolate, | 130 static inline HeapObject* GetCodeCacheHolder(Isolate* isolate, |
136 Object* object, | 131 Object* object, |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 | 332 |
338 Address address() const { return address_; } | 333 Address address() const { return address_; } |
339 | 334 |
340 IC::UtilityId id() const { return id_; } | 335 IC::UtilityId id() const { return id_; } |
341 private: | 336 private: |
342 Address address_; | 337 Address address_; |
343 IC::UtilityId id_; | 338 IC::UtilityId id_; |
344 }; | 339 }; |
345 | 340 |
346 | 341 |
347 class CallIC: public IC { | |
348 public: | |
349 enum CallType { METHOD, FUNCTION }; | |
350 enum StubType { DEFAULT, MONOMORPHIC }; | |
351 enum ArgumentCheck { ARGUMENTS_MUST_MATCH, ARGUMENTS_COUNT_UNKNOWN }; | |
352 | |
353 class State V8_FINAL BASE_EMBEDDED { | |
354 public: | |
355 explicit State(ExtraICState extra_ic_state); | |
356 | |
357 static State MonomorphicCallState(int argc, CallType call_type, | |
358 ArgumentCheck argument_check, | |
359 StrictMode strict_mode) { | |
360 return State(argc, call_type, MONOMORPHIC, argument_check, strict_mode); | |
361 } | |
362 | |
363 static State SlowCallState(int argc, CallType call_type) { | |
364 return State(argc, call_type, DEFAULT, ARGUMENTS_COUNT_UNKNOWN, | |
365 SLOPPY); | |
366 } | |
367 | |
368 static State DefaultCallState(int argc, CallType call_type) { | |
369 return State(argc, call_type, DEFAULT, ARGUMENTS_MUST_MATCH, | |
370 SLOPPY); | |
371 } | |
372 | |
373 // Transition from the current state to another. | |
374 State ToGenericState(); | |
375 State ToMonomorphicState(Handle<JSFunction> function); | |
376 | |
377 InlineCacheState GetICState() const { | |
378 return stub_type_ == CallIC::MONOMORPHIC | |
379 ? ::v8::internal::MONOMORPHIC | |
380 : ::v8::internal::GENERIC; | |
381 } | |
382 | |
383 ExtraICState GetExtraICState() const; | |
384 | |
385 static void GenerateAheadOfTime( | |
386 Isolate*, void (*Generate)(Isolate*, const State&)); | |
387 | |
388 int arg_count() const { return argc_; } | |
389 CallType call_type() const { return call_type_; } | |
390 StubType stub_type() const { return stub_type_; } | |
391 ArgumentCheck argument_check() const { return argument_check_; } | |
392 StrictMode strict_mode() const { | |
393 return strict_mode_; | |
394 } | |
395 | |
396 bool ArgumentsMustMatch() const { | |
397 return argument_check_ == ARGUMENTS_MUST_MATCH; | |
398 } | |
399 bool IsGeneric() const { return stub_type_ == DEFAULT; } | |
400 bool CallAsMethod() const { return call_type_ == METHOD; } | |
401 bool IsSloppy() const { | |
402 return strict_mode_ == SLOPPY; | |
403 } | |
404 | |
405 void Print(StringStream* stream) const; | |
406 | |
407 bool operator==(const State& other_state) const { | |
408 return (argc_ == other_state.argc_ && | |
409 call_type_ == other_state.call_type_ && | |
410 stub_type_ == other_state.stub_type_ && | |
411 argument_check_ == other_state.argument_check_ && | |
412 strict_mode_ == other_state.strict_mode_); | |
413 } | |
414 | |
415 bool operator!=(const State& other_state) const { | |
416 return !(*this == other_state); | |
417 } | |
418 | |
419 private: | |
420 State(int argc, | |
421 CallType call_type, | |
422 StubType stub_type, | |
423 ArgumentCheck argument_check, | |
424 StrictMode strict_mode) | |
425 : argc_(argc), | |
426 call_type_(call_type), | |
427 stub_type_(stub_type), | |
428 argument_check_(argument_check), | |
429 strict_mode_(strict_mode) { | |
430 } | |
431 | |
432 class ArgcBits: public BitField<int, 0, Code::kArgumentsBits> {}; | |
433 class CallTypeBits: public BitField<CallType, Code::kArgumentsBits, 1> {}; | |
434 class StubTypeBits: | |
435 public BitField<StubType, Code::kArgumentsBits + 1, 1> {}; // NOLINT | |
436 class ArgumentCheckBits: | |
437 public BitField<ArgumentCheck, | |
438 Code::kArgumentsBits + 2, 1> {}; // NOLINT | |
439 class StrictModeBits: | |
440 public BitField<StrictMode, | |
441 Code::kArgumentsBits + 3, 1> {}; // NOLINT | |
442 | |
443 const int argc_; | |
444 const CallType call_type_; | |
445 const StubType stub_type_; | |
446 const ArgumentCheck argument_check_; | |
447 const StrictMode strict_mode_; | |
448 }; | |
449 | |
450 explicit CallIC(Isolate* isolate) | |
451 : IC(EXTRA_CALL_FRAME, isolate) { | |
452 } | |
453 | |
454 void HandleMiss(Handle<Object> receiver, | |
455 Handle<Object> function, | |
456 Handle<FixedArray> vector, | |
457 Handle<Smi> slot); | |
458 | |
459 // Code generator routines. | |
460 static Handle<Code> initialize_stub(Isolate* isolate, | |
461 int argc, | |
462 CallType call_type); | |
463 | |
464 static void Clear(Isolate* isolate, Address address, Code* target, | |
465 ConstantPoolArray* constant_pool); | |
466 }; | |
467 | |
468 | |
469 class LoadIC: public IC { | 342 class LoadIC: public IC { |
470 public: | 343 public: |
471 // ExtraICState bits | 344 // ExtraICState bits |
472 class ContextualModeBits: public BitField<ContextualMode, 0, 1> {}; | 345 class ContextualModeBits: public BitField<ContextualMode, 0, 1> {}; |
473 STATIC_ASSERT(static_cast<int>(NOT_CONTEXTUAL) == 0); | 346 STATIC_ASSERT(static_cast<int>(NOT_CONTEXTUAL) == 0); |
474 | 347 |
475 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode) { | 348 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode) { |
476 return ContextualModeBits::encode(contextual_mode); | 349 return ContextualModeBits::encode(contextual_mode); |
477 } | 350 } |
478 | 351 |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1092 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss); | 965 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss); |
1093 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss); | 966 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss); |
1094 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_MissWithAllocationSite); | 967 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_MissWithAllocationSite); |
1095 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss); | 968 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss); |
1096 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss); | 969 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss); |
1097 | 970 |
1098 | 971 |
1099 } } // namespace v8::internal | 972 } } // namespace v8::internal |
1100 | 973 |
1101 #endif // V8_IC_H_ | 974 #endif // V8_IC_H_ |
OLD | NEW |