Reviewers: Vyacheslav Egorov,
Description:
Do not assume that names of function expressions are context-allocated.
The heap profile generator assumes that for named function expressions, the
name is context allocated. This is not necessary true.
BUG=v8:2051
TEST=WebKit layout test
inspector/profiler/heap-snapshot-inspect-dom-wrapper.html
Please review this at http://codereview.chromium.org/9960065/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/objects.h
M src/profile-generator.cc
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
76d8351db1b9225e2486662673023f78cb1c2183..147dc00d4c70e52da5f3469a114b2d940d4cc67d
100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -3413,8 +3413,8 @@ class ScopeInfo : public FixedArray {
// otherwise returns a value < 0. The name must be a symbol
(canonicalized).
int ParameterIndex(String* name);
- // Lookup support for serialized scope info. Returns the
- // function context slot index if the function name is present (named
+ // Lookup support for serialized scope info. Returns the function context
+ // slot index if the function name is present and context-allocated
(named
// function expressions, only), otherwise returns a value < 0. The name
// must be a symbol (canonicalized).
int FunctionContextSlotIndex(String* name, VariableMode* mode);
Index: src/profile-generator.cc
diff --git a/src/profile-generator.cc b/src/profile-generator.cc
index
683fec15bb98afc281ce2a1b15eb9f4c35e0eb65..e895cccdfc4b58e62681b091117c0c1e17396bb9
100644
--- a/src/profile-generator.cc
+++ b/src/profile-generator.cc
@@ -2109,12 +2109,11 @@ void
V8HeapExplorer::ExtractClosureReferences(JSObject* js_obj,
// Add function variable.
if (scope_info->HasFunctionName()) {
String* name = scope_info->FunctionName();
- int idx = Context::MIN_CONTEXT_SLOTS + context_locals;
-#ifdef DEBUG
VariableMode mode;
- ASSERT(idx == scope_info->FunctionContextSlotIndex(name, &mode));
-#endif
- SetClosureReference(js_obj, entry, name, context->get(idx));
+ int idx = scope_info->FunctionContextSlotIndex(name, &mode);
+ if (idx >= 0) {
+ SetClosureReference(js_obj, entry, name, context->get(idx));
+ }
}
}
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev