Changeset 185608 in webkit
- Timestamp:
- Jun 16, 2015, 1:51:04 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 40 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSBase.cpp
r185259 r185608 65 65 SourceCode source = makeSource(script->string(), sourceURL ? sourceURL->string() : String(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first())); 66 66 67 Exception*evaluationException;67 NakedPtr<Exception> evaluationException; 68 68 JSValue returnValue = evaluate(globalObject->globalExec(), source, jsThisObject, evaluationException); 69 69 -
trunk/Source/JavaScriptCore/API/JSScriptRef.cpp
r185346 r185608 144 144 return 0; 145 145 } 146 Exception*internalException;146 NakedPtr<Exception> internalException; 147 147 JSValue thisValue = thisValueRef ? toJS(exec, thisValueRef) : jsUndefined(); 148 148 JSValue result = evaluate(exec, SourceCode(script), thisValue, internalException); -
trunk/Source/JavaScriptCore/ChangeLog
r185600 r185608 1 2015-06-16 Mark Lam <mark.lam@apple.com> 2 3 Use NakedPtr<Exception>& to return exception results. 4 https://bugs.webkit.org/show_bug.cgi?id=145870 5 6 Reviewed by Anders Carlsson and Filip Pizlo. 7 8 Before r185259, calls into the VM takes a JSValue* exception result argument for 9 returning any uncaught exception that may have been thrown while executing JS code. 10 As a result, clients of the VM functions will declare a local JSValue exception 11 result which is automatically initialized to a null value (i.e. the empty value, 12 not the JS null value). 13 14 With r185259, the VM functions were changed to take an Exception*& exception result 15 instead, and the VM functions are responsible for initializing the exception result 16 to null if no exception is thrown. 17 18 This introduces 2 issues: 19 20 1. the VM functions are vulnerable to modifications that may add early returns 21 before the exception result is nullified. This can result in the exception 22 result being used without initialization. 23 24 2. Previously, a client could technically use the same exception result for more 25 than one calls into the VM functions. If an earlier call sets it to a thrown 26 value, the thrown value will stick unless a subsequent call throws a different 27 exception. 28 29 With the new Exception*& exception result, the VM functions will always clear 30 the exception result before proceeding. As a result, the client's exception 31 result will be null after the second call even though the first call saw an 32 exception thrown. This is a change in the expected behavior. 33 34 To fix these issues, we'll introduce a NakedPtr smart pointer whose sole purpose 35 is to guarantee that the pointer is initialized. The VM functions will now take 36 a NakedPtr<Exception>& instead of the Exception*&. This ensures that the 37 exception result is initialized. 38 39 The VM functions be also reverted to only set the exception result if a new 40 exception is thrown. 41 42 * API/JSBase.cpp: 43 (JSEvaluateScript): 44 * API/JSScriptRef.cpp: 45 * bindings/ScriptFunctionCall.cpp: 46 (Deprecated::ScriptFunctionCall::call): 47 * bindings/ScriptFunctionCall.h: 48 * debugger/Debugger.cpp: 49 (JSC::Debugger::hasBreakpoint): 50 * debugger/Debugger.h: 51 * debugger/DebuggerCallFrame.cpp: 52 (JSC::DebuggerCallFrame::thisValue): 53 (JSC::DebuggerCallFrame::evaluate): 54 * debugger/DebuggerCallFrame.h: 55 (JSC::DebuggerCallFrame::isValid): 56 * inspector/InjectedScriptManager.cpp: 57 (Inspector::InjectedScriptManager::createInjectedScript): 58 * inspector/InspectorEnvironment.h: 59 * inspector/JSJavaScriptCallFrame.cpp: 60 (Inspector::JSJavaScriptCallFrame::evaluate): 61 * inspector/JavaScriptCallFrame.h: 62 (Inspector::JavaScriptCallFrame::vmEntryGlobalObject): 63 (Inspector::JavaScriptCallFrame::thisValue): 64 (Inspector::JavaScriptCallFrame::evaluate): 65 * inspector/ScriptDebugServer.cpp: 66 (Inspector::ScriptDebugServer::evaluateBreakpointAction): 67 * jsc.cpp: 68 (functionRun): 69 (functionLoad): 70 (runWithScripts): 71 (runInteractive): 72 * runtime/CallData.cpp: 73 (JSC::call): 74 * runtime/CallData.h: 75 * runtime/Completion.cpp: 76 (JSC::checkSyntax): 77 (JSC::evaluate): 78 * runtime/Completion.h: 79 (JSC::evaluate): 80 1 81 2015-06-15 Filip Pizlo <fpizlo@apple.com> 2 82 -
trunk/Source/JavaScriptCore/bindings/ScriptFunctionCall.cpp
r185259 r185608 134 134 135 135 JSValue result; 136 Exception*exception;136 NakedPtr<Exception> exception; 137 137 if (m_callHandler) 138 138 result = m_callHandler(m_exec, function, callType, callData, thisObject, m_arguments, exception); -
trunk/Source/JavaScriptCore/bindings/ScriptFunctionCall.h
r185259 r185608 72 72 class JS_EXPORT_PRIVATE ScriptFunctionCall : public ScriptCallArgumentHandler { 73 73 public: 74 typedef JSC::JSValue (*ScriptFunctionCallHandler)(JSC::ExecState* exec, JSC::JSValue functionObject, JSC::CallType callType, const JSC::CallData& callData, JSC::JSValue thisValue, const JSC::ArgList& args, JSC::Exception*& exception);74 typedef JSC::JSValue (*ScriptFunctionCallHandler)(JSC::ExecState* exec, JSC::JSValue functionObject, JSC::CallType callType, const JSC::CallData& callData, JSC::JSValue thisValue, const JSC::ArgList& args, NakedPtr<JSC::Exception>&); 75 75 ScriptFunctionCall(const ScriptObject& thisObject, const String& name, ScriptFunctionCallHandler handler = nullptr); 76 76 ScriptValue call(bool& hadException); -
trunk/Source/JavaScriptCore/debugger/Debugger.cpp
r185379 r185608 26 26 #include "DebuggerCallFrame.h" 27 27 #include "Error.h" 28 29 28 #include "HeapIterationScope.h" 30 29 #include "Interpreter.h" … … 488 487 TemporaryPausedState pausedState(*this); 489 488 490 Exception*exception;489 NakedPtr<Exception> exception; 491 490 DebuggerCallFrame* debuggerCallFrame = currentDebuggerCallFrame(); 492 491 JSValue result = debuggerCallFrame->evaluate(breakpoint->condition, exception); -
trunk/Source/JavaScriptCore/debugger/Debugger.h
r185259 r185608 35 35 36 36 class CodeBlock; 37 class Exception; 37 38 class ExecState; 38 39 class JSGlobalObject; -
trunk/Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp
r185532 r185608 33 33 #include "DebuggerEvalEnabler.h" 34 34 #include "DebuggerScope.h" 35 #include "Exception.h"36 35 #include "Interpreter.h" 37 36 #include "JSFunction.h" … … 178 177 179 178 // Evaluate some JavaScript code in the scope of this frame. 180 JSValue DebuggerCallFrame::evaluate(const String& script, Exception*& exception) 181 { 182 ASSERT(isValid()); 183 exception = nullptr; 179 JSValue DebuggerCallFrame::evaluate(const String& script, NakedPtr<Exception>& exception) 180 { 181 ASSERT(isValid()); 184 182 CallFrame* callFrame = m_callFrame; 185 183 if (!callFrame) -
trunk/Source/JavaScriptCore/debugger/DebuggerCallFrame.h
r185532 r185608 32 32 #include "DebuggerPrimitives.h" 33 33 #include "Strong.h" 34 #include <wtf/NakedPtr.h> 34 35 #include <wtf/PassRefPtr.h> 35 36 #include <wtf/RefCounted.h> … … 68 69 JS_EXPORT_PRIVATE Type type() const; 69 70 JS_EXPORT_PRIVATE JSValue thisValue() const; 70 JSValue evaluate(const String&, Exception*&);71 JSValue evaluate(const String&, NakedPtr<Exception>&); 71 72 72 73 bool isValid() const { return !!m_callFrame; } -
trunk/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp
r185259 r185608 140 140 JSValue globalThisValue = scriptState->globalThisValue(); 141 141 142 Exception*evaluationException;142 NakedPtr<Exception> evaluationException; 143 143 InspectorEvaluateHandler evaluateHandler = m_environment.evaluateHandler(); 144 144 JSValue functionValue = evaluateHandler(scriptState, sourceCode, globalThisValue, evaluationException); -
trunk/Source/JavaScriptCore/inspector/InspectorEnvironment.h
r185259 r185608 40 40 namespace Inspector { 41 41 42 typedef JSC::JSValue (*InspectorFunctionCallHandler)(JSC::ExecState* exec, JSC::JSValue functionObject, JSC::CallType callType, const JSC::CallData& callData, JSC::JSValue thisValue, const JSC::ArgList& args, JSC::Exception*& returnedException);43 typedef JSC::JSValue (*InspectorEvaluateHandler)(JSC::ExecState*, const JSC::SourceCode&, JSC::JSValue thisValue, JSC::Exception*& returnedException);42 typedef JSC::JSValue (*InspectorFunctionCallHandler)(JSC::ExecState* exec, JSC::JSValue functionObject, JSC::CallType callType, const JSC::CallData& callData, JSC::JSValue thisValue, const JSC::ArgList& args, NakedPtr<JSC::Exception>& returnedException); 43 typedef JSC::JSValue (*InspectorEvaluateHandler)(JSC::ExecState*, const JSC::SourceCode&, JSC::JSValue thisValue, NakedPtr<JSC::Exception>& returnedException); 44 44 45 45 class InspectorEnvironment { -
trunk/Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp
r185259 r185608 29 29 #include "DebuggerScope.h" 30 30 #include "Error.h" 31 #include "Exception.h"32 31 #include "JSCJSValue.h" 33 32 #include "JSCellInlines.h" … … 77 76 JSValue JSJavaScriptCallFrame::evaluate(ExecState* exec) 78 77 { 79 Exception*exception;78 NakedPtr<Exception> exception; 80 79 JSValue result = impl().evaluate(exec->argument(0).toString(exec)->value(exec), exception); 81 80 if (exception) -
trunk/Source/JavaScriptCore/inspector/JavaScriptCallFrame.h
r185346 r185608 56 56 57 57 JSC::JSValue thisValue() const { return m_debuggerCallFrame->thisValue(); } 58 JSC::JSValue evaluate(const String& script, JSC::Exception*& exception) const { return m_debuggerCallFrame->evaluate(script, exception); }58 JSC::JSValue evaluate(const String& script, NakedPtr<JSC::Exception>& exception) const { return m_debuggerCallFrame->evaluate(script, exception); } 59 59 60 60 private: -
trunk/Source/JavaScriptCore/inspector/ScriptDebugServer.cpp
r185259 r185608 95 95 } 96 96 case ScriptBreakpointActionTypeEvaluate: { 97 Exception*exception;97 NakedPtr<Exception> exception; 98 98 debuggerCallFrame->evaluate(breakpointAction.data, exception); 99 99 if (exception) … … 105 105 break; 106 106 case ScriptBreakpointActionTypeProbe: { 107 Exception*exception;107 NakedPtr<Exception> exception; 108 108 JSValue result = debuggerCallFrame->evaluate(breakpointAction.data, exception); 109 109 if (exception) -
trunk/Source/JavaScriptCore/jsc.cpp
r185346 r185608 909 909 exec->vm(), Identifier::fromString(globalObject->globalExec(), "arguments"), array); 910 910 911 Exception*exception;911 NakedPtr<Exception> exception; 912 912 StopWatch stopWatch; 913 913 stopWatch.start(); … … 932 932 JSGlobalObject* globalObject = exec->lexicalGlobalObject(); 933 933 934 Exception*evaluationException;934 NakedPtr<Exception> evaluationException; 935 935 JSValue result = evaluate(globalObject->globalExec(), jscSource(script.data(), fileName), JSValue(), evaluationException); 936 936 if (evaluationException) … … 1295 1295 vm.startSampling(); 1296 1296 1297 Exception*evaluationException;1297 NakedPtr<Exception> evaluationException; 1298 1298 JSValue returnValue = evaluate(globalObject->globalExec(), jscSource(script, fileName), JSValue(), evaluationException); 1299 1299 success = success && !evaluationException; … … 1359 1359 1360 1360 1361 Exception*evaluationException;1361 NakedPtr<Exception> evaluationException; 1362 1362 JSValue returnValue = evaluate(globalObject->globalExec(), makeSource(source, interpreterName), JSValue(), evaluationException); 1363 1363 #else … … 1375 1375 line.append('\0'); 1376 1376 1377 Exception*evaluationException;1377 NakedPtr<Exception> evaluationException; 1378 1378 JSValue returnValue = evaluate(globalObject->globalExec(), jscSource(line.data(), interpreterName), JSValue(), evaluationException); 1379 1379 #endif -
trunk/Source/JavaScriptCore/runtime/CallData.cpp
r185259 r185608 27 27 #include "CallData.h" 28 28 29 #include "Exception.h"30 29 #include "Executable.h" 31 30 #include "Interpreter.h" … … 41 40 } 42 41 43 JSValue call(ExecState* exec, JSValue functionObject, CallType callType, const CallData& callData, JSValue thisValue, const ArgList& args, Exception*& returnedException)42 JSValue call(ExecState* exec, JSValue functionObject, CallType callType, const CallData& callData, JSValue thisValue, const ArgList& args, NakedPtr<Exception>& returnedException) 44 43 { 45 44 JSValue result = call(exec, functionObject, callType, callData, thisValue, args); … … 48 47 exec->clearException(); 49 48 return jsUndefined(); 50 } else 51 returnedException = nullptr; 49 } 52 50 RELEASE_ASSERT(result); 53 51 return result; -
trunk/Source/JavaScriptCore/runtime/CallData.h
r185259 r185608 31 31 32 32 #include "JSCJSValue.h" 33 #include <wtf/NakedPtr.h> 33 34 34 35 namespace JSC { … … 60 61 61 62 JS_EXPORT_PRIVATE JSValue call(ExecState*, JSValue functionObject, CallType, const CallData&, JSValue thisValue, const ArgList&); 62 JS_EXPORT_PRIVATE JSValue call(ExecState*, JSValue functionObject, CallType, const CallData&, JSValue thisValue, const ArgList&, Exception*& returnedException);63 JS_EXPORT_PRIVATE JSValue call(ExecState*, JSValue functionObject, CallType, const CallData&, JSValue thisValue, const ArgList&, NakedPtr<Exception>& returnedException); 63 64 64 65 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/Completion.cpp
r185259 r185608 62 62 } 63 63 64 JSValue evaluate(ExecState* exec, const SourceCode& source, JSValue thisValue, Exception*& returnedException)64 JSValue evaluate(ExecState* exec, const SourceCode& source, JSValue thisValue, NakedPtr<Exception>& returnedException) 65 65 { 66 66 JSLockHolder lock(exec); 67 67 RELEASE_ASSERT(exec->vm().atomicStringTable() == wtfThreadData().atomicStringTable()); 68 68 RELEASE_ASSERT(!exec->vm().isCollectorBusy()); 69 returnedException = nullptr;70 69 71 70 CodeProfiling profile(source); -
trunk/Source/JavaScriptCore/runtime/Completion.h
r185259 r185608 25 25 26 26 #include "JSCJSValue.h" 27 #include <wtf/NakedPtr.h> 27 28 28 29 namespace JSC { … … 37 38 JS_EXPORT_PRIVATE bool checkSyntax(VM&, const SourceCode&, ParserError&); 38 39 JS_EXPORT_PRIVATE bool checkSyntax(ExecState*, const SourceCode&, JSValue* exception = 0); 39 JS_EXPORT_PRIVATE JSValue evaluate(ExecState*, const SourceCode&, JSValue thisValue, Exception*& returnedException);40 JS_EXPORT_PRIVATE JSValue evaluate(ExecState*, const SourceCode&, JSValue thisValue, NakedPtr<Exception>& returnedException); 40 41 inline JSValue evaluate(ExecState* exec, const SourceCode& sourceCode, JSValue thisValue = JSValue()) 41 42 { 42 Exception*unused;43 NakedPtr<Exception> unused; 43 44 return evaluate(exec, sourceCode, thisValue, unused); 44 45 } -
trunk/Source/WTF/ChangeLog
r185502 r185608 1 2015-06-16 Mark Lam <mark.lam@apple.com> 2 3 Use NakedPtr<Exception>& to return exception results. 4 https://bugs.webkit.org/show_bug.cgi?id=145870 5 6 Reviewed by Anders Carlsson and Filip Pizlo. 7 8 Introducing the NakedPtr class. 9 10 * WTF.xcodeproj/project.pbxproj: 11 * wtf/NakedPtr.h: Added. 12 (WTF::NakedPtr::NakedPtr): 13 (WTF::NakedPtr::get): 14 (WTF::NakedPtr::clear): 15 (WTF::NakedPtr::operator*): 16 (WTF::NakedPtr::operator->): 17 (WTF::NakedPtr::operator T*): 18 (WTF::NakedPtr::operator!): 19 (WTF::NakedPtr::operator bool): 20 (WTF::=): 21 (WTF::NakedPtr<T>::swap): 22 (WTF::swap): 23 1 24 2015-06-12 Zan Dobersek <zdobersek@igalia.com> 2 25 -
trunk/Source/WTF/WTF.xcodeproj/project.pbxproj
r185324 r185608 278 278 E4A0AD3D1A96253C00536DF6 /* WorkQueueCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4A0AD3C1A96253C00536DF6 /* WorkQueueCocoa.cpp */; }; 279 279 EB95E1F0161A72410089A2F5 /* ByteOrder.h in Headers */ = {isa = PBXBuildFile; fileRef = EB95E1EF161A72410089A2F5 /* ByteOrder.h */; }; 280 FE8225311B2A1E5B00BA68FD /* NakedPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = FE8225301B2A1E5B00BA68FD /* NakedPtr.h */; }; 280 281 FE91E8811AB2A0200099895F /* SpinLock.h in Headers */ = {isa = PBXBuildFile; fileRef = FE91E8801AB2A0200099895F /* SpinLock.h */; }; 281 282 FEDACD3D1630F83F00C69634 /* StackStats.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEDACD3B1630F83F00C69634 /* StackStats.cpp */; }; … … 569 570 E4A0AD3C1A96253C00536DF6 /* WorkQueueCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkQueueCocoa.cpp; sourceTree = "<group>"; }; 570 571 EB95E1EF161A72410089A2F5 /* ByteOrder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ByteOrder.h; sourceTree = "<group>"; }; 572 FE8225301B2A1E5B00BA68FD /* NakedPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NakedPtr.h; sourceTree = "<group>"; }; 571 573 FE91E8801AB2A0200099895F /* SpinLock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpinLock.h; sourceTree = "<group>"; }; 572 574 FEDACD3B1630F83F00C69634 /* StackStats.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StackStats.cpp; sourceTree = "<group>"; }; … … 783 785 A8A472CE151A825B004123FF /* MetaAllocator.h */, 784 786 A8A472CF151A825B004123FF /* MetaAllocatorHandle.h */, 787 FE8225301B2A1E5B00BA68FD /* NakedPtr.h */, 785 788 1A3F6BE6174ADA2100B2EEA7 /* NeverDestroyed.h */, 786 789 0F0D85B317234CB100338210 /* NoLock.h */, … … 1179 1182 A8A4742C151A825B004123FF /* StringExtras.h in Headers */, 1180 1183 A8A4743F151A825B004123FF /* StringHash.h in Headers */, 1184 FE8225311B2A1E5B00BA68FD /* NakedPtr.h in Headers */, 1181 1185 A748745417A0BDAE00FA04CB /* StringHashDumpContext.h in Headers */, 1182 1186 A8A4742D151A825B004123FF /* StringHasher.h in Headers */, -
trunk/Source/WebCore/ChangeLog
r185606 r185608 1 2015-06-16 Mark Lam <mark.lam@apple.com> 2 3 Use NakedPtr<Exception>& to return exception results. 4 https://bugs.webkit.org/show_bug.cgi?id=145870 5 6 Reviewed by Anders Carlsson and Filip Pizlo. 7 8 No new WebCore tests because this functionality is already covered by existing tests. 9 API tests added for WTF::NakedPtr. 10 11 * bindings/js/JSCallbackData.cpp: 12 (WebCore::JSCallbackData::invokeCallback): 13 * bindings/js/JSCustomXPathNSResolver.cpp: 14 (WebCore::JSCustomXPathNSResolver::lookupNamespaceURI): 15 * bindings/js/JSErrorHandler.cpp: 16 (WebCore::JSErrorHandler::handleEvent): 17 * bindings/js/JSEventListener.cpp: 18 (WebCore::JSEventListener::handleEvent): 19 * bindings/js/JSMainThreadExecState.cpp: 20 (WebCore::JSMainThreadExecState::didLeaveScriptContext): 21 (WebCore::functionCallHandlerFromAnyThread): 22 (WebCore::evaluateHandlerFromAnyThread): 23 * bindings/js/JSMainThreadExecState.h: 24 (WebCore::JSMainThreadExecState::currentState): 25 (WebCore::JSMainThreadExecState::call): 26 (WebCore::JSMainThreadExecState::evaluate): 27 * bindings/js/JSMutationCallback.cpp: 28 (WebCore::JSMutationCallback::call): 29 * bindings/js/ScheduledAction.cpp: 30 (WebCore::ScheduledAction::executeFunctionInContext): 31 * bindings/js/ScriptController.cpp: 32 (WebCore::ScriptController::evaluateInWorld): 33 * bindings/js/WorkerScriptController.cpp: 34 (WebCore::WorkerScriptController::evaluate): 35 (WebCore::WorkerScriptController::setException): 36 * bindings/js/WorkerScriptController.h: 37 (WebCore::WorkerScriptController::workerGlobalScopeWrapper): 38 * bindings/objc/WebScriptObject.mm: 39 (-[WebScriptObject callWebScriptMethod:withArguments:]): 40 * workers/WorkerGlobalScope.cpp: 41 (WebCore::WorkerGlobalScope::importScripts): 42 1 43 2015-06-16 Brent Fulgham <bfulgham@apple.com> 2 44 -
trunk/Source/WebCore/bindings/js/JSCallbackData.cpp
r185259 r185608 74 74 InspectorInstrumentationCookie cookie = JSMainThreadExecState::instrumentFunctionCall(context, callType, callData); 75 75 76 Exception*exception;76 NakedPtr<Exception> exception; 77 77 JSValue result = context->isDocument() 78 78 ? JSMainThreadExecState::call(exec, function, callType, callData, thisValue, args, exception) -
trunk/Source/WebCore/bindings/js/JSCustomXPathNSResolver.cpp
r185259 r185608 94 94 args.append(jsStringWithCache(exec, prefix)); 95 95 96 Exception*exception;96 NakedPtr<Exception> exception; 97 97 JSValue retval = JSMainThreadExecState::call(exec, function, callType, callData, m_customResolver.get(), args, exception); 98 98 -
trunk/Source/WebCore/bindings/js/JSErrorHandler.cpp
r185259 r185608 99 99 VMEntryScope entryScope(vm, vm.entryScope ? vm.entryScope->globalObject() : globalObject); 100 100 101 Exception*exception;101 NakedPtr<Exception> exception; 102 102 JSValue returnValue = scriptExecutionContext->isDocument() 103 103 ? JSMainThreadExecState::call(exec, jsFunction, callType, callData, globalObject, args, exception) -
trunk/Source/WebCore/bindings/js/JSEventListener.cpp
r185259 r185608 125 125 126 126 JSValue thisValue = handleEventFunction == jsFunction ? toJS(exec, globalObject, event->currentTarget()) : jsFunction; 127 Exception*exception;127 NakedPtr<Exception> exception; 128 128 JSValue retval = scriptExecutionContext->isDocument() 129 129 ? JSMainThreadExecState::call(exec, handleEventFunction, callType, callData, thisValue, args, exception) -
trunk/Source/WebCore/bindings/js/JSMainThreadExecState.cpp
r185259 r185608 47 47 } 48 48 49 JSC::JSValue functionCallHandlerFromAnyThread(JSC::ExecState* exec, JSC::JSValue functionObject, JSC::CallType callType, const JSC::CallData& callData, JSC::JSValue thisValue, const JSC::ArgList& args, JSC::Exception*& returnedException)49 JSC::JSValue functionCallHandlerFromAnyThread(JSC::ExecState* exec, JSC::JSValue functionObject, JSC::CallType callType, const JSC::CallData& callData, JSC::JSValue thisValue, const JSC::ArgList& args, NakedPtr<JSC::Exception>& returnedException) 50 50 { 51 51 if (isMainThread()) … … 54 54 } 55 55 56 JSC::JSValue evaluateHandlerFromAnyThread(JSC::ExecState* exec, const JSC::SourceCode& source, JSC::JSValue thisValue, JSC::Exception*& returnedException)56 JSC::JSValue evaluateHandlerFromAnyThread(JSC::ExecState* exec, const JSC::SourceCode& source, JSC::JSValue thisValue, NakedPtr<JSC::Exception>& returnedException) 57 57 { 58 58 if (isMainThread()) -
trunk/Source/WebCore/bindings/js/JSMainThreadExecState.h
r185259 r185608 51 51 }; 52 52 53 static JSC::JSValue call(JSC::ExecState* exec, JSC::JSValue functionObject, JSC::CallType callType, const JSC::CallData& callData, JSC::JSValue thisValue, const JSC::ArgList& args, JSC::Exception*& returnedException)53 static JSC::JSValue call(JSC::ExecState* exec, JSC::JSValue functionObject, JSC::CallType callType, const JSC::CallData& callData, JSC::JSValue thisValue, const JSC::ArgList& args, NakedPtr<JSC::Exception>& returnedException) 54 54 { 55 55 JSMainThreadExecState currentState(exec); … … 57 57 }; 58 58 59 static JSC::JSValue evaluate(JSC::ExecState* exec, const JSC::SourceCode& source, JSC::JSValue thisValue, JSC::Exception*& returnedException)59 static JSC::JSValue evaluate(JSC::ExecState* exec, const JSC::SourceCode& source, JSC::JSValue thisValue, NakedPtr<JSC::Exception>& returnedException) 60 60 { 61 61 JSMainThreadExecState currentState(exec); … … 65 65 static JSC::JSValue evaluate(JSC::ExecState* exec, const JSC::SourceCode& source, JSC::JSValue thisValue = JSC::JSValue()) 66 66 { 67 JSC::Exception*unused;67 NakedPtr<JSC::Exception> unused; 68 68 return evaluate(exec, source, thisValue, unused); 69 69 }; … … 128 128 }; 129 129 130 JSC::JSValue functionCallHandlerFromAnyThread(JSC::ExecState*, JSC::JSValue functionObject, JSC::CallType, const JSC::CallData&, JSC::JSValue thisValue, const JSC::ArgList& args, JSC::Exception*& returnedException);131 JSC::JSValue evaluateHandlerFromAnyThread(JSC::ExecState*, const JSC::SourceCode&, JSC::JSValue thisValue, JSC::Exception*& returnedException);130 JSC::JSValue functionCallHandlerFromAnyThread(JSC::ExecState*, JSC::JSValue functionObject, JSC::CallType, const JSC::CallData&, JSC::JSValue thisValue, const JSC::ArgList& args, NakedPtr<JSC::Exception>& returnedException); 131 JSC::JSValue evaluateHandlerFromAnyThread(JSC::ExecState*, const JSC::SourceCode&, JSC::JSValue thisValue, NakedPtr<JSC::Exception>& returnedException); 132 132 133 133 } // namespace WebCore -
trunk/Source/WebCore/bindings/js/JSMutationCallback.cpp
r185259 r185608 88 88 InspectorInstrumentationCookie cookie = JSMainThreadExecState::instrumentFunctionCall(context, callType, callData); 89 89 90 Exception*exception;90 NakedPtr<Exception> exception; 91 91 JSMainThreadExecState::call(exec, callback, callType, callData, jsObserver, args, exception); 92 92 -
trunk/Source/WebCore/bindings/js/ScheduledAction.cpp
r185259 r185608 100 100 InspectorInstrumentationCookie cookie = JSMainThreadExecState::instrumentFunctionCall(&context, callType, callData); 101 101 102 Exception*exception;102 NakedPtr<Exception> exception; 103 103 if (is<Document>(context)) 104 104 JSMainThreadExecState::call(exec, m_function.get(), callType, callData, thisValue, args, exception); -
trunk/Source/WebCore/bindings/js/ScriptController.cpp
r185342 r185608 161 161 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willEvaluateScript(m_frame, sourceURL, sourceCode.startLine()); 162 162 163 Exception*evaluationException;163 NakedPtr<Exception> evaluationException; 164 164 JSValue returnValue = JSMainThreadExecState::evaluate(exec, jsSourceCode, shell, evaluationException); 165 165 -
trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp
r185286 r185608 100 100 return; 101 101 102 Exception*exception;102 NakedPtr<Exception> exception; 103 103 evaluate(sourceCode, exception); 104 104 if (exception) { … … 108 108 } 109 109 110 void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, JSC::Exception*& returnedException)110 void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, NakedPtr<JSC::Exception>& returnedException) 111 111 { 112 returnedException = nullptr;113 112 if (isExecutionForbidden()) 114 113 return; … … 119 118 JSLockHolder lock(exec); 120 119 121 JSC::Exception* evaluationException; 122 JSC::evaluate(exec, sourceCode.jsSourceCode(), m_workerGlobalScopeWrapper->globalThis(), evaluationException); 120 JSC::evaluate(exec, sourceCode.jsSourceCode(), m_workerGlobalScopeWrapper->globalThis(), returnedException); 123 121 124 122 VM& vm = exec->vm(); 125 if (( evaluationException && isTerminatedExecutionException(evaluationException))123 if ((returnedException && isTerminatedExecutionException(returnedException)) 126 124 || (vm.watchdog && vm.watchdog->didFire())) { 127 125 forbidExecution(); … … 129 127 } 130 128 131 if ( evaluationException) {129 if (returnedException) { 132 130 String errorMessage; 133 131 int lineNumber = 0; … … 136 134 if (m_workerGlobalScope->sanitizeScriptError(errorMessage, lineNumber, columnNumber, sourceURL, sourceCode.cachedScript())) { 137 135 vm.throwException(exec, createError(exec, errorMessage.impl())); 138 evaluationException = vm.exception();136 returnedException = vm.exception(); 139 137 vm.clearException(); 140 138 } 141 139 } 142 returnedException = evaluationException;143 140 } 144 141 -
trunk/Source/WebCore/bindings/js/WorkerScriptController.h
r185259 r185608 32 32 #include <heap/Strong.h> 33 33 #include <wtf/Forward.h> 34 #include <wtf/NakedPtr.h> 34 35 #include <wtf/Threading.h> 35 36 … … 61 62 62 63 void evaluate(const ScriptSourceCode&); 63 void evaluate(const ScriptSourceCode&, JSC::Exception*& returnedException);64 void evaluate(const ScriptSourceCode&, NakedPtr<JSC::Exception>& returnedException); 64 65 65 66 void setException(JSC::Exception*); -
trunk/Source/WebCore/bindings/objc/WebScriptObject.mm
r185259 r185608 343 343 return nil; 344 344 345 JSC::Exception*exception;345 NakedPtr<JSC::Exception> exception; 346 346 JSC::JSValue result = JSMainThreadExecState::call(exec, function, callType, callData, [self _imp], argList, exception); 347 347 -
trunk/Source/WebCore/workers/WorkerGlobalScope.cpp
r185259 r185608 198 198 InspectorInstrumentation::scriptImported(scriptExecutionContext(), scriptLoader->identifier(), scriptLoader->script()); 199 199 200 JSC::Exception*exception;200 NakedPtr<JSC::Exception> exception; 201 201 m_script->evaluate(ScriptSourceCode(scriptLoader->script(), scriptLoader->responseURL()), exception); 202 202 if (exception) { -
trunk/Tools/ChangeLog
r185587 r185608 1 2015-06-16 Mark Lam <mark.lam@apple.com> 2 3 Use NakedPtr<Exception>& to return exception results. 4 https://bugs.webkit.org/show_bug.cgi?id=145870 5 6 Reviewed by Anders Carlsson and Filip Pizlo. 7 8 * TestWebKitAPI/CMakeLists.txt: 9 * TestWebKitAPI/TestWebKitAPI.vcxproj/TestWebKitAPI.vcxproj: 10 * TestWebKitAPI/TestWebKitAPI.vcxproj/TestWebKitAPI.vcxproj.filters: 11 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 12 * TestWebKitAPI/Tests/WTF/NakedPtr.cpp: Added. 13 (TestWebKitAPI::TEST): 14 (TestWebKitAPI::nakedPtrFoo): 15 1 16 2015-06-16 Tobias Reiss <tobi+webkit@basecode.de> 2 17 -
trunk/Tools/TestWebKitAPI/CMakeLists.txt
r185358 r185608 80 80 ${TESTWEBKITAPI_DIR}/Tests/WTF/MediaTime.cpp 81 81 ${TESTWEBKITAPI_DIR}/Tests/WTF/MetaAllocator.cpp 82 ${TESTWEBKITAPI_DIR}/Tests/WTF/NakedPtr.cpp 82 83 ${TESTWEBKITAPI_DIR}/Tests/WTF/RedBlackTree.cpp 83 84 ${TESTWEBKITAPI_DIR}/Tests/WTF/Ref.cpp -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.vcxproj/TestWebKitAPI.vcxproj
r184137 r185608 324 324 <ClCompile Include="..\Tests\WTF\MediaTime.cpp" /> 325 325 <ClCompile Include="..\Tests\WTF\MetaAllocator.cpp" /> 326 <ClCompile Include="..\Tests\WTF\NakedPtr.cpp" /> 326 327 <ClCompile Include="..\Tests\WTF\Optional.cpp" /> 327 328 <ClCompile Include="..\Tests\WTF\RedBlackTree.cpp" /> -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.vcxproj/TestWebKitAPI.vcxproj.filters
r182871 r185608 74 74 </ClCompile> 75 75 <ClCompile Include="..\Tests\WTF\MediaTime.cpp"> 76 <Filter>Tests\WTF</Filter> 77 </ClCompile> 78 <ClCompile Include="..\Tests\WTF\NakedPtr.cpp"> 76 79 <Filter>Tests\WTF</Filter> 77 80 </ClCompile> -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r185230 r185608 301 301 F6F49C6B15545CA70007F39D /* DOMWindowExtensionNoCache_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6F49C6615545C8D0007F39D /* DOMWindowExtensionNoCache_Bundle.cpp */; }; 302 302 F6FDDDD614241C6F004F1729 /* push-state.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F6FDDDD514241C48004F1729 /* push-state.html */; }; 303 FEB6F7511B2BA464009E4922 /* NakedPtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEB6F74E1B2BA44E009E4922 /* NakedPtr.cpp */; }; 303 304 /* End PBXBuildFile section */ 304 305 … … 729 730 F6FDDDD214241AD4004F1729 /* PrivateBrowsingPushStateNoHistoryCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateBrowsingPushStateNoHistoryCallback.cpp; sourceTree = "<group>"; }; 730 731 F6FDDDD514241C48004F1729 /* push-state.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "push-state.html"; sourceTree = "<group>"; }; 732 FEB6F74E1B2BA44E009E4922 /* NakedPtr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NakedPtr.cpp; sourceTree = "<group>"; }; 731 733 /* End PBXFileReference section */ 732 734 … … 1074 1076 0FC6C4CE141034AD005B7F0C /* MetaAllocator.cpp */, 1075 1077 93A427AC180DA60F00CD24D7 /* MoveOnly.h */, 1078 FEB6F74E1B2BA44E009E4922 /* NakedPtr.cpp */, 1076 1079 1AFDE6541953B2C000C48FFA /* Optional.cpp */, 1077 1080 0FC6C4CB141027E0005B7F0C /* RedBlackTree.cpp */, … … 1501 1504 7CCE7F031A411AE600447C4C /* NewFirstVisuallyNonEmptyLayoutFails.cpp in Sources */, 1502 1505 7CCE7F041A411AE600447C4C /* NewFirstVisuallyNonEmptyLayoutForImages.cpp in Sources */, 1506 FEB6F7511B2BA464009E4922 /* NakedPtr.cpp in Sources */, 1503 1507 7CCE7F051A411AE600447C4C /* NewFirstVisuallyNonEmptyLayoutFrames.cpp in Sources */, 1504 1508 7CCE7F251A411AF600447C4C /* OpenAndCloseWindow.mm in Sources */,
Note:
See TracChangeset
for help on using the changeset viewer.