diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/create_hash_table | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/JavaScriptCore/create_hash_table')
-rwxr-xr-x | Source/JavaScriptCore/create_hash_table | 127 |
1 files changed, 89 insertions, 38 deletions
diff --git a/Source/JavaScriptCore/create_hash_table b/Source/JavaScriptCore/create_hash_table index 397976b06..d020f02db 100755 --- a/Source/JavaScriptCore/create_hash_table +++ b/Source/JavaScriptCore/create_hash_table @@ -5,7 +5,7 @@ # (c) 2000-2002 by Harri Porten <porten@kde.org> and # David Faure <faure@kde.org> # Modified (c) 2004 by Nikolas Zimmermann <wildfox@kde.org> -# Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. +# Copyright (C) 2007, 2008, 2009, 2015-2016 Apple Inc. All rights reserved. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -21,29 +21,24 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # - + use strict; +use Getopt::Long qw(:config pass_through); -my $file = $ARGV[0]; -shift; -my $includelookup = 0; - -# Use -i as second argument to make it include "Lookup.h" -$includelookup = 1 if (defined($ARGV[0]) && $ARGV[0] eq "-i"); - -# Use -n as second argument to make it use the third argument as namespace parameter ie. -n KDOM -my $useNameSpace = $ARGV[1] if (defined($ARGV[0]) && $ARGV[0] eq "-n"); +my $file = shift @ARGV or die("Must provide source file as final argument."); -print STDERR "Creating hashtable for $file\n"; open(IN, $file) or die "No such file $file"; my @keys = (); my @attrs = (); my @values = (); my @hashes = (); +my @table = (); +my @links = (); my $hasSetter = "false"; +my $includeBuiltin = 0; my $inside = 0; my $name; my $pefectHashSize; @@ -76,20 +71,42 @@ while (<IN>) { @attrs = (); @values = (); @hashes = (); + @table = (); + @links = (); + $includeBuiltin = 0; $inside = 0; - } elsif (/^(\S+)\s*(\S+)\s*([\w\|]*)\s*(\w*)\s*$/ && $inside) { + } elsif (/^(\S+)\s*(\S+)\s*([\w\|]*)\s*(\w*)\s*(\w*)\s*$/ && $inside) { my $key = $1; my $val = $2; my $att = $3; my $param = $4; + my $intrinsic = $5; push(@keys, $key); push(@attrs, length($att) > 0 ? $att : "0"); + if ($val eq "JSBuiltin") { + $includeBuiltin = 1; + } + if ($att =~ m/Function/) { - push(@values, { "type" => "Function", "function" => $val, "params" => (length($param) ? $param : "") }); + push(@values, { "type" => "Function", "function" => $val, "params" => (length($param) ? $param : ""), "intrinsic" => (length($intrinsic) ? $intrinsic : "NoIntrinsic") }); #printf STDERR "WARNING: Number of arguments missing for $key/$val\n" if (length($param) == 0); + } elsif ($att =~ m/Accessor/) { + my $get = $val; + my $put = "nullptr"; + $hasSetter = "true"; + push(@values, { "type" => "Accessor", "get" => $get, "put" => $put }); + } elsif ($att =~ m/CellProperty/) { + my $property = $val; + push(@values, { "type" => "CellProperty", "property" => $property }); + } elsif ($att =~ m/ClassStructure/) { + my $property = $val; + push(@values, { "type" => "ClassStructure", "property" => $property }); + } elsif ($att =~ m/PropertyCallback/) { + my $cback = $val; + push(@values, { "type" => "PropertyCallback", "cback" => $cback }); } elsif (length($att)) { my $get = $val; my $put = "0"; @@ -155,8 +172,6 @@ sub leftShift($$) { sub calcCompactHashSize() { - my @table = (); - my @links = (); my $compactHashSize = ceilingToPowerOf2(2 * @keys); $compactHashSizeMask = $compactHashSize - 1; $compactSize = $compactHashSize; @@ -247,27 +262,58 @@ sub output() { my $nameEntries = "${name}Values"; $nameEntries =~ s/:/_/g; + my $nameIndex = "${name}Index"; + $nameIndex =~ s/:/_/g; + + print "\n"; + print "#include \"JSCBuiltins.h\"\n" if ($includeBuiltin); + print "#include \"Lookup.h\"\n"; + print "\n"; + print "namespace JSC {\n"; + print "\n"; + if ($compactSize != 0) { + print "static const struct CompactHashIndex ${nameIndex}\[$compactSize\] = {\n"; + for (my $i = 0; $i < $compactSize; $i++) { + my $T = -1; + if (defined($table[$i])) { $T = $table[$i]; } + my $L = -1; + if (defined($links[$i])) { $L = $links[$i]; } + print " { $T, $L },\n"; + } + } else { + # MSVC dislikes empty arrays. + print "static const struct CompactHashIndex ${nameIndex}\[1\] = {\n"; + print " { 0, 0 }\n"; + } + print "};\n"; + print "\n"; - print "\n#include \"Lookup.h\"\n" if ($includelookup); - if ($useNameSpace) { - print "\nnamespace ${useNameSpace} {\n"; - print "\nusing namespace JSC;\n"; + my $packedSize = scalar @keys; + if ($packedSize != 0) { + print "static const struct HashTableValue ${nameEntries}\[$packedSize\] = {\n"; } else { - print "\nnamespace JSC {\n"; + # MSVC dislikes empty arrays. + print "static const struct HashTableValue ${nameEntries}\[1\] = {\n"; + print " { nullptr, 0, NoIntrinsic, { 0, 0 } }\n"; } - my $count = scalar @keys + 1; - print "\nstatic const struct HashTableValue ${nameEntries}\[$count\] = {\n"; my $i = 0; foreach my $key (@keys) { my $firstValue = ""; my $secondValue = ""; my $firstCastStr = ""; my $secondCastStr = ""; + my $intrinsic = "NoIntrinsic"; if ($values[$i]{"type"} eq "Function") { $firstCastStr = "static_cast<NativeFunction>"; $firstValue = $values[$i]{"function"}; $secondValue = $values[$i]{"params"}; + $intrinsic = $values[$i]{"intrinsic"}; + } elsif ($values[$i]{"type"} eq "Accessor") { + $firstCastStr = "static_cast<NativeFunction>"; + $secondCastStr = "static_cast<NativeFunction>"; + $firstValue = $values[$i]{"get"}; + $secondValue = $values[$i]{"put"}; } elsif ($values[$i]{"type"} eq "Property") { $firstCastStr = "static_cast<PropertySlot::GetValueFunc>"; $secondCastStr = "static_cast<PutPropertySlot::PutValueFunc>"; @@ -276,25 +322,30 @@ sub output() { } elsif ($values[$i]{"type"} eq "Lexer") { $firstValue = $values[$i]{"value"}; $secondValue = "0"; + } elsif ($values[$i]{"type"} eq "CellProperty" || $values[$i]{"type"} eq "ClassStructure") { + $values[$i]{"property"} =~ /\A([a-zA-Z0-9_]+)::(.*)\Z/ or die; + $firstValue = "OBJECT_OFFSETOF($1, $2)"; + $secondValue = "0"; + } elsif ($values[$i]{"type"} eq "PropertyCallback") { + $firstCastStr = "static_cast<LazyPropertyCallback>"; + $firstValue = $values[$i]{"cback"}; + $secondValue = "0"; } - my $intrinsic = "NoIntrinsic"; - $intrinsic = "FromCharCodeIntrinsic" if ($key eq "fromCharCode"); - if ($name eq "arrayPrototypeTable") { - $intrinsic = "ArrayPushIntrinsic" if ($key eq "push"); - $intrinsic = "ArrayPopIntrinsic" if ($key eq "pop"); + if ($values[$i]{"type"} eq "Function" && $firstValue eq "JSBuiltin") { + my $tableHead = $name; + $tableHead =~ s/Table$//; + print " { \"$key\", (($attrs[$i]) & ~Function) | Builtin, $intrinsic, { (intptr_t)static_cast<BuiltinGenerator>(" . $tableHead . ucfirst($key) . "CodeGenerator), (intptr_t)$secondValue } },\n"; } - if ($name eq "regExpPrototypeTable") { - $intrinsic = "RegExpExecIntrinsic" if ($key eq "exec"); - $intrinsic = "RegExpTestIntrinsic" if ($key eq "test"); + else { + print " { \"$key\", $attrs[$i], $intrinsic, { (intptr_t)" . $firstCastStr . "($firstValue), (intptr_t)" . $secondCastStr . "($secondValue) } },\n"; } - - print " { \"$key\", $attrs[$i], $intrinsic, (intptr_t)" . $firstCastStr . "($firstValue), (intptr_t)" . $secondCastStr . "($secondValue) },\n"; $i++; } - print " { 0, 0, NoIntrinsic, 0, 0 }\n"; - print "};\n\n"; - print "extern const struct HashTable $name =\n"; - print " \{ $compactSize, $compactHashSizeMask, $hasSetter, $nameEntries, 0 \};\n"; - print "} // namespace\n"; + print "};\n"; + print "\n"; + print "static const struct HashTable $name =\n"; + print " \{ $packedSize, $compactHashSizeMask, $hasSetter, $nameEntries, $nameIndex \};\n"; + print "\n"; + print "} // namespace JSC\n"; } |