This repository has been archived by the owner on Jul 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw an exception when a wasm trap is hit (#88)
* Convert wasm traps to Dart exceptions * Fix analysis
- Loading branch information
1 parent
8c7e3b9
commit 9046d3b
Showing
5 changed files
with
53 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
// Test that we can load a wasm module, find a function, and call it. | ||
import 'dart:typed_data'; | ||
|
||
import 'package:test/test.dart'; | ||
import 'package:wasm/wasm.dart'; | ||
|
||
import 'test_shared.dart'; | ||
|
||
void main() { | ||
test('basics', () { | ||
// (func $foo (export "foo") (type $t0) (unreachable)) | ||
final data = Uint8List.fromList([ | ||
0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x04, 0x01, 0x60, // | ||
0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0x04, 0x05, 0x01, 0x70, 0x01, 0x07, | ||
0x07, 0x05, 0x03, 0x01, 0x00, 0x11, 0x07, 0x10, 0x02, 0x03, 0x66, 0x6f, | ||
0x6f, 0x00, 0x00, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x02, 0x00, | ||
0x0a, 0x05, 0x01, 0x03, 0x00, 0x00, 0x0b, 0x00, 0x2b, 0x04, 0x6e, 0x61, | ||
0x6d, 0x65, 0x01, 0x06, 0x01, 0x00, 0x03, 0x66, 0x6f, 0x6f, 0x02, 0x03, | ||
0x01, 0x00, 0x00, 0x04, 0x05, 0x01, 0x00, 0x02, 0x74, 0x30, 0x05, 0x05, | ||
0x01, 0x00, 0x02, 0x54, 0x30, 0x06, 0x09, 0x01, 0x00, 0x06, 0x6d, 0x65, | ||
0x6d, 0x6f, 0x72, 0x79, | ||
]); | ||
|
||
final inst = WasmModule(data).builder().build(); | ||
final foo = inst.lookupFunction('foo'); | ||
// ignore: unnecessary_lambdas | ||
expect(() => foo(), throwsWasmException('unreachable')); | ||
}); | ||
} |
This file contains 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