Only flush code when there are no heap allocated locals in the scopeinfo.

When flushing code we can potentially flush code with a scopeinfo that
we later need to resolve variables. This makes an explicit check that
there are heap allocated locals in the scopeinfo.


Review URL: http://codereview.chromium.org/2836021

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4921 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
ricow@chromium.org 2010-06-23 07:16:09 +00:00
parent 41d9d375e3
commit a330683b00
3 changed files with 21 additions and 0 deletions

View File

@ -2264,6 +2264,12 @@ static void FlushCodeForFunction(SharedFunctionInfo* function_info) {
ThreadManager::IterateArchivedThreads(&threadvisitor); ThreadManager::IterateArchivedThreads(&threadvisitor);
if (threadvisitor.FoundCode()) return; 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; HandleScope scope;
// Compute the lazy compilable version of the code. // Compute the lazy compilable version of the code.
function_info->set_code(*ComputeLazyCompile(function_info->length())); function_info->set_code(*ComputeLazyCompile(function_info->length()));

View File

@ -407,6 +407,18 @@ int ScopeInfo<Allocator>::NumberOfContextSlots(Code* code) {
} }
template<class Allocator>
bool ScopeInfo<Allocator>::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<class Allocator> template<class Allocator>
int ScopeInfo<Allocator>::StackSlotIndex(Code* code, String* name) { int ScopeInfo<Allocator>::StackSlotIndex(Code* code, String* name) {
ASSERT(name->IsSymbol()); ASSERT(name->IsSymbol());

View File

@ -112,6 +112,9 @@ class ScopeInfo BASE_EMBEDDED {
// Return the number of context slots for code. // Return the number of context slots for code.
static int NumberOfContextSlots(Code* 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 // Lookup support for scope info embedded in Code objects. Returns
// the stack slot index for a given slot name if the slot is // 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 // present; otherwise returns a value < 0. The name must be a symbol