diff --git a/src/objects.h b/src/objects.h index 76d8351db1..147dc00d4c 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); diff --git a/src/profile-generator.cc b/src/profile-generator.cc index 683fec15bb..e895cccdfc 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)); + } } } }