Question

In: Computer Science

When languages allow separate compilation, the compiler must decide on the compilation order. How does the...

When languages allow separate compilation, the compiler must decide on the compilation order. How does the Java compiler make that decision?

Solutions

Expert Solution

In practice, attening function arguments yields a substantial speedup for SML code and signi cantly reduces allocation. Much of the improvement claimed by Shao and Appel for their implementation of Leroy-style representation analysis is due to argument attening [110]. In particular, they reduced total execution time by 11% on average and allocation by 30% on average. I found similar performance advantages with argument attening in the context of the TIL compilerAfter demonstrating how multi-argument functions and polymorphic equality may be implemented in ML i , I sketch how other language constructs, notably C-style structsHaskell-style type classes, and polymorphic communication primitives, can be coded using dynamic type dispatch. The rest of this chapter proceeds as follows: I define the target language, Ximi-Rep.

Translation of Types I translate Mini-ML monotypes to ML i -Rep constructors via the function j j, which is de ned by induction on as follows: jtj = t jintj = Int j oatj = Float junitj = Unit jh1 2ij = hj1jj2ji j1 ! 2j = Vararg j1j j2j

Translation of Terms I specify the translation of Mini-ML expressions as a deductive system using judgments of the form ; ` e : ) e 0 where ; ` e : is a Mini-ML typing judgment and e 0 is the ML i -Rep translation of e. The axioms and inference rules that allow us to conclude this judgment

Translation of Equality The translation uses an auxiliary function, peq, that can be coded in the target language using typerec. Here, I use the pattern-matching syntax to de ne such a function Operationally, peq takes a constructor as an argument and selects the appropriate comparison function according to that constructor. For a product Prod(ta; tb), the appropriate function is constructed by using the inductive arguments peq[ta] and peq[tb] to compare the components of the product.

Translation of Functions There are three cases to consider when translating a -expression:

1. the argument type is known to be a tuple;

2. the argument type is int, oat, unit, or an arrow type;

3. the argument type is a type variable.

In the first case, the argument is a tuple. I need to produce a function that takes the components of the tuple directly as arguments. I translate the body of the function under the assumption that the argument was passed as a tuple. Then, I abstract the arguments appropriately. However, before executing the body of the function, I allocate a tuple and bind it to the original parameter, x.


Related Solutions

Interpreter and compiler are two methods to convert high level languages to machine language. How Python...
Interpreter and compiler are two methods to convert high level languages to machine language. How Python and C++ language works?
What does the following statement tell a C compiler to do, and when does it do...
What does the following statement tell a C compiler to do, and when does it do it? #define UCHAR unsigned char
what role does the symbol table play in compiler when it is created
what role does the symbol table play in compiler when it is created
A toy store must decide on how many bears to order for the next year. Each...
A toy store must decide on how many bears to order for the next year. Each bear is sold for $6 and costs $3. After January 1st 2019, any unsold bears are returned to the publisher for a refund of $1 each. If demand is normally distributed with a mean of 3000 and a standard deviation of 500, how many bears should the toy store order?
7. What role does the symbol table play in a compiler? When is it created?
7. What role does the symbol table play in a compiler? When is it created? 8. What are two unique advantages of implementing a language with a runtime interpreter i.e. scheme, python) versus a standalone executable file (i.e. C, C++)? 
When a firm wants to expand, how does it decide on how much of each of...
When a firm wants to expand, how does it decide on how much of each of its inputs to increase? Does it make sense to only increase one of its inputs? What happens when the price of an input rises or falls? Does the firm stop using that input or adjust how much of it is used? Explain how diminishing marginal product affects the amount of labor your employer or another company uses. What happens to the marginal product of...
What items does a firewall use to decide whether to allow or deny communication traffic. no...
What items does a firewall use to decide whether to allow or deny communication traffic. no plagarism
When would a company decide to change from a functional to a multidivisional structure? How does...
When would a company decide to change from a functional to a multidivisional structure? How does the multidivisional structure solve the problems associated with the functional structure?
How does an organization decide when to finance with a note payable versus a bond payable?...
How does an organization decide when to finance with a note payable versus a bond payable? Is one form of financing preferred over the other? Explain your answer.
make recommendations for how counselors decide when and how to advocate for a change they decide...
make recommendations for how counselors decide when and how to advocate for a change they decide will benefit the profession. Describe processes through which you could advocate on behalf of the profession on an issue that impacts the credentialing (licensure, certifications) of Clinical Mental Health Counselors.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT