Created
          January 11, 2020 10:22 
        
      - 
      
- 
        Save thatisuday/3f9fc710fc29c5022ef0254de021c862 to your computer and use it in GitHub Desktop. 
    A simple asm.js module
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function Calc(stdlib, foreign, heap) { | |
| "use asm"; | |
| function add(a, b) { | |
| a = a|0; | |
| b = b|0; | |
| return (a + b)|0; | |
| } | |
| return { | |
| add: add | |
| }; | |
| } | |
| var stdlib = null; | |
| var foreign = null; | |
| var heap = new ArrayBuffer(1000); // 1kb | |
| // create module instance | |
| var calc = Calc( stdlib, foreign, heap ); | |
| // call `add` function | |
| var result = calc.add( 1, 2 ); | |
| console.log( result ); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment