summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/webkit/JavaScriptCore/debugger
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/webkit/JavaScriptCore/debugger')
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/debugger/Debugger.cpp65
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/debugger/Debugger.h75
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerActivation.cpp19
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerActivation.h10
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerCallFrame.cpp16
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerCallFrame.h3
6 files changed, 90 insertions, 98 deletions
diff --git a/src/3rdparty/webkit/JavaScriptCore/debugger/Debugger.cpp b/src/3rdparty/webkit/JavaScriptCore/debugger/Debugger.cpp
index 7d791e7..61167d4 100644
--- a/src/3rdparty/webkit/JavaScriptCore/debugger/Debugger.cpp
+++ b/src/3rdparty/webkit/JavaScriptCore/debugger/Debugger.cpp
@@ -22,16 +22,16 @@
#include "config.h"
#include "Debugger.h"
-#include "JSGlobalObject.h"
+#include "CollectorHeapIterator.h"
+#include "Error.h"
#include "Interpreter.h"
+#include "JSFunction.h"
+#include "JSGlobalObject.h"
#include "Parser.h"
+#include "Protect.h"
namespace JSC {
-Debugger::Debugger()
-{
-}
-
Debugger::~Debugger()
{
HashSet<JSGlobalObject*>::iterator end = m_globalObjects.end();
@@ -53,18 +53,59 @@ void Debugger::detach(JSGlobalObject* globalObject)
globalObject->setDebugger(0);
}
+void Debugger::recompileAllJSFunctions(JSGlobalData* globalData)
+{
+ // If JavaScript is running, it's not safe to recompile, since we'll end
+ // up throwing away code that is live on the stack.
+ ASSERT(!globalData->dynamicGlobalObject);
+ if (globalData->dynamicGlobalObject)
+ return;
+
+ typedef HashSet<FunctionExecutable*> FunctionExecutableSet;
+ typedef HashMap<SourceProvider*, ExecState*> SourceProviderMap;
+
+ FunctionExecutableSet functionExecutables;
+ SourceProviderMap sourceProviders;
+
+ Heap::iterator heapEnd = globalData->heap.primaryHeapEnd();
+ for (Heap::iterator it = globalData->heap.primaryHeapBegin(); it != heapEnd; ++it) {
+ if (!(*it)->inherits(&JSFunction::info))
+ continue;
+
+ JSFunction* function = asFunction(*it);
+ if (function->executable()->isHostFunction())
+ continue;
+
+ FunctionExecutable* executable = function->jsExecutable();
+
+ // Check if the function is already in the set - if so,
+ // we've already retranslated it, nothing to do here.
+ if (!functionExecutables.add(executable).second)
+ continue;
+
+ ExecState* exec = function->scope().globalObject()->JSGlobalObject::globalExec();
+ executable->recompile(exec);
+ if (function->scope().globalObject()->debugger() == this)
+ sourceProviders.add(executable->source().provider(), exec);
+ }
+
+ // Call sourceParsed() after reparsing all functions because it will execute
+ // JavaScript in the inspector.
+ SourceProviderMap::const_iterator end = sourceProviders.end();
+ for (SourceProviderMap::const_iterator iter = sourceProviders.begin(); iter != end; ++iter)
+ sourceParsed(iter->second, SourceCode(iter->first), -1, 0);
+}
+
JSValue evaluateInGlobalCallFrame(const UString& script, JSValue& exception, JSGlobalObject* globalObject)
{
CallFrame* globalCallFrame = globalObject->globalExec();
- int errLine;
- UString errMsg;
- SourceCode source = makeSource(script);
- RefPtr<EvalNode> evalNode = globalObject->globalData()->parser->parse<EvalNode>(globalCallFrame, globalObject->debugger(), source, &errLine, &errMsg);
- if (!evalNode)
- return Error::create(globalCallFrame, SyntaxError, errMsg, errLine, source.provider()->asID(), source.provider()->url());
+ EvalExecutable eval(makeSource(script));
+ JSObject* error = eval.compile(globalCallFrame, globalCallFrame->scopeChain());
+ if (error)
+ return error;
- return globalObject->globalData()->interpreter->execute(evalNode.get(), globalCallFrame, globalObject, globalCallFrame->scopeChain(), &exception);
+ return globalObject->globalData()->interpreter->execute(&eval, globalCallFrame, globalObject, globalCallFrame->scopeChain(), &exception);
}
} // namespace JSC
diff --git a/src/3rdparty/webkit/JavaScriptCore/debugger/Debugger.h b/src/3rdparty/webkit/JavaScriptCore/debugger/Debugger.h
index 1ed39ec..3ee9767 100644
--- a/src/3rdparty/webkit/JavaScriptCore/debugger/Debugger.h
+++ b/src/3rdparty/webkit/JavaScriptCore/debugger/Debugger.h
@@ -1,7 +1,7 @@
/*
* Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
- * Copyright (C) 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -22,87 +22,42 @@
#ifndef Debugger_h
#define Debugger_h
-#include <debugger/DebuggerCallFrame.h>
-#include "Protect.h"
+#include <wtf/HashSet.h>
namespace JSC {
+ class DebuggerCallFrame;
class ExecState;
+ class JSGlobalData;
class JSGlobalObject;
+ class JSValue;
class SourceCode;
class UString;
class Debugger {
public:
- Debugger();
virtual ~Debugger();
void attach(JSGlobalObject*);
virtual void detach(JSGlobalObject*);
-#if PLATFORM(QT)
-#ifdef QT_BUILD_SCRIPT_LIB
- virtual void scriptUnload(qint64 id)
- {
- UNUSED_PARAM(id);
- };
- virtual void scriptLoad(qint64 id, const UString &program,
- const UString &fileName, int baseLineNumber)
- {
- UNUSED_PARAM(id);
- UNUSED_PARAM(program);
- UNUSED_PARAM(fileName);
- UNUSED_PARAM(baseLineNumber);
- };
- virtual void contextPush() {};
- virtual void contextPop() {};
+ virtual void sourceParsed(ExecState*, const SourceCode&, int errorLineNumber, const UString& errorMessage) = 0;
+ virtual void exception(const DebuggerCallFrame&, intptr_t sourceID, int lineNumber) = 0;
+ virtual void atStatement(const DebuggerCallFrame&, intptr_t sourceID, int lineNumber) = 0;
+ virtual void callEvent(const DebuggerCallFrame&, intptr_t sourceID, int lineNumber) = 0;
+ virtual void returnEvent(const DebuggerCallFrame&, intptr_t sourceID, int lineNumber) = 0;
- virtual void evaluateStart(intptr_t sourceID)
- {
- UNUSED_PARAM(sourceID);
- }
- virtual void evaluateStop(const JSC::JSValue& returnValue, intptr_t sourceID)
- {
- UNUSED_PARAM(sourceID);
- UNUSED_PARAM(returnValue);
- }
+ virtual void willExecuteProgram(const DebuggerCallFrame&, intptr_t sourceID, int lineNumber) = 0;
+ virtual void didExecuteProgram(const DebuggerCallFrame&, intptr_t sourceID, int lineNumber) = 0;
+ virtual void didReachBreakpoint(const DebuggerCallFrame&, intptr_t sourceID, int lineNumber) = 0;
- virtual void exceptionThrow(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, bool hasHandler)
- {
- UNUSED_PARAM(frame);
- UNUSED_PARAM(sourceID);
- UNUSED_PARAM(hasHandler);
- };
- virtual void exceptionCatch(const JSC::DebuggerCallFrame& frame, intptr_t sourceID)
- {
- UNUSED_PARAM(frame);
- UNUSED_PARAM(sourceID);
- };
-
- virtual void functionExit(const JSC::JSValue& returnValue, intptr_t sourceID)
- {
- UNUSED_PARAM(returnValue);
- UNUSED_PARAM(sourceID);
- };
-#endif
-#endif
-
- virtual void sourceParsed(ExecState*, const SourceCode&, int errorLine, const UString& errorMsg) = 0;
- virtual void exception(const DebuggerCallFrame&, intptr_t sourceID, int lineno) = 0;
- virtual void atStatement(const DebuggerCallFrame&, intptr_t sourceID, int lineno, int column) = 0;
- virtual void callEvent(const DebuggerCallFrame&, intptr_t sourceID, int lineno) = 0;
- virtual void returnEvent(const DebuggerCallFrame&, intptr_t sourceID, int lineno) = 0;
-
- virtual void willExecuteProgram(const DebuggerCallFrame&, intptr_t sourceID, int lineno) = 0;
- virtual void didExecuteProgram(const DebuggerCallFrame&, intptr_t sourceID, int lineno) = 0;
- virtual void didReachBreakpoint(const DebuggerCallFrame&, intptr_t sourceID, int lineno, int column) = 0;
+ void recompileAllJSFunctions(JSGlobalData*);
private:
HashSet<JSGlobalObject*> m_globalObjects;
};
- // This method exists only for backwards compatibility with existing
- // WebScriptDebugger clients
+ // This function exists only for backwards compatibility with existing WebScriptDebugger clients.
JSValue evaluateInGlobalCallFrame(const UString&, JSValue& exception, JSGlobalObject*);
} // namespace JSC
diff --git a/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerActivation.cpp b/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerActivation.cpp
index c1815c8..7a68d7d 100644
--- a/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerActivation.cpp
+++ b/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerActivation.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -38,11 +38,12 @@ DebuggerActivation::DebuggerActivation(JSObject* activation)
m_activation = static_cast<JSActivation*>(activation);
}
-void DebuggerActivation::mark()
+void DebuggerActivation::markChildren(MarkStack& markStack)
{
- JSObject::mark();
- if (m_activation && !m_activation->marked())
- m_activation->mark();
+ JSObject::markChildren(markStack);
+
+ if (m_activation)
+ markStack.append(m_activation);
}
UString DebuggerActivation::className() const
@@ -65,14 +66,14 @@ void DebuggerActivation::putWithAttributes(ExecState* exec, const Identifier& pr
m_activation->putWithAttributes(exec, propertyName, value, attributes);
}
-bool DebuggerActivation::deleteProperty(ExecState* exec, const Identifier& propertyName, bool checkDontDelete)
+bool DebuggerActivation::deleteProperty(ExecState* exec, const Identifier& propertyName)
{
- return m_activation->deleteProperty(exec, propertyName, checkDontDelete);
+ return m_activation->deleteProperty(exec, propertyName);
}
-void DebuggerActivation::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, unsigned listedAttributes)
+void DebuggerActivation::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
{
- m_activation->getPropertyNames(exec, propertyNames, listedAttributes);
+ m_activation->getPropertyNames(exec, propertyNames);
}
bool DebuggerActivation::getPropertyAttributes(JSC::ExecState* exec, const Identifier& propertyName, unsigned& attributes) const
diff --git a/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerActivation.h b/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerActivation.h
index 7c9f7d1..06aea5a 100644
--- a/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerActivation.h
+++ b/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerActivation.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -36,13 +36,13 @@ namespace JSC {
public:
DebuggerActivation(JSObject*);
- virtual void mark();
+ virtual void markChildren(MarkStack&);
virtual UString className() const;
virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
virtual void put(ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
virtual void putWithAttributes(ExecState*, const Identifier& propertyName, JSValue, unsigned attributes);
- virtual bool deleteProperty(ExecState*, const Identifier& propertyName, bool checkDontDelete = true);
- virtual void getPropertyNames(ExecState*, PropertyNameArray&, unsigned listedAttributes = Structure::Prototype);
+ virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
+ virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&);
virtual bool getPropertyAttributes(ExecState*, const Identifier& propertyName, unsigned& attributes) const;
virtual void defineGetter(ExecState*, const Identifier& propertyName, JSObject* getterFunction);
virtual void defineSetter(ExecState*, const Identifier& propertyName, JSObject* setterFunction);
@@ -51,7 +51,7 @@ namespace JSC {
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
- return Structure::create(prototype, TypeInfo(ObjectType));
+ return Structure::create(prototype, TypeInfo(ObjectType, HasDefaultGetPropertyNames));
}
private:
diff --git a/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerCallFrame.cpp b/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerCallFrame.cpp
index cd8702b..9c8ca2a 100644
--- a/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerCallFrame.cpp
+++ b/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerCallFrame.cpp
@@ -41,7 +41,7 @@ const UString* DebuggerCallFrame::functionName() const
if (!m_callFrame->codeBlock())
return 0;
- JSFunction* function = static_cast<JSFunction*>(m_callFrame->callee());
+ JSFunction* function = asFunction(m_callFrame->callee());
if (!function)
return 0;
return &function->name(&m_callFrame->globalData());
@@ -52,7 +52,7 @@ UString DebuggerCallFrame::calculatedFunctionName() const
if (!m_callFrame->codeBlock())
return 0;
- JSFunction* function = static_cast<JSFunction*>(m_callFrame->callee());
+ JSFunction* function = asFunction(m_callFrame->callee());
if (!function)
return 0;
return function->calculatedDisplayName(&m_callFrame->globalData());
@@ -79,14 +79,12 @@ JSValue DebuggerCallFrame::evaluate(const UString& script, JSValue& exception) c
if (!m_callFrame->codeBlock())
return JSValue();
- int errLine;
- UString errMsg;
- SourceCode source = makeSource(script);
- RefPtr<EvalNode> evalNode = m_callFrame->scopeChain()->globalData->parser->parse<EvalNode>(m_callFrame, m_callFrame->dynamicGlobalObject()->debugger(), source, &errLine, &errMsg);
- if (!evalNode)
- return Error::create(m_callFrame, SyntaxError, errMsg, errLine, source.provider()->asID(), source.provider()->url());
+ EvalExecutable eval(makeSource(script));
+ JSObject* error = eval.compile(m_callFrame, m_callFrame->scopeChain());
+ if (error)
+ return error;
- return m_callFrame->scopeChain()->globalData->interpreter->execute(evalNode.get(), m_callFrame, thisObject(), m_callFrame->scopeChain(), &exception);
+ return m_callFrame->scopeChain()->globalData->interpreter->execute(&eval, m_callFrame, thisObject(), m_callFrame->scopeChain(), &exception);
}
} // namespace JSC
diff --git a/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerCallFrame.h b/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerCallFrame.h
index 5984fab..9d377ef 100644
--- a/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerCallFrame.h
+++ b/src/3rdparty/webkit/JavaScriptCore/debugger/DebuggerCallFrame.h
@@ -56,9 +56,6 @@ namespace JSC {
JSObject* thisObject() const;
JSValue evaluate(const UString&, JSValue& exception) const;
JSValue exception() const { return m_exception; }
-#if QT_BUILD_SCRIPT_LIB
- CallFrame* callFrame() const { return m_callFrame; }
-#endif
private:
CallFrame* m_callFrame;