Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Bootstrap from C#. Number formats #857

Merged
merged 22 commits into from
Oct 8, 2015

Conversation

iskiselev
Copy link
Member

Per discussion in #850.
Added new C# project - JSIL.mscorlib.
This project is translated on JSIL compilation and goes into Libraries folder. It is attached as bootstrap through JSIL.js.
Currently I've added (Numeric).ToString(format, ...) implementations through mono System.NumberFormatter.

Also this PR contains several StringBuilder method implementations, fix for #855.

To support Bootstrap from C# there was introduced several meta attributes:
JSRepaceAssemblyDeclaration - replaces JSIL.DeclareAssembly with passed string
JSOverrideAssemblyReference - overrides $asm... for passed type assembly with string and enclose all translation in self-execution function
JSImportType - include type from other assembly in translation as it was defined here. Should be use with JSProxy.
JSSuppressTypeDeclaration (#507) - TypeDeclarationsToSuppress moved here.

@kg, please wait for tests to pass. I've not yet check all of them - but we can already start review of this change.

@@ -8,7 +8,7 @@ if (!$jsilcore)

$jsilcore.getCurrentUICultureImpl = function () {
var language;
var svc = JSIL.Host.getService("window", false);
var svc = JSIL.Host.getService("window", true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need initialize current culture even in non-browser environment.
Really next line even tries to do it:

  if (svc) {
    language = svc.getNavigatorLanguage() || "en-US";
  } else {
    language = "en-US";
  }

But in non-browser environment it will not return null, but fail.
Now it will return null.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I probably got the second argument's boolean nature backwards... bools are awful.

@iskiselev
Copy link
Member Author

Currently JSImport works incorrectly on Linux.
Some methods of imported classes become UntranslatableFunctions. Right now will look on it.
I've now worked on Linux a lot before. @kg, what could you advice to debug JSIL on Linux (except of improving log output)?

@kg
Copy link
Member

kg commented Sep 18, 2015

I don't really know, I find Linux development a nightmare. None of the tools are good. That's why some of the 'doesn't work on Mono' tests are still broken.

@iskiselev
Copy link
Member Author

@kg, how could function go into FunctionCache?
On linux, when I'm try to translate imported functions, looks like some of them are already in cache with null records.
I start suppose that either JSIL key comparer works incorrectly - or Concurrent Dictionary returns incorrect records.

@iskiselev
Copy link
Member Author

It was my fault. Functions went to cache through GetSecondPass.
Last that I still don't understand - why it wasn't happen on windows (both mono and .net)?

@kg
Copy link
Member

kg commented Sep 19, 2015

Mono's ConcurrentDictionary is probably broken. They've had trivial bugs in their BCL containers before, and they take forever to get fixed (even when I provide a fix). It's a nightmare.

@iskiselev
Copy link
Member Author

Formatting test on travis still failing, but I've just tested it on my own Linux box - and it works as expected.
For now I'll mark this test (IntegerToStringFormatted) as FailsOnMono.

We need really upload somewhere all artifacts (at least Libraries folder and all tests *.out files) to be able test problems that happens on Travis - but it is another task.

It works incorrectly on Travis, but it works on my linux box.
@iskiselev
Copy link
Member Author

So, now I think this PR is stable enough and could be merged.
Probably we need write some additional checks for JSImport edge cases, but it may be better to do later - when we'll have some more experience with translated Bootstrap.

@iskiselev
Copy link
Member Author

Ops. Looks like I missed non-integer types. Let's see test results.

Added BitConverter.DoubleToInt64Bits.
@iskiselev iskiselev force-pushed the TranslatedBootstrap_NumberFormats branch from 87e7f5f to 83672d3 Compare September 19, 2015 03:30
@iskiselev
Copy link
Member Author

Get artifacts from travis and looked why test fails there.
Looks like NumberFormatter.Format, that contains switch with goto translated incorrectly if was compiled under mono.

@iskiselev iskiselev mentioned this pull request Oct 4, 2015
@iskiselev
Copy link
Member Author

@kg, could you review/discuss this? I'm working now on new implementation for #773, and it is done on top of it. It will be not so easy to make that PR fully independent, but I don't want make this PR too complicated.

@@ -0,0 +1,916 @@
//
// mono/mono/metadata/number-formatter.h
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please explicitly call out what license that was under in addition to the filename. Doesn't need the whole license prologue

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, good catch. Looks like this file, as it located in mono/mono folder is licensed only with LGPL or commercial license.
It is really bad, so we should check if it was previously located under anther directory pr ask them for using this file with another license :(

@kg
Copy link
Member

kg commented Oct 7, 2015

Took a second look at this and I don't see anything wrong other than the two nits I commented on. Thanks.

@iskiselev
Copy link
Member Author

PR fix applied. Also added double signature fix and .Parse(string, IFormatProvider) signature as it is used by NumberFormatter.

kg added a commit that referenced this pull request Oct 8, 2015
@kg kg merged commit 46ac870 into sq:master Oct 8, 2015
@iskiselev iskiselev deleted the TranslatedBootstrap_NumberFormats branch October 19, 2015 18:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants