Changeset 139599 in webkit


Ignore:
Timestamp:
Jan 14, 2013 2:44:47 AM (11 years ago)
Author:
haraken@chromium.org
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):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r139598 r139599  
     12013-01-14  Kentaro Hara  <haraken@chromium.org>
     2
     3        [V8] Call Isolate::GetCurrent() in a callback from WebCore
     4        https://bugs.webkit.org/show_bug.cgi?id=106766
     5
     6        Reviewed by Adam Barth.
     7
     8        The objective is to pass an Isolate everywhere.
     9        Given that a callback from WebCore is an entry point to V8,
     10        we can call Isolate::GetCurrent() at the head of the callback
     11        and pass it to other places. (In practice, handleEvent() is
     12        the only callback used in the current WebKit.)
     13
     14        No tests. No change in behavior.
     15
     16        * bindings/scripts/CodeGeneratorV8.pm:
     17        (GenerateCallbackImplementation):
     18        (NativeToJSValue):
     19        * bindings/scripts/test/V8/V8TestCallback.cpp:
     20        (WebCore::V8TestCallback::callbackWithNoParam):
     21        (WebCore::V8TestCallback::callbackWithClass1Param):
     22        (WebCore::V8TestCallback::callbackWithClass2Param):
     23        (WebCore::V8TestCallback::callbackWithStringList):
     24        (WebCore::V8TestCallback::callbackWithBoolean):
     25        (WebCore::V8TestCallback::callbackRequiresThisToPass):
     26
    1272013-01-14  Tommy Widenflycht  <tommyw@google.com>
    228
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r139469 r139599  
    33803380            foreach my $param (@params) {
    33813381                my $paramName = $param->name;
    3382                 push(@implContent, "    v8::Handle<v8::Value> ${paramName}Handle = " . NativeToJSValue($param, $paramName) . ";\n");
     3382                push(@implContent, "    v8::Handle<v8::Value> ${paramName}Handle = " . NativeToJSValue($param, $paramName, "v8::Handle<v8::Object>()", "v8::Isolate::GetCurrent()") . ";\n");
    33833383                push(@implContent, "    if (${paramName}Handle.IsEmpty()) {\n");
    33843384                push(@implContent, "        if (!isScriptControllerTerminating())\n");
     
    40244024    my $value = shift;
    40254025    my $getCreationContext = shift;
    4026     my $getCreationContextArg = $getCreationContext ? ", $getCreationContext" : "";
    40274026    my $getIsolate = shift;
    4028     my $getIsolateArg = $getIsolate ? ", $getIsolate" : "";
    40294027    my $getHolderContainer = shift;
    40304028    my $getHolderContainerArg = $getHolderContainer ? ", $getHolderContainer" : "";
     
    40324030    my $getScriptWrappableArg = $getScriptWrappable ? ", $getScriptWrappable" : "";
    40334031    my $returnHandleType = shift;
     4032    my $returnHandleTypeArg = $returnHandleType ? ", $returnHandleType" : "";
    40344033
    40354034    my $type = $signature->type;
     
    40434042    if ($signature->extendedAttributes->{"Reflect"} and ($type eq "unsigned long" or $type eq "unsigned short")) {
    40444043        $value =~ s/getUnsignedIntegralAttribute/getIntegralAttribute/g;
    4045         return "v8UnsignedInteger(std::max(0, " . $value . ")$getIsolateArg)";
     4044        return "v8UnsignedInteger(std::max(0, " . $value . "), $getIsolate)";
    40464045    }
    40474046
     
    40494048    # we use v8Integer() which has a fast small integer conversion check.
    40504049    my $nativeType = GetNativeType($type);
    4051     return "v8Integer($value$getIsolateArg)" if $nativeType eq "int";
    4052     return "v8UnsignedInteger($value$getIsolateArg)" if $nativeType eq "unsigned";
    4053 
    4054     return "v8DateOrNull($value$getIsolateArg)" if $type eq "Date";
     4050    return "v8Integer($value, $getIsolate)" if $nativeType eq "int";
     4051    return "v8UnsignedInteger($value, $getIsolate)" if $nativeType eq "unsigned";
     4052
     4053    return "v8DateOrNull($value, $getIsolate)" if $type eq "Date";
    40554054    # long long and unsigned long long are not representable in ECMAScript.
    40564055    return "v8::Number::New(static_cast<double>($value))" if $type eq "long long" or $type eq "unsigned long long" or $type eq "DOMTimeStamp";
     
    40614060        my $conv = $signature->extendedAttributes->{"TreatReturnedNullStringAs"};
    40624061        if (defined $conv) {
    4063             return "v8StringOrNull($value$getIsolateArg, $returnHandleType)" if $conv eq "Null";
    4064             return "v8StringOrUndefined($value$getIsolateArg, $returnHandleType)" if $conv eq "Undefined";
     4062            return "v8StringOrNull($value, $getIsolate$returnHandleTypeArg)" if $conv eq "Null";
     4063            return "v8StringOrUndefined($value, $getIsolate$returnHandleTypeArg)" if $conv eq "Undefined";
    40654064
    40664065            die "Unknown value for TreatReturnedNullStringAs extended attribute";
    40674066        }
    4068         return $getIsolate ? "v8String($value$getIsolateArg, $returnHandleType)" : "deprecatedV8String($value)";
     4067        return $getIsolate ? "v8String($value, $getIsolate$returnHandleTypeArg)" : "deprecatedV8String($value)";
    40694068    }
    40704069
     
    40824081            AddToImplIncludes("${arrayOrSequenceType}.h");
    40834082        }
    4084         return "v8Array(${value}${getIsolateArg})";
     4083        return "v8Array($value, $getIsolate)";
    40854084    }
    40864085
     
    40914090          return "toV8Fast($value$getHolderContainerArg$getScriptWrappableArg)";
    40924091      }
    4093       return "toV8($value$getCreationContextArg$getIsolateArg)";
     4092      return "toV8($value, $getCreationContext, $getIsolate)";
    40944093    }
    40954094
     
    41114110          return "toV8Fast($value$getHolderContainerArg$getScriptWrappableArg)";
    41124111    }
    4113     return "toV8($value$getCreationContextArg$getIsolateArg)";
     4112    return "toV8($value, $getCreationContext, $getIsolate)";
    41144113}
    41154114
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp

    r138841 r139599  
    8686    v8::Context::Scope scope(v8Context);
    8787
    88     v8::Handle<v8::Value> class1ParamHandle = toV8(class1Param);
     88    v8::Handle<v8::Value> class1ParamHandle = toV8(class1Param, v8::Handle<v8::Object>(), v8::Isolate::GetCurrent());
    8989    if (class1ParamHandle.IsEmpty()) {
    9090        if (!isScriptControllerTerminating())
     
    114114    v8::Context::Scope scope(v8Context);
    115115
    116     v8::Handle<v8::Value> class2ParamHandle = toV8(class2Param);
     116    v8::Handle<v8::Value> class2ParamHandle = toV8(class2Param, v8::Handle<v8::Object>(), v8::Isolate::GetCurrent());
    117117    if (class2ParamHandle.IsEmpty()) {
    118118        if (!isScriptControllerTerminating())
     
    120120        return true;
    121121    }
    122     v8::Handle<v8::Value> strArgHandle = deprecatedV8String(strArg);
     122    v8::Handle<v8::Value> strArgHandle = v8String(strArg, v8::Isolate::GetCurrent());
    123123    if (strArgHandle.IsEmpty()) {
    124124        if (!isScriptControllerTerminating())
     
    149149    v8::Context::Scope scope(v8Context);
    150150
    151     v8::Handle<v8::Value> listParamHandle = toV8(listParam);
     151    v8::Handle<v8::Value> listParamHandle = toV8(listParam, v8::Handle<v8::Object>(), v8::Isolate::GetCurrent());
    152152    if (listParamHandle.IsEmpty()) {
    153153        if (!isScriptControllerTerminating())
     
    177177    v8::Context::Scope scope(v8Context);
    178178
    179     v8::Handle<v8::Value> boolParamHandle = v8Boolean(boolParam);
     179    v8::Handle<v8::Value> boolParamHandle = v8Boolean(boolParam, v8::Isolate::GetCurrent());
    180180    if (boolParamHandle.IsEmpty()) {
    181181        if (!isScriptControllerTerminating())
     
    207207    v8::Context::Scope scope(v8Context);
    208208
    209     v8::Handle<v8::Value> class8ParamHandle = toV8(class8Param);
     209    v8::Handle<v8::Value> class8ParamHandle = toV8(class8Param, v8::Handle<v8::Object>(), v8::Isolate::GetCurrent());
    210210    if (class8ParamHandle.IsEmpty()) {
    211211        if (!isScriptControllerTerminating())
     
    213213        return true;
    214214    }
    215     v8::Handle<v8::Value> thisClassParamHandle = toV8(thisClassParam);
     215    v8::Handle<v8::Value> thisClassParamHandle = toV8(thisClassParam, v8::Handle<v8::Object>(), v8::Isolate::GetCurrent());
    216216    if (thisClassParamHandle.IsEmpty()) {
    217217        if (!isScriptControllerTerminating())
Note: See TracChangeset for help on using the changeset viewer.