Commit f41a7da7 authored by weinig@apple.com's avatar weinig@apple.com

Remove the Completion object from JSC, I have never liked it

https://bugs.webkit.org/show_bug.cgi?id=67755

Reviewed by Gavin Barraclough.

../JavaScriptCore: 

- Removes the Completion object and replaces its use with out parameter exceptions.
- Remove ComplType and virtual exceptionType() function on JSObject. Replace with
  ClassInfo for InterruptedExecutionError and TerminatedExecutionError.

* API/JSBase.cpp:
(JSEvaluateScript):
(JSCheckScriptSyntax):
* JavaScriptCore.exp:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
* interpreter/Interpreter.cpp:
(JSC::Interpreter::throwException):
* jsc.cpp:
(functionLoad):
(functionCheckSyntax):
(runWithScripts):
(runInteractive):
* runtime/Completion.cpp:
(JSC::checkSyntax):
(JSC::evaluate):
* runtime/Completion.h:
* runtime/ExceptionHelpers.cpp:
(JSC::InterruptedExecutionError::toString):
(JSC::TerminatedExecutionError::toString):
(JSC::createInterruptedExecutionException):
* runtime/ExceptionHelpers.h:
(JSC::InterruptedExecutionError::InterruptedExecutionError):
(JSC::InterruptedExecutionError::create):
(JSC::InterruptedExecutionError::createStructure):
(JSC::TerminatedExecutionError::TerminatedExecutionError):
(JSC::TerminatedExecutionError::create):
(JSC::TerminatedExecutionError::createStructure):
* runtime/JSGlobalData.cpp:
(JSC::JSGlobalData::JSGlobalData):
* runtime/JSObject.h:

../JavaScriptGlue: 

* JSRun.cpp:
(JSRun::Evaluate):
(JSRun::CheckSyntax):
* JSRun.h:
* JavaScriptGlue.cpp:
(JSRunEvaluate):

../WebCore: 

* bindings/js/JSDOMBinding.cpp:
(WebCore::reportException):
* bindings/js/JSEventListener.cpp:
(WebCore::JSEventListener::handleEvent):
* bindings/js/JSInjectedScriptManager.cpp:
(WebCore::InjectedScriptManager::createInjectedScript):
* bindings/js/JSMainThreadExecState.h:
(WebCore::JSMainThreadExecState::evaluate):
* bindings/js/ScriptController.cpp:
(WebCore::ScriptController::evaluateInWorld):
* bindings/js/WorkerScriptController.cpp:
(WebCore::WorkerScriptController::evaluate):
* bindings/objc/WebScriptObject.mm:
(-[WebScriptObject evaluateWebScript:]):
* bridge/NP_jsobject.cpp:
(_NPN_Evaluate):
* bridge/jni/jni_jsobject.mm:
(JavaJSObject::eval):

../WebKit/mac: 

* Plugins/Hosted/NetscapePluginInstanceProxy.mm:
(WebKit::NetscapePluginInstanceProxy::evaluate):

../WebKit/qt: 

* Api/qwebelement.cpp:
(QWebElement::evaluateJavaScript):

../WebKit2: 

* WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:
(WebKit::NPRuntimeObjectMap::evaluate):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@94811 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d5b296c6
......@@ -29,7 +29,6 @@
#include "APICast.h"
#include "APIShims.h"
#include "Completion.h"
#include "OpaqueJSString.h"
#include "SourceCode.h"
#include <interpreter/CallFrame.h>
......@@ -52,17 +51,19 @@ JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef th
// evaluate sets "this" to the global object if it is NULL
JSGlobalObject* globalObject = exec->dynamicGlobalObject();
SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), startingLineNumber);
Completion completion = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), source, jsThisObject);
if (completion.complType() == Throw) {
JSValue evaluationException;
JSValue returnValue = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), source, jsThisObject, &evaluationException);
if (evaluationException) {
if (exception)
*exception = toRef(exec, completion.value());
*exception = toRef(exec, evaluationException);
return 0;
}
if (completion.value())
return toRef(exec, completion.value());
if (returnValue)
return toRef(exec, returnValue);
// happens, for example, when the only statement is an empty (';') statement
return toRef(exec, jsUndefined());
}
......@@ -73,13 +74,16 @@ bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourc
APIEntryShim entryShim(exec);
SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), startingLineNumber);
Completion completion = checkSyntax(exec->dynamicGlobalObject()->globalExec(), source);
if (completion.complType() == Throw) {
JSValue syntaxException;
bool isValidSyntax = checkSyntax(exec->dynamicGlobalObject()->globalExec(), source, &syntaxException);
if (!isValidSyntax) {
if (exception)
*exception = toRef(exec, completion.value());
*exception = toRef(exec, syntaxException);
return false;
}
return true;
}
......
2011-09-08 Sam Weinig <sam@webkit.org>
Remove the Completion object from JSC, I have never liked it
https://bugs.webkit.org/show_bug.cgi?id=67755
Reviewed by Gavin Barraclough.
- Removes the Completion object and replaces its use with out parameter exceptions.
- Remove ComplType and virtual exceptionType() function on JSObject. Replace with
ClassInfo for InterruptedExecutionError and TerminatedExecutionError.
* API/JSBase.cpp:
(JSEvaluateScript):
(JSCheckScriptSyntax):
* JavaScriptCore.exp:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
* interpreter/Interpreter.cpp:
(JSC::Interpreter::throwException):
* jsc.cpp:
(functionLoad):
(functionCheckSyntax):
(runWithScripts):
(runInteractive):
* runtime/Completion.cpp:
(JSC::checkSyntax):
(JSC::evaluate):
* runtime/Completion.h:
* runtime/ExceptionHelpers.cpp:
(JSC::InterruptedExecutionError::toString):
(JSC::TerminatedExecutionError::toString):
(JSC::createInterruptedExecutionException):
* runtime/ExceptionHelpers.h:
(JSC::InterruptedExecutionError::InterruptedExecutionError):
(JSC::InterruptedExecutionError::create):
(JSC::InterruptedExecutionError::createStructure):
(JSC::TerminatedExecutionError::TerminatedExecutionError):
(JSC::TerminatedExecutionError::create):
(JSC::TerminatedExecutionError::createStructure):
* runtime/JSGlobalData.cpp:
(JSC::JSGlobalData::JSGlobalData):
* runtime/JSObject.h:
2011-09-08 Ryosuke Niwa <rniwa@webkit.org>
Build fix.
......
......@@ -119,7 +119,7 @@ __ZN3JSC11JSByteArray13s_defaultInfoE
__ZN3JSC11JSByteArray15createStructureERNS_12JSGlobalDataEPNS_14JSGlobalObjectENS_7JSValueEPKNS_9ClassInfoE
__ZN3JSC11JSByteArrayC1EPNS_9ExecStateEPNS_9StructureEPN3WTF9ByteArrayE
__ZN3JSC11ParserArena5resetEv
__ZN3JSC11checkSyntaxEPNS_9ExecStateERKNS_10SourceCodeE
__ZN3JSC11checkSyntaxEPNS_9ExecStateERKNS_10SourceCodeEPNS_7JSValueE
__ZN3JSC11createErrorEPNS_9ExecStateERKNS_7UStringE
__ZN3JSC11regExpFlagsERKNS_7UStringE
__ZN3JSC12DateInstance6s_infoE
......@@ -135,6 +135,7 @@ __ZN3JSC12JSGlobalData14resetDateCacheEv
__ZN3JSC12JSGlobalData14sharedInstanceEv
__ZN3JSC12JSGlobalData15dumpRegExpTraceEv
__ZN3JSC12JSGlobalData22clearBuiltinStructuresEv
__ZN3JSC12JSGlobalData23releaseExecutableMemoryEv
__ZN3JSC12JSGlobalData6createENS_15ThreadStackTypeENS_8HeapSizeE
__ZN3JSC12JSGlobalDataD1Ev
__ZN3JSC12RegExpObject6s_infoE
......@@ -217,6 +218,7 @@ __ZN3JSC23AbstractSamplingCounter4dumpEv
__ZN3JSC23objectProtoFuncToStringEPNS_9ExecStateE
__ZN3JSC23setUpStaticFunctionSlotEPNS_9ExecStateEPKNS_9HashEntryEPNS_8JSObjectERKNS_10IdentifierERNS_12PropertySlotE
__ZN3JSC24DynamicGlobalObjectScopeC1ERNS_12JSGlobalDataEPNS_14JSGlobalObjectE
__ZN3JSC24TerminatedExecutionError6s_infoE
__ZN3JSC24createStackOverflowErrorEPNS_9ExecStateE
__ZN3JSC25evaluateInGlobalCallFrameERKNS_7UStringERNS_7JSValueEPNS_14JSGlobalObjectE
__ZN3JSC35createInterruptedExecutionExceptionEPNS_12JSGlobalDataE
......@@ -326,7 +328,7 @@ __ZN3JSC8JSObject6s_infoE
__ZN3JSC8Profiler13stopProfilingEPNS_9ExecStateERKNS_7UStringE
__ZN3JSC8Profiler14startProfilingEPNS_9ExecStateERKNS_7UStringE
__ZN3JSC8Profiler8profilerEv
__ZN3JSC8evaluateEPNS_9ExecStateEPNS_14ScopeChainNodeERKNS_10SourceCodeENS_7JSValueE
__ZN3JSC8evaluateEPNS_9ExecStateEPNS_14ScopeChainNodeERKNS_10SourceCodeENS_7JSValueEPS7_
__ZN3JSC8isZombieEPKNS_6JSCellE
__ZN3JSC9CodeBlockD1Ev
__ZN3JSC9CodeBlockD2Ev
......@@ -617,7 +619,3 @@ __ZTVN3JSC8JSObjectE
__ZTVN3JSC8JSStringE
_jscore_fastmalloc_introspection
_kJSClassDefinitionEmpty
#ifndef NDEBUG
__ZN3JSC12JSGlobalData23releaseExecutableMemoryEv
#endif
......@@ -39,6 +39,8 @@ EXPORTS
??1WeakHandleOwner@JSC@@UAE@XZ
??8JSC@@YA_NABVUString@0@0@Z
??8WTF@@YA_NABVCString@0@0@Z
?checkSyntax@JSC@@YA_NPAVExecState@1@ABVSourceCode@1@PAVJSValue@1@@Z
?evaluate@JSC@@YA?AVJSValue@1@PAVExecState@1@PAVScopeChainNode@1@ABVSourceCode@1@V21@PAV21@@Z
?EcmaScriptConverter@DoubleToStringConverter@double_conversion@WTF@@SAABV123@XZ
?ToExponential@DoubleToStringConverter@double_conversion@WTF@@QBE_NNHPAVStringBuilder@23@@Z
?ToFixed@DoubleToStringConverter@double_conversion@WTF@@QBE_NNHPAVStringBuilder@23@@Z
......@@ -80,7 +82,6 @@ EXPORTS
?changePrototypeTransition@Structure@JSC@@SAPAV12@AAVJSGlobalData@2@PAV12@VJSValue@2@@Z
?checkCurrentIdentifierTable@Identifier@JSC@@CAXPAVExecState@2@@Z
?checkCurrentIdentifierTable@Identifier@JSC@@CAXPAVJSGlobalData@2@@Z
?checkSyntax@JSC@@YA?AVCompletion@1@PAVExecState@1@ABVSourceCode@1@@Z
?checksum@MD5@WTF@@QAEXAAV?$Vector@E$0BA@@2@@Z
?className@JSObject@JSC@@UBE?AVUString@2@XZ
?clear@SourceProviderCache@JSC@@QAEXXZ
......@@ -160,7 +161,6 @@ EXPORTS
?equal@Identifier@JSC@@SA_NPBVStringImpl@WTF@@PBD@Z
?equalUTF16WithUTF8@Unicode@WTF@@YA_NPB_W0PBD1@Z
?evaluate@DebuggerCallFrame@JSC@@QBE?AVJSValue@2@ABVUString@2@AAV32@@Z
?evaluate@JSC@@YA?AVCompletion@1@PAVExecState@1@PAVScopeChainNode@1@ABVSourceCode@1@VJSValue@1@@Z
?exclude@Profile@JSC@@QAEXPBVProfileNode@2@@Z
?fastCalloc@WTF@@YAPAXII@Z
?fastFree@WTF@@YAXPAX@Z
......
......@@ -708,8 +708,7 @@ NEVER_INLINE HandlerInfo* Interpreter::throwException(CallFrame*& callFrame, JSV
addErrorInfo(callFrame, exception, codeBlock->lineNumberForBytecodeOffset(bytecodeOffset), codeBlock->ownerExecutable()->source());
}
ComplType exceptionType = exception->exceptionType();
isInterrupt = exceptionType == Interrupted || exceptionType == Terminated;
isInterrupt = (exception->inherits(&InterruptedExecutionError::s_info) || exception->inherits(&TerminatedExecutionError::s_info));
}
if (Debugger* debugger = callFrame->dynamicGlobalObject()->debugger()) {
......
......@@ -261,10 +261,12 @@ EncodedJSValue JSC_HOST_CALL functionLoad(ExecState* exec)
return JSValue::encode(throwError(exec, createError(exec, "Could not open file.")));
JSGlobalObject* globalObject = exec->lexicalGlobalObject();
Completion result = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(script.data(), fileName));
if (result.complType() == Throw)
throwError(exec, result.value());
return JSValue::encode(result.value());
JSValue evaluationException;
JSValue result = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(script.data(), fileName), JSValue(), &evaluationException);
if (evaluationException)
throwError(exec, evaluationException);
return JSValue::encode(result);
}
EncodedJSValue JSC_HOST_CALL functionCheckSyntax(ExecState* exec)
......@@ -278,11 +280,13 @@ EncodedJSValue JSC_HOST_CALL functionCheckSyntax(ExecState* exec)
StopWatch stopWatch;
stopWatch.start();
Completion result = checkSyntax(globalObject->globalExec(), makeSource(script.data(), fileName));
JSValue syntaxException;
bool validSyntax = checkSyntax(globalObject->globalExec(), makeSource(script.data(), fileName), &syntaxException);
stopWatch.stop();
if (result.complType() == Throw)
throwError(exec, result.value());
if (!validSyntax)
throwError(exec, syntaxException);
return JSValue::encode(jsNumber(stopWatch.getElapsedMS()));
}
......@@ -436,13 +440,14 @@ static bool runWithScripts(GlobalObject* globalObject, const Vector<Script>& scr
globalData.startSampling();
Completion completion = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(script, fileName));
success = success && completion.complType() != Throw;
JSValue evaluationException;
JSValue returnValue = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(script, fileName), JSValue(), &evaluationException);
success = success && !evaluationException;
if (dump) {
if (completion.complType() == Throw)
printf("Exception: %s\n", completion.value().toString(globalObject->globalExec()).utf8().data());
if (evaluationException)
printf("Exception: %s\n", evaluationException.toString(globalObject->globalExec()).utf8().data());
else
printf("End: %s\n", completion.value().toString(globalObject->globalExec()).utf8().data());
printf("End: %s\n", returnValue.toString(globalObject->globalExec()).utf8().data());
}
globalData.stopSampling();
......@@ -473,7 +478,8 @@ static void runInteractive(GlobalObject* globalObject)
break;
if (line[0])
add_history(line);
Completion completion = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(line, interpreterName));
JSValue evaluationException;
JSValue returnValue = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(line, interpreterName), JSValue(), &evaluationException);
free(line);
#else
printf("%s", interactivePrompt);
......@@ -488,12 +494,14 @@ static void runInteractive(GlobalObject* globalObject)
if (line.isEmpty())
break;
line.append('\0');
Completion completion = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(line.data(), interpreterName));
JSValue evaluationException;
JSValue returnValue = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(line.data(), interpreterName), JSValue(), &evaluationException);
#endif
if (completion.complType() == Throw)
printf("Exception: %s\n", completion.value().toString(globalObject->globalExec()).utf8().data());
if (evaluationException)
printf("Exception: %s\n", evaluationException.toString(globalObject->globalExec()).utf8().data());
else
printf("%s\n", completion.value().toString(globalObject->globalExec()).utf8().data());
printf("%s\n", returnValue.toString(globalObject->globalExec()).utf8().data());
globalObject->globalExec()->clearException();
}
......
......@@ -34,47 +34,51 @@
namespace JSC {
Completion checkSyntax(ExecState* exec, const SourceCode& source)
bool checkSyntax(ExecState* exec, const SourceCode& source, JSValue* returnedException)
{
JSLock lock(exec);
ASSERT(exec->globalData().identifierTable == wtfThreadData().currentIdentifierTable());
ProgramExecutable* program = ProgramExecutable::create(exec, source);
JSObject* error = program->checkSyntax(exec);
if (error)
return Completion(Throw, error);
if (error) {
if (returnedException)
*returnedException = error;
return false;
}
return Completion(Normal);
return true;
}
Completion evaluate(ExecState* exec, ScopeChainNode* scopeChain, const SourceCode& source, JSValue thisValue)
JSValue evaluate(ExecState* exec, ScopeChainNode* scopeChain, const SourceCode& source, JSValue thisValue, JSValue* returnedException)
{
JSLock lock(exec);
ASSERT(exec->globalData().identifierTable == wtfThreadData().currentIdentifierTable());
ProgramExecutable* program = ProgramExecutable::create(exec, source);
if (!program) {
JSValue exception = exec->globalData().exception;
if (returnedException)
*returnedException = exec->globalData().exception;
exec->globalData().exception = JSValue();
return Completion(Throw, exception);
return jsUndefined();
}
if (!thisValue || thisValue.isUndefinedOrNull())
thisValue = exec->dynamicGlobalObject();
JSObject* thisObj = thisValue.toThisObject(exec);
JSValue result = exec->interpreter()->execute(program, exec, scopeChain, thisObj);
if (exec->hadException()) {
JSValue exception = exec->exception();
exec->clearException();
if (returnedException)
*returnedException = exec->exception();
ComplType exceptionType = Throw;
if (exception.isObject())
exceptionType = asObject(exception)->exceptionType();
return Completion(exceptionType, exception);
exec->clearException();
return jsUndefined();
}
return Completion(Normal, result);
ASSERT(result);
return result;
}
} // namespace JSC
......@@ -31,32 +31,8 @@ namespace JSC {
class ScopeChainNode;
class SourceCode;
enum ComplType { Normal, Break, Continue, ReturnValue, Throw, Interrupted, Terminated };
/*
* Completion objects are used to convey the return status and value
* from functions.
*/
class Completion {
public:
Completion(ComplType type = Normal, JSValue value = JSValue())
: m_type(type)
, m_value(value)
{
}
ComplType complType() const { return m_type; }
JSValue value() const { return m_value; }
void setValue(JSValue v) { m_value = v; }
bool isValueCompletion() const { return m_value; }
private:
ComplType m_type;
JSValue m_value;
};
Completion checkSyntax(ExecState*, const SourceCode&);
Completion evaluate(ExecState*, ScopeChainNode*, const SourceCode&, JSValue thisValue = JSValue());
bool checkSyntax(ExecState*, const SourceCode&, JSValue* exception = 0);
JSValue evaluate(ExecState*, ScopeChainNode*, const SourceCode&, JSValue thisValue = JSValue(), JSValue* exception = 0);
} // namespace JSC
......
......@@ -41,55 +41,26 @@
namespace JSC {
class InterruptedExecutionError : public JSNonFinalObject {
private:
InterruptedExecutionError(JSGlobalData& globalData)
: JSNonFinalObject(globalData, globalData.interruptedExecutionErrorStructure.get())
{
}
const ClassInfo InterruptedExecutionError::s_info = { "InterruptedExecutionError", 0, 0, 0 };
public:
typedef JSNonFinalObject Base;
UString InterruptedExecutionError::toString(ExecState*) const
{
return "JavaScript execution exceeded timeout.";
}
static InterruptedExecutionError* create(JSGlobalData& globalData)
{
InterruptedExecutionError* error = new (allocateCell<InterruptedExecutionError>(globalData.heap)) InterruptedExecutionError(globalData);
error->finishCreation(globalData);
return error;
}
const ClassInfo TerminatedExecutionError::s_info = { "TerminatedExecutionError", 0, 0, 0 };
virtual ComplType exceptionType() const { return Interrupted; }
UString TerminatedExecutionError::toString(ExecState*) const
{
return "JavaScript execution terminated.";
}
virtual UString toString(ExecState*) const { return "JavaScript execution exceeded timeout."; }
};
JSObject* createInterruptedExecutionException(JSGlobalData* globalData)
{
return InterruptedExecutionError::create(*globalData);
}
class TerminatedExecutionError : public JSNonFinalObject {
private:
TerminatedExecutionError(JSGlobalData& globalData)
: JSNonFinalObject(globalData, globalData.terminatedExecutionErrorStructure.get())
{
}
public:
typedef JSNonFinalObject Base;
static TerminatedExecutionError* create(JSGlobalData& globalData)
{
TerminatedExecutionError* error = new (allocateCell<TerminatedExecutionError>(globalData.heap)) TerminatedExecutionError(globalData);
error->finishCreation(globalData);
return error;
}
virtual ComplType exceptionType() const { return Terminated; }
virtual UString toString(ExecState*) const { return "JavaScript execution terminated."; }
};
JSObject* createTerminatedExecutionException(JSGlobalData* globalData)
{
return TerminatedExecutionError::create(*globalData);
......
......@@ -29,34 +29,79 @@
#ifndef ExceptionHelpers_h
#define ExceptionHelpers_h
#include "JSValue.h"
#include "JSObject.h"
namespace JSC {
class CodeBlock;
class ExecState;
class Identifier;
class JSGlobalData;
class JSGlobalObject;
class JSNotAnObjectErrorStub;
class JSObject;
class Node;
struct Instruction;
JSObject* createInterruptedExecutionException(JSGlobalData*);
JSObject* createTerminatedExecutionException(JSGlobalData*);
JSObject* createStackOverflowError(ExecState*);
JSObject* createStackOverflowError(JSGlobalObject*);
JSObject* createOutOfMemoryError(JSGlobalObject*);
JSObject* createUndefinedVariableError(ExecState*, const Identifier&);
JSObject* createNotAnObjectError(ExecState*, JSValue);
JSObject* createInvalidParamError(ExecState*, const char* op, JSValue);
JSObject* createNotAConstructorError(ExecState*, JSValue);
JSObject* createNotAFunctionError(ExecState*, JSValue);
JSObject* createErrorForInvalidGlobalAssignment(ExecState*, const UString&);
JSObject* throwOutOfMemoryError(ExecState*);
JSObject* throwStackOverflowError(ExecState*);
JSObject* createInterruptedExecutionException(JSGlobalData*);
JSObject* createTerminatedExecutionException(JSGlobalData*);
JSObject* createStackOverflowError(ExecState*);
JSObject* createStackOverflowError(JSGlobalObject*);
JSObject* createOutOfMemoryError(JSGlobalObject*);
JSObject* createUndefinedVariableError(ExecState*, const Identifier&);
JSObject* createNotAnObjectError(ExecState*, JSValue);
JSObject* createInvalidParamError(ExecState*, const char* op, JSValue);
JSObject* createNotAConstructorError(ExecState*, JSValue);
JSObject* createNotAFunctionError(ExecState*, JSValue);
JSObject* createErrorForInvalidGlobalAssignment(ExecState*, const UString&);
JSObject* throwOutOfMemoryError(ExecState*);
JSObject* throwStackOverflowError(ExecState*);
class InterruptedExecutionError : public JSNonFinalObject {
private:
InterruptedExecutionError(JSGlobalData& globalData)
: JSNonFinalObject(globalData, globalData.interruptedExecutionErrorStructure.get())
{
}
virtual UString toString(ExecState*) const;
public:
typedef JSNonFinalObject Base;
static InterruptedExecutionError* create(JSGlobalData& globalData)
{
InterruptedExecutionError* error = new (allocateCell<InterruptedExecutionError>(globalData.heap)) InterruptedExecutionError(globalData);
error->finishCreation(globalData);
return error;
}
static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype)
{
return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
}
static JS_EXPORTDATA const ClassInfo s_info;
};
class TerminatedExecutionError : public JSNonFinalObject {
private:
TerminatedExecutionError(JSGlobalData& globalData)
: JSNonFinalObject(globalData, globalData.terminatedExecutionErrorStructure.get())
{
}
virtual UString toString(ExecState*) const;
public:
typedef JSNonFinalObject Base;
static TerminatedExecutionError* create(JSGlobalData& globalData)
{
TerminatedExecutionError* error = new (allocateCell<TerminatedExecutionError>(globalData.heap)) TerminatedExecutionError(globalData);
error->finishCreation(globalData);
return error;
}
static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype)
{
return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
}
static JS_EXPORTDATA const ClassInfo s_info;
};
} // namespace JSC
......
......@@ -216,8 +216,8 @@ JSGlobalData::JSGlobalData(GlobalDataType globalDataType, ThreadStackType thread
structureStructure.set(*this, Structure::createStructure(*this));
debuggerActivationStructure.set(*this, DebuggerActivation::createStructure(*this, 0, jsNull()));
activationStructure.set(*this, JSActivation::createStructure(*this, 0, jsNull()));
interruptedExecutionErrorStructure.set(*this, JSNonFinalObject::createStructure(*this, 0, jsNull()));
terminatedExecutionErrorStructure.set(*this, JSNonFinalObject::createStructure(*this, 0, jsNull()));
interruptedExecutionErrorStructure.set(*this, InterruptedExecutionError::createStructure(*this, 0, jsNull()));
terminatedExecutionErrorStructure.set(*this, TerminatedExecutionError::createStructure(*this, 0, jsNull()));
staticScopeStructure.set(*this, JSStaticScopeObject::createStructure(*this, 0, jsNull()));
strictEvalActivationStructure.set(*this, StrictEvalActivation::createStructure(*this, 0, jsNull()));
stringStructure.set(*this, JSString::createStructure(*this, 0, jsNull()));
......
......@@ -26,7 +26,6 @@
#include "ArgList.h"
#include "ClassInfo.h"
#include "CommonIdentifiers.h"
#include "Completion.h"
#include "CallFrame.h"
#include "JSCell.h"
#include "PropertySlot.h"
......@@ -219,8 +218,6 @@ namespace JSC {
bool isFrozen(JSGlobalData& globalData) { return m_structure->isFrozen(globalData); }
bool isExtensible() { return m_structure->isExtensible(); }
virtual ComplType exceptionType() const { return Throw; }
void allocatePropertyStorage(size_t oldSize, size_t newSize);
bool isUsingInlineStorage() const { return static_cast<const void*>(m_propertyStorage) == static_cast<const void*>(this + 1); }
......
2011-09-08 Sam Weinig <sam@webkit.org>
Remove the Completion object from JSC, I have never liked it
https://bugs.webkit.org/show_bug.cgi?id=67755
Reviewed by Gavin Barraclough.
* JSRun.cpp:
(JSRun::Evaluate):
(JSRun::CheckSyntax):
* JSRun.h:
* JavaScriptGlue.cpp:
(JSRunEvaluate):
2011-09-07 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r94627 and r94632.
......
......@@ -67,12 +67,12 @@ JSGlobalObject* JSRun::GlobalObject() const
return fGlobalObject.get();
}
Completion JSRun::Evaluate()
JSValue JSRun::Evaluate(JSValue* expception)
{
return JSC::evaluate(fGlobalObject->globalExec(), fGlobalObject->globalScopeChain(), makeSource(fSource));
return JSC::evaluate(fGlobalObject->globalExec(), fGlobalObject->globalScopeChain(), makeSource(fSource), JSValue(), expception);
}
bool JSRun::CheckSyntax()
{
return JSC::checkSyntax(fGlobalObject->globalExec(), makeSource(fSource)).complType() != Throw;
return JSC::checkSyntax(fGlobalObject->globalExec(), makeSource(fSource));
}
......@@ -61,7 +61,7 @@ class JSRun : public JSBase {
UString GetSource() const;
JSGlobalObject* GlobalObject() const;
Completion Evaluate();
JSValue Evaluate(JSValue* exception);
bool CheckSyntax();
JSFlags Flags() const;
private:
......