Changeset 94811 in webkit
- Timestamp:
- Sep 8, 2011 3:38:44 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSBase.cpp
r91401 r94811 30 30 #include "APICast.h" 31 31 #include "APIShims.h" 32 #include "Completion.h"33 32 #include "OpaqueJSString.h" 34 33 #include "SourceCode.h" … … 53 52 JSGlobalObject* globalObject = exec->dynamicGlobalObject(); 54 53 SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), startingLineNumber); 55 Completion completion = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), source, jsThisObject);56 54 57 if (completion.complType() == Throw) { 55 JSValue evaluationException; 56 JSValue returnValue = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), source, jsThisObject, &evaluationException); 57 58 if (evaluationException) { 58 59 if (exception) 59 *exception = toRef(exec, completion.value());60 *exception = toRef(exec, evaluationException); 60 61 return 0; 61 62 } 62 63 63 if ( completion.value())64 return toRef(exec, completion.value());65 64 if (returnValue) 65 return toRef(exec, returnValue); 66 66 67 // happens, for example, when the only statement is an empty (';') statement 67 68 return toRef(exec, jsUndefined()); … … 74 75 75 76 SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), startingLineNumber); 76 Completion completion = checkSyntax(exec->dynamicGlobalObject()->globalExec(), source); 77 if (completion.complType() == Throw) { 77 78 JSValue syntaxException; 79 bool isValidSyntax = checkSyntax(exec->dynamicGlobalObject()->globalExec(), source, &syntaxException); 80 81 if (!isValidSyntax) { 78 82 if (exception) 79 *exception = toRef(exec, completion.value());83 *exception = toRef(exec, syntaxException); 80 84 return false; 81 85 } 82 86 83 87 return true; 84 88 } -
trunk/Source/JavaScriptCore/ChangeLog
r94806 r94811 1 2011-09-08 Sam Weinig <sam@webkit.org> 2 3 Remove the Completion object from JSC, I have never liked it 4 https://bugs.webkit.org/show_bug.cgi?id=67755 5 6 Reviewed by Gavin Barraclough. 7 8 - Removes the Completion object and replaces its use with out parameter exceptions. 9 - Remove ComplType and virtual exceptionType() function on JSObject. Replace with 10 ClassInfo for InterruptedExecutionError and TerminatedExecutionError. 11 12 * API/JSBase.cpp: 13 (JSEvaluateScript): 14 (JSCheckScriptSyntax): 15 * JavaScriptCore.exp: 16 * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: 17 * interpreter/Interpreter.cpp: 18 (JSC::Interpreter::throwException): 19 * jsc.cpp: 20 (functionLoad): 21 (functionCheckSyntax): 22 (runWithScripts): 23 (runInteractive): 24 * runtime/Completion.cpp: 25 (JSC::checkSyntax): 26 (JSC::evaluate): 27 * runtime/Completion.h: 28 * runtime/ExceptionHelpers.cpp: 29 (JSC::InterruptedExecutionError::toString): 30 (JSC::TerminatedExecutionError::toString): 31 (JSC::createInterruptedExecutionException): 32 * runtime/ExceptionHelpers.h: 33 (JSC::InterruptedExecutionError::InterruptedExecutionError): 34 (JSC::InterruptedExecutionError::create): 35 (JSC::InterruptedExecutionError::createStructure): 36 (JSC::TerminatedExecutionError::TerminatedExecutionError): 37 (JSC::TerminatedExecutionError::create): 38 (JSC::TerminatedExecutionError::createStructure): 39 * runtime/JSGlobalData.cpp: 40 (JSC::JSGlobalData::JSGlobalData): 41 * runtime/JSObject.h: 42 1 43 2011-09-08 Ryosuke Niwa <rniwa@webkit.org> 2 44 -
trunk/Source/JavaScriptCore/JavaScriptCore.exp
r94774 r94811 120 120 __ZN3JSC11JSByteArrayC1EPNS_9ExecStateEPNS_9StructureEPN3WTF9ByteArrayE 121 121 __ZN3JSC11ParserArena5resetEv 122 __ZN3JSC11checkSyntaxEPNS_9ExecStateERKNS_10SourceCodeE 122 __ZN3JSC11checkSyntaxEPNS_9ExecStateERKNS_10SourceCodeEPNS_7JSValueE 123 123 __ZN3JSC11createErrorEPNS_9ExecStateERKNS_7UStringE 124 124 __ZN3JSC11regExpFlagsERKNS_7UStringE … … 136 136 __ZN3JSC12JSGlobalData15dumpRegExpTraceEv 137 137 __ZN3JSC12JSGlobalData22clearBuiltinStructuresEv 138 __ZN3JSC12JSGlobalData23releaseExecutableMemoryEv 138 139 __ZN3JSC12JSGlobalData6createENS_15ThreadStackTypeENS_8HeapSizeE 139 140 __ZN3JSC12JSGlobalDataD1Ev … … 218 219 __ZN3JSC23setUpStaticFunctionSlotEPNS_9ExecStateEPKNS_9HashEntryEPNS_8JSObjectERKNS_10IdentifierERNS_12PropertySlotE 219 220 __ZN3JSC24DynamicGlobalObjectScopeC1ERNS_12JSGlobalDataEPNS_14JSGlobalObjectE 221 __ZN3JSC24TerminatedExecutionError6s_infoE 220 222 __ZN3JSC24createStackOverflowErrorEPNS_9ExecStateE 221 223 __ZN3JSC25evaluateInGlobalCallFrameERKNS_7UStringERNS_7JSValueEPNS_14JSGlobalObjectE … … 327 329 __ZN3JSC8Profiler14startProfilingEPNS_9ExecStateERKNS_7UStringE 328 330 __ZN3JSC8Profiler8profilerEv 329 __ZN3JSC8evaluateEPNS_9ExecStateEPNS_14ScopeChainNodeERKNS_10SourceCodeENS_7JSValueE 331 __ZN3JSC8evaluateEPNS_9ExecStateEPNS_14ScopeChainNodeERKNS_10SourceCodeENS_7JSValueEPS7_ 330 332 __ZN3JSC8isZombieEPKNS_6JSCellE 331 333 __ZN3JSC9CodeBlockD1Ev … … 618 620 _jscore_fastmalloc_introspection 619 621 _kJSClassDefinitionEmpty 620 621 #ifndef NDEBUG622 __ZN3JSC12JSGlobalData23releaseExecutableMemoryEv623 #endif -
trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
r94774 r94811 40 40 ??8JSC@@YA_NABVUString@0@0@Z 41 41 ??8WTF@@YA_NABVCString@0@0@Z 42 ?checkSyntax@JSC@@YA_NPAVExecState@1@ABVSourceCode@1@PAVJSValue@1@@Z 43 ?evaluate@JSC@@YA?AVJSValue@1@PAVExecState@1@PAVScopeChainNode@1@ABVSourceCode@1@V21@PAV21@@Z 42 44 ?EcmaScriptConverter@DoubleToStringConverter@double_conversion@WTF@@SAABV123@XZ 43 45 ?ToExponential@DoubleToStringConverter@double_conversion@WTF@@QBE_NNHPAVStringBuilder@23@@Z … … 81 83 ?checkCurrentIdentifierTable@Identifier@JSC@@CAXPAVExecState@2@@Z 82 84 ?checkCurrentIdentifierTable@Identifier@JSC@@CAXPAVJSGlobalData@2@@Z 83 ?checkSyntax@JSC@@YA?AVCompletion@1@PAVExecState@1@ABVSourceCode@1@@Z84 85 ?checksum@MD5@WTF@@QAEXAAV?$Vector@E$0BA@@2@@Z 85 86 ?className@JSObject@JSC@@UBE?AVUString@2@XZ … … 161 162 ?equalUTF16WithUTF8@Unicode@WTF@@YA_NPB_W0PBD1@Z 162 163 ?evaluate@DebuggerCallFrame@JSC@@QBE?AVJSValue@2@ABVUString@2@AAV32@@Z 163 ?evaluate@JSC@@YA?AVCompletion@1@PAVExecState@1@PAVScopeChainNode@1@ABVSourceCode@1@VJSValue@1@@Z164 164 ?exclude@Profile@JSC@@QAEXPBVProfileNode@2@@Z 165 165 ?fastCalloc@WTF@@YAPAXII@Z -
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r94336 r94811 709 709 } 710 710 711 ComplType exceptionType = exception->exceptionType(); 712 isInterrupt = exceptionType == Interrupted || exceptionType == Terminated; 711 isInterrupt = (exception->inherits(&InterruptedExecutionError::s_info) || exception->inherits(&TerminatedExecutionError::s_info)); 713 712 } 714 713 -
trunk/Source/JavaScriptCore/jsc.cpp
r94644 r94811 262 262 263 263 JSGlobalObject* globalObject = exec->lexicalGlobalObject(); 264 Completion result = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(script.data(), fileName)); 265 if (result.complType() == Throw) 266 throwError(exec, result.value()); 267 return JSValue::encode(result.value()); 264 265 JSValue evaluationException; 266 JSValue result = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(script.data(), fileName), JSValue(), &evaluationException); 267 if (evaluationException) 268 throwError(exec, evaluationException); 269 return JSValue::encode(result); 268 270 } 269 271 … … 279 281 StopWatch stopWatch; 280 282 stopWatch.start(); 281 Completion result = checkSyntax(globalObject->globalExec(), makeSource(script.data(), fileName)); 283 284 JSValue syntaxException; 285 bool validSyntax = checkSyntax(globalObject->globalExec(), makeSource(script.data(), fileName), &syntaxException); 282 286 stopWatch.stop(); 283 287 284 if ( result.complType() == Throw)285 throwError(exec, result.value());288 if (!validSyntax) 289 throwError(exec, syntaxException); 286 290 return JSValue::encode(jsNumber(stopWatch.getElapsedMS())); 287 291 } … … 437 441 globalData.startSampling(); 438 442 439 Completion completion = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(script, fileName)); 440 success = success && completion.complType() != Throw; 443 JSValue evaluationException; 444 JSValue returnValue = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(script, fileName), JSValue(), &evaluationException); 445 success = success && !evaluationException; 441 446 if (dump) { 442 if ( completion.complType() == Throw)443 printf("Exception: %s\n", completion.value().toString(globalObject->globalExec()).utf8().data());447 if (evaluationException) 448 printf("Exception: %s\n", evaluationException.toString(globalObject->globalExec()).utf8().data()); 444 449 else 445 printf("End: %s\n", completion.value().toString(globalObject->globalExec()).utf8().data());450 printf("End: %s\n", returnValue.toString(globalObject->globalExec()).utf8().data()); 446 451 } 447 452 … … 474 479 if (line[0]) 475 480 add_history(line); 476 Completion completion = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(line, interpreterName)); 481 JSValue evaluationException; 482 JSValue returnValue = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(line, interpreterName), JSValue(), &evaluationException); 477 483 free(line); 478 484 #else … … 489 495 break; 490 496 line.append('\0'); 491 Completion completion = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(line.data(), interpreterName)); 492 #endif 493 if (completion.complType() == Throw) 494 printf("Exception: %s\n", completion.value().toString(globalObject->globalExec()).utf8().data()); 497 498 JSValue evaluationException; 499 JSValue returnValue = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(line.data(), interpreterName), JSValue(), &evaluationException); 500 #endif 501 if (evaluationException) 502 printf("Exception: %s\n", evaluationException.toString(globalObject->globalExec()).utf8().data()); 495 503 else 496 printf("%s\n", completion.value().toString(globalObject->globalExec()).utf8().data());504 printf("%s\n", returnValue.toString(globalObject->globalExec()).utf8().data()); 497 505 498 506 globalObject->globalExec()->clearException(); -
trunk/Source/JavaScriptCore/runtime/Completion.cpp
r91095 r94811 35 35 namespace JSC { 36 36 37 Completion checkSyntax(ExecState* exec, const SourceCode& source)37 bool checkSyntax(ExecState* exec, const SourceCode& source, JSValue* returnedException) 38 38 { 39 39 JSLock lock(exec); … … 42 42 ProgramExecutable* program = ProgramExecutable::create(exec, source); 43 43 JSObject* error = program->checkSyntax(exec); 44 if (error) 45 return Completion(Throw, error); 44 if (error) { 45 if (returnedException) 46 *returnedException = error; 47 return false; 48 } 46 49 47 return Completion(Normal);50 return true; 48 51 } 49 52 50 Completion evaluate(ExecState* exec, ScopeChainNode* scopeChain, const SourceCode& source, JSValue thisValue)53 JSValue evaluate(ExecState* exec, ScopeChainNode* scopeChain, const SourceCode& source, JSValue thisValue, JSValue* returnedException) 51 54 { 52 55 JSLock lock(exec); … … 55 58 ProgramExecutable* program = ProgramExecutable::create(exec, source); 56 59 if (!program) { 57 JSValue exception = exec->globalData().exception; 60 if (returnedException) 61 *returnedException = exec->globalData().exception; 62 58 63 exec->globalData().exception = JSValue(); 59 return Completion(Throw, exception);64 return jsUndefined(); 60 65 } 61 66 … … 63 68 thisValue = exec->dynamicGlobalObject(); 64 69 JSObject* thisObj = thisValue.toThisObject(exec); 65 66 70 JSValue result = exec->interpreter()->execute(program, exec, scopeChain, thisObj); 67 71 68 72 if (exec->hadException()) { 69 JSValue exception = exec->exception(); 73 if (returnedException) 74 *returnedException = exec->exception(); 75 70 76 exec->clearException(); 77 return jsUndefined(); 78 } 71 79 72 ComplType exceptionType = Throw; 73 if (exception.isObject()) 74 exceptionType = asObject(exception)->exceptionType(); 75 return Completion(exceptionType, exception); 76 } 77 return Completion(Normal, result); 80 ASSERT(result); 81 return result; 78 82 } 79 83 -
trunk/Source/JavaScriptCore/runtime/Completion.h
r79904 r94811 32 32 class SourceCode; 33 33 34 enum ComplType { Normal, Break, Continue, ReturnValue, Throw, Interrupted, Terminated }; 35 36 /* 37 * Completion objects are used to convey the return status and value 38 * from functions. 39 */ 40 class Completion { 41 public: 42 Completion(ComplType type = Normal, JSValue value = JSValue()) 43 : m_type(type) 44 , m_value(value) 45 { 46 } 47 48 ComplType complType() const { return m_type; } 49 JSValue value() const { return m_value; } 50 void setValue(JSValue v) { m_value = v; } 51 bool isValueCompletion() const { return m_value; } 52 53 private: 54 ComplType m_type; 55 JSValue m_value; 56 }; 57 58 Completion checkSyntax(ExecState*, const SourceCode&); 59 Completion evaluate(ExecState*, ScopeChainNode*, const SourceCode&, JSValue thisValue = JSValue()); 34 bool checkSyntax(ExecState*, const SourceCode&, JSValue* exception = 0); 35 JSValue evaluate(ExecState*, ScopeChainNode*, const SourceCode&, JSValue thisValue = JSValue(), JSValue* exception = 0); 60 36 61 37 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp
r94364 r94811 42 42 namespace JSC { 43 43 44 class InterruptedExecutionError : public JSNonFinalObject { 45 private: 46 InterruptedExecutionError(JSGlobalData& globalData) 47 : JSNonFinalObject(globalData, globalData.interruptedExecutionErrorStructure.get()) 48 { 49 } 44 const ClassInfo InterruptedExecutionError::s_info = { "InterruptedExecutionError", 0, 0, 0 }; 50 45 51 public: 52 typedef JSNonFinalObject Base; 46 UString InterruptedExecutionError::toString(ExecState*) const 47 { 48 return "JavaScript execution exceeded timeout."; 49 } 53 50 54 static InterruptedExecutionError* create(JSGlobalData& globalData) 55 { 56 InterruptedExecutionError* error = new (allocateCell<InterruptedExecutionError>(globalData.heap)) InterruptedExecutionError(globalData); 57 error->finishCreation(globalData); 58 return error; 59 } 51 const ClassInfo TerminatedExecutionError::s_info = { "TerminatedExecutionError", 0, 0, 0 }; 60 52 61 virtual ComplType exceptionType() const { return Interrupted; } 53 UString TerminatedExecutionError::toString(ExecState*) const 54 { 55 return "JavaScript execution terminated."; 56 } 62 57 63 virtual UString toString(ExecState*) const { return "JavaScript execution exceeded timeout."; }64 };65 58 66 59 JSObject* createInterruptedExecutionException(JSGlobalData* globalData) … … 68 61 return InterruptedExecutionError::create(*globalData); 69 62 } 70 71 class TerminatedExecutionError : public JSNonFinalObject {72 private:73 TerminatedExecutionError(JSGlobalData& globalData)74 : JSNonFinalObject(globalData, globalData.terminatedExecutionErrorStructure.get())75 {76 }77 78 public:79 typedef JSNonFinalObject Base;80 81 static TerminatedExecutionError* create(JSGlobalData& globalData)82 {83 TerminatedExecutionError* error = new (allocateCell<TerminatedExecutionError>(globalData.heap)) TerminatedExecutionError(globalData);84 error->finishCreation(globalData);85 return error;86 }87 88 virtual ComplType exceptionType() const { return Terminated; }89 90 virtual UString toString(ExecState*) const { return "JavaScript execution terminated."; }91 };92 63 93 64 JSObject* createTerminatedExecutionException(JSGlobalData* globalData) -
trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.h
r75408 r94811 30 30 #define ExceptionHelpers_h 31 31 32 #include "JS Value.h"32 #include "JSObject.h" 33 33 34 34 namespace JSC { 35 35 36 class CodeBlock; 37 class ExecState; 38 class Identifier; 39 class JSGlobalData; 40 class JSGlobalObject; 41 class JSNotAnObjectErrorStub; 42 class JSObject; 43 class Node; 44 struct Instruction; 45 46 JSObject* createInterruptedExecutionException(JSGlobalData*); 47 JSObject* createTerminatedExecutionException(JSGlobalData*); 48 JSObject* createStackOverflowError(ExecState*); 49 JSObject* createStackOverflowError(JSGlobalObject*); 50 JSObject* createOutOfMemoryError(JSGlobalObject*); 51 JSObject* createUndefinedVariableError(ExecState*, const Identifier&); 52 JSObject* createNotAnObjectError(ExecState*, JSValue); 53 JSObject* createInvalidParamError(ExecState*, const char* op, JSValue); 54 JSObject* createNotAConstructorError(ExecState*, JSValue); 55 JSObject* createNotAFunctionError(ExecState*, JSValue); 56 JSObject* createErrorForInvalidGlobalAssignment(ExecState*, const UString&); 36 JSObject* createInterruptedExecutionException(JSGlobalData*); 37 JSObject* createTerminatedExecutionException(JSGlobalData*); 38 JSObject* createStackOverflowError(ExecState*); 39 JSObject* createStackOverflowError(JSGlobalObject*); 40 JSObject* createOutOfMemoryError(JSGlobalObject*); 41 JSObject* createUndefinedVariableError(ExecState*, const Identifier&); 42 JSObject* createNotAnObjectError(ExecState*, JSValue); 43 JSObject* createInvalidParamError(ExecState*, const char* op, JSValue); 44 JSObject* createNotAConstructorError(ExecState*, JSValue); 45 JSObject* createNotAFunctionError(ExecState*, JSValue); 46 JSObject* createErrorForInvalidGlobalAssignment(ExecState*, const UString&); 57 47 58 JSObject* throwOutOfMemoryError(ExecState*); 59 JSObject* throwStackOverflowError(ExecState*); 48 JSObject* throwOutOfMemoryError(ExecState*); 49 JSObject* throwStackOverflowError(ExecState*); 50 51 52 class InterruptedExecutionError : public JSNonFinalObject { 53 private: 54 InterruptedExecutionError(JSGlobalData& globalData) 55 : JSNonFinalObject(globalData, globalData.interruptedExecutionErrorStructure.get()) 56 { 57 } 58 59 virtual UString toString(ExecState*) const; 60 61 public: 62 typedef JSNonFinalObject Base; 63 64 static InterruptedExecutionError* create(JSGlobalData& globalData) 65 { 66 InterruptedExecutionError* error = new (allocateCell<InterruptedExecutionError>(globalData.heap)) InterruptedExecutionError(globalData); 67 error->finishCreation(globalData); 68 return error; 69 } 70 71 static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype) 72 { 73 return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info); 74 } 75 76 static JS_EXPORTDATA const ClassInfo s_info; 77 }; 78 79 class TerminatedExecutionError : public JSNonFinalObject { 80 private: 81 TerminatedExecutionError(JSGlobalData& globalData) 82 : JSNonFinalObject(globalData, globalData.terminatedExecutionErrorStructure.get()) 83 { 84 } 85 86 virtual UString toString(ExecState*) const; 87 88 public: 89 typedef JSNonFinalObject Base; 90 91 static TerminatedExecutionError* create(JSGlobalData& globalData) 92 { 93 TerminatedExecutionError* error = new (allocateCell<TerminatedExecutionError>(globalData.heap)) TerminatedExecutionError(globalData); 94 error->finishCreation(globalData); 95 return error; 96 } 97 98 static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype) 99 { 100 return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info); 101 } 102 103 static JS_EXPORTDATA const ClassInfo s_info; 104 }; 60 105 61 106 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/JSGlobalData.cpp
r94599 r94811 217 217 debuggerActivationStructure.set(*this, DebuggerActivation::createStructure(*this, 0, jsNull())); 218 218 activationStructure.set(*this, JSActivation::createStructure(*this, 0, jsNull())); 219 interruptedExecutionErrorStructure.set(*this, JSNonFinalObject::createStructure(*this, 0, jsNull()));220 terminatedExecutionErrorStructure.set(*this, JSNonFinalObject::createStructure(*this, 0, jsNull()));219 interruptedExecutionErrorStructure.set(*this, InterruptedExecutionError::createStructure(*this, 0, jsNull())); 220 terminatedExecutionErrorStructure.set(*this, TerminatedExecutionError::createStructure(*this, 0, jsNull())); 221 221 staticScopeStructure.set(*this, JSStaticScopeObject::createStructure(*this, 0, jsNull())); 222 222 strictEvalActivationStructure.set(*this, StrictEvalActivation::createStructure(*this, 0, jsNull())); -
trunk/Source/JavaScriptCore/runtime/JSObject.h
r94701 r94811 27 27 #include "ClassInfo.h" 28 28 #include "CommonIdentifiers.h" 29 #include "Completion.h"30 29 #include "CallFrame.h" 31 30 #include "JSCell.h" … … 219 218 bool isFrozen(JSGlobalData& globalData) { return m_structure->isFrozen(globalData); } 220 219 bool isExtensible() { return m_structure->isExtensible(); } 221 222 virtual ComplType exceptionType() const { return Throw; }223 220 224 221 void allocatePropertyStorage(size_t oldSize, size_t newSize); -
trunk/Source/JavaScriptGlue/ChangeLog
r94644 r94811 1 2011-09-08 Sam Weinig <sam@webkit.org> 2 3 Remove the Completion object from JSC, I have never liked it 4 https://bugs.webkit.org/show_bug.cgi?id=67755 5 6 Reviewed by Gavin Barraclough. 7 8 * JSRun.cpp: 9 (JSRun::Evaluate): 10 (JSRun::CheckSyntax): 11 * JSRun.h: 12 * JavaScriptGlue.cpp: 13 (JSRunEvaluate): 14 1 15 2011-09-07 Sheriff Bot <webkit.review.bot@gmail.com> 2 16 -
trunk/Source/JavaScriptGlue/JSRun.cpp
r94644 r94811 68 68 } 69 69 70 Completion JSRun::Evaluate()70 JSValue JSRun::Evaluate(JSValue* expception) 71 71 { 72 return JSC::evaluate(fGlobalObject->globalExec(), fGlobalObject->globalScopeChain(), makeSource(fSource) );72 return JSC::evaluate(fGlobalObject->globalExec(), fGlobalObject->globalScopeChain(), makeSource(fSource), JSValue(), expception); 73 73 } 74 74 75 75 bool JSRun::CheckSyntax() 76 76 { 77 return JSC::checkSyntax(fGlobalObject->globalExec(), makeSource(fSource)) .complType() != Throw;77 return JSC::checkSyntax(fGlobalObject->globalExec(), makeSource(fSource)); 78 78 } -
trunk/Source/JavaScriptGlue/JSRun.h
r94599 r94811 62 62 UString GetSource() const; 63 63 JSGlobalObject* GlobalObject() const; 64 Completion Evaluate();64 JSValue Evaluate(JSValue* exception); 65 65 bool CheckSyntax(); 66 66 JSFlags Flags() const; -
trunk/Source/JavaScriptGlue/JavaScriptGlue.cpp
r52856 r94811 293 293 { 294 294 JSGlueAPIEntry entry; 295 Completion completion = ptr->Evaluate();296 if (completion.isValueCompletion())297 {298 result = (JSObjectRef)KJSValueToJSObject(completion.value(), ptr->GlobalObject()->globalExec());299 }300 301 if (completion.complType() == Throw)302 {295 296 JSValue evaluationException; 297 JSValue returnValue = ptr->Evaluate(&evaluationException); 298 299 if (evaluationException) 300 { 301 result = (JSObjectRef)KJSValueToJSObject(evaluationException, ptr->GlobalObject()->globalExec()); 302 303 303 JSFlags flags = ptr->Flags(); 304 304 if (flags & kJSFlagDebug) … … 311 311 } 312 312 } 313 } 314 else 315 { 316 result = (JSObjectRef)KJSValueToJSObject(returnValue, ptr->GlobalObject()->globalExec()); 313 317 } 314 318 } -
trunk/Source/WebCore/ChangeLog
r94810 r94811 1 2011-09-08 Sam Weinig <sam@webkit.org> 2 3 Remove the Completion object from JSC, I have never liked it 4 https://bugs.webkit.org/show_bug.cgi?id=67755 5 6 Reviewed by Gavin Barraclough. 7 8 * bindings/js/JSDOMBinding.cpp: 9 (WebCore::reportException): 10 * bindings/js/JSEventListener.cpp: 11 (WebCore::JSEventListener::handleEvent): 12 * bindings/js/JSInjectedScriptManager.cpp: 13 (WebCore::InjectedScriptManager::createInjectedScript): 14 * bindings/js/JSMainThreadExecState.h: 15 (WebCore::JSMainThreadExecState::evaluate): 16 * bindings/js/ScriptController.cpp: 17 (WebCore::ScriptController::evaluateInWorld): 18 * bindings/js/WorkerScriptController.cpp: 19 (WebCore::WorkerScriptController::evaluate): 20 * bindings/objc/WebScriptObject.mm: 21 (-[WebScriptObject evaluateWebScript:]): 22 * bridge/NP_jsobject.cpp: 23 (_NPN_Evaluate): 24 * bridge/jni/jni_jsobject.mm: 25 (JavaJSObject::eval): 26 1 27 2011-09-08 Adam Barth <abarth@webkit.org> 2 28 -
trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp
r91194 r94811 58 58 #include <runtime/DateInstance.h> 59 59 #include <runtime/Error.h> 60 #include <runtime/ExceptionHelpers.h> 60 61 #include <runtime/JSFunction.h> 61 62 … … 171 172 void reportException(ExecState* exec, JSValue exception) 172 173 { 173 if (exception.i sObject() && asObject(exception)->exceptionType() == Terminated)174 if (exception.inherits(&TerminatedExecutionError::s_info)) 174 175 return; 175 176 -
trunk/Source/WebCore/bindings/js/JSEventListener.cpp
r93913 r94811 27 27 #include "JSMainThreadExecState.h" 28 28 #include "WorkerContext.h" 29 #include <runtime/ExceptionHelpers.h> 29 30 #include <runtime/JSLock.h> 30 31 #include <wtf/RefCountedLeakCounter.h> … … 134 135 #if ENABLE(WORKERS) 135 136 if (scriptExecutionContext->isWorkerContext()) { 136 bool terminatorCausedException = (exec->hadException() && exec->exception().i sObject() && asObject(exec->exception())->exceptionType() == Terminated);137 bool terminatorCausedException = (exec->hadException() && exec->exception().inherits(&TerminatedExecutionError::s_info)); 137 138 if (terminatorCausedException || globalData.terminator.shouldTerminate()) 138 139 static_cast<WorkerContext*>(scriptExecutionContext)->script()->forbidExecution(); -
trunk/Source/WebCore/bindings/js/JSInjectedScriptManager.cpp
r90124 r94811 52 52 ScriptObject InjectedScriptManager::createInjectedScript(const String& source, ScriptState* scriptState, long id) 53 53 { 54 JSLock lock(SilenceAssertionsOnly); 55 54 56 SourceCode sourceCode = makeSource(stringToUString(source)); 55 JSLock lock(SilenceAssertionsOnly);56 57 JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject()); 57 58 JSValue globalThisValue = scriptState->globalThisValue(); 58 Completion comp = JSMainThreadExecState::evaluate(scriptState, globalObject->globalScopeChain(), sourceCode, globalThisValue); 59 if (comp.complType() != JSC::Normal && comp.complType() != JSC::ReturnValue) 59 60 JSValue evaluationException; 61 JSValue evaluationReturnValue = JSMainThreadExecState::evaluate(scriptState, globalObject->globalScopeChain(), sourceCode, globalThisValue, &evaluationException); 62 if (evaluationException) 60 63 return ScriptObject(); 61 JSValue functionValue = comp.value(); 64 65 JSValue functionValue = evaluationReturnValue; 62 66 CallData callData; 63 67 CallType callType = getCallData(functionValue, callData); -
trunk/Source/WebCore/bindings/js/JSMainThreadExecState.h
r91641 r94811 28 28 29 29 #include "JSDOMBinding.h" 30 #include <runtime/Completion.h> 30 31 #ifndef NDEBUG 31 32 #include <wtf/MainThread.h> … … 52 53 }; 53 54 54 static JSC:: Completion evaluate(JSC::ExecState* exec, JSC::ScopeChainNode* chain, const JSC::SourceCode& source, JSC::JSValue thisValue)55 static JSC::JSValue evaluate(JSC::ExecState* exec, JSC::ScopeChainNode* chain, const JSC::SourceCode& source, JSC::JSValue thisValue, JSC::JSValue* exception) 55 56 { 56 57 JSMainThreadExecState currentState(exec); 57 return JSC::evaluate(exec, chain, source, thisValue );58 return JSC::evaluate(exec, chain, source, thisValue, exception); 58 59 }; 59 60 -
trunk/Source/WebCore/bindings/js/ScriptController.cpp
r94364 r94811 139 139 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willEvaluateScript(m_frame, sourceURL, sourceCode.startLine()); 140 140 141 JSValue evaluationException; 142 141 143 exec->globalData().timeoutChecker.start(); 142 Completion comp = JSMainThreadExecState::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), jsSourceCode, shell);144 JSValue returnValue = JSMainThreadExecState::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), jsSourceCode, shell, &evaluationException); 143 145 exec->globalData().timeoutChecker.stop(); 144 146 145 147 InspectorInstrumentation::didEvaluateScript(cookie); 146 148 147 if (comp.complType() == Normal || comp.complType() == ReturnValue) { 149 if (evaluationException) { 150 reportException(exec, evaluationException); 148 151 m_sourceURL = savedSourceURL; 149 return ScriptValue(exec->globalData(), comp.value()); 150 } 151 152 if (comp.complType() == Throw || comp.complType() == Interrupted) 153 reportException(exec, comp.value()); 152 return ScriptValue(); 153 } 154 154 155 155 m_sourceURL = savedSourceURL; 156 return ScriptValue( );156 return ScriptValue(exec->globalData(), returnValue); 157 157 } 158 158 -
trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp
r94701 r94811 41 41 #include <interpreter/Interpreter.h> 42 42 #include <runtime/Completion.h> 43 #include <runtime/ Completion.h>43 #include <runtime/ExceptionHelpers.h> 44 44 #include <runtime/Error.h> 45 45 #include <runtime/JSLock.h> … … 132 132 133 133 ExecState* exec = m_workerContextWrapper->globalExec(); 134 135 JSValue evaluationException; 136 134 137 m_workerContextWrapper->globalData().timeoutChecker.start(); 135 Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), sourceCode.jsSourceCode(), m_workerContextWrapper.get());138 JSValue returnValue = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), sourceCode.jsSourceCode(), m_workerContextWrapper.get(), &evaluationException); 136 139 m_workerContextWrapper->globalData().timeoutChecker.stop(); 137 140 138 139 ComplType completionType = comp.complType(); 140 141 if (completionType == Terminated || m_workerContextWrapper->globalData().terminator.shouldTerminate()) { 141 if ((evaluationException && evaluationException.inherits(&TerminatedExecutionError::s_info)) || m_workerContextWrapper->globalData().terminator.shouldTerminate()) { 142 142 forbidExecution(); 143 143 return ScriptValue(); 144 144 } 145 145 146 if (completionType == Normal || completionType == ReturnValue) 147 return ScriptValue(*m_globalData, comp.value()); 148 149 if (completionType == Throw) { 146 if (evaluationException) { 150 147 String errorMessage; 151 148 int lineNumber = 0; … … 154 151 *exception = ScriptValue(*m_globalData, throwError(exec, createError(exec, errorMessage.impl()))); 155 152 else 156 *exception = ScriptValue(*m_globalData, comp.value());153 *exception = ScriptValue(*m_globalData, evaluationException); 157 154 } 158 return ScriptValue(); 155 156 return ScriptValue(*m_globalData, returnValue); 157 159 158 } 160 159 -
trunk/Source/WebCore/bindings/objc/WebScriptObject.mm
r93026 r94811 326 326 ASSERT(!exec->hadException()); 327 327 328 JSValue result;329 328 JSLock lock(SilenceAssertionsOnly); 330 329 331 330 [self _rootObject]->globalObject()->globalData().timeoutChecker.start(); 332 Completion completion = JSMainThreadExecState::evaluate([self _rootObject]->globalObject()->globalExec(), [self _rootObject]->globalObject()->globalScopeChain(), makeSource(String(script)), JSC::JSValue());331 JSValue returnValue = JSMainThreadExecState::evaluate(exec, [self _rootObject]->globalObject()->globalScopeChain(), makeSource(String(script)), JSC::JSValue(), 0); 333 332 [self _rootObject]->globalObject()->globalData().timeoutChecker.stop(); 334 ComplType type = completion.complType(); 335 336 if (type == Normal) { 337 result = completion.value(); 338 if (!result) 339 result = jsUndefined(); 340 } else 341 result = jsUndefined(); 342 343 if (exec->hadException()) { 344 addExceptionToConsole(exec); 345 result = jsUndefined(); 346 exec->clearException(); 347 } 348 349 id resultObj = [WebScriptObject _convertValueToObjcValue:result originRootObject:[self _originRootObject] rootObject:[self _rootObject]]; 333 334 id resultObj = [WebScriptObject _convertValueToObjcValue:returnValue originRootObject:[self _originRootObject] rootObject:[self _rootObject]]; 350 335 351 336 _didExecute(self); -
trunk/Source/WebCore/bridge/NP_jsobject.cpp
r91195 r94811 275 275 String scriptString = convertNPStringToUTF16(s); 276 276 RefPtr<JSGlobalData> globalData(&exec->globalData()); 277 277 278 globalData->timeoutChecker.start(); 278 Completion completion= JSC::evaluate(rootObject->globalObject()->globalExec(), rootObject->globalObject()->globalScopeChain(), makeSource(scriptString), JSC::JSValue());279 JSValue returnValue = JSC::evaluate(rootObject->globalObject()->globalExec(), rootObject->globalObject()->globalScopeChain(), makeSource(scriptString), JSC::JSValue()); 279 280 globalData->timeoutChecker.stop(); 280 ComplType type = completion.complType(); 281 282 JSValue result; 283 if (type == Normal) { 284 result = completion.value(); 285 if (!result) 286 result = jsUndefined(); 287 } else 288 result = jsUndefined(); 289 290 convertValueToNPVariant(exec, result, variant); 281 282 convertValueToNPVariant(exec, returnValue, variant); 291 283 exec->clearException(); 292 284 return true; -
trunk/Source/WebCore/bridge/jni/jni_jsobject.mm
r92693 r94811 307 307 { 308 308 LOG(LiveConnect, "JavaJSObject::eval script = %s", JavaString(script).utf8()); 309 310 JSValue result;311 309 312 310 JSLock lock(SilenceAssertionsOnly); … … 317 315 318 316 rootObject->globalObject()->globalData().timeoutChecker.start(); 319 Completion completion = JSC::evaluate(rootObject->globalObject()->globalExec(), rootObject->globalObject()->globalScopeChain(), makeSource(JavaString(script).impl()), JSC::JSValue());317 JSValue result = JSC::evaluate(rootObject->globalObject()->globalExec(), rootObject->globalObject()->globalScopeChain(), makeSource(JavaString(script).impl())); 320 318 rootObject->globalObject()->globalData().timeoutChecker.stop(); 321 ComplType type = completion.complType(); 322 323 if (type == Normal) { 324 result = completion.value(); 325 if (!result) 326 result = jsUndefined(); 327 } else 328 result = jsUndefined(); 329 330 return convertValueToJObject (result); 319 320 return convertValueToJObject(result); 331 321 } 332 322 -
trunk/Source/WebKit/mac/ChangeLog
r94644 r94811 1 2011-09-08 Sam Weinig <sam@webkit.org> 2 3 Remove the Completion object from JSC, I have never liked it 4 https://bugs.webkit.org/show_bug.cgi?id=67755 5 6 Reviewed by Gavin Barraclough. 7 8 * Plugins/Hosted/NetscapePluginInstanceProxy.mm: 9 (WebKit::NetscapePluginInstanceProxy::evaluate): 10 1 11 2011-09-07 Sheriff Bot <webkit.review.bot@gmail.com> 2 12 -
trunk/Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm
r93732 r94811 42 42 #import "WebUIDelegatePrivate.h" 43 43 #import "WebViewInternal.h" 44 #import <JavaScriptCore/Completion.h> 44 45 #import <JavaScriptCore/Error.h> 45 46 #import <JavaScriptCore/JSLock.h> … … 876 877 877 878 UserGestureIndicator gestureIndicator(allowPopups ? DefinitelyProcessingUserGesture : PossiblyProcessingUserGesture); 878 Completion completion = JSC::evaluate(exec, globalObject->globalScopeChain(), makeSource(script)); 879 879 880 JSValue result = JSC::evaluate(exec, globalObject->globalScopeChain(), makeSource(script)); 881 880 882 globalObject->globalData().timeoutChecker.stop(); 881 ComplType type = completion.complType();882 883 JSValue result;884 if (type == Normal)885 result = completion.value();886 887 if (!result)888 result = jsUndefined();889 883 890 884 marshalValue(exec, result, resultData, resultLength); -
trunk/Source/WebKit/qt/Api/qwebelement.cpp
r94516 r94811 34 34 #include "HTMLElement.h" 35 35 #if USE(JSC) 36 #include "Completion.h" 36 37 #include "JSGlobalObject.h" 37 38 #include "JSHTMLElement.h" … … 790 791 JSC::ScopeChainNode* scopeChain = state->dynamicGlobalObject()->globalScopeChain(); 791 792 JSC::UString script(reinterpret_cast_ptr<const UChar*>(scriptSource.data()), scriptSource.length()); 792 JSC::Completion completion = JSC::evaluate(state, scopeChain, JSC::makeSource(script), thisValue); 793 if ((completion.complType() != JSC::ReturnValue) && (completion.complType() != JSC::Normal)) 793 794 JSC::JSValue evaluationException; 795 JSC::JSValue evaluationResult = JSC::evaluate(state, scopeChain, JSC::makeSource(script), thisValue, &evaluationException); 796 if (evaluationException) 794 797 return QVariant(); 795 798 796 JSC::JSValue result = completion.value();797 if (!result)798 return QVariant();799 800 799 int distance = 0; 801 return JSC::Bindings::convertValueToQVariant(state, result, QMetaType::Void, &distance);800 return JSC::Bindings::convertValueToQVariant(state, evaluationResult, QMetaType::Void, &distance); 802 801 #elif USE(V8) 803 802 notImplemented(); -
trunk/Source/WebKit/qt/ChangeLog
r94685 r94811 1 2011-09-08 Sam Weinig <sam@webkit.org> 2 3 Remove the Completion object from JSC, I have never liked it 4 https://bugs.webkit.org/show_bug.cgi?id=67755 5 6 Reviewed by Gavin Barraclough. 7 8 * Api/qwebelement.cpp: 9 (QWebElement::evaluateJavaScript): 10 1 11 2011-09-05 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> 2 12 -
trunk/Source/WebKit2/ChangeLog
r94804 r94811 1 2011-09-08 Sam Weinig <sam@webkit.org> 2 3 Remove the Completion object from JSC, I have never liked it 4 https://bugs.webkit.org/show_bug.cgi?id=67755 5 6 Reviewed by Gavin Barraclough. 7 8 * WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp: 9 (WebKit::NPRuntimeObjectMap::evaluate): 10 1 11 2011-09-08 Anders Carlsson <andersca@apple.com> 2 12 -
trunk/Source/WebKit2/Platform/CoreIPC/Connection.cpp
r93905 r94811 466 466 // We didn't find a sync reply yet, keep waiting. 467 467 #if PLATFORM(WIN) 468 timedOut = !m_syncMessageState->wait WhileDispatchingSentWin32Messages(absoluteTime, m_client->windowsToReceiveSentMessagesWhileWaitingForSyncReply());468 timedOut = !m_syncMessageState->wait\oluteTime, m_client->windowsToReceiveSentMessagesWhileWaitingForSyncReply()); 469 469 #else 470 470 -
trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp
r93555 r94811 32 32 #include "PluginView.h" 33 33 #include "WebProcess.h" 34 #include <JavaScriptCore/Completion.h> 34 35 #include <JavaScriptCore/Error.h> 35 36 #include <JavaScriptCore/JSLock.h> … … 189 190 190 191 globalObject->globalData().timeoutChecker.start(); 191 Completion completion= JSC::evaluate(exec, globalObject->globalScopeChain(), makeSource(UString(scriptString.impl())), thisValue);192 JSValue resultValue = JSC::evaluate(exec, globalObject->globalScopeChain(), makeSource(UString(scriptString.impl())), thisValue); 192 193 globalObject->globalData().timeoutChecker.stop(); 193 194 194 ComplType completionType = completion.complType();195 196 JSValue resultValue;197 if (completionType == Normal) {198 resultValue = completion.value();199 if (!resultValue)200 resultValue = jsUndefined();201 } else202 resultValue = jsUndefined();203 204 exec->clearException();205 206 195 convertJSValueToNPVariant(exec, resultValue, *result); 207 196 return true;
Note: See TracChangeset
for help on using the changeset viewer.