Title: [202981] trunk/Source/WebCore
Revision
202981
Author
[email protected]
Date
2016-07-08 08:52:57 -0700 (Fri, 08 Jul 2016)

Log Message

ExecState should be passed by reference in JS bindings generator for custom constructors
https://bugs.webkit.org/show_bug.cgi?id=159357

Reviewed by Youenn Fablet.

Pass ExecState as a reference instead of pointer in JS bindings
code for custom constructors.

* bindings/js/JSAudioContextCustom.cpp:
(WebCore::constructJSAudioContext):
* bindings/js/JSBlobCustom.cpp:
(WebCore::constructJSBlob):
* bindings/js/JSDOMFormDataCustom.cpp:
(WebCore::constructJSDOMFormData):
(WebCore::JSDOMFormData::append):
* bindings/js/JSDataCueCustom.cpp:
(WebCore::constructJSDataCue):
* bindings/js/JSFileCustom.cpp:
(WebCore::constructJSFile):
* bindings/js/JSHTMLElementCustom.cpp:
(WebCore::constructJSHTMLElement):
* bindings/js/JSMediaSessionCustom.cpp:
(WebCore::constructJSMediaSession):
* bindings/js/JSMutationObserverCustom.cpp:
(WebCore::constructJSMutationObserver):
* bindings/js/JSReadableStreamPrivateConstructors.cpp:
(WebCore::constructJSReadableStreamController):
(WebCore::constructJSReadableStreamReader):
* bindings/js/JSWebKitPointCustom.cpp:
(WebCore::constructJSWebKitPoint):
* bindings/js/JSWorkerCustom.cpp:
(WebCore::constructJSWorker):
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateHeader):
(GenerateConstructorDefinition):
* bindings/scripts/test/JS/JSTestCustomConstructorWithNoInterfaceObject.cpp:
(WebCore::JSTestCustomConstructorWithNoInterfaceObjectConstructor::construct):
* bindings/scripts/test/JS/JSTestCustomConstructorWithNoInterfaceObject.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (202980 => 202981)


--- trunk/Source/WebCore/ChangeLog	2016-07-08 15:48:23 UTC (rev 202980)
+++ trunk/Source/WebCore/ChangeLog	2016-07-08 15:52:57 UTC (rev 202981)
@@ -1,3 +1,44 @@
+2016-07-08  Nael Ouedraogo  <[email protected]>
+
+        ExecState should be passed by reference in JS bindings generator for custom constructors
+        https://bugs.webkit.org/show_bug.cgi?id=159357
+
+        Reviewed by Youenn Fablet.
+
+        Pass ExecState as a reference instead of pointer in JS bindings
+        code for custom constructors.
+
+        * bindings/js/JSAudioContextCustom.cpp:
+        (WebCore::constructJSAudioContext):
+        * bindings/js/JSBlobCustom.cpp:
+        (WebCore::constructJSBlob):
+        * bindings/js/JSDOMFormDataCustom.cpp:
+        (WebCore::constructJSDOMFormData):
+        (WebCore::JSDOMFormData::append):
+        * bindings/js/JSDataCueCustom.cpp:
+        (WebCore::constructJSDataCue):
+        * bindings/js/JSFileCustom.cpp:
+        (WebCore::constructJSFile):
+        * bindings/js/JSHTMLElementCustom.cpp:
+        (WebCore::constructJSHTMLElement):
+        * bindings/js/JSMediaSessionCustom.cpp:
+        (WebCore::constructJSMediaSession):
+        * bindings/js/JSMutationObserverCustom.cpp:
+        (WebCore::constructJSMutationObserver):
+        * bindings/js/JSReadableStreamPrivateConstructors.cpp:
+        (WebCore::constructJSReadableStreamController):
+        (WebCore::constructJSReadableStreamReader):
+        * bindings/js/JSWebKitPointCustom.cpp:
+        (WebCore::constructJSWebKitPoint):
+        * bindings/js/JSWorkerCustom.cpp:
+        (WebCore::constructJSWorker):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateHeader):
+        (GenerateConstructorDefinition):
+        * bindings/scripts/test/JS/JSTestCustomConstructorWithNoInterfaceObject.cpp:
+        (WebCore::JSTestCustomConstructorWithNoInterfaceObjectConstructor::construct):
+        * bindings/scripts/test/JS/JSTestCustomConstructorWithNoInterfaceObject.h:
+
 2016-07-08  Olivier Blin  <[email protected]>
 
         Expose crossOrigin attribute as a static property in HTMLMediaElement

Modified: trunk/Source/WebCore/bindings/js/JSAudioContextCustom.cpp (202980 => 202981)


--- trunk/Source/WebCore/bindings/js/JSAudioContextCustom.cpp	2016-07-08 15:48:23 UTC (rev 202980)
+++ trunk/Source/WebCore/bindings/js/JSAudioContextCustom.cpp	2016-07-08 15:52:57 UTC (rev 202981)
@@ -44,33 +44,33 @@
 
 namespace WebCore {
 
-EncodedJSValue JSC_HOST_CALL constructJSAudioContext(ExecState* exec)
+EncodedJSValue JSC_HOST_CALL constructJSAudioContext(ExecState& exec)
 {
-    DOMConstructorObject* jsConstructor = jsCast<DOMConstructorObject*>(exec->callee());
+    DOMConstructorObject* jsConstructor = jsCast<DOMConstructorObject*>(exec.callee());
     if (!jsConstructor)
-        return throwVMError(exec, createReferenceError(exec, "AudioContext constructor callee is unavailable"));
+        return throwVMError(&exec, createReferenceError(&exec, "AudioContext constructor callee is unavailable"));
 
     ScriptExecutionContext* scriptExecutionContext = jsConstructor->scriptExecutionContext();
     if (!scriptExecutionContext)
-        return throwVMError(exec, createReferenceError(exec, "AudioContext constructor script execution context is unavailable"));
-        
+        return throwVMError(&exec, createReferenceError(&exec, "AudioContext constructor script execution context is unavailable"));
+
     if (!is<Document>(*scriptExecutionContext))
-        return throwVMError(exec, createReferenceError(exec, "AudioContext constructor called in a script execution context which is not a document"));
+        return throwVMError(&exec, createReferenceError(&exec, "AudioContext constructor called in a script execution context which is not a document"));
 
     Document& document = downcast<Document>(*scriptExecutionContext);
 
     RefPtr<AudioContext> audioContext;
-    
-    if (!exec->argumentCount()) {
+
+    if (!exec.argumentCount()) {
         // Constructor for default AudioContext which talks to audio hardware.
         ExceptionCode ec = 0;
         audioContext = AudioContext::create(document, ec);
         if (ec) {
-            setDOMException(exec, ec);
+            setDOMException(&exec, ec);
             return JSValue::encode(JSValue());
         }
         if (!audioContext.get())
-            return throwVMError(exec, createSyntaxError(exec, "audio resources unavailable for AudioContext construction"));
+            return throwVMError(&exec, createSyntaxError(&exec, "audio resources unavailable for AudioContext construction"));
     } else {
 #if ENABLE(LEGACY_WEB_AUDIO)
         // Constructor for offline (render-target) AudioContext which renders into an AudioBuffer.
@@ -77,36 +77,36 @@
         // new AudioContext(in unsigned long numberOfChannels, in unsigned long numberOfFrames, in float sampleRate);
         document.addConsoleMessage(MessageSource::JS, MessageLevel::Warning, ASCIILiteral("Deprecated AudioContext constructor: use OfflineAudioContext instead"));
 
-        if (exec->argumentCount() < 3)
-            return throwVMError(exec, createNotEnoughArgumentsError(exec));
+        if (exec.argumentCount() < 3)
+            return throwVMError(&exec, createNotEnoughArgumentsError(&exec));
 
-        int32_t numberOfChannels = exec->argument(0).toInt32(exec);
-        int32_t numberOfFrames = exec->argument(1).toInt32(exec);
-        float sampleRate = exec->argument(2).toFloat(exec);
-        
+        int32_t numberOfChannels = exec.uncheckedArgument(0).toInt32(&exec);
+        int32_t numberOfFrames = exec.uncheckedArgument(1).toInt32(&exec);
+        float sampleRate = exec.uncheckedArgument(2).toFloat(&exec);
+
         if (numberOfChannels <= 0 || numberOfChannels > 10)
-            return throwVMError(exec, createSyntaxError(exec, "Invalid number of channels"));
+            return throwVMError(&exec, createSyntaxError(&exec, "Invalid number of channels"));
 
         if (numberOfFrames <= 0)
-            return throwVMError(exec, createSyntaxError(exec, "Invalid number of frames"));
+            return throwVMError(&exec, createSyntaxError(&exec, "Invalid number of frames"));
 
         if (sampleRate <= 0)
-            return throwVMError(exec, createSyntaxError(exec, "Invalid sample rate"));
+            return throwVMError(&exec, createSyntaxError(&exec, "Invalid sample rate"));
 
 
         ExceptionCode ec = 0;
         audioContext = OfflineAudioContext::create(document, numberOfChannels, numberOfFrames, sampleRate, ec);
         if (ec) {
-            setDOMException(exec, ec);
-            return throwVMError(exec, createSyntaxError(exec, "Error creating OfflineAudioContext"));
+            setDOMException(&exec, ec);
+            return throwVMError(&exec, createSyntaxError(&exec, "Error creating OfflineAudioContext"));
         }
 #else
-        return throwVMError(exec, createSyntaxError(exec, "Illegal AudioContext constructor"));
+        return throwVMError(&exec, createSyntaxError(&exec, "Illegal AudioContext constructor"));
 #endif
     }
 
     if (!audioContext)
-        return throwVMError(exec, createReferenceError(exec, "Error creating AudioContext"));
+        return throwVMError(&exec, createReferenceError(&exec, "Error creating AudioContext"));
 
     return JSValue::encode(CREATE_DOM_WRAPPER(jsConstructor->globalObject(), AudioContext, audioContext.releaseNonNull()));
 }

Modified: trunk/Source/WebCore/bindings/js/JSBlobCustom.cpp (202980 => 202981)


--- trunk/Source/WebCore/bindings/js/JSBlobCustom.cpp	2016-07-08 15:48:23 UTC (rev 202980)
+++ trunk/Source/WebCore/bindings/js/JSBlobCustom.cpp	2016-07-08 15:52:57 UTC (rev 202981)
@@ -60,20 +60,20 @@
     return wrap(state, globalObject, blob);
 }
 
-EncodedJSValue JSC_HOST_CALL constructJSBlob(ExecState* exec)
+EncodedJSValue JSC_HOST_CALL constructJSBlob(ExecState& exec)
 {
-    DOMConstructorObject* jsConstructor = jsCast<DOMConstructorObject*>(exec->callee());
+    DOMConstructorObject* jsConstructor = jsCast<DOMConstructorObject*>(exec.callee());
     ScriptExecutionContext* context = jsConstructor->scriptExecutionContext();
     if (!context)
-        return throwVMError(exec, createReferenceError(exec, "Blob constructor associated document is unavailable"));
+        return throwVMError(&exec, createReferenceError(&exec, "Blob constructor associated document is unavailable"));
 
-    if (!exec->argumentCount()) {
+    if (!exec.argumentCount()) {
         return JSValue::encode(CREATE_DOM_WRAPPER(jsConstructor->globalObject(), Blob, Blob::create()));
     }
 
     unsigned blobPartsLength = 0;
-    JSObject* blobParts = toJSSequence(exec, exec->argument(0), blobPartsLength);
-    if (exec->hadException())
+    JSObject* blobParts = toJSSequence(&exec, exec.uncheckedArgument(0), blobPartsLength);
+    if (exec.hadException())
         return JSValue::encode(jsUndefined());
     ASSERT(blobParts);
 
@@ -80,31 +80,31 @@
     String type;
     String endings = ASCIILiteral("transparent");
 
-    if (exec->argumentCount() > 1) {
-        JSValue blobPropertyBagValue = exec->argument(1);
+    if (exec.argumentCount() > 1) {
+        JSValue blobPropertyBagValue = exec.uncheckedArgument(1);
 
         if (!blobPropertyBagValue.isObject())
-            return throwVMTypeError(exec, "Second argument of the constructor is not of type Object");
+            return throwVMTypeError(&exec, "Second argument of the constructor is not of type Object");
 
         // Given the above test, this will always yield an object.
-        JSObject* blobPropertyBagObject = blobPropertyBagValue.toObject(exec);
+        JSObject* blobPropertyBagObject = blobPropertyBagValue.toObject(&exec);
 
         // Create the dictionary wrapper from the initializer object.
-        JSDictionary dictionary(exec, blobPropertyBagObject);
+        JSDictionary dictionary(&exec, blobPropertyBagObject);
 
         // Attempt to get the endings property and validate it.
         bool containsEndings = dictionary.get("endings", endings);
-        if (exec->hadException())
+        if (exec.hadException())
             return JSValue::encode(jsUndefined());
 
         if (containsEndings) {
             if (endings != "transparent" && endings != "native")
-                return throwVMTypeError(exec, "The endings property must be either \"transparent\" or \"native\"");
+                return throwVMTypeError(&exec, "The endings property must be either \"transparent\" or \"native\"");
         }
 
         // Attempt to get the type property.
         dictionary.get("type", type);
-        if (exec->hadException())
+        if (exec.hadException())
             return JSValue::encode(jsUndefined());
     }
 
@@ -113,8 +113,8 @@
     BlobBuilder blobBuilder;
 
     for (unsigned i = 0; i < blobPartsLength; ++i) {
-        JSValue item = blobParts->get(exec, i);
-        if (exec->hadException())
+        JSValue item = blobParts->get(&exec, i);
+        if (exec.hadException())
             return JSValue::encode(jsUndefined());
 
         if (ArrayBuffer* arrayBuffer = toArrayBuffer(item))
@@ -124,8 +124,8 @@
         else if (Blob* blob = JSBlob::toWrapped(item))
             blobBuilder.append(blob);
         else {
-            String string = item.toString(exec)->value(exec);
-            if (exec->hadException())
+            String string = item.toWTFString(&exec);
+            if (exec.hadException())
                 return JSValue::encode(jsUndefined());
             blobBuilder.append(string, endings);
         }

Modified: trunk/Source/WebCore/bindings/js/JSDOMFormDataCustom.cpp (202980 => 202981)


--- trunk/Source/WebCore/bindings/js/JSDOMFormDataCustom.cpp	2016-07-08 15:48:23 UTC (rev 202980)
+++ trunk/Source/WebCore/bindings/js/JSDOMFormDataCustom.cpp	2016-07-08 15:52:57 UTC (rev 202981)
@@ -46,27 +46,27 @@
     return value.inherits(JSHTMLFormElement::info()) ? &jsCast<JSHTMLFormElement*>(asObject(value))->wrapped() : nullptr;
 }
 
-EncodedJSValue JSC_HOST_CALL constructJSDOMFormData(ExecState* exec)
+EncodedJSValue JSC_HOST_CALL constructJSDOMFormData(ExecState& exec)
 {
-    DOMConstructorObject* jsConstructor = jsCast<DOMConstructorObject*>(exec->callee());
+    DOMConstructorObject* jsConstructor = jsCast<DOMConstructorObject*>(exec.callee());
 
-    HTMLFormElement* form = toHTMLFormElementOrNull(exec->argument(0));
+    HTMLFormElement* form = toHTMLFormElementOrNull(exec.argument(0));
     auto domFormData = DOMFormData::create(form);
-    return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), domFormData)));
+    return JSValue::encode(toJSNewlyCreated(&exec, jsConstructor->globalObject(), WTFMove(domFormData)));
 }
 
-JSValue JSDOMFormData::append(ExecState& state)
+JSValue JSDOMFormData::append(ExecState& exec)
 {
-    if (state.argumentCount() >= 2) {
-        String name = state.argument(0).toString(&state)->value(&state);
-        JSValue value = state.argument(1);
+    if (exec.argumentCount() >= 2) {
+        String name = exec.uncheckedArgument(0).toWTFString(&exec);
+        JSValue value = exec.uncheckedArgument(1);
         if (value.inherits(JSBlob::info())) {
             String filename;
-            if (state.argumentCount() >= 3 && !state.argument(2).isUndefinedOrNull())
-                filename = state.argument(2).toString(&state)->value(&state);
+            if (exec.argumentCount() >= 3 && !exec.uncheckedArgument(2).isUndefinedOrNull())
+                filename = exec.uncheckedArgument(2).toWTFString(&exec);
             wrapped().append(name, JSBlob::toWrapped(value), filename);
         } else
-            wrapped().append(name, value.toString(&state)->value(&state));
+            wrapped().append(name, value.toWTFString(&exec));
     }
 
     return jsUndefined();

Modified: trunk/Source/WebCore/bindings/js/JSDataCueCustom.cpp (202980 => 202981)


--- trunk/Source/WebCore/bindings/js/JSDataCueCustom.cpp	2016-07-08 15:48:23 UTC (rev 202980)
+++ trunk/Source/WebCore/bindings/js/JSDataCueCustom.cpp	2016-07-08 15:52:57 UTC (rev 202981)
@@ -47,61 +47,56 @@
 }
 #endif
 
-EncodedJSValue JSC_HOST_CALL constructJSDataCue(ExecState* exec)
+EncodedJSValue JSC_HOST_CALL constructJSDataCue(ExecState& exec)
 {
-    DOMConstructorObject* castedThis = jsCast<DOMConstructorObject*>(exec->callee());
-    if (exec->argumentCount() < 3)
-        return throwVMError(exec, createNotEnoughArgumentsError(exec));
+    DOMConstructorObject* castedThis = jsCast<DOMConstructorObject*>(exec.callee());
+    if (exec.argumentCount() < 3)
+        return throwVMError(&exec, createNotEnoughArgumentsError(&exec));
 
-    double startTime(exec->argument(0).toNumber(exec));
-    if (UNLIKELY(exec->hadException()))
+    double startTime(exec.uncheckedArgument(0).toNumber(&exec));
+    if (UNLIKELY(exec.hadException()))
         return JSValue::encode(jsUndefined());
 
-    double endTime(exec->argument(1).toNumber(exec));
-    if (UNLIKELY(exec->hadException()))
+    double endTime(exec.uncheckedArgument(1).toNumber(&exec));
+    if (UNLIKELY(exec.hadException()))
         return JSValue::encode(jsUndefined());
 
     ScriptExecutionContext* context = castedThis->scriptExecutionContext();
     if (!context)
-        return throwConstructorDocumentUnavailableError(*exec, "DataCue");
+        return throwConstructorDocumentUnavailableError(exec, "DataCue");
 
     String type;
 #if ENABLE(DATACUE_VALUE)
-    if (exec->argumentCount() > 3) {
-        if (!exec->argument(3).isString())
-            return throwVMTypeError(exec, ASCIILiteral("Second argument of the constructor is not of type String"));
-        type = exec->argument(3).getString(exec);
+    if (exec.argumentCount() > 3) {
+        if (!exec.uncheckedArgument(3).isString())
+            return throwVMTypeError(&exec, ASCIILiteral("Second argument of the constructor is not of type String"));
+        type = exec.uncheckedArgument(3).getString(&exec);
     }
 #endif
 
-    JSValue valueArgument = exec->argument(2);
+    JSValue valueArgument = exec.uncheckedArgument(2);
     if (valueArgument.isUndefinedOrNull()) {
-        setDOMException(exec, TypeError);
+        setDOMException(&exec, TypeError);
         return JSValue::encode(JSValue());
     }
 
-    RefPtr<DataCue> object;
     if (valueArgument.isCell() && valueArgument.asCell()->inherits(std::remove_pointer<JSArrayBuffer*>::type::info())) {
 
         ArrayBuffer* data = ""
-        if (UNLIKELY(exec->hadException()))
+        if (UNLIKELY(exec.hadException()))
             return JSValue::encode(jsUndefined());
 
         if (UNLIKELY(!data)) {
-            setDOMException(exec, TypeError);
+            setDOMException(&exec, TypeError);
             return JSValue::encode(jsUndefined());
         }
-
-        object = DataCue::create(*context, MediaTime::createWithDouble(startTime), MediaTime::createWithDouble(endTime), *data, type);
-
-        return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));
+        return JSValue::encode(CREATE_DOM_WRAPPER(castedThis->globalObject(), DataCue, DataCue::create(*context, MediaTime::createWithDouble(startTime), MediaTime::createWithDouble(endTime), *data, type)));
     }
 
 #if !ENABLE(DATACUE_VALUE)
     return JSValue::encode(jsUndefined());
 #else
-    object = DataCue::create(*context, MediaTime::createWithDouble(startTime), MediaTime::createWithDouble(endTime), valueArgument, type);
-    return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));
+    return JSValue::encode(CREATE_DOM_WRAPPER(castedThis->globalObject(), DataCue,DataCue::create(*context, MediaTime::createWithDouble(startTime), MediaTime::createWithDouble(endTime), valueArgument, type)));
 #endif
 }
 

Modified: trunk/Source/WebCore/bindings/js/JSFileCustom.cpp (202980 => 202981)


--- trunk/Source/WebCore/bindings/js/JSFileCustom.cpp	2016-07-08 15:48:23 UTC (rev 202980)
+++ trunk/Source/WebCore/bindings/js/JSFileCustom.cpp	2016-07-08 15:52:57 UTC (rev 202981)
@@ -40,47 +40,47 @@
 
 namespace WebCore {
 
-EncodedJSValue JSC_HOST_CALL constructJSFile(ExecState* exec)
+EncodedJSValue JSC_HOST_CALL constructJSFile(ExecState& exec)
 {
-    auto* constructor = jsCast<DOMConstructorObject*>(exec->callee());
+    auto* constructor = jsCast<DOMConstructorObject*>(exec.callee());
     ScriptExecutionContext* context = constructor->scriptExecutionContext();
     if (!context)
-        return throwVMError(exec, createReferenceError(exec, "File constructor associated document is unavailable"));
+        return throwVMError(&exec, createReferenceError(&exec, "File constructor associated document is unavailable"));
 
-    JSValue arg = exec->argument(0);
+    JSValue arg = exec.argument(0);
     if (arg.isUndefinedOrNull())
-        return throwVMTypeError(exec, ASCIILiteral("First argument to File constructor must be a valid sequence, was undefined or null"));
+        return throwVMTypeError(&exec, ASCIILiteral("First argument to File constructor must be a valid sequence, was undefined or null"));
 
     unsigned blobPartsLength = 0;
-    JSObject* blobParts = toJSSequence(exec, arg, blobPartsLength);
-    if (exec->hadException())
+    JSObject* blobParts = toJSSequence(&exec, arg, blobPartsLength);
+    if (exec.hadException())
         return JSValue::encode(jsUndefined());
     ASSERT(blobParts);
 
-    arg = exec->argument(1);
+    arg = exec.argument(1);
     if (arg.isUndefined())
-        return throwVMTypeError(exec, ASCIILiteral("Second argument to File constructor must be a valid string, was undefined"));
+        return throwVMTypeError(&exec, ASCIILiteral("Second argument to File constructor must be a valid string, was undefined"));
 
-    String filename = arg.toWTFString(exec).replace('/', ':');
-    if (exec->hadException())
+    String filename = arg.toWTFString(&exec).replace('/', ':');
+    if (exec.hadException())
         return JSValue::encode(jsUndefined());
 
     String normalizedType;
     Optional<int64_t> lastModified;
 
-    arg = exec->argument(2);
+    arg = exec.argument(2);
     if (!arg.isUndefinedOrNull()) {
         JSObject* filePropertyBagObject = arg.getObject();
         if (!filePropertyBagObject)
-            return throwVMTypeError(exec, ASCIILiteral("Third argument of the constructor is not of type Object"));
+            return throwVMTypeError(&exec, ASCIILiteral("Third argument of the constructor is not of type Object"));
 
         // Create the dictionary wrapper from the initializer object.
-        JSDictionary dictionary(exec, filePropertyBagObject);
+        JSDictionary dictionary(&exec, filePropertyBagObject);
 
         // Attempt to get the type property.
         String type;
         dictionary.get("type", type);
-        if (exec->hadException())
+        if (exec.hadException())
             return JSValue::encode(jsUndefined());
 
         normalizedType = Blob::normalizedContentType(type);
@@ -88,7 +88,7 @@
         // Only try to parse the lastModified date if there was not an invalid type argument.
         if (type.isEmpty() ||  !normalizedType.isEmpty()) {
             dictionary.get("lastModified", lastModified);
-            if (exec->hadException())
+            if (exec.hadException())
                 return JSValue::encode(jsUndefined());
         }
     }
@@ -99,8 +99,8 @@
     BlobBuilder blobBuilder;
 
     for (unsigned i = 0; i < blobPartsLength; ++i) {
-        JSValue item = blobParts->get(exec, i);
-        if (exec->hadException())
+        JSValue item = blobParts->get(&exec, i);
+        if (exec.hadException())
             return JSValue::encode(jsUndefined());
 
         if (ArrayBuffer* arrayBuffer = toArrayBuffer(item))
@@ -110,8 +110,8 @@
         else if (Blob* blob = JSBlob::toWrapped(item))
             blobBuilder.append(blob);
         else {
-            String string = item.toWTFString(exec);
-            if (exec->hadException())
+            String string = item.toWTFString(&exec);
+            if (exec.hadException())
                 return JSValue::encode(jsUndefined());
             blobBuilder.append(string, ASCIILiteral("transparent"));
         }

Modified: trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp (202980 => 202981)


--- trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp	2016-07-08 15:48:23 UTC (rev 202980)
+++ trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp	2016-07-08 15:52:57 UTC (rev 202981)
@@ -38,31 +38,31 @@
 using namespace JSC;
 
 #if ENABLE(CUSTOM_ELEMENTS)
-EncodedJSValue JSC_HOST_CALL constructJSHTMLElement(ExecState* state)
+EncodedJSValue JSC_HOST_CALL constructJSHTMLElement(ExecState& exec)
 {
-    auto* jsConstructor = jsCast<DOMConstructorObject*>(state->callee());
+    auto* jsConstructor = jsCast<DOMConstructorObject*>(exec.callee());
 
     auto* context = jsConstructor->scriptExecutionContext();
     if (!is<Document>(context))
-        return throwConstructorDocumentUnavailableError(*state, "HTMLElement");
+        return throwConstructorDocumentUnavailableError(exec, "HTMLElement");
     auto& document = downcast<Document>(*context);
 
     auto* definitions = document.customElementDefinitions();
     if (!definitions)
-        return throwVMTypeError(state, "new.target is not a valid custom element constructor");
+        return throwVMTypeError(&exec, "new.target is not a valid custom element constructor");
 
-    VM& vm = state->vm();
-    JSValue newTargetValue = state->thisValue();
+    VM& vm = exec.vm();
+    JSValue newTargetValue = exec.thisValue();
     JSObject* newTarget = newTargetValue.getObject();
     auto* elementInterface = definitions->findInterface(newTarget);
     if (!elementInterface)
-        return throwVMTypeError(state, "new.target does not define a custom element");
+        return throwVMTypeError(&exec, "new.target does not define a custom element");
 
     if (!elementInterface->isUpgradingElement()) {
         auto* globalObject = jsConstructor->globalObject();
         Structure* baseStructure = getDOMStructure<JSHTMLElement>(vm, *globalObject);
-        auto* newElementStructure = InternalFunction::createSubclassStructure(state, newTargetValue, baseStructure);
-        if (UNLIKELY(state->hadException()))
+        auto* newElementStructure = InternalFunction::createSubclassStructure(&exec, newTargetValue, baseStructure);
+        if (UNLIKELY(exec.hadException()))
             return JSValue::encode(jsUndefined());
 
         Ref<HTMLElement> element = HTMLElement::create(elementInterface->name(), document);
@@ -74,20 +74,20 @@
 
     Element* elementToUpgrade = elementInterface->lastElementInConstructionStack();
     if (!elementToUpgrade) {
-        throwInvalidStateError(*state, "Cannot instantiate a custom element inside its own constrcutor during upgrades");
+        throwInvalidStateError(exec, "Cannot instantiate a custom element inside its own constrcutor during upgrades");
         return JSValue::encode(jsUndefined());
     }
 
-    JSValue elementWrapperValue = toJS(state, jsConstructor->globalObject(), *elementToUpgrade);
+    JSValue elementWrapperValue = toJS(&exec, jsConstructor->globalObject(), *elementToUpgrade);
     ASSERT(elementWrapperValue.isObject());
 
-    JSValue newPrototype = newTarget->get(state, vm.propertyNames->prototype);
-    if (state->hadException())
+    JSValue newPrototype = newTarget->get(&exec, vm.propertyNames->prototype);
+    if (exec.hadException())
         return JSValue::encode(jsUndefined());
 
     JSObject* elementWrapperObject = asObject(elementWrapperValue);
-    JSObject::setPrototype(elementWrapperObject, state, newPrototype, true /* shouldThrowIfCantSet */);
-    if (state->hadException())
+    JSObject::setPrototype(elementWrapperObject, &exec, newPrototype, true /* shouldThrowIfCantSet */);
+    if (exec.hadException())
         return JSValue::encode(jsUndefined());
 
     elementInterface->didUpgradeLastElementInConstructionStack();

Modified: trunk/Source/WebCore/bindings/js/JSMediaSessionCustom.cpp (202980 => 202981)


--- trunk/Source/WebCore/bindings/js/JSMediaSessionCustom.cpp	2016-07-08 15:48:23 UTC (rev 202980)
+++ trunk/Source/WebCore/bindings/js/JSMediaSessionCustom.cpp	2016-07-08 15:52:57 UTC (rev 202981)
@@ -39,26 +39,26 @@
 
 namespace WebCore {
 
-EncodedJSValue JSC_HOST_CALL constructJSMediaSession(ExecState* exec)
+EncodedJSValue JSC_HOST_CALL constructJSMediaSession(ExecState& exec)
 {
-    auto* castedThis = jsCast<DOMConstructorObject*>(exec->callee());
+    auto* castedThis = jsCast<DOMConstructorObject*>(exec.callee());
+
     auto* context = castedThis->scriptExecutionContext();
     if (!context)
-        return throwConstructorDocumentUnavailableError(*exec, "MediaSession");
+        return throwConstructorDocumentUnavailableError(exec, "MediaSession");
 
     String kind;
-    if (exec->argumentCount() > 0) {
-        JSString* kindString = exec->argument(0).toString(exec);
-        if (UNLIKELY(exec->hadException()))
+    if (exec.argumentCount() > 0) {
+        JSString* kindString = exec.uncheckedArgument(0).toString(&exec);
+        if (UNLIKELY(exec.hadException()))
             return JSValue::encode(jsUndefined());
-        kind = kindString->value(exec);
+        kind = kindString->value(&exec);
         if (kind != "content" && kind != "transient" && kind != "transient-solo" && kind != "ambient")
-            return throwArgumentMustBeEnumError(*exec, 0, "kind", "MediaSession", nullptr, "\"content\", \"transient\", \"transient-solo\", \"ambient\"");
+            return throwArgumentMustBeEnumError(exec, 0, "kind", "MediaSession", nullptr, "\"content\", \"transient\", \"transient-solo\", \"ambient\"");
     } else
         kind = "content";
 
-    auto object = MediaSession::create(*context, kind);
-    return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object)));
+    return JSValue::encode(toJSNewlyCreated(&exec, castedThis->globalObject(), MediaSession::create(*context, kind)));
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/js/JSMutationObserverCustom.cpp (202980 => 202981)


--- trunk/Source/WebCore/bindings/js/JSMutationObserverCustom.cpp	2016-07-08 15:48:23 UTC (rev 202980)
+++ trunk/Source/WebCore/bindings/js/JSMutationObserverCustom.cpp	2016-07-08 15:52:57 UTC (rev 202981)
@@ -42,19 +42,19 @@
 
 namespace WebCore {
 
-EncodedJSValue JSC_HOST_CALL constructJSMutationObserver(ExecState* exec)
+EncodedJSValue JSC_HOST_CALL constructJSMutationObserver(ExecState& exec)
 {
-    if (exec->argumentCount() < 1)
-        return throwVMError(exec, createNotEnoughArgumentsError(exec));
+    if (exec.argumentCount() < 1)
+        return throwVMError(&exec, createNotEnoughArgumentsError(&exec));
 
-    JSObject* object = exec->argument(0).getObject();
+    JSObject* object = exec.uncheckedArgument(0).getObject();
     CallData callData;
     if (!object || object->methodTable()->getCallData(object, callData) == CallType::None)
-        return throwVMTypeError(exec, ASCIILiteral("Callback argument must be a function"));
+        return throwVMTypeError(&exec, ASCIILiteral("Callback argument must be a function"));
 
-    DOMConstructorObject* jsConstructor = jsCast<DOMConstructorObject*>(exec->callee());
+    DOMConstructorObject* jsConstructor = jsCast<DOMConstructorObject*>(exec.callee());
     auto callback = JSMutationCallback::create(object, jsConstructor->globalObject());
-    JSObject* jsObserver = asObject(toJS(exec, jsConstructor->globalObject(), MutationObserver::create(WTFMove(callback))));
+    JSObject* jsObserver = asObject(toJSNewlyCreated(&exec, jsConstructor->globalObject(), MutationObserver::create(WTFMove(callback))));
     PrivateName propertyName;
     jsObserver->putDirect(jsConstructor->globalObject()->vm(), propertyName, object);
     return JSValue::encode(jsObserver);

Modified: trunk/Source/WebCore/bindings/js/JSReadableStreamPrivateConstructors.cpp (202980 => 202981)


--- trunk/Source/WebCore/bindings/js/JSReadableStreamPrivateConstructors.cpp	2016-07-08 15:48:23 UTC (rev 202980)
+++ trunk/Source/WebCore/bindings/js/JSReadableStreamPrivateConstructors.cpp	2016-07-08 15:52:57 UTC (rev 202981)
@@ -34,23 +34,23 @@
 namespace WebCore {
 
 // Public JS ReadableStreamReder and ReadableStreamController constructor callbacks.
-EncodedJSValue JSC_HOST_CALL constructJSReadableStreamController(ExecState* state)
+EncodedJSValue JSC_HOST_CALL constructJSReadableStreamController(ExecState& exec)
 {
-    return throwVMTypeError(state, ASCIILiteral("ReadableStreamController constructor should not be called directly"));
+    return throwVMTypeError(&exec, ASCIILiteral("ReadableStreamController constructor should not be called directly"));
 }
 
-EncodedJSValue JSC_HOST_CALL constructJSReadableStreamReader(ExecState* state)
+EncodedJSValue JSC_HOST_CALL constructJSReadableStreamReader(ExecState& exec)
 {
-    JSReadableStream* stream = jsDynamicCast<JSReadableStream*>(state->argument(0));
+    JSReadableStream* stream = jsDynamicCast<JSReadableStream*>(exec.argument(0));
     if (!stream)
-        return throwVMTypeError(state, ASCIILiteral("ReadableStreamReader constructor parameter is not a ReadableStream"));
+        return throwVMTypeError(&exec, ASCIILiteral("ReadableStreamReader constructor parameter is not a ReadableStream"));
 
-    JSValue jsFunction = stream->get(state, Identifier::fromString(state, "getReader"));
+    JSValue jsFunction = stream->get(&exec, Identifier::fromString(&exec, "getReader"));
 
     CallData callData;
     CallType callType = getCallData(jsFunction, callData);
     MarkedArgumentBuffer noArguments;
-    return JSValue::encode(call(state, jsFunction, callType, callData, stream, noArguments));
+    return JSValue::encode(call(&exec, jsFunction, callType, callData, stream, noArguments));
 }
 
 // Private JS ReadableStreamReder and ReadableStreamController constructors.

Modified: trunk/Source/WebCore/bindings/js/JSWebKitPointCustom.cpp (202980 => 202981)


--- trunk/Source/WebCore/bindings/js/JSWebKitPointCustom.cpp	2016-07-08 15:48:23 UTC (rev 202980)
+++ trunk/Source/WebCore/bindings/js/JSWebKitPointCustom.cpp	2016-07-08 15:52:57 UTC (rev 202981)
@@ -32,21 +32,21 @@
 
 namespace WebCore {
 
-EncodedJSValue JSC_HOST_CALL constructJSWebKitPoint(ExecState* exec)
+EncodedJSValue JSC_HOST_CALL constructJSWebKitPoint(ExecState& exec)
 {
-    DOMConstructorObject* jsConstructor = jsCast<DOMConstructorObject*>(exec->callee());
+    DOMConstructorObject* jsConstructor = jsCast<DOMConstructorObject*>(exec.callee());
 
     float x = 0;
     float y = 0;
-    if (exec->argumentCount() >= 2) {
-        x = static_cast<float>(exec->argument(0).toNumber(exec));
-        y = static_cast<float>(exec->argument(1).toNumber(exec));
+    if (exec.argumentCount() >= 2) {
+        x = static_cast<float>(exec.uncheckedArgument(0).toNumber(&exec));
+        y = static_cast<float>(exec.uncheckedArgument(1).toNumber(&exec));
         if (std::isnan(x))
             x = 0;
         if (std::isnan(y))
             y = 0;
     }
-    return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), WebKitPoint::create(x, y))));
+    return JSValue::encode(asObject(toJSNewlyCreated(&exec, jsConstructor->globalObject(), WebKitPoint::create(x, y))));
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/js/JSWorkerCustom.cpp (202980 => 202981)


--- trunk/Source/WebCore/bindings/js/JSWorkerCustom.cpp	2016-07-08 15:48:23 UTC (rev 202980)
+++ trunk/Source/WebCore/bindings/js/JSWorkerCustom.cpp	2016-07-08 15:52:57 UTC (rev 202981)
@@ -45,29 +45,29 @@
     return handlePostMessage(state, &wrapped());
 }
 
-EncodedJSValue JSC_HOST_CALL constructJSWorker(ExecState* exec)
+EncodedJSValue JSC_HOST_CALL constructJSWorker(ExecState& exec)
 {
-    DOMConstructorObject* jsConstructor = jsCast<DOMConstructorObject*>(exec->callee());
+    DOMConstructorObject* jsConstructor = jsCast<DOMConstructorObject*>(exec.callee());
 
-    if (!exec->argumentCount())
-        return throwVMError(exec, createNotEnoughArgumentsError(exec));
+    if (!exec.argumentCount())
+        return throwVMError(&exec, createNotEnoughArgumentsError(&exec));
 
-    String scriptURL = exec->argument(0).toString(exec)->value(exec);
-    if (exec->hadException())
+    String scriptURL = exec.uncheckedArgument(0).toWTFString(&exec);
+    if (exec.hadException())
         return JSValue::encode(JSValue());
 
-    // See section 4.8.2 step 14 of WebWorkers for why this is the lexicalGlobalObject. 
-    DOMWindow& window = asJSDOMWindow(exec->lexicalGlobalObject())->wrapped();
+    // See section 4.8.2 step 14 of WebWorkers for why this is the lexicalGlobalObject.
+    DOMWindow& window = asJSDOMWindow(exec.lexicalGlobalObject())->wrapped();
 
     ExceptionCode ec = 0;
     ASSERT(window.document());
     RefPtr<Worker> worker = Worker::create(*window.document(), scriptURL, ec);
     if (ec) {
-        setDOMException(exec, ec);
+        setDOMException(&exec, ec);
         return JSValue::encode(JSValue());
     }
 
-    return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), *worker)));
+    return JSValue::encode(asObject(toJSNewlyCreated(&exec, jsConstructor->globalObject(), WTFMove(worker))));
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (202980 => 202981)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-07-08 15:48:23 UTC (rev 202980)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-07-08 15:52:57 UTC (rev 202981)
@@ -1534,7 +1534,7 @@
 
     if (HasCustomConstructor($interface)) {
         push(@headerContent, "// Custom constructor\n");
-        push(@headerContent, "JSC::EncodedJSValue JSC_HOST_CALL construct${className}(JSC::ExecState*);\n\n");
+        push(@headerContent, "JSC::EncodedJSValue JSC_HOST_CALL construct${className}(JSC::ExecState&);\n\n");
     }
 
     if ($codeGenerator->IsConstructorTemplate($interface, "Event")) {
@@ -5089,9 +5089,10 @@
 
 END
          } elsif ($interface->extendedAttributes->{"CustomConstructor"}) {
-            push(@$outputArray, "template<> JSC::EncodedJSValue JSC_HOST_CALL ${constructorClassName}::construct(JSC::ExecState* state)\n");
+            push(@$outputArray, "template<> JSC::EncodedJSValue JSC_HOST_CALL ${constructorClassName}::construct(JSC::ExecState* exec)\n");
             push(@$outputArray, "{\n");
-            push(@$outputArray, "    return construct${className}(state);\n");
+            push(@$outputArray, "    ASSERT(exec);\n");
+            push(@$outputArray, "    return construct${className}(*exec);\n");
             push(@$outputArray, "}\n\n");
          } elsif (!HasCustomConstructor($interface) && (!$interface->extendedAttributes->{"NamedConstructor"} || $generatingNamedConstructor)) {
             if ($function->{overloadedIndex} && $function->{overloadedIndex} > 0) {

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomConstructorWithNoInterfaceObject.cpp (202980 => 202981)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomConstructorWithNoInterfaceObject.cpp	2016-07-08 15:48:23 UTC (rev 202980)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomConstructorWithNoInterfaceObject.cpp	2016-07-08 15:52:57 UTC (rev 202981)
@@ -62,9 +62,10 @@
 
 typedef JSDOMConstructor<JSTestCustomConstructorWithNoInterfaceObject> JSTestCustomConstructorWithNoInterfaceObjectConstructor;
 
-template<> JSC::EncodedJSValue JSC_HOST_CALL JSTestCustomConstructorWithNoInterfaceObjectConstructor::construct(JSC::ExecState* state)
+template<> JSC::EncodedJSValue JSC_HOST_CALL JSTestCustomConstructorWithNoInterfaceObjectConstructor::construct(JSC::ExecState* exec)
 {
-    return constructJSTestCustomConstructorWithNoInterfaceObject(state);
+    ASSERT(exec);
+    return constructJSTestCustomConstructorWithNoInterfaceObject(*exec);
 }
 
 template<> JSValue JSTestCustomConstructorWithNoInterfaceObjectConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomConstructorWithNoInterfaceObject.h (202980 => 202981)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomConstructorWithNoInterfaceObject.h	2016-07-08 15:48:23 UTC (rev 202980)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomConstructorWithNoInterfaceObject.h	2016-07-08 15:52:57 UTC (rev 202981)
@@ -82,7 +82,7 @@
 inline JSC::JSValue toJSNewlyCreated(JSC::ExecState* state, JSDOMGlobalObject* globalObject, RefPtr<TestCustomConstructorWithNoInterfaceObject>&& impl) { return impl ? toJSNewlyCreated(state, globalObject, impl.releaseNonNull()) : JSC::jsNull(); }
 
 // Custom constructor
-JSC::EncodedJSValue JSC_HOST_CALL constructJSTestCustomConstructorWithNoInterfaceObject(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL constructJSTestCustomConstructorWithNoInterfaceObject(JSC::ExecState&);
 
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to