ファーストを使用した場合、単純なC APIのコードのコンパイル、コード
asm.js私の知識シンプルなasm.jsコードを入手できますか? emscripten
C/C++コード>>コンパイル([EMCC] emscripten)>>をご確認のI/Cを得ることができますC + +のコードをasm.jsのコードに、それは正しいですか?
asm.jsコード>>コンパイル(binaryen [asm2wasm])>> wasmコード
私はwasmコードにasm.jsコードを取得することができ、それが正しいのですか?
次に、私の主な質問は、どのように単純なasm.jsコードを取得できますか?
私は簡単なasm.jsコードを取得できません... emccコンパイルを使用すると、私はいつも複雑なasm.jsコード(5000行以上)を取得します。 ...
私のtryステップ
A.作る簡単なC APIコード// my_add.c
#include <stdio.h>
#include <emscripten.h>
EMSCRIPTEN_KEEPALIVE
double my_add(double num1, double num2) {
return num1 + num2;
}
B.が
(EMCCを使用して)コードをasm.jsするmy_add.cコードをコンパイルするには、多くのEMCCオプション...
EMCCのmy_add.c
EMCCのmy_addを試してみてください。 C -s WASM = 1
等...
私の予想...シンプルasm.jsコード(そう)...次のコードのようにmething
function my_add(num1, num2) {
"use asm";
num1 = num1|0;
num2 = num2|0;
retrurn (num1 + num2)|0;
}
しかし、EMCC遵守結果が/私のC複雑なasm.jsコード
1 // The Module object: Our interface to the outside world. We import
2 // and export values on it, and do the work to get that through
3 // closure compiler if necessary. There are various ways Module can be used:
4 // 1. Not defined. We create it here
5 // 2. A function parameter, function(Module) { ..generated code.. }
6 // 3. pre-run appended it, var Module = {}; ..generated code..
7 // 4. External script tag defines var Module.
8 // We need to do an eval in order to handle the closure compiler
9 // case, where this code here is minified but Module was defined
10 // elsewhere (e.g. case 4 above). We also need to check if Module
11 // already exists (e.g. case 3 above).
12 // Note that if you want to run closure, and also to use Module
13 // after the generated code, you will need to define var Module = {};
14 // before the code. Then that object will be used in the code, and you
15 // can continue to use Module afterwards as well.
16 var Module;
17 if (!Module) Module = (typeof Module !== 'undefined' ? Module : null) || {};
18
19 // Sometimes an existing Module object exists with properties
20 // meant to overwrite the default module functionality. Here
21 // we collect those properties and reapply _after_ we configure
22 // the current environment's defaults to avoid having to be so
23 // defensive during initialization.
24 var moduleOverrides = {};
25 for (var key in Module) {
26 if (Module.hasOwnProperty(key)) {
27 moduleOverrides[key] = Module[key];
28 }
29 }
30
31 // The environment setup code below is customized to use Module.
32 // *** Environment setup code ***
33 var ENVIRONMENT_IS_WEB = false;
34 var ENVIRONMENT_IS_WORKER = false;
35 var ENVIRONMENT_IS_NODE = false;
36 var ENVIRONMENT_IS_SHELL = false;
37
......
2038 function _my_add($num1,$num2) {
2039 $num1 = +$num1;
2040 $num2 = +$num2;
2041 var $0 = 0.0, $1 = 0.0, $2 = 0.0, $3 = 0.0, $4 = 0.0, label = 0, sp = 0;
2042 sp = STACKTOP;
2043 STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort();
2044 $0 = $num1;
2045 $1 = $num2;
2046 $2 = $0;
2047 $3 = $1;
2048 $4 = $2 + $3;
2049 STACKTOP = sp;return (+$4);
2050 }
.......
ですC++コードは5〜6行ですが、co mplied asm.jsコードは5000〜10000行です。
コンパイル結果に単純な 'asm.js'コードが必要です...
それは可能ですか?
...どうすればいいですか?
緑色のチェックボタン(投票ボタンの下)を使用して、この回答を承認済みとマークすることを検討してください。そうすれば、他の誰かがこの質問に対する答えを見つけたいと思っているなら、彼らは「この1つがうまくいく」ことを簡単に見ることができます。 – wizzwizz4
コメントありがとうございます〜 –