Use the AST optimizer on the bodies of function literals. Notify the

oprofile agent when we compile the body of a function literal.
Review URL: http://codereview.chromium.org/57048

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1645 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent b9c5232c
// 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 // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
...@@ -30,8 +30,10 @@ ...@@ -30,8 +30,10 @@
#include "bootstrapper.h" #include "bootstrapper.h"
#include "codegen-inl.h" #include "codegen-inl.h"
#include "debug.h" #include "debug.h"
#include "oprofile-agent.h"
#include "prettyprinter.h" #include "prettyprinter.h"
#include "register-allocator-inl.h" #include "register-allocator-inl.h"
#include "rewriter.h"
#include "runtime.h" #include "runtime.h"
#include "scopeinfo.h" #include "scopeinfo.h"
#include "stub-cache.h" #include "stub-cache.h"
...@@ -264,6 +266,12 @@ Handle<JSFunction> CodeGenerator::BuildBoilerplate(FunctionLiteral* node) { ...@@ -264,6 +266,12 @@ Handle<JSFunction> CodeGenerator::BuildBoilerplate(FunctionLiteral* node) {
if (FLAG_lazy && allow_lazy) { if (FLAG_lazy && allow_lazy) {
code = ComputeLazyCompile(node->num_parameters()); code = ComputeLazyCompile(node->num_parameters());
} else { } 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); code = MakeCode(node, script_, false);
// Check for stack-overflow exception. // Check for stack-overflow exception.
...@@ -274,6 +282,12 @@ Handle<JSFunction> CodeGenerator::BuildBoilerplate(FunctionLiteral* node) { ...@@ -274,6 +282,12 @@ Handle<JSFunction> CodeGenerator::BuildBoilerplate(FunctionLiteral* node) {
// Function compilation complete. // Function compilation complete.
LOG(CodeCreateEvent("Function", *code, *node->name())); LOG(CodeCreateEvent("Function", *code, *node->name()));
#ifdef ENABLE_OPROFILE_AGENT
OProfileAgent::CreateNativeCodeRegion(*node->name(),
code->address(),
code->ExecutableSize());
#endif
} }
// Create a boilerplate function. // Create a boilerplate function.
......
// 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 // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
...@@ -32,10 +32,10 @@ ...@@ -32,10 +32,10 @@
#include "compilation-cache.h" #include "compilation-cache.h"
#include "compiler.h" #include "compiler.h"
#include "debug.h" #include "debug.h"
#include "scopes.h" #include "oprofile-agent.h"
#include "rewriter.h" #include "rewriter.h"
#include "scopes.h"
#include "usage-analyzer.h" #include "usage-analyzer.h"
#include "oprofile-agent.h"
namespace v8 { namespace internal { namespace v8 { namespace internal {
......
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