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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/type-feedback-vector.h ('k') | src/type-feedback-vector-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/type-feedback-vector.cc
diff --git a/src/type-feedback-vector.cc b/src/type-feedback-vector.cc
index a3fe0707c7d578fbbbcf204dc51a68694308b271..dcae7c72e657bacba67c4ee206fb28c57365098f 100644
--- a/src/type-feedback-vector.cc
+++ b/src/type-feedback-vector.cc
@@ -4,6 +4,7 @@
#include "src/v8.h"
+#include "src/ic/ic-state.h"
#include "src/objects.h"
#include "src/type-feedback-vector-inl.h"
@@ -11,6 +12,36 @@ namespace v8 {
namespace internal {
// static
+Handle<TypeFeedbackVector> TypeFeedbackVector::Allocate(Isolate* isolate,
+ int slot_count,
+ int ic_slot_count) {
+ int length = slot_count + ic_slot_count + kReservedIndexCount;
+ if (length == kReservedIndexCount) {
+ return Handle<TypeFeedbackVector>::cast(
+ isolate->factory()->empty_fixed_array());
+ }
+
+ Handle<FixedArray> array = isolate->factory()->NewFixedArray(length, TENURED);
+ if (ic_slot_count > 0) {
+ array->set(kFirstICSlotIndex,
+ Smi::FromInt(slot_count + kReservedIndexCount));
+ } else {
+ array->set(kFirstICSlotIndex, Smi::FromInt(length));
+ }
+ array->set(kWithTypesIndex, Smi::FromInt(0));
+ array->set(kGenericCountIndex, Smi::FromInt(0));
+
+ // Ensure we can skip the write barrier
+ Handle<Object> uninitialized_sentinel = UninitializedSentinel(isolate);
+ DCHECK_EQ(isolate->heap()->uninitialized_symbol(), *uninitialized_sentinel);
+ for (int i = kReservedIndexCount; i < length; i++) {
+ array->set(i, *uninitialized_sentinel, SKIP_WRITE_BARRIER);
+ }
+ return Handle<TypeFeedbackVector>::cast(array);
+}
+
+
+// static
Handle<TypeFeedbackVector> TypeFeedbackVector::Copy(
Isolate* isolate, Handle<TypeFeedbackVector> vector) {
Handle<TypeFeedbackVector> result;
@@ -18,5 +49,42 @@ Handle<TypeFeedbackVector> TypeFeedbackVector::Copy(
isolate->factory()->CopyFixedArray(Handle<FixedArray>::cast(vector)));
return result;
}
+
+
+void TypeFeedbackVector::ClearSlots(SharedFunctionInfo* shared) {
+ int slots = Slots();
+ Isolate* isolate = GetIsolate();
+ Object* uninitialized_sentinel =
+ TypeFeedbackVector::RawUninitializedSentinel(isolate->heap());
+
+ for (int i = 0; i < slots; i++) {
+ FeedbackVectorSlot slot(i);
+ Object* obj = Get(slot);
+ if (obj->IsHeapObject()) {
+ InstanceType instance_type =
+ HeapObject::cast(obj)->map()->instance_type();
+ // AllocationSites are exempt from clearing. They don't store Maps
+ // or Code pointers which can cause memory leaks if not cleared
+ // regularly.
+ if (instance_type != ALLOCATION_SITE_TYPE) {
+ Set(slot, uninitialized_sentinel, SKIP_WRITE_BARRIER);
+ }
+ }
+ }
+
+ slots = ICSlots();
+ if (slots == 0) return;
+
+ // Now clear vector-based ICs. They are all CallICs.
+ // Try and pass the containing code (the "host").
+ Code* host = shared->code();
+ for (int i = 0; i < slots; i++) {
+ FeedbackVectorICSlot slot(i);
+ Object* obj = Get(slot);
+ if (obj != uninitialized_sentinel) {
+ ICUtility::Clear(isolate, Code::CALL_IC, host, this, slot);
+ }
+ }
+}
}
} // namespace v8::internal
« 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