| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 CompilationInfo::CompilationInfo(Handle<Script> script) | 54 CompilationInfo::CompilationInfo(Handle<Script> script) |
| 55 : isolate_(script->GetIsolate()), | 55 : isolate_(script->GetIsolate()), |
| 56 flags_(LanguageModeField::encode(CLASSIC_MODE)), | 56 flags_(LanguageModeField::encode(CLASSIC_MODE)), |
| 57 function_(NULL), | 57 function_(NULL), |
| 58 scope_(NULL), | 58 scope_(NULL), |
| 59 global_scope_(NULL), | 59 global_scope_(NULL), |
| 60 script_(script), | 60 script_(script), |
| 61 extension_(NULL), | 61 extension_(NULL), |
| 62 pre_parse_data_(NULL), | 62 pre_parse_data_(NULL), |
| 63 osr_ast_id_(AstNode::kNoNumber) { | 63 osr_ast_id_(AstNode::kNoNumber), |
| 64 number_of_ics_(0) { |
| 64 Initialize(BASE); | 65 Initialize(BASE); |
| 65 } | 66 } |
| 66 | 67 |
| 67 | 68 |
| 68 CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info) | 69 CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info) |
| 69 : isolate_(shared_info->GetIsolate()), | 70 : isolate_(shared_info->GetIsolate()), |
| 70 flags_(LanguageModeField::encode(CLASSIC_MODE) | | 71 flags_(LanguageModeField::encode(CLASSIC_MODE) | |
| 71 IsLazy::encode(true)), | 72 IsLazy::encode(true)), |
| 72 function_(NULL), | 73 function_(NULL), |
| 73 scope_(NULL), | 74 scope_(NULL), |
| 74 global_scope_(NULL), | 75 global_scope_(NULL), |
| 75 shared_info_(shared_info), | 76 shared_info_(shared_info), |
| 76 script_(Handle<Script>(Script::cast(shared_info->script()))), | 77 script_(Handle<Script>(Script::cast(shared_info->script()))), |
| 77 extension_(NULL), | 78 extension_(NULL), |
| 78 pre_parse_data_(NULL), | 79 pre_parse_data_(NULL), |
| 79 osr_ast_id_(AstNode::kNoNumber) { | 80 osr_ast_id_(AstNode::kNoNumber), |
| 81 number_of_ics_(0) { |
| 80 Initialize(BASE); | 82 Initialize(BASE); |
| 81 } | 83 } |
| 82 | 84 |
| 83 | 85 |
| 84 CompilationInfo::CompilationInfo(Handle<JSFunction> closure) | 86 CompilationInfo::CompilationInfo(Handle<JSFunction> closure) |
| 85 : isolate_(closure->GetIsolate()), | 87 : isolate_(closure->GetIsolate()), |
| 86 flags_(LanguageModeField::encode(CLASSIC_MODE) | | 88 flags_(LanguageModeField::encode(CLASSIC_MODE) | |
| 87 IsLazy::encode(true)), | 89 IsLazy::encode(true)), |
| 88 function_(NULL), | 90 function_(NULL), |
| 89 scope_(NULL), | 91 scope_(NULL), |
| 90 global_scope_(NULL), | 92 global_scope_(NULL), |
| 91 closure_(closure), | 93 closure_(closure), |
| 92 shared_info_(Handle<SharedFunctionInfo>(closure->shared())), | 94 shared_info_(Handle<SharedFunctionInfo>(closure->shared())), |
| 93 script_(Handle<Script>(Script::cast(shared_info_->script()))), | 95 script_(Handle<Script>(Script::cast(shared_info_->script()))), |
| 94 extension_(NULL), | 96 extension_(NULL), |
| 95 pre_parse_data_(NULL), | 97 pre_parse_data_(NULL), |
| 96 osr_ast_id_(AstNode::kNoNumber) { | 98 osr_ast_id_(AstNode::kNoNumber), |
| 99 number_of_ics_(0) { |
| 97 Initialize(BASE); | 100 Initialize(BASE); |
| 98 } | 101 } |
| 99 | 102 |
| 100 | 103 |
| 101 // Disable optimization for the rest of the compilation pipeline. | 104 // Disable optimization for the rest of the compilation pipeline. |
| 102 void CompilationInfo::DisableOptimization() { | 105 void CompilationInfo::DisableOptimization() { |
| 103 bool is_optimizable_closure = | 106 bool is_optimizable_closure = |
| 104 FLAG_optimize_closures && | 107 FLAG_optimize_closures && |
| 105 closure_.is_null() && | 108 closure_.is_null() && |
| 106 !scope_->HasTrivialOuterContext() && | 109 !scope_->HasTrivialOuterContext() && |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 } | 416 } |
| 414 | 417 |
| 415 // Allocate function. | 418 // Allocate function. |
| 416 ASSERT(!info->code().is_null()); | 419 ASSERT(!info->code().is_null()); |
| 417 Handle<SharedFunctionInfo> result = | 420 Handle<SharedFunctionInfo> result = |
| 418 isolate->factory()->NewSharedFunctionInfo( | 421 isolate->factory()->NewSharedFunctionInfo( |
| 419 lit->name(), | 422 lit->name(), |
| 420 lit->materialized_literal_count(), | 423 lit->materialized_literal_count(), |
| 421 info->code(), | 424 info->code(), |
| 422 ScopeInfo::Create(info->scope())); | 425 ScopeInfo::Create(info->scope())); |
| 426 result->set_ic_total_count(info->number_of_ics()); |
| 423 | 427 |
| 424 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position()); | 428 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position()); |
| 425 Compiler::SetFunctionInfo(result, lit, true, script); | 429 Compiler::SetFunctionInfo(result, lit, true, script); |
| 426 | 430 |
| 427 if (script->name()->IsString()) { | 431 if (script->name()->IsString()) { |
| 428 PROFILE(isolate, CodeCreateEvent( | 432 PROFILE(isolate, CodeCreateEvent( |
| 429 info->is_eval() | 433 info->is_eval() |
| 430 ? Logger::EVAL_TAG | 434 ? Logger::EVAL_TAG |
| 431 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), | 435 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), |
| 432 *info->code(), | 436 *info->code(), |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 function->ReplaceCode(*code); | 643 function->ReplaceCode(*code); |
| 640 } else { | 644 } else { |
| 641 // Update the shared function info with the compiled code and the | 645 // Update the shared function info with the compiled code and the |
| 642 // scope info. Please note, that the order of the shared function | 646 // scope info. Please note, that the order of the shared function |
| 643 // info initialization is important since set_scope_info might | 647 // info initialization is important since set_scope_info might |
| 644 // trigger a GC, causing the ASSERT below to be invalid if the code | 648 // trigger a GC, causing the ASSERT below to be invalid if the code |
| 645 // was flushed. By setting the code object last we avoid this. | 649 // was flushed. By setting the code object last we avoid this. |
| 646 Handle<ScopeInfo> scope_info = ScopeInfo::Create(info->scope()); | 650 Handle<ScopeInfo> scope_info = ScopeInfo::Create(info->scope()); |
| 647 shared->set_scope_info(*scope_info); | 651 shared->set_scope_info(*scope_info); |
| 648 shared->set_code(*code); | 652 shared->set_code(*code); |
| 653 shared->set_ic_total_count(info->number_of_ics()); |
| 649 if (!function.is_null()) { | 654 if (!function.is_null()) { |
| 650 function->ReplaceCode(*code); | 655 function->ReplaceCode(*code); |
| 651 ASSERT(!function->IsOptimized()); | 656 ASSERT(!function->IsOptimized()); |
| 652 } | 657 } |
| 653 | 658 |
| 654 // Set the expected number of properties for instances. | 659 // Set the expected number of properties for instances. |
| 655 FunctionLiteral* lit = info->function(); | 660 FunctionLiteral* lit = info->function(); |
| 656 int expected = lit->expected_property_count(); | 661 int expected = lit->expected_property_count(); |
| 657 SetExpectedNofPropertiesFromEstimate(shared, expected); | 662 SetExpectedNofPropertiesFromEstimate(shared, expected); |
| 658 | 663 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 } else { | 729 } else { |
| 725 return Handle<SharedFunctionInfo>::null(); | 730 return Handle<SharedFunctionInfo>::null(); |
| 726 } | 731 } |
| 727 | 732 |
| 728 // Create a shared function info object. | 733 // Create a shared function info object. |
| 729 Handle<SharedFunctionInfo> result = | 734 Handle<SharedFunctionInfo> result = |
| 730 FACTORY->NewSharedFunctionInfo(literal->name(), | 735 FACTORY->NewSharedFunctionInfo(literal->name(), |
| 731 literal->materialized_literal_count(), | 736 literal->materialized_literal_count(), |
| 732 info.code(), | 737 info.code(), |
| 733 scope_info); | 738 scope_info); |
| 739 result->set_ic_total_count(info.number_of_ics()); |
| 734 SetFunctionInfo(result, literal, false, script); | 740 SetFunctionInfo(result, literal, false, script); |
| 735 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result); | 741 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result); |
| 736 result->set_allows_lazy_compilation(allow_lazy); | 742 result->set_allows_lazy_compilation(allow_lazy); |
| 737 | 743 |
| 738 // Set the expected number of properties for instances and return | 744 // Set the expected number of properties for instances and return |
| 739 // the resulting function. | 745 // the resulting function. |
| 740 SetExpectedNofPropertiesFromEstimate(result, | 746 SetExpectedNofPropertiesFromEstimate(result, |
| 741 literal->expected_property_count()); | 747 literal->expected_property_count()); |
| 742 live_edit_tracker.RecordFunctionInfo(result, literal); | 748 live_edit_tracker.RecordFunctionInfo(result, literal); |
| 743 return result; | 749 return result; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 } | 815 } |
| 810 } | 816 } |
| 811 | 817 |
| 812 GDBJIT(AddCode(Handle<String>(shared->DebugName()), | 818 GDBJIT(AddCode(Handle<String>(shared->DebugName()), |
| 813 Handle<Script>(info->script()), | 819 Handle<Script>(info->script()), |
| 814 Handle<Code>(info->code()), | 820 Handle<Code>(info->code()), |
| 815 info)); | 821 info)); |
| 816 } | 822 } |
| 817 | 823 |
| 818 } } // namespace v8::internal | 824 } } // namespace v8::internal |
| OLD | NEW |