feedback-cell-inl.h 1.75 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_OBJECTS_FEEDBACK_CELL_INL_H_
#define V8_OBJECTS_FEEDBACK_CELL_INL_H_

#include "src/objects/feedback-cell.h"

#include "src/heap/heap-write-barrier-inl.h"
11
#include "src/objects/objects-inl.h"
12
#include "src/objects/struct-inl.h"
13 14 15 16 17 18 19

// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"

namespace v8 {
namespace internal {

20
TQ_OBJECT_CONSTRUCTORS_IMPL(FeedbackCell)
21 22

void FeedbackCell::clear_padding() {
Irina Yatsenko's avatar
Irina Yatsenko committed
23 24
  if (FeedbackCell::kAlignedSize == FeedbackCell::kUnalignedSize) return;
  DCHECK_GE(FeedbackCell::kAlignedSize, FeedbackCell::kUnalignedSize);
25
  memset(reinterpret_cast<byte*>(address() + FeedbackCell::kUnalignedSize), 0,
Irina Yatsenko's avatar
Irina Yatsenko committed
26
         FeedbackCell::kAlignedSize - FeedbackCell::kUnalignedSize);
27
}
28

29 30 31 32
void FeedbackCell::reset_feedback_vector(
    base::Optional<std::function<void(HeapObject object, ObjectSlot slot,
                                      HeapObject target)>>
        gc_notify_updated_slot) {
33
  set_interrupt_budget(FeedbackCell::GetInitialInterruptBudget());
34 35 36 37 38 39 40 41 42 43
  if (value().IsUndefined() || value().IsClosureFeedbackCellArray()) return;

  CHECK(value().IsFeedbackVector());
  ClosureFeedbackCellArray closure_feedback_cell_array =
      FeedbackVector::cast(value()).closure_feedback_cell_array();
  set_value(closure_feedback_cell_array);
  if (gc_notify_updated_slot) {
    (*gc_notify_updated_slot)(*this, RawField(FeedbackCell::kValueOffset),
                              closure_feedback_cell_array);
  }
44 45
}

46 47 48 49 50 51
}  // namespace internal
}  // namespace v8

#include "src/objects/object-macros-undef.h"

#endif  // V8_OBJECTS_FEEDBACK_CELL_INL_H_