X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/14957cd040308e3eeec43d26bae5d76da13fcd85..a253471d7f8e4d91bf6ebabab00155c3b387d3d0:/create_hash_table diff --git a/create_hash_table b/create_hash_table index 59b574a..cb2809d 100755 --- a/create_hash_table +++ b/create_hash_table @@ -179,7 +179,6 @@ sub calcCompactHashSize() # Paul Hsieh's SuperFastHash # http://www.azillionmonkeys.com/qed/hash.html -# Ported from UString.. sub hashValue($) { my @chars = split(/ */, $_[0]); @@ -207,7 +206,7 @@ sub hashValue($) { } # Handle end case - if ($rem !=0) { + if ($rem != 0) { $hash += ord($chars[$s]); $hash ^= (leftShift($hash, 11)% $EXP2_32); $hash += $hash >> 17; @@ -221,11 +220,15 @@ sub hashValue($) { $hash += ($hash >> 15); $hash = $hash% $EXP2_32; $hash ^= (leftShift($hash, 10)% $EXP2_32); - - # this avoids ever returning a hash code of 0, since that is used to - # signal "hash not computed yet", using a value that is likely to be - # effectively the same as 0 when the low bits are masked - $hash = 0x80000000 if ($hash == 0); + + # Save 8 bits for StringImpl to use as flags. + $hash &= 0xffffff; + + # This avoids ever returning a hash code of 0, since that is used to + # signal "hash not computed yet". Setting the high bit maintains + # reasonable fidelity to a hash code of 0 because it is likely to yield + # exactly 0 when hash lookup masks out the high bits. + $hash = (0x80000000 >> 8) if ($hash == 0); return $hash; } @@ -247,11 +250,6 @@ sub output() { print "\nnamespace JSC {\n"; } my $count = scalar @keys + 1; - print "#if ENABLE(JIT)\n"; - print "#define THUNK_GENERATOR(generator) , generator\n"; - print "#else\n"; - print "#define THUNK_GENERATOR(generator)\n"; - print "#endif\n"; print "\nstatic const struct HashTableValue ${nameEntries}\[$count\] = {\n"; my $i = 0; foreach my $key (@keys) { @@ -271,29 +269,38 @@ sub output() { $firstValue = $values[$i]{"value"}; $secondValue = "0"; } - my $thunkGenerator = "0"; - if ($key eq "charCodeAt") { - $thunkGenerator = "charCodeAtThunkGenerator"; - } - if ($key eq "charAt") { - $thunkGenerator = "charAtThunkGenerator"; - } - if ($key eq "sqrt") { - $thunkGenerator = "sqrtThunkGenerator"; + + my $intrinsic = "NoIntrinsic"; + $intrinsic = "CharCodeAtIntrinsic" if ($key eq "charCodeAt"); + $intrinsic = "CharAtIntrinsic" if ($key eq "charAt"); + $intrinsic = "FromCharCodeIntrinsic" if ($key eq "fromCharCode"); + if ($name eq "mathTable") { + $intrinsic = "MinIntrinsic" if ($key eq "min"); + $intrinsic = "MaxIntrinsic" if ($key eq "max"); + $intrinsic = "SqrtIntrinsic" if ($key eq "sqrt"); + $intrinsic = "PowIntrinsic" if ($key eq "pow"); + $intrinsic = "AbsIntrinsic" if ($key eq "abs"); + $intrinsic = "FloorIntrinsic" if ($key eq "floor"); + $intrinsic = "CeilIntrinsic" if ($key eq "ceil"); + $intrinsic = "RoundIntrinsic" if ($key eq "round"); + $intrinsic = "ExpIntrinsic" if ($key eq "exp"); + $intrinsic = "LogIntrinsic" if ($key eq "log"); } - if ($key eq "pow") { - $thunkGenerator = "powThunkGenerator"; + if ($name eq "arrayPrototypeTable") { + $intrinsic = "ArrayPushIntrinsic" if ($key eq "push"); + $intrinsic = "ArrayPopIntrinsic" if ($key eq "pop"); } - if ($key eq "fromCharCode") { - $thunkGenerator = "fromCharCodeThunkGenerator"; + if ($name eq "regExpPrototypeTable") { + $intrinsic = "RegExpExecIntrinsic" if ($key eq "exec"); + $intrinsic = "RegExpTestIntrinsic" if ($key eq "test"); } - print " { \"$key\", $attrs[$i], (intptr_t)" . $castStr . "($firstValue), (intptr_t)$secondValue THUNK_GENERATOR($thunkGenerator) },\n"; + + print " { \"$key\", $attrs[$i], (intptr_t)" . $castStr . "($firstValue), (intptr_t)$secondValue, $intrinsic },\n"; $i++; } - print " { 0, 0, 0, 0 THUNK_GENERATOR(0) }\n"; + print " { 0, 0, 0, 0, NoIntrinsic }\n"; print "};\n\n"; - print "#undef THUNK_GENERATOR\n"; - print "extern JSC_CONST_HASHTABLE HashTable $name =\n"; + print "extern const struct HashTable $name =\n"; print " \{ $compactSize, $compactHashSizeMask, $nameEntries, 0 \};\n"; print "} // namespace\n"; }