Question: Using your local implementations of Java and C#, compile the code of Figures 16.2 and C 16.7 all the way to machine language. Disassemble and

Using your local implementations of Java and C#, compile the code of Figures 16.2 and C 16.7 all the way to machine language. Disassemble and compare the results. Can all the differences be attributed to variations in the quality of the compilers, or are any reflective of more fundamental differences between the source languages or virtual machines?

Figure 16.2:

Code: public void insert (int v) { Stack=3, Locals=4, Args size=2 // this # 4; //Field head:LLLset $node; node n = head; 0: aload_0 1: getfield astore_2 aload_2 4: while (n.next != null // n #5; //Field LLset $node.next:LLLset $node; // conditional branch 5: &k n.next.val < v) { 6:

Code: public void insert (int v) { Stack=3, Locals=4, Args size=2 // this # 4; //Field head:LLLset $node; node n = head; 0: aload_0 1: getfield astore_2 aload_2 4: while (n.next != null // n #5; //Field LLset $node.next:LLLset $node; // conditional branch 5: &k n.next.val < v) { 6: getfield 9: ifnull 31 12: aload_2 13: getfield 16: getfield #5; //Field LLset$node.next:LLLset $node; #6; //Field LLset$node.val:I // v 19: iload_1 20: if_icmpge 31 n = n.next; 23: aload_2 24: getfield #5; //Field LLset$node. next:LLLset$node; 27: astore_2 28: goto if (n.next == null Il n.next.val > v) { 31: aload_2 32: getfield #5; //Field LLset$node.next:LLLset$node; 35: ifnull 49 38: aload_2 #5; //Field LLset $node.next:LLLset$node; 39: getfield 42: getfield 45: iload_1 #6; //Field LLset$node.val:I 46: if_icmple 76 node t = new node (); 49: # 2; //class LLset$node new 52: dup 53: aload_0 54: invokespecial #3; //Method LLset$node." ":(LLLset;) 57: astore_3 t.val = v; 58: aload_3 // t 59: iload_1 60: putfield #6; //Field LLset$node.val:I t.next = n.next; 63: aload_3 64: aload_2 65: getfield 68: putfield aload_2 #5; //Field LLset$node.next:LLLset$node; #5; //Field LLset$node.next:LLLset$node; n.next = t; 71: 72: aload_3 73: putfield #5; //Field LLset$node.next:LLLset$node; } // else v already in set 76: return

Step by Step Solution

3.26 Rating (164 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

ANS WER The machine language code generated by the Java and C comp ilers will be differe... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Language Pragmatics Questions!