Title: [139599] trunk/Source/WebCore
Revision
139599
Author
[email protected]
Date
2013-01-14 02:44:47 -0800 (Mon, 14 Jan 2013)

Log Message

[V8] Call Isolate::GetCurrent() in a callback from WebCore
https://bugs.webkit.org/show_bug.cgi?id=106766

Reviewed by Adam Barth.

The objective is to pass an Isolate everywhere.
Given that a callback from WebCore is an entry point to V8,
we can call Isolate::GetCurrent() at the head of the callback
and pass it to other places. (In practice, handleEvent() is
the only callback used in the current WebKit.)

No tests. No change in behavior.

* bindings/scripts/CodeGeneratorV8.pm:
(GenerateCallbackImplementation):
(NativeToJSValue):
* bindings/scripts/test/V8/V8TestCallback.cpp:
(WebCore::V8TestCallback::callbackWithNoParam):
(WebCore::V8TestCallback::callbackWithClass1Param):
(WebCore::V8TestCallback::callbackWithClass2Param):
(WebCore::V8TestCallback::callbackWithStringList):
(WebCore::V8TestCallback::callbackWithBoolean):
(WebCore::V8TestCallback::callbackRequiresThisToPass):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (139598 => 139599)


--- trunk/Source/WebCore/ChangeLog	2013-01-14 10:15:25 UTC (rev 139598)
+++ trunk/Source/WebCore/ChangeLog	2013-01-14 10:44:47 UTC (rev 139599)
@@ -1,3 +1,29 @@
+2013-01-14  Kentaro Hara  <[email protected]>
+
+        [V8] Call Isolate::GetCurrent() in a callback from WebCore
+        https://bugs.webkit.org/show_bug.cgi?id=106766
+
+        Reviewed by Adam Barth.
+
+        The objective is to pass an Isolate everywhere.
+        Given that a callback from WebCore is an entry point to V8,
+        we can call Isolate::GetCurrent() at the head of the callback
+        and pass it to other places. (In practice, handleEvent() is
+        the only callback used in the current WebKit.)
+
+        No tests. No change in behavior.
+
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateCallbackImplementation):
+        (NativeToJSValue):
+        * bindings/scripts/test/V8/V8TestCallback.cpp:
+        (WebCore::V8TestCallback::callbackWithNoParam):
+        (WebCore::V8TestCallback::callbackWithClass1Param):
+        (WebCore::V8TestCallback::callbackWithClass2Param):
+        (WebCore::V8TestCallback::callbackWithStringList):
+        (WebCore::V8TestCallback::callbackWithBoolean):
+        (WebCore::V8TestCallback::callbackRequiresThisToPass):
+
 2013-01-14  Tommy Widenflycht  <[email protected]>
 
         MediaStream API: Change MediaStream::readyState to an boolean attribute called ended.

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (139598 => 139599)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2013-01-14 10:15:25 UTC (rev 139598)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2013-01-14 10:44:47 UTC (rev 139599)
@@ -3379,7 +3379,7 @@
             @args = ();
             foreach my $param (@params) {
                 my $paramName = $param->name;
-                push(@implContent, "    v8::Handle<v8::Value> ${paramName}Handle = " . NativeToJSValue($param, $paramName) . ";\n");
+                push(@implContent, "    v8::Handle<v8::Value> ${paramName}Handle = " . NativeToJSValue($param, $paramName, "v8::Handle<v8::Object>()", "v8::Isolate::GetCurrent()") . ";\n");
                 push(@implContent, "    if (${paramName}Handle.IsEmpty()) {\n");
                 push(@implContent, "        if (!isScriptControllerTerminating())\n");
                 push(@implContent, "            CRASH();\n");
@@ -4023,14 +4023,13 @@
     my $signature = shift;
     my $value = shift;
     my $getCreationContext = shift;
-    my $getCreationContextArg = $getCreationContext ? ", $getCreationContext" : "";
     my $getIsolate = shift;
-    my $getIsolateArg = $getIsolate ? ", $getIsolate" : "";
     my $getHolderContainer = shift;
     my $getHolderContainerArg = $getHolderContainer ? ", $getHolderContainer" : "";
     my $getScriptWrappable = shift;
     my $getScriptWrappableArg = $getScriptWrappable ? ", $getScriptWrappable" : "";
     my $returnHandleType = shift;
+    my $returnHandleTypeArg = $returnHandleType ? ", $returnHandleType" : "";
 
     my $type = $signature->type;
 
@@ -4042,16 +4041,16 @@
     # should be returned instead.
     if ($signature->extendedAttributes->{"Reflect"} and ($type eq "unsigned long" or $type eq "unsigned short")) {
         $value =~ s/getUnsignedIntegralAttribute/getIntegralAttribute/g;
-        return "v8UnsignedInteger(std::max(0, " . $value . ")$getIsolateArg)";
+        return "v8UnsignedInteger(std::max(0, " . $value . "), $getIsolate)";
     }
 
     # For all the types where we use 'int' as the representation type,
     # we use v8Integer() which has a fast small integer conversion check.
     my $nativeType = GetNativeType($type);
-    return "v8Integer($value$getIsolateArg)" if $nativeType eq "int";
-    return "v8UnsignedInteger($value$getIsolateArg)" if $nativeType eq "unsigned";
+    return "v8Integer($value, $getIsolate)" if $nativeType eq "int";
+    return "v8UnsignedInteger($value, $getIsolate)" if $nativeType eq "unsigned";
 
-    return "v8DateOrNull($value$getIsolateArg)" if $type eq "Date";
+    return "v8DateOrNull($value, $getIsolate)" if $type eq "Date";
     # long long and unsigned long long are not representable in ECMAScript.
     return "v8::Number::New(static_cast<double>($value))" if $type eq "long long" or $type eq "unsigned long long" or $type eq "DOMTimeStamp";
     return "v8::Number::New($value)" if $codeGenerator->IsPrimitiveType($type);
@@ -4060,12 +4059,12 @@
     if ($codeGenerator->IsStringType($type)) {
         my $conv = $signature->extendedAttributes->{"TreatReturnedNullStringAs"};
         if (defined $conv) {
-            return "v8StringOrNull($value$getIsolateArg, $returnHandleType)" if $conv eq "Null";
-            return "v8StringOrUndefined($value$getIsolateArg, $returnHandleType)" if $conv eq "Undefined";
+            return "v8StringOrNull($value, $getIsolate$returnHandleTypeArg)" if $conv eq "Null";
+            return "v8StringOrUndefined($value, $getIsolate$returnHandleTypeArg)" if $conv eq "Undefined";
 
             die "Unknown value for TreatReturnedNullStringAs extended attribute";
         }
-        return $getIsolate ? "v8String($value$getIsolateArg, $returnHandleType)" : "deprecatedV8String($value)";
+        return $getIsolate ? "v8String($value, $getIsolate$returnHandleTypeArg)" : "deprecatedV8String($value)";
     }
 
     my $arrayType = $codeGenerator->GetArrayType($type);
@@ -4081,7 +4080,7 @@
             AddToImplIncludes(GetV8HeaderName($arrayOrSequenceType));
             AddToImplIncludes("${arrayOrSequenceType}.h");
         }
-        return "v8Array(${value}${getIsolateArg})";
+        return "v8Array($value, $getIsolate)";
     }
 
     AddIncludesForType($type);
@@ -4090,7 +4089,7 @@
       if ($getScriptWrappable) {
           return "toV8Fast($value$getHolderContainerArg$getScriptWrappableArg)";
       }
-      return "toV8($value$getCreationContextArg$getIsolateArg)";
+      return "toV8($value, $getCreationContext, $getIsolate)";
     }
 
     if ($type eq "EventListener") {
@@ -4110,7 +4109,7 @@
     if ($getScriptWrappable) {
           return "toV8Fast($value$getHolderContainerArg$getScriptWrappableArg)";
     }
-    return "toV8($value$getCreationContextArg$getIsolateArg)";
+    return "toV8($value, $getCreationContext, $getIsolate)";
 }
 
 sub WriteData

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp (139598 => 139599)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp	2013-01-14 10:15:25 UTC (rev 139598)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp	2013-01-14 10:44:47 UTC (rev 139599)
@@ -85,7 +85,7 @@
 
     v8::Context::Scope scope(v8Context);
 
-    v8::Handle<v8::Value> class1ParamHandle = toV8(class1Param);
+    v8::Handle<v8::Value> class1ParamHandle = toV8(class1Param, v8::Handle<v8::Object>(), v8::Isolate::GetCurrent());
     if (class1ParamHandle.IsEmpty()) {
         if (!isScriptControllerTerminating())
             CRASH();
@@ -113,13 +113,13 @@
 
     v8::Context::Scope scope(v8Context);
 
-    v8::Handle<v8::Value> class2ParamHandle = toV8(class2Param);
+    v8::Handle<v8::Value> class2ParamHandle = toV8(class2Param, v8::Handle<v8::Object>(), v8::Isolate::GetCurrent());
     if (class2ParamHandle.IsEmpty()) {
         if (!isScriptControllerTerminating())
             CRASH();
         return true;
     }
-    v8::Handle<v8::Value> strArgHandle = deprecatedV8String(strArg);
+    v8::Handle<v8::Value> strArgHandle = v8String(strArg, v8::Isolate::GetCurrent());
     if (strArgHandle.IsEmpty()) {
         if (!isScriptControllerTerminating())
             CRASH();
@@ -148,7 +148,7 @@
 
     v8::Context::Scope scope(v8Context);
 
-    v8::Handle<v8::Value> listParamHandle = toV8(listParam);
+    v8::Handle<v8::Value> listParamHandle = toV8(listParam, v8::Handle<v8::Object>(), v8::Isolate::GetCurrent());
     if (listParamHandle.IsEmpty()) {
         if (!isScriptControllerTerminating())
             CRASH();
@@ -176,7 +176,7 @@
 
     v8::Context::Scope scope(v8Context);
 
-    v8::Handle<v8::Value> boolParamHandle = v8Boolean(boolParam);
+    v8::Handle<v8::Value> boolParamHandle = v8Boolean(boolParam, v8::Isolate::GetCurrent());
     if (boolParamHandle.IsEmpty()) {
         if (!isScriptControllerTerminating())
             CRASH();
@@ -206,13 +206,13 @@
 
     v8::Context::Scope scope(v8Context);
 
-    v8::Handle<v8::Value> class8ParamHandle = toV8(class8Param);
+    v8::Handle<v8::Value> class8ParamHandle = toV8(class8Param, v8::Handle<v8::Object>(), v8::Isolate::GetCurrent());
     if (class8ParamHandle.IsEmpty()) {
         if (!isScriptControllerTerminating())
             CRASH();
         return true;
     }
-    v8::Handle<v8::Value> thisClassParamHandle = toV8(thisClassParam);
+    v8::Handle<v8::Value> thisClassParamHandle = toV8(thisClassParam, v8::Handle<v8::Object>(), v8::Isolate::GetCurrent());
     if (thisClassParamHandle.IsEmpty()) {
         if (!isScriptControllerTerminating())
             CRASH();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to