Questions tagged [calling-conventions]

8 questions
33
votes
6 answers

Why do programs use call stacks, if nested function calls can be inlined?

Why not have the compiler take a program like this: function a(b) { return b^2 }; function c(b) { return a(b) + 5 }; and convert it into a program like this: function c(b) { return b^2 + 5 }; thereby eliminating the computer's need to remember…
moonman239
  • 2,023
  • 4
  • 18
  • 23
9
votes
2 answers

Which arguments pass by value and which pass by reference in Java?

I am starting to learn Java with the Java Trails tutorials offered by Oracle. I am in the section where it talks about passing arguments to methods The Java™ Tutorials: Passing Information to a Method or a Constructor. It says that primitive types…
Daniel Scocco
  • 5,832
  • 9
  • 39
  • 47
7
votes
2 answers

What's the REAL benefit of using CDECL? (more specifically pushing instead of reg-ing)

So, I'm learning assembly, and I've come to know the ABIs and i got some basics tests working using the cdecl calling convention to use the c's stdlib under nasm. But I've seen other Calling Conventions (like topspeed/Clarion/JPI/watcom/borland…
Nande
  • 173
  • 1
  • 7
5
votes
4 answers

What argument passing mechanism does python use, and where is this officially documented?

As far as I am aware, python is generally referred to as 'call-by-sharing', but does it implement this with call-by-value (like Java) or call-by-reference? or something else? I would appreciate if this could be answered with official python…
Tim Atkinson
  • 213
  • 2
  • 5
5
votes
2 answers

Where is it specified that Java is call by value?

I know that Java is by default call-by-value but I am not sure where in the Java Language Specification this is addressed. Google searching only seems to find me unofficial sources but never points to where the actual part of the specification that…
Tim Atkinson
  • 213
  • 2
  • 5
5
votes
2 answers

Where does `this` go in a x64 thiscall?

So I understand that thiscall doesn't really exist in x64 programming. However, I can't really find any definitive explanation as to where the this pointer is put to be passed to the callee. Is a x64 thiscall like a true cdecl call, where this is…
4
votes
1 answer

Is there a programming language which requires argument qualifiers (reference/value) to be specified at the call point?

For quite a long time now, I have been using a calling convention from C++ google style guide, which boils down to the following: "[for a function] arguments are values or const references while output arguments are pointers" The reason I like it so…
-1
votes
1 answer

What specifies the agreement (i.e. the convention) of which registers are used to pass which arguments and to return which values?

In Computer Systems: a Programmer's Perspective: procedure calls may involve passing data as arguments, and returning from a procedure may also involve returning a value. With x86-64, most of these data passing to and from procedures take place via…
Tim
  • 5,405
  • 7
  • 48
  • 84