Introduces a faster long emulation.

Doubles are capable of holding integral numbers up to 53
bits without losing any precision. The new implementation
exploits this fact and uses double to represent long numbers
up to 45 bits and then switches to existing number triplet
representation for any number beyond that.

45 bits is chosen to simplify the conversion between two
representations as the number triplet representation uses two 22bit
slots for lower bits. Later the approach can be extended to
represent all numbers that fits into 53 bits.

The added overhead for big longs is very small. However it
uses much less memory for small longs and provides extremely
fast arithmetic operations.
Benchmarks results shows division is now 5170 times faster
in Firefox compared to earlier implementation[1].

The new implementation is also JsInterop friendly as small
numbers are real non-opaque numbers usable in javascript side
without any conversion. For example, even though time is
represented by long in java and double in javascript, both
uses less than 45 bits hence now interoperable.

I also experimented with doing optimistic arithmetic, meaning that,
without any type check I can assume SmallLong and do the arithmethic
operation. If it is not a SmallLong the result will never be in the
safe-range so we will fallback to BigLong arithmethic.
That appraoch provided around another 20% performance improvement
for small longs. However surprisingly the overhead for large numbers
significantly increased (slows down by half). It doesn't seem like
a good trade off so this patches uses explicit type check.


[1] Benchmark results:

            Chrome    Firefox    IE11
Add(Small): +84.96%   +227.51%   +7.59%
Add(Big):   -23.56%   -35.74%    -59.48%
Div(Small): +694.25%  +5170.80%  +717.81%
Div(Big):   -8.60%    -8.31%     -14.12%
Mul(Small): +242.78%  +785.87%   +33.80%
Mul(Big):   -9.12%    -8.55%     -38.86%
Shr(Small): -34.72%   -12.21%    -77.41%
Shr(Big):   -12.23%   -16.02%    -35.75%

Change-Id: I6fcf5650c9357a7255fc126d65f463138fa47e68
9 files changed
tree: 01b2315aaf4d11e588cdbfac06415a37cb28c131
  1. build_tools/
  2. dev/
  3. dev-ext/
  4. distro-source/
  5. doc/
  6. eclipse/
  7. elemental/
  8. jni/
  9. maven/
  10. reference/
  11. requestfactory/
  12. samples/
  13. servlet/
  14. tools/
  15. user/
  16. .gitignore
  17. build.xml
  18. common.ant.xml
  19. platforms.ant.xml
  20. README.md
README.md

## GWT

GWT is the official open source project for GWT releases 2.5 and onwards.

In this document you have some quick instructions to build the SDK from source code and to run its tests.

For a more detailed documentation visit our web site. If you are interested in contributing with the project, please read the Making GWT better section.

Building the GWT SDK:

  • In order to build GWT, java and ant are required in your system.

  • Optional: if you want to compile elemental you need python and g++ installed.

  • You need the gwt-tools checked out and up-to-date, and it will be placed by default at ../tools. You can override the default location using the GWT_TOOLS environment variable or passing -Dgwt.tools= argument to ant.

    Note: that you need svn to checkout gwt-tools

  • To create the SDK distribution files run:

    $ ant clean elemental dist-dev

    or if you don't have python and g++ just run

    $ ant clean dist-dev

    Then you will get all .jar files in the folder build/lib and the redistributable file will be: build/dist/gwt-0.0.0.zip

    if you want to specify a different version number run:

    $ ant elemental clean dist-dev -Dgwt.version=x.x.x

  • To compile everything including examples you have to run

    $ ant clean elemental dist

How to verify GWT code conventions:

  • In GWT we have some conventions so as all code written by contributors look similar being easier to review.

  • After you make any modification, run this command to compile everything including tests, to check APIs, and to verify code style. It shouldn't take longer than 3-4 minutes.

    $ ant compile.tests apicheck checkstyle -Dprecompile.disable=true

How to run GWT tests

  • Previously to run any test you have to set some environment variables to guarantee that they are run in the same conditions for all developers.

    In a Unix like platform you can use the export command:

    $ export TZ=America/Los_Angeles ANT_OPTS=-Dfile.encoding=UTF-8

    But in Windows™ you have to set the time-zone in your control panel, and the environment variables using the command set.

  • Finally you can run all test suites with the following command, but be prepared because it could take hours, and probably it would fail because of timeouts, etc.

    $ ant test

  • Thus, you might want to run only certain tests so as you can focus on checking the modifications you are working on.

    GWT build scripts use specific ant tasks and a bunch of system properties listed in the following table to specify which tests to run and how.

    For instance to run the task test in the module user you have to change to the user folder and run ant with the task as argument, adding any other property with the -D flag:

    $ ( cd user && ant test -Dtest.emma.htmlunit.disable=true ; cd .. )

    ModuleTaskProperty to skip
    devtesttest.dev.disable
    codeservertesttest.codeserver.disable
    usertesttest.user.disable
    usertest.nongwttest.nongwt.disable
    usertest.dev.htmlunittest.dev.htmlunit.disable
    usertest.web.htmlunittest.web.htmlunit.disable
    usertest.draft.htmlunittest.draft.htmlunit.disable
    usertest.nometa.htmlunittest.nometa.htmlunit.disable
    usertest.emma.htmlunittest.emma.htmlunit.disable
    usertest.coverage.htmlunittest.coverage.htmlunit.disable
    usertest.dev.seleniumtest.dev.selenium.disable
    usertest.web.seleniumtest.web.selenium.disable
    usertest.draft.seleniumtest.draft.selenium.disable
    usertest.nometa.seleniumtest.nometa.selenium.disable
    usertest.emma.seleniumtest.emma.selenium.disable
    requestfactorytest
    elementaltest
    elementaltest.nongwt
    elementaltest.dev.htmlunit
    elementaltest.web.htmlunit
    toolstest

    Additionally you can utilize some variables to filter which test to run in each task:

    ModuleTaskPropertiesDefault
    dev/coretestgwt.junit.testcase.dev.core.includes**/com/google/**/*Test.class
    gwt.junit.testcase.dev.core.excludes
    usertestgwt.junit.testcase.includes**/*Suite.class
    usertest.nongwtgwt.nongwt.testcase.includes**/*JreSuite.class
    gwt.nongwt.testcase.excludes
    usertest.web.* test.draft.* test.nometa.*gwt.junit.testcase.web.includes**/*Suite.class
    gwt.junit.testcase.web.excludes**/*JsInteropSuite.class,**/*JreSuite.class,***/OptimizedOnly*
    usertest.dev.* test.emma.*gwt.junit.testcase.dev.includes**/*Suite.class
    gwt.junit.testcase.dev.excludes**/*JsInteropSuite.class,**/*JreSuite.class,***/OptimizedOnly*

Examples

  • Run all tests in dev

    $ ( cd dev && ant test ; cd .. )

    Note: that the last `cd ..' is only needed in Windows.

  • There is another option to do the same but without changing to the module folder. We have to specify the module as the ant task, and the task as a target argument.

    $ ant dev -Dtarget=test

  • Run all tests in codeserver

    $ ( cd dev/codeserver && ant test )

    or

    $ ant codeserver -Dtarget=test -Dtest.dev.disable=true

    Note: that we disable dev tests because code server depends on dev and we don`t want to run its tests.

  • Run all tests in elemental:

    $ ( cd elemental && ant test.nongwt )

    or

    $ ant elemental -Dtarget=test -Dtest.dev.disable=true -Dtest.user.disable=true

    Note: that we have to disable dev and user tests because elemental depends on both.

  • Run all tests in tools

    $ ant tools -Dtarget=test -Dtest.dev.disable=true -Dtest.user.disable=true

  • Run only the JsniRefTest in dev

    $ ant dev -Dtarget=test \
        -Dgwt.junit.testcase.dev.core.includes="**/JsniRefTest.class"
    
  • Run a couple of tests in dev

    $ ant dev -Dtarget=test \
        -Dgwt.junit.testcase.dev.core.includes="**/JsniRefTest.class,**/JsParserTest.class"
    

    Note: that you have to use regular expressions separated by comma to select the test classes to execute.

  • Run all Jre tests in user, they should take not longer than 3min. We have two ways to run them. Although the second case is more complex it is here to know how disable properties work.

    $ ( cd user && ant test.nongwt )

    or

    $ ant user -Dtarget=test -Dtest.dev.disable=true \
           -Dtest.dev.htmlunit.disable=true \
           -Dtest.web.htmlunit.disable=true \
           -Dtest.coverage.htmlunit.disable=true \
           -Dtest.dev.selenium.disable=true \
           -Dtest.draft.htmlunit.disable=true \
           -Dtest.draft.selenium.disable=true \
           -Dtest.emma.htmlunit.disable=true \
           -Dtest.emma.selenium.disable=true \
           -Dtest.nometa.htmlunit.disable=true \
           -Dtest.nometa.selenium.disable=true \
           -Dtest.web.selenium.disable=true
    

    Note: that we have to set all disable variables but test.nongwt.disable

  • Run certain Jre tests in the user module.

    $ ( cd user && ant test.nongwt -Dgwt.nongwt.testcase.includes="**/I18NJreSuite.class" )

  • Run all GWT tests in user using htmlunit in dev mode.

    $ ( cd user && ant test.dev.htmlunit )