41 #include "../include/v8-profiler.h"
51 class NamedEntriesDetector {
53 NamedEntriesDetector()
57 void CheckEntry(i::HeapEntry* entry) {
58 if (strcmp(entry->name(),
"A2") == 0) has_A2 =
true;
59 if (strcmp(entry->name(),
"B2") == 0) has_B2 =
true;
60 if (strcmp(entry->name(),
"C2") == 0) has_C2 =
true;
63 static bool AddressesMatch(
void* key1,
void* key2) {
67 void CheckAllReachables(i::HeapEntry* root) {
72 while (!list.is_empty()) {
73 i::HeapEntry* entry = list.RemoveLast();
75 for (
int i = 0; i < children.
length(); ++i) {
76 if (children[i]->type() == i::HeapGraphEdge::kShortcut)
continue;
77 i::HeapEntry* child = children[i]->to();
78 i::HashMap::Entry* entry = visited.Lookup(
79 reinterpret_cast<void*>(child),
80 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(child)),
84 entry->value =
reinterpret_cast<void*
>(1);
105 CHECK_EQ(0, strncmp(
"Object", const_cast<i::HeapEntry*>(
106 reinterpret_cast<const i::HeapEntry*>(global_obj))->
name(), 6));
117 if (prop->
GetType() == type && strcmp(name, *prop_name) == 0)
130 if (strcmp(contents, *node_name) == 0)
return true;
137 static bool AddressesMatch(
void* key1,
void* key2) {
143 static bool ValidateSnapshot(
const v8::HeapSnapshot* snapshot,
int depth = 3) {
149 for (
int i = 0; i < edges.length(); ++i) {
150 i::HashMap::Entry* entry = visited.Lookup(
151 reinterpret_cast<void*>(edges[i].to()),
152 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(edges[i].to())),
154 uint32_t ref_count =
static_cast<uint32_t
>(
155 reinterpret_cast<uintptr_t
>(entry->value));
156 entry->value =
reinterpret_cast<void*
>(ref_count + 1);
158 uint32_t unretained_entries_count = 0;
160 for (
int i = 0; i < entries.length(); ++i) {
161 i::HashMap::Entry* entry = visited.Lookup(
162 reinterpret_cast<void*>(&entries[i]),
163 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(&entries[i])),
165 if (!entry && entries[i].
id() != 1) {
166 entries[i].Print(
"entry with no retainer",
"", depth, 0);
167 ++unretained_entries_count;
170 return unretained_entries_count == 0;
181 "function B2(x) { return function() { return typeof x; }; }\n"
182 "function C2(x) { this.x1 = x; this.x2 = x; this[1] = x; }\n"
183 "var a2 = new A2();\n"
184 "var b2_1 = new B2(a2), b2_2 = new B2(a2);\n"
185 "var c2 = new C2(a2);");
187 heap_profiler->TakeHeapSnapshot(v8_str(
"env2"));
188 CHECK(ValidateSnapshot(snapshot_env2));
201 NamedEntriesDetector det;
202 det.CheckAllReachables(const_cast<i::HeapEntry*>(
203 reinterpret_cast<const i::HeapEntry*>(global_env2)));
210 TEST(HeapSnapshotObjectSizes) {
218 "function X(a, b) { this.a = a; this.b = b; }\n"
219 "x = new X(new X(), new X());\n"
221 "(function() { x.a.a = x.b; })();");
223 heap_profiler->TakeHeapSnapshot(v8_str(
"sizes"));
224 CHECK(ValidateSnapshot(snapshot));
243 TEST(BoundFunctionInSnapshot) {
248 "function myFunction(a, b) { this.a = a; this.b = b; }\n"
249 "function AAAAA() {}\n"
250 "boundFunction = myFunction.bind(new AAAAA(), 20, new Number(12)); \n");
252 heap_profiler->TakeHeapSnapshot(v8_str(
"sizes"));
253 CHECK(ValidateSnapshot(snapshot));
264 CHECK_EQ(4, bindings->GetChildrenCount());
273 CHECK(bound_function);
278 CHECK(bound_argument);
283 TEST(HeapSnapshotEntryChildren) {
292 heap_profiler->TakeHeapSnapshot(v8_str(
"children"));
293 CHECK(ValidateSnapshot(snapshot));
309 TEST(HeapSnapshotCodeObjects) {
315 "function lazy(x) { return x - 1; }\n"
316 "function compiled(x) { return x + 1; }\n"
317 "var anonymous = (function() { return function() { return 0; } })();\n"
320 heap_profiler->TakeHeapSnapshot(v8_str(
"code"));
321 CHECK(ValidateSnapshot(snapshot));
359 bool compiled_references_x =
false, lazy_references_x =
false;
360 for (
int i = 0, count = compiled_code->
GetChildrenCount(); i < count; ++i) {
364 if (HasString(node,
"x")) {
365 compiled_references_x =
true;
374 if (HasString(node,
"x")) {
375 lazy_references_x =
true;
380 CHECK(compiled_references_x);
381 CHECK(!lazy_references_x);
385 TEST(HeapSnapshotHeapNumbers) {
390 "a = 1; // a is Smi\n"
391 "b = 2.5; // b is HeapNumber");
393 heap_profiler->TakeHeapSnapshot(v8_str(
"numbers"));
394 CHECK(ValidateSnapshot(snapshot));
404 TEST(HeapSnapshotSlicedString) {
409 "parent_string = \"123456789.123456789.123456789.123456789.123456789."
410 "123456789.123456789.123456789.123456789.123456789."
411 "123456789.123456789.123456789.123456789.123456789."
412 "123456789.123456789.123456789.123456789.123456789.\";"
413 "child_string = parent_string.slice(100);");
415 heap_profiler->TakeHeapSnapshot(v8_str(
"strings"));
416 CHECK(ValidateSnapshot(snapshot));
428 heap_profiler->DeleteAllHeapSnapshots();
455 CHECK(ValidateSnapshot(snapshot));
476 TEST(HeapSnapshotInternalReferences) {
492 CHECK(ValidateSnapshot(snapshot));
504 #define CHECK_EQ_SNAPSHOT_OBJECT_ID(a, b) \
505 CHECK_EQ(static_cast<int32_t>(a), static_cast<int32_t>(b))
506 #define CHECK_NE_SNAPSHOT_OBJECT_ID(a, b) \
507 CHECK((a) != (b)) // NOLINT
509 TEST(HeapSnapshotAddressReuse) {
517 "for (var i = 0; i < 10000; ++i)\n"
518 " a[i] = new A();\n");
520 heap_profiler->TakeHeapSnapshot(v8_str(
"snapshot1"));
521 CHECK(ValidateSnapshot(snapshot1));
525 "for (var i = 0; i < 10000; ++i)\n"
526 " a[i] = new A();\n");
530 heap_profiler->TakeHeapSnapshot(v8_str(
"snapshot2"));
531 CHECK(ValidateSnapshot(snapshot2));
550 TEST(HeapEntryIdsAndArrayShift) {
556 "function AnObject() {\n"
557 " this.first = 'first';\n"
558 " this.second = 'second';\n"
560 "var a = new Array();\n"
561 "for (var i = 0; i < 10; ++i)\n"
562 " a.push(new AnObject());\n");
564 heap_profiler->TakeHeapSnapshot(v8_str(
"s1"));
565 CHECK(ValidateSnapshot(snapshot1));
568 "for (var i = 0; i < 1; ++i)\n"
574 heap_profiler->TakeHeapSnapshot(v8_str(
"s2"));
575 CHECK(ValidateSnapshot(snapshot2));
607 "function B(x) { this.x = x; }\n"
609 "var b = new B(a);");
613 heap_profiler->TakeHeapSnapshot(s1_str);
614 CHECK(ValidateSnapshot(snapshot1));
619 heap_profiler->TakeHeapSnapshot(s2_str);
620 CHECK(ValidateSnapshot(snapshot2));
665 TEST(HeapSnapshotRootPreservedAfterSorting) {
670 heap_profiler->TakeHeapSnapshot(v8_str(
"s"));
671 CHECK(ValidateSnapshot(snapshot));
684 TestJSONStream() : eos_signaled_(0), abort_countdown_(-1) {}
685 explicit TestJSONStream(
int abort_countdown)
686 : eos_signaled_(0), abort_countdown_(abort_countdown) {}
687 virtual ~TestJSONStream() {}
690 if (abort_countdown_ > 0) --abort_countdown_;
691 if (abort_countdown_ == 0)
return kAbort;
697 virtual WriteResult WriteUint32Chunk(uint32_t* buffer,
int chars_written) {
702 int eos_signaled() {
return eos_signaled_; }
703 int size() {
return buffer_.size(); }
708 int abort_countdown_;
714 length_ =
string.length();
716 virtual const char*
data()
const {
return data_; }
717 virtual size_t length()
const {
return length_; }
725 TEST(HeapSnapshotJSONSerialization) {
730 #define STRING_LITERAL_FOR_TEST \
731 "\"String \\n\\r\\u0008\\u0081\\u0101\\u0801\\u8001\""
733 "function A(s) { this.s = s; }\n"
734 "function B(x) { this.x = x; }\n"
736 "var b = new B(a);");
738 heap_profiler->TakeHeapSnapshot(v8_str(
"json"));
739 CHECK(ValidateSnapshot(snapshot));
741 TestJSONStream stream;
746 stream.WriteTo(json);
749 AsciiResource* json_res =
new AsciiResource(json);
752 env->
Global()->Set(v8_str(
"json_snapshot"), json_string);
754 "var parsed = JSON.parse(json_snapshot); true;");
759 env->
Global()->Get(v8_str(
"parsed"))->ToObject();
760 CHECK(parsed_snapshot->Has(v8_str(
"snapshot")));
761 CHECK(parsed_snapshot->Has(v8_str(
"nodes")));
762 CHECK(parsed_snapshot->Has(v8_str(
"edges")));
763 CHECK(parsed_snapshot->Has(v8_str(
"strings")));
767 "var meta = parsed.snapshot.meta;\n"
768 "var edge_count_offset = meta.node_fields.indexOf('edge_count');\n"
769 "var node_fields_count = meta.node_fields.length;\n"
770 "var edge_fields_count = meta.edge_fields.length;\n"
771 "var edge_type_offset = meta.edge_fields.indexOf('type');\n"
772 "var edge_name_offset = meta.edge_fields.indexOf('name_or_index');\n"
773 "var edge_to_node_offset = meta.edge_fields.indexOf('to_node');\n"
774 "var property_type ="
775 " meta.edge_types[edge_type_offset].indexOf('property');\n"
776 "var shortcut_type ="
777 " meta.edge_types[edge_type_offset].indexOf('shortcut');\n"
778 "var node_count = parsed.nodes.length / node_fields_count;\n"
779 "var first_edge_indexes = parsed.first_edge_indexes = [];\n"
780 "for (var i = 0, first_edge_index = 0; i < node_count; ++i) {\n"
781 " first_edge_indexes[i] = first_edge_index;\n"
782 " first_edge_index += edge_fields_count *\n"
783 " parsed.nodes[i * node_fields_count + edge_count_offset];\n"
785 "first_edge_indexes[node_count] = first_edge_index;\n");
786 CHECK(!meta_analysis_result.IsEmpty());
790 "function GetChildPosByProperty(pos, prop_name, prop_type) {\n"
791 " var nodes = parsed.nodes;\n"
792 " var edges = parsed.edges;\n"
793 " var strings = parsed.strings;\n"
794 " var node_ordinal = pos / node_fields_count;\n"
795 " for (var i = parsed.first_edge_indexes[node_ordinal],\n"
796 " count = parsed.first_edge_indexes[node_ordinal + 1];\n"
797 " i < count; i += edge_fields_count) {\n"
798 " if (edges[i + edge_type_offset] === prop_type\n"
799 " && strings[edges[i + edge_name_offset]] === prop_name)\n"
800 " return edges[i + edge_to_node_offset];\n"
806 "GetChildPosByProperty(\n"
807 " GetChildPosByProperty(\n"
808 " GetChildPosByProperty("
809 " parsed.edges[edge_fields_count + edge_to_node_offset],"
810 " \"b\", property_type),\n"
811 " \"x\", property_type),"
812 " \"s\", property_type)");
815 static_cast<int>(string_obj_pos_val->ToNumber()->Value());
817 parsed_snapshot->Get(v8_str(
"nodes"))->ToObject();
818 int string_index =
static_cast<int>(
819 nodes_array->
Get(string_obj_pos + 1)->ToNumber()->Value());
822 parsed_snapshot->Get(v8_str(
"strings"))->ToObject();
826 #undef STRING_LITERAL_FOR_TEST
832 TEST(HeapSnapshotJSONSerializationAborting) {
837 heap_profiler->TakeHeapSnapshot(v8_str(
"abort"));
838 CHECK(ValidateSnapshot(snapshot));
839 TestJSONStream stream(5);
855 first_interval_index_(-1) { }
856 TestStatsStream(
const TestStatsStream& stream)
857 : v8::OutputStream(stream),
858 eos_signaled_(stream.eos_signaled_),
859 updates_written_(stream.updates_written_),
860 entries_count_(stream.entries_count_),
861 entries_size_(stream.entries_size_),
862 intervals_count_(stream.intervals_count_),
863 first_interval_index_(stream.first_interval_index_) { }
864 virtual ~TestStatsStream() {}
871 int updates_written) {
874 updates_written_ += updates_written;
876 if (first_interval_index_ == -1 && updates_written != 0)
877 first_interval_index_ = buffer[0].
index;
878 for (
int i = 0; i < updates_written; ++i) {
879 entries_count_ += buffer[i].
count;
880 entries_size_ += buffer[i].
size;
885 int eos_signaled() {
return eos_signaled_; }
886 int updates_written() {
return updates_written_; }
887 uint32_t entries_count()
const {
return entries_count_; }
888 uint32_t entries_size()
const {
return entries_size_; }
889 int intervals_count()
const {
return intervals_count_; }
890 int first_interval_index()
const {
return first_interval_index_; }
894 int updates_written_;
895 uint32_t entries_count_;
896 uint32_t entries_size_;
897 int intervals_count_;
898 int first_interval_index_;
903 static TestStatsStream GetHeapStatsUpdate(
906 TestStatsStream stream;
909 *object_id = last_seen_id;
915 TEST(HeapSnapshotObjectsStats) {
923 for (
int i = 0; i < 6; ++i) {
930 TestStatsStream stats_update = GetHeapStatsUpdate(heap_profiler,
932 CHECK_EQ(1, stats_update.intervals_count());
933 CHECK_EQ(1, stats_update.updates_written());
934 CHECK_LT(0, stats_update.entries_size());
935 CHECK_EQ(0, stats_update.first_interval_index());
940 CHECK_EQ(0, GetHeapStatsUpdate(heap_profiler, &same_id).updates_written());
949 TestStatsStream stats_update = GetHeapStatsUpdate(heap_profiler,
950 &additional_string_id);
951 CHECK_LT(same_id, additional_string_id);
952 CHECK_EQ(1, stats_update.intervals_count());
953 CHECK_EQ(1, stats_update.updates_written());
954 CHECK_LT(0, stats_update.entries_size());
955 CHECK_EQ(1, stats_update.entries_count());
956 CHECK_EQ(2, stats_update.first_interval_index());
961 CHECK_EQ(0, GetHeapStatsUpdate(heap_profiler, &last_id).updates_written());
968 uint32_t entries_size;
976 TestStatsStream stats_update = GetHeapStatsUpdate(heap_profiler);
977 CHECK_EQ(1, stats_update.intervals_count());
978 CHECK_EQ(1, stats_update.updates_written());
979 CHECK_LT(0, entries_size = stats_update.entries_size());
980 CHECK_EQ(3, stats_update.entries_count());
981 CHECK_EQ(4, stats_update.first_interval_index());
987 TestStatsStream stats_update = GetHeapStatsUpdate(heap_profiler);
988 CHECK_EQ(1, stats_update.intervals_count());
989 CHECK_EQ(1, stats_update.updates_written());
990 CHECK_GT(entries_size, stats_update.entries_size());
991 CHECK_EQ(1, stats_update.entries_count());
993 CHECK_EQ(4, stats_update.first_interval_index());
999 TestStatsStream stats_update = GetHeapStatsUpdate(heap_profiler);
1000 CHECK_EQ(1, stats_update.intervals_count());
1001 CHECK_EQ(1, stats_update.updates_written());
1002 CHECK_EQ(0, stats_update.entries_size());
1003 CHECK_EQ(0, stats_update.entries_count());
1005 CHECK_EQ(4, stats_update.first_interval_index());
1010 TestStatsStream stats_update = GetHeapStatsUpdate(heap_profiler);
1011 CHECK_EQ(1, stats_update.intervals_count());
1012 CHECK_EQ(1, stats_update.updates_written());
1013 CHECK_EQ(0, stats_update.entries_size());
1014 CHECK_EQ(0, stats_update.entries_count());
1016 CHECK_EQ(2, stats_update.first_interval_index());
1022 array->
Set(2, v8_num(7));
1024 uint32_t entries_size;
1027 TestStatsStream stats_update = GetHeapStatsUpdate(heap_profiler);
1028 CHECK_EQ(1, stats_update.intervals_count());
1029 CHECK_EQ(1, stats_update.updates_written());
1030 CHECK_LT(0, entries_size = stats_update.entries_size());
1032 CHECK_EQ(2, stats_update.entries_count());
1033 CHECK_EQ(8, stats_update.first_interval_index());
1036 for (
int i = 0; i < 100; ++i)
1037 array->
Set(i, v8_num(i));
1041 TestStatsStream stats_update = GetHeapStatsUpdate(heap_profiler);
1042 CHECK_EQ(1, stats_update.intervals_count());
1045 CHECK_EQ(2, stats_update.updates_written());
1046 CHECK_LT(entries_size, stats_update.entries_size());
1047 CHECK_EQ(2, stats_update.entries_count());
1048 CHECK_EQ(8, stats_update.first_interval_index());
1051 heap_profiler->StopTrackingHeapObjects();
1061 const int kLength = 10;
1067 for (
int i = 0; i < kLength; i++) {
1070 GetHeapStatsUpdate(heap_profiler);
1072 for (
int i = 0; i < kLength; i++) {
1081 for (
int i = 0; i < kLength; i++) {
1083 CHECK_EQ(static_cast<int>(ids[i]), static_cast<int>(
id));
1089 for (
int i = 0; i < kLength; i++) {
1100 int level,
int max_level) {
1101 if (level > max_level)
return;
1109 CheckChildrenIds(snapshot, child, level + 1, max_level);
1120 heap_profiler->TakeHeapSnapshot(v8_str(
"id"));
1121 CHECK(ValidateSnapshot(snapshot));
1123 CheckChildrenIds(snapshot, root, 0, 3);
1129 TEST(HeapSnapshotGetSnapshotObjectId) {
1133 CompileRun(
"globalObject = {};\n");
1135 heap_profiler->TakeHeapSnapshot(v8_str(
"get_snapshot_object_id"));
1136 CHECK(ValidateSnapshot(snapshot));
1140 CHECK(global_object);
1145 CHECK(globalObjectHandle->IsObject());
1154 TEST(HeapSnapshotUnknownSnapshotObjectId) {
1158 CompileRun(
"globalObject = {};\n");
1160 heap_profiler->TakeHeapSnapshot(v8_str(
"unknown_object_id"));
1161 CHECK(ValidateSnapshot(snapshot));
1172 explicit TestActivityControl(
int abort_count)
1173 : done_(0), total_(0), abort_count_(abort_count) {}
1177 return --abort_count_ != 0 ? kContinue :
kAbort;
1179 int done() {
return done_; }
1180 int total() {
return total_; }
1196 TestActivityControl aborting_control(1);
1198 heap_profiler->TakeHeapSnapshot(v8_str(
"abort"),
1201 CHECK_EQ(snapshots_count, heap_profiler->GetSnapshotCount());
1202 CHECK_GT(aborting_control.total(), aborting_control.done());
1204 TestActivityControl control(-1);
1206 heap_profiler->TakeHeapSnapshot(v8_str(
"full"),
1208 CHECK(ValidateSnapshot(snapshot));
1211 CHECK_EQ(snapshots_count + 1, heap_profiler->GetSnapshotCount());
1212 CHECK_EQ(control.total(), control.done());
1222 const char* group_label,
1224 intptr_t element_count = -1,
1228 group_label_(group_label),
1230 element_count_(element_count),
1232 instances.Add(
this);
1240 return GetHash() == other->GetHash();
1242 virtual intptr_t
GetHash() {
return hash_; }
1243 virtual const char*
GetGroupLabel() {
return group_label_; }
1244 virtual const char*
GetLabel() {
return label_; }
1247 bool disposed() {
return disposed_; }
1251 if (class_id == 1) {
1254 if (strcmp(*utf8,
"AAA") == 0)
1256 else if (strcmp(*utf8,
"BBB") == 0)
1259 }
else if (class_id == 2) {
1262 if (strcmp(*utf8,
"CCC") == 0)
1275 const char* group_label_;
1277 intptr_t element_count_;
1291 if (node->
GetType() == type && strcmp(name,
1292 const_cast<i::HeapEntry*>(
1293 reinterpret_cast<const i::HeapEntry*>(node))->
name()) == 0) {
1301 TEST(HeapSnapshotRetainedObjectInfo) {
1308 1, TestRetainedObjectInfo::WrapperInfoCallback);
1310 2, TestRetainedObjectInfo::WrapperInfoCallback);
1317 CHECK_EQ(0, TestRetainedObjectInfo::instances.length());
1320 CHECK(ValidateSnapshot(snapshot));
1322 CHECK_EQ(3, TestRetainedObjectInfo::instances.length());
1323 for (
int i = 0; i < TestRetainedObjectInfo::instances.length(); ++i) {
1324 CHECK(TestRetainedObjectInfo::instances[i]->disposed());
1325 delete TestRetainedObjectInfo::instances[i];
1335 CHECK_EQ(2, aaa->GetChildrenCount());
1349 CHECK_EQ(1, ccc->GetChildrenCount());
1366 isolate_ = (*env)->GetIsolate();
1370 (*env)->Global()->Set(v8_str(
"root_object"),
1378 instance_->AddImplicitReferences();
1382 void AddImplicitReferences() {
1403 TEST(HeapSnapshotImplicitReferences) {
1412 heap_profiler->TakeHeapSnapshot(v8_str(
"implicit_refs"));
1413 CHECK(ValidateSnapshot(snapshot));
1423 int implicit_targets_count = 0;
1424 for (
int i = 0, count = obj1->GetChildrenCount(); i < count; ++i) {
1428 strcmp(
"native", *prop_name) == 0) {
1429 ++implicit_targets_count;
1432 CHECK_EQ(2, implicit_targets_count);
1442 CHECK_EQ(0, heap_profiler->GetSnapshotCount());
1443 heap_profiler->DeleteAllHeapSnapshots();
1444 CHECK_EQ(0, heap_profiler->GetSnapshotCount());
1445 CHECK_NE(
NULL, heap_profiler->TakeHeapSnapshot(v8_str(
"1")));
1446 CHECK_EQ(1, heap_profiler->GetSnapshotCount());
1447 heap_profiler->DeleteAllHeapSnapshots();
1448 CHECK_EQ(0, heap_profiler->GetSnapshotCount());
1449 CHECK_NE(
NULL, heap_profiler->TakeHeapSnapshot(v8_str(
"1")));
1450 CHECK_NE(
NULL, heap_profiler->TakeHeapSnapshot(v8_str(
"2")));
1451 CHECK_EQ(2, heap_profiler->GetSnapshotCount());
1452 heap_profiler->DeleteAllHeapSnapshots();
1453 CHECK_EQ(0, heap_profiler->GetSnapshotCount());
1460 for (
int i = 0; i < length; i++) {
1462 if (snapshot->
GetUid() == uid) {
1475 CHECK_EQ(0, heap_profiler->GetSnapshotCount());
1477 heap_profiler->TakeHeapSnapshot(v8_str(
"1"));
1480 CHECK_EQ(1, heap_profiler->GetSnapshotCount());
1481 unsigned uid1 = s1->GetUid();
1482 CHECK_EQ(s1, FindHeapSnapshot(heap_profiler, uid1));
1484 CHECK_EQ(0, heap_profiler->GetSnapshotCount());
1488 heap_profiler->TakeHeapSnapshot(v8_str(
"2"));
1490 CHECK_EQ(1, heap_profiler->GetSnapshotCount());
1491 unsigned uid2 = s2->
GetUid();
1492 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2));
1493 CHECK_EQ(s2, FindHeapSnapshot(heap_profiler, uid2));
1495 heap_profiler->TakeHeapSnapshot(v8_str(
"3"));
1497 CHECK_EQ(2, heap_profiler->GetSnapshotCount());
1498 unsigned uid3 = s3->
GetUid();
1499 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3));
1500 CHECK_EQ(s3, FindHeapSnapshot(heap_profiler, uid3));
1502 CHECK_EQ(1, heap_profiler->GetSnapshotCount());
1504 CHECK_EQ(s3, FindHeapSnapshot(heap_profiler, uid3));
1506 CHECK_EQ(0, heap_profiler->GetSnapshotCount());
1514 return "Global object name";
1524 CompileRun(
"document = { URL:\"abcdefgh\" };");
1528 heap_profiler->TakeHeapSnapshot(v8_str(
"document"),
1531 CHECK(ValidateSnapshot(snapshot));
1534 CHECK_EQ(
"Object / Global object name" ,
1535 const_cast<i::HeapEntry*>(
1536 reinterpret_cast<const i::HeapEntry*>(global))->
name());
1544 CompileRun(
"obj = {};");
1546 heap_profiler->TakeHeapSnapshot(v8_str(
"snapshot"));
1547 CHECK(ValidateSnapshot(snapshot));
1569 CompileRun(
"document = { URL:\"abcdefgh\" };");
1574 heap_profiler->TakeHeapSnapshot(name);
1576 CHECK_EQ(count_before, count_after);
1585 heap_profiler->TakeHeapSnapshot(v8_str(
"iteration"));
1586 CHECK(ValidateSnapshot(snapshot));
1592 for (
int i = 0; i < nodes_count; ++i) {
1593 if (snapshot->
GetNode(i) == global)
1605 CompileRun(
"a = { s_prop: \'value\', n_prop: 0.1 };");
1607 heap_profiler->TakeHeapSnapshot(v8_str(
"value"));
1608 CHECK(ValidateSnapshot(snapshot));
1610 CHECK(heap_profiler->FindObjectById(global->
GetId())->IsObject());
1613 CHECK(js_global == heap_profiler->FindObjectById(global->
GetId()));
1616 CHECK(heap_profiler->FindObjectById(obj->
GetId())->IsObject());
1618 CHECK(js_obj == heap_profiler->FindObjectById(obj->
GetId()));
1623 CHECK(js_s_prop == heap_profiler->FindObjectById(s_prop->
GetId()));
1629 heap_profiler->FindObjectById(n_prop->
GetId())->NumberValue());
1633 TEST(GetHeapValueForDeletedObject) {
1641 CompileRun(
"a = { p: { r: {} } };");
1643 heap_profiler->TakeHeapSnapshot(v8_str(
"snapshot"));
1644 CHECK(ValidateSnapshot(snapshot));
1654 CHECK(heap_profiler->FindObjectById(prop->
GetId())->IsObject());
1656 CompileRun(
"delete a.p;");
1657 CHECK(heap_profiler->FindObjectById(prop->
GetId()).IsEmpty());
1661 static int StringCmp(
const char* ref,
i::String* act) {
1663 int result = strcmp(ref, s_act.
get());
1665 fprintf(stderr,
"Expected: \"%s\", Actual: \"%s\"\n", ref, s_act.
get());
1675 "function Constructor1() {};\n"
1676 "var obj1 = new Constructor1();\n"
1677 "var Constructor2 = function() {};\n"
1678 "var obj2 = new Constructor2();\n"
1680 "obj3.constructor = function Constructor3() {};\n"
1682 "// Slow properties\n"
1683 "for (var i=0; i<2000; ++i) obj4[\"p\" + i] = i;\n"
1684 "obj4.constructor = function Constructor4() {};\n"
1687 "obj6.constructor = 6;");
1722 CompileRun(
"var obj1 = {};\n"
1723 "obj1.__defineGetter__('propWithGetter', function Y() {\n"
1726 "obj1.__defineSetter__('propWithSetter', function Z(value) {\n"
1727 " return this.value_ = value;\n"
1730 heap_profiler->TakeHeapSnapshot(v8_str(
"fastCaseAccessors"));
1731 CHECK(ValidateSnapshot(snapshot));
1755 CompileRun(
"var obj1 = {};\n"
1756 "for (var i = 0; i < 100; ++i) obj1['z' + i] = {};"
1757 "obj1.__defineGetter__('propWithGetter', function Y() {\n"
1760 "obj1.__defineSetter__('propWithSetter', function Z(value) {\n"
1761 " return this.value_ = value;\n"
1764 heap_profiler->TakeHeapSnapshot(v8_str(
"slowCaseAccessors"));
1765 CHECK(ValidateSnapshot(snapshot));
1790 "function C(x) { this.a = this; this.b = x; }\n"
1791 "c = new C(2012);\n");
1793 heap_profiler->TakeHeapSnapshot(v8_str(
"HiddenPropertiesFastCase1"));
1794 CHECK(ValidateSnapshot(snapshot));
1806 cHandle->
ToObject()->SetHiddenValue(v8_str(
"key"), v8_str(
"val"));
1808 snapshot = heap_profiler->TakeHeapSnapshot(
1809 v8_str(
"HiddenPropertiesFastCase2"));
1810 CHECK(ValidateSnapshot(snapshot));
1811 global = GetGlobalObject(snapshot);
1815 "hidden_properties");
1834 CHECK(ValidateSnapshot(snapshot));
1845 static void PersistentHandleCallback(
1847 data.GetParameter()->Reset();
1848 delete data.GetParameter();
1860 handle.
SetWeak(&handle, PersistentHandleCallback);
1872 "fun = (function (x) { return function () { return x + 1; } })(1);");
1874 heap_profiler->TakeHeapSnapshot(v8_str(
"fun"));
1875 CHECK(ValidateSnapshot(snapshot));
1887 #ifdef ENABLE_DEBUGGER_SUPPORT
1888 TEST(NoDebugObjectInSnapshot) {
1894 CompileRun(
"foo = {};");
1896 heap_profiler->TakeHeapSnapshot(v8_str(
"snapshot"));
1897 CHECK(ValidateSnapshot(snapshot));
1899 int globals_count = 0;
1912 #endif // ENABLE_DEBUGGER_SUPPORT
1920 CompileRun(
"foo = {};");
1922 heap_profiler->TakeHeapSnapshot(v8_str(
"snapshot"));
1923 CHECK(ValidateSnapshot(snapshot));
1934 CHECK(isalpha(**name));
1939 TEST(NoRefsToNonEssentialEntries) {
1943 CompileRun(
"global_object = {};\n");
1945 heap_profiler->TakeHeapSnapshot(v8_str(
"snapshot"));
1946 CHECK(ValidateSnapshot(snapshot));
1960 TEST(MapHasDescriptorsAndTransitions) {
1964 CompileRun(
"obj = { a: 10 };\n");
1966 heap_profiler->TakeHeapSnapshot(v8_str(
"snapshot"));
1967 CHECK(ValidateSnapshot(snapshot));
1989 int num_objects = 6000;
1993 "result.push('(function outer() {');"
1994 "for (var i = 0; i < n; i++) {"
1995 " var f = 'function f_' + i + '() { ';"
1997 " f += 'f_' + (i - 1) + '();';"
2001 "result.push('return f_' + (n - 1) + ';');"
2002 "result.push('})()');"
2003 "var ok = eval(result.join('\\n'));");
2005 heap_profiler->TakeHeapSnapshot(v8_str(
"snapshot"));
2006 CHECK(ValidateSnapshot(snapshot));
2021 for (
int i = 0; i < num_objects - 1; i += 15) {
2037 "fun = function () { var a = [3, 2, 1]; return a; }\n"
2041 CHECK(ValidateSnapshot(snapshot));
2059 CHECK_EQ(
"system / AllocationSite", *name);
2092 CompileRun(
"function foo(x, y) { return x + y; }\n");
2094 heap_profiler->TakeHeapSnapshot(v8_str(
"snapshot"));
2095 CHECK(ValidateSnapshot(snapshot));
2110 for (
int current_depth = 0; current_depth < depth; ++current_depth) {
2112 for (i = 0; i < count; ++i) {
2119 if (strstr(name.start(), path[current_depth])) {
2124 if (i == count)
return NULL;
2134 CompileRun(
"var a = 1.1;");
2136 heap_profiler->TakeHeapSnapshot(v8_str(
"CheckCodeNames"));
2137 CHECK(ValidateSnapshot(snapshot));
2139 const char* stub_path[] = {
2143 "::(ArraySingleArgumentConstructorStub code)"
2149 const char* builtin_path1[] = {
2152 "::(KeyedLoadIC_Generic builtin)"
2154 node = GetNodeByPath(snapshot, builtin_path1,
ARRAY_SIZE(builtin_path1));
2157 const char* builtin_path2[] = {
2160 "::(CompileUnoptimized builtin)"
2162 node = GetNodeByPath(snapshot, builtin_path2,
ARRAY_SIZE(builtin_path2));
2165 CHECK_EQ(
"(CompileUnoptimized builtin)", *node_name);
2169 static const char* record_trace_tree_source =
2170 "var topFunctions = [];\n"
2171 "var global = this;\n"
2172 "function generateFunctions(width, depth) {\n"
2173 " var script = [];\n"
2174 " for (var i = 0; i < width; i++) {\n"
2175 " for (var j = 0; j < depth; j++) {\n"
2176 " script.push('function f_' + i + '_' + j + '(x) {\\n');\n"
2177 " script.push(' try {\\n');\n"
2178 " if (j < depth-2) {\n"
2179 " script.push(' return f_' + i + '_' + (j+1) + '(x+1);\\n');\n"
2180 " } else if (j == depth - 2) {\n"
2181 " script.push(' return new f_' + i + '_' + (depth - 1) + '();\\n');\n"
2182 " } else if (j == depth - 1) {\n"
2183 " script.push(' this.ts = Date.now();\\n');\n"
2185 " script.push(' } catch (e) {}\\n');\n"
2186 " script.push('}\\n');\n"
2190 " var script = script.join('');\n"
2191 " // throw script;\n"
2192 " global.eval(script);\n"
2193 " for (var i = 0; i < width; i++) {\n"
2194 " topFunctions.push(this['f_' + i + '_0']);\n"
2200 "generateFunctions(width, depth);\n"
2201 "var instances = [];\n"
2202 "function start() {\n"
2203 " for (var i = 0; i < width; i++) {\n"
2204 " instances.push(topFunctions[i](0));\n"
2208 "for (var i = 0; i < 100; i++) start();\n";
2211 static AllocationTraceNode* FindNode(
2212 AllocationTracker* tracker,
const Vector<const char*>& names) {
2213 AllocationTraceNode* node = tracker->trace_tree()->root();
2214 for (
int i = 0; node !=
NULL && i < names.length(); i++) {
2215 const char* name = names[i];
2216 Vector<AllocationTraceNode*> children = node->children();
2218 for (
int j = 0; j < children.length(); j++) {
2219 unsigned index = children[j]->function_info_index();
2220 AllocationTracker::FunctionInfo*
info =
2221 tracker->function_info_list()[index];
2222 if (info && strcmp(info->name, name) == 0) {
2240 "for (var i = 0; i < 5; ++i)\n"
2242 "for (var i = 0; i < 3; ++i)\n"
2245 const char* names[] = {
"(anonymous function)" };
2246 AllocationTracker* tracker =
2247 reinterpret_cast<i::HeapProfiler*
>(heap_profiler)->allocation_tracker();
2250 tracker->PrepareForSerialization();
2252 tracker->trace_tree()->Print(tracker);
2254 AllocationTraceNode* node =
2255 FindNode(tracker, Vector<const char*>(names,
ARRAY_SIZE(names)));
2257 CHECK_GE(node->allocation_count(), 2);
2258 CHECK_GE(node->allocation_size(), 4 * 5);
2259 heap_profiler->StopTrackingHeapObjects();
2270 CompileRun(record_trace_tree_source);
2272 AllocationTracker* tracker =
2273 reinterpret_cast<i::HeapProfiler*
>(heap_profiler)->allocation_tracker();
2276 tracker->PrepareForSerialization();
2278 tracker->trace_tree()->Print(tracker);
2280 const char* names[] =
2281 {
"(anonymous function)",
"start",
"f_0_0",
"f_0_1",
"f_0_2" };
2282 AllocationTraceNode* node =
2283 FindNode(tracker, Vector<const char*>(names,
ARRAY_SIZE(names)));
2285 CHECK_GE(node->allocation_count(), 100);
2286 CHECK_GE(node->allocation_size(), 4 * node->allocation_count());
2291 static const char* inline_heap_allocation_source =
2292 "function f_0(x) {\n"
2293 " return f_1(x+1);\n"
2295 "%NeverOptimizeFunction(f_0);\n"
2296 "function f_1(x) {\n"
2297 " return new f_2(x+1);\n"
2299 "function f_2(x) {\n"
2302 "var instances = [];\n"
2303 "function start() {\n"
2304 " instances.push(f_0(0));\n"
2307 "for (var i = 0; i < 100; i++) start();\n";
2310 TEST(TrackBumpPointerAllocations) {
2311 i::FLAG_allow_natives_syntax =
true;
2316 const char* names[] = {
"(anonymous function)",
"start",
"f_0",
"f_1" };
2321 CompileRun(inline_heap_allocation_source);
2323 AllocationTracker* tracker =
2324 reinterpret_cast<i::HeapProfiler*
>(heap_profiler)->allocation_tracker();
2327 tracker->PrepareForSerialization();
2329 tracker->trace_tree()->Print(tracker);
2331 AllocationTraceNode* node =
2332 FindNode(tracker, Vector<const char*>(names,
ARRAY_SIZE(names)));
2334 CHECK_GE(node->allocation_count(), 100);
2335 CHECK_GE(node->allocation_size(), 4 * node->allocation_count());
2347 CompileRun(inline_heap_allocation_source);
2349 AllocationTracker* tracker =
2350 reinterpret_cast<i::HeapProfiler*
>(heap_profiler)->allocation_tracker();
2353 tracker->PrepareForSerialization();
2355 tracker->trace_tree()->Print(tracker);
2357 AllocationTraceNode* node =
2358 FindNode(tracker, Vector<const char*>(names,
ARRAY_SIZE(names)));
2360 CHECK_LT(node->allocation_count(), 100);
2373 const char* names[] = {
"(V8 API)" };
2379 AllocationTracker* tracker =
2380 reinterpret_cast<i::HeapProfiler*
>(heap_profiler)->allocation_tracker();
2383 tracker->PrepareForSerialization();
2385 tracker->trace_tree()->Print(tracker);
2387 AllocationTraceNode* node =
2388 FindNode(tracker, Vector<const char*>(names,
ARRAY_SIZE(names)));
2390 CHECK_GE(node->allocation_count(), 2);
2391 CHECK_GE(node->allocation_size(), 4 * node->allocation_count());
2396 TEST(ArrayBufferAndArrayBufferView) {
2400 CompileRun(
"arr1 = new Uint32Array(100);\n");
2402 heap_profiler->TakeHeapSnapshot(v8_str(
"snapshot"));
2403 CHECK(ValidateSnapshot(snapshot));
2424 for (
int i = 0, l = snapshot->
GetNodesCount(); i < l; ++i) {
2436 TEST(ArrayBufferSharedBackingStore) {
2448 CHECK_EQ(1024, static_cast<int>(ab_contents.ByteLength()));
2449 void* data = ab_contents.Data();
2454 env->
Global()->Set(v8_str(
"ab1"), ab);
2455 env->
Global()->Set(v8_str(
"ab2"), ab2);
2462 CHECK(ValidateSnapshot(snapshot));
2477 CHECK_EQ(2, GetRetainersCount(snapshot, ab1_data));
2493 global->
Set(0, v8::ToApiHandle<v8::Object>(box));
2498 CHECK(ValidateSnapshot(snapshot));
2504 CHECK_EQ(
"system / Box", *box_node_name);
2522 map.
AddRange(ToAddress(0x100), 0x100, 1
U);
2530 map.
AddRange(ToAddress(0x200), 0x100, 2
U);
2535 map.
AddRange(ToAddress(0x180), 0x100, 3
U);
2543 map.
AddRange(ToAddress(0x400), 0x100, 4
U);
2553 map.
AddRange(ToAddress(0x200), 0x400, 5
U);
2559 map.
AddRange(ToAddress(0x180), 0x80, 6
U);
2560 map.
AddRange(ToAddress(0x180), 0x80, 7
U);
void DeleteAllHeapSnapshots()
static Isolate * GetCurrent()
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
double NumberValue() const
const HeapGraphEdge * GetChild(int index) const
V8_INLINE void SetWrapperClassId(uint16_t class_id)
#define CHECK_EQ(expected, value)
void StopTrackingHeapObjects()
void SetWrapperClassInfoProvider(uint16_t class_id, WrapperInfoCallback callback)
const HeapGraphNode * GetFromNode() const
SnapshotObjectId GetObjectId(Handle< Value > value)
void CollectAllGarbage(int flags, const char *gc_reason=NULL, const GCCallbackFlags gc_callback_flags=kNoGCCallbackFlags)
Handle< Value > FindObjectById(SnapshotObjectId id)
Local< Value > Get(Handle< Value > key)
virtual const char * GetName(v8::Handle< v8::Object > object)
void SetObjectGroupId(const Persistent< T > &object, UniqueId id)
Handle< Value > GetName() const
GraphWithImplicitRefs(LocalContext *env)
Handle< String > GetName() const
SnapshotObjectId GetId() const
static void gcPrologue(v8::GCType type, v8::GCCallbackFlags flags)
const HeapGraphNode * GetNodeById(SnapshotObjectId id) const
const HeapGraphNode * GetNode(int index) const
#define ASSERT(condition)
size_t GetShallowSize() const
static Local< Integer > New(Isolate *isolate, int32_t value)
void AddRange(Address addr, int size, unsigned node_id)
Handle< Object > GetProperty(Handle< JSReceiver > obj, const char *name)
virtual ControlOption ReportProgressValue(int done, int total)=0
virtual bool IsEquivalent(v8::RetainedObjectInfo *other)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in name
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object size
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in only print modified registers Don t break for ASM_UNIMPLEMENTED_BREAK macros print stack trace when an illegal exception is thrown randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot testing_bool_flag testing_int_flag string flag tmp file in which to serialize heap Print the time it takes to lazily compile hydrogen code stubs concurrent_recompilation concurrent_sweeping Print usage including flags
static void AddGCPrologueCallback(GCPrologueCallback callback, GCType gc_type_filter=kGCTypeAll)
v8::Isolate * GetIsolate()
void SetInternalField(int index, Handle< Value > value)
SmartArrayPointer< char > ToCString(AllowNullsFlag allow_nulls, RobustnessFlag robustness_flag, int offset, int length, int *length_output=0)
int GetChildrenCount() const
List< HeapEntry > & entries()
static Local< ObjectTemplate > New()
static int NumberOfHandles(Isolate *isolate)
static void MemCopy(void *dest, const void *src, size_t size)
SnapshotObjectId GetMaxSnapshotJSObjectId() const
Local< Value > GetPrototype()
static String * GetConstructorName(JSObject *object)
void CollectAllAvailableGarbage(const char *gc_reason=NULL)
static const int kNoGCFlags
void SetInternalFieldCount(int value)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf map
AsciiResource(const char *data, size_t length)
int32_t Int32Value() const
virtual WriteResult WriteHeapStatsChunk(HeapStatsUpdate *data, int count)
static V8_INLINE Handle< T > Cast(Handle< S > that)
static Local< ArrayBuffer > New(Isolate *isolate, size_t byte_length)
unsigned GetTraceNodeId(Address addr)
static i::Isolate * i_isolate()
List< HeapGraphEdge > & edges()
#define STRING_LITERAL_FOR_TEST
static const int kObjectsCount
static Local< Array > New(Isolate *isolate, int length=0)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in only print modified registers Don t break for ASM_UNIMPLEMENTED_BREAK macros print stack trace when an illegal exception is thrown randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot testing_bool_flag testing_int_flag string flag tmp file in which to serialize heap Print the time it takes to lazily compile hydrogen code stubs concurrent_recompilation concurrent_sweeping Print usage including on console Map counters to a file Enable debugger compile events enable GDBJIT enable GDBJIT interface for all code objects dump only objects containing this substring stress the GC compactor to flush out pretty print source code print source AST function name where to insert a breakpoint print scopes for builtins trace contexts operations print stuff during garbage collection report code statistics after GC report handles after GC trace cache state transitions print interface inference details prints when objects are turned into dictionaries report heap spill statistics along with trace isolate state changes trace regexp bytecode execution Minimal Log all events to the log file Log API events to the log file Log heap samples on garbage collection for the hp2ps tool log positions Log suspect operations Used with turns on browser compatible mode for profiling v8 Specify the name of the log file Enable low level linux profiler Enable perf linux profiler(experimental annotate support).") DEFINE_string(gc_fake_mmap
static v8::internal::Handle< To > OpenHandle(v8::Local< From > handle)
#define CHECK_NE(unexpected, value)
Vector< const char > CStrVector(const char *data)
static Local< Object > New(Isolate *isolate)
static int SizeFor(int length)
SnapshotObjectId GetHeapStats(OutputStream *stream)
virtual intptr_t GetHash()
V8_INLINE bool IsString() const
const HeapSnapshot * TakeHeapSnapshot(Handle< String > title, ActivityControl *control=NULL, ObjectNameResolver *global_object_name_resolver=NULL)
void SetReferenceFromGroup(UniqueId id, const Persistent< T > &child)
static int SNPrintF(Vector< char > str, const char *format,...)
virtual WriteResult WriteAsciiChunk(char *data, int size)=0
virtual size_t length() const =0
V8_INLINE Local< S > As()
void SetReference(const Persistent< T > &parent, const Persistent< S > &child)
const HeapSnapshot * GetHeapSnapshot(int index)
Handle< T > handle(T *t, Isolate *isolate)
V8_INLINE bool IsEmpty() const
List< HeapEntry * > * GetSortedEntriesList()
uint32_t SnapshotObjectId
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra code(assertions) for debugging") DEFINE_bool(code_comments
void EnableInlineAllocation()
int GetNodesCount() const
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function info
static Local< String > NewExternal(Isolate *isolate, ExternalStringResource *resource)
virtual const char * data() const =0
const HeapGraphNode * GetRoot() const
virtual const char * GetLabel()
TemplateHashMapImpl< FreeStoreAllocationPolicy > HashMap
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric literals(0o77, 0b11)") DEFINE_bool(harmony_strings
virtual intptr_t GetElementCount()
static void RemoveGCPrologueCallback(GCPrologueCallback callback)
void DisableInlineAllocation()
void StartTrackingHeapObjects(bool track_allocations=false)
bool HasWeakEdge(const v8::HeapGraphNode *node)
Local< Object > ToObject() const
size_t ByteLength() const
virtual void EndOfStream()=0
#define CHECK_NE_SNAPSHOT_OBJECT_ID(a, b)
#define CHECK_EQ_SNAPSHOT_OBJECT_ID(a, b)
V8_INLINE void SetWeak(P *parameter, typename WeakCallbackData< T, P >::Callback callback)
virtual intptr_t GetSizeInBytes()
HeapProfiler * GetHeapProfiler()
const HeapGraphNode * GetToNode() const
bool HasWeakGlobalHandle()
void Serialize(OutputStream *stream, SerializationFormat format) const
virtual const char * GetGroupLabel()
static const SnapshotObjectId kUnknownObjectId
bool Set(Handle< Value > key, Handle< Value > value, PropertyAttribute attribs=None)
static v8::Isolate * isolate()
static Local< String > NewFromUtf8(Isolate *isolate, const char *data, NewStringType type=kNormalString, int length=-1)