Chromium Code Reviews| 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 "v8.h" | 5 #include "v8.h" |
| 6 | 6 |
| 7 #include "api.h" | 7 #include "api.h" |
| 8 #include "arguments.h" | 8 #include "arguments.h" |
| 9 #include "bootstrapper.h" | 9 #include "bootstrapper.h" |
| 10 #include "code-stubs.h" | 10 #include "code-stubs.h" |
| (...skipping 2019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2030 } | 2030 } |
| 2031 | 2031 |
| 2032 private: | 2032 private: |
| 2033 Isolate *isolate_; | 2033 Isolate *isolate_; |
| 2034 bool old_state_; | 2034 bool old_state_; |
| 2035 | 2035 |
| 2036 DISALLOW_COPY_AND_ASSIGN(ForceDebuggerActive); | 2036 DISALLOW_COPY_AND_ASSIGN(ForceDebuggerActive); |
| 2037 }; | 2037 }; |
| 2038 | 2038 |
| 2039 | 2039 |
| 2040 void Debug::MaybeRecompileFunctionForDebugging(Handle<JSFunction> function) { | 2040 void Debug::EnsureFunctionHasDebugBreakSlots(Handle<JSFunction> function) { |
| 2041 ASSERT_EQ(Code::FUNCTION, function->code()->kind()); | 2041 if (function->code()->kind() == Code::FUNCTION && |
| 2042 ASSERT_EQ(function->code(), function->shared()->code()); | 2042 function->code()->has_debug_break_slots()) { |
| 2043 // Nothing to do. Function code already had debug break slots. | |
| 2044 return; | |
| 2045 } | |
| 2043 | 2046 |
| 2044 if (function->code()->has_debug_break_slots()) return; | 2047 // Make sure that the shared full code is compiled with debug |
| 2048 // break slots. | |
| 2049 if (!function->shared()->code()->has_debug_break_slots()) { | |
| 2050 ForceDebuggerActive force_debugger_active(isolate_); | |
| 2051 MaybeHandle<Code> code = Compiler::GetCodeForDebugging(function); | |
| 2052 // Recompilation can fail. In that case leave the code as it was. | |
| 2053 if (!code.is_null()) | |
| 2054 function->ReplaceCode(*code.ToHandleChecked()); | |
| 2055 } | |
| 2045 | 2056 |
| 2046 ForceDebuggerActive force_debugger_active(isolate_); | 2057 // Keep function code in sync with shared function info. |
| 2047 MaybeHandle<Code> code = Compiler::GetCodeForDebugging(function); | 2058 function->set_code(function->shared()->code()); |
| 2048 // Recompilation can fail. In that case leave the code as it was. | |
| 2049 if (!code.is_null()) | |
| 2050 function->ReplaceCode(*code.ToHandleChecked()); | |
| 2051 ASSERT_EQ(function->code(), function->shared()->code()); | |
| 2052 } | 2059 } |
| 2053 | 2060 |
| 2054 | 2061 |
| 2055 void Debug::RecompileAndRelocateSuspendedGenerators( | 2062 void Debug::RecompileAndRelocateSuspendedGenerators( |
| 2056 const List<Handle<JSGeneratorObject> > &generators) { | 2063 const List<Handle<JSGeneratorObject> > &generators) { |
| 2057 for (int i = 0; i < generators.length(); i++) { | 2064 for (int i = 0; i < generators.length(); i++) { |
| 2058 Handle<JSFunction> fun(generators[i]->function()); | 2065 Handle<JSFunction> fun(generators[i]->function()); |
| 2059 | 2066 |
| 2060 MaybeRecompileFunctionForDebugging(fun); | 2067 EnsureFunctionHasDebugBreakSlots(fun); |
|
rmcilroy
2014/05/08 17:00:45
Should there also be checks here to just continue
Yang
2014/05/08 17:03:49
Not sure about lazy compilation. I'll do some rese
rmcilroy
2014/05/08 17:45:37
OK, I'll land as-is now, and leave investigation o
wingo
2014/05/12 08:02:50
Some test cases would have been nice here. I don'
| |
| 2061 | 2068 |
| 2062 int code_offset = generators[i]->continuation(); | 2069 int code_offset = generators[i]->continuation(); |
| 2063 int pc_offset = ComputePcOffsetFromCodeOffset(fun->code(), code_offset); | 2070 int pc_offset = ComputePcOffsetFromCodeOffset(fun->code(), code_offset); |
| 2064 generators[i]->set_continuation(pc_offset); | 2071 generators[i]->set_continuation(pc_offset); |
| 2065 } | 2072 } |
| 2066 } | 2073 } |
| 2067 | 2074 |
| 2068 | 2075 |
| 2069 void Debug::PrepareForBreakPoints() { | 2076 void Debug::PrepareForBreakPoints() { |
| 2070 // If preparing for the first break point make sure to deoptimize all | 2077 // If preparing for the first break point make sure to deoptimize all |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2210 // activations could also have active activations. That's fine. | 2217 // activations could also have active activations. That's fine. |
| 2211 for (int i = 0; i < active_functions.length(); i++) { | 2218 for (int i = 0; i < active_functions.length(); i++) { |
| 2212 Handle<JSFunction> function = active_functions[i]; | 2219 Handle<JSFunction> function = active_functions[i]; |
| 2213 Handle<SharedFunctionInfo> shared(function->shared()); | 2220 Handle<SharedFunctionInfo> shared(function->shared()); |
| 2214 | 2221 |
| 2215 // If recompilation is not possible just skip it. | 2222 // If recompilation is not possible just skip it. |
| 2216 if (shared->is_toplevel()) continue; | 2223 if (shared->is_toplevel()) continue; |
| 2217 if (!shared->allows_lazy_compilation()) continue; | 2224 if (!shared->allows_lazy_compilation()) continue; |
| 2218 if (shared->code()->kind() == Code::BUILTIN) continue; | 2225 if (shared->code()->kind() == Code::BUILTIN) continue; |
| 2219 | 2226 |
| 2220 MaybeRecompileFunctionForDebugging(function); | 2227 EnsureFunctionHasDebugBreakSlots(function); |
| 2221 } | 2228 } |
| 2222 | 2229 |
| 2223 RedirectActivationsToRecompiledCodeOnThread(isolate_, | 2230 RedirectActivationsToRecompiledCodeOnThread(isolate_, |
| 2224 isolate_->thread_local_top()); | 2231 isolate_->thread_local_top()); |
| 2225 | 2232 |
| 2226 ActiveFunctionsRedirector active_functions_redirector; | 2233 ActiveFunctionsRedirector active_functions_redirector; |
| 2227 isolate_->thread_manager()->IterateArchivedThreads( | 2234 isolate_->thread_manager()->IterateArchivedThreads( |
| 2228 &active_functions_redirector); | 2235 &active_functions_redirector); |
| 2229 } | 2236 } |
| 2230 } | 2237 } |
| (...skipping 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3847 already_signalled_ = false; | 3854 already_signalled_ = false; |
| 3848 } | 3855 } |
| 3849 { | 3856 { |
| 3850 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); | 3857 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); |
| 3851 isolate_->debugger()->CallMessageDispatchHandler(); | 3858 isolate_->debugger()->CallMessageDispatchHandler(); |
| 3852 } | 3859 } |
| 3853 } | 3860 } |
| 3854 } | 3861 } |
| 3855 | 3862 |
| 3856 } } // namespace v8::internal | 3863 } } // namespace v8::internal |
| OLD | NEW |