Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: test/mjsunit/wasm/receiver.js

Issue 2111843002: [wasm] Fix receiver conversion for WASM->JS calls. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mjsunit/wasm/import-table.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Flags: --expose-wasm
6
7 load("test/mjsunit/wasm/wasm-constants.js");
8 load("test/mjsunit/wasm/wasm-module-builder.js");
9
10 function testCallImport(func, expected, a, b) {
11 var builder = new WasmModuleBuilder();
12
13 var sig_index = builder.addType(kSig_i_dd);
14 builder.addImport("func", sig_index);
15 builder.addFunction("main", sig_index)
16 .addBody([
17 kExprGetLocal, 0, // --
18 kExprGetLocal, 1, // --
19 kExprCallImport, 2, 0]) // --
20 .exportAs("main");
21
22 var main = builder.instantiate({func: func}).exports.main;
23
24 assertEquals(expected, main(a, b));
25 }
26
27 var global = (function() { return this; })();
28
29 function sloppyReceiver(a, b) {
30 assertEquals(global, this);
31 assertEquals(33.3, a);
32 assertEquals(44.4, b);
33 return 11;
34 }
35
36 function strictReceiver(a, b) {
37 'use strict';
38 assertEquals(undefined, this);
39 assertEquals(55.5, a);
40 assertEquals(66.6, b);
41 return 22;
42 }
43
44 testCallImport(sloppyReceiver, 11, 33.3, 44.4);
45 testCallImport(strictReceiver, 22, 55.5, 66.6);
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/import-table.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698