Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Write all of the runtime in Dart. #310

Closed
1 of 8 tasks
ochafik opened this issue Sep 8, 2015 · 10 comments
Closed
1 of 8 tasks

Write all of the runtime in Dart. #310

ochafik opened this issue Sep 8, 2015 · 10 comments
Assignees

Comments

@ochafik
Copy link
Contributor

ochafik commented Sep 8, 2015

This would help with:

Note that this would imply changing the signature of a couple of vararg functions (dart.mixin, dart.fn...).

There are a couple of files that need translation as they produce modules:

The following helper file needs to be converted to a module:

Then the following file is used to support the current module system, so we might not want to translate them:

@ochafik
Copy link
Contributor Author

ochafik commented Sep 8, 2015

Started experimenting in branch passthrough-js-interop.

@jmesserly
Copy link
Contributor

yeah, the methods that take rest arguments are a problem. @jacob314 @vsmenon any thoughts on how we can encode it in such a way DDC understands?

Other than that, do we need anything other than the existing "JS" builtin? dart2js implements the SDK with it, so it should be pretty powerful.

edit: and we also have Jacob's interop which allows "direct" calls to JS members. So we might be able to use that as well.

@jmesserly
Copy link
Contributor

oh, we also need a way to get DDC to stop emitting type assertions around JS builtin expressions. Either fixing how we parse the type strings, or just trusting them and allow it to be assigned to any type.

@ochafik ochafik changed the title Support JS intrinsics to write all of the runtime in Dart. Write all of the runtime in Dart. Sep 14, 2015
@ochafik
Copy link
Contributor Author

ochafik commented Oct 16, 2015

Regarding rest params, seems like an ad-hoc annotation such as @varargs could do the trick.

Note that dart_runtime/* modules might need to be relocated under dart/* if they're generated from the sdk input, as there is quite a bit of dart: scheme-specific logic in the compiler (and dart_runtime is not a valid scheme as it contains an underscore).

That is, for instance, dart_runtime.js currently defines a dart_runtime/dart module, but we might want the new equivalent _dart_runtime.dart to define a dart._dart_runtime library instead.

Regarding what to start with:

  • It's unclear if any file is easier to translate before the others, as there's quite a bit of interdependence
  • We can adopt rest parameters in our .js helpers, which will make the translation slightly easier.

(side-note: JS('', '...') can be used to wrap arbitrary payload without type assertions, and its parsing limitations - no ES6 support - seem straightforward to work around)

@ochafik ochafik self-assigned this Oct 16, 2015
@jmesserly
Copy link
Contributor

@ochafik -- do you mind moving your checklist into the first message, or do you mind if I do it? GitHub has some special UI magic for checklists, but it only seems to kick in if they're in the initial bug report comment :)

@jacob314
Copy link
Contributor

Some support for rest parameters would be very helpful for JS interop in general. This is one of the of edge cases we have to hack around today.

@ochafik
Copy link
Contributor Author

ochafik commented Oct 16, 2015

@jacob314 I'm toying with a @varargs annotation for params + varargs(args) -> ...args argument transform in branch runtime-varargs, WDYT?

@jacob314
Copy link
Contributor

I'm open to adding '''@VarArgs''' to package:js with the other js interop specific annotations.

@ochafik
Copy link
Contributor Author

ochafik commented Oct 19, 2015

@jacob314 Cool! Filed dart-lang/sdk#24623 to track :-)

ochafik pushed a commit that referenced this issue Oct 29, 2015
Prepare for writing all the runtime in Dart:
- Move js runtime files to lib/runtime/dart (dart_runtime.js ->
dart/_runtime.js),
- Use rest params instead of arguments slicing in a couple of places.

BUG=#310
[email protected]

Review URL: https://codereview.chromium.org/1413683006 .
ochafik pushed a commit that referenced this issue Oct 29, 2015
Note: need new package:js release before merging this in (dart-lang/sdk#24623). Maybe it's time to think again about sneaking JsName + JsPeerInterface into it? (#135)

BUG=#310
[email protected]

Review URL: https://codereview.chromium.org/1424133007 .
ochafik pushed a commit that referenced this issue Dec 16, 2015
To match Dart style:
https://www.dartlang.org/effective-dart/style/#do-use-curly-braces-for-all-flow-control-structures

(also, that's the style we use in our .js runtime files, so that will help with diffs of the js->dart runtime migration from #310)

BUG=
[email protected]

Review URL: https://codereview.chromium.org/1524843002 .
ochafik pushed a commit that referenced this issue Jan 21, 2016
The following part files were ported from the original .js (lib/runtime/dart/_foo.js -> input_sdk/private/foo.dart):
- input_sdk/private/rtti.dart
- input_sdk/private/types.dart
- input_sdk/private/classes.dart
- input_sdk/private/errors.dart
- input_sdk/private/generators.dart
- input_sdk/private/operations.dart
- input_sdk/private/runtime.dart

Notes:
- Introduced genericTypeConstructor intrinsic: `JS('', '#(type)', genericTypeConstructor(List))` generates `core.List$(type)`
- Used new JS quasiquotes everywhere
- Depends on new internal `@JSExportName` annotation to alias symbols like dart.{as, is, const, assert, export, implements, throw, async, dynamic, void} (see https://codereview.chromium.org/1580413002/)

BUG=
[email protected]

Review URL: https://codereview.chromium.org/1530563003 .
@ochafik ochafik closed this as completed Jan 21, 2016
@jmesserly
Copy link
Contributor

🎉

nex3 pushed a commit to dart-lang/sdk that referenced this issue Aug 31, 2016
Prepare for writing all the runtime in Dart:
- Move js runtime files to lib/runtime/dart (dart_runtime.js ->
dart/_runtime.js),
- Use rest params instead of arguments slicing in a couple of places.

BUG=dart-archive/dev_compiler#310
[email protected]

Review URL: https://codereview.chromium.org/1413683006 .
nex3 pushed a commit to dart-lang/sdk that referenced this issue Aug 31, 2016
Note: need new package:js release before merging this in (#24623). Maybe it's time to think again about sneaking JsName + JsPeerInterface into it? (dart-archive/dev_compiler#135)

BUG=dart-archive/dev_compiler#310
[email protected]

Review URL: https://codereview.chromium.org/1424133007 .
nex3 pushed a commit to dart-lang/sdk that referenced this issue Aug 31, 2016
To match Dart style:
https://www.dartlang.org/effective-dart/style/#do-use-curly-braces-for-all-flow-control-structures

(also, that's the style we use in our .js runtime files, so that will help with diffs of the js->dart runtime migration from dart-archive/dev_compiler#310)

BUG=
[email protected]

Review URL: https://codereview.chromium.org/1524843002 .
nex3 pushed a commit to dart-lang/sdk that referenced this issue Aug 31, 2016
The following part files were ported from the original .js (lib/runtime/dart/_foo.js -> input_sdk/private/foo.dart):
- input_sdk/private/rtti.dart
- input_sdk/private/types.dart
- input_sdk/private/classes.dart
- input_sdk/private/errors.dart
- input_sdk/private/generators.dart
- input_sdk/private/operations.dart
- input_sdk/private/runtime.dart

Notes:
- Introduced genericTypeConstructor intrinsic: `JS('', '#(type)', genericTypeConstructor(List))` generates `core.List$(type)`
- Used new JS quasiquotes everywhere
- Depends on new internal `@JSExportName` annotation to alias symbols like dart.{as, is, const, assert, export, implements, throw, async, dynamic, void} (see https://codereview.chromium.org/1580413002/)

BUG=
[email protected]

Review URL: https://codereview.chromium.org/1530563003 .
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

3 participants