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

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

Issue 2673383002: [ic] Encode LoadGlobalIC's typeof mode in slot kind instead of code object's flags. (Closed)
Patch Set: Addressed comments and added check to FCG 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
« no previous file with comments | « src/runtime/runtime.h ('k') | src/type-feedback-vector.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "src/elements-kind.h" 11 #include "src/elements-kind.h"
12 #include "src/objects.h" 12 #include "src/objects.h"
13 #include "src/type-hints.h" 13 #include "src/type-hints.h"
14 #include "src/zone/zone-containers.h" 14 #include "src/zone/zone-containers.h"
15 15
16 namespace v8 { 16 namespace v8 {
17 namespace internal { 17 namespace internal {
18 18
19 enum class FeedbackVectorSlotKind { 19 enum class FeedbackVectorSlotKind {
20 // This kind means that the slot points to the middle of other slot 20 // This kind means that the slot points to the middle of other slot
21 // which occupies more than one feedback vector element. 21 // which occupies more than one feedback vector element.
22 // There must be no such slots in the system. 22 // There must be no such slots in the system.
23 INVALID, 23 INVALID,
24 24
25 CALL_IC, 25 CALL_IC,
26 LOAD_IC, 26 LOAD_IC,
27 LOAD_GLOBAL_IC, 27 LOAD_GLOBAL_NOT_INSIDE_TYPEOF_IC,
28 LOAD_GLOBAL_INSIDE_TYPEOF_IC,
28 KEYED_LOAD_IC, 29 KEYED_LOAD_IC,
29 STORE_SLOPPY_IC, 30 STORE_SLOPPY_IC,
30 STORE_STRICT_IC, 31 STORE_STRICT_IC,
31 KEYED_STORE_SLOPPY_IC, 32 KEYED_STORE_SLOPPY_IC,
32 KEYED_STORE_STRICT_IC, 33 KEYED_STORE_STRICT_IC,
33 INTERPRETER_BINARYOP_IC, 34 INTERPRETER_BINARYOP_IC,
34 INTERPRETER_COMPARE_IC, 35 INTERPRETER_COMPARE_IC,
35 STORE_DATA_PROPERTY_IN_LITERAL_IC, 36 STORE_DATA_PROPERTY_IN_LITERAL_IC,
36 CREATE_CLOSURE, 37 CREATE_CLOSURE,
37 LITERAL, 38 LITERAL,
38 // This is a general purpose slot that occupies one feedback vector element. 39 // This is a general purpose slot that occupies one feedback vector element.
39 GENERAL, 40 GENERAL,
40 41
41 KINDS_NUMBER // Last value indicating number of kinds. 42 KINDS_NUMBER // Last value indicating number of kinds.
42 }; 43 };
43 44
44 inline bool IsCallICKind(FeedbackVectorSlotKind kind) { 45 inline bool IsCallICKind(FeedbackVectorSlotKind kind) {
45 return kind == FeedbackVectorSlotKind::CALL_IC; 46 return kind == FeedbackVectorSlotKind::CALL_IC;
46 } 47 }
47 48
48 inline bool IsLoadICKind(FeedbackVectorSlotKind kind) { 49 inline bool IsLoadICKind(FeedbackVectorSlotKind kind) {
49 return kind == FeedbackVectorSlotKind::LOAD_IC; 50 return kind == FeedbackVectorSlotKind::LOAD_IC;
50 } 51 }
51 52
52 inline bool IsLoadGlobalICKind(FeedbackVectorSlotKind kind) { 53 inline bool IsLoadGlobalICKind(FeedbackVectorSlotKind kind) {
53 return kind == FeedbackVectorSlotKind::LOAD_GLOBAL_IC; 54 return kind == FeedbackVectorSlotKind::LOAD_GLOBAL_NOT_INSIDE_TYPEOF_IC ||
55 kind == FeedbackVectorSlotKind::LOAD_GLOBAL_INSIDE_TYPEOF_IC;
54 } 56 }
55 57
56 inline bool IsKeyedLoadICKind(FeedbackVectorSlotKind kind) { 58 inline bool IsKeyedLoadICKind(FeedbackVectorSlotKind kind) {
57 return kind == FeedbackVectorSlotKind::KEYED_LOAD_IC; 59 return kind == FeedbackVectorSlotKind::KEYED_LOAD_IC;
58 } 60 }
59 61
60 inline bool IsStoreICKind(FeedbackVectorSlotKind kind) { 62 inline bool IsStoreICKind(FeedbackVectorSlotKind kind) {
61 return kind == FeedbackVectorSlotKind::STORE_SLOPPY_IC || 63 return kind == FeedbackVectorSlotKind::STORE_SLOPPY_IC ||
62 kind == FeedbackVectorSlotKind::STORE_STRICT_IC; 64 kind == FeedbackVectorSlotKind::STORE_STRICT_IC;
63 } 65 }
64 66
65 inline bool IsKeyedStoreICKind(FeedbackVectorSlotKind kind) { 67 inline bool IsKeyedStoreICKind(FeedbackVectorSlotKind kind) {
66 return kind == FeedbackVectorSlotKind::KEYED_STORE_SLOPPY_IC || 68 return kind == FeedbackVectorSlotKind::KEYED_STORE_SLOPPY_IC ||
67 kind == FeedbackVectorSlotKind::KEYED_STORE_STRICT_IC; 69 kind == FeedbackVectorSlotKind::KEYED_STORE_STRICT_IC;
68 } 70 }
69 71
72 inline TypeofMode GetTypeofModeFromICKind(FeedbackVectorSlotKind kind) {
73 DCHECK(IsLoadGlobalICKind(kind));
74 return (kind == FeedbackVectorSlotKind::LOAD_GLOBAL_INSIDE_TYPEOF_IC)
75 ? INSIDE_TYPEOF
76 : NOT_INSIDE_TYPEOF;
77 }
78
70 inline LanguageMode GetLanguageModeFromICKind(FeedbackVectorSlotKind kind) { 79 inline LanguageMode GetLanguageModeFromICKind(FeedbackVectorSlotKind kind) {
71 DCHECK(IsStoreICKind(kind) || IsKeyedStoreICKind(kind)); 80 DCHECK(IsStoreICKind(kind) || IsKeyedStoreICKind(kind));
72 return (kind == FeedbackVectorSlotKind::STORE_SLOPPY_IC || 81 return (kind == FeedbackVectorSlotKind::STORE_SLOPPY_IC ||
73 kind == FeedbackVectorSlotKind::KEYED_STORE_SLOPPY_IC) 82 kind == FeedbackVectorSlotKind::KEYED_STORE_SLOPPY_IC)
74 ? SLOPPY 83 ? SLOPPY
75 : STRICT; 84 : STRICT;
76 } 85 }
77 86
78 std::ostream& operator<<(std::ostream& os, FeedbackVectorSlotKind kind); 87 std::ostream& operator<<(std::ostream& os, FeedbackVectorSlotKind kind);
79 88
80 89
81 template <typename Derived> 90 template <typename Derived>
82 class FeedbackVectorSpecBase { 91 class FeedbackVectorSpecBase {
83 public: 92 public:
84 FeedbackVectorSlot AddCallICSlot() { 93 FeedbackVectorSlot AddCallICSlot() {
85 return AddSlot(FeedbackVectorSlotKind::CALL_IC); 94 return AddSlot(FeedbackVectorSlotKind::CALL_IC);
86 } 95 }
87 96
88 FeedbackVectorSlot AddLoadICSlot() { 97 FeedbackVectorSlot AddLoadICSlot() {
89 return AddSlot(FeedbackVectorSlotKind::LOAD_IC); 98 return AddSlot(FeedbackVectorSlotKind::LOAD_IC);
90 } 99 }
91 100
92 FeedbackVectorSlot AddLoadGlobalICSlot() { 101 FeedbackVectorSlot AddLoadGlobalICSlot(TypeofMode typeof_mode) {
93 return AddSlot(FeedbackVectorSlotKind::LOAD_GLOBAL_IC); 102 return AddSlot(
103 typeof_mode == INSIDE_TYPEOF
104 ? FeedbackVectorSlotKind::LOAD_GLOBAL_INSIDE_TYPEOF_IC
105 : FeedbackVectorSlotKind::LOAD_GLOBAL_NOT_INSIDE_TYPEOF_IC);
94 } 106 }
95 107
96 FeedbackVectorSlot AddCreateClosureSlot() { 108 FeedbackVectorSlot AddCreateClosureSlot() {
97 return AddSlot(FeedbackVectorSlotKind::CREATE_CLOSURE); 109 return AddSlot(FeedbackVectorSlotKind::CREATE_CLOSURE);
98 } 110 }
99 111
100 FeedbackVectorSlot AddKeyedLoadICSlot() { 112 FeedbackVectorSlot AddKeyedLoadICSlot() {
101 return AddSlot(FeedbackVectorSlotKind::KEYED_LOAD_IC); 113 return AddSlot(FeedbackVectorSlotKind::KEYED_LOAD_IC);
102 } 114 }
103 115
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 bool Name(FeedbackVectorSlot slot) const { return Name##Kind(GetKind(slot)); } 317 bool Name(FeedbackVectorSlot slot) const { return Name##Kind(GetKind(slot)); }
306 318
307 DEFINE_SLOT_KIND_PREDICATE(IsCallIC) 319 DEFINE_SLOT_KIND_PREDICATE(IsCallIC)
308 DEFINE_SLOT_KIND_PREDICATE(IsLoadIC) 320 DEFINE_SLOT_KIND_PREDICATE(IsLoadIC)
309 DEFINE_SLOT_KIND_PREDICATE(IsLoadGlobalIC) 321 DEFINE_SLOT_KIND_PREDICATE(IsLoadGlobalIC)
310 DEFINE_SLOT_KIND_PREDICATE(IsKeyedLoadIC) 322 DEFINE_SLOT_KIND_PREDICATE(IsKeyedLoadIC)
311 DEFINE_SLOT_KIND_PREDICATE(IsStoreIC) 323 DEFINE_SLOT_KIND_PREDICATE(IsStoreIC)
312 DEFINE_SLOT_KIND_PREDICATE(IsKeyedStoreIC) 324 DEFINE_SLOT_KIND_PREDICATE(IsKeyedStoreIC)
313 #undef DEFINE_SLOT_KIND_PREDICATE 325 #undef DEFINE_SLOT_KIND_PREDICATE
314 326
327 // Returns typeof mode encoded into kind of given slot.
328 inline TypeofMode GetTypeofMode(FeedbackVectorSlot slot) const {
329 return GetTypeofModeFromICKind(GetKind(slot));
330 }
331
315 // Returns language mode encoded into kind of given slot. 332 // Returns language mode encoded into kind of given slot.
316 inline LanguageMode GetLanguageMode(FeedbackVectorSlot slot) const { 333 inline LanguageMode GetLanguageMode(FeedbackVectorSlot slot) const {
317 return GetLanguageModeFromICKind(GetKind(slot)); 334 return GetLanguageModeFromICKind(GetKind(slot));
318 } 335 }
319 336
320 #ifdef OBJECT_PRINT 337 #ifdef OBJECT_PRINT
321 // For gdb debugging. 338 // For gdb debugging.
322 void Print(); 339 void Print();
323 #endif // OBJECT_PRINT 340 #endif // OBJECT_PRINT
324 341
(...skipping 12 matching lines...) Expand all
337 // The object that indicates a megamorphic state. 354 // The object that indicates a megamorphic state.
338 static inline Handle<Symbol> MegamorphicSentinel(Isolate* isolate); 355 static inline Handle<Symbol> MegamorphicSentinel(Isolate* isolate);
339 356
340 // The object that indicates a premonomorphic state. 357 // The object that indicates a premonomorphic state.
341 static inline Handle<Symbol> PremonomorphicSentinel(Isolate* isolate); 358 static inline Handle<Symbol> PremonomorphicSentinel(Isolate* isolate);
342 359
343 // A raw version of the uninitialized sentinel that's safe to read during 360 // A raw version of the uninitialized sentinel that's safe to read during
344 // garbage collection (e.g., for patching the cache). 361 // garbage collection (e.g., for patching the cache).
345 static inline Symbol* RawUninitializedSentinel(Isolate* isolate); 362 static inline Symbol* RawUninitializedSentinel(Isolate* isolate);
346 363
347 static const int kDummyLoadICSlot = 0;
348
349 static Handle<TypeFeedbackVector> DummyVector(Isolate* isolate);
350
351 private: 364 private:
352 void ClearSlotsImpl(SharedFunctionInfo* shared, bool force_clear); 365 void ClearSlotsImpl(SharedFunctionInfo* shared, bool force_clear);
353 366
354 DISALLOW_IMPLICIT_CONSTRUCTORS(TypeFeedbackVector); 367 DISALLOW_IMPLICIT_CONSTRUCTORS(TypeFeedbackVector);
355 }; 368 };
356 369
357 370
358 // The following asserts protect an optimization in type feedback vector 371 // The following asserts protect an optimization in type feedback vector
359 // code that looks into the contents of a slot assuming to find a String, 372 // code that looks into the contents of a slot assuming to find a String,
360 // a Symbol, an AllocationSite, a WeakCell, or a FixedArray. 373 // a Symbol, an AllocationSite, a WeakCell, or a FixedArray.
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 float ComputeCallFrequency(); 535 float ComputeCallFrequency();
523 }; 536 };
524 537
525 538
526 class LoadICNexus : public FeedbackNexus { 539 class LoadICNexus : public FeedbackNexus {
527 public: 540 public:
528 LoadICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot) 541 LoadICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorSlot slot)
529 : FeedbackNexus(vector, slot) { 542 : FeedbackNexus(vector, slot) {
530 DCHECK(vector->IsLoadIC(slot)); 543 DCHECK(vector->IsLoadIC(slot));
531 } 544 }
532 explicit LoadICNexus(Isolate* isolate)
533 : FeedbackNexus(
534 TypeFeedbackVector::DummyVector(isolate),
535 FeedbackVectorSlot(TypeFeedbackVector::kDummyLoadICSlot)) {}
536 LoadICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot) 545 LoadICNexus(TypeFeedbackVector* vector, FeedbackVectorSlot slot)
537 : FeedbackNexus(vector, slot) { 546 : FeedbackNexus(vector, slot) {
538 DCHECK(vector->IsLoadIC(slot)); 547 DCHECK(vector->IsLoadIC(slot));
539 } 548 }
540 549
541 void Clear(Code* host); 550 void Clear(Code* host);
542 551
543 void ConfigureMonomorphic(Handle<Map> receiver_map, Handle<Object> handler); 552 void ConfigureMonomorphic(Handle<Map> receiver_map, Handle<Object> handler);
544 553
545 void ConfigurePolymorphic(MapHandleList* maps, 554 void ConfigurePolymorphic(MapHandleList* maps,
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 InlineCacheState StateFromFeedback() const override; 755 InlineCacheState StateFromFeedback() const override;
747 }; 756 };
748 757
749 inline BinaryOperationHint BinaryOperationHintFromFeedback(int type_feedback); 758 inline BinaryOperationHint BinaryOperationHintFromFeedback(int type_feedback);
750 inline CompareOperationHint CompareOperationHintFromFeedback(int type_feedback); 759 inline CompareOperationHint CompareOperationHintFromFeedback(int type_feedback);
751 760
752 } // namespace internal 761 } // namespace internal
753 } // namespace v8 762 } // namespace v8
754 763
755 #endif // V8_TRANSITIONS_H_ 764 #endif // V8_TRANSITIONS_H_
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/type-feedback-vector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698