summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/create_hash_table
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2016-05-24 08:28:08 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2016-05-24 08:28:08 +0000
commita4e969f4965059196ca948db781e52f7cfebf19e (patch)
tree6ca352808c8fdc52006a0f33f6ae3c593b23867d /Source/JavaScriptCore/create_hash_table
parent41386e9cb918eed93b3f13648cbef387e371e451 (diff)
downloadWebKitGtk-tarball-a4e969f4965059196ca948db781e52f7cfebf19e.tar.gz
webkitgtk-2.12.3webkitgtk-2.12.3
Diffstat (limited to 'Source/JavaScriptCore/create_hash_table')
-rwxr-xr-xSource/JavaScriptCore/create_hash_table88
1 files changed, 59 insertions, 29 deletions
diff --git a/Source/JavaScriptCore/create_hash_table b/Source/JavaScriptCore/create_hash_table
index 397976b06..792319444 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 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");
+my $file = shift @ARGV or die("Must provide source file as final argument.");
-# 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");
-
-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,6 +71,9 @@ while (<IN>) {
@attrs = ();
@values = ();
@hashes = ();
+ @table = ();
+ @links = ();
+ $includeBuiltin = 0;
$inside = 0;
} elsif (/^(\S+)\s*(\S+)\s*([\w\|]*)\s*(\w*)\s*$/ && $inside) {
@@ -87,9 +85,18 @@ while (<IN>) {
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 : "") });
#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 (length($att)) {
my $get = $val;
my $put = "0";
@@ -155,8 +162,6 @@ sub leftShift($$) {
sub calcCompactHashSize()
{
- my @table = ();
- my @links = ();
my $compactHashSize = ceilingToPowerOf2(2 * @keys);
$compactHashSizeMask = $compactHashSize - 1;
$compactSize = $compactHashSize;
@@ -247,16 +252,28 @@ sub output() {
my $nameEntries = "${name}Values";
$nameEntries =~ s/:/_/g;
-
- print "\n#include \"Lookup.h\"\n" if ($includelookup);
- if ($useNameSpace) {
- print "\nnamespace ${useNameSpace} {\n";
- print "\nusing namespace JSC;\n";
- } else {
- print "\nnamespace JSC {\n";
+ 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";
+ 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";
}
- my $count = scalar @keys + 1;
- print "\nstatic const struct HashTableValue ${nameEntries}\[$count\] = {\n";
+ print "};\n";
+ print "\n";
+
+ my $packedSize = scalar @keys;
+ print "static const struct HashTableValue ${nameEntries}\[$packedSize\] = {\n";
my $i = 0;
foreach my $key (@keys) {
my $firstValue = "";
@@ -268,6 +285,11 @@ sub output() {
$firstCastStr = "static_cast<NativeFunction>";
$firstValue = $values[$i]{"function"};
$secondValue = $values[$i]{"params"};
+ } 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>";
@@ -289,12 +311,20 @@ sub output() {
$intrinsic = "RegExpTestIntrinsic" if ($key eq "test");
}
- print " { \"$key\", $attrs[$i], $intrinsic, (intptr_t)" . $firstCastStr . "($firstValue), (intptr_t)" . $secondCastStr . "($secondValue) },\n";
+ 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";
+ }
+ else {
+ 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";
}