OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 1876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1887 | 1887 |
1888 EnsureFunctionHasDebugBreakSlots(fun); | 1888 EnsureFunctionHasDebugBreakSlots(fun); |
1889 | 1889 |
1890 int code_offset = generators[i]->continuation(); | 1890 int code_offset = generators[i]->continuation(); |
1891 int pc_offset = ComputePcOffsetFromCodeOffset(fun->code(), code_offset); | 1891 int pc_offset = ComputePcOffsetFromCodeOffset(fun->code(), code_offset); |
1892 generators[i]->set_continuation(pc_offset); | 1892 generators[i]->set_continuation(pc_offset); |
1893 } | 1893 } |
1894 } | 1894 } |
1895 | 1895 |
1896 | 1896 |
1897 static bool SkipSharedFunctionInfo(SharedFunctionInfo* shared, | |
1898 Object* active_code_marker) { | |
1899 if (!shared->allows_lazy_compilation()) return true; | |
1900 if (!shared->script()->IsScript()) return true; | |
1901 Object* script = shared->script(); | |
1902 if (!script->IsScript()) return true; | |
1903 if (Script::cast(script)->type()->value() == Script::TYPE_NATIVE) return true; | |
1904 Code* shared_code = shared->code(); | |
1905 return shared_code->gc_metadata() == active_code_marker; | |
1906 } | |
1907 | |
1908 | |
1909 static inline bool HasDebugBreakSlots(Code* code) { | |
1910 return code->kind() == Code::FUNCTION && code->has_debug_break_slots(); | |
1911 } | |
1912 | |
1913 | |
1914 void Debug::PrepareForBreakPoints() { | 1897 void Debug::PrepareForBreakPoints() { |
1915 // If preparing for the first break point make sure to deoptimize all | 1898 // If preparing for the first break point make sure to deoptimize all |
1916 // functions as debugging does not work with optimized code. | 1899 // functions as debugging does not work with optimized code. |
1917 if (!has_break_points_) { | 1900 if (!has_break_points_) { |
1918 if (isolate_->concurrent_recompilation_enabled()) { | 1901 if (isolate_->concurrent_recompilation_enabled()) { |
1919 isolate_->optimizing_compiler_thread()->Flush(); | 1902 isolate_->optimizing_compiler_thread()->Flush(); |
1920 } | 1903 } |
1921 | 1904 |
1922 Deoptimizer::DeoptimizeAll(isolate_); | 1905 Deoptimizer::DeoptimizeAll(isolate_); |
1923 | 1906 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1969 &active_functions_collector); | 1952 &active_functions_collector); |
1970 | 1953 |
1971 // Scan the heap for all non-optimized functions which have no | 1954 // Scan the heap for all non-optimized functions which have no |
1972 // debug break slots and are not active or inlined into an active | 1955 // debug break slots and are not active or inlined into an active |
1973 // function and mark them for lazy compilation. | 1956 // function and mark them for lazy compilation. |
1974 HeapObject* obj = NULL; | 1957 HeapObject* obj = NULL; |
1975 while (((obj = iterator.next()) != NULL)) { | 1958 while (((obj = iterator.next()) != NULL)) { |
1976 if (obj->IsJSFunction()) { | 1959 if (obj->IsJSFunction()) { |
1977 JSFunction* function = JSFunction::cast(obj); | 1960 JSFunction* function = JSFunction::cast(obj); |
1978 SharedFunctionInfo* shared = function->shared(); | 1961 SharedFunctionInfo* shared = function->shared(); |
1979 if (SkipSharedFunctionInfo(shared, active_code_marker)) continue; | 1962 |
| 1963 if (!shared->allows_lazy_compilation()) continue; |
| 1964 if (!shared->script()->IsScript()) continue; |
| 1965 if (function->IsFromNativeScript()) continue; |
| 1966 if (shared->code()->gc_metadata() == active_code_marker) continue; |
| 1967 |
1980 if (shared->is_generator()) { | 1968 if (shared->is_generator()) { |
1981 generator_functions.Add(Handle<JSFunction>(function, isolate_)); | 1969 generator_functions.Add(Handle<JSFunction>(function, isolate_)); |
1982 continue; | 1970 continue; |
1983 } | 1971 } |
1984 if (HasDebugBreakSlots(function->code())) continue; | 1972 |
1985 Code* fallback = HasDebugBreakSlots(shared->code()) ? shared->code() | |
1986 : *lazy_compile; | |
1987 Code::Kind kind = function->code()->kind(); | 1973 Code::Kind kind = function->code()->kind(); |
1988 if (kind == Code::FUNCTION || | 1974 if (kind == Code::FUNCTION && |
1989 (kind == Code::BUILTIN && // Abort in-flight compilation. | 1975 !function->code()->has_debug_break_slots()) { |
1990 (function->IsInOptimizationQueue() || | 1976 function->ReplaceCode(*lazy_compile); |
1991 function->IsMarkedForOptimization() || | 1977 function->shared()->ReplaceCode(*lazy_compile); |
1992 function->IsMarkedForConcurrentOptimization()))) { | 1978 } else if (kind == Code::BUILTIN && |
1993 function->ReplaceCode(fallback); | 1979 (function->IsInOptimizationQueue() || |
| 1980 function->IsMarkedForOptimization() || |
| 1981 function->IsMarkedForConcurrentOptimization())) { |
| 1982 // Abort in-flight compilation. |
| 1983 Code* shared_code = function->shared()->code(); |
| 1984 if (shared_code->kind() == Code::FUNCTION && |
| 1985 shared_code->has_debug_break_slots()) { |
| 1986 function->ReplaceCode(shared_code); |
| 1987 } else { |
| 1988 function->ReplaceCode(*lazy_compile); |
| 1989 function->shared()->ReplaceCode(*lazy_compile); |
| 1990 } |
1994 } | 1991 } |
1995 } else if (obj->IsJSGeneratorObject()) { | 1992 } else if (obj->IsJSGeneratorObject()) { |
1996 JSGeneratorObject* gen = JSGeneratorObject::cast(obj); | 1993 JSGeneratorObject* gen = JSGeneratorObject::cast(obj); |
1997 if (!gen->is_suspended()) continue; | 1994 if (!gen->is_suspended()) continue; |
1998 | 1995 |
1999 JSFunction* fun = gen->function(); | 1996 JSFunction* fun = gen->function(); |
2000 DCHECK_EQ(fun->code()->kind(), Code::FUNCTION); | 1997 DCHECK_EQ(fun->code()->kind(), Code::FUNCTION); |
2001 if (fun->code()->has_debug_break_slots()) continue; | 1998 if (fun->code()->has_debug_break_slots()) continue; |
2002 | 1999 |
2003 int pc_offset = gen->continuation(); | 2000 int pc_offset = gen->continuation(); |
2004 DCHECK_LT(0, pc_offset); | 2001 DCHECK_LT(0, pc_offset); |
2005 | 2002 |
2006 int code_offset = | 2003 int code_offset = |
2007 ComputeCodeOffsetFromPcOffset(fun->code(), pc_offset); | 2004 ComputeCodeOffsetFromPcOffset(fun->code(), pc_offset); |
2008 | 2005 |
2009 // This will be fixed after we recompile the functions. | 2006 // This will be fixed after we recompile the functions. |
2010 gen->set_continuation(code_offset); | 2007 gen->set_continuation(code_offset); |
2011 | 2008 |
2012 suspended_generators.Add(Handle<JSGeneratorObject>(gen, isolate_)); | 2009 suspended_generators.Add(Handle<JSGeneratorObject>(gen, isolate_)); |
2013 } else if (obj->IsSharedFunctionInfo()) { | |
2014 SharedFunctionInfo* shared = SharedFunctionInfo::cast(obj); | |
2015 if (SkipSharedFunctionInfo(shared, active_code_marker)) continue; | |
2016 if (shared->is_generator()) continue; | |
2017 if (HasDebugBreakSlots(shared->code())) continue; | |
2018 shared->ReplaceCode(*lazy_compile); | |
2019 } | 2010 } |
2020 } | 2011 } |
2021 | 2012 |
2022 // Clear gc_metadata field. | 2013 // Clear gc_metadata field. |
2023 for (int i = 0; i < active_functions.length(); i++) { | 2014 for (int i = 0; i < active_functions.length(); i++) { |
2024 Handle<JSFunction> function = active_functions[i]; | 2015 Handle<JSFunction> function = active_functions[i]; |
2025 function->shared()->code()->set_gc_metadata(Smi::FromInt(0)); | 2016 function->shared()->code()->set_gc_metadata(Smi::FromInt(0)); |
2026 } | 2017 } |
2027 } | 2018 } |
2028 | 2019 |
(...skipping 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3395 logger_->DebugEvent("Put", message.text()); | 3386 logger_->DebugEvent("Put", message.text()); |
3396 } | 3387 } |
3397 | 3388 |
3398 | 3389 |
3399 void LockingCommandMessageQueue::Clear() { | 3390 void LockingCommandMessageQueue::Clear() { |
3400 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 3391 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
3401 queue_.Clear(); | 3392 queue_.Clear(); |
3402 } | 3393 } |
3403 | 3394 |
3404 } } // namespace v8::internal | 3395 } } // namespace v8::internal |
OLD | NEW |