| OLD | NEW |
| 1 // Copyright 2009 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 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 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 "compilation-cache.h" | 32 #include "compilation-cache.h" |
| 33 #include "compiler.h" | 33 #include "compiler.h" |
| 34 #include "data-flow.h" |
| 34 #include "debug.h" | 35 #include "debug.h" |
| 35 #include "fast-codegen.h" | 36 #include "fast-codegen.h" |
| 36 #include "full-codegen.h" | 37 #include "full-codegen.h" |
| 37 #include "oprofile-agent.h" | 38 #include "oprofile-agent.h" |
| 38 #include "rewriter.h" | 39 #include "rewriter.h" |
| 39 #include "scopes.h" | 40 #include "scopes.h" |
| 40 #include "usage-analyzer.h" | 41 #include "usage-analyzer.h" |
| 41 #include "liveedit.h" | 42 #include "liveedit.h" |
| 42 | 43 |
| 43 namespace v8 { | 44 namespace v8 { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 72 } | 73 } |
| 73 #endif | 74 #endif |
| 74 | 75 |
| 75 // Optimize the AST. | 76 // Optimize the AST. |
| 76 if (!Rewriter::Optimize(function)) { | 77 if (!Rewriter::Optimize(function)) { |
| 77 // Signal a stack overflow by returning a null handle. The stack | 78 // Signal a stack overflow by returning a null handle. The stack |
| 78 // overflow exception will be thrown by the caller. | 79 // overflow exception will be thrown by the caller. |
| 79 return Handle<Code>::null(); | 80 return Handle<Code>::null(); |
| 80 } | 81 } |
| 81 | 82 |
| 83 if (FLAG_use_flow_graph) { |
| 84 FlowGraphBuilder builder; |
| 85 builder.Build(function); |
| 86 |
| 87 #ifdef DEBUG |
| 88 if (FLAG_print_graph_text) { |
| 89 builder.graph()->PrintText(builder.postorder()); |
| 90 } |
| 91 #endif |
| 92 } |
| 93 |
| 82 // Generate code and return it. Code generator selection is governed by | 94 // Generate code and return it. Code generator selection is governed by |
| 83 // which backends are enabled and whether the function is considered | 95 // which backends are enabled and whether the function is considered |
| 84 // run-once code or not: | 96 // run-once code or not: |
| 85 // | 97 // |
| 86 // --full-compiler enables the dedicated backend for code we expect to be | 98 // --full-compiler enables the dedicated backend for code we expect to be |
| 87 // run once | 99 // run once |
| 88 // --fast-compiler enables a speculative optimizing backend (for | 100 // --fast-compiler enables a speculative optimizing backend (for |
| 89 // non-run-once code) | 101 // non-run-once code) |
| 90 // | 102 // |
| 91 // The normal choice of backend can be overridden with the flags | 103 // The normal choice of backend can be overridden with the flags |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 Handle<Code> code; | 449 Handle<Code> code; |
| 438 if (FLAG_lazy && allow_lazy) { | 450 if (FLAG_lazy && allow_lazy) { |
| 439 code = ComputeLazyCompile(literal->num_parameters()); | 451 code = ComputeLazyCompile(literal->num_parameters()); |
| 440 } else { | 452 } else { |
| 441 // The bodies of function literals have not yet been visited by | 453 // The bodies of function literals have not yet been visited by |
| 442 // the AST optimizer/analyzer. | 454 // the AST optimizer/analyzer. |
| 443 if (!Rewriter::Optimize(literal)) { | 455 if (!Rewriter::Optimize(literal)) { |
| 444 return Handle<JSFunction>::null(); | 456 return Handle<JSFunction>::null(); |
| 445 } | 457 } |
| 446 | 458 |
| 459 if (FLAG_use_flow_graph) { |
| 460 FlowGraphBuilder builder; |
| 461 builder.Build(literal); |
| 462 |
| 463 #ifdef DEBUG |
| 464 if (FLAG_print_graph_text) { |
| 465 builder.graph()->PrintText(builder.postorder()); |
| 466 } |
| 467 #endif |
| 468 } |
| 469 |
| 447 // Generate code and return it. The way that the compilation mode | 470 // Generate code and return it. The way that the compilation mode |
| 448 // is controlled by the command-line flags is described in | 471 // is controlled by the command-line flags is described in |
| 449 // the static helper function MakeCode. | 472 // the static helper function MakeCode. |
| 450 CompilationInfo info(literal, script, false); | 473 CompilationInfo info(literal, script, false); |
| 451 | 474 |
| 452 CHECK(!FLAG_always_full_compiler || !FLAG_always_fast_compiler); | 475 CHECK(!FLAG_always_full_compiler || !FLAG_always_fast_compiler); |
| 453 bool is_run_once = literal->try_full_codegen(); | 476 bool is_run_once = literal->try_full_codegen(); |
| 454 bool is_compiled = false; | 477 bool is_compiled = false; |
| 455 if (FLAG_always_full_compiler || (FLAG_full_compiler && is_run_once)) { | 478 if (FLAG_always_full_compiler || (FLAG_full_compiler && is_run_once)) { |
| 456 FullCodeGenSyntaxChecker checker; | 479 FullCodeGenSyntaxChecker checker; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 LOG(CodeCreateEvent(tag, *code, *func_name)); | 586 LOG(CodeCreateEvent(tag, *code, *func_name)); |
| 564 OProfileAgent::CreateNativeCodeRegion(*func_name, | 587 OProfileAgent::CreateNativeCodeRegion(*func_name, |
| 565 code->instruction_start(), | 588 code->instruction_start(), |
| 566 code->instruction_size()); | 589 code->instruction_size()); |
| 567 } | 590 } |
| 568 } | 591 } |
| 569 } | 592 } |
| 570 #endif | 593 #endif |
| 571 | 594 |
| 572 } } // namespace v8::internal | 595 } } // namespace v8::internal |
| OLD | NEW |