Archive for August, 2007

requires the unEx method of a Cx object (Web hosting company)

Friday, August 31st, 2007

requires the unEx method of a Cx object so that a 1 (for true) or 0 (for false) can be stored into flag. Program 7.3 shows the class Cx. The unEx method is of particular interest. To convert a “conditional” into a “value expression”, we invent a new temporary r and new labels t and f. Then we make a Tree.Stm that moves the value 1 into r, and a conditional jump unCx(t, f) that implements the conditional. If the condition is false, then 0 is moved into r; if it is true, then execution proceeds at t and the second move is skipped. The result of the whole thing is just the temporary r containing zero or one. PROGRAM 7.3: The Cx class. abstract class Cx extends Exp { Tree.Exp unEx() { Temp r = new Temp(); Label t = new Label(); Label f = new Label(); return new Tree.ESEQ( new Tree.SEQ(new Tree.MOVE(new Tree.TEMP(r), new Tree.CONST(1)), new Tree.SEQ(unCx(t,f), new Tree.SEQ(new Tree.LABEL(f), new Tree.SEQ(new Tree.MOVE(new Tree.TEMP(r), new Tree.CONST(0)), new Tree.LABEL(t))))), new Tree.TEMP(r)); } abstract Tree.Stm unCx(Label t, Label f); Tree.Stm unNx() { … } } The unCx method is still abstract: We will discuss this later, with the translation of comparison operators. But the unEx and unNx methods can still be implemented in terms of the unCx method. We have shown unEx; we will leave unNx (which is simpler) as an exercise. The unCx method of class Ex is left as an exercise. It’s helpful to have unCx treat the cases of CONST 0and CONST 1 specially, since they have particularly simple and efficient translations. Class Nx’s unEx and unCx methods need not be implemented, since these cases should never occur in compiling a well-typed MiniJava program. SIMPLE VARIABLES For a simple variable v declared in the current procedure’s stack frame, we translate it as where k is the offset of v within the frame and TEMP fp is the frame-pointer register. For the
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.

. Cx stands for “conditional”, represented (Web hosting directory) as a

Friday, August 31st, 2007

. Cx stands for “conditional”, represented as a function from label-pair to statement. If you pass it a true destination and a false destination, it will make a statement that evaluates some conditionals and then jumps to one of the destinations (the statement will never “fall through”). For example, the MiniJava statement if (aWe recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.

relational operators are EQ and NE for integer (Msn web hosting)

Friday, August 31st, 2007

relational operators are EQ and NE for integer equality and nonequality (signed or unsigned); signed integer inequalities LT, GT, LE, GE; and unsigned integer inequalities ULT, ULE, UGT, UGE. . SEQ(s1, s2) The statement s1 followed by s2. . LABEL(n) Define the constant value of name n to be the current machine code address. This is like a label definition in assembly language. The value NAME(n) may be the target of jumps, calls, etc. It is almost possible to give a formal semantics to the Tree language. However, there is no provision in this language for procedure and function definitions -we can specify only the body of each function. The procedure entry and exit sequences will be added later as special “glue” that is different for each target machine. Team-Fly Team-Fly 7.2 TRANSLATION INTO TREES Translation of abstract syntax expressions into intermediate trees is reasonably straightforward; but there are many cases to handle. We will cover the translation of various language constructs, including many from MiniJava. KINDS OF EXPRESSIONS The MiniJava grammar has clearly distinguished statements and expressions. However, in languages such as C, the distinction is blurred; for example, an assignment in C can be used as an expression. When translating such languages, we will have to ask the following question. What should the representation of an abstract-syntax expression be in the Tree language? At first it seems obvious that it should be Tree.Exp. However, this is true only for certain kinds of expressions, the ones that compute a value. Expressions that return no value are more naturally represented by Tree.Stm. And expressions with boolean values, such as a>b, might best be represented as a conditional jump -a combination of Tree.Stm and a pair of destinations represented by Temp.Labels. It is better instead to ask, “how might the expression be used?” Then we can make the right kind of methods for an object-oriented interface to expressions. Both for MiniJava and other languages, we end up with Translate.Exp, not the same class as Tree.Exp, having three methods: package Translate; public abstract class Exp { abstract Tree.Exp unEx(); abstract Tree.Stm unNx(); abstract Tree.Stm unCx(Temp.Label t, Temp.Label f); } . Ex stands for an “expression”, represented as a Tree.Exp. . Nx stands for “no result”, represented as a Tree statement.
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.

Therefore, the intermediate (Tomcat web server) representation should have individual components

Thursday, August 30th, 2007

Therefore, the intermediate representation should have individual components that describe only extremely simple things: a single fetch, store, add, move, or jump. Then any “chunky” piece of abstract syntax can be translated into just the right set of abstract machine instructions; and groups of abstract machine instructions can be clumped together (perhaps in quite different clumps) to form “real” machine instructions. Here is a description of the meaning of each tree operator. First, the expressions (Exp), which stand for the computation of some value (possibly with side effects): . CONST(i) The integer constant i. . NAME(n) The symbolic constant n (corresponding to an assembly language label). . TEMP(t) Temporary t. A temporary in the abstract machine is similar to a register in a real machine. However, the abstract machine has an infinite number of temporaries. . BINOP(o, e1, e2) The application of binary operator o to operands e1, e2. Subexpression e1 is evaluated before e2. The integer arithmetic operators are PLUS, MINUS, MUL, DIV; the integer bitwise logical operators are AND, OR, XOR; the integer logical shift operators are LSHIFT, RSHIFT; the integer arithmetic right-shift is ARSHIFT. The MiniJava language has only one logical operator, but the intermediate language is meant to be independent of any source language; also, the logical operators might be used in implementing other features of MiniJava. . MEM(e) The contents of wordSize bytes of memory starting at address e (where wordSize is defined in the Frame module). Note that when MEM is used as the left child of a MOVE, it means “store”, but anywhere else it means “fetch.” . CALL(f, l) A procedure call: the application of function f to argument list l. The subexpression f is evaluated before the arguments which are evaluated left to right. . ESEQ(s, e) The statement s is evaluated for side effects, then e is evaluated for a result. The statements (stm) of the tree language perform side effects and control flow: . MOVE(TEMP t, e) Evaluate e and move it into temporary t. . MOVE(MEM(e1) e2) Evaluate e1, yielding address a. The nevaluate e2, and store the result into wordSize bytes of memory starting at a. . EXP(e) Evaluate e and discard the result. . JUMP(e, labs) Transfer control (jump) to address e. The destination e may be a literal label, as in NAME(lab), or it may be an address calculated by any other kind of expression. For example, a C-language switch(i) statement may be implemented by doing arithmetic on i. The list of labels labs specifies all the possible locations that the expression e can evaluate to; this is necessary for dataflow analysis later. The common case of jumping to a known label l is written as JUMP(NAME l, new LabelList(l, null)), but the JUMP class has an extra constructor so that this can be abbreviated as JUMP(l). . CJUMP(o, e1, e2, t, f) Evaluate e1, e2 in that order, yielding values a, b. Then compare a, b using the relational operator o. If the result is true, jump to t; otherwise jump to f . The
From our experience, we can recommend PHP5 Web Hosting services, if you need affordable webhost to host and run your web application.

Free php web host - Team-Fly 7.1 INTERMEDIATE REPRESENTATION TREES The intermediate representation

Thursday, August 30th, 2007

Team-Fly 7.1 INTERMEDIATE REPRESENTATION TREES The intermediate representation tree language is defined by the package Tree, containing abstract classes Stm and Exp and their subclasses, as shown in Figure 7.2. package Tree; abstract class Exp CONST(int value) NAME(Label label) TEMP(Temp.Temp temp) BINOP(int binop, Exp left, Exp right) MEM(Exp exp) CALL(Exp func, ExpList args) ESEQ(Stm stm, Exp exp) abstract class Stm MOVE(Exp dst, Exp src) EXP(Exp exp) JUMP(Exp exp, Temp.LabelList targets) CJUMP(int relop, Exp left, Exp right, Label iftrue, Label iffalse) SEQ(Stm left, Stm right) LABEL(Label label) other classes: ExpList(Exp head, ExpList tail) StmList(Stm head, StmList tail) other constants: final static int BINOP.PLUS, BINOP.MINUS, BINOP.MUL, BINOP.DIV, BINOP.AND, BINOP.OR, BINOP.LSHIFT, BINOP.RSHIFT, BINOP.ARSHIFT, BINOP.XOR; final static int CJUMP.EQ, CJUMP.NE, CJUMP.LT, CJUMP.GT, CJUMP.LE, CJUMP.GE, CJUMP.ULT, CJUMP.ULE, CJUMP.UGT, CJUMP.UGE; Figure 7.2: Intermediate representation trees. A good intermediate representation has several qualities: . It must be convenient for the semantic analysis phase to produce. . It must be convenient to translate into real machine language, for all the desired target machines. . Each construct must have a clear and simple meaning, so that optimizing transformations that rewrite the intermediate representation can easily be specified and implemented. Individual pieces of abstract syntax can be complicated things, such as array subscripts, procedure calls, and so on. And individual “real machine” instructions can also have a complicated effect (though this is less true of modern RISC machines than of earlier architectures). Unfortunately, it is not always the case that complex pieces of the abstract syntax correspond exactly to the complex instructions that a machine can execute.
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

of the issues. Team-Fly Team-Fly Chapter 7: Translation (Web server info)

Wednesday, August 29th, 2007

of the issues. Team-Fly Team-Fly Chapter 7: Translation to Intermediate Code trans-late: to turn into one’s own or another language Webster’s Dictionary OVERVIEW The semantic analysis phase of a compiler must translate abstract syntax into abstract machine code. It can do this after type-checking, or at the same time. Though it is possible to translate directly to real machine code, this hinders portability and modularity. Suppose we want compilers for N different source languages, targeted to M different machines. In principle this is N M compilers (Figure 7.1a), a large implementation task. Figure 7.1: Compilers for five languages and four target machines: (a) without an IR, (b) with an IR. An intermediate representation (IR) is a kind of abstract machine language that can express the target-machine operations without committing to too much machine-specific detail. But it is also independent of the details of the source language. The front end of the compiler does lexical analysis, parsing, semantic analysis, and translation to intermediate representation. The back end does optimization of the intermediate representation and translation to machine language. A portable compiler translates the source language into IR and then translates the IR into machine language, as illustrated in Figure 7.1b. Now only N front ends and M back ends are required. Such an implementation task is more reasonable. Even when only one front end and one back end are being built, a good IR can modularize the task, so that the front end is not complicated with machine-specific details, and the back end is not bothered with information specific to one source language. Many different kinds of IR are used in compilers; for this compiler we have chosen simple expression trees. Team-Fly
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

f. Comment on the likelihood that the designers (Yahoo web hosting)

Wednesday, August 29th, 2007

f. Comment on the likelihood that the designers of this C compiler considered deeply recursive functions important in real programs. . *6.5 Instead of (or in addition to) using static links, there are other ways of getting access to nonlocal variables. One way is just to leave the variable in a register! function f() : int = let var a := 5 function g() : int = (a+1) in g()+g() end If a is left in register r7 (for example) while g is called, then g can just access it from there. What properties must a local variable, the function in which it is defined, and the functions in which it is used, have for this trick to work? . *6.6 A display is a data structure that may be used as an alternative to static links for maintaining access to nonlocal variables. It is an array of frame pointers, indexed by static nesting depth. Element Di of the display always points to the most recently called function whose static nesting depth is i. The bookkeeping performed by a function f, whose static nesting depth is i, looks like: Copy Di to save locationin stack frame Copy frame pointer to Di … body of f … Copy save locationback to Di In Program 6.3, function prettyprint is at depth 1, write and show are at depth 2, and so on. a. Show the sequence of machine instructions required to fetch the variable output into a register at line 14 of Program 6.3, using static links. b. Show the machine instructions required if a display were used instead. c. When variable x is declared at depth d1 and accessed at depth d2, how many instructions does the static-link method require to fetch x? d. How many does the display method require? e. How many instructions does static-link maintenance require for a procedure entry and exit (combined)? f. How many instructions does display maintenance require for procedure entry and exit? Should we use displays instead of static links? Perhaps; but the issue is more complicated. For languages such as Pascal with block structure but no function variables, displays work well. But the full expressive power of block structure is obtained when functions can be returned as results of other functions, as in Scheme and ML. For such languages, there are more issues to consider than just variable-access time and procedure entry-exit cost: there is closure-building cost, and the problem of avoiding useless data kept live in closures. Chapter 15 explains some
Go visit our java server pages services for a reliable, lowcost webhost to satisfy all your needs.

all possible compiler optimizations. Then evaluate the compiled (Adult web hosting)

Tuesday, August 28th, 2007

all possible compiler optimizations. Then evaluate the compiled programs by these criteria: a. a. Are local variables kept in registers? b. b. If local variable b is live across more than one procedure call, is it kept in a calleesave register? Explain how doing this would speed up the following program: int f(int a) {int b; b=a+1; g(); h(b); return b+2;} c. c. If local variable x is never live across a procedure call, is it properly kept in a caller- save register? Explain how doing this would speed up the following program: void h(int y) {int x; x=y+1; f(y); f(2);} . 6.2 If you have a C compiler that passes parameters in registers, make it generate assembly language for this function: extern void h(int, int); void m(int x, int y) {h(y,y); h(x,x);} Clearly, if arguments to m(x, y) arrive in registers rarg1 and rarg2, and arguments to h must be passed in rarg1 and rarg2, then x cannot stay in rarg1 during the marshalling of arguments to h (y, y). Explain when and how your C compiler moves x out of the rarg1 register so as to call h (y, y). . 6.3 For each of the variables a, b, c, d, e in this C program, say whether the variable should be kept in memory or a register, and why. int f(int a, int b) { int c[3], d, e; d=a+1; e=g(c, &b); return e+c[1]+b; } . *6.4 How much memory should this program use? int f(int i) {int j,k; j=i*i; k=i?f(i-1):0; return k+j;} void main() {f(100000);} a. Imagine a compiler that passes parameters in registers, wastes no space providing “backup storage” for parameters passed in registers, does not use static links, and in general makes stack frames as small as possible. How big should each stack frame for f be, in words? b. What is the maximum memory use of this program, with such a compiler? c. Using your favorite C compiler, compile this program to assembly language and report the size of f ’s stack frame. d. Calculate the total memory use of this program with the real C compiler. e. Quantitatively and comprehensively explain the discrepancy between (a) and (c).
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.

If you are working on a RISC machine (X web hosting)

Tuesday, August 28th, 2007

If you are working on a RISC machine (such as MIPS or Sparc) that passes the first k parameters in registers and the rest in memory, keep things simple by handling only the case where there are k or fewer parameters. Supporting files available in $MINIJAVA/chap6 include: Temp/* The module supporting temporaries and labels. Util/BoolList.java The class for lists of booleans. Optional: Handle functions with more than k formal parameters. Team-Fly Team-Fly FURTHER READING The use of a single contiguous stack to hold variables and return addresses dates from Lisp [McCarthy 1960] and Algol [Naur et al. 1963]. Block structure (the nesting of functions) and the use of static links are also from Algol. Computers and compilers of the 1960s and ’70s kept most program variables in memory, so that there was less need to worry about which variables escaped (needed addresses). The VAX, built in 1978, had a procedure-call instruction that assumed all arguments were pushed on the stack, and itself pushed program counter, frame pointer, argument pointer, argument count, and callee-save register mask on the stack [Leonard 1987]. With the RISC revolution [Patterson 1985] came the idea that procedure calling can be done with much less memory traffic. Local variables should be kept in registers by default; storing and fetching should be done as needed, driven by “spilling” in the register allocator [Chaitin 1982]. Most procedures don’t have more than five arguments and five local variables [Tanenbaum 1978]. To take advantage of this, Chow et al. [1986] and Hopkins [1986] designed calling conventions optimized for the common case: The first four arguments are passed in registers, with the (rare) extra arguments passed in memory; compilers use both caller-and callee-save registers for local variables; leaf procedures don’t even need stack frames of their own if they can operate within the caller-save registers; and even the return address need not always be pushed on the stack. Team-Fly Team-Fly EXERCISES . 6.1 Using the C compiler of your choice (or a compiler for another language), compile some small test functions into assembly language. On Unix this is usually done by cc -S. Turn on
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.

public String toString(); public Temp(); } public class (Starting a web site)

Monday, August 27th, 2007

public String toString(); public Temp(); } public class Label { public String toString(); public Label(); public Label(String s); public Label(Symbol s); } public class TempList {…} public class LabelList {…} new Temp.Temp() returns a new temporary from an infinite set of temps. new Temp.Label() returns a new label from an infinite set of labels. And new Temp.Label(string)) returns a new label whose assembly-language name is string. When processing the declaration m( ), a label for the address of m’s machine code can be produced by new Temp.Label(). It’s tempting to call new Temp.Label(”m”) instead -the assembly-language program will be easier to debug if it uses the label m instead of L213 -but unfortunately there could be two different methods named m in different classes. A better idea is to call new Temp.Label (”C”+”$”+”m”), where C is the name of the class in which the method m occurs. MANAGING STATIC LINKS The Frame module should be independent of the specific source language being compiled. Many source languages, including MiniJava, do not have nested function declarations; thus, Frame should not know anything about static links. Instead, this is the responsibility of the translation phase. The translation phase would know that each frame contains a static link. The static link would be passed to a function in a register and stored into the frame. Since the static link behaves so much like a formal parameter, we can treat it as one (as much as possible). [1]Before about 1960, they were passed not on the stack but in statically allocated blocks of memory, which precluded the use of recursive functions. [2]However, with register allocation across function boundaries, local variables accessed by inner functions can sometimes go in registers, as long as the inner function knows where to look. [3]However, some compilers spread out a large value into several registers for efficiency. [4]This program would be cleaner if show called write here instead of manipulating output directly, but it would not be as instructive. Team-Fly Team-Fly PROGRAM FRAMES If you are compiling for the Sparc, implement the Sparc package containing Sparc/SparcFrame.java. If compiling for the MIPS, implement the Mips package, and so on.
You want to have a cheap webhost for your apache application, then check apache web hosting services.