Skip to content

Commit

Permalink
Merge with upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
dhil committed Oct 2, 2023
2 parents ab3bf77 + 45c7147 commit 2250826
Show file tree
Hide file tree
Showing 6 changed files with 298 additions and 301 deletions.
15 changes: 3 additions & 12 deletions document/js-api/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ spec:ecma-262; type:exception; for:ECMAScript; text:Error
spec:ecmascript; type:exception; for:ECMAScript; text:TypeError
spec:ecmascript; type:exception; for:ECMAScript; text:RangeError
spec:ecmascript; type:interface; for:ECMAScript; text:ArrayBuffer
spec:ecmascript; type:dfn; text:agent
spec:webidl; type:dfn; text:resolve
</pre>

Expand Down Expand Up @@ -432,16 +433,6 @@ The verification of WebAssembly type requirements is deferred to the
1. Return |promise|.
</div>

<div algorithm="instantiate">
To <dfn>synchronously instantiate a WebAssembly module</dfn> from a {{Module}} |moduleObject| and imports |importObject|, perform the following steps:
1. Let |module| be |moduleObject|.\[[Module]].
1. [=Read the imports=] of |module| with imports |importObject|, and let |imports| be the result.
1. [=Instantiate the core of a WebAssembly module=] |module| with |imports|, and let |instance| be the result.
1. Let |instanceObject| be a [=/new=] {{Instance}}.
1. [=initialize an instance object|Initialize=] |instanceObject| from |module| and |instance|.
1. Return |instanceObject|.
</div>

<div algorithm>
To <dfn>instantiate a promise of a module</dfn> |promiseOfModule| with imports |importObject|, perform the following steps:

Expand Down Expand Up @@ -845,7 +836,7 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each

<div algorithm>
To <dfn>create a global object</dfn> from a [=global address=] |globaladdr|, perform the following steps:
1. Let |map| be the current [=agent=]'s associated [=Global object cache=].
1. Let |map| be the [=surrounding agent=]'s associated [=Global object cache=].
1. If |map|[|globaladdr|] [=map/exists=],
1. Return |map|[|globaladdr|].
1. Let |global| be a [=/new=] {{Global}}.
Expand Down Expand Up @@ -1012,7 +1003,7 @@ Note: Exported Functions do not have a \[[Construct]] method and thus it is not
1. Otherwise,
1. Let |method| be [=?=] [$GetMethod$](|ret|, {{@@iterator}}).
1. If |method| is undefined, [=throw=] a {{TypeError}}.
1. Let |values| be [=?=] [$IterableToList$](|ret|, |method|).
1. Let |values| be [=?=] [$IteratorToList$]([=?=] [$GetIteratorFromMethod$](|ret|, |method|)).
1. Let |wasmValues| be a new, empty [=list=].
1. If |values|'s [=list/size=] is not |resultsSize|, throw a {{TypeError}} exception.
1. For each |value| and |resultType| in |values| and |results|, paired linearly,
Expand Down
6 changes: 4 additions & 2 deletions interpreter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ zip: $(ZIP)

# Building

.PHONY: $(NAME) $(JSLIB)

$(NAME):
rm -f $@
dune build $@.exe
Expand All @@ -47,7 +49,7 @@ $(JSLIB):
# Unit tests

UNITTESTDIR = unittest
UNITTESTFILES = $(shell cd $(UNITTESTDIR); ls *.ml)
UNITTESTFILES = $(shell cd $(UNITTESTDIR) > /dev/null; ls *.ml)
UNITTESTS = $(UNITTESTFILES:%.ml=%)

.PHONY: unittest
Expand All @@ -62,7 +64,7 @@ unittest/%:
# Test suite

TESTDIR = ../test/core
TESTFILES = $(shell cd $(TESTDIR); ls *.wast; ls [a-z]*/*.wast)
TESTFILES = $(shell cd $(TESTDIR) > /dev/null; ls *.wast; ls [a-z]*/*.wast)
TESTS = $(TESTFILES:%.wast=%)

.PHONY: test partest quiettest
Expand Down
26 changes: 14 additions & 12 deletions interpreter/exec/eval.ml
Original file line number Diff line number Diff line change
Expand Up @@ -480,15 +480,16 @@ let rec step (c : config) : config =
Plain (TableCopy (x, y));
]
else (* d > s *)
let n' = I32.sub n 1l in
vs', List.map (Lib.Fun.flip (@@) e.at) [
Plain (Const (I32 (I32.add d 1l) @@ e.at));
Plain (Const (I32 (I32.add s 1l) @@ e.at));
Plain (Const (I32 (I32.sub n 1l) @@ e.at));
Plain (TableCopy (x, y));
Plain (Const (I32 d @@ e.at));
Plain (Const (I32 s @@ e.at));
Plain (Const (I32 (I32.add d n') @@ e.at));
Plain (Const (I32 (I32.add s n') @@ e.at));
Plain (TableGet y);
Plain (TableSet x);
Plain (Const (I32 d @@ e.at));
Plain (Const (I32 s @@ e.at));
Plain (Const (I32 n' @@ e.at));
Plain (TableCopy (x, y));
]

| TableInit (x, y), Num (I32 n) :: Num (I32 s) :: Num (I32 d) :: vs' ->
Expand Down Expand Up @@ -642,17 +643,18 @@ let rec step (c : config) : config =
Plain (MemoryCopy);
]
else (* d > s *)
let n' = I32.sub n 1l in
vs', List.map (Lib.Fun.flip (@@) e.at) [
Plain (Const (I32 (I32.add d 1l) @@ e.at));
Plain (Const (I32 (I32.add s 1l) @@ e.at));
Plain (Const (I32 (I32.sub n 1l) @@ e.at));
Plain (MemoryCopy);
Plain (Const (I32 d @@ e.at));
Plain (Const (I32 s @@ e.at));
Plain (Const (I32 (I32.add d n') @@ e.at));
Plain (Const (I32 (I32.add s n') @@ e.at));
Plain (Load
{ty = Types.I32T; align = 0; offset = 0l; pack = Some (Pack8, ZX)});
Plain (Store
{ty = Types.I32T; align = 0; offset = 0l; pack = Some Pack8});
Plain (Const (I32 d @@ e.at));
Plain (Const (I32 s @@ e.at));
Plain (Const (I32 n' @@ e.at));
Plain (MemoryCopy);
]

| MemoryInit x, Num (I32 n) :: Num (I32 s) :: Num (I32 d) :: vs' ->
Expand Down
2 changes: 1 addition & 1 deletion test/core/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def _runTestFile(self, inputPath):

if __name__ == "__main__":
if not os.path.exists(outputDir):
os.makedirs(outputDir)
os.makedirs(outputDir, exist_ok=True)
for fileName in inputFiles:
testName = 'test ' + os.path.basename(fileName)
setattr(RunTests, testName, lambda self, file=fileName: self._runTestFile(file))
Expand Down
Loading

0 comments on commit 2250826

Please sign in to comment.