Commit 20ce87be authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

[cleanup] Fix more header includes to allow individual compilation

Fixes:
  src/parsing/parse-info.h
  src/parsing/preparsed-scope-data.h
  src/profiler/heap-profiler.h
  src/profiler/heap-snapshot-generator.h
  src/profiler/heap-snapshot-generator-inl.h'
  src/property.h
  src/prototype.h
  src/prototype-inl.h

Bug: v8:7754,v8:7490,v8:7965
Change-Id: Iba14292cdfbbaf29d5b989c16d579a1ee0edcc25
Reviewed-on: https://chromium-review.googlesource.com/1154967
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54787}
parent d854d351
......@@ -449,6 +449,11 @@ Handle<PodArray<T>> PodArray<T>::New(Isolate* isolate, int length,
isolate->factory()->NewByteArray(length * sizeof(T), pretenure));
}
template <class T>
int PodArray<T>::length() {
return ByteArray::length() / sizeof(T);
}
void* FixedTypedArrayBase::external_pointer() const {
intptr_t ptr = READ_INTPTR_FIELD(this, kExternalPointerOffset);
return reinterpret_cast<void*>(ptr);
......
......@@ -611,7 +611,7 @@ class PodArray : public ByteArray {
copy_in(index * sizeof(T), reinterpret_cast<const byte*>(&value),
sizeof(T));
}
int length() { return ByteArray::length() / sizeof(T); }
inline int length();
DECL_CAST(PodArray<T>)
private:
......
......@@ -481,6 +481,11 @@ uint8_t ConsumedPreParsedScopeData::ByteData::ReadQuarter() {
return result;
}
size_t ConsumedPreParsedScopeData::ByteData::RemainingBytes() const {
DCHECK_NOT_NULL(data_);
return data_->length() - index_;
}
ConsumedPreParsedScopeData::ConsumedPreParsedScopeData()
: isolate_(nullptr), scope_data_(new ByteData()), child_index_(0) {}
......
......@@ -212,10 +212,7 @@ class ConsumedPreParsedScopeData {
uint8_t ReadUint8();
uint8_t ReadQuarter();
size_t RemainingBytes() const {
DCHECK_NOT_NULL(data_);
return data_->length() - index_;
}
size_t RemainingBytes() const;
// private:
PodArray<uint8_t>* data_;
......
......@@ -222,6 +222,8 @@ void HeapProfiler::ClearHeapObjectMap() {
Heap* HeapProfiler::heap() const { return ids_->heap(); }
Isolate* HeapProfiler::isolate() const { return heap()->isolate(); }
void HeapProfiler::QueryObjects(Handle<Context> context,
debug::QueryObjectPredicate* predicate,
PersistentValueVector<v8::Object>* objects) {
......
......@@ -85,7 +85,7 @@ class HeapProfiler : public HeapObjectAllocationTracker {
Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id);
void ClearHeapObjectMap();
Isolate* isolate() const { return heap()->isolate(); }
Isolate* isolate() const;
void QueryObjects(Handle<Context> context,
debug::QueryObjectPredicate* predicate,
......
......@@ -7,6 +7,9 @@
#include "src/profiler/heap-snapshot-generator.h"
#include "src/profiler/heap-profiler.h"
#include "src/string-hasher-inl.h"
namespace v8 {
namespace internal {
......@@ -38,6 +41,12 @@ int HeapEntry::set_children_index(int index) {
return next_index;
}
void HeapEntry::add_child(HeapGraphEdge* edge) {
*(children_begin() + children_count_++) = edge;
}
HeapGraphEdge* HeapEntry::child(int i) { return *(children_begin() + i); }
std::deque<HeapGraphEdge*>::iterator HeapEntry::children_begin() {
DCHECK_GE(children_index_, 0);
SLOW_DCHECK(
......@@ -51,9 +60,19 @@ std::deque<HeapGraphEdge*>::iterator HeapEntry::children_end() {
return children_begin() + children_count_;
}
Isolate* HeapEntry::isolate() const { return snapshot_->profiler()->isolate(); }
uint32_t HeapSnapshotJSONSerializer::StringHash(const void* string) {
const char* s = reinterpret_cast<const char*>(string);
int len = static_cast<int>(strlen(s));
return StringHasher::HashSequentialString(s, len,
v8::internal::kZeroHashSeed);
}
int HeapSnapshotJSONSerializer::entry_index(const HeapEntry* e) {
return e->index() * kNodeFieldsCount;
}
} // namespace internal
} // namespace v8
......
......@@ -125,10 +125,8 @@ class HeapEntry BASE_EMBEDDED {
V8_INLINE int index() const;
int children_count() const { return children_count_; }
V8_INLINE int set_children_index(int index);
void add_child(HeapGraphEdge* edge) {
*(children_begin() + children_count_++) = edge;
}
HeapGraphEdge* child(int i) { return *(children_begin() + i); }
V8_INLINE void add_child(HeapGraphEdge* edge);
V8_INLINE HeapGraphEdge* child(int i);
V8_INLINE Isolate* isolate() const;
void SetIndexedReference(
......@@ -593,15 +591,10 @@ class HeapSnapshotJSONSerializer {
reinterpret_cast<char*>(key2)) == 0;
}
V8_INLINE static uint32_t StringHash(const void* string) {
const char* s = reinterpret_cast<const char*>(string);
int len = static_cast<int>(strlen(s));
return StringHasher::HashSequentialString(
s, len, v8::internal::kZeroHashSeed);
}
V8_INLINE static uint32_t StringHash(const void* string);
int GetStringId(const char* s);
int entry_index(const HeapEntry* e) { return e->index() * kNodeFieldsCount; }
V8_INLINE int entry_index(const HeapEntry* e);
void SerializeEdge(HeapGraphEdge* edge, bool first_edge);
void SerializeEdges();
void SerializeImpl();
......
......@@ -7,6 +7,7 @@
#include "src/field-type.h"
#include "src/handles-inl.h"
#include "src/objects-inl.h"
#include "src/objects/name-inl.h"
#include "src/ostreams.h"
namespace v8 {
......@@ -22,6 +23,27 @@ std::ostream& operator<<(std::ostream& os,
return os;
}
Descriptor::Descriptor() : details_(Smi::kZero) {}
Descriptor::Descriptor(Handle<Name> key, MaybeObjectHandle value,
PropertyKind kind, PropertyAttributes attributes,
PropertyLocation location, PropertyConstness constness,
Representation representation, int field_index)
: key_(key),
value_(value),
details_(kind, attributes, location, constness, representation,
field_index) {
DCHECK(key->IsUniqueName());
DCHECK_IMPLIES(key->IsPrivate(), !details_.IsEnumerable());
}
Descriptor::Descriptor(Handle<Name> key, MaybeObjectHandle value,
PropertyDetails details)
: key_(key), value_(value), details_(details) {
DCHECK(key->IsUniqueName());
DCHECK_IMPLIES(key->IsPrivate(), !details_.IsEnumerable());
}
Descriptor Descriptor::DataField(Isolate* isolate, Handle<Name> key,
int field_index, PropertyAttributes attributes,
Representation representation) {
......@@ -40,6 +62,13 @@ Descriptor Descriptor::DataField(Handle<Name> key, int field_index,
return Descriptor(key, wrapped_field_type, details);
}
Descriptor Descriptor::DataConstant(Handle<Name> key, Handle<Object> value,
PropertyAttributes attributes) {
return Descriptor(key, MaybeObjectHandle(value), kData, attributes,
kDescriptor, PropertyConstness::kConst,
value->OptimalRepresentation(), 0);
}
Descriptor Descriptor::DataConstant(Isolate* isolate, Handle<Name> key,
int field_index, Handle<Object> value,
PropertyAttributes attributes) {
......@@ -55,6 +84,14 @@ Descriptor Descriptor::DataConstant(Isolate* isolate, Handle<Name> key,
}
}
Descriptor Descriptor::AccessorConstant(Handle<Name> key,
Handle<Object> foreign,
PropertyAttributes attributes) {
return Descriptor(key, MaybeObjectHandle(foreign), kAccessor, attributes,
kDescriptor, PropertyConstness::kConst,
Representation::Tagged(), 0);
}
// Outputs PropertyDetails as a dictionary details.
void PropertyDetails::PrintAsSlowTo(std::ostream& os) {
os << "(";
......
......@@ -24,7 +24,7 @@ namespace internal {
// optionally a piece of data.
class Descriptor final BASE_EMBEDDED {
public:
Descriptor() : details_(Smi::kZero) {}
Descriptor();
Handle<Name> GetKey() const { return key_; }
MaybeObjectHandle GetValue() const { return value_; }
......@@ -43,22 +43,14 @@ class Descriptor final BASE_EMBEDDED {
MaybeObjectHandle wrapped_field_type);
static Descriptor DataConstant(Handle<Name> key, Handle<Object> value,
PropertyAttributes attributes) {
return Descriptor(key, MaybeObjectHandle(value), kData, attributes,
kDescriptor, PropertyConstness::kConst,
value->OptimalRepresentation(), 0);
}
PropertyAttributes attributes);
static Descriptor DataConstant(Isolate* isolate, Handle<Name> key,
int field_index, Handle<Object> value,
PropertyAttributes attributes);
static Descriptor AccessorConstant(Handle<Name> key, Handle<Object> foreign,
PropertyAttributes attributes) {
return Descriptor(key, MaybeObjectHandle(foreign), kAccessor, attributes,
kDescriptor, PropertyConstness::kConst,
Representation::Tagged(), 0);
}
PropertyAttributes attributes);
private:
Handle<Name> key_;
......@@ -66,23 +58,13 @@ class Descriptor final BASE_EMBEDDED {
PropertyDetails details_;
protected:
Descriptor(Handle<Name> key, MaybeObjectHandle value, PropertyDetails details)
: key_(key), value_(value), details_(details) {
DCHECK(key->IsUniqueName());
DCHECK_IMPLIES(key->IsPrivate(), !details_.IsEnumerable());
}
Descriptor(Handle<Name> key, MaybeObjectHandle value,
PropertyDetails details);
Descriptor(Handle<Name> key, MaybeObjectHandle value, PropertyKind kind,
PropertyAttributes attributes, PropertyLocation location,
PropertyConstness constness, Representation representation,
int field_index)
: key_(key),
value_(value),
details_(kind, attributes, location, constness, representation,
field_index) {
DCHECK(key->IsUniqueName());
DCHECK_IMPLIES(key->IsPrivate(), !details_.IsEnumerable());
}
int field_index);
friend class MapUpdater;
};
......
......@@ -5,9 +5,11 @@
#ifndef V8_PROTOTYPE_INL_H_
#define V8_PROTOTYPE_INL_H_
#include "src/handles-inl.h"
#include "src/prototype.h"
#include "src/handles-inl.h"
#include "src/objects/map-inl.h"
namespace v8 {
namespace internal {
......@@ -36,6 +38,36 @@ PrototypeIterator::PrototypeIterator(Isolate* isolate, JSReceiver* receiver,
if (where_to_start == kStartAtPrototype) Advance();
}
PrototypeIterator::PrototypeIterator(Isolate* isolate, Map* receiver_map,
WhereToEnd where_to_end)
: isolate_(isolate),
object_(receiver_map->GetPrototypeChainRootMap(isolate_)->prototype()),
where_to_end_(where_to_end),
is_at_end_(object_->IsNull(isolate_)),
seen_proxies_(0) {
if (!is_at_end_ && where_to_end_ == END_AT_NON_HIDDEN) {
DCHECK(object_->IsJSReceiver());
Map* map = JSReceiver::cast(object_)->map();
is_at_end_ = !map->has_hidden_prototype();
}
}
PrototypeIterator::PrototypeIterator(Isolate* isolate, Handle<Map> receiver_map,
WhereToEnd where_to_end)
: isolate_(isolate),
object_(nullptr),
handle_(receiver_map->GetPrototypeChainRootMap(isolate_)->prototype(),
isolate_),
where_to_end_(where_to_end),
is_at_end_(handle_->IsNull(isolate_)),
seen_proxies_(0) {
if (!is_at_end_ && where_to_end_ == END_AT_NON_HIDDEN) {
DCHECK(handle_->IsJSReceiver());
Map* map = JSReceiver::cast(*handle_)->map();
is_at_end_ = !map->has_hidden_prototype();
}
}
bool PrototypeIterator::HasAccess() const {
// We can only perform access check in the handlified version of the
// PrototypeIterator.
......
......@@ -35,35 +35,11 @@ class PrototypeIterator {
WhereToStart where_to_start = kStartAtPrototype,
WhereToEnd where_to_end = END_AT_NULL);
explicit PrototypeIterator(Isolate* isolate, Map* receiver_map,
WhereToEnd where_to_end = END_AT_NULL)
: isolate_(isolate),
object_(receiver_map->GetPrototypeChainRootMap(isolate_)->prototype()),
where_to_end_(where_to_end),
is_at_end_(object_->IsNull(isolate_)),
seen_proxies_(0) {
if (!is_at_end_ && where_to_end_ == END_AT_NON_HIDDEN) {
DCHECK(object_->IsJSReceiver());
Map* map = JSReceiver::cast(object_)->map();
is_at_end_ = !map->has_hidden_prototype();
}
}
inline explicit PrototypeIterator(Isolate* isolate, Map* receiver_map,
WhereToEnd where_to_end = END_AT_NULL);
explicit PrototypeIterator(Isolate* isolate, Handle<Map> receiver_map,
WhereToEnd where_to_end = END_AT_NULL)
: isolate_(isolate),
object_(nullptr),
handle_(receiver_map->GetPrototypeChainRootMap(isolate_)->prototype(),
isolate_),
where_to_end_(where_to_end),
is_at_end_(handle_->IsNull(isolate_)),
seen_proxies_(0) {
if (!is_at_end_ && where_to_end_ == END_AT_NON_HIDDEN) {
DCHECK(handle_->IsJSReceiver());
Map* map = JSReceiver::cast(*handle_)->map();
is_at_end_ = !map->has_hidden_prototype();
}
}
inline explicit PrototypeIterator(Isolate* isolate, Handle<Map> receiver_map,
WhereToEnd where_to_end = END_AT_NULL);
~PrototypeIterator() {}
......
......@@ -5,9 +5,11 @@
#ifndef V8_STRING_HASHER_INL_H_
#define V8_STRING_HASHER_INL_H_
#include "src/string-hasher.h"
#include "src/char-predicates-inl.h"
#include "src/objects.h"
#include "src/string-hasher.h"
#include "src/objects/string-inl.h"
namespace v8 {
namespace internal {
......
......@@ -54,16 +54,8 @@ AUTO_EXCLUDE = [
'src/json-stringifier.h',
'src/keys.h',
'src/lookup.h',
'src/parsing/parse-info.h',
'src/parsing/parser.h',
'src/parsing/preparsed-scope-data.h',
'src/parsing/preparser.h',
'src/profiler/heap-profiler.h',
'src/profiler/heap-snapshot-generator.h',
'src/profiler/heap-snapshot-generator-inl.h',
'src/property.h',
'src/prototype.h',
'src/prototype-inl.h',
'src/regexp/jsregexp.h',
'src/regexp/jsregexp-inl.h',
'src/snapshot/object-deserializer.h',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment