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

Unified Diff: src/type-feedback-vector.h

Issue 1309303008: Make type-feedback-vector.h usable without objects-inl.h header (and others). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comment. Created 5 years, 4 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 | « no previous file | 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.h
diff --git a/src/type-feedback-vector.h b/src/type-feedback-vector.h
index 29e4402d7d2dac5446ca360655635a5f9b3105a3..cbba89339a305d30ff050fecd57bb78732102e31 100644
--- a/src/type-feedback-vector.h
+++ b/src/type-feedback-vector.h
@@ -87,10 +87,7 @@ class ZoneFeedbackVectorSpec {
class TypeFeedbackVector : public FixedArray {
public:
// Casting.
- static TypeFeedbackVector* cast(Object* obj) {
- DCHECK(obj->IsTypeFeedbackVector());
- return reinterpret_cast<TypeFeedbackVector*>(obj);
- }
+ static inline TypeFeedbackVector* cast(Object* obj);
static const int kReservedIndexCount = 3;
static const int kFirstICSlotIndex = 0;
@@ -99,89 +96,33 @@ class TypeFeedbackVector : public FixedArray {
static int elements_per_ic_slot() { return 2; }
- int first_ic_slot_index() const {
- DCHECK(length() >= kReservedIndexCount);
- return Smi::cast(get(kFirstICSlotIndex))->value();
- }
-
- int ic_with_type_info_count() {
- return length() > 0 ? Smi::cast(get(kWithTypesIndex))->value() : 0;
- }
-
- void change_ic_with_type_info_count(int delta) {
- if (delta == 0) return;
- int value = ic_with_type_info_count() + delta;
- // Could go negative because of the debugger.
- if (value >= 0) {
- set(kWithTypesIndex, Smi::FromInt(value));
- }
- }
-
- int ic_generic_count() {
- return length() > 0 ? Smi::cast(get(kGenericCountIndex))->value() : 0;
- }
-
- void change_ic_generic_count(int delta) {
- if (delta == 0) return;
- int value = ic_generic_count() + delta;
- if (value >= 0) {
- set(kGenericCountIndex, Smi::FromInt(value));
- }
- }
-
+ inline int first_ic_slot_index() const;
+ inline int ic_with_type_info_count();
+ inline void change_ic_with_type_info_count(int delta);
+ inline int ic_generic_count();
+ inline void change_ic_generic_count(int delta);
inline int ic_metadata_length() const;
bool SpecDiffersFrom(const ZoneFeedbackVectorSpec* other_spec) const;
- int Slots() const {
- if (length() == 0) return 0;
- return Max(
- 0, first_ic_slot_index() - ic_metadata_length() - kReservedIndexCount);
- }
-
- int ICSlots() const {
- if (length() == 0) return 0;
- return (length() - first_ic_slot_index()) / elements_per_ic_slot();
- }
+ inline int Slots() const;
+ inline int ICSlots() const;
// Conversion from a slot or ic slot to an integer index to the underlying
// array.
- int GetIndex(FeedbackVectorSlot slot) const {
- DCHECK(slot.ToInt() < first_ic_slot_index());
- return kReservedIndexCount + ic_metadata_length() + slot.ToInt();
- }
-
- int GetIndex(FeedbackVectorICSlot slot) const {
- int first_ic_slot = first_ic_slot_index();
- DCHECK(slot.ToInt() < ICSlots());
- return first_ic_slot + slot.ToInt() * elements_per_ic_slot();
- }
+ inline int GetIndex(FeedbackVectorSlot slot) const;
+ inline int GetIndex(FeedbackVectorICSlot slot) const;
// Conversion from an integer index to either a slot or an ic slot. The caller
// should know what kind she expects.
- FeedbackVectorSlot ToSlot(int index) const {
- DCHECK(index >= kReservedIndexCount && index < first_ic_slot_index());
- return FeedbackVectorSlot(index - ic_metadata_length() -
- kReservedIndexCount);
- }
-
- FeedbackVectorICSlot ToICSlot(int index) const {
- DCHECK(index >= first_ic_slot_index() && index < length());
- int ic_slot = (index - first_ic_slot_index()) / elements_per_ic_slot();
- return FeedbackVectorICSlot(ic_slot);
- }
-
- Object* Get(FeedbackVectorSlot slot) const { return get(GetIndex(slot)); }
- void Set(FeedbackVectorSlot slot, Object* value,
- WriteBarrierMode mode = UPDATE_WRITE_BARRIER) {
- set(GetIndex(slot), value, mode);
- }
-
- Object* Get(FeedbackVectorICSlot slot) const { return get(GetIndex(slot)); }
- void Set(FeedbackVectorICSlot slot, Object* value,
- WriteBarrierMode mode = UPDATE_WRITE_BARRIER) {
- set(GetIndex(slot), value, mode);
- }
+ inline FeedbackVectorSlot ToSlot(int index) const;
+ inline FeedbackVectorICSlot ToICSlot(int index) const;
+ inline Object* Get(FeedbackVectorSlot slot) const;
+ inline void Set(FeedbackVectorSlot slot, Object* value,
+ WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
+ inline Object* Get(FeedbackVectorICSlot slot) const;
+ inline void Set(FeedbackVectorICSlot slot, Object* value,
+ WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
// IC slots need metadata to recognize the type of IC.
Code::Kind GetKind(FeedbackVectorICSlot slot) const;
@@ -320,27 +261,16 @@ class FeedbackNexus {
virtual void ConfigurePremonomorphic();
virtual void ConfigureMegamorphic();
- Object* GetFeedback() const { return vector()->Get(slot()); }
- Object* GetFeedbackExtra() const {
- DCHECK(TypeFeedbackVector::elements_per_ic_slot() > 1);
- int extra_index = vector()->GetIndex(slot()) + 1;
- return vector()->get(extra_index);
- }
+ inline Object* GetFeedback() const;
+ inline Object* GetFeedbackExtra() const;
protected:
- Isolate* GetIsolate() const { return vector()->GetIsolate(); }
+ inline Isolate* GetIsolate() const;
- void SetFeedback(Object* feedback,
- WriteBarrierMode mode = UPDATE_WRITE_BARRIER) {
- vector()->Set(slot(), feedback, mode);
- }
-
- void SetFeedbackExtra(Object* feedback_extra,
- WriteBarrierMode mode = UPDATE_WRITE_BARRIER) {
- DCHECK(TypeFeedbackVector::elements_per_ic_slot() > 1);
- int index = vector()->GetIndex(slot()) + 1;
- vector()->set(index, feedback_extra, mode);
- }
+ inline void SetFeedback(Object* feedback,
+ WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
+ inline void SetFeedbackExtra(Object* feedback_extra,
+ WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
Handle<FixedArray> EnsureArrayOfSize(int length);
Handle<FixedArray> EnsureExtraArrayOfSize(int length);
« no previous file with comments | « no previous file | src/type-feedback-vector-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698