Switch branches/tags
Nothing to show
Commits on Jul 14, 2010
  1. QJS: tfun ... -> this.fnbind(function ... )

    Reviewer: ben
    Disable Tests:
    Disable Push:
    committed Jul 14, 2010
  2. jspryme: initial add

    converting jsbeautify from old libfbjs repo to be the basis of the rewriter
    for jspryme
    Reviewer: ben
    Disable Tests:
    Disable Push:
    committed Jul 14, 2010
Commits on Dec 7, 2009
  1. Don't optimize future reserved keywords

    Summary: It breaks Safari. For example, class is a future reserved keyword,
             don't change b['class'] to b.class.
    Reviewed By: lklots
    Test Plan: test following js file:
               var a = {'class' : 10}
               It should not be changed to
               var a = {'class' : 10} print(a.class)
    Revert: OK
    DiffCamp Revision: 78052
    Feng Qian committed Dec 7, 2009
Commits on Nov 25, 2009
  1. More on code reduction

    Summary: The outcome of 'jsxmin --replace' is that these are some if
             statements with empty blocks. This diff removes these if statements
             if the expression has no side effects. Currently I can think of
             assignment and function calls have side-effects. Please let me know
             if you can think more expressions with side effects.
    Reviewed By: lklots
    Test Plan: Run all existing JS tests.
    Revert: OK
    DiffCamp Revision: 76206
    Feng Qian committed Nov 25, 2009
Commits on Nov 21, 2009
  1. Using fbconfig/fbmake for libfbjs and jsxmin

    Summary: 1. move applications from libfbjs to fbjstools directory;
             2. create fbconfg/fbmake TARGETS files for libfbjs and fbjstools;
             Fbconfig/fbmake's handling of flex/bison files are limited, the
             make rule for generated files does not include original directory
             in the path. To keep old libfbjs/Makefile working, I have to add a
             workaround, passing NOT_FBMAKE to g++. A simple fix in fbconfig
             should fix this issue by including the original directory in the
             include path.
    Reviewed By: marcel
    Test Plan: Tested fbconfig/fbmake both dbg|opt and run all JS tests.
    Revert: OK
    DiffCamp Revision: 75837
    Feng Qian committed Nov 21, 2009
Commits on Nov 20, 2009
  1. Integrate jsbeautify into jsxmin

    Summary: It is easier for deployment to have one binary. A few changes in
             this diff:
             1 use google-gflags, I made a copy of gflags from
             fbcode/external/gflags (it is insane), see my plan at the end;
             2.converted jsbeautify to jsxmin_reduction, the replacement patten
             is passed as:
               --replace "pattern1 : replacement1 , pattern2 : replacement2",
             assuming patterns and replacements don't contain ':' and ','. We
             can come up a different scheme if we hit cases where it does not
             3. each optimization is controlled by individual flag: e.g.,
             --novariable_renaming, --nocode_reduction, etc
             OK, back to gflags thing. the number of jsxmin files is growing, I
             feel we should move them out of libfbjs so that libfbjs is kept
             small and clean. I'd like to move these optimizations to an upper
             directory in fbcode and use fbconfig/fbmake. What do you guys
    Reviewed By: lklots
    Other Commenters: jsobel
    Test Plan: See my on-the-fly jsxminified sandbox
               JSXMIN has following options:
               --replace "Util.isDevelopmentEnvironment():false,__DEV__:0"
               --reduce --pretty --debug
    Revert: OK
    DiffCamp Revision: 75621
    Feng Qian committed Nov 20, 2009
Commits on Nov 19, 2009
  1. Better local variable renaming

    Summary: Instead of using 4-plus characters for new names, try to use
             shorter names as much as possible. On the largest JS package,
             better local renaming gives about 5% size reduction.
             The diff itself also re-organize jsxmin code towards OO style.
             Private global variable and property renaming is almost working, I
             am hitting some cases where variable/functions are named as private
             property (starting with '_'), but actually been used by files in
             different packages. By default, both property and global renaming
             are disable.
             This is the first cut. It is big so you can start reviewing it
             early. I will make more testing and improvement at the same time.
    Reviewed By: lklots
    Test Plan: Added several tests.
               My sandbox uses new jsxmin. You can browse it to see if you get any
               JS errors.
    Revert: OK
    DiffCamp Revision: 75098
    Feng Qian committed Nov 19, 2009
Commits on Nov 17, 2009
  1. Fix exponent parsing

    Summary: libfbjs fails on 1e+1. Fixing that. Also using strtod instead of
             sscanf, as strtod is more precise.
    Reviewed By: fengqian
    Test Plan: marcel@dev050 ~/libfbjs $ cat tests/exponent.js | ./jsbeautify
    Revert: OK
    DiffCamp Revision: 74797
    laverdet committed Nov 17, 2009
Commits on Oct 23, 2009
  1. Fix the buggy code dealing with nested if's

    Summary: Old code only deals with
             if () {
               if ()
             } else {}
             but does not handle following case properly
             if () {
               for () {
                 if ()
             } else {}
             This patch has a quick fix that always put braces around TRUE
             statements if there is an else part.
    Reviewed By: rdbayer
    Test Plan: The code triggers this bug is in html/js/lib/ui/sort.js
               See the reduced test case, and tested on my sandbox, it works
    Revert: OK
    DiffCamp Revision: 70592
    Feng Qian committed Oct 23, 2009
Commits on Oct 21, 2009
  1. Fix another bug that can generates infinite loops

    Summary: The code generation, render, can skip braces incorrectly, see the
             test case.
             Also add an opt mode with -O2 gcc option.
    Reviewed By: lklots
    Test Plan: See the test case.
    Revert: OK
    DiffCamp Revision: 70031
    Feng Qian committed Oct 21, 2009
  2. Small improvement in renaming

    Summary: Don't rename a variable if the orignal name is shorter then the new
             Also move 'unsafe' to 'g_unsafe'.
    Reviewed By: lklots
    Test Plan: Run the script and works fine.
    Revert: OK
    DiffCamp Revision: 70032
    Feng Qian committed Oct 21, 2009
Commits on Oct 20, 2009
  1. Don't rename for functions with eval and with

    Summary: We cannot get it right because the dynamic nature.
    Reviewed By: lklots
    Test Plan: Two tests are attached.
    Revert: OK
    DiffCamp Revision: 69923
    Feng Qian committed Oct 20, 2009
Commits on Oct 13, 2009
  1. Testing tool enhancement and more test cases

    Summary: 1. add a script that jsxminifies all JS files in a directory,
             useful for testing large JS benchmarks;
             See tools/README for more details.
             2. add three test cases in bugs/ directory, which are accepted by
             SpiderMonkey, but rejected by jsxmin parser
    Reviewed By: marcel
    Test Plan: A local tool for testing, run it locally on mozilla and v8
               benchmarks and it works fine.
    Revert: OK
    DiffCamp Revision: 68736
    Feng Qian committed Oct 13, 2009
Commits on Oct 12, 2009
  1. Fix instanceof on new line

    Summary: This expression fails to parse:
             instanceof bar);
             This is because of libfbjs's crazy virtual semicolon logic. I
             cleaned some of that up and fixed the bug.
             This also fixes the DEBUG_FLEX option, which is apparently broken.
             And it improves the dependencies in the Makefile so that make -j10
             works and the build goes really fast.
    Reviewed By: fengqian
    Test Plan: (foo
               instanceof bar);
    Revert: OK
    DiffCamp Revision: 68397
    laverdet committed Oct 12, 2009
Commits on Oct 10, 2009
  1. Fix a parsing issue

    Summary: The grammar of handling switch statement is slightly off the spec.
             jsxmin generated invalid code if no case statements are in a switch
             statement body.
             The patch makes the case clauses the same as spec.
             A test case is attached.
    Reviewed By: marcel
    Test Plan: See the test case. Currently jsxmin generates:
               case default::
    Revert: OK
    DiffCamp Revision: 68392
    Feng Qian committed Oct 10, 2009
  2. Improve the test script

    Summary: 1. renamed bin/ directory to tools/ directory
             2. make jsshell, jsxmin as options and the script accept a list or
             tests or test dirs and can recursively search for files end with
             'js' (case-insensitive) and verify.
             3. add a --pretty option to jsxmin for easy debugging
    Reviewed By: lklots
    Test Plan: Manually tested options and different flags.
    Revert: OK
    DiffCamp Revision: 68312
    Feng Qian committed Oct 10, 2009
Commits on Oct 6, 2009
  1. Rename function in local scope

    Summary: Fix the issue happened in the dev site where a function declared
             inside another function is not renamed, but references to the inner
             function name in the outer function got renamed.
             Also add several test cases reduced from real code.
             Added a test script bin/ and a SpiderMonkey 1.7
             executable so that we can run tests. The script does following:
             for each test in tests/ directory:
               1. run js test and get output
               2. run jsxmin on the test and run js on the result, get output
               3. if outputs from 1 and 2 are not the same, print out FAIL,
             otherwise, print out PASS
             Going forward, we can create more test cases and add many existing
             test cases from Mozilla, WebKit and V8.
    Reviewed By: lklots
    Test Plan: Apply the patch and invoke bin/, all tests should
    Revert: OK
    DiffCamp Revision: 67483
    Feng Qian committed Oct 6, 2009
Commits on Oct 2, 2009
  1. bypass libfbjs segfault on empty if(){}

    Got a segfault running jsxmin based of the parser in fbcode/libfbjs/ with head at 12964. A dynamic_cast was failing because the children nodes of an if statement are being populated incorrectly when the body of an if statement is empty.
      if (whatever) {
    Stack trace
      > #1  0x0000000000411d1c in fbjs::NodeIf::render (this=0x6b3b70,
      > guts=0x7fff31d312f0, indentation=1) at node.cpp:978
      > 978         while (firstStatement &&
      > dynamic_cast<NodeStatementList*>(firstStatement) != NULL
    I doubt that this is the 100% correct fix but it works.
    Reviewed By: marcel
    Test Plan:
    build ran jsxmin on test case and worked ok. ran jsxmin against all files no more segfaults.
    Revert: OK
    DiffCamp Revision: 65907
    Levy Klots committed Oct 2, 2009
Commits on Sep 29, 2009
  1. Fix function renaming issue in jsxmin #131179

    Summary: The first child node of a function declaration/expression is the
             function identifier (name), it should not be renamed.
    Reviewed By: epriestley
    Test Plan: Here is the test case:
               function test() {
                 var test =1;
               The output should preserve the function name as "test".
               Another verification step is to enable jsxmin in dev mode and
               load the home page, it should not throw a JS exception that
               "values not found" or something like that.
    Revert: OK
    DiffCamp Revision: 66603
    Feng Qian committed Sep 29, 2009
Commits on Aug 18, 2009
  1. Require braces while rendering nested if's

    Summary: libfbjs was changing the meaning of certain nested if statements by
             removing braces. Now when rendering we check to see if we're
             rendering an if statement with no else in which case braces are
             There is also a huge chance this doesn't work and I don't have any
             unit tests to confirm whether or not that's the case...
    Reviewed By: epriestley
    Test Plan: marcel@dev050 ~/libfbjs $ echo 'if(a){if(b)ab();}else nota();'  |
               ./jsbeautify -c
               if(a){if(b)ab();}else nota();
               marcel@dev050 ~/libfbjs $ echo 'if(a){if(b)ab();}else nota();'  |
               ./jsbeautify -c | ./jsbeautify
               if (a) {
                 if (b) {
               } else {
               marcel@dev050 ~/libfbjs $ echo 'if(a){if(b)ab();else 1;}else
               nota();'  | ./jsbeautify -c
               if(a)if(b)ab();else 1;else nota();
               marcel@dev050 ~/libfbjs $ echo 'if(a){if(b)ab();else 1;}else
               nota();'  | ./jsbeautify -c | ./jsbeautify
               if (a) {
                 if (b) {
                 } else {
               } else {
    Revert: OK
    DiffCamp Revision: 60166
    laverdet committed Aug 18, 2009
Commits on Aug 13, 2009
  1. Add "--unsafe" flag to jsxmin.

    Evan Priestley committed Aug 13, 2009
Commits on Jul 18, 2009
  1. Fix segfault in jsbeautify

    Summary: This was happening because the optimization was removing the `else`
             NULL placeholder. The default behavior on a NULL reduction is to
             remove it from childNodes, but that actually should only apply to
    Reviewed By: epriestley
    Test Plan: marcel@dev050 ~/libfbjs $ echo 'if (x) {} else if (0) {}' |
               ./jsbeautify -o
               if (x);
               marcel@dev050 ~/libfbjs $ echo 'false && foo(); bar();' |
               ./jsbeautify -o
    Revert: OK
    DiffCamp Revision: 55386
    laverdet committed Jul 18, 2009
Commits on Jul 12, 2009
  1. jsxmin

    Summary: Renames locals, arguments, and any identifier beginning with an "_"
             into some sort of garbage. I remap everything into the "_" scope
             since those identifiers are off-limits and subject to renaming
             anyway. This does mean that minification isn't stable (in the sense
             that min(min(JS)) is not the same as min(JS)) but this is academic
    Reviewed By: marcel
    Test Plan: Minified some files, no apparent breaks except when frickin'
               variables are hardcoded into string constants. I'm not going to
               roll this out immediately, but my plan for when I do is probably
               to tag like every file in the codebase with
               "@preserve-identifiers" or something and then make tomocchino or
               someone go vet them all I guess.
    Revert: OK
    DiffCamp Revision: 51209
    Evan Priestley committed Jul 12, 2009
Commits on Jul 10, 2009
  1. js intl parser: fix parse exception

    Summary: Including the filename when dealing with a parse exception.
    Reviewed By: marcel
    Test Plan: parse exceptions on multiple files more understandable
    DiffCamp Revision: 54371
    Levy Klots committed Jul 10, 2009
  2. js intl: verify tx() calls in c++ binary

    The php js parser is slow and prohibits, for example, running the parser as part of analyze_resources. Porting the parser to C++ makes the parsing two orders of magnitude faster.
    For this first round, just using the parser to verify that developers are using tx() correctly. The integration with analyze_resources is coming in a separate diff. Can also include it as part of an svn hook.
    Eventually the php parser will be completely deprecated in favor of this C++ binary (although the parser has problems with things like function() { a({})} which needs to be fixed before going forward).
    Reviewed By: marcel
    Test Plan:
    1. ran parser against all js files html/js and all checked out ok.
         2. inserted a bad call like tx(lklots) and correct, helpful error message cameup
    Revert: OK
    DiffCamp Revision: 54296
    Levy Klots committed Jul 10, 2009
  3. documentation change

    Reviewed By: no one
    Test Plan: none
    Revert Plan: ok
    laverdet committed Jul 10, 2009
  4. don't render line break at the start of pretty output

    jsbeautify always started with an extra linebreak, which was annoying
    Reviewed By: epriestley
    Test Plan: make
    Revert Plan: ok
    laverdet committed Jul 10, 2009
  5. Fix remove Flex default rule conditions

    Summary: There existed a few conditions in which Flex's default rule would
             be hit. I disabled the default rule and cleaned up the cases in
             which this would occur.
    Reviewed By: lklots
    Test Plan: var foo = bar.
               var foo = /test
    Revert: OK
    DiffCamp Revision: 54283
    laverdet committed Jul 10, 2009
  6. Fix line numbers in doc blocks

    Comments like:
     * honk
    would mess up line numbers.
    This is fixed now.
    Reviewed By: lklots
    Test Plan: see above
    Revert Plan: ok
    laverdet committed Jul 10, 2009
Commits on Jun 26, 2009
  1. Apply licences, fix build bugs, and some stuff to the readme.

    Dave missed a few spots for the licenses, so I'm getting those here. I scp'd this to a machine which has an up-to-date copy of gcc and fixed some build errors we didn't see on FC4. Also added a little bit of information to the readme.
    Reviewed By: epriestley
    Test Plan: make fbjs jsbeautify
    Revert Plan: ok
    laverdet committed Jun 26, 2009
Commits on Jun 24, 2009
  1. Quick optimization + extra debug information

    Remove NEVERMIND in favor if yyless(0), which is much quicker. Also make BEGIN and parsertok display real names.
    Reviewed By: no one
    Test Plan: jsexports on the code base
    Revert Plan: ok
    laverdet committed Jun 24, 2009
Commits on Jun 23, 2009
  1. Adding Apache License 2.0

    Reviewed By: marcel
    DaveFet committed Jun 23, 2009
Commits on Jun 18, 2009
  1. Cleanup stuff

    Summary: - Get rid of my custom flex input function. I realized later that
             flex had this functionality built-in, I just didn't know how to use
             - Catch errors in jsbeautify
             - Remove shady `identifier()` method; replace with `isValidlVal()`.
             - Remove duped code in parser.cpp
    Reviewed By: epriestley
    Test Plan: * Ran jsbeautify through valgrind to ensure I haven't done
               anything terrible
               * Made `jsexports` and ran analyze_resources with it, no
               * Built fbjs, no errors.
    Revert: OK
    DiffCamp Revision: 51202
    laverdet committed Jun 18, 2009
Commits on Jun 15, 2009
  1. Check in dtoa

    Summary: No longer rely on Makefile rules.
    Reviewed By: epriestley
    Test Plan: None.
    Revert: OK
    DiffCamp Revision: 50858
    laverdet committed Jun 15, 2009
  2. Comma optimizations and cleanup

    Summary: I added this reduction because I wanted to deobfuscate some code.
             Also includes suggestions from diff 49651.
    Reviewed By: epriestley
    Test Plan: make
    Revert: OK
    DiffCamp Revision: 50871
    laverdet committed Jun 15, 2009