Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 391 false, | 391 false, |
| 392 info); | 392 info); |
| 393 | 393 |
| 394 // Check for stack-overflow exception. | 394 // Check for stack-overflow exception. |
| 395 if (code.is_null()) { | 395 if (code.is_null()) { |
| 396 Top::StackOverflow(); | 396 Top::StackOverflow(); |
| 397 return false; | 397 return false; |
| 398 } | 398 } |
| 399 | 399 |
| 400 #if defined ENABLE_LOGGING_AND_PROFILING || defined ENABLE_OPROFILE_AGENT | 400 #if defined ENABLE_LOGGING_AND_PROFILING || defined ENABLE_OPROFILE_AGENT |
| 401 // Log the code generation. If source information is available include script | 401 LogCodeCreateEvent(Logger::LAZY_COMPILE_TAG, |
|
Erik Corry
2010/02/04 15:11:06
We don't indent based on #if, so this should be 2
mnaganov (inactive)
2010/02/04 15:18:15
This is because I copied it from below. Fixed.
| |
| 402 // name and line number. Check explicit whether logging is enabled as finding | 402 name, |
| 403 // the line number is not for free. | 403 Handle<String>(shared->inferred_name()), |
| 404 if (Logger::is_logging() || OProfileAgent::is_enabled()) { | 404 start_position, |
| 405 Handle<String> func_name(name->length() > 0 ? | 405 script, |
| 406 *name : shared->inferred_name()); | 406 code); |
| 407 if (script->name()->IsString()) { | |
| 408 int line_num = GetScriptLineNumber(script, start_position) + 1; | |
| 409 LOG(CodeCreateEvent(Logger::LAZY_COMPILE_TAG, *code, *func_name, | |
| 410 String::cast(script->name()), line_num)); | |
| 411 OProfileAgent::CreateNativeCodeRegion(*func_name, | |
| 412 String::cast(script->name()), | |
| 413 line_num, | |
| 414 code->instruction_start(), | |
| 415 code->instruction_size()); | |
| 416 } else { | |
| 417 LOG(CodeCreateEvent(Logger::LAZY_COMPILE_TAG, *code, *func_name)); | |
| 418 OProfileAgent::CreateNativeCodeRegion(*func_name, | |
| 419 code->instruction_start(), | |
| 420 code->instruction_size()); | |
| 421 } | |
| 422 } | |
| 423 #endif | 407 #endif |
| 424 | 408 |
| 425 // Update the shared function info with the compiled code. | 409 // Update the shared function info with the compiled code. |
| 426 shared->set_code(*code); | 410 shared->set_code(*code); |
| 427 | 411 |
| 428 // Set the expected number of properties for instances. | 412 // Set the expected number of properties for instances. |
| 429 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); | 413 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); |
| 430 | 414 |
| 431 // Set the optimication hints after performing lazy compilation, as these are | 415 // Set the optimication hints after performing lazy compilation, as these are |
| 432 // not set when the function is set up as a lazily compiled function. | 416 // not set when the function is set up as a lazily compiled function. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 506 &info); | 490 &info); |
| 507 } | 491 } |
| 508 | 492 |
| 509 // Check for stack-overflow exception. | 493 // Check for stack-overflow exception. |
| 510 if (code.is_null()) { | 494 if (code.is_null()) { |
| 511 caller->SetStackOverflow(); | 495 caller->SetStackOverflow(); |
| 512 return Handle<JSFunction>::null(); | 496 return Handle<JSFunction>::null(); |
| 513 } | 497 } |
| 514 | 498 |
| 515 // Function compilation complete. | 499 // Function compilation complete. |
| 516 LOG(CodeCreateEvent(Logger::FUNCTION_TAG, *code, *literal->name())); | |
| 517 | 500 |
| 518 #ifdef ENABLE_OPROFILE_AGENT | 501 #if defined ENABLE_LOGGING_AND_PROFILING || defined ENABLE_OPROFILE_AGENT |
| 519 OProfileAgent::CreateNativeCodeRegion(*literal->name(), | 502 LogCodeCreateEvent(Logger::FUNCTION_TAG, |
| 520 code->instruction_start(), | 503 literal->name(), |
| 521 code->instruction_size()); | 504 literal->inferred_name(), |
| 505 literal->start_position(), | |
| 506 script, | |
| 507 code); | |
| 522 #endif | 508 #endif |
| 523 } | 509 } |
| 524 | 510 |
| 525 // Create a boilerplate function. | 511 // Create a boilerplate function. |
| 526 Handle<JSFunction> function = | 512 Handle<JSFunction> function = |
| 527 Factory::NewFunctionBoilerplate(literal->name(), | 513 Factory::NewFunctionBoilerplate(literal->name(), |
| 528 literal->materialized_literal_count(), | 514 literal->materialized_literal_count(), |
| 529 code); | 515 code); |
| 530 SetFunctionInfo(function, literal, false, script); | 516 SetFunctionInfo(function, literal, false, script); |
| 531 | 517 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 559 fun->shared()->set_is_expression(lit->is_expression()); | 545 fun->shared()->set_is_expression(lit->is_expression()); |
| 560 fun->shared()->set_is_toplevel(is_toplevel); | 546 fun->shared()->set_is_toplevel(is_toplevel); |
| 561 fun->shared()->set_inferred_name(*lit->inferred_name()); | 547 fun->shared()->set_inferred_name(*lit->inferred_name()); |
| 562 fun->shared()->SetThisPropertyAssignmentsInfo( | 548 fun->shared()->SetThisPropertyAssignmentsInfo( |
| 563 lit->has_only_simple_this_property_assignments(), | 549 lit->has_only_simple_this_property_assignments(), |
| 564 *lit->this_property_assignments()); | 550 *lit->this_property_assignments()); |
| 565 fun->shared()->set_try_full_codegen(lit->try_full_codegen()); | 551 fun->shared()->set_try_full_codegen(lit->try_full_codegen()); |
| 566 } | 552 } |
| 567 | 553 |
| 568 | 554 |
| 555 #if defined ENABLE_LOGGING_AND_PROFILING || defined ENABLE_OPROFILE_AGENT | |
| 556 inline void Compiler::LogCodeCreateEvent(Logger::LogEventsAndTags tag, | |
|
Erik Corry
2010/02/04 15:11:06
I don't think there is any point in having an inli
mnaganov (inactive)
2010/02/04 15:18:15
Removed 'inline'.
| |
| 557 Handle<String> name, | |
| 558 Handle<String> inferred_name, | |
| 559 int start_position, | |
| 560 Handle<Script> script, | |
| 561 Handle<Code> code) { | |
| 562 // Log the code generation. If source information is available | |
| 563 // include script name and line number. Check explicit whether | |
|
Erik Corry
2010/02/04 15:11:06
explicit->explicitly
mnaganov (inactive)
2010/02/04 15:18:15
Done.
| |
| 564 // logging is enabled as finding the line number is not for free. | |
|
Erik Corry
2010/02/04 15:11:06
for free -> free
mnaganov (inactive)
2010/02/04 15:18:15
Done.
| |
| 565 if (Logger::is_logging() || OProfileAgent::is_enabled()) { | |
| 566 Handle<String> func_name(name->length() > 0 ? *name : *inferred_name); | |
| 567 if (script->name()->IsString()) { | |
| 568 int line_num = GetScriptLineNumber(script, start_position) + 1; | |
| 569 LOG(CodeCreateEvent(tag, *code, *func_name, | |
| 570 String::cast(script->name()), line_num)); | |
| 571 OProfileAgent::CreateNativeCodeRegion(*func_name, | |
| 572 String::cast(script->name()), | |
| 573 line_num, | |
| 574 code->instruction_start(), | |
| 575 code->instruction_size()); | |
| 576 } else { | |
| 577 LOG(CodeCreateEvent(tag, *code, *func_name)); | |
| 578 OProfileAgent::CreateNativeCodeRegion(*func_name, | |
| 579 code->instruction_start(), | |
| 580 code->instruction_size()); | |
| 581 } | |
| 582 } | |
| 583 } | |
| 584 #endif | |
| 585 | |
| 569 } } // namespace v8::internal | 586 } } // namespace v8::internal |
| OLD | NEW |