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 || |
Yang
2014/05/08 14:28:09
Like I said in the reland CL, this is incorrect. I
rmcilroy
2014/05/08 14:53:59
Sorry I missed that comment. This doesn't work -
| |
2042 ASSERT_EQ(function->code(), function->shared()->code()); | 2042 function->code()->has_debug_break_slots()) { |
2043 | 2043 return; |
2044 if (function->code()->has_debug_break_slots()) return; | 2044 } |
2045 | 2045 |
2046 ForceDebuggerActive force_debugger_active(isolate_); | 2046 ForceDebuggerActive force_debugger_active(isolate_); |
2047 MaybeHandle<Code> code = Compiler::GetCodeForDebugging(function); | 2047 MaybeHandle<Code> code = Compiler::GetCodeForDebugging(function); |
2048 // Recompilation can fail. In that case leave the code as it was. | 2048 // Recompilation can fail. In that case leave the code as it was. |
2049 if (!code.is_null()) | 2049 if (!code.is_null()) |
2050 function->ReplaceCode(*code.ToHandleChecked()); | 2050 function->ReplaceCode(*code.ToHandleChecked()); |
2051 ASSERT_EQ(function->code(), function->shared()->code()); | 2051 ASSERT_EQ(function->code(), function->shared()->code()); |
2052 } | 2052 } |
2053 | 2053 |
2054 | 2054 |
2055 void Debug::RecompileAndRelocateSuspendedGenerators( | 2055 void Debug::RecompileAndRelocateSuspendedGenerators( |
2056 const List<Handle<JSGeneratorObject> > &generators) { | 2056 const List<Handle<JSGeneratorObject> > &generators) { |
2057 for (int i = 0; i < generators.length(); i++) { | 2057 for (int i = 0; i < generators.length(); i++) { |
2058 Handle<JSFunction> fun(generators[i]->function()); | 2058 Handle<JSFunction> fun(generators[i]->function()); |
2059 | 2059 |
2060 MaybeRecompileFunctionForDebugging(fun); | 2060 EnsureFunctionHasDebugBreakSlots(fun); |
2061 | 2061 |
2062 int code_offset = generators[i]->continuation(); | 2062 int code_offset = generators[i]->continuation(); |
2063 int pc_offset = ComputePcOffsetFromCodeOffset(fun->code(), code_offset); | 2063 int pc_offset = ComputePcOffsetFromCodeOffset(fun->code(), code_offset); |
2064 generators[i]->set_continuation(pc_offset); | 2064 generators[i]->set_continuation(pc_offset); |
2065 } | 2065 } |
2066 } | 2066 } |
2067 | 2067 |
2068 | 2068 |
2069 void Debug::PrepareForBreakPoints() { | 2069 void Debug::PrepareForBreakPoints() { |
2070 // If preparing for the first break point make sure to deoptimize all | 2070 // 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. | 2210 // activations could also have active activations. That's fine. |
2211 for (int i = 0; i < active_functions.length(); i++) { | 2211 for (int i = 0; i < active_functions.length(); i++) { |
2212 Handle<JSFunction> function = active_functions[i]; | 2212 Handle<JSFunction> function = active_functions[i]; |
2213 Handle<SharedFunctionInfo> shared(function->shared()); | 2213 Handle<SharedFunctionInfo> shared(function->shared()); |
2214 | 2214 |
2215 // If recompilation is not possible just skip it. | 2215 // If recompilation is not possible just skip it. |
2216 if (shared->is_toplevel()) continue; | 2216 if (shared->is_toplevel()) continue; |
2217 if (!shared->allows_lazy_compilation()) continue; | 2217 if (!shared->allows_lazy_compilation()) continue; |
2218 if (shared->code()->kind() == Code::BUILTIN) continue; | 2218 if (shared->code()->kind() == Code::BUILTIN) continue; |
2219 | 2219 |
2220 MaybeRecompileFunctionForDebugging(function); | 2220 EnsureFunctionHasDebugBreakSlots(function); |
2221 } | 2221 } |
2222 | 2222 |
2223 RedirectActivationsToRecompiledCodeOnThread(isolate_, | 2223 RedirectActivationsToRecompiledCodeOnThread(isolate_, |
2224 isolate_->thread_local_top()); | 2224 isolate_->thread_local_top()); |
2225 | 2225 |
2226 ActiveFunctionsRedirector active_functions_redirector; | 2226 ActiveFunctionsRedirector active_functions_redirector; |
2227 isolate_->thread_manager()->IterateArchivedThreads( | 2227 isolate_->thread_manager()->IterateArchivedThreads( |
2228 &active_functions_redirector); | 2228 &active_functions_redirector); |
2229 } | 2229 } |
2230 } | 2230 } |
(...skipping 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3847 already_signalled_ = false; | 3847 already_signalled_ = false; |
3848 } | 3848 } |
3849 { | 3849 { |
3850 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); | 3850 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); |
3851 isolate_->debugger()->CallMessageDispatchHandler(); | 3851 isolate_->debugger()->CallMessageDispatchHandler(); |
3852 } | 3852 } |
3853 } | 3853 } |
3854 } | 3854 } |
3855 | 3855 |
3856 } } // namespace v8::internal | 3856 } } // namespace v8::internal |
OLD | NEW |