Commit a330683b authored by ricow@chromium.org's avatar ricow@chromium.org

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
parent 41d9d375
......@@ -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()));
......
......@@ -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>
int ScopeInfo<Allocator>::StackSlotIndex(Code* code, String* name) {
ASSERT(name->IsSymbol());
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment