Commit 71431d79 authored by antonm@chromium.org's avatar antonm@chromium.org

Do not create a SharedFunctionInfo for closures on each recompilation.

Unoptimized code should already keep a reference to the SharedFunctionInfo,
let's use it instead of allocating a new object and prohibiting SharedFunctionInfo
specific optimizations.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7467 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 5f2b7a0f
......@@ -2767,9 +2767,33 @@ void HGraphBuilder::VisitDebuggerStatement(DebuggerStatement* stmt) {
}
static Handle<SharedFunctionInfo> SearchSharedFunctionInfo(
Code* unoptimized_code, FunctionLiteral* expr) {
int start_position = expr->start_position();
RelocIterator it(unoptimized_code);
for (;!it.done(); it.next()) {
RelocInfo* rinfo = it.rinfo();
if (rinfo->rmode() != RelocInfo::EMBEDDED_OBJECT) continue;
Object* obj = rinfo->target_object();
if (obj->IsSharedFunctionInfo()) {
SharedFunctionInfo* shared = SharedFunctionInfo::cast(obj);
if (shared->start_position() == start_position) {
return Handle<SharedFunctionInfo>(shared);
}
}
}
return Handle<SharedFunctionInfo>();
}
void HGraphBuilder::VisitFunctionLiteral(FunctionLiteral* expr) {
Handle<SharedFunctionInfo> shared_info =
Compiler::BuildFunctionInfo(expr, info()->script());
SearchSharedFunctionInfo(info()->shared_info()->code(),
expr);
if (shared_info.is_null()) {
shared_info = Compiler::BuildFunctionInfo(expr, info()->script());
}
CHECK_BAILOUT;
HFunctionLiteral* instr =
new HFunctionLiteral(shared_info, expr->pretenure());
......
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