Reviewers: yurys, loislo, ulan,
Message:
ptal
Description:
Do not overwrite builtin code names in heap profiler
Make sure builtin code objects get their builtin tags
first. Otherwise a particular JSFunction object could set
its custom name to a generic builtin.
LOG=N
Please review this at https://codereview.chromium.org/145973006/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+37, -27 lines):
M src/heap-snapshot-generator.h
M src/heap-snapshot-generator.cc
M test/cctest/test-heap-profiler.cc
Index: src/heap-snapshot-generator.cc
diff --git a/src/heap-snapshot-generator.cc b/src/heap-snapshot-generator.cc
index
bae1baed29ec072902f7601f289ca8e575b1f3d5..acb2c1772d6a8a0b25fd3b2635dbd4472f1d9f47
100644
--- a/src/heap-snapshot-generator.cc
+++ b/src/heap-snapshot-generator.cc
@@ -1365,8 +1365,8 @@ void V8HeapExplorer::ExtractCodeCacheReferences(
}
-void V8HeapExplorer::TagCodeObject(Code* code, const char* external_name) {
- TagObject(code, names_->GetFormatted("(%s code)", external_name));
+void V8HeapExplorer::TagBuiltinCodeObject(Code* code, const char* name) {
+ TagObject(code, names_->GetFormatted("(%s builtin)", name));
}
@@ -1659,24 +1659,20 @@ class RootsReferencesExtractor : public
ObjectVisitor {
}
int strong_index = 0, all_index = 0, tags_index = 0, builtin_index = 0;
while (all_index < all_references_.length()) {
- if (strong_index < strong_references_.length() &&
- strong_references_[strong_index] == all_references_[all_index]) {
- explorer->SetGcSubrootReference(reference_tags_[tags_index].tag,
- false,
- all_references_[all_index]);
- ++strong_index;
- } else {
- explorer->SetGcSubrootReference(reference_tags_[tags_index].tag,
- true,
- all_references_[all_index]);
- }
+ bool is_strong = strong_index < strong_references_.length()
+ && strong_references_[strong_index] ==
all_references_[all_index];
+ explorer->SetGcSubrootReference(reference_tags_[tags_index].tag,
+ !is_strong,
+ all_references_[all_index]);
if (reference_tags_[tags_index].tag ==
VisitorSynchronization::kBuiltins) {
ASSERT(all_references_[all_index]->IsCode());
- explorer->TagCodeObject(Code::cast(all_references_[all_index]),
+ explorer->TagBuiltinCodeObject(
+ Code::cast(all_references_[all_index]),
builtins->name(builtin_index++));
}
++all_index;
+ if (is_strong) ++strong_index;
if (reference_tags_[tags_index].index == all_index) ++tags_index;
}
}
@@ -1701,11 +1697,21 @@ class RootsReferencesExtractor : public
ObjectVisitor {
bool V8HeapExplorer::IterateAndExtractReferences(
SnapshotFillerInterface* filler) {
- HeapIterator iterator(heap_, HeapIterator::kFilterUnreachable);
-
filler_ = filler;
- bool interrupted = false;
+ // Make sure builtin code objects get their builtin tags
+ // first. Otherwise a particular JSFunction object could set
+ // its custom name to a generic builtin.
+ SetRootGcRootsReference();
+ RootsReferencesExtractor extractor(heap_);
+ heap_->IterateRoots(&extractor, VISIT_ONLY_STRONG);
+ extractor.SetCollectingAllReferences();
+ heap_->IterateRoots(&extractor, VISIT_ALL);
+ extractor.FillReferences(this);
+
+ // Now iterate the whole heap.
+ bool interrupted = false;
+ HeapIterator iterator(heap_, HeapIterator::kFilterUnreachable);
// Heap iteration with filtering must be finished in any case.
for (HeapObject* obj = iterator.next();
obj != NULL;
@@ -1720,12 +1726,6 @@ bool V8HeapExplorer::IterateAndExtractReferences(
return false;
}
- SetRootGcRootsReference();
- RootsReferencesExtractor extractor(heap_);
- heap_->IterateRoots(&extractor, VISIT_ONLY_STRONG);
- extractor.SetCollectingAllReferences();
- heap_->IterateRoots(&extractor, VISIT_ALL);
- extractor.FillReferences(this);
filler_ = NULL;
return progress_->ProgressReport(true);
}
Index: src/heap-snapshot-generator.h
diff --git a/src/heap-snapshot-generator.h b/src/heap-snapshot-generator.h
index
59d324e499cf8daeabc404a6f05f501a28397d0e..2deb4bfe77bb8c6865826d5ba712728a7e2abc74
100644
--- a/src/heap-snapshot-generator.h
+++ b/src/heap-snapshot-generator.h
@@ -385,7 +385,7 @@ class V8HeapExplorer : public HeapEntriesAllocator {
bool IterateAndExtractReferences(SnapshotFillerInterface* filler);
void TagGlobalObjects();
void TagCodeObject(Code* code);
- void TagCodeObject(Code* code, const char* external_name);
+ void TagBuiltinCodeObject(Code* code, const char* name);
static String* GetConstructorName(JSObject* object);
Index: test/cctest/test-heap-profiler.cc
diff --git a/test/cctest/test-heap-profiler.cc
b/test/cctest/test-heap-profiler.cc
index
fdaf9fa6c9a7fa111848b0b20bc57f39aa087fe4..650704d2c4c5c30217208f5a609c0e16200e4ff2
100644
--- a/test/cctest/test-heap-profiler.cc
+++ b/test/cctest/test-heap-profiler.cc
@@ -2113,13 +2113,23 @@ TEST(CheckCodeNames) {
stub_path, ARRAY_SIZE(stub_path));
CHECK_NE(NULL, node);
- const char* builtin_path[] = {
+ const char* builtin_path1[] = {
"::(GC roots)",
"::(Builtins)",
- "::(KeyedLoadIC_Generic code)"
+ "::(KeyedLoadIC_Generic builtin)"
};
- node = GetNodeByPath(snapshot, builtin_path, ARRAY_SIZE(builtin_path));
+ node = GetNodeByPath(snapshot, builtin_path1, ARRAY_SIZE(builtin_path1));
CHECK_NE(NULL, node);
+
+ const char* builtin_path2[] = {
+ "::(GC roots)",
+ "::(Builtins)",
+ "::(CompileUnoptimized builtin)"
+ };
+ node = GetNodeByPath(snapshot, builtin_path2, ARRAY_SIZE(builtin_path2));
+ CHECK_NE(NULL, node);
+ v8::String::Utf8Value node_name(node->GetName());
+ CHECK_EQ("(CompileUnoptimized builtin)", *node_name);
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.