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

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

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: Reduced -inl.h file usage. 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 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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/ic/ic-state.h"
7 #include "src/objects.h" 8 #include "src/objects.h"
8 #include "src/type-feedback-vector-inl.h" 9 #include "src/type-feedback-vector-inl.h"
9 10
10 namespace v8 { 11 namespace v8 {
11 namespace internal { 12 namespace internal {
12 13
13 // static 14 // static
15 Handle<TypeFeedbackVector> TypeFeedbackVector::Allocate(Isolate* isolate,
16 int slot_count,
17 int ic_slot_count) {
18 int length = slot_count + ic_slot_count + kReservedIndexCount;
19 if (length == kReservedIndexCount) {
20 return Handle<TypeFeedbackVector>::cast(
21 isolate->factory()->empty_fixed_array());
22 }
23
24 Handle<FixedArray> array = isolate->factory()->NewFixedArray(length, TENURED);
25 if (ic_slot_count > 0) {
26 array->set(kFirstICSlotIndex,
27 Smi::FromInt(slot_count + kReservedIndexCount));
28 } else {
29 array->set(kFirstICSlotIndex, Smi::FromInt(length));
30 }
31 array->set(kWithTypesIndex, Smi::FromInt(0));
32 array->set(kGenericCountIndex, Smi::FromInt(0));
33
34 // Ensure we can skip the write barrier
35 Handle<Object> uninitialized_sentinel = UninitializedSentinel(isolate);
36 DCHECK_EQ(isolate->heap()->uninitialized_symbol(), *uninitialized_sentinel);
37 for (int i = kReservedIndexCount; i < length; i++) {
38 array->set(i, *uninitialized_sentinel, SKIP_WRITE_BARRIER);
39 }
40 return Handle<TypeFeedbackVector>::cast(array);
41 }
42
43
44 // static
14 Handle<TypeFeedbackVector> TypeFeedbackVector::Copy( 45 Handle<TypeFeedbackVector> TypeFeedbackVector::Copy(
15 Isolate* isolate, Handle<TypeFeedbackVector> vector) { 46 Isolate* isolate, Handle<TypeFeedbackVector> vector) {
16 Handle<TypeFeedbackVector> result; 47 Handle<TypeFeedbackVector> result;
17 result = Handle<TypeFeedbackVector>::cast( 48 result = Handle<TypeFeedbackVector>::cast(
18 isolate->factory()->CopyFixedArray(Handle<FixedArray>::cast(vector))); 49 isolate->factory()->CopyFixedArray(Handle<FixedArray>::cast(vector)));
19 return result; 50 return result;
20 } 51 }
52
53
54 void TypeFeedbackVector::ClearSlots(SharedFunctionInfo* shared) {
55 int slots = Slots();
56 Isolate* isolate = GetIsolate();
57 Object* uninitialized_sentinel =
58 TypeFeedbackVector::RawUninitializedSentinel(isolate->heap());
59
60 for (int i = 0; i < slots; i++) {
61 FeedbackVectorSlot slot(i);
62 Object* obj = Get(slot);
63 if (obj->IsHeapObject()) {
64 InstanceType instance_type =
65 HeapObject::cast(obj)->map()->instance_type();
66 switch (instance_type) {
67 case ALLOCATION_SITE_TYPE:
68 // AllocationSites are not cleared because they do not store
69 // information that leaks.
70 break;
71 // Fall through...
Jakob Kummerow 2014/10/20 10:29:43 Uhm, what? Either "break;" or "// Fall through.",
mvstanton 2014/10/20 11:09:22 You are right, it's unwieldy...changing to if()...
72 default:
73 Set(slot, uninitialized_sentinel, SKIP_WRITE_BARRIER);
74 }
75 }
76 }
77
78 // Now clear vector-based ICs. They are all CallICs.
Jakob Kummerow 2014/10/20 10:29:43 Whoa. The comment in the header said "leaves vecto
mvstanton 2014/10/20 11:09:22 Nice catch, I'll fix that outdated comment in the
79 // Try and pass the containing code (the "host")
80 slots = ICSlots();
81 Code* host = shared->code();
82 for (int i = 0; i < slots; i++) {
83 FeedbackVectorICSlot slot(i);
84 Object* obj = Get(slot);
85 if (obj != uninitialized_sentinel) {
86 ICUtility::Clear(isolate, Code::CALL_IC, host, this, slot);
87 }
88 }
89 }
21 } 90 }
22 } // namespace v8::internal 91 } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698