Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Unified Diff: Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

Issue 12251015: Merge 141034 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1364/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
===================================================================
--- Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (revision 142703)
+++ Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (working copy)
@@ -2618,6 +2618,9 @@
my $visibleInterfaceName = $codeGenerator->GetVisibleInterfaceName($interface);
my $v8InterfaceName = "V8$interfaceName";
my $nativeType = GetNativeTypeForConversions($interface);
+ my $vtableNameGnu = GetGnuVTableNameForInterface($interface);
+ my $vtableRefGnu = GetGnuVTableRefForInterface($interface);
+ my $vtableRefWin = GetWinVTableRefForInterface($interface);
# - Add default header template
push(@implContentHeader, GenerateImplementationContentHeader($interface));
@@ -2643,7 +2646,39 @@
$parentClassTemplate = $parentClass . "::GetTemplate()";
last;
}
+
+ push(@implContentDecls, <<END) if $vtableNameGnu;
+#if ENABLE(BINDING_INTEGRITY)
+#if defined(OS_WIN)
+#pragma warning(disable: 4483)
+extern "C" { extern void (*const ${vtableRefWin}[])(); }
+#else
+extern "C" { extern void* ${vtableNameGnu}[]; }
+#endif
+#endif // ENABLE(BINDING_INTEGRITY)
+
+END
+
push(@implContentDecls, "namespace WebCore {\n\n");
+
+ push(@implContentDecls, <<END) if $vtableNameGnu;
+#if ENABLE(BINDING_INTEGRITY)
+inline void checkTypeOrDieTrying(${nativeType}* object)
+{
+ void* actualVTablePointer = *(reinterpret_cast<void**>(object));
+#if defined(OS_WIN)
+ void* expectedVTablePointer = reinterpret_cast<void*>(${vtableRefWin});
+#else
+ void* expectedVTablePointer = ${vtableRefGnu};
+#endif
+ if (actualVTablePointer != expectedVTablePointer)
+ CRASH();
+}
+#endif // ENABLE(BINDING_INTEGRITY)
+
+END
+
+
my $parentClassInfo = $parentClass ? "&${parentClass}::info" : "0";
my $WrapperTypePrototype = $interface->isException ? "WrapperTypeErrorPrototype" : "WrapperTypeObjectPrototype";
@@ -3459,6 +3494,8 @@
return;
}
+ AddToImplIncludes("Frame.h");
+
my $createWrapperArgumentType = GetPassRefPtrType($nativeType);
my $baseType = BaseInterfaceName($interface);
@@ -3469,14 +3506,19 @@
ASSERT(impl.get());
ASSERT(DOMDataStore::getWrapper(impl.get(), isolate).IsEmpty());
END
- if ($baseType ne $interfaceName) {
- push(@implContent, <<END);
+
+ my $vtableNameGnu = GetGnuVTableNameForInterface($interface);
+ push(@implContent, <<END) if $vtableNameGnu;
+
+#if ENABLE(BINDING_INTEGRITY)
+ checkTypeOrDieTrying(impl.get());
+#endif
+END
+
+ push(@implContent, <<END) if ($baseType ne $interfaceName);
ASSERT(static_cast<void*>(static_cast<${baseType}*>(impl.get())) == static_cast<void*>(impl.get()));
END
- }
- AddToImplIncludes("Frame.h");
-
if ($codeGenerator->IsSubType($interface, "Document")) {
push(@implContent, <<END);
if (Frame* frame = impl->frame()) {
@@ -3509,11 +3551,123 @@
{
my $interface = shift;
my $interfaceName = $interface->name;
-
$interfaceName = $codeGenerator->GetSVGTypeNeedingTearOff($interfaceName) if $codeGenerator->IsSVGTypeNeedingTearOff($interfaceName);
- return $interfaceName;;
+ return $interfaceName;
}
+# See http://refspecs.linux-foundation.org/cxxabi-1.83.html.
+sub GetGnuVTableRefForInterface
+{
+ my $interface = shift;
+ my $vtableName = GetGnuVTableNameForInterface($interface);
+ if (!$vtableName) {
+ return "0";
+ }
+ my $typename = GetNativeTypeForConversions($interface);
+ my $offset = GetGnuVTableOffsetForType($typename);
+ return "&" . $vtableName . "[" . $offset . "]";
+}
+
+sub GetGnuVTableNameForInterface
+{
+ my $interface = shift;
+ my $typename = GetNativeTypeForConversions($interface);
+ my $templatePosition = index($typename, "<");
+ return "" if $templatePosition != -1;
+ return "" if GetImplementationLacksVTableForInterface($interface);
+ return "" if GetV8SkipVTableValidationForInterface($interface);
+ return "_ZTV" . GetGnuMangledNameForInterface($interface);
+}
+
+sub GetGnuMangledNameForInterface
+{
+ my $interface = shift;
+ my $typename = GetNativeTypeForConversions($interface);
+ my $templatePosition = index($typename, "<");
+ if ($templatePosition != -1) {
+ return "";
+ }
+ my $mangledType = length($typename) . $typename;
+ my $namespace = GetNamespaceForInterface($interface);
+ my $mangledNamespace = "N" . length($namespace) . $namespace;
+ return $mangledNamespace . $mangledType . "E";
+}
+
+sub GetGnuVTableOffsetForType
+{
+ my $typename = shift;
+ if ($typename eq "SVGAElement"
+ || $typename eq "SVGCircleElement"
+ || $typename eq "SVGClipPathElement"
+ || $typename eq "SVGDefsElement"
+ || $typename eq "SVGEllipseElement"
+ || $typename eq "SVGForeignObjectElement"
+ || $typename eq "SVGGElement"
+ || $typename eq "SVGImageElement"
+ || $typename eq "SVGLineElement"
+ || $typename eq "SVGPathElement"
+ || $typename eq "SVGPolyElement"
+ || $typename eq "SVGPolygonElement"
+ || $typename eq "SVGPolylineElement"
+ || $typename eq "SVGRectElement"
+ || $typename eq "SVGSVGElement"
+ || $typename eq "SVGStyledLocatableElement"
+ || $typename eq "SVGStyledTransformableElement"
+ || $typename eq "SVGSwitchElement"
+ || $typename eq "SVGTextElement"
+ || $typename eq "SVGTransformable"
+ || $typename eq "SVGUseElement") {
+ return "3";
+ }
+ return "2";
+}
+
+# See http://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B_Name_Mangling.
+sub GetWinVTableRefForInterface
+{
+ my $interface = shift;
+ my $vtableName = GetWinVTableNameForInterface($interface);
+ return 0 if !$vtableName;
+ return "__identifier(\"" . $vtableName . "\")";
+}
+
+sub GetWinVTableNameForInterface
+{
+ my $interface = shift;
+ my $typename = GetNativeTypeForConversions($interface);
+ my $templatePosition = index($typename, "<");
+ return "" if $templatePosition != -1;
+ return "" if GetImplementationLacksVTableForInterface($interface);
+ return "" if GetV8SkipVTableValidationForInterface($interface);
+ return "??_7" . GetWinMangledNameForInterface($interface) . "6B@";
+}
+
+sub GetWinMangledNameForInterface
+{
+ my $interface = shift;
+ my $typename = GetNativeTypeForConversions($interface);
+ my $namespace = GetNamespaceForInterface($interface);
+ return $typename . "@" . $namespace . "@@";
+}
+
+sub GetNamespaceForInterface
+{
+ my $interface = shift;
+ return $interface->extendedAttributes->{"ImplementationNamespace"} || "WebCore";
+}
+
+sub GetImplementationLacksVTableForInterface
+{
+ my $interface = shift;
+ return $interface->extendedAttributes->{"ImplementationLacksVTable"};
+}
+
+sub GetV8SkipVTableValidationForInterface
+{
+ my $interface = shift;
+ return $interface->extendedAttributes->{"V8SkipVTableValidation"};
+}
+
sub GenerateFunctionCallString()
{
my $function = shift;
« no previous file with comments | « Source/WebCore/Modules/webdatabase/SQLTransactionSync.idl ('k') | Source/WebCore/bindings/scripts/IDLAttributes.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698