| 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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 info()->SetCode(code); | 369 info()->SetCode(code); |
| 370 return SetLastStatus(BAILED_OUT); | 370 return SetLastStatus(BAILED_OUT); |
| 371 } | 371 } |
| 372 | 372 |
| 373 // Recompile the unoptimized version of the code if the current version | 373 // Recompile the unoptimized version of the code if the current version |
| 374 // doesn't have deoptimization support. Alternatively, we may decide to | 374 // doesn't have deoptimization support. Alternatively, we may decide to |
| 375 // run the full code generator to get a baseline for the compile-time | 375 // run the full code generator to get a baseline for the compile-time |
| 376 // performance of the hydrogen-based compiler. | 376 // performance of the hydrogen-based compiler. |
| 377 bool should_recompile = !info()->shared_info()->has_deoptimization_support(); | 377 bool should_recompile = !info()->shared_info()->has_deoptimization_support(); |
| 378 if (should_recompile || FLAG_hydrogen_stats) { | 378 if (should_recompile || FLAG_hydrogen_stats) { |
| 379 HPhase phase(HPhase::kFullCodeGen, isolate()); | 379 HPhase phase(HPhase::kFullCodeGen, isolate(), info()->zone()); |
| 380 CompilationInfoWithZone unoptimized(info()->shared_info()); | 380 CompilationInfoWithZone unoptimized(info()->shared_info()); |
| 381 // Note that we use the same AST that we will use for generating the | 381 // Note that we use the same AST that we will use for generating the |
| 382 // optimized code. | 382 // optimized code. |
| 383 unoptimized.SetFunction(info()->function()); | 383 unoptimized.SetFunction(info()->function()); |
| 384 unoptimized.SetScope(info()->scope()); | 384 unoptimized.SetScope(info()->scope()); |
| 385 unoptimized.SetContext(info()->context()); | 385 unoptimized.SetContext(info()->context()); |
| 386 if (should_recompile) unoptimized.EnableDeoptimizationSupport(); | 386 if (should_recompile) unoptimized.EnableDeoptimizationSupport(); |
| 387 bool succeeded = FullCodeGenerator::MakeCode(&unoptimized); | 387 bool succeeded = FullCodeGenerator::MakeCode(&unoptimized); |
| 388 if (should_recompile) { | 388 if (should_recompile) { |
| 389 if (!succeeded) return SetLastStatus(FAILED); | 389 if (!succeeded) return SetLastStatus(FAILED); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 404 ASSERT(info()->shared_info()->has_deoptimization_support()); | 404 ASSERT(info()->shared_info()->has_deoptimization_support()); |
| 405 | 405 |
| 406 if (FLAG_trace_hydrogen) { | 406 if (FLAG_trace_hydrogen) { |
| 407 Handle<String> name = info()->function()->debug_name(); | 407 Handle<String> name = info()->function()->debug_name(); |
| 408 PrintF("-----------------------------------------------------------\n"); | 408 PrintF("-----------------------------------------------------------\n"); |
| 409 PrintF("Compiling method %s using hydrogen\n", *name->ToCString()); | 409 PrintF("Compiling method %s using hydrogen\n", *name->ToCString()); |
| 410 isolate()->GetHTracer()->TraceCompilation(info()); | 410 isolate()->GetHTracer()->TraceCompilation(info()); |
| 411 } | 411 } |
| 412 | 412 |
| 413 // Type-check the function. | 413 // Type-check the function. |
| 414 AstTyper::Type(info()); | 414 AstTyper::Run(info()); |
| 415 | 415 |
| 416 graph_builder_ = new(info()->zone()) HOptimizedGraphBuilder(info()); | 416 graph_builder_ = new(info()->zone()) HOptimizedGraphBuilder(info()); |
| 417 | 417 |
| 418 Timer t(this, &time_taken_to_create_graph_); | 418 Timer t(this, &time_taken_to_create_graph_); |
| 419 graph_ = graph_builder_->CreateGraph(); | 419 graph_ = graph_builder_->CreateGraph(); |
| 420 | 420 |
| 421 if (isolate()->has_pending_exception()) { | 421 if (isolate()->has_pending_exception()) { |
| 422 info()->SetCode(Handle<Code>::null()); | 422 info()->SetCode(Handle<Code>::null()); |
| 423 return SetLastStatus(FAILED); | 423 return SetLastStatus(FAILED); |
| 424 } | 424 } |
| (...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1183 | 1183 |
| 1184 // Log the code generation. If source information is available include | 1184 // Log the code generation. If source information is available include |
| 1185 // script name and line number. Check explicitly whether logging is | 1185 // script name and line number. Check explicitly whether logging is |
| 1186 // enabled as finding the line number is not free. | 1186 // enabled as finding the line number is not free. |
| 1187 if (info->isolate()->logger()->is_logging_code_events() || | 1187 if (info->isolate()->logger()->is_logging_code_events() || |
| 1188 info->isolate()->cpu_profiler()->is_profiling()) { | 1188 info->isolate()->cpu_profiler()->is_profiling()) { |
| 1189 Handle<Script> script = info->script(); | 1189 Handle<Script> script = info->script(); |
| 1190 Handle<Code> code = info->code(); | 1190 Handle<Code> code = info->code(); |
| 1191 if (*code == info->isolate()->builtins()->builtin(Builtins::kLazyCompile)) | 1191 if (*code == info->isolate()->builtins()->builtin(Builtins::kLazyCompile)) |
| 1192 return; | 1192 return; |
| 1193 Handle<String> script_name; | |
| 1194 if (script->name()->IsString()) { | 1193 if (script->name()->IsString()) { |
| 1195 script_name = Handle<String>(String::cast(script->name())); | |
| 1196 } else { | |
| 1197 Handle<Object> name = GetScriptNameOrSourceURL(script); | |
| 1198 if (!name.is_null() && name->IsString()) { | |
| 1199 script_name = Handle<String>::cast(name); | |
| 1200 } | |
| 1201 } | |
| 1202 if (!script_name.is_null()) { | |
| 1203 int line_num = GetScriptLineNumber(script, shared->start_position()) + 1; | 1194 int line_num = GetScriptLineNumber(script, shared->start_position()) + 1; |
| 1204 USE(line_num); | 1195 USE(line_num); |
| 1205 PROFILE(info->isolate(), | 1196 PROFILE(info->isolate(), |
| 1206 CodeCreateEvent(Logger::ToNativeByScript(tag, *script), | 1197 CodeCreateEvent(Logger::ToNativeByScript(tag, *script), |
| 1207 *code, | 1198 *code, |
| 1208 *shared, | 1199 *shared, |
| 1209 info, | 1200 info, |
| 1210 String::cast(*script_name), | 1201 String::cast(script->name()), |
| 1211 line_num)); | 1202 line_num)); |
| 1212 } else { | 1203 } else { |
| 1213 PROFILE(info->isolate(), | 1204 PROFILE(info->isolate(), |
| 1214 CodeCreateEvent(Logger::ToNativeByScript(tag, *script), | 1205 CodeCreateEvent(Logger::ToNativeByScript(tag, *script), |
| 1215 *code, | 1206 *code, |
| 1216 *shared, | 1207 *shared, |
| 1217 info, | 1208 info, |
| 1218 shared->DebugName())); | 1209 shared->DebugName())); |
| 1219 } | 1210 } |
| 1220 } | 1211 } |
| 1221 | 1212 |
| 1222 GDBJIT(AddCode(Handle<String>(shared->DebugName()), | 1213 GDBJIT(AddCode(Handle<String>(shared->DebugName()), |
| 1223 Handle<Script>(info->script()), | 1214 Handle<Script>(info->script()), |
| 1224 Handle<Code>(info->code()), | 1215 Handle<Code>(info->code()), |
| 1225 info)); | 1216 info)); |
| 1226 } | 1217 } |
| 1227 | 1218 |
| 1228 } } // namespace v8::internal | 1219 } } // namespace v8::internal |
| OLD | NEW |