OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --expose-wasm | 5 // Flags: --expose-wasm |
6 | 6 |
7 function bytes() { | 7 function bytes() { |
8 var buffer = new ArrayBuffer(arguments.length); | 8 var buffer = new ArrayBuffer(arguments.length); |
9 var view = new Uint8Array(buffer); | 9 var view = new Uint8Array(buffer); |
10 for (var i = 0; i < arguments.length; i++) { | 10 for (var i = 0; i < arguments.length; i++) { |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 var kExprJITSingleFunction = 0xf0; | 309 var kExprJITSingleFunction = 0xf0; |
310 | 310 |
311 var kTrapUnreachable = 0; | 311 var kTrapUnreachable = 0; |
312 var kTrapMemOutOfBounds = 1; | 312 var kTrapMemOutOfBounds = 1; |
313 var kTrapDivByZero = 2; | 313 var kTrapDivByZero = 2; |
314 var kTrapDivUnrepresentable = 3; | 314 var kTrapDivUnrepresentable = 3; |
315 var kTrapRemByZero = 4; | 315 var kTrapRemByZero = 4; |
316 var kTrapFloatUnrepresentable = 5; | 316 var kTrapFloatUnrepresentable = 5; |
317 var kTrapFuncInvalid = 6; | 317 var kTrapFuncInvalid = 6; |
318 var kTrapFuncSigMismatch = 7; | 318 var kTrapFuncSigMismatch = 7; |
319 var kTrapMemAllocationFail = 8; | 319 var kTrapInvalidIndex = 8; |
320 var kTrapInvalidIndex = 9; | |
321 | 320 |
322 var kTrapMsgs = [ | 321 var kTrapMsgs = [ |
323 "unreachable", | 322 "unreachable", |
324 "memory access out of bounds", | 323 "memory access out of bounds", |
325 "divide by zero", | 324 "divide by zero", |
326 "divide result unrepresentable", | 325 "divide result unrepresentable", |
327 "remainder by zero", | 326 "remainder by zero", |
328 "integer result unrepresentable", | 327 "integer result unrepresentable", |
329 "invalid function", | 328 "invalid function", |
330 "function signature mismatch", | 329 "function signature mismatch", |
331 "failed to allocate memory", | |
332 "invalid index into function table" | 330 "invalid index into function table" |
333 ]; | 331 ]; |
334 | 332 |
335 function assertTraps(trap, code) { | 333 function assertTraps(trap, code) { |
336 var threwException = true; | 334 var threwException = true; |
337 try { | 335 try { |
338 if (typeof code === 'function') { | 336 if (typeof code === 'function') { |
339 code(); | 337 code(); |
340 } else { | 338 } else { |
341 eval(code); | 339 eval(code); |
342 } | 340 } |
343 threwException = false; | 341 threwException = false; |
344 } catch (e) { | 342 } catch (e) { |
345 assertEquals("object", typeof e); | 343 assertEquals("object", typeof e); |
346 assertEquals(kTrapMsgs[trap], e.message); | 344 assertEquals(kTrapMsgs[trap], e.message); |
347 // Success. | 345 // Success. |
348 return; | 346 return; |
349 } | 347 } |
350 throw new MjsUnitAssertionError("Did not trap, expected: " + kTrapMsgs[trap]
); | 348 throw new MjsUnitAssertionError("Did not trap, expected: " + kTrapMsgs[trap]
); |
351 } | 349 } |
OLD | NEW |