calling-convention

How to invoke a javascript function (generated from typescript) trapped within “System.register()” module while using Google protobuf?

廉价感情. 提交于 2019-12-19 09:27:36
问题 Update : It seems that, the problem is coming due to protobuf. I am fine with other solution as well, which help me to fix the Google protobuf issues. This problem boils down to: How to integrate Google protobuf with Typescript/Javascript for the browser? I am retaining below question for the future purpose. We have moved our application from Javascript to Typescript for obvious advantages of OOP etc.. Earlier invoking a direct javascript function from Html was as straight forward as: <script

C calling conventions and passed arguments

…衆ロ難τιáo~ 提交于 2019-12-19 03:27:10
问题 When making a function call in Linux (or OS X for that matter), can the callee modify the values of the arguments on the stack? I was under the assumption that since the caller is the one that cleans them up, that they should contain the same values after the function call. However I found that GCC with -O2 was modifying parameters that were passed to it on the stack. I have also looked for documentation including the System V i386 calling conventions, but was unable to find a definitive

Order of evaluation of arguments in function calling?

孤者浪人 提交于 2019-12-19 00:43:13
问题 I am studying about undefined behavior in C and I came to a statement that states that there is no particular order of evaluation of function arguments but then what about the standard calling conventions like _cdecl and _stdcall , whose definition said (in a book) that arguments are evaluated from right to left. Now I am confused with these two definitions one, in accordance of UB, states different than the other which is in accordance of the definition of calling convention. Please justify

__cdecl, __stdcall and __fastcall are all called the exact same way?

杀马特。学长 韩版系。学妹 提交于 2019-12-18 04:54:08
问题 I am using Visual C++ 2010, and MASM as my x64-Assembler. This is my C++ code: // include directive #include "stdafx.h" // functions extern "C" int Asm(); extern "C" int (convention) sum(int x, int y) { return x + y; } // main function int main() { // print asm printf("Asm returned %d.\n", Asm()); // get char, return _getch(); return EXIT_SUCCESS; } And my assembly code: ; external functions extern sum : proc ; code segment .code Asm proc ; create shadow space sub rsp, 20o ; setup parameters

How does method chaining work?

风流意气都作罢 提交于 2019-12-17 21:23:44
问题 How does getRequestDispatcher("xxx") get called from getServletContext() in the example below? How does calling procedures like this work in general? Please give me a clear picture about this context. RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/index.jsp"); dispatcher.include(request, response); 回答1: getServletContext() returns a ServletContext object, which has a method called getRequestDispatcher() . Your line of code is just shorthand for two method calls, and

Is fastcall really faster?

送分小仙女□ 提交于 2019-12-17 18:33:55
问题 Is the fastcall calling convention really faster than other calling conventions, such as cdecl? Are there any benchmarks out there that show how performance is affected by calling convention? 回答1: It depends on the platform. For a Xenon PowerPC, for example, it can be an order of magnitude difference due to a load-hit-store issue with passing data on the stack. I empirically timed the overhead of a cdecl function at about 45 cycles compared to ~4 for a fastcall . For an out-of-order x86

Is returning a 2-tuple less efficient than std::pair?

拈花ヽ惹草 提交于 2019-12-17 18:17:02
问题 Consider this code: #include <utility> #include <tuple> std::pair<int, int> f1() { return std::make_pair(0x111, 0x222); } std::tuple<int, int> f2() { return std::make_tuple(0x111, 0x222); } Clang 3 and 4 generate similar code for both on x86-64: f1(): movabs rax,0x22200000111 ret f2(): movabs rax,0x11100000222 ; opposite packing order, not important ret But Clang 5 generates different code for f2() : f2(): movabs rax,0x11100000222 mov QWORD PTR [rdi],rax mov rax,rdi ret As do GCC 4 through

What kind of C11 data type is an array according to the AMD64 ABI

烂漫一生 提交于 2019-12-17 14:58:09
问题 I was researching the calling convention of x86_64 that's used on OSX and was reading the section called "Aggregates and Unions" in the System V x86-64 ABI standard). It mention arrays and I figured that was like a fixed length c array, e.g. int[5] . I went down to "3.2.3 Parameter Passing" to read about how arrays were passed and if I'm understanding correctly, something like uint8_t[3] should be passed in registers as it's smaller than the four eightbyte limit imposed by rule 1 of the

Why not store function parameters in XMM vector registers?

丶灬走出姿态 提交于 2019-12-17 10:55:02
问题 I'm currently reading the book: "Computer Systems - A Programmers Perspective". I've found out that, on the x86-64 architecture, we are limited to 6 integral parameters which will be passed to a function in registers. The next parameters will be passed on the stack. And also, the first up-to-8 FP or vector args are passed in xmm0..7. Why not use float registers in order to store the next parameters, even when the parameters are not single/double precision variables? It would be much more

Why not store function parameters in XMM vector registers?

荒凉一梦 提交于 2019-12-17 10:54:08
问题 I'm currently reading the book: "Computer Systems - A Programmers Perspective". I've found out that, on the x86-64 architecture, we are limited to 6 integral parameters which will be passed to a function in registers. The next parameters will be passed on the stack. And also, the first up-to-8 FP or vector args are passed in xmm0..7. Why not use float registers in order to store the next parameters, even when the parameters are not single/double precision variables? It would be much more