Revision: 7467
Author: [email protected]
Date: Fri Apr 1 03:20:39 2011
Log: 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
http://code.google.com/p/v8/source/detail?r=7467
Modified:
/branches/bleeding_edge/src/hydrogen.cc
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Mon Mar 28 06:05:36 2011
+++ /branches/bleeding_edge/src/hydrogen.cc Fri Apr 1 03:20:39 2011
@@ -2765,11 +2765,35 @@
void HGraphBuilder::VisitDebuggerStatement(DebuggerStatement* stmt) {
BAILOUT("DebuggerStatement");
}
+
+
+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());
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev