Changeset 49996 in webkit


Ignore:
Timestamp:
Oct 23, 2009 1:43:17 PM (14 years ago)
Author:
eric@webkit.org
Message:

2009-10-23 Jens Alfke <snej@chromium.org>

Reviewed by Dimitri Glazkov.

Slight optimizations to object returning and exception handling in generated V8 bindings.
https://bugs.webkit.org/show_bug.cgi?id=30599

  • bindings/scripts/CodeGeneratorV8.pm: Generate better code
  • bindings/v8/V8DOMWrapper.h: (WebCore::V8DOMWrapper::convertToV8Object): Added overload that takes a Ref<>
  • bindings/v8/custom/V8InspectorBackendCustom.cpp: (WebCore::CALLBACK_FUNC_DECL): Remove unnecessary template param to prevent compile error
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r49995 r49996  
     12009-10-23  Jens Alfke  <snej@chromium.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Slight optimizations to object returning and exception handling in generated V8 bindings.
     6        https://bugs.webkit.org/show_bug.cgi?id=30599
     7
     8        * bindings/scripts/CodeGeneratorV8.pm: Generate better code
     9        * bindings/v8/V8DOMWrapper.h:
     10        (WebCore::V8DOMWrapper::convertToV8Object): Added overload that takes a Ref<>
     11        * bindings/v8/custom/V8InspectorBackendCustom.cpp:
     12        (WebCore::CALLBACK_FUNC_DECL): Remove unnecessary template param to prevent compile error
     13
    1142009-10-23  Alpha Lam  <hclam@chromium.org>
    215
  • trunk/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r49949 r49996  
    308308    my $result = "";
    309309
    310     $result .= $indent . "if (ec) {\n";
     310    $result .= $indent . "if (UNLIKELY(ec)) {\n";
    311311    $result .= $indent . "    V8Proxy::setDOMException(ec);\n";
    312312    $result .= $indent . "    return v8::Handle<v8::Value>();\n";
     
    623623            push(@implContentDecls, "      return v8::Undefined();\n");
    624624        }
    625         push(@implContentDecls, "    $nativeType v = ");
    626 
    627         push(@implContentDecls, "$getterString;\n");
    628625
    629626        if ($useExceptions) {
     627            push(@implContentDecls, "    $nativeType v = ");
     628            push(@implContentDecls, "$getterString;\n");
    630629            push(@implContentDecls, GenerateSetDOMException("    "));
    631         }
    632 
    633         $result = "v";
     630            $result = "v";
     631            $result .= ".release()" if (IsRefPtrType($returnType));
     632        } else {
     633            # Can inline the function call into the return statement to avoid overhead of using a Ref<> temporary
     634            $result = $getterString;
     635        }
    634636    }
    635637
     
    647649        push(@implContentDecls, "    return V8DOMWrapper::convertToV8Object(V8ClassIndex::$classIndex, wrapper.release());\n");
    648650    } else {
    649         $result .= ".release()" if (IsRefPtrType($attrType));
    650651        push(@implContentDecls, "    " . ReturnNativeToJSValue($attribute->signature, $result, "    ").";\n");
    651652    }
     
    785786
    786787    if ($useExceptions) {
    787         push(@implContentDecls, "    V8Proxy::setDOMException(ec);\n");
     788        push(@implContentDecls, "    if (UNLIKELY(ec))\n");
     789        push(@implContentDecls, "        V8Proxy::setDOMException(ec);\n");
    788790    }
    789791
     
    918920            $implIncludes{"ExceptionCode.h"} = 1;
    919921            push(@implContentDecls,
    920 "    if (!$parameterName" . (BasicTypeCanFailConversion($parameter) ? "Ok" : "") . ") {\n" .
     922"    if (UNLIKELY(!$parameterName" . (BasicTypeCanFailConversion($parameter) ? "Ok" : "") . ")) {\n" .
    921923"      V8Proxy::setDOMException(TYPE_MISMATCH_ERR);\n" .
    922924"      return v8::Handle<v8::Value>();\n" .
     
    927929            $implIncludes{"ExceptionCode.h"} = 1;
    928930            push(@implContentDecls,
    929 "    if ($parameterName < 0) {\n" .
     931"    if (UNLIKELY($parameterName < 0)) {\n" .
    930932"      V8Proxy::setDOMException(INDEX_SIZE_ERR);\n" .
    931933"      return v8::Handle<v8::Value>();\n" .
     
    15381540    $functionString .= ")";
    15391541
     1542    my $return = "result";
     1543    my $returnIsRef = IsRefPtrType($returnType);
     1544
    15401545    if ($nodeToReturn) {
    15411546        # Special case for insertBefore, replaceChild, removeChild and
     
    15581563    } elsif ($returnsListItemPodType) {
    15591564        $result .= $indent . "RefPtr<SVGPODListItem<$nativeReturnType> > result = $functionString;\n";
     1565    } elsif (@{$function->raisesExceptions} or $returnsPodType or $isPodType or IsSVGTypeNeedingContextParameter($returnType)) {
     1566        $result .= $indent . $nativeReturnType . " result = $functionString;\n";
    15601567    } else {
    1561         $result .= $indent . $nativeReturnType . " result = $functionString;\n";
     1568        # Can inline the function call into the return statement to avoid overhead of using a Ref<> temporary
     1569        $return = $functionString;
     1570        $returnIsRef = 0;
    15621571    }
    15631572
     
    15651574        $result .= GenerateSetDOMException($indent);
    15661575    }
    1567 
    1568     my $return = "result";
    15691576
    15701577    # If the return type is a POD type, separate out the wrapper generation
     
    16101617        $result .= $indent . "return V8DOMWrapper::convertToV8Object(V8ClassIndex::$classIndex, wrapper.release());\n";
    16111618    } else {
    1612         $return .= ".release()" if (IsRefPtrType($returnType));
     1619        $return .= ".release()" if ($returnIsRef);
    16131620        $result .= $indent . ReturnNativeToJSValue($function->signature, $return, $indent) . ";\n";
    16141621    }
Note: See TracChangeset for help on using the changeset viewer.