Changeset 43642 in webkit for trunk/JavaScriptCore/debugger/Debugger.cpp
- Timestamp:
- May 13, 2009, 11:14:48 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/debugger/Debugger.cpp
r43122 r43642 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 … … 54 55 } 55 56 57 void Debugger::recompileAllJSFunctions(JSGlobalData* globalData, bool callSourceParsed) 58 { 59 // If JavaScript is running, it's not safe to recompile, since we'll end 60 // up throwing away code that is live on the stack. 61 ASSERT(!globalData->dynamicGlobalObject); 62 if (globalData->dynamicGlobalObject) 63 return; 64 65 Vector<ProtectedPtr<JSFunction> > functions; 66 Heap::iterator heapEnd = globalData->heap.primaryHeapEnd(); 67 for (Heap::iterator it = globalData->heap.primaryHeapBegin(); it != heapEnd; ++it) { 68 if ((*it)->isObject(&JSFunction::info)) { 69 JSFunction* function = static_cast<JSFunction*>(*it); 70 FunctionBodyNode* body = function->body(); 71 if (body && !body->isHostFunction()) 72 functions.append(function); 73 } 74 } 75 76 typedef HashMap<RefPtr<FunctionBodyNode>, RefPtr<FunctionBodyNode> > FunctionBodyMap; 77 typedef HashMap<SourceProvider*, ExecState*> SourceProviderMap; 78 79 FunctionBodyMap functionBodies; 80 SourceProviderMap sourceProviders; 81 82 size_t size = functions.size(); 83 for (size_t i = 0; i < size; ++i) { 84 JSFunction* function = functions[i]; 85 86 FunctionBodyNode* oldBody = function->body(); 87 pair<FunctionBodyMap::iterator, bool> result = functionBodies.add(oldBody, 0); 88 if (!result.second) { 89 function->setBody(result.first->second.get()); 90 continue; 91 } 92 93 ExecState* exec = function->scope().globalObject()->JSGlobalObject::globalExec(); 94 const SourceCode& sourceCode = oldBody->source(); 95 96 RefPtr<FunctionBodyNode> newBody = globalData->parser->parse<FunctionBodyNode>(exec, 0, sourceCode); 97 ASSERT(newBody); 98 newBody->finishParsing(oldBody->copyParameters(), oldBody->parameterCount()); 99 100 result.first->second = newBody; 101 function->setBody(newBody.release()); 102 103 if (callSourceParsed && function->scope().globalObject()->debugger() == this) 104 sourceProviders.add(sourceCode.provider(), exec); 105 } 106 107 // Call sourceParsed() after reparsing all functions because it will execute 108 // JavaScript in the inspector. 109 SourceProviderMap::const_iterator end = sourceProviders.end(); 110 for (SourceProviderMap::const_iterator iter = sourceProviders.begin(); iter != end; ++iter) 111 sourceParsed((*iter).second, SourceCode((*iter).first), -1, 0); 112 } 113 56 114 JSValue evaluateInGlobalCallFrame(const UString& script, JSValue& exception, JSGlobalObject* globalObject) 57 115 {
Note:
See TracChangeset
for help on using the changeset viewer.