OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 11 matching lines...) Expand all Loading... |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include "v8.h" | 28 #include "v8.h" |
29 | 29 |
30 #include "bootstrapper.h" | 30 #include "bootstrapper.h" |
31 #include "codegen-inl.h" | 31 #include "codegen-inl.h" |
32 #include "debug.h" | 32 #include "debug.h" |
| 33 #include "oprofile-agent.h" |
33 #include "prettyprinter.h" | 34 #include "prettyprinter.h" |
34 #include "register-allocator-inl.h" | 35 #include "register-allocator-inl.h" |
| 36 #include "rewriter.h" |
35 #include "runtime.h" | 37 #include "runtime.h" |
36 #include "scopeinfo.h" | 38 #include "scopeinfo.h" |
37 #include "stub-cache.h" | 39 #include "stub-cache.h" |
38 | 40 |
39 namespace v8 { namespace internal { | 41 namespace v8 { namespace internal { |
40 | 42 |
41 DeferredCode::DeferredCode(CodeGenerator* generator) | 43 DeferredCode::DeferredCode(CodeGenerator* generator) |
42 : generator_(generator), | 44 : generator_(generator), |
43 masm_(generator->masm()), | 45 masm_(generator->masm()), |
44 enter_(generator), | 46 enter_(generator), |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 // compiled. These builtins cannot be handled lazily by the parser, | 259 // compiled. These builtins cannot be handled lazily by the parser, |
258 // since we have to know if a function uses the special natives | 260 // since we have to know if a function uses the special natives |
259 // syntax, which is something the parser records. | 261 // syntax, which is something the parser records. |
260 bool allow_lazy = node->AllowsLazyCompilation(); | 262 bool allow_lazy = node->AllowsLazyCompilation(); |
261 | 263 |
262 // Generate code | 264 // Generate code |
263 Handle<Code> code; | 265 Handle<Code> code; |
264 if (FLAG_lazy && allow_lazy) { | 266 if (FLAG_lazy && allow_lazy) { |
265 code = ComputeLazyCompile(node->num_parameters()); | 267 code = ComputeLazyCompile(node->num_parameters()); |
266 } else { | 268 } else { |
| 269 // The bodies of function literals have not yet been visited by |
| 270 // the AST optimizer/analyzer. |
| 271 if (!Rewriter::Optimize(node)) { |
| 272 return Handle<JSFunction>::null(); |
| 273 } |
| 274 |
267 code = MakeCode(node, script_, false); | 275 code = MakeCode(node, script_, false); |
268 | 276 |
269 // Check for stack-overflow exception. | 277 // Check for stack-overflow exception. |
270 if (code.is_null()) { | 278 if (code.is_null()) { |
271 SetStackOverflow(); | 279 SetStackOverflow(); |
272 return Handle<JSFunction>::null(); | 280 return Handle<JSFunction>::null(); |
273 } | 281 } |
274 | 282 |
275 // Function compilation complete. | 283 // Function compilation complete. |
276 LOG(CodeCreateEvent("Function", *code, *node->name())); | 284 LOG(CodeCreateEvent("Function", *code, *node->name())); |
| 285 |
| 286 #ifdef ENABLE_OPROFILE_AGENT |
| 287 OProfileAgent::CreateNativeCodeRegion(*node->name(), |
| 288 code->address(), |
| 289 code->ExecutableSize()); |
| 290 #endif |
277 } | 291 } |
278 | 292 |
279 // Create a boilerplate function. | 293 // Create a boilerplate function. |
280 Handle<JSFunction> function = | 294 Handle<JSFunction> function = |
281 Factory::NewFunctionBoilerplate(node->name(), | 295 Factory::NewFunctionBoilerplate(node->name(), |
282 node->materialized_literal_count(), | 296 node->materialized_literal_count(), |
283 node->contains_array_literal(), | 297 node->contains_array_literal(), |
284 code); | 298 code); |
285 CodeGenerator::SetFunctionInfo(function, node->num_parameters(), | 299 CodeGenerator::SetFunctionInfo(function, node->num_parameters(), |
286 node->function_token_position(), | 300 node->function_token_position(), |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 void ArgumentsAccessStub::Generate(MacroAssembler* masm) { | 599 void ArgumentsAccessStub::Generate(MacroAssembler* masm) { |
586 switch (type_) { | 600 switch (type_) { |
587 case READ_LENGTH: GenerateReadLength(masm); break; | 601 case READ_LENGTH: GenerateReadLength(masm); break; |
588 case READ_ELEMENT: GenerateReadElement(masm); break; | 602 case READ_ELEMENT: GenerateReadElement(masm); break; |
589 case NEW_OBJECT: GenerateNewObject(masm); break; | 603 case NEW_OBJECT: GenerateNewObject(masm); break; |
590 } | 604 } |
591 } | 605 } |
592 | 606 |
593 | 607 |
594 } } // namespace v8::internal | 608 } } // namespace v8::internal |
OLD | NEW |