Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/compiler.cc

Issue 1317003: Align OProfile agent invocations style with logging. (Closed)
Patch Set: Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler.h ('k') | src/oprofile-agent.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 // Compile the code. 228 // Compile the code.
229 CompilationInfo info(lit, script, is_eval); 229 CompilationInfo info(lit, script, is_eval);
230 Handle<Code> code = MakeCode(context, &info); 230 Handle<Code> code = MakeCode(context, &info);
231 231
232 // Check for stack-overflow exceptions. 232 // Check for stack-overflow exceptions.
233 if (code.is_null()) { 233 if (code.is_null()) {
234 Top::StackOverflow(); 234 Top::StackOverflow();
235 return Handle<SharedFunctionInfo>::null(); 235 return Handle<SharedFunctionInfo>::null();
236 } 236 }
237 237
238 #if defined ENABLE_LOGGING_AND_PROFILING || defined ENABLE_OPROFILE_AGENT 238 if (script->name()->IsString()) {
239 // Log the code generation for the script. Check explicit whether logging is 239 LOG(CodeCreateEvent(is_eval ? Logger::EVAL_TAG : Logger::SCRIPT_TAG,
240 // to avoid allocating when not required. 240 *code, String::cast(script->name())));
241 if (Logger::is_logging() || OProfileAgent::is_enabled()) { 241 OPROFILE(CreateNativeCodeRegion(String::cast(script->name()),
242 if (script->name()->IsString()) { 242 code->instruction_start(),
243 SmartPointer<char> data = 243 code->instruction_size()));
244 String::cast(script->name())->ToCString(DISALLOW_NULLS); 244 } else {
245 LOG(CodeCreateEvent(is_eval ? Logger::EVAL_TAG : Logger::SCRIPT_TAG, 245 LOG(CodeCreateEvent(is_eval ? Logger::EVAL_TAG : Logger::SCRIPT_TAG,
246 *code, *data)); 246 *code, ""));
247 OProfileAgent::CreateNativeCodeRegion(*data, 247 OPROFILE(CreateNativeCodeRegion(is_eval ? "Eval" : "Script",
248 code->instruction_start(), 248 code->instruction_start(),
249 code->instruction_size()); 249 code->instruction_size()));
250 } else {
251 LOG(CodeCreateEvent(is_eval ? Logger::EVAL_TAG : Logger::SCRIPT_TAG,
252 *code, ""));
253 OProfileAgent::CreateNativeCodeRegion(is_eval ? "Eval" : "Script",
254 code->instruction_start(),
255 code->instruction_size());
256 }
257 } 250 }
258 #endif
259 251
260 // Allocate function. 252 // Allocate function.
261 Handle<SharedFunctionInfo> result = 253 Handle<SharedFunctionInfo> result =
262 Factory::NewSharedFunctionInfo(lit->name(), 254 Factory::NewSharedFunctionInfo(lit->name(),
263 lit->materialized_literal_count(), 255 lit->materialized_literal_count(),
264 code); 256 code);
265 257
266 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position()); 258 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position());
267 Compiler::SetFunctionInfo(result, lit, true, script); 259 Compiler::SetFunctionInfo(result, lit, true, script);
268 260
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 428
437 // Compile the code. 429 // Compile the code.
438 Handle<Code> code = MakeCode(Handle<Context>::null(), info); 430 Handle<Code> code = MakeCode(Handle<Context>::null(), info);
439 431
440 // Check for stack-overflow exception. 432 // Check for stack-overflow exception.
441 if (code.is_null()) { 433 if (code.is_null()) {
442 Top::StackOverflow(); 434 Top::StackOverflow();
443 return false; 435 return false;
444 } 436 }
445 437
446 #if defined ENABLE_LOGGING_AND_PROFILING || defined ENABLE_OPROFILE_AGENT 438 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG,
447 LogCodeCreateEvent(Logger::LAZY_COMPILE_TAG, 439 name,
448 name, 440 Handle<String>(shared->inferred_name()),
449 Handle<String>(shared->inferred_name()), 441 start_position,
450 start_position, 442 info->script(),
451 info->script(), 443 code);
452 code);
453 #endif
454 444
455 // Update the shared function info with the compiled code. 445 // Update the shared function info with the compiled code.
456 shared->set_code(*code); 446 shared->set_code(*code);
457 447
458 // Set the expected number of properties for instances. 448 // Set the expected number of properties for instances.
459 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); 449 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count());
460 450
461 // Set the optimication hints after performing lazy compilation, as these are 451 // Set the optimication hints after performing lazy compilation, as these are
462 // not set when the function is set up as a lazily compiled function. 452 // not set when the function is set up as a lazily compiled function.
463 shared->SetThisPropertyAssignmentsInfo( 453 shared->SetThisPropertyAssignmentsInfo(
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 code = CodeGenerator::MakeCode(&info); 561 code = CodeGenerator::MakeCode(&info);
572 } 562 }
573 563
574 // Check for stack-overflow exception. 564 // Check for stack-overflow exception.
575 if (code.is_null()) { 565 if (code.is_null()) {
576 caller->SetStackOverflow(); 566 caller->SetStackOverflow();
577 return Handle<SharedFunctionInfo>::null(); 567 return Handle<SharedFunctionInfo>::null();
578 } 568 }
579 569
580 // Function compilation complete. 570 // Function compilation complete.
581 571 RecordFunctionCompilation(Logger::FUNCTION_TAG,
582 #if defined ENABLE_LOGGING_AND_PROFILING || defined ENABLE_OPROFILE_AGENT 572 literal->name(),
583 LogCodeCreateEvent(Logger::FUNCTION_TAG, 573 literal->inferred_name(),
584 literal->name(), 574 literal->start_position(),
585 literal->inferred_name(), 575 script,
586 literal->start_position(), 576 code);
587 script,
588 code);
589 #endif
590 } 577 }
591 578
592 // Create a boilerplate function. 579 // Create a boilerplate function.
593 Handle<SharedFunctionInfo> result = 580 Handle<SharedFunctionInfo> result =
594 Factory::NewSharedFunctionInfo(literal->name(), 581 Factory::NewSharedFunctionInfo(literal->name(),
595 literal->materialized_literal_count(), 582 literal->materialized_literal_count(),
596 code); 583 code);
597 SetFunctionInfo(result, literal, false, script); 584 SetFunctionInfo(result, literal, false, script);
598 585
599 // Set the expected number of properties for instances and return 586 // Set the expected number of properties for instances and return
(...skipping 21 matching lines...) Expand all
621 function_info->set_is_expression(lit->is_expression()); 608 function_info->set_is_expression(lit->is_expression());
622 function_info->set_is_toplevel(is_toplevel); 609 function_info->set_is_toplevel(is_toplevel);
623 function_info->set_inferred_name(*lit->inferred_name()); 610 function_info->set_inferred_name(*lit->inferred_name());
624 function_info->SetThisPropertyAssignmentsInfo( 611 function_info->SetThisPropertyAssignmentsInfo(
625 lit->has_only_simple_this_property_assignments(), 612 lit->has_only_simple_this_property_assignments(),
626 *lit->this_property_assignments()); 613 *lit->this_property_assignments());
627 function_info->set_try_full_codegen(lit->try_full_codegen()); 614 function_info->set_try_full_codegen(lit->try_full_codegen());
628 } 615 }
629 616
630 617
631 #if defined ENABLE_LOGGING_AND_PROFILING || defined ENABLE_OPROFILE_AGENT 618 void Compiler::RecordFunctionCompilation(Logger::LogEventsAndTags tag,
632 void Compiler::LogCodeCreateEvent(Logger::LogEventsAndTags tag, 619 Handle<String> name,
633 Handle<String> name, 620 Handle<String> inferred_name,
634 Handle<String> inferred_name, 621 int start_position,
635 int start_position, 622 Handle<Script> script,
636 Handle<Script> script, 623 Handle<Code> code) {
637 Handle<Code> code) {
638 // Log the code generation. If source information is available 624 // Log the code generation. If source information is available
639 // include script name and line number. Check explicitly whether 625 // include script name and line number. Check explicitly whether
640 // logging is enabled as finding the line number is not free. 626 // logging is enabled as finding the line number is not free.
641 if (Logger::is_logging() || OProfileAgent::is_enabled()) { 627 if (Logger::is_logging() || OProfileAgent::is_enabled()) {
642 Handle<String> func_name(name->length() > 0 ? *name : *inferred_name); 628 Handle<String> func_name(name->length() > 0 ? *name : *inferred_name);
643 if (script->name()->IsString()) { 629 if (script->name()->IsString()) {
644 int line_num = GetScriptLineNumber(script, start_position) + 1; 630 int line_num = GetScriptLineNumber(script, start_position) + 1;
631 USE(line_num);
645 LOG(CodeCreateEvent(tag, *code, *func_name, 632 LOG(CodeCreateEvent(tag, *code, *func_name,
646 String::cast(script->name()), line_num)); 633 String::cast(script->name()), line_num));
647 OProfileAgent::CreateNativeCodeRegion(*func_name, 634 OPROFILE(CreateNativeCodeRegion(*func_name,
648 String::cast(script->name()), 635 String::cast(script->name()),
649 line_num, 636 line_num,
650 code->instruction_start(), 637 code->instruction_start(),
651 code->instruction_size()); 638 code->instruction_size()));
652 } else { 639 } else {
653 LOG(CodeCreateEvent(tag, *code, *func_name)); 640 LOG(CodeCreateEvent(tag, *code, *func_name));
654 OProfileAgent::CreateNativeCodeRegion(*func_name, 641 OPROFILE(CreateNativeCodeRegion(*func_name,
655 code->instruction_start(), 642 code->instruction_start(),
656 code->instruction_size()); 643 code->instruction_size()));
657 } 644 }
658 } 645 }
659 } 646 }
660 #endif
661 647
662 } } // namespace v8::internal 648 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/oprofile-agent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698