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 10 matching lines...) Expand all Loading... |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
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 "cfg.h" | |
32 #include "codegen-inl.h" | 31 #include "codegen-inl.h" |
33 #include "compilation-cache.h" | 32 #include "compilation-cache.h" |
34 #include "compiler.h" | 33 #include "compiler.h" |
35 #include "debug.h" | 34 #include "debug.h" |
36 #include "oprofile-agent.h" | 35 #include "oprofile-agent.h" |
37 #include "rewriter.h" | 36 #include "rewriter.h" |
38 #include "scopes.h" | 37 #include "scopes.h" |
39 #include "usage-analyzer.h" | 38 #include "usage-analyzer.h" |
40 | 39 |
41 namespace v8 { | 40 namespace v8 { |
(...skipping 30 matching lines...) Expand all Loading... |
72 } | 71 } |
73 #endif | 72 #endif |
74 | 73 |
75 // Optimize the AST. | 74 // Optimize the AST. |
76 if (!Rewriter::Optimize(literal)) { | 75 if (!Rewriter::Optimize(literal)) { |
77 // Signal a stack overflow by returning a null handle. The stack | 76 // Signal a stack overflow by returning a null handle. The stack |
78 // overflow exception will be thrown by the caller. | 77 // overflow exception will be thrown by the caller. |
79 return Handle<Code>::null(); | 78 return Handle<Code>::null(); |
80 } | 79 } |
81 | 80 |
82 if (FLAG_multipass) { | |
83 CfgGlobals scope(literal); | |
84 Cfg* cfg = Cfg::Build(); | |
85 #ifdef DEBUG | |
86 if (FLAG_print_cfg && cfg != NULL) { | |
87 SmartPointer<char> name = literal->name()->ToCString(); | |
88 PrintF("Function \"%s\":\n", *name); | |
89 cfg->Print(); | |
90 PrintF("\n"); | |
91 } | |
92 #endif | |
93 if (cfg != NULL) { | |
94 return cfg->Compile(script); | |
95 } | |
96 } | |
97 | |
98 // Generate code and return it. | 81 // Generate code and return it. |
99 Handle<Code> result = CodeGenerator::MakeCode(literal, script, is_eval); | 82 Handle<Code> result = CodeGenerator::MakeCode(literal, script, is_eval); |
100 return result; | 83 return result; |
101 } | 84 } |
102 | 85 |
103 | 86 |
104 static bool IsValidJSON(FunctionLiteral* lit) { | 87 static bool IsValidJSON(FunctionLiteral* lit) { |
105 if (lit->body()->length() != 1) | 88 if (lit->body()->length() != 1) |
106 return false; | 89 return false; |
107 Statement* stmt = lit->body()->at(0); | 90 Statement* stmt = lit->body()->at(0); |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 lit->has_only_simple_this_property_assignments(), | 415 lit->has_only_simple_this_property_assignments(), |
433 *lit->this_property_assignments()); | 416 *lit->this_property_assignments()); |
434 | 417 |
435 // Check the function has compiled code. | 418 // Check the function has compiled code. |
436 ASSERT(shared->is_compiled()); | 419 ASSERT(shared->is_compiled()); |
437 return true; | 420 return true; |
438 } | 421 } |
439 | 422 |
440 | 423 |
441 } } // namespace v8::internal | 424 } } // namespace v8::internal |
OLD | NEW |