StoreFloatToFloat32.js 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. // 5th store float in float32
  6. function AsmModule(stdlib,foreign,buffer) {
  7. "use asm";
  8. var m1 = stdlib.Math.fround;
  9. var func1 = foreign.fun1;
  10. //views
  11. var HEAP32 =new stdlib.Float32Array(buffer);
  12. function f1(){
  13. var x = m1(1.5);
  14. x = m1(x)
  15. HEAP32[1] = x;
  16. return m1(HEAP32[1])
  17. }
  18. return f1;
  19. }
  20. var global = {Math:Math,Float32Array:Float32Array}
  21. var env = {fun1:function(x1,x2,x3,x4,x5,x6,x7,x8){print(x1,x2,x3,x4,x5,x6,x7,x8);}, fun2:function(x,y){print(x,y);},x:155,i2:658,d1:68.25,d2:3.14156,f1:48.1523,f2:14896.2514}
  22. var buffer = new ArrayBuffer(1<<20);
  23. var asmModule = AsmModule(global,env,buffer);
  24. WScript.Echo(asmModule());
  25. WScript.Echo(asmModule());