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

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

Issue 650073002: vector-based ICs did not update type feedback counts correctly. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Ports. Created 6 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_INL_H_ 5 #ifndef V8_TYPE_FEEDBACK_VECTOR_INL_H_
6 #define V8_TYPE_FEEDBACK_VECTOR_INL_H_ 6 #define V8_TYPE_FEEDBACK_VECTOR_INL_H_
7 7
8 #include "src/type-feedback-vector.h" 8 #include "src/type-feedback-vector.h"
9 9
10 namespace v8 { 10 namespace v8 {
11 namespace internal { 11 namespace internal {
12 12
13 int TypeFeedbackVector::ic_with_type_info_count() {
14 return length() > 0 ? Smi::cast(get(kWithTypesIndex))->value() : 0;
15 }
16
17
18 void TypeFeedbackVector::change_ic_with_type_info_count(int delta) {
19 if (delta == 0) return;
20 int value = ic_with_type_info_count() + delta;
21 // Could go negative because of the debugger.
22 if (value >= 0) {
23 set(kWithTypesIndex, Smi::FromInt(value));
24 }
25 }
26
27
28 int TypeFeedbackVector::ic_generic_count() {
29 return length() > 0 ? Smi::cast(get(kGenericCountIndex))->value() : 0;
30 }
31
32
33 void TypeFeedbackVector::change_ic_generic_count(int delta) {
34 if (delta == 0) return;
35 int value = ic_generic_count() + delta;
36 if (value >= 0) {
37 set(kGenericCountIndex, Smi::FromInt(value));
38 }
39 }
40
41
42 int TypeFeedbackVector::Slots() {
43 if (length() == 0) return 0;
44 int first_ic_slot = first_ic_slot_index();
ulan 2014/10/15 10:17:06 If instead of -1, you would make first_ic_slot ==
mvstanton 2014/10/16 10:54:14 Done.
45 if (first_ic_slot >= 0) {
46 DCHECK(first_ic_slot >= kReservedIndexCount);
47 return first_ic_slot - kReservedIndexCount;
48 }
49 DCHECK(length() >= kReservedIndexCount);
50 return length() - kReservedIndexCount;
51 }
52
53
54 int TypeFeedbackVector::ICSlots() {
55 if (length() == 0) return 0;
56 int first_ic_slot = first_ic_slot_index();
57 if (first_ic_slot < 0) return 0;
58 DCHECK(first_ic_slot >= kReservedIndexCount);
59 return length() - first_ic_slot;
60 }
61
62
63 int TypeFeedbackVector::GetIndex(FeedbackVectorSlot slot) {
64 return kReservedIndexCount + slot.ToInt();
65 }
66
67
68 int TypeFeedbackVector::GetIndex(FeedbackVectorICSlot slot) {
69 int first_ic_slot = first_ic_slot_index();
70 DCHECK(first_ic_slot >= 0);
ulan 2014/10/15 10:17:05 DCHECK(slot.ToInt() < ICSlots()) would be more pre
mvstanton 2014/10/16 10:54:15 Done.
71 return first_ic_slot + slot.ToInt();
72 }
73
74
75 FeedbackVectorSlot TypeFeedbackVector::ToSlot(int index) {
76 DCHECK(index >= kReservedIndexCount);
ulan 2014/10/15 10:17:06 also DCHECK(index < first_ic_slot_index() || first
mvstanton 2014/10/16 10:54:15 Done.
77 return FeedbackVectorSlot(index - kReservedIndexCount);
78 }
79
80
81 FeedbackVectorICSlot TypeFeedbackVector::ToICSlot(int index) {
82 DCHECK(index >= kReservedIndexCount);
ulan 2014/10/15 10:17:05 DCHECK(index >= first_ic_slot_index) would be more
mvstanton 2014/10/16 10:54:15 Done.
83 DCHECK(first_ic_slot_index() >= 0);
84 return FeedbackVectorICSlot(index - first_ic_slot_index());
85 }
86
87
88 Object* TypeFeedbackVector::Get(FeedbackVectorSlot slot) {
89 return get(kReservedIndexCount + slot.ToInt());
ulan 2014/10/15 10:17:06 Why not use GetIndex(slot) here and below? :)
mvstanton 2014/10/16 10:54:14 Oh brother, great idea, thx!
90 }
91
92
93 void TypeFeedbackVector::Set(FeedbackVectorSlot slot, Object* value,
94 WriteBarrierMode mode) {
95 set(kReservedIndexCount + slot.ToInt(), value, mode);
96 }
97
98
99 Object* TypeFeedbackVector::Get(FeedbackVectorICSlot slot) {
100 int first_ic_slot = first_ic_slot_index();
101 DCHECK(first_ic_slot >= 0 && first_ic_slot < length());
102 return get(first_ic_slot + slot.ToInt());
103 }
104
105
106 void TypeFeedbackVector::Set(FeedbackVectorICSlot slot, Object* value,
107 WriteBarrierMode mode) {
108 int first_ic_slot = first_ic_slot_index();
109 DCHECK(first_ic_slot >= 0 && first_ic_slot < length());
110 set(first_ic_slot + slot.ToInt(), value, mode);
111 }
112
113
13 Handle<Object> TypeFeedbackVector::UninitializedSentinel(Isolate* isolate) { 114 Handle<Object> TypeFeedbackVector::UninitializedSentinel(Isolate* isolate) {
14 return isolate->factory()->uninitialized_symbol(); 115 return isolate->factory()->uninitialized_symbol();
15 } 116 }
16 117
17 118
18 Handle<Object> TypeFeedbackVector::MegamorphicSentinel(Isolate* isolate) { 119 Handle<Object> TypeFeedbackVector::MegamorphicSentinel(Isolate* isolate) {
19 return isolate->factory()->megamorphic_symbol(); 120 return isolate->factory()->megamorphic_symbol();
20 } 121 }
21 122
22 123
23 Handle<Object> TypeFeedbackVector::PremonomorphicSentinel(Isolate* isolate) { 124 Handle<Object> TypeFeedbackVector::PremonomorphicSentinel(Isolate* isolate) {
24 return isolate->factory()->megamorphic_symbol(); 125 return isolate->factory()->premonomorphic_symbol();
25 } 126 }
26 127
27 128
28 Handle<Object> TypeFeedbackVector::GenericSentinel(Isolate* isolate) { 129 Handle<Object> TypeFeedbackVector::GenericSentinel(Isolate* isolate) {
29 return isolate->factory()->generic_symbol(); 130 return isolate->factory()->generic_symbol();
30 } 131 }
31 132
32 133
33 Handle<Object> TypeFeedbackVector::MonomorphicArraySentinel( 134 Handle<Object> TypeFeedbackVector::MonomorphicArraySentinel(
34 Isolate* isolate, ElementsKind elements_kind) { 135 Isolate* isolate, ElementsKind elements_kind) {
35 return Handle<Object>(Smi::FromInt(static_cast<int>(elements_kind)), isolate); 136 return Handle<Object>(Smi::FromInt(static_cast<int>(elements_kind)), isolate);
36 } 137 }
37 138
38 139
39 Object* TypeFeedbackVector::RawUninitializedSentinel(Heap* heap) { 140 Object* TypeFeedbackVector::RawUninitializedSentinel(Heap* heap) {
40 return heap->uninitialized_symbol(); 141 return heap->uninitialized_symbol();
41 } 142 }
42 } 143 }
43 } // namespace v8::internal 144 } // namespace v8::internal
44 145
45 #endif // V8_TYPE_FEEDBACK_VECTOR_INL_H_ 146 #endif // V8_TYPE_FEEDBACK_VECTOR_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698