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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 function_ = NULL; | 96 function_ = NULL; |
97 scope_ = NULL; | 97 scope_ = NULL; |
98 global_scope_ = NULL; | 98 global_scope_ = NULL; |
99 extension_ = NULL; | 99 extension_ = NULL; |
100 pre_parse_data_ = NULL; | 100 pre_parse_data_ = NULL; |
101 zone_ = zone; | 101 zone_ = zone; |
102 deferred_handles_ = NULL; | 102 deferred_handles_ = NULL; |
103 code_stub_ = NULL; | 103 code_stub_ = NULL; |
104 prologue_offset_ = kPrologueOffsetNotSet; | 104 prologue_offset_ = kPrologueOffsetNotSet; |
105 opt_count_ = shared_info().is_null() ? 0 : shared_info()->opt_count(); | 105 opt_count_ = shared_info().is_null() ? 0 : shared_info()->opt_count(); |
| 106 no_frame_ranges_ = isolate->cpu_profiler()->is_profiling() |
| 107 ? new List<OffsetRange>(2) : NULL; |
106 if (mode == STUB) { | 108 if (mode == STUB) { |
107 mode_ = STUB; | 109 mode_ = STUB; |
108 return; | 110 return; |
109 } | 111 } |
110 mode_ = V8::UseCrankshaft() ? mode : NONOPT; | 112 mode_ = V8::UseCrankshaft() ? mode : NONOPT; |
111 if (script_->type()->value() == Script::TYPE_NATIVE) { | 113 if (script_->type()->value() == Script::TYPE_NATIVE) { |
112 MarkAsNative(); | 114 MarkAsNative(); |
113 } | 115 } |
114 if (!shared_info_.is_null()) { | 116 if (!shared_info_.is_null()) { |
115 ASSERT(language_mode() == CLASSIC_MODE); | 117 ASSERT(language_mode() == CLASSIC_MODE); |
116 SetLanguageMode(shared_info_->language_mode()); | 118 SetLanguageMode(shared_info_->language_mode()); |
117 } | 119 } |
118 set_bailout_reason("unknown"); | 120 set_bailout_reason("unknown"); |
119 } | 121 } |
120 | 122 |
121 | 123 |
122 CompilationInfo::~CompilationInfo() { | 124 CompilationInfo::~CompilationInfo() { |
123 delete deferred_handles_; | 125 delete deferred_handles_; |
| 126 delete no_frame_ranges_; |
124 } | 127 } |
125 | 128 |
126 | 129 |
127 int CompilationInfo::num_parameters() const { | 130 int CompilationInfo::num_parameters() const { |
128 ASSERT(!IsStub()); | 131 ASSERT(!IsStub()); |
129 return scope()->num_parameters(); | 132 return scope()->num_parameters(); |
130 } | 133 } |
131 | 134 |
132 | 135 |
133 int CompilationInfo::num_heap_slots() const { | 136 int CompilationInfo::num_heap_slots() const { |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position()); | 564 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position()); |
562 Compiler::SetFunctionInfo(result, lit, true, script); | 565 Compiler::SetFunctionInfo(result, lit, true, script); |
563 | 566 |
564 if (script->name()->IsString()) { | 567 if (script->name()->IsString()) { |
565 PROFILE(isolate, CodeCreateEvent( | 568 PROFILE(isolate, CodeCreateEvent( |
566 info->is_eval() | 569 info->is_eval() |
567 ? Logger::EVAL_TAG | 570 ? Logger::EVAL_TAG |
568 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), | 571 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), |
569 *info->code(), | 572 *info->code(), |
570 *result, | 573 *result, |
| 574 info, |
571 String::cast(script->name()))); | 575 String::cast(script->name()))); |
572 GDBJIT(AddCode(Handle<String>(String::cast(script->name())), | 576 GDBJIT(AddCode(Handle<String>(String::cast(script->name())), |
573 script, | 577 script, |
574 info->code(), | 578 info->code(), |
575 info)); | 579 info)); |
576 } else { | 580 } else { |
577 PROFILE(isolate, CodeCreateEvent( | 581 PROFILE(isolate, CodeCreateEvent( |
578 info->is_eval() | 582 info->is_eval() |
579 ? Logger::EVAL_TAG | 583 ? Logger::EVAL_TAG |
580 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), | 584 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), |
581 *info->code(), | 585 *info->code(), |
582 *result, | 586 *result, |
| 587 info, |
583 isolate->heap()->empty_string())); | 588 isolate->heap()->empty_string())); |
584 GDBJIT(AddCode(Handle<String>(), script, info->code(), info)); | 589 GDBJIT(AddCode(Handle<String>(), script, info->code(), info)); |
585 } | 590 } |
586 | 591 |
587 // Hint to the runtime system used when allocating space for initial | 592 // Hint to the runtime system used when allocating space for initial |
588 // property space by setting the expected number of properties for | 593 // property space by setting the expected number of properties for |
589 // the instances of the function. | 594 // the instances of the function. |
590 SetExpectedNofPropertiesFromEstimate(result, lit->expected_property_count()); | 595 SetExpectedNofPropertiesFromEstimate(result, lit->expected_property_count()); |
591 | 596 |
592 script->set_compilation_state( | 597 script->set_compilation_state( |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 static void InstallCodeCommon(CompilationInfo* info) { | 805 static void InstallCodeCommon(CompilationInfo* info) { |
801 Handle<SharedFunctionInfo> shared = info->shared_info(); | 806 Handle<SharedFunctionInfo> shared = info->shared_info(); |
802 Handle<Code> code = info->code(); | 807 Handle<Code> code = info->code(); |
803 ASSERT(!code.is_null()); | 808 ASSERT(!code.is_null()); |
804 | 809 |
805 // Set optimizable to false if this is disallowed by the shared | 810 // Set optimizable to false if this is disallowed by the shared |
806 // function info, e.g., we might have flushed the code and must | 811 // function info, e.g., we might have flushed the code and must |
807 // reset this bit when lazy compiling the code again. | 812 // reset this bit when lazy compiling the code again. |
808 if (shared->optimization_disabled()) code->set_optimizable(false); | 813 if (shared->optimization_disabled()) code->set_optimizable(false); |
809 | 814 |
| 815 if (shared->code() == *code) { |
| 816 // Do not send compilation event for the same code twice. |
| 817 return; |
| 818 } |
810 Compiler::RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared); | 819 Compiler::RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared); |
811 } | 820 } |
812 | 821 |
813 | 822 |
814 static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { | 823 static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { |
815 Handle<Code> code = info->code(); | 824 Handle<Code> code = info->code(); |
816 if (FLAG_cache_optimized_code && | 825 if (FLAG_cache_optimized_code && |
817 info->osr_ast_id().IsNone() && | 826 info->osr_ast_id().IsNone() && |
818 code->kind() == Code::OPTIMIZED_FUNCTION) { | 827 code->kind() == Code::OPTIMIZED_FUNCTION) { |
819 Handle<JSFunction> function = info->closure(); | 828 Handle<JSFunction> function = info->closure(); |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1144 Handle<Code> code = info->code(); | 1153 Handle<Code> code = info->code(); |
1145 if (*code == info->isolate()->builtins()->builtin(Builtins::kLazyCompile)) | 1154 if (*code == info->isolate()->builtins()->builtin(Builtins::kLazyCompile)) |
1146 return; | 1155 return; |
1147 if (script->name()->IsString()) { | 1156 if (script->name()->IsString()) { |
1148 int line_num = GetScriptLineNumber(script, shared->start_position()) + 1; | 1157 int line_num = GetScriptLineNumber(script, shared->start_position()) + 1; |
1149 USE(line_num); | 1158 USE(line_num); |
1150 PROFILE(info->isolate(), | 1159 PROFILE(info->isolate(), |
1151 CodeCreateEvent(Logger::ToNativeByScript(tag, *script), | 1160 CodeCreateEvent(Logger::ToNativeByScript(tag, *script), |
1152 *code, | 1161 *code, |
1153 *shared, | 1162 *shared, |
| 1163 info, |
1154 String::cast(script->name()), | 1164 String::cast(script->name()), |
1155 line_num)); | 1165 line_num)); |
1156 } else { | 1166 } else { |
1157 PROFILE(info->isolate(), | 1167 PROFILE(info->isolate(), |
1158 CodeCreateEvent(Logger::ToNativeByScript(tag, *script), | 1168 CodeCreateEvent(Logger::ToNativeByScript(tag, *script), |
1159 *code, | 1169 *code, |
1160 *shared, | 1170 *shared, |
| 1171 info, |
1161 shared->DebugName())); | 1172 shared->DebugName())); |
1162 } | 1173 } |
1163 } | 1174 } |
1164 | 1175 |
1165 GDBJIT(AddCode(Handle<String>(shared->DebugName()), | 1176 GDBJIT(AddCode(Handle<String>(shared->DebugName()), |
1166 Handle<Script>(info->script()), | 1177 Handle<Script>(info->script()), |
1167 Handle<Code>(info->code()), | 1178 Handle<Code>(info->code()), |
1168 info)); | 1179 info)); |
1169 } | 1180 } |
1170 | 1181 |
1171 } } // namespace v8::internal | 1182 } } // namespace v8::internal |
OLD | NEW |