| 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 static int code_size = 0; | 187 static int code_size = 0; |
| 188 | 188 |
| 189 compilation_time += (ms_creategraph + ms_optimize + ms_codegen); | 189 compilation_time += (ms_creategraph + ms_optimize + ms_codegen); |
| 190 compiled_functions++; | 190 compiled_functions++; |
| 191 code_size += function->shared()->SourceSize(); | 191 code_size += function->shared()->SourceSize(); |
| 192 PrintF("Compiled: %d functions with %d byte source size in %fms.\n", | 192 PrintF("Compiled: %d functions with %d byte source size in %fms.\n", |
| 193 compiled_functions, | 193 compiled_functions, |
| 194 code_size, | 194 code_size, |
| 195 compilation_time); | 195 compilation_time); |
| 196 } | 196 } |
| 197 if (FLAG_hydrogen_stats) { |
| 198 HStatistics::Instance()->IncrementSubtotals(time_taken_to_create_graph_, |
| 199 time_taken_to_optimize_, |
| 200 time_taken_to_codegen_); |
| 201 } |
| 197 } | 202 } |
| 198 | 203 |
| 199 | 204 |
| 200 // A return value of true indicates the compilation pipeline is still | 205 // A return value of true indicates the compilation pipeline is still |
| 201 // going, not necessarily that we optimized the code. | 206 // going, not necessarily that we optimized the code. |
| 202 static bool MakeCrankshaftCode(CompilationInfo* info) { | 207 static bool MakeCrankshaftCode(CompilationInfo* info) { |
| 203 OptimizingCompiler compiler(info); | 208 OptimizingCompiler compiler(info); |
| 204 OptimizingCompiler::Status status = compiler.CreateGraph(); | 209 OptimizingCompiler::Status status = compiler.CreateGraph(); |
| 205 | 210 |
| 206 if (status != OptimizingCompiler::SUCCEEDED) { | 211 if (status != OptimizingCompiler::SUCCEEDED) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 || (filter[0] != '-' && !name->IsEqualTo(filter))) { | 282 || (filter[0] != '-' && !name->IsEqualTo(filter))) { |
| 278 info()->SetCode(code); | 283 info()->SetCode(code); |
| 279 return SetLastStatus(BAILED_OUT); | 284 return SetLastStatus(BAILED_OUT); |
| 280 } | 285 } |
| 281 } | 286 } |
| 282 | 287 |
| 283 // Recompile the unoptimized version of the code if the current version | 288 // Recompile the unoptimized version of the code if the current version |
| 284 // doesn't have deoptimization support. Alternatively, we may decide to | 289 // doesn't have deoptimization support. Alternatively, we may decide to |
| 285 // run the full code generator to get a baseline for the compile-time | 290 // run the full code generator to get a baseline for the compile-time |
| 286 // performance of the hydrogen-based compiler. | 291 // performance of the hydrogen-based compiler. |
| 287 Timer t(this, &time_taken_to_create_graph_); | |
| 288 bool should_recompile = !info()->shared_info()->has_deoptimization_support(); | 292 bool should_recompile = !info()->shared_info()->has_deoptimization_support(); |
| 289 if (should_recompile || FLAG_hydrogen_stats) { | 293 if (should_recompile || FLAG_hydrogen_stats) { |
| 290 HPhase phase(HPhase::kFullCodeGen); | 294 HPhase phase(HPhase::kFullCodeGen); |
| 291 CompilationInfoWithZone unoptimized(info()->shared_info()); | 295 CompilationInfoWithZone unoptimized(info()->shared_info()); |
| 292 // Note that we use the same AST that we will use for generating the | 296 // Note that we use the same AST that we will use for generating the |
| 293 // optimized code. | 297 // optimized code. |
| 294 unoptimized.SetFunction(info()->function()); | 298 unoptimized.SetFunction(info()->function()); |
| 295 unoptimized.SetScope(info()->scope()); | 299 unoptimized.SetScope(info()->scope()); |
| 296 unoptimized.SetContext(info()->context()); | 300 unoptimized.SetContext(info()->context()); |
| 297 if (should_recompile) unoptimized.EnableDeoptimizationSupport(); | 301 if (should_recompile) unoptimized.EnableDeoptimizationSupport(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 317 if (FLAG_trace_hydrogen) { | 321 if (FLAG_trace_hydrogen) { |
| 318 PrintF("-----------------------------------------------------------\n"); | 322 PrintF("-----------------------------------------------------------\n"); |
| 319 PrintF("Compiling method %s using hydrogen\n", *name->ToCString()); | 323 PrintF("Compiling method %s using hydrogen\n", *name->ToCString()); |
| 320 HTracer::Instance()->TraceCompilation(info()->function()); | 324 HTracer::Instance()->TraceCompilation(info()->function()); |
| 321 } | 325 } |
| 322 Handle<Context> native_context( | 326 Handle<Context> native_context( |
| 323 info()->closure()->context()->native_context()); | 327 info()->closure()->context()->native_context()); |
| 324 oracle_ = new(info()->zone()) TypeFeedbackOracle( | 328 oracle_ = new(info()->zone()) TypeFeedbackOracle( |
| 325 code, native_context, info()->isolate(), info()->zone()); | 329 code, native_context, info()->isolate(), info()->zone()); |
| 326 graph_builder_ = new(info()->zone()) HGraphBuilder(info(), oracle_); | 330 graph_builder_ = new(info()->zone()) HGraphBuilder(info(), oracle_); |
| 327 HPhase phase(HPhase::kTotal); | 331 |
| 332 Timer t(this, &time_taken_to_create_graph_); |
| 328 graph_ = graph_builder_->CreateGraph(); | 333 graph_ = graph_builder_->CreateGraph(); |
| 329 | 334 |
| 330 if (info()->isolate()->has_pending_exception()) { | 335 if (info()->isolate()->has_pending_exception()) { |
| 331 info()->SetCode(Handle<Code>::null()); | 336 info()->SetCode(Handle<Code>::null()); |
| 332 return SetLastStatus(FAILED); | 337 return SetLastStatus(FAILED); |
| 333 } | 338 } |
| 334 | 339 |
| 335 // The function being compiled may have bailed out due to an inline | 340 // The function being compiled may have bailed out due to an inline |
| 336 // candidate bailing out. In such a case, we don't disable | 341 // candidate bailing out. In such a case, we don't disable |
| 337 // optimization on the shared_info. | 342 // optimization on the shared_info. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 364 if (chunk_ == NULL) { | 369 if (chunk_ == NULL) { |
| 365 return SetLastStatus(BAILED_OUT); | 370 return SetLastStatus(BAILED_OUT); |
| 366 } | 371 } |
| 367 } | 372 } |
| 368 return SetLastStatus(SUCCEEDED); | 373 return SetLastStatus(SUCCEEDED); |
| 369 } | 374 } |
| 370 | 375 |
| 371 | 376 |
| 372 OptimizingCompiler::Status OptimizingCompiler::GenerateAndInstallCode() { | 377 OptimizingCompiler::Status OptimizingCompiler::GenerateAndInstallCode() { |
| 373 ASSERT(last_status() == SUCCEEDED); | 378 ASSERT(last_status() == SUCCEEDED); |
| 374 Timer timer(this, &time_taken_to_codegen_); | 379 { // Scope for timer. |
| 375 ASSERT(chunk_ != NULL); | 380 Timer timer(this, &time_taken_to_codegen_); |
| 376 ASSERT(graph_ != NULL); | 381 ASSERT(chunk_ != NULL); |
| 377 Handle<Code> optimized_code = chunk_->Codegen(); | 382 ASSERT(graph_ != NULL); |
| 378 if (optimized_code.is_null()) { | 383 Handle<Code> optimized_code = chunk_->Codegen(); |
| 379 info()->set_bailout_reason("code generation failed"); | 384 if (optimized_code.is_null()) { |
| 380 return AbortOptimization(); | 385 info()->set_bailout_reason("code generation failed"); |
| 386 return AbortOptimization(); |
| 387 } |
| 388 info()->SetCode(optimized_code); |
| 381 } | 389 } |
| 382 info()->SetCode(optimized_code); | |
| 383 RecordOptimizationStats(); | 390 RecordOptimizationStats(); |
| 384 return SetLastStatus(SUCCEEDED); | 391 return SetLastStatus(SUCCEEDED); |
| 385 } | 392 } |
| 386 | 393 |
| 387 | 394 |
| 388 static bool GenerateCode(CompilationInfo* info) { | 395 static bool GenerateCode(CompilationInfo* info) { |
| 389 bool is_optimizing = V8::UseCrankshaft() && | 396 bool is_optimizing = V8::UseCrankshaft() && |
| 390 !info->IsCompilingForDebugging() && | 397 !info->IsCompilingForDebugging() && |
| 391 info->IsOptimizing(); | 398 info->IsOptimizing(); |
| 392 if (is_optimizing) { | 399 if (is_optimizing) { |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 } | 1061 } |
| 1055 } | 1062 } |
| 1056 | 1063 |
| 1057 GDBJIT(AddCode(Handle<String>(shared->DebugName()), | 1064 GDBJIT(AddCode(Handle<String>(shared->DebugName()), |
| 1058 Handle<Script>(info->script()), | 1065 Handle<Script>(info->script()), |
| 1059 Handle<Code>(info->code()), | 1066 Handle<Code>(info->code()), |
| 1060 info)); | 1067 info)); |
| 1061 } | 1068 } |
| 1062 | 1069 |
| 1063 } } // namespace v8::internal | 1070 } } // namespace v8::internal |
| OLD | NEW |