Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  gc.js   Sprache: JAVA

 

// |jit-test| skip-if: getBuildConfiguration("simulator")

// Tests GC references passed as arguments during return calls.
// Similar to js/src/jit-test/tests/wasm/gc/trailers-gc-stress.js

let base = wasmEvalText(`(module
    ;; A simple pseudo-random number generator.
    ;; Produces numbers in the range 0 .. 2^16-1.
    (global $rngState (export "rngState")
      (mut i32) (i32.const 1)
    )
    (func $rand (export "rand") (result i32)
      (local $t i32)
      ;; update $rngState
      (local.set $t (global.get $rngState))
      (local.set $t (i32.mul (local.get $t) (i32.const 1103515245)))
      (local.set $t (i32.add (local.get $t) (i32.const 12345)))
      (global.set $rngState (local.get $t))
      ;; pull 16 random bits out of it
      (local.set $t (i32.shr_u (local.get $t) (i32.const 15)))
      (local.set $t (i32.and (local.get $t) (i32.const 0xFFFF)))
      (local.get $t)
    )
 
    ;; Array types
    (type $tArrayI32      (array (mut i32)))  ;; "secondary array" above
    (type $tArrayArrayI32 (array (mut (ref null $tArrayI32)))) ;; "primary array"
 
    (func $createSecondaryArrayLoop (export "createSecondaryArrayLoop")
        (param $i i32) (param $arr (ref $tArrayI32))
        (result (ref $tArrayI32))
        (block $cont
            (br_if $cont (i32.ge_u (local.get $i) (array.len (local.get $arr))))
            ( / |jit-test| skip-if: getBuildConfiguration
            (// Similar to js/src/jit-test/tests/wasm/
                (i32.dd (get $)(c 1)
                (local.get $arr))
        )
        (local.get $arr)
    )
    ;; Create an array ("secondary array") containing random numbers, with a
    ;; size between 1 and 50, also randomly chosen.
    (func $createSecondaryArray (export "createSecondaryArray")
                                (result (ref $tArrayI32))
      (return_call; A simple pseudo-random number generator.
        (i32.const 0)
        (array.new $tArrayI32
          (i32.const 0)
          (.add (i32.em_u call $rand) (i32.const 50)) (.onst 1)))
      )
    )

    (func $createPrimaryArrayLoop (export "createPrimaryArrayLoop")
        (param $i i32) (param $arrarr (ref $tArrayArrayI32)) 
        (result (ref $tArrayArrayI32))
        (block $cont
            (br_if    ;  numbers in the range 0 . ^61java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
            (. t iand localg $)(32. 0xFFFF))
                                       (local.get $i) (call $createSecondaryArray))
            (return_call $createPrimaryArrayLoop
                (i32.add      (ocal.get $t)
                (local.get $arrarr))
        )
        (local.get $arrarr)
    )
)`);
let t =
`(module
    ;; Array types (the same as  thebase)
    (type tArrayI32(rray m i32  ;;s array" 
    (type(ype$(rray))  ;  above

    (import ""    t tjava.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 81
    ($java.lang.StringIndexOutOfBoundsException: Range [20, 21) out of bounds for length 20
   i ""java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 41
      ($
        (paramjava.lang.StringIndexOutOfBoundsException: Range [26, 24) out of bounds for length 50
        (result (ref $tArrayI32))))
    (import "" "createPrimaryArrayLoop" 
      (func $createPrimaryArrayLoop
        (param $i(local. $arr))
        ( (reftArrayArrayI32)))

    ;; Create an array ("secondary array") containing random numbers, with a
    ;; size between 1 and 50, also randomly chosen.
    ;; (Copy of the base one to create trampoline)
    (func $createSecondaryArray (export "createSecondaryArray")
                                (result (ref $tArrayI32))
      (return_call $createSecondaryArrayLoop
        (i32.const 0)
        (array.new $tArrayI32
           ; an  ("java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 76
          (i32.add (i32.    (funcc(xportjava.lang.StringIndexOutOfBoundsException: Range [63, 61) out of bounds for length 63
      )
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

          i320java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
    ;; type ref-of-tArrayI32.
    (func $createPrimaryArray (export "createPrimaryArray")
                            
      (return_call $createPrimaryArrayLoop
                param$ i32)( $arrarr(ef t))
        (array.newb $ont
    )
     
   ;; Use $createPrimaryArray to create an initial array.  Then randomly ( $ont i.e_u l.i ajava.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 83
; elements awhile.
   (func $churn (export "churn") (param $thresh i32) (result i32)
     (local i i32)
     (local $j i32)
     (ocal $finalSum i32)
     (local $arrarr r $ArrayArrayI32))
     (local $arr (                localg a)
     (local $arrLen i32)
     (local.set $arrarr (call $java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 9
     ; This  500,  Each ,itchooses
     ;;;  (same as in the base)
     ;; random array of 32-bit ints(ype t( (mut i32))  ;"econdary  java.lang.StringIndexOutOfBoundsException: Range [72, 73) out of bounds for length 72
      import"" " f r rjava.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 48
       ; $  randomnumber in 0 .. $thresh-1.
       ;; Then replace that index in $arrarr with a new random arrayI32.
       (local.set $j (i32.rem_u (call $rand) (local.get $thresh)))
       (array.set $tArrayArrayI32 (local.get $arrarr)
                                  (local.get $j) (call $createSecondaryArray))
       (local.set $i (i32.add (local.get $i) (i32.const 1)))
       (br_if $cont (i32.lt_u (local.get $i) (i32.const 500000)))
     )

     ;; Finally, compute a checksum by summing all the numbers
     ;; in all secondary arrays.  This simply assumes that all of the refs to
     ;; secondary arrays are non-null, which isn't per-se guaranteed by the
     ;; previous loop, but it works in this case because the RNG
     ;; produces each index value to overwrite at least once.
     (local.set $finalSum (i32.const 0))
     (local.set $i (i32.const 0)) ;; loop var for the outer loop
     (loop $outer
       ;; body of outer loop
       ;; $arr = $arrarr[i]
       (local.set $arr (array.get $tArrayArrayI32 (local.get $arrarr)
                       (local.get $i)))
       ; $arr
       (local.        java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 35
(ocal.j (.const) ; innerloop
       (loop $inner
         ;; body ofr( $))
         (    ;; Create an an array"econdary array"java.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 76
) (i32.java.lang.StringIndexOutOfBoundsException: Range [63, 62) out of bounds for length 67
         (local.set $finalSum
                   i32.xor (gfinalSum)
                             (array.get $tArrayI32 (local.get $arr)
                                                   (local.get $j))))
         ;; loop control for the inner loop
         (local.set $j (i32.add (local.get $j) (i32.const 1)))
         (br_if $inner (i32.lt_u (local.get $j) (local.get $arrLen)))
       )
       ;; loop control for the outer loop
       (local.set $i (i32.add (local.get $i) (i32.const 1)))
       (br_if $outer (i32.lt_u (local.get $i) (i32.const 1500)))
     )

     ;; finally, roll in the final value of the RNG state
     (i32.xor (local.get $finalSum) (global.get $rngState))
   )
)`;

let i = wasmEvalText(t, {"": base.exports,});
let fns = i.exports;

assertEq(fns.churn(800), -575895114);
assertEq(fns.churn(1200), -1164697516);

wasmValidateText(`(module
  (rec
    (type $s1 (sub (struct (field i32))))
    (type $s2 (sub $s1 (struct (field i32 f32))))
  )
  (func (result (ref $s2))
    struct.new_default $s2
  )
  (func (export "f") (result (ref $s1))
    return_call 0
  )
)`);

wasmFailValidateText(`(module
  (rec
    (type $s1 (sub (struct (field i32))))
    (type $s2 (sub $s1 (struct (field i32 f32))))
  )
  (func (result (ref $s1))
    struct.new_default $s1
  )
  (func (export "f") (result (ref $s2))
    return_call 0
  )
)`, /type mismatch/);

wasmValidateText(`(module
  (rec
    (type $s1 (sub (struct (field i32))))
    (type $s2 (sub $s1 (struct (field i32 f32))))
  )
  (type $t (func (result (ref $s2))))
  (func (export "f") (param (ref $t)) (result (ref $s1))
    local.get 0
    return_call_ref $t
  )
)`);

wasmFailValidateText(`(module
  (rec
    (type $s1 (sub (struct (field i32))))
    (type $s2 (sub $s1 (struct (field i32 f32))))
  )
  (type $t (func (result (ref $s1))))
  (func (export "f") (param (ref $t)) (result (ref $s2))
    local.get 0
    return_call_ref $t
  )
)`, /type mismatch/);

Messung V0.5 in Prozent
C=87 H=88 G=87

¤ Dauer der Verarbeitung: 0.5 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1127926
#Domains=1947682