Type type,
const char* name,
SnapshotObjectId id,
- int self_size)
+ size_t self_size)
: type_(type),
children_count_(0),
children_index_(-1),
void HeapEntry::Print(
const char* prefix, const char* edge_name, int max_depth, int indent) {
STATIC_CHECK(sizeof(unsigned) == sizeof(id()));
- OS::Print("%6d @%6u %*c %s%s: ",
+ OS::Print("%6"V8PRIuPTR" @%6u %*c %s%s: ",
self_size(), id(), indent, ' ', prefix, edge_name);
if (type() != kString) {
OS::Print("%s %.40s\n", TypeAsString(), name_);
template <> struct SnapshotSizeConstants<8> {
static const int kExpectedHeapGraphEdgeSize = 24;
- static const int kExpectedHeapEntrySize = 32;
+ static const int kExpectedHeapEntrySize = 40;
};
} // namespace
HeapEntry* HeapSnapshot::AddEntry(HeapEntry::Type type,
const char* name,
SnapshotObjectId id,
- int size) {
+ size_t size) {
HeapEntry entry(this, type, name, id, size);
entries_.Add(entry);
return &entries_.last();
HeapEntry* V8HeapExplorer::AddEntry(Address address,
HeapEntry::Type type,
const char* name,
- int size) {
+ size_t size) {
SnapshotObjectId object_id = heap_object_map_->FindOrAddEntry(address, size);
return snapshot_->AddEntry(type, name, object_id, size);
}
class JSArrayBufferDataEntryAllocator : public HeapEntriesAllocator {
public:
- JSArrayBufferDataEntryAllocator(int size, V8HeapExplorer* explorer)
+ JSArrayBufferDataEntryAllocator(size_t size, V8HeapExplorer* explorer)
: size_(size)
, explorer_(explorer) {
}
HeapEntry::kNative, "system / JSArrayBufferData", size_);
}
private:
- int size_;
+ size_t size_;
V8HeapExplorer* explorer_;
};
if (!buffer->backing_store())
return;
size_t data_size = NumberToSize(heap_->isolate(), buffer->byte_length());
- CHECK(data_size <= static_cast<size_t>(kMaxInt));
- JSArrayBufferDataEntryAllocator allocator(static_cast<int>(data_size), this);
+ JSArrayBufferDataEntryAllocator allocator(data_size, this);
HeapEntry* data_entry =
filler_->FindOrAddEntry(buffer->backing_store(), &allocator);
filler_->SetNamedReference(HeapGraphEdge::kInternal,
}
-static int utoa(unsigned value, const Vector<char>& buffer, int buffer_pos) {
+namespace {
+
+template<size_t size> struct ToUnsigned;
+
+template<> struct ToUnsigned<4> {
+ typedef uint32_t Type;
+};
+
+template<> struct ToUnsigned<8> {
+ typedef uint64_t Type;
+};
+
+} // namespace
+
+
+template<typename T>
+static int utoa_impl(T value, const Vector<char>& buffer, int buffer_pos) {
+ STATIC_CHECK(static_cast<T>(-1) > 0); // Check that T is unsigned
int number_of_digits = 0;
- unsigned t = value;
+ T t = value;
do {
++number_of_digits;
} while (t /= 10);
buffer_pos += number_of_digits;
int result = buffer_pos;
do {
- int last_digit = value % 10;
+ int last_digit = static_cast<int>(value % 10);
buffer[--buffer_pos] = '0' + last_digit;
value /= 10;
} while (value);
}
+template<typename T>
+static int utoa(T value, const Vector<char>& buffer, int buffer_pos) {
+ typename ToUnsigned<sizeof(value)>::Type unsigned_value = value;
+ STATIC_CHECK(sizeof(value) == sizeof(unsigned_value));
+ return utoa_impl(unsigned_value, buffer, buffer_pos);
+}
+
+
void HeapSnapshotJSONSerializer::SerializeEdge(HeapGraphEdge* edge,
bool first_edge) {
// The buffer needs space for 3 unsigned ints, 3 commas, \n and \0
void HeapSnapshotJSONSerializer::SerializeNode(HeapEntry* entry) {
- // The buffer needs space for 5 unsigned ints, 5 commas, \n and \0
+ // The buffer needs space for 4 unsigned ints, 1 size_t, 5 commas, \n and \0
static const int kBufferSize =
- 5 * MaxDecimalDigitsIn<sizeof(unsigned)>::kUnsigned // NOLINT
+ 4 * MaxDecimalDigitsIn<sizeof(unsigned)>::kUnsigned // NOLINT
+ + MaxDecimalDigitsIn<sizeof(size_t)>::kUnsigned // NOLINT
+ 5 + 1 + 1;
EmbeddedVector<char, kBufferSize> buffer;
int buffer_pos = 0;
Type type,
const char* name,
SnapshotObjectId id,
- int self_size);
+ size_t self_size);
HeapSnapshot* snapshot() { return snapshot_; }
Type type() { return static_cast<Type>(type_); }
const char* name() { return name_; }
void set_name(const char* name) { name_ = name; }
inline SnapshotObjectId id() { return id_; }
- int self_size() { return self_size_; }
+ size_t self_size() { return self_size_; }
INLINE(int index() const);
int children_count() const { return children_count_; }
INLINE(int set_children_index(int index));
unsigned type_: 4;
int children_count_: 28;
int children_index_;
- int self_size_;
+ size_t self_size_;
SnapshotObjectId id_;
HeapSnapshot* snapshot_;
const char* name_;
HeapEntry* AddEntry(HeapEntry::Type type,
const char* name,
SnapshotObjectId id,
- int size);
+ size_t size);
HeapEntry* AddRootEntry();
HeapEntry* AddGcRootsEntry();
HeapEntry* AddGcSubrootEntry(int tag);
HeapEntry* AddEntry(Address address,
HeapEntry::Type type,
const char* name,
- int size);
+ size_t size);
static String* GetConstructorName(JSObject* object);
CHECK_NE(NULL, x2);
// Test sizes.
- CHECK_NE(0, x->GetSelfSize());
- CHECK_NE(0, x1->GetSelfSize());
- CHECK_NE(0, x2->GetSelfSize());
+ CHECK_NE(0, static_cast<int>(x->GetShallowSize()));
+ CHECK_NE(0, static_cast<int>(x1->GetShallowSize()));
+ CHECK_NE(0, static_cast<int>(x2->GetShallowSize()));
}
"elements");
CHECK_NE(NULL, elements);
CHECK_EQ(v8::HeapGraphNode::kArray, elements->GetType());
- CHECK_EQ(v8::internal::FixedArray::SizeFor(3), elements->GetSelfSize());
+ CHECK_EQ(v8::internal::FixedArray::SizeFor(3),
+ static_cast<int>(elements->GetShallowSize()));
v8::Handle<v8::Value> array_val =
heap_profiler->FindObjectById(transition_info->GetId());
const v8::HeapGraphNode* backing_store =
GetProperty(arr1_buffer, v8::HeapGraphEdge::kInternal, "backing_store");
CHECK_NE(NULL, backing_store);
- CHECK_EQ(400, backing_store->GetSelfSize());
+ CHECK_EQ(400, static_cast<int>(backing_store->GetShallowSize()));
}