Skip to content

Conversation

@Cellule
Copy link
Contributor

@Cellule Cellule commented Jan 9, 2018

Add unit test to regenerate bytecode header to verify that what the current build generates matches with the current header file.
Normalize line endings before serializing bytecode header for library code.

ChakraFull PR: https://devdiv.visualstudio.com/DevDiv/_git/Chakra/pullrequest/100648?_a=overview


This change is Reviewable

@MSLaguana
Copy link
Contributor

Looks like there's some issue with using the regex header from ch on xplat.

We also discussed issues with the source file (e.g. Intl.js) having different line endings since that isn't specified by gitattributes at the moment, did you come up with a solution for that?

bin/ch/ch.cpp Outdated
#include "stdafx.h"
#include "Core/AtomLockGuids.h"
#include <CommonPal.h>
#include <regex>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we not add dependency to regex and fix the line ending instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

One problem it might cause is that the character offset for line/col numbers in the generated byte code will be different then JS file on disk

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe @tcare 's investigation into line endings with gitattributes suggests that the strongest defense we have is core.autocrlf, which we can't enforce. When we regen bytecode, could we also re-write the file we are generating bytecode after normalization back to disk?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think modifying the source JS files is a great idea, since this process isn't just used for code that we own, it's also used on WWAs (and in particular I think on WWAs that are not on the developer's machine, but on the end-user's machine)

Copy link
Contributor

Choose a reason for hiding this comment

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

This is only intended to be for internal library js files. WWA shouldn't hit this path?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One problem it might cause is that the character offset for line/col numbers in the generated byte code will be different then JS file on disk

This is exactly the problem this is trying to solve. Since we can't reliably enforce line endings on the javascript files from source control. It is simpler to normalize the line endings so we get the same line offset wherever the header is generated.

When we regen bytecode, could we also re-write the file we are generating bytecode after normalization back to disk?

The line endings of the file is not actually wrong, it just depends on the setting on one's computer.

I don't think modifying the source JS files is a great idea, since this process isn't just used for code that we own, it's also used on WWAs (and in particular I think on WWAs that are not on the developer's machine, but on the end-user's machine)

This change is localized to our testing host, therefore, it doesn't affect WWA.

@Cellule
Copy link
Contributor Author

Cellule commented Jan 9, 2018

Looks like there's some issue with using the regex header from ch on xplat.

I will try with the solution I used in ChakraFull using strtok instead.

We also discussed issues with the source file (e.g. Intl.js) having different line endings since that isn't specified by gitattributes at the moment, did you come up with a solution for that?

After talking to @tcare it seems we don't have a reliable way to ensure those javascript files will always have the right line endings. Normalization upon consumption seemed the most reliable solution.

…arison.

Use strtok instead of regex to normalize files being serialized.
@chakrabot chakrabot merged commit ed00225 into chakra-core:release/1.7 Jan 10, 2018
chakrabot pushed a commit that referenced this pull request Jan 10, 2018
Merge pull request #4516 from Cellule:bytecodeheader_test

Add unit test to regenerate bytecode header to verify that what the current build generates matches with the current header file.
Normalize line endings before serializing bytecode header for library code.

ChakraFull PR: https://devdiv.visualstudio.com/DevDiv/_git/Chakra/pullrequest/100648?_a=overview
@Cellule Cellule deleted the bytecodeheader_test branch January 10, 2018 18:44
chakrabot pushed a commit that referenced this pull request Jan 10, 2018
Merge pull request #4516 from Cellule:bytecodeheader_test

Add unit test to regenerate bytecode header to verify that what the current build generates matches with the current header file.
Normalize line endings before serializing bytecode header for library code.

ChakraFull PR: https://devdiv.visualstudio.com/DevDiv/_git/Chakra/pullrequest/100648?_a=overview

# Conflicts:
#	lib/Runtime/Library/InJavascript/Intl.js.bc.32b.h
#	lib/Runtime/Library/InJavascript/Intl.js.bc.64b.h
#	lib/Runtime/Library/InJavascript/Intl.js.nojit.bc.32b.h
#	lib/Runtime/Library/InJavascript/Intl.js.nojit.bc.64b.h
chakrabot pushed a commit that referenced this pull request Jan 10, 2018
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.

6 participants