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

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: REBASE. 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
« no previous file with comments | « src/type-feedback-vector.h ('k') | src/type-feedback-vector-inl.h » ('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 #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 // AllocationSites are exempt from clearing. They don't store Maps
67 // or Code pointers which can cause memory leaks if not cleared
68 // regularly.
69 if (instance_type != ALLOCATION_SITE_TYPE) {
70 Set(slot, uninitialized_sentinel, SKIP_WRITE_BARRIER);
71 }
72 }
73 }
74
75 slots = ICSlots();
76 if (slots == 0) return;
77
78 // Now clear vector-based ICs. They are all CallICs.
79 // Try and pass the containing code (the "host").
80 Code* host = shared->code();
81 for (int i = 0; i < slots; i++) {
82 FeedbackVectorICSlot slot(i);
83 Object* obj = Get(slot);
84 if (obj != uninitialized_sentinel) {
85 ICUtility::Clear(isolate, Code::CALL_IC, host, this, slot);
86 }
87 }
88 }
21 } 89 }
22 } // namespace v8::internal 90 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/type-feedback-vector.h ('k') | src/type-feedback-vector-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698