Closed Bug 1740053 Opened 3 years ago Closed 3 years ago

Clean-up type definitions for VMFunctions

Categories

(Core :: JavaScript Engine: JIT, task, P1)

task

Tracking

()

RESOLVED FIXED
96 Branch
Tracking Status
firefox96 --- fixed

People

(Reporter: anba, Assigned: anba)

References

(Blocks 1 open bug)

Details

Attachments

(12 files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
  • TypeToDataType has specialisations for handles, which seems dubious because TypeToDataType is only used for return types and we never return handles.
  • There's quite a bit of repetition in TypeToDataType and TypeToArgProperties for gc::Cell types.
  • RootType::RootFunction doesn't seem to be necessary as a distinct type. RootType::RootObject should work just fine for TypeToRootType<HandleFunction>.
  • ...

TypeToDataType is only used for return types and because neither Handle nor
MutableHandle are valid return types, we don't need to provide TypeToDataType
specialisations for these types.

If we default to returning Type_Object for gc::Cell pointers, we can avoid some code duplication.

Depends on D130650

This should make it more obvious that this struct is only needed for return types.

Depends on D130651

Similar to the changes in part 2.

Depends on D130652

Depends on D130653

RootFunction doesn't seem to provide any benefits when compared to using RootObject.
TraceRoot(JSFunction**) calls gc::ConvertToBase(), which casts JSFunction down
to JSObject.

Depends on D130654

  • Add a general specialisation for pointers to pointers (Type_Pointer).
  • Add a general specialisation for MutableHandle (Type_Handle).

Depends on D130656

This prevents making a VM function which uses for example JS::BigInt* as an
out-param. This isn't valid because JS::BigInt* is already used by other VM
functions as an input parameter.

Depends on D130657

A const pointer can't be an out-param, so when we change the VM functions which
use JS::BigInt* as the last parameter to instead use const JS::BigInt*, we
no longer have to worry about conflicts between in- and out-parameters.

Depends on D130658

Similar to the changes in part 10.

Depends on D130659

Type_Object is also used for non-object types, like strings, symbols, and
bigints. Rename it to Type_Cell to indicate that also non-objec types are
possible. The name Type_Cell was chosen to match RootType::RootCell.

Pushed by andre.bargull@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/68264fdb6723
Part 1: Remove Handle and MutableHandle specialisations from TypeToDataType. r=jandem
https://hg.mozilla.org/integration/autoland/rev/6358f32ec818
Part 2: Remove duplication in TypeToDataType when returning pointers to GC cells. r=jandem
https://hg.mozilla.org/integration/autoland/rev/6b78ae6c6381
Part 3: Rename "TypeToDataType" to "ReturnTypeToDataType". r=jandem
https://hg.mozilla.org/integration/autoland/rev/4d819830b0f1
Part 4: Remove duplication in TypeToArgProperties for handles to GC cells. r=jandem
https://hg.mozilla.org/integration/autoland/rev/ca48cdb63ce6
Part 5: Fix a comment. r=jandem
https://hg.mozilla.org/integration/autoland/rev/069fd355ef6b
Part 6: Remove RootType::RootFunction. r=jandem
https://hg.mozilla.org/integration/autoland/rev/f628d5ce0d33
Part 7: Automatically derive root type from trace kind. r=jandem
https://hg.mozilla.org/integration/autoland/rev/2706136fedf7
Part 8: Remove duplication in OutParamToDataType. r=jandem
https://hg.mozilla.org/integration/autoland/rev/9a9d8e431e4e
Part 9: Prevent OutParamToDataType from making an input param to an implicit output param. r=jandem
https://hg.mozilla.org/integration/autoland/rev/f3300f17ce4e
Part 10: Use the type system to differentiate between input and output parameters. r=jandem
https://hg.mozilla.org/integration/autoland/rev/31b721186d70
Part 11: Use the type system for uint8_t* trailing parameters. r=jandem
https://hg.mozilla.org/integration/autoland/rev/3731bfaca711
Part 12: Rename DataType::Type_Object to Type_Cell. r=jandem
Severity: -- → S3
Priority: -- → P1
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: