Changeset 47236 in webkit for trunk/JavaScriptCore/debugger/Debugger.cpp
- Timestamp:
- Aug 13, 2009, 2:51:50 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/debugger/Debugger.cpp
r44224 r47236 23 23 #include "Debugger.h" 24 24 25 #include "CollectorHeapIterator.h" 26 #include "Interpreter.h" 25 27 #include "JSGlobalObject.h" 26 #include "Interpreter.h"27 28 #include "Parser.h" 28 29 29 30 namespace JSC { 30 31 Debugger::Debugger()32 {33 }34 31 35 32 Debugger::~Debugger() … … 54 51 } 55 52 53 void Debugger::recompileAllJSFunctions(JSGlobalData* globalData) 54 { 55 // If JavaScript is running, it's not safe to recompile, since we'll end 56 // up throwing away code that is live on the stack. 57 ASSERT(!globalData->dynamicGlobalObject); 58 if (globalData->dynamicGlobalObject) 59 return; 60 61 Vector<ProtectedPtr<JSFunction> > functions; 62 Heap::iterator heapEnd = globalData->heap.primaryHeapEnd(); 63 for (Heap::iterator it = globalData->heap.primaryHeapBegin(); it != heapEnd; ++it) { 64 if ((*it)->isObject(&JSFunction::info)) { 65 JSFunction* function = asFunction(*it); 66 if (!function->body()->isHostFunction()) 67 functions.append(function); 68 } 69 } 70 71 typedef HashMap<RefPtr<FunctionBodyNode>, RefPtr<FunctionBodyNode> > FunctionBodyMap; 72 typedef HashMap<SourceProvider*, ExecState*> SourceProviderMap; 73 74 FunctionBodyMap functionBodies; 75 SourceProviderMap sourceProviders; 76 77 size_t size = functions.size(); 78 for (size_t i = 0; i < size; ++i) { 79 JSFunction* function = functions[i]; 80 81 FunctionBodyNode* oldBody = function->body(); 82 pair<FunctionBodyMap::iterator, bool> result = functionBodies.add(oldBody, 0); 83 if (!result.second) { 84 function->setBody(result.first->second); 85 continue; 86 } 87 88 ExecState* exec = function->scope().globalObject()->JSGlobalObject::globalExec(); 89 const SourceCode& sourceCode = oldBody->source(); 90 91 RefPtr<FunctionBodyNode> newBody = globalData->parser->parse<FunctionBodyNode>(exec, 0, sourceCode); 92 ASSERT(newBody); 93 newBody->finishParsing(oldBody->copyParameters(), oldBody->parameterCount(), oldBody->ident()); 94 95 result.first->second = newBody; 96 function->setBody(newBody.release()); 97 98 if (function->scope().globalObject()->debugger() == this) 99 sourceProviders.add(sourceCode.provider(), exec); 100 } 101 102 // Call sourceParsed() after reparsing all functions because it will execute 103 // JavaScript in the inspector. 104 SourceProviderMap::const_iterator end = sourceProviders.end(); 105 for (SourceProviderMap::const_iterator iter = sourceProviders.begin(); iter != end; ++iter) 106 sourceParsed(iter->second, SourceCode(iter->first), -1, 0); 107 } 108 56 109 JSValue evaluateInGlobalCallFrame(const UString& script, JSValue& exception, JSGlobalObject* globalObject) 57 110 {
Note:
See TracChangeset
for help on using the changeset viewer.