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 |
2045 | 2048 // break slots. |
2046 ForceDebuggerActive force_debugger_active(isolate_); | 2049 if (!function->shared()->code()->has_debug_break_slots()) { |
2047 MaybeHandle<Code> code = Compiler::GetCodeForDebugging(function); | 2050 ForceDebuggerActive force_debugger_active(isolate_); |
2048 // Recompilation can fail. In that case leave the code as it was. | 2051 MaybeHandle<Code> code = Compiler::GetCodeForDebugging(function); |
2049 if (!code.is_null()) | 2052 // Recompilation can fail. In that case leave the code as it was. |
2050 function->ReplaceCode(*code.ToHandleChecked()); | 2053 if (!code.is_null()) |
2051 ASSERT_EQ(function->code(), function->shared()->code()); | 2054 function->ReplaceCode(*code.ToHandleChecked()); |
2055 ASSERT_EQ(function->code(), function->shared()->code()); | |
2056 } | |
2052 } | 2057 } |
Yang
2014/05/08 16:36:48
You need to replace the function code by the share
rmcilroy
2014/05/08 16:57:16
Done.
| |
2053 | 2058 |
2054 | 2059 |
2055 void Debug::RecompileAndRelocateSuspendedGenerators( | 2060 void Debug::RecompileAndRelocateSuspendedGenerators( |
2056 const List<Handle<JSGeneratorObject> > &generators) { | 2061 const List<Handle<JSGeneratorObject> > &generators) { |
2057 for (int i = 0; i < generators.length(); i++) { | 2062 for (int i = 0; i < generators.length(); i++) { |
2058 Handle<JSFunction> fun(generators[i]->function()); | 2063 Handle<JSFunction> fun(generators[i]->function()); |
2059 | 2064 |
2060 MaybeRecompileFunctionForDebugging(fun); | 2065 EnsureFunctionHasDebugBreakSlots(fun); |
2061 | 2066 |
2062 int code_offset = generators[i]->continuation(); | 2067 int code_offset = generators[i]->continuation(); |
2063 int pc_offset = ComputePcOffsetFromCodeOffset(fun->code(), code_offset); | 2068 int pc_offset = ComputePcOffsetFromCodeOffset(fun->code(), code_offset); |
2064 generators[i]->set_continuation(pc_offset); | 2069 generators[i]->set_continuation(pc_offset); |
2065 } | 2070 } |
2066 } | 2071 } |
2067 | 2072 |
2068 | 2073 |
2069 void Debug::PrepareForBreakPoints() { | 2074 void Debug::PrepareForBreakPoints() { |
2070 // If preparing for the first break point make sure to deoptimize all | 2075 // 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. | 2215 // activations could also have active activations. That's fine. |
2211 for (int i = 0; i < active_functions.length(); i++) { | 2216 for (int i = 0; i < active_functions.length(); i++) { |
2212 Handle<JSFunction> function = active_functions[i]; | 2217 Handle<JSFunction> function = active_functions[i]; |
2213 Handle<SharedFunctionInfo> shared(function->shared()); | 2218 Handle<SharedFunctionInfo> shared(function->shared()); |
2214 | 2219 |
2215 // If recompilation is not possible just skip it. | 2220 // If recompilation is not possible just skip it. |
2216 if (shared->is_toplevel()) continue; | 2221 if (shared->is_toplevel()) continue; |
2217 if (!shared->allows_lazy_compilation()) continue; | 2222 if (!shared->allows_lazy_compilation()) continue; |
2218 if (shared->code()->kind() == Code::BUILTIN) continue; | 2223 if (shared->code()->kind() == Code::BUILTIN) continue; |
2219 | 2224 |
2220 MaybeRecompileFunctionForDebugging(function); | 2225 EnsureFunctionHasDebugBreakSlots(function); |
2221 } | 2226 } |
2222 | 2227 |
2223 RedirectActivationsToRecompiledCodeOnThread(isolate_, | 2228 RedirectActivationsToRecompiledCodeOnThread(isolate_, |
2224 isolate_->thread_local_top()); | 2229 isolate_->thread_local_top()); |
2225 | 2230 |
2226 ActiveFunctionsRedirector active_functions_redirector; | 2231 ActiveFunctionsRedirector active_functions_redirector; |
2227 isolate_->thread_manager()->IterateArchivedThreads( | 2232 isolate_->thread_manager()->IterateArchivedThreads( |
2228 &active_functions_redirector); | 2233 &active_functions_redirector); |
2229 } | 2234 } |
2230 } | 2235 } |
(...skipping 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3847 already_signalled_ = false; | 3852 already_signalled_ = false; |
3848 } | 3853 } |
3849 { | 3854 { |
3850 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); | 3855 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); |
3851 isolate_->debugger()->CallMessageDispatchHandler(); | 3856 isolate_->debugger()->CallMessageDispatchHandler(); |
3852 } | 3857 } |
3853 } | 3858 } |
3854 } | 3859 } |
3855 | 3860 |
3856 } } // namespace v8::internal | 3861 } } // namespace v8::internal |
OLD | NEW |