Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: src/debug.cc

Issue 274043002: Use ReplaceCode instead of set_code in debug.cc. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2032 matching lines...) Expand 10 before | Expand all | Expand 10 after
2043 // Nothing to do. Function code already had debug break slots. 2043 // Nothing to do. Function code already had debug break slots.
2044 return; 2044 return;
2045 } 2045 }
2046 2046
2047 // Make sure that the shared full code is compiled with debug 2047 // Make sure that the shared full code is compiled with debug
2048 // break slots. 2048 // break slots.
2049 if (!function->shared()->code()->has_debug_break_slots()) { 2049 if (!function->shared()->code()->has_debug_break_slots()) {
2050 ForceDebuggerActive force_debugger_active(isolate_); 2050 ForceDebuggerActive force_debugger_active(isolate_);
2051 MaybeHandle<Code> code = Compiler::GetCodeForDebugging(function); 2051 MaybeHandle<Code> code = Compiler::GetCodeForDebugging(function);
2052 // Recompilation can fail. In that case leave the code as it was. 2052 // Recompilation can fail. In that case leave the code as it was.
2053 if (!code.is_null()) 2053 if (!code.is_null()) function->ReplaceCode(*code.ToHandleChecked());
2054 function->ReplaceCode(*code.ToHandleChecked()); 2054 } else {
2055 // Simply use shared code if it has debug break slots.
2056 function->ReplaceCode(function->shared()->code());
2055 } 2057 }
2056
2057 // Keep function code in sync with shared function info.
2058 function->ReplaceCode(function->shared()->code());
2059 } 2058 }
2060 2059
2061 2060
2062 void Debug::RecompileAndRelocateSuspendedGenerators( 2061 void Debug::RecompileAndRelocateSuspendedGenerators(
2063 const List<Handle<JSGeneratorObject> > &generators) { 2062 const List<Handle<JSGeneratorObject> > &generators) {
2064 for (int i = 0; i < generators.length(); i++) { 2063 for (int i = 0; i < generators.length(); i++) {
2065 Handle<JSFunction> fun(generators[i]->function()); 2064 Handle<JSFunction> fun(generators[i]->function());
2066 2065
2067 EnsureFunctionHasDebugBreakSlots(fun); 2066 EnsureFunctionHasDebugBreakSlots(fun);
2068 2067
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2145 if (shared->code()->gc_metadata() == active_code_marker) continue; 2144 if (shared->code()->gc_metadata() == active_code_marker) continue;
2146 2145
2147 if (shared->is_generator()) { 2146 if (shared->is_generator()) {
2148 generator_functions.Add(Handle<JSFunction>(function, isolate_)); 2147 generator_functions.Add(Handle<JSFunction>(function, isolate_));
2149 continue; 2148 continue;
2150 } 2149 }
2151 2150
2152 Code::Kind kind = function->code()->kind(); 2151 Code::Kind kind = function->code()->kind();
2153 if (kind == Code::FUNCTION && 2152 if (kind == Code::FUNCTION &&
2154 !function->code()->has_debug_break_slots()) { 2153 !function->code()->has_debug_break_slots()) {
2155 function->set_code(*lazy_compile); 2154 function->ReplaceCode(*lazy_compile);
2156 function->shared()->set_code(*lazy_compile); 2155 function->shared()->ReplaceCode(*lazy_compile);
2157 } else if (kind == Code::BUILTIN && 2156 } else if (kind == Code::BUILTIN &&
2158 (function->IsInOptimizationQueue() || 2157 (function->IsInOptimizationQueue() ||
2159 function->IsMarkedForOptimization() || 2158 function->IsMarkedForOptimization() ||
2160 function->IsMarkedForConcurrentOptimization())) { 2159 function->IsMarkedForConcurrentOptimization())) {
2161 // Abort in-flight compilation. 2160 // Abort in-flight compilation.
2162 Code* shared_code = function->shared()->code(); 2161 Code* shared_code = function->shared()->code();
2163 if (shared_code->kind() == Code::FUNCTION && 2162 if (shared_code->kind() == Code::FUNCTION &&
2164 shared_code->has_debug_break_slots()) { 2163 shared_code->has_debug_break_slots()) {
2165 function->set_code(shared_code); 2164 function->ReplaceCode(shared_code);
2166 } else { 2165 } else {
2167 function->set_code(*lazy_compile); 2166 function->ReplaceCode(*lazy_compile);
2168 function->shared()->set_code(*lazy_compile); 2167 function->shared()->ReplaceCode(*lazy_compile);
2169 } 2168 }
2170 } 2169 }
2171 } else if (obj->IsJSGeneratorObject()) { 2170 } else if (obj->IsJSGeneratorObject()) {
2172 JSGeneratorObject* gen = JSGeneratorObject::cast(obj); 2171 JSGeneratorObject* gen = JSGeneratorObject::cast(obj);
2173 if (!gen->is_suspended()) continue; 2172 if (!gen->is_suspended()) continue;
2174 2173
2175 JSFunction* fun = gen->function(); 2174 JSFunction* fun = gen->function();
2176 ASSERT_EQ(fun->code()->kind(), Code::FUNCTION); 2175 ASSERT_EQ(fun->code()->kind(), Code::FUNCTION);
2177 if (fun->code()->has_debug_break_slots()) continue; 2176 if (fun->code()->has_debug_break_slots()) continue;
2178 2177
(...skipping 20 matching lines...) Expand all
2199 // Recompile generator functions that have suspended activations, and 2198 // Recompile generator functions that have suspended activations, and
2200 // relocate those activations. 2199 // relocate those activations.
2201 RecompileAndRelocateSuspendedGenerators(suspended_generators); 2200 RecompileAndRelocateSuspendedGenerators(suspended_generators);
2202 2201
2203 // Mark generator functions that didn't have suspended activations for lazy 2202 // Mark generator functions that didn't have suspended activations for lazy
2204 // recompilation. Note that this set does not include any active functions. 2203 // recompilation. Note that this set does not include any active functions.
2205 for (int i = 0; i < generator_functions.length(); i++) { 2204 for (int i = 0; i < generator_functions.length(); i++) {
2206 Handle<JSFunction> &function = generator_functions[i]; 2205 Handle<JSFunction> &function = generator_functions[i];
2207 if (function->code()->kind() != Code::FUNCTION) continue; 2206 if (function->code()->kind() != Code::FUNCTION) continue;
2208 if (function->code()->has_debug_break_slots()) continue; 2207 if (function->code()->has_debug_break_slots()) continue;
2209 function->set_code(*lazy_compile); 2208 function->ReplaceCode(*lazy_compile);
2210 function->shared()->set_code(*lazy_compile); 2209 function->shared()->ReplaceCode(*lazy_compile);
2211 } 2210 }
2212 2211
2213 // Now recompile all functions with activation frames and and 2212 // Now recompile all functions with activation frames and and
2214 // patch the return address to run in the new compiled code. It could be 2213 // patch the return address to run in the new compiled code. It could be
2215 // that some active functions were recompiled already by the suspended 2214 // that some active functions were recompiled already by the suspended
2216 // generator recompilation pass above; a generator with suspended 2215 // generator recompilation pass above; a generator with suspended
2217 // activations could also have active activations. That's fine. 2216 // activations could also have active activations. That's fine.
2218 for (int i = 0; i < active_functions.length(); i++) { 2217 for (int i = 0; i < active_functions.length(); i++) {
2219 Handle<JSFunction> function = active_functions[i]; 2218 Handle<JSFunction> function = active_functions[i];
2220 Handle<SharedFunctionInfo> shared(function->shared()); 2219 Handle<SharedFunctionInfo> shared(function->shared());
(...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after
3854 already_signalled_ = false; 3853 already_signalled_ = false;
3855 } 3854 }
3856 { 3855 {
3857 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); 3856 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_));
3858 isolate_->debugger()->CallMessageDispatchHandler(); 3857 isolate_->debugger()->CallMessageDispatchHandler();
3859 } 3858 }
3860 } 3859 }
3861 } 3860 }
3862 3861
3863 } } // namespace v8::internal 3862 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698