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

Side by Side Diff: src/type-feedback-vector.h

Issue 2662113005: [ic] Introduce IsXyzIC() predicates. (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
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 21 matching lines...) Expand all
32 INTERPRETER_COMPARE_IC, 32 INTERPRETER_COMPARE_IC,
33 STORE_DATA_PROPERTY_IN_LITERAL_IC, 33 STORE_DATA_PROPERTY_IN_LITERAL_IC,
34 CREATE_CLOSURE, 34 CREATE_CLOSURE,
35 LITERAL, 35 LITERAL,
36 // This is a general purpose slot that occupies one feedback vector element. 36 // This is a general purpose slot that occupies one feedback vector element.
37 GENERAL, 37 GENERAL,
38 38
39 KINDS_NUMBER // Last value indicating number of kinds. 39 KINDS_NUMBER // Last value indicating number of kinds.
40 }; 40 };
41 41
42 inline bool IsCallICKind(FeedbackVectorSlotKind kind) {
43 return kind == FeedbackVectorSlotKind::CALL_IC;
44 }
45
46 inline bool IsLoadICKind(FeedbackVectorSlotKind kind) {
47 return kind == FeedbackVectorSlotKind::LOAD_IC;
48 }
49
50 inline bool IsLoadGlobalICKind(FeedbackVectorSlotKind kind) {
51 return kind == FeedbackVectorSlotKind::LOAD_GLOBAL_IC;
52 }
53
54 inline bool IsKeyedLoadICKind(FeedbackVectorSlotKind kind) {
55 return kind == FeedbackVectorSlotKind::KEYED_LOAD_IC;
56 }
57
58 inline bool IsStoreICKind(FeedbackVectorSlotKind kind) {
59 return kind == FeedbackVectorSlotKind::STORE_IC;
60 }
61
62 inline bool IsKeyedStoreICKind(FeedbackVectorSlotKind kind) {
63 return kind == FeedbackVectorSlotKind::KEYED_STORE_IC;
64 }
65
42 std::ostream& operator<<(std::ostream& os, FeedbackVectorSlotKind kind); 66 std::ostream& operator<<(std::ostream& os, FeedbackVectorSlotKind kind);
43 67
44 68
45 template <typename Derived> 69 template <typename Derived>
46 class FeedbackVectorSpecBase { 70 class FeedbackVectorSpecBase {
47 public: 71 public:
48 inline FeedbackVectorSlot AddSlot(FeedbackVectorSlotKind kind); 72 inline FeedbackVectorSlot AddSlot(FeedbackVectorSlotKind kind);
49 73
50 FeedbackVectorSlot AddCallICSlot() { 74 FeedbackVectorSlot AddCallICSlot() {
51 return AddSlot(FeedbackVectorSlotKind::CALL_IC); 75 return AddSlot(FeedbackVectorSlotKind::CALL_IC);
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 276
253 // Returns slot kind for given slot. 277 // Returns slot kind for given slot.
254 FeedbackVectorSlotKind GetKind(FeedbackVectorSlot slot) const; 278 FeedbackVectorSlotKind GetKind(FeedbackVectorSlot slot) const;
255 279
256 static Handle<TypeFeedbackVector> New(Isolate* isolate, 280 static Handle<TypeFeedbackVector> New(Isolate* isolate,
257 Handle<TypeFeedbackMetadata> metadata); 281 Handle<TypeFeedbackMetadata> metadata);
258 282
259 static Handle<TypeFeedbackVector> Copy(Isolate* isolate, 283 static Handle<TypeFeedbackVector> Copy(Isolate* isolate,
260 Handle<TypeFeedbackVector> vector); 284 Handle<TypeFeedbackVector> vector);
261 285
286 #define DEFINE_SLOT_KIND_PREDICATE(Name) \
287 bool Name(FeedbackVectorSlot slot) const { return Name##Kind(GetKind(slot)); }
288
289 DEFINE_SLOT_KIND_PREDICATE(IsCallIC)
290 DEFINE_SLOT_KIND_PREDICATE(IsLoadIC)
291 DEFINE_SLOT_KIND_PREDICATE(IsLoadGlobalIC)
292 DEFINE_SLOT_KIND_PREDICATE(IsKeyedLoadIC)
293 DEFINE_SLOT_KIND_PREDICATE(IsStoreIC)
294 DEFINE_SLOT_KIND_PREDICATE(IsKeyedStoreIC)
295 #undef DEFINE_SLOT_KIND_PREDICATE
296
262 #ifdef OBJECT_PRINT 297 #ifdef OBJECT_PRINT
263 // For gdb debugging. 298 // For gdb debugging.
264 void Print(); 299 void Print();
265 #endif // OBJECT_PRINT 300 #endif // OBJECT_PRINT
266 301
267 DECLARE_PRINTER(TypeFeedbackVector) 302 DECLARE_PRINTER(TypeFeedbackVector)
268 303
269 // Clears the vector slots. 304 // Clears the vector slots.
270 void ClearSlots(SharedFunctionInfo* shared) { ClearSlotsImpl(shared, true); } 305 void ClearSlots(SharedFunctionInfo* shared) { ClearSlotsImpl(shared, true); }
271 306
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 virtual ~FeedbackNexus() {} 403 virtual ~FeedbackNexus() {}
369 404
370 Handle<TypeFeedbackVector> vector_handle() const { 405 Handle<TypeFeedbackVector> vector_handle() const {
371 DCHECK(vector_ == NULL); 406 DCHECK(vector_ == NULL);
372 return vector_handle_; 407 return vector_handle_;
373 } 408 }
374 TypeFeedbackVector* vector() const { 409 TypeFeedbackVector* vector() const {
375 return vector_handle_.is_null() ? vector_ : *vector_handle_; 410 return vector_handle_.is_null() ? vector_ : *vector_handle_;
376 } 411 }
377 FeedbackVectorSlot slot() const { return slot_; } 412 FeedbackVectorSlot slot() const { return slot_; }
413 FeedbackVectorSlotKind kind() const { return vector()->GetKind(slot()); }
378 414
379 InlineCacheState ic_state() const { return StateFromFeedback(); } 415 InlineCacheState ic_state() const { return StateFromFeedback(); }
380 bool IsUninitialized() const { return StateFromFeedback() == UNINITIALIZED; } 416 bool IsUninitialized() const { return StateFromFeedback() == UNINITIALIZED; }
381 Map* FindFirstMap() const { 417 Map* FindFirstMap() const {
382 MapHandleList maps; 418 MapHandleList maps;
383 ExtractMaps(&maps); 419 ExtractMaps(&maps);
384 if (maps.length() > 0) return *maps.at(0); 420 if (maps.length() > 0) return *maps.at(0);
385 return NULL; 421 return NULL;
386 } 422 }
387 423
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 Handle<TypeFeedbackVector> vector_handle_; 459 Handle<TypeFeedbackVector> vector_handle_;
424 TypeFeedbackVector* vector_; 460 TypeFeedbackVector* vector_;
425 FeedbackVectorSlot slot_; 461 FeedbackVectorSlot slot_;
426 }; 462 };
427 463
428 464
429 class CallICNexus final : public FeedbackNexus { 465 class CallICNexus final : public FeedbackNexus {
430 public: 466 public:
431 CallICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot) 467 CallICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot)
432 : FeedbackNexus(vector, slot) { 468 : FeedbackNexus(vector, slot) {
433 DCHECK_EQ(FeedbackVectorSlotKind::CALL_IC, vector->GetKind(slot)); 469 DCHECK(vector->IsCallIC(slot));
434 } 470 }
435 CallICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot) 471 CallICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot)
436 : FeedbackNexus(vector, slot) { 472 : FeedbackNexus(vector, slot) {
437 DCHECK_EQ(FeedbackVectorSlotKind::CALL_IC, vector->GetKind(slot)); 473 DCHECK(vector->IsCallIC(slot));
438 } 474 }
439 475
440 void Clear(Code* host); 476 void Clear(Code* host);
441 477
442 void ConfigureUninitialized() override; 478 void ConfigureUninitialized() override;
443 void ConfigureMonomorphicArray(); 479 void ConfigureMonomorphicArray();
444 void ConfigureMonomorphic(Handle<JSFunction> function); 480 void ConfigureMonomorphic(Handle<JSFunction> function);
445 void ConfigureMegamorphic() final; 481 void ConfigureMegamorphic() final;
446 void ConfigureMegamorphic(int call_count); 482 void ConfigureMegamorphic(int call_count);
447 483
(...skipping 16 matching lines...) Expand all
464 // Compute the call frequency based on the call count and the invocation 500 // Compute the call frequency based on the call count and the invocation
465 // count (taken from the type feedback vector). 501 // count (taken from the type feedback vector).
466 float ComputeCallFrequency(); 502 float ComputeCallFrequency();
467 }; 503 };
468 504
469 505
470 class LoadICNexus : public FeedbackNexus { 506 class LoadICNexus : public FeedbackNexus {
471 public: 507 public:
472 LoadICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot) 508 LoadICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot)
473 : FeedbackNexus(vector, slot) { 509 : FeedbackNexus(vector, slot) {
474 DCHECK_EQ(FeedbackVectorSlotKind::LOAD_IC, vector->GetKind(slot)); 510 DCHECK(vector->IsLoadIC(slot));
475 } 511 }
476 explicit LoadICNexus(Isolate* isolate) 512 explicit LoadICNexus(Isolate* isolate)
477 : FeedbackNexus( 513 : FeedbackNexus(
478 TypeFeedbackVector::DummyVector(isolate), 514 TypeFeedbackVector::DummyVector(isolate),
479 FeedbackVectorSlot(TypeFeedbackVector::kDummyLoadICSlot)) {} 515 FeedbackVectorSlot(TypeFeedbackVector::kDummyLoadICSlot)) {}
480 LoadICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot) 516 LoadICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot)
481 : FeedbackNexus(vector, slot) { 517 : FeedbackNexus(vector, slot) {
482 DCHECK_EQ(FeedbackVectorSlotKind::LOAD_IC, vector->GetKind(slot)); 518 DCHECK(vector->IsLoadIC(slot));
483 } 519 }
484 520
485 void Clear(Code* host); 521 void Clear(Code* host);
486 522
487 void ConfigureMonomorphic(Handle<Map> receiver_map, Handle<Object> handler); 523 void ConfigureMonomorphic(Handle<Map> receiver_map, Handle<Object> handler);
488 524
489 void ConfigurePolymorphic(MapHandleList* maps, 525 void ConfigurePolymorphic(MapHandleList* maps,
490 List<Handle<Object>>* handlers); 526 List<Handle<Object>>* handlers);
491 527
492 InlineCacheState StateFromFeedback() const override; 528 InlineCacheState StateFromFeedback() const override;
493 }; 529 };
494 530
495 class LoadGlobalICNexus : public FeedbackNexus { 531 class LoadGlobalICNexus : public FeedbackNexus {
496 public: 532 public:
497 LoadGlobalICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot) 533 LoadGlobalICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot)
498 : FeedbackNexus(vector, slot) { 534 : FeedbackNexus(vector, slot) {
499 DCHECK_EQ(FeedbackVectorSlotKind::LOAD_GLOBAL_IC, vector->GetKind(slot)); 535 DCHECK(vector->IsLoadGlobalIC(slot));
500 } 536 }
501 LoadGlobalICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot) 537 LoadGlobalICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot)
502 : FeedbackNexus(vector, slot) { 538 : FeedbackNexus(vector, slot) {
503 DCHECK_EQ(FeedbackVectorSlotKind::LOAD_GLOBAL_IC, vector->GetKind(slot)); 539 DCHECK(vector->IsLoadGlobalIC(slot));
504 } 540 }
505 541
506 int ExtractMaps(MapHandleList* maps) const final { 542 int ExtractMaps(MapHandleList* maps) const final {
507 // LoadGlobalICs don't record map feedback. 543 // LoadGlobalICs don't record map feedback.
508 return 0; 544 return 0;
509 } 545 }
510 MaybeHandle<Object> FindHandlerForMap(Handle<Map> map) const final { 546 MaybeHandle<Object> FindHandlerForMap(Handle<Map> map) const final {
511 return MaybeHandle<Code>(); 547 return MaybeHandle<Code>();
512 } 548 }
513 bool FindHandlers(List<Handle<Object>>* code_list, 549 bool FindHandlers(List<Handle<Object>>* code_list,
514 int length = -1) const final { 550 int length = -1) const final {
515 return length == 0; 551 return length == 0;
516 } 552 }
517 553
518 void ConfigureMegamorphic() override { UNREACHABLE(); } 554 void ConfigureMegamorphic() override { UNREACHABLE(); }
519 void Clear(Code* host); 555 void Clear(Code* host);
520 556
521 void ConfigureUninitialized() override; 557 void ConfigureUninitialized() override;
522 void ConfigurePropertyCellMode(Handle<PropertyCell> cell); 558 void ConfigurePropertyCellMode(Handle<PropertyCell> cell);
523 void ConfigureHandlerMode(Handle<Object> handler); 559 void ConfigureHandlerMode(Handle<Object> handler);
524 560
525 InlineCacheState StateFromFeedback() const override; 561 InlineCacheState StateFromFeedback() const override;
526 }; 562 };
527 563
528 class KeyedLoadICNexus : public FeedbackNexus { 564 class KeyedLoadICNexus : public FeedbackNexus {
529 public: 565 public:
530 KeyedLoadICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot) 566 KeyedLoadICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot)
531 : FeedbackNexus(vector, slot) { 567 : FeedbackNexus(vector, slot) {
532 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC, vector->GetKind(slot)); 568 DCHECK(vector->IsKeyedLoadIC(slot));
533 } 569 }
534 explicit KeyedLoadICNexus(Isolate* isolate) 570 explicit KeyedLoadICNexus(Isolate* isolate)
535 : FeedbackNexus( 571 : FeedbackNexus(
536 TypeFeedbackVector::DummyVector(isolate), 572 TypeFeedbackVector::DummyVector(isolate),
537 FeedbackVectorSlot(TypeFeedbackVector::kDummyKeyedLoadICSlot)) {} 573 FeedbackVectorSlot(TypeFeedbackVector::kDummyKeyedLoadICSlot)) {}
538 KeyedLoadICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot) 574 KeyedLoadICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot)
539 : FeedbackNexus(vector, slot) { 575 : FeedbackNexus(vector, slot) {
540 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC, vector->GetKind(slot)); 576 DCHECK(vector->IsKeyedLoadIC(slot));
541 } 577 }
542 578
543 void Clear(Code* host); 579 void Clear(Code* host);
544 580
545 // name can be a null handle for element loads. 581 // name can be a null handle for element loads.
546 void ConfigureMonomorphic(Handle<Name> name, Handle<Map> receiver_map, 582 void ConfigureMonomorphic(Handle<Name> name, Handle<Map> receiver_map,
547 Handle<Object> handler); 583 Handle<Object> handler);
548 // name can be null. 584 // name can be null.
549 void ConfigurePolymorphic(Handle<Name> name, MapHandleList* maps, 585 void ConfigurePolymorphic(Handle<Name> name, MapHandleList* maps,
550 List<Handle<Object>>* handlers); 586 List<Handle<Object>>* handlers);
551 587
552 void ConfigureMegamorphicKeyed(IcCheckType property_type); 588 void ConfigureMegamorphicKeyed(IcCheckType property_type);
553 589
554 IcCheckType GetKeyType() const; 590 IcCheckType GetKeyType() const;
555 InlineCacheState StateFromFeedback() const override; 591 InlineCacheState StateFromFeedback() const override;
556 Name* FindFirstName() const override; 592 Name* FindFirstName() const override;
557 }; 593 };
558 594
559 595
560 class StoreICNexus : public FeedbackNexus { 596 class StoreICNexus : public FeedbackNexus {
561 public: 597 public:
562 StoreICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot) 598 StoreICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot)
563 : FeedbackNexus(vector, slot) { 599 : FeedbackNexus(vector, slot) {
564 DCHECK_EQ(FeedbackVectorSlotKind::STORE_IC, vector->GetKind(slot)); 600 DCHECK(vector->IsStoreIC(slot));
565 } 601 }
566 explicit StoreICNexus(Isolate* isolate) 602 explicit StoreICNexus(Isolate* isolate)
567 : FeedbackNexus( 603 : FeedbackNexus(
568 TypeFeedbackVector::DummyVector(isolate), 604 TypeFeedbackVector::DummyVector(isolate),
569 FeedbackVectorSlot(TypeFeedbackVector::kDummyStoreICSlot)) {} 605 FeedbackVectorSlot(TypeFeedbackVector::kDummyStoreICSlot)) {}
570 StoreICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot) 606 StoreICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot)
571 : FeedbackNexus(vector, slot) { 607 : FeedbackNexus(vector, slot) {
572 DCHECK_EQ(FeedbackVectorSlotKind::STORE_IC, vector->GetKind(slot)); 608 DCHECK(vector->IsStoreIC(slot));
573 } 609 }
574 610
575 void Clear(Code* host); 611 void Clear(Code* host);
576 612
577 void ConfigureMonomorphic(Handle<Map> receiver_map, Handle<Object> handler); 613 void ConfigureMonomorphic(Handle<Map> receiver_map, Handle<Object> handler);
578 614
579 void ConfigurePolymorphic(MapHandleList* maps, 615 void ConfigurePolymorphic(MapHandleList* maps,
580 List<Handle<Object>>* handlers); 616 List<Handle<Object>>* handlers);
581 617
582 InlineCacheState StateFromFeedback() const override; 618 InlineCacheState StateFromFeedback() const override;
583 }; 619 };
584 620
585 621
586 class KeyedStoreICNexus : public FeedbackNexus { 622 class KeyedStoreICNexus : public FeedbackNexus {
587 public: 623 public:
588 KeyedStoreICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot) 624 KeyedStoreICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot)
589 : FeedbackNexus(vector, slot) { 625 : FeedbackNexus(vector, slot) {
590 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_STORE_IC, vector->GetKind(slot)); 626 DCHECK(vector->IsKeyedStoreIC(slot));
591 } 627 }
592 explicit KeyedStoreICNexus(Isolate* isolate) 628 explicit KeyedStoreICNexus(Isolate* isolate)
593 : FeedbackNexus( 629 : FeedbackNexus(
594 TypeFeedbackVector::DummyVector(isolate), 630 TypeFeedbackVector::DummyVector(isolate),
595 FeedbackVectorSlot(TypeFeedbackVector::kDummyKeyedStoreICSlot)) {} 631 FeedbackVectorSlot(TypeFeedbackVector::kDummyKeyedStoreICSlot)) {}
596 KeyedStoreICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot) 632 KeyedStoreICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot)
597 : FeedbackNexus(vector, slot) { 633 : FeedbackNexus(vector, slot) {
598 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_STORE_IC, vector->GetKind(slot)); 634 DCHECK(vector->IsKeyedStoreIC(slot));
599 } 635 }
600 636
601 void Clear(Code* host); 637 void Clear(Code* host);
602 638
603 // name can be a null handle for element loads. 639 // name can be a null handle for element loads.
604 void ConfigureMonomorphic(Handle<Name> name, Handle<Map> receiver_map, 640 void ConfigureMonomorphic(Handle<Name> name, Handle<Map> receiver_map,
605 Handle<Object> handler); 641 Handle<Object> handler);
606 // name can be null. 642 // name can be null.
607 void ConfigurePolymorphic(Handle<Name> name, MapHandleList* maps, 643 void ConfigurePolymorphic(Handle<Name> name, MapHandleList* maps,
608 List<Handle<Object>>* handlers); 644 List<Handle<Object>>* handlers);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 InlineCacheState StateFromFeedback() const override; 738 InlineCacheState StateFromFeedback() const override;
703 }; 739 };
704 740
705 inline BinaryOperationHint BinaryOperationHintFromFeedback(int type_feedback); 741 inline BinaryOperationHint BinaryOperationHintFromFeedback(int type_feedback);
706 inline CompareOperationHint CompareOperationHintFromFeedback(int type_feedback); 742 inline CompareOperationHint CompareOperationHintFromFeedback(int type_feedback);
707 743
708 } // namespace internal 744 } // namespace internal
709 } // namespace v8 745 } // namespace v8
710 746
711 #endif // V8_TRANSITIONS_H_ 747 #endif // V8_TRANSITIONS_H_
OLDNEW
« no previous file with comments | « src/ic/ic.cc ('k') | src/type-feedback-vector.cc » ('j') | src/type-feedback-vector.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698