Bug 68328 - The generator and intrinsic fields in HashTableValue/HashEntry and associated structures and methods are redundant
Summary: The generator and intrinsic fields in HashTableValue/HashEntry and associated...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Gavin Barraclough
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-18 15:40 PDT by Filip Pizlo
Modified: 2011-12-06 12:47 PST (History)
4 users (show)

See Also:


Attachments
Fix (34.56 KB, patch)
2011-12-06 00:02 PST, Gavin Barraclough
ggaren: review+
webkit-ews: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Filip Pizlo 2011-09-18 15:40:50 PDT
The old JIT optimizes intrinsics with ThunkGenerators, which are functions that when called generate JIT code that implements the intrinsic.  The DFG JIT optimizes intrinsics by weaving them through the optimizing compiler, and only exposes an enum (DFG::Intrinsic) for declaring whether or not an ExecutableBase is intrinsic, and if so, which intrinsic it is.

These two mechanism require some redundancy in runtime/Lookup.h, and various scripts for creating JS bindings.

A good solution would be to have one enum (say, in jit/JITIntrinsic.h).  The DFG would simply switch to using this intrinsic, while the old JIT would abandon passing function pointers and simply select the thunk generator by switching on the intrinsic enum.
Comment 1 Sam Weinig 2011-09-18 16:16:59 PDT
If you are going to make this change, it might also be a good opportunity to remove the special casing from the generation script and put it in the lookup definitions.
Comment 2 Gavin Barraclough 2011-09-19 13:23:18 PDT
It may even be that we don't want the enum to be in either JIT - we may with to make use of the intrinsic from the interpreter, in environments where we don't have the JIT enabled.  Maybe an enum in JSFunction?
Comment 3 Filip Pizlo 2011-09-19 13:24:31 PDT
(In reply to comment #2)
> It may even be that we don't want the enum to be in either JIT - we may with to make use of the intrinsic from the interpreter, in environments where we don't have the JIT enabled.  Maybe an enum in JSFunction?

How about runtime/Intrinsic.h?

The benefit of a separate file is that:

1) JSFunction and pretty much everything else in runtime/ is cluttered.

2) If we do our jobs correctly then this enum will get big. ;-)
Comment 4 Gavin Barraclough 2011-09-21 15:52:47 PDT
Agreed, that sounds even better.
Comment 5 Gavin Barraclough 2011-12-06 00:02:03 PST
Created attachment 117999 [details]
Fix
Comment 6 Geoffrey Garen 2011-12-06 00:14:04 PST
Comment on attachment 117999 [details]
Fix

r=me
Comment 7 Early Warning System Bot 2011-12-06 00:20:26 PST
Comment on attachment 117999 [details]
Fix

Attachment 117999 [details] did not pass qt-ews (qt):
Output: http://queues.webkit.org/results/10690698
Comment 8 Gyuyoung Kim 2011-12-06 00:29:04 PST
Comment on attachment 117999 [details]
Fix

Attachment 117999 [details] did not pass efl-ews (efl):
Output: http://queues.webkit.org/results/10728902
Comment 9 Gustavo Noronha (kov) 2011-12-06 00:42:21 PST
Comment on attachment 117999 [details]
Fix

Attachment 117999 [details] did not pass gtk-ews (gtk):
Output: http://queues.webkit.org/results/10729969
Comment 10 Sam Weinig 2011-12-06 07:31:26 PST
Comment on attachment 117999 [details]
Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=117999&action=review

> Source/JavaScriptCore/create_hash_table:276
>          if ($key eq "charCodeAt") {
>              $thunkGenerator = "charCodeAtThunkGenerator";
> -            $intrinsic = "DFG::CharCodeAtIntrinsic";
> +            $intrinsic = "CharCodeAtIntrinsic";

Do we really need this specialized check? Can't we just write CharCodeAtIntrinsic at the definition site?

> Source/JavaScriptCore/create_hash_table:323
>                  $thunkGenerator = "logThunkGenerator";
> +                $intrinsic = "LogIntrinsic";

Is $thunkGenerator still being used?
Comment 11 Gavin Barraclough 2011-12-06 11:51:30 PST
(In reply to comment #10)
> (From update of attachment 117999 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=117999&action=review
> 
> > Source/JavaScriptCore/create_hash_table:276
> >          if ($key eq "charCodeAt") {
> >              $thunkGenerator = "charCodeAtThunkGenerator";
> > -            $intrinsic = "DFG::CharCodeAtIntrinsic";
> > +            $intrinsic = "CharCodeAtIntrinsic";
> 
> Do we really need this specialized check? Can't we just write CharCodeAtIntrinsic at the definition site?

I definitely agree with you that we should do this, but I don't think it's a part of this change.  This patch changes the data in the table output by the create_hash_table script, you're proposing changing the data in the tables parsed in by create_hash_table, these two changes are completely independent of each other.
 
> > Source/JavaScriptCore/create_hash_table:323
> >                  $thunkGenerator = "logThunkGenerator";
> > +                $intrinsic = "LogIntrinsic";
> 
> Is $thunkGenerator still being used?

Ooops - meant to remove them - thanks! - will do.
Comment 12 Gavin Barraclough 2011-12-06 12:47:17 PST
Fixed in r102167