OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 | 53 |
54 CompilationInfo::CompilationInfo(Handle<Script> script) | 54 CompilationInfo::CompilationInfo(Handle<Script> script) |
55 : isolate_(script->GetIsolate()), | 55 : isolate_(script->GetIsolate()), |
56 flags_(0), | 56 flags_(0), |
57 function_(NULL), | 57 function_(NULL), |
58 scope_(NULL), | 58 scope_(NULL), |
59 script_(script), | 59 script_(script), |
60 extension_(NULL), | 60 extension_(NULL), |
61 pre_parse_data_(NULL), | 61 pre_parse_data_(NULL), |
62 supports_deoptimization_(false), | |
63 osr_ast_id_(AstNode::kNoNumber) { | 62 osr_ast_id_(AstNode::kNoNumber) { |
64 Initialize(NONOPT); | 63 Initialize(NONOPT); |
65 } | 64 } |
66 | 65 |
67 | 66 |
68 CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info) | 67 CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info) |
69 : isolate_(shared_info->GetIsolate()), | 68 : isolate_(shared_info->GetIsolate()), |
70 flags_(IsLazy::encode(true)), | 69 flags_(IsLazy::encode(true)), |
71 function_(NULL), | 70 function_(NULL), |
72 scope_(NULL), | 71 scope_(NULL), |
73 shared_info_(shared_info), | 72 shared_info_(shared_info), |
74 script_(Handle<Script>(Script::cast(shared_info->script()))), | 73 script_(Handle<Script>(Script::cast(shared_info->script()))), |
75 extension_(NULL), | 74 extension_(NULL), |
76 pre_parse_data_(NULL), | 75 pre_parse_data_(NULL), |
77 supports_deoptimization_(false), | |
78 osr_ast_id_(AstNode::kNoNumber) { | 76 osr_ast_id_(AstNode::kNoNumber) { |
79 Initialize(BASE); | 77 Initialize(BASE); |
80 } | 78 } |
81 | 79 |
82 | 80 |
83 CompilationInfo::CompilationInfo(Handle<JSFunction> closure) | 81 CompilationInfo::CompilationInfo(Handle<JSFunction> closure) |
84 : isolate_(closure->GetIsolate()), | 82 : isolate_(closure->GetIsolate()), |
85 flags_(IsLazy::encode(true)), | 83 flags_(IsLazy::encode(true)), |
86 function_(NULL), | 84 function_(NULL), |
87 scope_(NULL), | 85 scope_(NULL), |
88 closure_(closure), | 86 closure_(closure), |
89 shared_info_(Handle<SharedFunctionInfo>(closure->shared())), | 87 shared_info_(Handle<SharedFunctionInfo>(closure->shared())), |
90 script_(Handle<Script>(Script::cast(shared_info_->script()))), | 88 script_(Handle<Script>(Script::cast(shared_info_->script()))), |
91 extension_(NULL), | 89 extension_(NULL), |
92 pre_parse_data_(NULL), | 90 pre_parse_data_(NULL), |
93 supports_deoptimization_(false), | |
94 osr_ast_id_(AstNode::kNoNumber) { | 91 osr_ast_id_(AstNode::kNoNumber) { |
95 Initialize(BASE); | 92 Initialize(BASE); |
96 } | 93 } |
97 | 94 |
98 | 95 |
99 // Disable optimization for the rest of the compilation pipeline. | 96 // Disable optimization for the rest of the compilation pipeline. |
100 void CompilationInfo::DisableOptimization() { | 97 void CompilationInfo::DisableOptimization() { |
101 bool is_optimizable_closure = | 98 bool is_optimizable_closure = |
102 FLAG_optimize_closures && | 99 FLAG_optimize_closures && |
103 closure_.is_null() && | 100 closure_.is_null() && |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 Handle<JSFunction> closure = info->closure(); | 299 Handle<JSFunction> closure = info->closure(); |
303 info->shared_info()->DisableOptimization(*closure); | 300 info->shared_info()->DisableOptimization(*closure); |
304 } | 301 } |
305 // True indicates the compilation pipeline is still going, not necessarily | 302 // True indicates the compilation pipeline is still going, not necessarily |
306 // that we optimized the code. | 303 // that we optimized the code. |
307 return true; | 304 return true; |
308 } | 305 } |
309 | 306 |
310 | 307 |
311 static bool GenerateCode(CompilationInfo* info) { | 308 static bool GenerateCode(CompilationInfo* info) { |
312 return V8::UseCrankshaft() ? | 309 return info->IsCompilingForDebugging() || !V8::UseCrankshaft() ? |
313 MakeCrankshaftCode(info) : | 310 FullCodeGenerator::MakeCode(info) : |
314 FullCodeGenerator::MakeCode(info); | 311 MakeCrankshaftCode(info); |
315 } | 312 } |
316 | 313 |
317 | 314 |
318 static bool MakeCode(CompilationInfo* info) { | 315 static bool MakeCode(CompilationInfo* info) { |
319 // Precondition: code has been parsed. Postcondition: the code field in | 316 // Precondition: code has been parsed. Postcondition: the code field in |
320 // the compilation info is set if compilation succeeded. | 317 // the compilation info is set if compilation succeeded. |
321 ASSERT(info->function() != NULL); | 318 ASSERT(info->function() != NULL); |
322 return Rewriter::Rewrite(info) && Scope::Analyze(info) && GenerateCode(info); | 319 return Rewriter::Rewrite(info) && Scope::Analyze(info) && GenerateCode(info); |
323 } | 320 } |
324 | 321 |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 } | 785 } |
789 } | 786 } |
790 | 787 |
791 GDBJIT(AddCode(Handle<String>(shared->DebugName()), | 788 GDBJIT(AddCode(Handle<String>(shared->DebugName()), |
792 Handle<Script>(info->script()), | 789 Handle<Script>(info->script()), |
793 Handle<Code>(info->code()), | 790 Handle<Code>(info->code()), |
794 info)); | 791 info)); |
795 } | 792 } |
796 | 793 |
797 } } // namespace v8::internal | 794 } } // namespace v8::internal |
OLD | NEW |