Reviewers: Kasper Lund,

Description:
Use the AST optimizer on the bodies of function literals.  Notify the
oprofile agent when we compile the body of a function literal.

Please review this at http://codereview.chromium.org/57048

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
   M     src/codegen.cc
   M     src/compiler.cc


Index: src/compiler.cc
===================================================================
--- src/compiler.cc     (revision 1644)
+++ src/compiler.cc     (working copy)
@@ -1,4 +1,4 @@
-// Copyright 2006-2008 the V8 project authors. All rights reserved.
+// Copyright 2009 the V8 project authors. All rights reserved.
  // Redistribution and use in source and binary forms, with or without
  // modification, are permitted provided that the following conditions are
  // met:
@@ -32,10 +32,10 @@
  #include "compilation-cache.h"
  #include "compiler.h"
  #include "debug.h"
+#include "oprofile-agent.h"
+#include "rewriter.h"
  #include "scopes.h"
-#include "rewriter.h"
  #include "usage-analyzer.h"
-#include "oprofile-agent.h"

  namespace v8 { namespace internal {

Index: src/codegen.cc
===================================================================
--- src/codegen.cc      (revision 1644)
+++ src/codegen.cc      (working copy)
@@ -1,4 +1,4 @@
-// Copyright 2007-2008 the V8 project authors. All rights reserved.
+// Copyright 2009 the V8 project authors. All rights reserved.
  // Redistribution and use in source and binary forms, with or without
  // modification, are permitted provided that the following conditions are
  // met:
@@ -30,8 +30,10 @@
  #include "bootstrapper.h"
  #include "codegen-inl.h"
  #include "debug.h"
+#include "oprofile-agent.h"
  #include "prettyprinter.h"
  #include "register-allocator-inl.h"
+#include "rewriter.h"
  #include "runtime.h"
  #include "scopeinfo.h"
  #include "stub-cache.h"
@@ -264,6 +266,12 @@
    if (FLAG_lazy && allow_lazy) {
      code = ComputeLazyCompile(node->num_parameters());
    } else {
+    // The bodies of function literals have not yet been visited by
+    // the AST optimizer/analyzer.
+    if (!Rewriter::Optimize(node)) {
+      return Handle<JSFunction>::null();
+    }
+
      code = MakeCode(node, script_, false);

      // Check for stack-overflow exception.
@@ -274,6 +282,12 @@

      // Function compilation complete.
      LOG(CodeCreateEvent("Function", *code, *node->name()));
+
+#ifdef ENABLE_OPROFILE_AGENT
+    OProfileAgent::CreateNativeCodeRegion(*node->name(),
+                                          code->address(),
+                                          code->ExecutableSize());
+#endif
    }

    // Create a boilerplate function.



--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to