OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 extension_(NULL), | 99 extension_(NULL), |
100 pre_parse_data_(NULL), | 100 pre_parse_data_(NULL), |
101 context_(closure->context()), | 101 context_(closure->context()), |
102 osr_ast_id_(BailoutId::None()), | 102 osr_ast_id_(BailoutId::None()), |
103 zone_(zone), | 103 zone_(zone), |
104 deferred_handles_(NULL) { | 104 deferred_handles_(NULL) { |
105 Initialize(BASE); | 105 Initialize(BASE); |
106 } | 106 } |
107 | 107 |
108 | 108 |
| 109 CompilationInfo::CompilationInfo(Isolate* isolate, Zone* zone) |
| 110 : isolate_(isolate), |
| 111 flags_(LanguageModeField::encode(CLASSIC_MODE) | |
| 112 IsLazy::encode(true)), |
| 113 function_(NULL), |
| 114 scope_(NULL), |
| 115 global_scope_(NULL), |
| 116 extension_(NULL), |
| 117 pre_parse_data_(NULL), |
| 118 osr_ast_id_(BailoutId::None()), |
| 119 zone_(zone), |
| 120 deferred_handles_(NULL) { |
| 121 Initialize(STUB); |
| 122 } |
| 123 |
| 124 |
109 CompilationInfo::~CompilationInfo() { | 125 CompilationInfo::~CompilationInfo() { |
110 delete deferred_handles_; | 126 delete deferred_handles_; |
111 } | 127 } |
112 | 128 |
113 | 129 |
| 130 int CompilationInfo::num_parameters() const { |
| 131 if (IsStub()) { |
| 132 return 0; |
| 133 } else { |
| 134 return scope()->num_parameters(); |
| 135 } |
| 136 } |
| 137 |
| 138 |
| 139 int CompilationInfo::num_heap_slots() const { |
| 140 if (IsStub()) { |
| 141 return 0; |
| 142 } else { |
| 143 return scope()->num_heap_slots(); |
| 144 } |
| 145 } |
| 146 |
| 147 |
| 148 Code::Flags CompilationInfo::flags() const { |
| 149 if (IsStub()) { |
| 150 return Code::ComputeFlags(Code::COMPILED_STUB); |
| 151 } else { |
| 152 return Code::ComputeFlags(Code::OPTIMIZED_FUNCTION); |
| 153 } |
| 154 } |
| 155 |
| 156 |
114 // Disable optimization for the rest of the compilation pipeline. | 157 // Disable optimization for the rest of the compilation pipeline. |
115 void CompilationInfo::DisableOptimization() { | 158 void CompilationInfo::DisableOptimization() { |
116 bool is_optimizable_closure = | 159 bool is_optimizable_closure = |
117 FLAG_optimize_closures && | 160 FLAG_optimize_closures && |
118 closure_.is_null() && | 161 closure_.is_null() && |
119 !scope_->HasTrivialOuterContext() && | 162 !scope_->HasTrivialOuterContext() && |
120 !scope_->outer_scope_calls_non_strict_eval() && | 163 !scope_->outer_scope_calls_non_strict_eval() && |
121 !scope_->inside_with(); | 164 !scope_->inside_with(); |
122 SetMode(is_optimizable_closure ? BASE : NONOPT); | 165 SetMode(is_optimizable_closure ? BASE : NONOPT); |
123 } | 166 } |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 // optimizations. When using the always_opt flag we disregard the | 353 // optimizations. When using the always_opt flag we disregard the |
311 // optimizable marker in the code object and optimize anyway. This | 354 // optimizable marker in the code object and optimize anyway. This |
312 // is safe as long as the unoptimized code has deoptimization | 355 // is safe as long as the unoptimized code has deoptimization |
313 // support. | 356 // support. |
314 ASSERT(FLAG_always_opt || code->optimizable()); | 357 ASSERT(FLAG_always_opt || code->optimizable()); |
315 ASSERT(info()->shared_info()->has_deoptimization_support()); | 358 ASSERT(info()->shared_info()->has_deoptimization_support()); |
316 | 359 |
317 if (FLAG_trace_hydrogen) { | 360 if (FLAG_trace_hydrogen) { |
318 PrintF("-----------------------------------------------------------\n"); | 361 PrintF("-----------------------------------------------------------\n"); |
319 PrintF("Compiling method %s using hydrogen\n", *name->ToCString()); | 362 PrintF("Compiling method %s using hydrogen\n", *name->ToCString()); |
320 HTracer::Instance()->TraceCompilation(info()->function()); | 363 HTracer::Instance()->TraceCompilation(info()); |
321 } | 364 } |
322 Handle<Context> native_context( | 365 Handle<Context> native_context( |
323 info()->closure()->context()->native_context()); | 366 info()->closure()->context()->native_context()); |
324 oracle_ = new(info()->zone()) TypeFeedbackOracle( | 367 oracle_ = new(info()->zone()) TypeFeedbackOracle( |
325 code, native_context, info()->isolate(), info()->zone()); | 368 code, native_context, info()->isolate(), info()->zone()); |
326 graph_builder_ = new(info()->zone()) HGraphBuilder(info(), oracle_); | 369 graph_builder_ = new(info()->zone()) HGraphBuilder(info(), oracle_); |
327 HPhase phase(HPhase::kTotal); | 370 HPhase phase(HPhase::kTotal); |
328 graph_ = graph_builder_->CreateGraph(); | 371 graph_ = graph_builder_->CreateGraph(); |
329 | 372 |
330 if (info()->isolate()->has_pending_exception()) { | 373 if (info()->isolate()->has_pending_exception()) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 } | 410 } |
368 return SetLastStatus(SUCCEEDED); | 411 return SetLastStatus(SUCCEEDED); |
369 } | 412 } |
370 | 413 |
371 | 414 |
372 OptimizingCompiler::Status OptimizingCompiler::GenerateAndInstallCode() { | 415 OptimizingCompiler::Status OptimizingCompiler::GenerateAndInstallCode() { |
373 ASSERT(last_status() == SUCCEEDED); | 416 ASSERT(last_status() == SUCCEEDED); |
374 Timer timer(this, &time_taken_to_codegen_); | 417 Timer timer(this, &time_taken_to_codegen_); |
375 ASSERT(chunk_ != NULL); | 418 ASSERT(chunk_ != NULL); |
376 ASSERT(graph_ != NULL); | 419 ASSERT(graph_ != NULL); |
377 Handle<Code> optimized_code = chunk_->Codegen(); | 420 Handle<Code> optimized_code = chunk_->Codegen(Code::OPTIMIZED_FUNCTION); |
378 if (optimized_code.is_null()) { | 421 if (optimized_code.is_null()) { |
379 info()->set_bailout_reason("code generation failed"); | 422 info()->set_bailout_reason("code generation failed"); |
380 return AbortOptimization(); | 423 return AbortOptimization(); |
381 } | 424 } |
382 info()->SetCode(optimized_code); | 425 info()->SetCode(optimized_code); |
383 RecordOptimizationStats(); | 426 RecordOptimizationStats(); |
384 return SetLastStatus(SUCCEEDED); | 427 return SetLastStatus(SUCCEEDED); |
385 } | 428 } |
386 | 429 |
387 | 430 |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1051 } | 1094 } |
1052 } | 1095 } |
1053 | 1096 |
1054 GDBJIT(AddCode(Handle<String>(shared->DebugName()), | 1097 GDBJIT(AddCode(Handle<String>(shared->DebugName()), |
1055 Handle<Script>(info->script()), | 1098 Handle<Script>(info->script()), |
1056 Handle<Code>(info->code()), | 1099 Handle<Code>(info->code()), |
1057 info)); | 1100 info)); |
1058 } | 1101 } |
1059 | 1102 |
1060 } } // namespace v8::internal | 1103 } } // namespace v8::internal |
OLD | NEW |