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

Side by Side Diff: src/debug.cc

Issue 685753002: In PrepareForBreakPoints, also purge shared function info not referenced by functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: minor fixes Created 6 years, 1 month 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 | test/mjsunit/regress/regress-crbug-424142.js » ('j') | 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 "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
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
1897 void Debug::PrepareForBreakPoints() { 1914 void Debug::PrepareForBreakPoints() {
1898 // If preparing for the first break point make sure to deoptimize all 1915 // If preparing for the first break point make sure to deoptimize all
1899 // functions as debugging does not work with optimized code. 1916 // functions as debugging does not work with optimized code.
1900 if (!has_break_points_) { 1917 if (!has_break_points_) {
1901 if (isolate_->concurrent_recompilation_enabled()) { 1918 if (isolate_->concurrent_recompilation_enabled()) {
1902 isolate_->optimizing_compiler_thread()->Flush(); 1919 isolate_->optimizing_compiler_thread()->Flush();
1903 } 1920 }
1904 1921
1905 Deoptimizer::DeoptimizeAll(isolate_); 1922 Deoptimizer::DeoptimizeAll(isolate_);
1906 1923
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1952 &active_functions_collector); 1969 &active_functions_collector);
1953 1970
1954 // Scan the heap for all non-optimized functions which have no 1971 // Scan the heap for all non-optimized functions which have no
1955 // debug break slots and are not active or inlined into an active 1972 // debug break slots and are not active or inlined into an active
1956 // function and mark them for lazy compilation. 1973 // function and mark them for lazy compilation.
1957 HeapObject* obj = NULL; 1974 HeapObject* obj = NULL;
1958 while (((obj = iterator.next()) != NULL)) { 1975 while (((obj = iterator.next()) != NULL)) {
1959 if (obj->IsJSFunction()) { 1976 if (obj->IsJSFunction()) {
1960 JSFunction* function = JSFunction::cast(obj); 1977 JSFunction* function = JSFunction::cast(obj);
1961 SharedFunctionInfo* shared = function->shared(); 1978 SharedFunctionInfo* shared = function->shared();
1962 1979 if (SkipSharedFunctionInfo(shared, active_code_marker)) continue;
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
1968 if (shared->is_generator()) { 1980 if (shared->is_generator()) {
1969 generator_functions.Add(Handle<JSFunction>(function, isolate_)); 1981 generator_functions.Add(Handle<JSFunction>(function, isolate_));
1970 continue; 1982 continue;
1971 } 1983 }
1972 1984 if (HasDebugBreakSlots(function->code())) continue;
1985 Code* fallback = HasDebugBreakSlots(shared->code()) ? shared->code()
1986 : *lazy_compile;
1973 Code::Kind kind = function->code()->kind(); 1987 Code::Kind kind = function->code()->kind();
1974 if (kind == Code::FUNCTION && 1988 if (kind == Code::FUNCTION ||
1975 !function->code()->has_debug_break_slots()) { 1989 (kind == Code::BUILTIN && // Abort in-flight compilation.
1976 function->ReplaceCode(*lazy_compile); 1990 (function->IsInOptimizationQueue() ||
1977 function->shared()->ReplaceCode(*lazy_compile); 1991 function->IsMarkedForOptimization() ||
1978 } else if (kind == Code::BUILTIN && 1992 function->IsMarkedForConcurrentOptimization()))) {
1979 (function->IsInOptimizationQueue() || 1993 function->ReplaceCode(fallback);
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 }
1991 } 1994 }
1992 } else if (obj->IsJSGeneratorObject()) { 1995 } else if (obj->IsJSGeneratorObject()) {
1993 JSGeneratorObject* gen = JSGeneratorObject::cast(obj); 1996 JSGeneratorObject* gen = JSGeneratorObject::cast(obj);
1994 if (!gen->is_suspended()) continue; 1997 if (!gen->is_suspended()) continue;
1995 1998
1996 JSFunction* fun = gen->function(); 1999 JSFunction* fun = gen->function();
1997 DCHECK_EQ(fun->code()->kind(), Code::FUNCTION); 2000 DCHECK_EQ(fun->code()->kind(), Code::FUNCTION);
1998 if (fun->code()->has_debug_break_slots()) continue; 2001 if (fun->code()->has_debug_break_slots()) continue;
1999 2002
2000 int pc_offset = gen->continuation(); 2003 int pc_offset = gen->continuation();
2001 DCHECK_LT(0, pc_offset); 2004 DCHECK_LT(0, pc_offset);
2002 2005
2003 int code_offset = 2006 int code_offset =
2004 ComputeCodeOffsetFromPcOffset(fun->code(), pc_offset); 2007 ComputeCodeOffsetFromPcOffset(fun->code(), pc_offset);
2005 2008
2006 // This will be fixed after we recompile the functions. 2009 // This will be fixed after we recompile the functions.
2007 gen->set_continuation(code_offset); 2010 gen->set_continuation(code_offset);
2008 2011
2009 suspended_generators.Add(Handle<JSGeneratorObject>(gen, isolate_)); 2012 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);
2010 } 2019 }
2011 } 2020 }
2012 2021
2013 // Clear gc_metadata field. 2022 // Clear gc_metadata field.
2014 for (int i = 0; i < active_functions.length(); i++) { 2023 for (int i = 0; i < active_functions.length(); i++) {
2015 Handle<JSFunction> function = active_functions[i]; 2024 Handle<JSFunction> function = active_functions[i];
2016 function->shared()->code()->set_gc_metadata(Smi::FromInt(0)); 2025 function->shared()->code()->set_gc_metadata(Smi::FromInt(0));
2017 } 2026 }
2018 } 2027 }
2019 2028
(...skipping 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after
3386 logger_->DebugEvent("Put", message.text()); 3395 logger_->DebugEvent("Put", message.text());
3387 } 3396 }
3388 3397
3389 3398
3390 void LockingCommandMessageQueue::Clear() { 3399 void LockingCommandMessageQueue::Clear() {
3391 base::LockGuard<base::Mutex> lock_guard(&mutex_); 3400 base::LockGuard<base::Mutex> lock_guard(&mutex_);
3392 queue_.Clear(); 3401 queue_.Clear();
3393 } 3402 }
3394 3403
3395 } } // namespace v8::internal 3404 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-424142.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698