| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <iomanip> | 5 #include <iomanip> |
| 6 #include <sstream> | 6 #include <sstream> |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
| (...skipping 9789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9800 // the code entry. | 9800 // the code entry. |
| 9801 IteratePointers(v, kPropertiesOffset, kCodeEntryOffset); | 9801 IteratePointers(v, kPropertiesOffset, kCodeEntryOffset); |
| 9802 v->VisitCodeEntry(this->address() + kCodeEntryOffset); | 9802 v->VisitCodeEntry(this->address() + kCodeEntryOffset); |
| 9803 IteratePointers(v, kCodeEntryOffset + kPointerSize, object_size); | 9803 IteratePointers(v, kCodeEntryOffset + kPointerSize, object_size); |
| 9804 } | 9804 } |
| 9805 | 9805 |
| 9806 | 9806 |
| 9807 void JSFunction::MarkForOptimization() { | 9807 void JSFunction::MarkForOptimization() { |
| 9808 Isolate* isolate = GetIsolate(); | 9808 Isolate* isolate = GetIsolate(); |
| 9809 DCHECK(!IsOptimized()); | 9809 DCHECK(!IsOptimized()); |
| 9810 DCHECK(shared()->allows_lazy_compilation() || code()->optimizable()); | 9810 DCHECK(shared()->allows_lazy_compilation() || IsOptimizable()); |
| 9811 set_code_no_write_barrier( | 9811 set_code_no_write_barrier( |
| 9812 isolate->builtins()->builtin(Builtins::kCompileOptimized)); | 9812 isolate->builtins()->builtin(Builtins::kCompileOptimized)); |
| 9813 // No write barrier required, since the builtin is part of the root set. | 9813 // No write barrier required, since the builtin is part of the root set. |
| 9814 } | 9814 } |
| 9815 | 9815 |
| 9816 | 9816 |
| 9817 void JSFunction::AttemptConcurrentOptimization() { | 9817 void JSFunction::AttemptConcurrentOptimization() { |
| 9818 Isolate* isolate = GetIsolate(); | 9818 Isolate* isolate = GetIsolate(); |
| 9819 if (!isolate->concurrent_recompilation_enabled() || | 9819 if (!isolate->concurrent_recompilation_enabled() || |
| 9820 isolate->bootstrapper()->IsActive()) { | 9820 isolate->bootstrapper()->IsActive()) { |
| 9821 MarkForOptimization(); | 9821 MarkForOptimization(); |
| 9822 return; | 9822 return; |
| 9823 } | 9823 } |
| 9824 if (isolate->concurrent_osr_enabled() && | 9824 if (isolate->concurrent_osr_enabled() && |
| 9825 isolate->optimizing_compile_dispatcher()->IsQueuedForOSR(this)) { | 9825 isolate->optimizing_compile_dispatcher()->IsQueuedForOSR(this)) { |
| 9826 // Do not attempt regular recompilation if we already queued this for OSR. | 9826 // Do not attempt regular recompilation if we already queued this for OSR. |
| 9827 // TODO(yangguo): This is necessary so that we don't install optimized | 9827 // TODO(yangguo): This is necessary so that we don't install optimized |
| 9828 // code on a function that is already optimized, since OSR and regular | 9828 // code on a function that is already optimized, since OSR and regular |
| 9829 // recompilation race. This goes away as soon as OSR becomes one-shot. | 9829 // recompilation race. This goes away as soon as OSR becomes one-shot. |
| 9830 return; | 9830 return; |
| 9831 } | 9831 } |
| 9832 DCHECK(!IsInOptimizationQueue()); | 9832 DCHECK(!IsInOptimizationQueue()); |
| 9833 DCHECK(!IsOptimized()); | 9833 DCHECK(!IsOptimized()); |
| 9834 DCHECK(shared()->allows_lazy_compilation() || code()->optimizable()); | 9834 DCHECK(shared()->allows_lazy_compilation() || IsOptimizable()); |
| 9835 DCHECK(isolate->concurrent_recompilation_enabled()); | 9835 DCHECK(isolate->concurrent_recompilation_enabled()); |
| 9836 if (FLAG_trace_concurrent_recompilation) { | 9836 if (FLAG_trace_concurrent_recompilation) { |
| 9837 PrintF(" ** Marking "); | 9837 PrintF(" ** Marking "); |
| 9838 ShortPrint(); | 9838 ShortPrint(); |
| 9839 PrintF(" for concurrent recompilation.\n"); | 9839 PrintF(" for concurrent recompilation.\n"); |
| 9840 } | 9840 } |
| 9841 set_code_no_write_barrier( | 9841 set_code_no_write_barrier( |
| 9842 GetIsolate()->builtins()->builtin(Builtins::kCompileOptimizedConcurrent)); | 9842 GetIsolate()->builtins()->builtin(Builtins::kCompileOptimizedConcurrent)); |
| 9843 // No write barrier required, since the builtin is part of the root set. | 9843 // No write barrier required, since the builtin is part of the root set. |
| 9844 } | 9844 } |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10722 if (!HasSourceCode()) return GetIsolate()->factory()->undefined_value(); | 10722 if (!HasSourceCode()) return GetIsolate()->factory()->undefined_value(); |
| 10723 Handle<String> source(String::cast(Script::cast(script())->source())); | 10723 Handle<String> source(String::cast(Script::cast(script())->source())); |
| 10724 return GetIsolate()->factory()->NewSubString( | 10724 return GetIsolate()->factory()->NewSubString( |
| 10725 source, start_position(), end_position()); | 10725 source, start_position(), end_position()); |
| 10726 } | 10726 } |
| 10727 | 10727 |
| 10728 | 10728 |
| 10729 bool SharedFunctionInfo::IsInlineable() { | 10729 bool SharedFunctionInfo::IsInlineable() { |
| 10730 // Check that the function has a script associated with it. | 10730 // Check that the function has a script associated with it. |
| 10731 if (!script()->IsScript()) return false; | 10731 if (!script()->IsScript()) return false; |
| 10732 if (optimization_disabled()) return false; | 10732 return !optimization_disabled(); |
| 10733 // If we never ran this (unlikely) then lets try to optimize it. | |
| 10734 if (code()->kind() != Code::FUNCTION) return true; | |
| 10735 return code()->optimizable(); | |
| 10736 } | 10733 } |
| 10737 | 10734 |
| 10738 | 10735 |
| 10739 int SharedFunctionInfo::SourceSize() { | 10736 int SharedFunctionInfo::SourceSize() { |
| 10740 return end_position() - start_position(); | 10737 return end_position() - start_position(); |
| 10741 } | 10738 } |
| 10742 | 10739 |
| 10743 | 10740 |
| 10744 int SharedFunctionInfo::CalculateInstanceSize() { | 10741 int SharedFunctionInfo::CalculateInstanceSize() { |
| 10745 int instance_size = | 10742 int instance_size = |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10827 // Disable optimization for the shared function info and mark the | 10824 // Disable optimization for the shared function info and mark the |
| 10828 // code as non-optimizable. The marker on the shared function info | 10825 // code as non-optimizable. The marker on the shared function info |
| 10829 // is there because we flush non-optimized code thereby loosing the | 10826 // is there because we flush non-optimized code thereby loosing the |
| 10830 // non-optimizable information for the code. When the code is | 10827 // non-optimizable information for the code. When the code is |
| 10831 // regenerated and set on the shared function info it is marked as | 10828 // regenerated and set on the shared function info it is marked as |
| 10832 // non-optimizable if optimization is disabled for the shared | 10829 // non-optimizable if optimization is disabled for the shared |
| 10833 // function info. | 10830 // function info. |
| 10834 DCHECK(reason != kNoReason); | 10831 DCHECK(reason != kNoReason); |
| 10835 set_optimization_disabled(true); | 10832 set_optimization_disabled(true); |
| 10836 set_disable_optimization_reason(reason); | 10833 set_disable_optimization_reason(reason); |
| 10837 // Code should be the lazy compilation stub or else unoptimized. If the | 10834 // Code should be the lazy compilation stub or else unoptimized. |
| 10838 // latter, disable optimization for the code too. | |
| 10839 DCHECK(code()->kind() == Code::FUNCTION || code()->kind() == Code::BUILTIN); | 10835 DCHECK(code()->kind() == Code::FUNCTION || code()->kind() == Code::BUILTIN); |
| 10840 if (code()->kind() == Code::FUNCTION) { | |
| 10841 code()->set_optimizable(false); | |
| 10842 } | |
| 10843 PROFILE(GetIsolate(), CodeDisableOptEvent(code(), this)); | 10836 PROFILE(GetIsolate(), CodeDisableOptEvent(code(), this)); |
| 10844 if (FLAG_trace_opt) { | 10837 if (FLAG_trace_opt) { |
| 10845 PrintF("[disabled optimization for "); | 10838 PrintF("[disabled optimization for "); |
| 10846 ShortPrint(); | 10839 ShortPrint(); |
| 10847 PrintF(", reason: %s]\n", GetBailoutReason(reason)); | 10840 PrintF(", reason: %s]\n", GetBailoutReason(reason)); |
| 10848 } | 10841 } |
| 10849 } | 10842 } |
| 10850 | 10843 |
| 10851 | 10844 |
| 10852 void SharedFunctionInfo::InitFromFunctionLiteral( | 10845 void SharedFunctionInfo::InitFromFunctionLiteral( |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10914 // If we clear ICs, we need to clear the type feedback vector too, since | 10907 // If we clear ICs, we need to clear the type feedback vector too, since |
| 10915 // CallICs are synced with a feedback vector slot. | 10908 // CallICs are synced with a feedback vector slot. |
| 10916 ClearTypeFeedbackInfo(); | 10909 ClearTypeFeedbackInfo(); |
| 10917 set_ic_age(new_ic_age); | 10910 set_ic_age(new_ic_age); |
| 10918 if (code()->kind() == Code::FUNCTION) { | 10911 if (code()->kind() == Code::FUNCTION) { |
| 10919 code()->set_profiler_ticks(0); | 10912 code()->set_profiler_ticks(0); |
| 10920 if (optimization_disabled() && | 10913 if (optimization_disabled() && |
| 10921 opt_count() >= FLAG_max_opt_count) { | 10914 opt_count() >= FLAG_max_opt_count) { |
| 10922 // Re-enable optimizations if they were disabled due to opt_count limit. | 10915 // Re-enable optimizations if they were disabled due to opt_count limit. |
| 10923 set_optimization_disabled(false); | 10916 set_optimization_disabled(false); |
| 10924 code()->set_optimizable(true); | |
| 10925 } | 10917 } |
| 10926 set_opt_count(0); | 10918 set_opt_count(0); |
| 10927 set_deopt_count(0); | 10919 set_deopt_count(0); |
| 10928 } | 10920 } |
| 10929 } | 10921 } |
| 10930 | 10922 |
| 10931 | 10923 |
| 10932 int SharedFunctionInfo::SearchOptimizedCodeMap(Context* native_context, | 10924 int SharedFunctionInfo::SearchOptimizedCodeMap(Context* native_context, |
| 10933 BailoutId osr_ast_id) { | 10925 BailoutId osr_ast_id) { |
| 10934 DisallowHeapAllocation no_gc; | 10926 DisallowHeapAllocation no_gc; |
| (...skipping 6325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17260 void PropertyCell::SetValueWithInvalidation(Handle<PropertyCell> cell, | 17252 void PropertyCell::SetValueWithInvalidation(Handle<PropertyCell> cell, |
| 17261 Handle<Object> new_value) { | 17253 Handle<Object> new_value) { |
| 17262 if (cell->value() != *new_value) { | 17254 if (cell->value() != *new_value) { |
| 17263 cell->set_value(*new_value); | 17255 cell->set_value(*new_value); |
| 17264 Isolate* isolate = cell->GetIsolate(); | 17256 Isolate* isolate = cell->GetIsolate(); |
| 17265 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 17257 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 17266 isolate, DependentCode::kPropertyCellChangedGroup); | 17258 isolate, DependentCode::kPropertyCellChangedGroup); |
| 17267 } | 17259 } |
| 17268 } | 17260 } |
| 17269 } } // namespace v8::internal | 17261 } } // namespace v8::internal |
| OLD | NEW |