diff --git a/src/heap.cc b/src/heap.cc index 855a25dff2..f1ec56ce5a 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -2264,6 +2264,12 @@ static void FlushCodeForFunction(SharedFunctionInfo* function_info) { ThreadManager::IterateArchivedThreads(&threadvisitor); if (threadvisitor.FoundCode()) return; + // Check that there are heap allocated locals in the scopeinfo. If + // there is, we are potentially using eval and need the scopeinfo + // for variable resolution. + if (ScopeInfo<>::HasHeapAllocatedLocals(function_info->code())) + return; + HandleScope scope; // Compute the lazy compilable version of the code. function_info->set_code(*ComputeLazyCompile(function_info->length())); diff --git a/src/scopeinfo.cc b/src/scopeinfo.cc index 8b7e2ad972..2091ca726c 100644 --- a/src/scopeinfo.cc +++ b/src/scopeinfo.cc @@ -407,6 +407,18 @@ int ScopeInfo::NumberOfContextSlots(Code* code) { } +template +bool ScopeInfo::HasHeapAllocatedLocals(Code* code) { + if (code->sinfo_size() > 0) { + Object** p = ContextEntriesAddr(code); + int n; // number of context slots; + ReadInt(p, &n); + return n > 0; + } + return false; +} + + template int ScopeInfo::StackSlotIndex(Code* code, String* name) { ASSERT(name->IsSymbol()); diff --git a/src/scopeinfo.h b/src/scopeinfo.h index 927ac66fc4..9fb26d0339 100644 --- a/src/scopeinfo.h +++ b/src/scopeinfo.h @@ -112,6 +112,9 @@ class ScopeInfo BASE_EMBEDDED { // Return the number of context slots for code. static int NumberOfContextSlots(Code* code); + // Return if this has context slots besides MIN_CONTEXT_SLOTS; + static bool HasHeapAllocatedLocals(Code* code); + // Lookup support for scope info embedded in Code objects. Returns // the stack slot index for a given slot name if the slot is // present; otherwise returns a value < 0. The name must be a symbol