Heap profiler: remove context checks for objects.
It seems that there will be no access to heap snapshots from web pages' code, only from Developer Tools, thus it makes no sense doing filtering of object by their security contexts. Review URL: http://codereview.chromium.org/4681003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5787 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
d80413160c
commit
0f66199b5e
@ -1848,22 +1848,6 @@ HeapEntry* HeapSnapshotGenerator::GetEntry(Object* obj) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int HeapSnapshotGenerator::GetGlobalSecurityToken() {
|
|
||||||
return collection_->token_enumerator()->GetTokenId(
|
|
||||||
Top::context()->global()->global_context()->security_token());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int HeapSnapshotGenerator::GetObjectSecurityToken(HeapObject* obj) {
|
|
||||||
if (obj->IsGlobalContext()) {
|
|
||||||
return collection_->token_enumerator()->GetTokenId(
|
|
||||||
Context::cast(obj)->security_token());
|
|
||||||
} else {
|
|
||||||
return TokenEnumerator::kNoSecurityToken;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class IndexedReferencesExtractor : public ObjectVisitor {
|
class IndexedReferencesExtractor : public ObjectVisitor {
|
||||||
public:
|
public:
|
||||||
IndexedReferencesExtractor(HeapSnapshotGenerator* generator,
|
IndexedReferencesExtractor(HeapSnapshotGenerator* generator,
|
||||||
@ -1893,19 +1877,11 @@ class IndexedReferencesExtractor : public ObjectVisitor {
|
|||||||
|
|
||||||
void HeapSnapshotGenerator::ExtractReferences(HeapObject* obj) {
|
void HeapSnapshotGenerator::ExtractReferences(HeapObject* obj) {
|
||||||
// We need to reference JS global objects from snapshot's root.
|
// We need to reference JS global objects from snapshot's root.
|
||||||
// We also need to only include global objects from the current
|
// We use JSGlobalProxy because this is what embedder (e.g. browser)
|
||||||
// security context. And we don't want to add the global proxy,
|
// uses for the global object.
|
||||||
// as we don't have a special type for it.
|
|
||||||
if (obj->IsJSGlobalProxy()) {
|
if (obj->IsJSGlobalProxy()) {
|
||||||
int global_security_token = GetGlobalSecurityToken();
|
|
||||||
JSGlobalProxy* proxy = JSGlobalProxy::cast(obj);
|
JSGlobalProxy* proxy = JSGlobalProxy::cast(obj);
|
||||||
int object_security_token =
|
SetRootReference(proxy->map()->prototype());
|
||||||
collection_->token_enumerator()->GetTokenId(
|
|
||||||
Context::cast(proxy->context())->security_token());
|
|
||||||
if (object_security_token == TokenEnumerator::kNoSecurityToken
|
|
||||||
|| object_security_token == global_security_token) {
|
|
||||||
SetRootReference(proxy->map()->prototype());
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -948,8 +948,6 @@ class HeapSnapshotGenerator {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
HeapEntry* GetEntry(Object* obj);
|
HeapEntry* GetEntry(Object* obj);
|
||||||
int GetGlobalSecurityToken();
|
|
||||||
int GetObjectSecurityToken(HeapObject* obj);
|
|
||||||
void ExtractReferences(HeapObject* obj);
|
void ExtractReferences(HeapObject* obj);
|
||||||
void ExtractClosureReferences(JSObject* js_obj, HeapEntry* entry);
|
void ExtractClosureReferences(JSObject* js_obj, HeapEntry* entry);
|
||||||
void ExtractPropertyReferences(JSObject* js_obj, HeapEntry* entry);
|
void ExtractPropertyReferences(JSObject* js_obj, HeapEntry* entry);
|
||||||
|
@ -388,14 +388,10 @@ namespace {
|
|||||||
class NamedEntriesDetector {
|
class NamedEntriesDetector {
|
||||||
public:
|
public:
|
||||||
NamedEntriesDetector()
|
NamedEntriesDetector()
|
||||||
: has_A1(false), has_B1(false), has_C1(false),
|
: has_A2(false), has_B2(false), has_C2(false) {
|
||||||
has_A2(false), has_B2(false), has_C2(false) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Apply(i::HeapEntry** entry_ptr) {
|
void Apply(i::HeapEntry** entry_ptr) {
|
||||||
if (IsReachableNodeWithName(*entry_ptr, "A1")) has_A1 = true;
|
|
||||||
if (IsReachableNodeWithName(*entry_ptr, "B1")) has_B1 = true;
|
|
||||||
if (IsReachableNodeWithName(*entry_ptr, "C1")) has_C1 = true;
|
|
||||||
if (IsReachableNodeWithName(*entry_ptr, "A2")) has_A2 = true;
|
if (IsReachableNodeWithName(*entry_ptr, "A2")) has_A2 = true;
|
||||||
if (IsReachableNodeWithName(*entry_ptr, "B2")) has_B2 = true;
|
if (IsReachableNodeWithName(*entry_ptr, "B2")) has_B2 = true;
|
||||||
if (IsReachableNodeWithName(*entry_ptr, "C2")) has_C2 = true;
|
if (IsReachableNodeWithName(*entry_ptr, "C2")) has_C2 = true;
|
||||||
@ -405,9 +401,6 @@ class NamedEntriesDetector {
|
|||||||
return strcmp(name, entry->name()) == 0 && entry->painted_reachable();
|
return strcmp(name, entry->name()) == 0 && entry->painted_reachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has_A1;
|
|
||||||
bool has_B1;
|
|
||||||
bool has_C1;
|
|
||||||
bool has_A2;
|
bool has_A2;
|
||||||
bool has_B2;
|
bool has_B2;
|
||||||
bool has_C2;
|
bool has_C2;
|
||||||
@ -464,21 +457,7 @@ static bool HasString(const v8::HeapGraphNode* node, const char* contents) {
|
|||||||
|
|
||||||
TEST(HeapSnapshot) {
|
TEST(HeapSnapshot) {
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
v8::Handle<v8::String> token1 = v8::String::New("token1");
|
|
||||||
LocalContext env1;
|
|
||||||
env1->SetSecurityToken(token1);
|
|
||||||
|
|
||||||
CompileRun(
|
|
||||||
"function A1() {}\n"
|
|
||||||
"function B1(x) { this.x = x; }\n"
|
|
||||||
"function C1(x) { this.x1 = x; this.x2 = x; }\n"
|
|
||||||
"var a1 = new A1();\n"
|
|
||||||
"var b1_1 = new B1(a1), b1_2 = new B1(a1);\n"
|
|
||||||
"var c1 = new C1(a1);");
|
|
||||||
|
|
||||||
v8::Handle<v8::String> token2 = v8::String::New("token2");
|
|
||||||
LocalContext env2;
|
LocalContext env2;
|
||||||
env2->SetSecurityToken(token2);
|
|
||||||
|
|
||||||
CompileRun(
|
CompileRun(
|
||||||
"function A2() {}\n"
|
"function A2() {}\n"
|
||||||
@ -498,14 +477,7 @@ TEST(HeapSnapshot) {
|
|||||||
const_cast<i::HeapEntry*>(
|
const_cast<i::HeapEntry*>(
|
||||||
reinterpret_cast<const i::HeapEntry*>(global_env2))->PaintAllReachable();
|
reinterpret_cast<const i::HeapEntry*>(global_env2))->PaintAllReachable();
|
||||||
|
|
||||||
// Verify, that JS global object of env2 doesn't have '..1'
|
// Verify, that JS global object of env2 has '..2' properties.
|
||||||
// properties, but has '..2' properties.
|
|
||||||
CHECK_EQ(NULL, GetProperty(global_env2, v8::HeapGraphEdge::kProperty, "a1"));
|
|
||||||
CHECK_EQ(
|
|
||||||
NULL, GetProperty(global_env2, v8::HeapGraphEdge::kProperty, "b1_1"));
|
|
||||||
CHECK_EQ(
|
|
||||||
NULL, GetProperty(global_env2, v8::HeapGraphEdge::kProperty, "b1_2"));
|
|
||||||
CHECK_EQ(NULL, GetProperty(global_env2, v8::HeapGraphEdge::kProperty, "c1"));
|
|
||||||
const v8::HeapGraphNode* a2_node =
|
const v8::HeapGraphNode* a2_node =
|
||||||
GetProperty(global_env2, v8::HeapGraphEdge::kProperty, "a2");
|
GetProperty(global_env2, v8::HeapGraphEdge::kProperty, "a2");
|
||||||
CHECK_NE(NULL, a2_node);
|
CHECK_NE(NULL, a2_node);
|
||||||
@ -518,9 +490,6 @@ TEST(HeapSnapshot) {
|
|||||||
// Verify that anything related to '[ABC]1' is not reachable.
|
// Verify that anything related to '[ABC]1' is not reachable.
|
||||||
NamedEntriesDetector det;
|
NamedEntriesDetector det;
|
||||||
i_snapshot_env2->IterateEntries(&det);
|
i_snapshot_env2->IterateEntries(&det);
|
||||||
CHECK(!det.has_A1);
|
|
||||||
CHECK(!det.has_B1);
|
|
||||||
CHECK(!det.has_C1);
|
|
||||||
CHECK(det.has_A2);
|
CHECK(det.has_A2);
|
||||||
CHECK(det.has_B2);
|
CHECK(det.has_B2);
|
||||||
CHECK(det.has_C2);
|
CHECK(det.has_C2);
|
||||||
|
Loading…
Reference in New Issue
Block a user