Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #8821 #15809

Merged
merged 2 commits into from
Nov 2, 2020
Merged

fix #8821 #15809

merged 2 commits into from
Nov 2, 2020

Conversation

ringabout
Copy link
Member

@ringabout ringabout commented Nov 1, 2020

Added a limitation for total length of range.

Choose 65535 because it generates 1 MB JS file for simple program

proc isInt32(i: int): bool =
  case i 
  of 1 .. 65536:
    return true
  else:
    return false

echo isInt32(1)

@Varriount
Copy link
Contributor

I read the original issue, but it wasn't very clear - why do "extreme" ranges cause JS memory issues?

@ringabout
Copy link
Member Author

It just causes compilation program crash when compiling Nim to JS. Because it generates too many labels for JS program. It's hard for me to optimize range branches. We should set a limitation in case that compilation program(NIm JS) crash.

@Araq Araq merged commit 544cb10 into nim-lang:devel Nov 2, 2020
narimiran pushed a commit that referenced this pull request Nov 5, 2020
(cherry picked from commit 544cb10)
@bung87
Copy link
Collaborator

bung87 commented Nov 20, 2020

Your reason to choose 65535 doesn't make sense, you will gonna explain why " 1 MB" and why "simple program"

@ringabout
Copy link
Member Author

ringabout commented Nov 20, 2020

It's a temporary solution and the issue is still open(The right solution is to change tranf.nim). If users have some problems with them, it's easy to change the number. This is not backported and won't be shipped until Nim 1.6.0 (namely many months).
See #8821 for details

@narimiran
Copy link
Member

This is not backported

I did backport it, because based on the PR title I thought it is a simple non-breaking fix. I can revert the backport if necessary.

@ringabout
Copy link
Member Author

Though this is not a proper fix. But I think it doesn't cause terrible issues. If users complain this, then we could revert this change or increase or decrease threshold. Anyway it prevents compilation program from crashing when compiling to JS.

PMunch pushed a commit to PMunch/Nim that referenced this pull request Jan 6, 2021
mildred pushed a commit to mildred/Nim that referenced this pull request Jan 11, 2021
irdassis pushed a commit to irdassis/Nim that referenced this pull request Mar 16, 2021
ardek66 pushed a commit to ardek66/Nim that referenced this pull request Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants