v8/src/objects-body-descriptors.h
Michael Achenbach 41b02eec5f Revert "Revert "Fix GCC 7 build errors""
This reverts commit da607264dd.

Reason for revert: Looked wrong. The persistent layout test
failures started in the next revision. The failure on the revision
of the reverted CL was just a flake.

Original change's description:
> Revert "Fix GCC 7 build errors"
> 
> This reverts commit c0f1ff2451.
> 
> Reason for revert: Speculative revert for layout test timeout:
> https://build.chromium.org/p/client.v8.fyi/builders/V8-Blink%20Linux%2064/builds/16402
> 
> Original change's description:
> > Fix GCC 7 build errors
> > 
> > BUG=chromium:691681
> > R=​franzih@chromium.org
> > 
> > Change-Id: Id7e5698487f16dc217a804f6d3f24da7213c72b9
> > Reviewed-on: https://chromium-review.googlesource.com/530227
> > Commit-Queue: Toon Verwaest <verwaest@chromium.org>
> > Reviewed-by: Toon Verwaest <verwaest@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#46045}
> 
> TBR=adamk@chromium.org,franzih@chromium.org,mic.besace@gmail.com,verwaest@chromium.org
> 
> Change-Id: I2119a87a95ed9eb88b7b32ae436edf28dfc86c16
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:691681
> Reviewed-on: https://chromium-review.googlesource.com/541227
> Reviewed-by: Michael Achenbach <machenbach@chromium.org>
> Commit-Queue: Michael Achenbach <machenbach@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#46065}

TBR=adamk@chromium.org,machenbach@chromium.org,franzih@chromium.org,mic.besace@gmail.com,verwaest@chromium.org

Change-Id: Ieee7f6b3b80d380e720206e7b43c4b580918b1d7
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:691681
Reviewed-on: https://chromium-review.googlesource.com/541228
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46067}
2017-06-20 18:22:54 +00:00

143 lines
4.7 KiB
C++

// Copyright 2015 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_BODY_DESCRIPTORS_H_
#define V8_OBJECTS_BODY_DESCRIPTORS_H_
#include "src/objects.h"
namespace v8 {
namespace internal {
// This is the base class for object's body descriptors.
//
// Each BodyDescriptor subclass must provide the following methods:
//
// 1) Returns true if the object contains a tagged value at given offset.
// It is used for invalid slots filtering. If the offset points outside
// of the object or to the map word, the result is UNDEFINED (!!!).
//
// static bool IsValidSlot(HeapObject* obj, int offset);
//
//
// 2) Iterate object's body using stateful object visitor.
//
// template <typename ObjectVisitor>
// static inline void IterateBody(HeapObject* obj, int object_size,
// ObjectVisitor* v);
//
//
// 3) Iterate object's body using stateless object visitor.
//
// template <typename StaticVisitor>
// static inline void IterateBody(HeapObject* obj, int object_size);
//
class BodyDescriptorBase BASE_EMBEDDED {
public:
template <typename ObjectVisitor>
static inline void IteratePointers(HeapObject* obj, int start_offset,
int end_offset, ObjectVisitor* v);
template <typename StaticVisitor>
static inline void IteratePointers(Heap* heap, HeapObject* obj,
int start_offset, int end_offset);
template <typename ObjectVisitor>
static inline void IteratePointer(HeapObject* obj, int offset,
ObjectVisitor* v);
template <typename StaticVisitor>
static inline void IteratePointer(Heap* heap, HeapObject* obj, int offset);
protected:
// Returns true for all header and embedder fields.
static inline bool IsValidSlotImpl(HeapObject* obj, int offset);
// Treats all header and embedder fields in the range as tagged.
template <typename ObjectVisitor>
static inline void IterateBodyImpl(HeapObject* obj, int start_offset,
int end_offset, ObjectVisitor* v);
// Treats all header and embedder fields in the range as tagged.
template <typename StaticVisitor>
static inline void IterateBodyImpl(Heap* heap, HeapObject* obj,
int start_offset, int end_offset);
};
// This class describes a body of an object of a fixed size
// in which all pointer fields are located in the [start_offset, end_offset)
// interval.
template <int start_offset, int end_offset, int size>
class FixedBodyDescriptor final : public BodyDescriptorBase {
public:
static const int kStartOffset = start_offset;
static const int kEndOffset = end_offset;
static const int kSize = size;
static bool IsValidSlot(HeapObject* obj, int offset) {
return offset >= kStartOffset && offset < kEndOffset;
}
template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, ObjectVisitor* v) {
IteratePointers(obj, start_offset, end_offset, v);
}
template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size,
ObjectVisitor* v) {
IterateBody(obj, v);
}
template <typename StaticVisitor>
static inline void IterateBody(HeapObject* obj) {
Heap* heap = obj->GetHeap();
IteratePointers<StaticVisitor>(heap, obj, start_offset, end_offset);
}
template <typename StaticVisitor>
static inline void IterateBody(HeapObject* obj, int object_size) {
IterateBody<StaticVisitor>(obj);
}
static inline int SizeOf(Map* map, HeapObject* object) { return kSize; }
};
// This class describes a body of an object of a variable size
// in which all pointer fields are located in the [start_offset, object_size)
// interval.
template <int start_offset>
class FlexibleBodyDescriptor final : public BodyDescriptorBase {
public:
static const int kStartOffset = start_offset;
static bool IsValidSlot(HeapObject* obj, int offset) {
return (offset >= kStartOffset);
}
template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size,
ObjectVisitor* v) {
IteratePointers(obj, start_offset, object_size, v);
}
template <typename StaticVisitor>
static inline void IterateBody(HeapObject* obj, int object_size) {
Heap* heap = obj->GetHeap();
IteratePointers<StaticVisitor>(heap, obj, start_offset, object_size);
}
static inline int SizeOf(Map* map, HeapObject* object);
};
typedef FlexibleBodyDescriptor<HeapObject::kHeaderSize> StructBodyDescriptor;
} // namespace internal
} // namespace v8
#endif // V8_OBJECTS_BODY_DESCRIPTORS_H_