OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_TYPE_FEEDBACK_VECTOR_H_ | 5 #ifndef V8_TYPE_FEEDBACK_VECTOR_H_ |
6 #define V8_TYPE_FEEDBACK_VECTOR_H_ | 6 #define V8_TYPE_FEEDBACK_VECTOR_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "src/base/logging.h" | 10 #include "src/base/logging.h" |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 ExtractMaps(&maps); | 405 ExtractMaps(&maps); |
406 if (maps.length() > 0) return *maps.at(0); | 406 if (maps.length() > 0) return *maps.at(0); |
407 return NULL; | 407 return NULL; |
408 } | 408 } |
409 | 409 |
410 // TODO(mvstanton): remove FindAllMaps, it didn't survive a code review. | 410 // TODO(mvstanton): remove FindAllMaps, it didn't survive a code review. |
411 void FindAllMaps(MapHandleList* maps) const { ExtractMaps(maps); } | 411 void FindAllMaps(MapHandleList* maps) const { ExtractMaps(maps); } |
412 | 412 |
413 virtual InlineCacheState StateFromFeedback() const = 0; | 413 virtual InlineCacheState StateFromFeedback() const = 0; |
414 virtual int ExtractMaps(MapHandleList* maps) const; | 414 virtual int ExtractMaps(MapHandleList* maps) const; |
415 virtual MaybeHandle<Code> FindHandlerForMap(Handle<Map> map) const; | 415 virtual MaybeHandle<Object> FindHandlerForMap(Handle<Map> map) const; |
416 virtual bool FindHandlers(CodeHandleList* code_list, int length = -1) const; | 416 virtual bool FindHandlers(List<Handle<Object>>* code_list, |
| 417 int length = -1) const; |
417 virtual Name* FindFirstName() const { return NULL; } | 418 virtual Name* FindFirstName() const { return NULL; } |
418 | 419 |
419 virtual void ConfigureUninitialized(); | 420 virtual void ConfigureUninitialized(); |
420 virtual void ConfigurePremonomorphic(); | 421 virtual void ConfigurePremonomorphic(); |
421 virtual void ConfigureMegamorphic(); | 422 virtual void ConfigureMegamorphic(); |
422 | 423 |
423 inline Object* GetFeedback() const; | 424 inline Object* GetFeedback() const; |
424 inline Object* GetFeedbackExtra() const; | 425 inline Object* GetFeedbackExtra() const; |
425 | 426 |
426 inline Isolate* GetIsolate() const; | 427 inline Isolate* GetIsolate() const; |
427 | 428 |
428 protected: | 429 protected: |
429 inline void SetFeedback(Object* feedback, | 430 inline void SetFeedback(Object* feedback, |
430 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | 431 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
431 inline void SetFeedbackExtra(Object* feedback_extra, | 432 inline void SetFeedbackExtra(Object* feedback_extra, |
432 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | 433 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
433 | 434 |
434 Handle<FixedArray> EnsureArrayOfSize(int length); | 435 Handle<FixedArray> EnsureArrayOfSize(int length); |
435 Handle<FixedArray> EnsureExtraArrayOfSize(int length); | 436 Handle<FixedArray> EnsureExtraArrayOfSize(int length); |
436 void InstallHandlers(Handle<FixedArray> array, MapHandleList* maps, | 437 void InstallHandlers(Handle<FixedArray> array, MapHandleList* maps, |
437 CodeHandleList* handlers); | 438 List<Handle<Object>>* handlers); |
438 | 439 |
439 private: | 440 private: |
440 // The reason for having a vector handle and a raw pointer is that we can and | 441 // The reason for having a vector handle and a raw pointer is that we can and |
441 // should use handles during IC miss, but not during GC when we clear ICs. If | 442 // should use handles during IC miss, but not during GC when we clear ICs. If |
442 // you have a handle to the vector that is better because more operations can | 443 // you have a handle to the vector that is better because more operations can |
443 // be done, like allocation. | 444 // be done, like allocation. |
444 Handle<TypeFeedbackVector> vector_handle_; | 445 Handle<TypeFeedbackVector> vector_handle_; |
445 TypeFeedbackVector* vector_; | 446 TypeFeedbackVector* vector_; |
446 FeedbackVectorSlot slot_; | 447 FeedbackVectorSlot slot_; |
447 }; | 448 }; |
(...skipping 16 matching lines...) Expand all Loading... |
464 void ConfigureMonomorphic(Handle<JSFunction> function); | 465 void ConfigureMonomorphic(Handle<JSFunction> function); |
465 void ConfigureMegamorphic() final; | 466 void ConfigureMegamorphic() final; |
466 void ConfigureMegamorphic(int call_count); | 467 void ConfigureMegamorphic(int call_count); |
467 | 468 |
468 InlineCacheState StateFromFeedback() const final; | 469 InlineCacheState StateFromFeedback() const final; |
469 | 470 |
470 int ExtractMaps(MapHandleList* maps) const final { | 471 int ExtractMaps(MapHandleList* maps) const final { |
471 // CallICs don't record map feedback. | 472 // CallICs don't record map feedback. |
472 return 0; | 473 return 0; |
473 } | 474 } |
474 MaybeHandle<Code> FindHandlerForMap(Handle<Map> map) const final { | 475 MaybeHandle<Object> FindHandlerForMap(Handle<Map> map) const final { |
475 return MaybeHandle<Code>(); | 476 return MaybeHandle<Code>(); |
476 } | 477 } |
477 bool FindHandlers(CodeHandleList* code_list, int length = -1) const final { | 478 bool FindHandlers(List<Handle<Object>>* code_list, |
| 479 int length = -1) const final { |
478 return length == 0; | 480 return length == 0; |
479 } | 481 } |
480 | 482 |
481 int ExtractCallCount(); | 483 int ExtractCallCount(); |
482 }; | 484 }; |
483 | 485 |
484 | 486 |
485 class LoadICNexus : public FeedbackNexus { | 487 class LoadICNexus : public FeedbackNexus { |
486 public: | 488 public: |
487 LoadICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot) | 489 LoadICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot) |
488 : FeedbackNexus(vector, slot) { | 490 : FeedbackNexus(vector, slot) { |
489 DCHECK_EQ(FeedbackVectorSlotKind::LOAD_IC, vector->GetKind(slot)); | 491 DCHECK_EQ(FeedbackVectorSlotKind::LOAD_IC, vector->GetKind(slot)); |
490 } | 492 } |
491 explicit LoadICNexus(Isolate* isolate) | 493 explicit LoadICNexus(Isolate* isolate) |
492 : FeedbackNexus( | 494 : FeedbackNexus( |
493 TypeFeedbackVector::DummyVector(isolate), | 495 TypeFeedbackVector::DummyVector(isolate), |
494 FeedbackVectorSlot(TypeFeedbackVector::kDummyLoadICSlot)) {} | 496 FeedbackVectorSlot(TypeFeedbackVector::kDummyLoadICSlot)) {} |
495 LoadICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot) | 497 LoadICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot) |
496 : FeedbackNexus(vector, slot) { | 498 : FeedbackNexus(vector, slot) { |
497 DCHECK_EQ(FeedbackVectorSlotKind::LOAD_IC, vector->GetKind(slot)); | 499 DCHECK_EQ(FeedbackVectorSlotKind::LOAD_IC, vector->GetKind(slot)); |
498 } | 500 } |
499 | 501 |
500 void Clear(Code* host); | 502 void Clear(Code* host); |
501 | 503 |
502 void ConfigureMonomorphic(Handle<Map> receiver_map, Handle<Code> handler); | 504 void ConfigureMonomorphic(Handle<Map> receiver_map, Handle<Object> handler); |
503 | 505 |
504 void ConfigurePolymorphic(MapHandleList* maps, CodeHandleList* handlers); | 506 void ConfigurePolymorphic(MapHandleList* maps, |
| 507 List<Handle<Object>>* handlers); |
505 | 508 |
506 InlineCacheState StateFromFeedback() const override; | 509 InlineCacheState StateFromFeedback() const override; |
507 }; | 510 }; |
508 | 511 |
509 class LoadGlobalICNexus : public FeedbackNexus { | 512 class LoadGlobalICNexus : public FeedbackNexus { |
510 public: | 513 public: |
511 LoadGlobalICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot) | 514 LoadGlobalICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot) |
512 : FeedbackNexus(vector, slot) { | 515 : FeedbackNexus(vector, slot) { |
513 DCHECK_EQ(FeedbackVectorSlotKind::LOAD_GLOBAL_IC, vector->GetKind(slot)); | 516 DCHECK_EQ(FeedbackVectorSlotKind::LOAD_GLOBAL_IC, vector->GetKind(slot)); |
514 } | 517 } |
515 LoadGlobalICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot) | 518 LoadGlobalICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot) |
516 : FeedbackNexus(vector, slot) { | 519 : FeedbackNexus(vector, slot) { |
517 DCHECK_EQ(FeedbackVectorSlotKind::LOAD_GLOBAL_IC, vector->GetKind(slot)); | 520 DCHECK_EQ(FeedbackVectorSlotKind::LOAD_GLOBAL_IC, vector->GetKind(slot)); |
518 } | 521 } |
519 | 522 |
520 int ExtractMaps(MapHandleList* maps) const final { | 523 int ExtractMaps(MapHandleList* maps) const final { |
521 // LoadGlobalICs don't record map feedback. | 524 // LoadGlobalICs don't record map feedback. |
522 return 0; | 525 return 0; |
523 } | 526 } |
524 MaybeHandle<Code> FindHandlerForMap(Handle<Map> map) const final { | 527 MaybeHandle<Object> FindHandlerForMap(Handle<Map> map) const final { |
525 return MaybeHandle<Code>(); | 528 return MaybeHandle<Code>(); |
526 } | 529 } |
527 bool FindHandlers(CodeHandleList* code_list, int length = -1) const final { | 530 bool FindHandlers(List<Handle<Object>>* code_list, |
| 531 int length = -1) const final { |
528 return length == 0; | 532 return length == 0; |
529 } | 533 } |
530 | 534 |
531 void ConfigureMegamorphic() override { UNREACHABLE(); } | 535 void ConfigureMegamorphic() override { UNREACHABLE(); } |
532 void Clear(Code* host); | 536 void Clear(Code* host); |
533 | 537 |
534 void ConfigureUninitialized() override; | 538 void ConfigureUninitialized() override; |
535 void ConfigurePropertyCellMode(Handle<PropertyCell> cell); | 539 void ConfigurePropertyCellMode(Handle<PropertyCell> cell); |
536 void ConfigureHandlerMode(Handle<Code> handler); | 540 void ConfigureHandlerMode(Handle<Code> handler); |
537 | 541 |
(...skipping 11 matching lines...) Expand all Loading... |
549 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC, vector->GetKind(slot)); | 553 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC, vector->GetKind(slot)); |
550 } | 554 } |
551 | 555 |
552 void Clear(Code* host); | 556 void Clear(Code* host); |
553 | 557 |
554 // name can be a null handle for element loads. | 558 // name can be a null handle for element loads. |
555 void ConfigureMonomorphic(Handle<Name> name, Handle<Map> receiver_map, | 559 void ConfigureMonomorphic(Handle<Name> name, Handle<Map> receiver_map, |
556 Handle<Code> handler); | 560 Handle<Code> handler); |
557 // name can be null. | 561 // name can be null. |
558 void ConfigurePolymorphic(Handle<Name> name, MapHandleList* maps, | 562 void ConfigurePolymorphic(Handle<Name> name, MapHandleList* maps, |
559 CodeHandleList* handlers); | 563 List<Handle<Object>>* handlers); |
560 | 564 |
561 void ConfigureMegamorphicKeyed(IcCheckType property_type); | 565 void ConfigureMegamorphicKeyed(IcCheckType property_type); |
562 | 566 |
563 IcCheckType GetKeyType() const; | 567 IcCheckType GetKeyType() const; |
564 InlineCacheState StateFromFeedback() const override; | 568 InlineCacheState StateFromFeedback() const override; |
565 Name* FindFirstName() const override; | 569 Name* FindFirstName() const override; |
566 }; | 570 }; |
567 | 571 |
568 | 572 |
569 class StoreICNexus : public FeedbackNexus { | 573 class StoreICNexus : public FeedbackNexus { |
570 public: | 574 public: |
571 StoreICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot) | 575 StoreICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot) |
572 : FeedbackNexus(vector, slot) { | 576 : FeedbackNexus(vector, slot) { |
573 DCHECK_EQ(FeedbackVectorSlotKind::STORE_IC, vector->GetKind(slot)); | 577 DCHECK_EQ(FeedbackVectorSlotKind::STORE_IC, vector->GetKind(slot)); |
574 } | 578 } |
575 explicit StoreICNexus(Isolate* isolate) | 579 explicit StoreICNexus(Isolate* isolate) |
576 : FeedbackNexus( | 580 : FeedbackNexus( |
577 TypeFeedbackVector::DummyVector(isolate), | 581 TypeFeedbackVector::DummyVector(isolate), |
578 FeedbackVectorSlot(TypeFeedbackVector::kDummyStoreICSlot)) {} | 582 FeedbackVectorSlot(TypeFeedbackVector::kDummyStoreICSlot)) {} |
579 StoreICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot) | 583 StoreICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot) |
580 : FeedbackNexus(vector, slot) { | 584 : FeedbackNexus(vector, slot) { |
581 DCHECK_EQ(FeedbackVectorSlotKind::STORE_IC, vector->GetKind(slot)); | 585 DCHECK_EQ(FeedbackVectorSlotKind::STORE_IC, vector->GetKind(slot)); |
582 } | 586 } |
583 | 587 |
584 void Clear(Code* host); | 588 void Clear(Code* host); |
585 | 589 |
586 void ConfigureMonomorphic(Handle<Map> receiver_map, Handle<Code> handler); | 590 void ConfigureMonomorphic(Handle<Map> receiver_map, Handle<Code> handler); |
587 | 591 |
588 void ConfigurePolymorphic(MapHandleList* maps, CodeHandleList* handlers); | 592 void ConfigurePolymorphic(MapHandleList* maps, |
| 593 List<Handle<Object>>* handlers); |
589 | 594 |
590 InlineCacheState StateFromFeedback() const override; | 595 InlineCacheState StateFromFeedback() const override; |
591 }; | 596 }; |
592 | 597 |
593 | 598 |
594 class KeyedStoreICNexus : public FeedbackNexus { | 599 class KeyedStoreICNexus : public FeedbackNexus { |
595 public: | 600 public: |
596 KeyedStoreICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot) | 601 KeyedStoreICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot) |
597 : FeedbackNexus(vector, slot) { | 602 : FeedbackNexus(vector, slot) { |
598 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_STORE_IC, vector->GetKind(slot)); | 603 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_STORE_IC, vector->GetKind(slot)); |
599 } | 604 } |
600 explicit KeyedStoreICNexus(Isolate* isolate) | 605 explicit KeyedStoreICNexus(Isolate* isolate) |
601 : FeedbackNexus( | 606 : FeedbackNexus( |
602 TypeFeedbackVector::DummyVector(isolate), | 607 TypeFeedbackVector::DummyVector(isolate), |
603 FeedbackVectorSlot(TypeFeedbackVector::kDummyKeyedStoreICSlot)) {} | 608 FeedbackVectorSlot(TypeFeedbackVector::kDummyKeyedStoreICSlot)) {} |
604 KeyedStoreICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot) | 609 KeyedStoreICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot) |
605 : FeedbackNexus(vector, slot) { | 610 : FeedbackNexus(vector, slot) { |
606 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_STORE_IC, vector->GetKind(slot)); | 611 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_STORE_IC, vector->GetKind(slot)); |
607 } | 612 } |
608 | 613 |
609 void Clear(Code* host); | 614 void Clear(Code* host); |
610 | 615 |
611 // name can be a null handle for element loads. | 616 // name can be a null handle for element loads. |
612 void ConfigureMonomorphic(Handle<Name> name, Handle<Map> receiver_map, | 617 void ConfigureMonomorphic(Handle<Name> name, Handle<Map> receiver_map, |
613 Handle<Code> handler); | 618 Handle<Code> handler); |
614 // name can be null. | 619 // name can be null. |
615 void ConfigurePolymorphic(Handle<Name> name, MapHandleList* maps, | 620 void ConfigurePolymorphic(Handle<Name> name, MapHandleList* maps, |
616 CodeHandleList* handlers); | 621 List<Handle<Object>>* handlers); |
617 void ConfigurePolymorphic(MapHandleList* maps, | 622 void ConfigurePolymorphic(MapHandleList* maps, |
618 MapHandleList* transitioned_maps, | 623 MapHandleList* transitioned_maps, |
619 CodeHandleList* handlers); | 624 CodeHandleList* handlers); |
620 void ConfigureMegamorphicKeyed(IcCheckType property_type); | 625 void ConfigureMegamorphicKeyed(IcCheckType property_type); |
621 | 626 |
622 KeyedAccessStoreMode GetKeyedAccessStoreMode() const; | 627 KeyedAccessStoreMode GetKeyedAccessStoreMode() const; |
623 IcCheckType GetKeyType() const; | 628 IcCheckType GetKeyType() const; |
624 | 629 |
625 InlineCacheState StateFromFeedback() const override; | 630 InlineCacheState StateFromFeedback() const override; |
626 Name* FindFirstName() const override; | 631 Name* FindFirstName() const override; |
627 }; | 632 }; |
628 } // namespace internal | 633 } // namespace internal |
629 } // namespace v8 | 634 } // namespace v8 |
630 | 635 |
631 #endif // V8_TRANSITIONS_H_ | 636 #endif // V8_TRANSITIONS_H_ |
OLD | NEW |