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

Side by Side Diff: src/debug.cc

Issue 269003: Fix a crash in Logger::LogCompiledFunctions due to a presence of scripts with disposed source. (Closed)
Patch Set: Fixed comments Created 11 years, 2 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
« no previous file with comments | « no previous file | src/log.cc » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 Handle<Object> fun(Top::global()->GetProperty(*function_name)); 1670 Handle<Object> fun(Top::global()->GetProperty(*function_name));
1671 ASSERT(fun->IsJSFunction()); 1671 ASSERT(fun->IsJSFunction());
1672 bool caught_exception; 1672 bool caught_exception;
1673 Handle<Object> js_object = Execution::TryCall( 1673 Handle<Object> js_object = Execution::TryCall(
1674 Handle<JSFunction>::cast(fun), 1674 Handle<JSFunction>::cast(fun),
1675 Handle<JSObject>(Debug::debug_context()->global()), 1675 Handle<JSObject>(Debug::debug_context()->global()),
1676 0, NULL, &caught_exception); 1676 0, NULL, &caught_exception);
1677 } 1677 }
1678 1678
1679 1679
1680 // If an object given is an external string, check that the underlying
1681 // resource is accessible. For other kinds of objects, always return true.
1682 static bool IsExternalStringValid(Object* str) {
1683 if (!str->IsString() || !StringShape(String::cast(str)).IsExternal()) {
1684 return true;
1685 }
1686 if (String::cast(str)->IsAsciiRepresentation()) {
1687 return ExternalAsciiString::cast(str)->resource() != NULL;
1688 } else if (String::cast(str)->IsTwoByteRepresentation()) {
1689 return ExternalTwoByteString::cast(str)->resource() != NULL;
1690 } else {
1691 return true;
1692 }
1693 }
1694
1695
1696 void Debug::CreateScriptCache() { 1680 void Debug::CreateScriptCache() {
1697 HandleScope scope; 1681 HandleScope scope;
1698 1682
1699 // Perform two GCs to get rid of all unreferenced scripts. The first GC gets 1683 // Perform two GCs to get rid of all unreferenced scripts. The first GC gets
1700 // rid of all the cached script wrappers and the second gets rid of the 1684 // rid of all the cached script wrappers and the second gets rid of the
1701 // scripts which is no longer referenced. 1685 // scripts which is no longer referenced.
1702 Heap::CollectAllGarbage(false); 1686 Heap::CollectAllGarbage(false);
1703 Heap::CollectAllGarbage(false); 1687 Heap::CollectAllGarbage(false);
1704 1688
1705 ASSERT(script_cache_ == NULL); 1689 ASSERT(script_cache_ == NULL);
1706 script_cache_ = new ScriptCache(); 1690 script_cache_ = new ScriptCache();
1707 1691
1708 // Scan heap for Script objects. 1692 // Scan heap for Script objects.
1709 int count = 0; 1693 int count = 0;
1710 HeapIterator iterator; 1694 HeapIterator iterator;
1711 while (iterator.has_next()) { 1695 while (iterator.has_next()) {
1712 HeapObject* obj = iterator.next(); 1696 HeapObject* obj = iterator.next();
1713 ASSERT(obj != NULL); 1697 ASSERT(obj != NULL);
1714 if (obj->IsScript() && IsExternalStringValid(Script::cast(obj)->source())) { 1698 if (obj->IsScript() && Script::cast(obj)->HasValidSource()) {
1715 script_cache_->Add(Handle<Script>(Script::cast(obj))); 1699 script_cache_->Add(Handle<Script>(Script::cast(obj)));
1716 count++; 1700 count++;
1717 } 1701 }
1718 } 1702 }
1719 } 1703 }
1720 1704
1721 1705
1722 void Debug::DestroyScriptCache() { 1706 void Debug::DestroyScriptCache() {
1723 // Get rid of the script cache if it was created. 1707 // Get rid of the script cache if it was created.
1724 if (script_cache_ != NULL) { 1708 if (script_cache_ != NULL) {
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after
2719 2703
2720 2704
2721 void LockingCommandMessageQueue::Clear() { 2705 void LockingCommandMessageQueue::Clear() {
2722 ScopedLock sl(lock_); 2706 ScopedLock sl(lock_);
2723 queue_.Clear(); 2707 queue_.Clear();
2724 } 2708 }
2725 2709
2726 #endif // ENABLE_DEBUGGER_SUPPORT 2710 #endif // ENABLE_DEBUGGER_SUPPORT
2727 2711
2728 } } // namespace v8::internal 2712 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698