In Vogue Dynamic. Alexander Shopov

Size: px
Start display at page:

Download "In Vogue Dynamic. Alexander Shopov"

Transcription

1 In Vogue Dynamic Alexander Shopov

2 ~]$ whoami By day: Software Engineer at Cisco {,Nov. 28} By night: OSS contributor Coordinator of Bulgarian Gnome TP Git speaks Bulgarian Contacts: Jabber: LinkedIn: SlideShare: GitHub: Web: Just search al_shopov

3 Please Learn and Share License: Creative Commons Attribution 4.0 International CC-BY v4.0

4 Disclaimer My opinions, knowledge and experience! Not my employer's.

5 Menu for Today Numbers Letters Sentences Poetry

6 Numbers

7 Hundred 100

8 Hundred Is a Wonderful Number 100 = ( )²

9 Hundred Is a Wonderful Hectonumber 100 = ( )² = 1³ + 2³ + 3³ + 4³

10 100 Hundred Is a Wonderful Hectonumber = ( )² = 1³ + 2³ + 3³ + 4³ Νικόμαχος was here!

11 100 Hundred Is a Wonderful Hectonumber = ( )² = 1³ + 2³ + 3³ + 4³ Νικόμαχος was here! A Very Bold Comic Sans Relief

12 Triple Hundred Is Even More Magical

13 Triple Hundred by Any Other Base Will Smell as Sweet ₂ 444₈ 292₁₀

14 Our Last Numerological Slide 292

15 The One and Only JSR 292 JSR 292 specified a new bytecode instruction: invokedynamic First and only in all the history of Java platform and technologies. There have been retired instructions jsr, jsr_w cannot appear in class file version 51.0 (JDK 7.0) and above; Together with ret were used for the finally block in Java < 1.5; Mainly used for obfuscation.

16 Letters

17 Bytecode? Who Cares? And It Is Not for Java Well it is also for Java, especially 8.0; And it is also for dynamic languages; And it is also for static languages; And it is also for way too many other things; But yeah, the lecture is about bytecode, so this is last chance to leave (run to the hills)

18 Bytecodes Are the Letters of JVM

19 Bytecode Crash Course in F4 F3 Thread A F2 F1 Thread B F2 F1 Thread C F1 Thread D F3 F2 F1 F0 F0 F0 F0

20 Bytecode Crash Course in JVM (heap) Local variables PC Class code F0 Class Pool of constants Stack

21 Bytecode Crash Course in byte sized, typed instructions; Bytecodes can encode information in themselves, retrieve things from class bytestream, constant pool, local variables array; Perform computations only on stack; Store temporary results in local variables array (non-visible after method call); Store more permanent results in object/class fields (visible after method call); Enter frame by method call; Exit frame by a return from with a possible result (top thing on stack), or by throwing top of stack; JVM can also throw and unroll frames;

22 Bytecode Crash Course in You print the bytecode with the javap command: javap -l -v -p -constants -s -cp CLASSPATH CLASSES

23 For More Info Check my other presentation: Lifting The Veil Reading Java Bytecode During Lunchtime

24 Most Bytecodes Are Very Dull They are lowercase letters they continue or are a part of a single computational sequence: The operate on a single stack; Inside a single frame; They are part of a single method call.

25 Sentences

26 The Uppercase Bytecodes Are the 5 bytecodes that invoke methods (start sentences) in some way. invokestatic (0xb8) invokevirtual (0xb6) invokeinterface (0xb9) invokespecial (0xb7) invokedynamic (0xba)

27 The Punctuations Just for completeness there are only 2 ways to end a sentence (method call): Normal returning by: areturn, dreturn, freturn, ireturn, lreturn, return; Abrupt exception: Either we throw via athrow Or the JVM throws itself

28 Let's Check Simple Sentences package org.kambanaria.standardinvoke; public class Examples { public static int I_STATIC() { int a = Integer.parseInt("7"); return a; } }

29 Decompile Classfile /Java/StandardInvoke/target/classes/org/kambanaria/standardinvoke/Examples.class Last modified ; size 477 bytes MD5 checksum 2b499f0d33b9e2ed f767bb95 Compiled from "Examples.java" public class org.kambanaria.standardinvoke.examples SourceFile: "Examples.java" minor version: 0 major version: 51 flags: ACC_PUBLIC, ACC_SUPER Constant pool: #1 = ref #5.#19 // java/lang/object."<init>":()v #2 = String #20 // 7 #3 = ref #21.#22 // java/lang/integer.parseint:(ljava/lang/string;)i #4 = Class #23 // org/kambanaria/standardinvoke/examples #5 = Class #24 // java/lang/object #6 = Utf8 <init> #7 = Utf8 ()V #8 = Utf8 Code #9 = Utf8 LineNumberTable #10 = Utf8 LocalVariableTable #11 = Utf8 this #12 = Utf8 Lorg/kambanaria/standardinvoke/Examples; #13 = Utf8 I_STATIC #14 = Utf8 ()I #15 = Utf8 a #16 = Utf8 I #17 = Utf8 SourceFile #18 = Utf8 Examples.java #19 = NameAndType #6:#7 // "<init>":()v #20 = Utf8 7 #21 = Class #25 // java/lang/integer #22 = NameAndType #26:#27 // parseint:(ljava/lang/string;)i #23 = Utf8 org/kambanaria/standardinvoke/examples #24 = Utf8 java/lang/object #25 = Utf8 java/lang/integer #26 = Utf8 parseint #27 = Utf8 (Ljava/lang/String;)I { } public org.kambanaria.standardinvoke.examples(); Signature: ()V flags: ACC_PUBLIC LineNumberTable: line 3: 0 LocalVariableTable: Start Length Slot Name Signature this Lorg/kambanaria/standardinvoke/Examples; Code: stack=1, locals=1, args_size=1 0: aload_0 1: invokespecial #1 // java/lang/object."<init>":()v 4: return LineNumberTable: line 3: 0 LocalVariableTable: Start Length Slot Name Signature this Lorg/kambanaria/standardinvoke/Examples; public static int I_STATIC(); Signature: ()I flags: ACC_PUBLIC, ACC_STATIC LineNumberTable: line 6: 0 line 7: 6 LocalVariableTable: Start Length Slot Name Signature a I Code: stack=1, locals=1, args_size=0 0: ldc #2 // String 7 2: invokestatic #3 // java/lang/integer.parseint:(ljava/lang/string;)i 5: istore_0 6: iload_0 7: ireturn LineNumberTable: line 6: 0 line 7: 6 LocalVariableTable: Start Length Slot Name Signature a I

30 But It Is Actually Simple Classfile /Java/StandardInvoke/target/classes/org/kambanaria/standardinvoke/Examples.class Last modified Stats ; size 477 About bytes Class MD5 checksum 2b499f0d33b9e2ed f767bb95 Compiled from "Examples.java" public class org.kambanaria.standardinvoke.examples SourceFile: "Examples.java" minor version: 0 major version: 51 flags: ACC_PUBLIC, ACC_SUPER Constant pool: #1 = ref #5.#19 // java/lang/object."<init>":()v #2 = String #20 // 7 #3 = ref #21.#22 // java/lang/integer.parseint:(ljava/lang/string;)i #4 = Class #23 // org/kambanaria/standardinvoke/examples #5 = Class #24 // java/lang/object #6 = Utf8 <init> #7 = Utf8 ()V #8 = Utf8 Code #9 = Utf8 LineNumberTable #10 = Utf8 LocalVariableTable #11 = Utf8 this #12 = Utf8 Constant Lorg/kambanaria/standardinvoke/Examples; Pool #13 = Utf8 I_STATIC #14 = Utf8 ()I #15 = Utf8 a #16 = Utf8 I #17 = Utf8 SourceFile #18 = Utf8 Examples.java #19 = NameAndType #6:#7 // "<init>":()v #20 = Utf8 7 #21 = Class #25 // java/lang/integer #22 = NameAndType #26:#27 // parseint:(ljava/lang/string;)i #23 = Utf8 org/kambanaria/standardinvoke/examples #24 = Utf8 java/lang/object #25 = Utf8 java/lang/integer #26 = Utf8 parseint #27 = Utf8 (Ljava/lang/String;)I { } public org.kambanaria.standardinvoke.examples(); Signature: ()V flags: ACC_PUBLIC LineNumberTable: line 3: 0 LocalVariableTable: Start Length Slot Name Signature Default this Lorg/kambanaria/standardinvoke/Examples; Constructor Code: stack=1, locals=1, args_size=1 0: aload_0 1: invokespecial #1 // java/lang/object."<init>":()v 4: return LineNumberTable: line 3: 0 LocalVariableTable: Start Length Slot Name Signature this Lorg/kambanaria/standardinvoke/Examples; public static int I_STATIC(); Signature: ()I flags: ACC_PUBLIC, ACC_STATIC LineNumberTable: line 6: 0 line 7: 6 LocalVariableTable: Start Length Slot Name Signature a I Code: I_STATIC method stack=1, locals=1, args_size=0 0: ldc #2 // String 7 2: invokestatic #3 // java/lang/integer.parseint:(ljava/lang/string;)i 5: istore_0 6: iload_0 7: ireturn LineNumberTable: line 6: 0 line 7: 6 LocalVariableTable: Start Length Slot Name Signature a I

31 But It Is Actually Very Simple Classfile /Java/StandardInvoke/target/classes/org/kambanaria/standardinvoke/Examples.class Last modified Stats ; size 477 About bytes Class MD5 checksum 2b499f0d33b9e2ed f767bb95 Compiled from "Examples.java" public class org.kambanaria.standardinvoke.examples SourceFile: "Examples.java" minor version: 0 major version: 51 flags: ACC_PUBLIC, ACC_SUPER Constant pool: #1 = ref #5.#19 // java/lang/object."<init>":()v #2 = String #20 // 7 #3 = ref #21.#22 // java/lang/integer.parseint:(ljava/lang/string;)i #4 = Class #23 // org/kambanaria/standardinvoke/examples #5 = Class #24 // java/lang/object #6 = Utf8 <init> #7 = Utf8 ()V #8 = Utf8 Code #9 = Utf8 LineNumberTable #10 = Utf8 LocalVariableTable #11 = Utf8 this #12 = Utf8 Constant Lorg/kambanaria/standardinvoke/Examples; Pool #13 = Utf8 I_STATIC #14 = Utf8 ()I #15 = Utf8 a #16 = Utf8 I #17 = Utf8 SourceFile #18 = Utf8 Examples.java #19 = NameAndType #6:#7 // "<init>":()v #20 = Utf8 7 #21 = Class #25 // java/lang/integer #22 = NameAndType #26:#27 // parseint:(ljava/lang/string;)i #23 = Utf8 org/kambanaria/standardinvoke/examples #24 = Utf8 java/lang/object #25 = Utf8 java/lang/integer #26 = Utf8 parseint #27 = Utf8 (Ljava/lang/String;)I { } public org.kambanaria.standardinvoke.examples(); Signature: ()V flags: ACC_PUBLIC LineNumberTable: line 3: 0 LocalVariableTable: Start Length Slot Name Signature Default this Lorg/kambanaria/standardinvoke/Examples; Constructor Code: stack=1, locals=1, args_size=1 0: aload_0 1: invokespecial #1 // java/lang/object."<init>":()v 4: return LineNumberTable: line 3: 0 LocalVariableTable: Start Length Slot Name Signature this Lorg/kambanaria/standardinvoke/Examples; public static int I_STATIC(); Signature: ()I flags: ACC_PUBLIC, I_STATIC ACC_STATIC stats 1 LineNumberTable: line 6: 0 line 7: 6 LocalVariableTable: Start Length Slot Name Signature a I Code: stack=1, locals=1, I_STATIC args_size=0 code 0: ldc #2 // String 7 2: invokestatic #3 // java/lang/integer.parseint:(ljava/lang/string;)i 5: istore_0 6: iload_0 7: ireturn LineNumberTable: line 6: I_STATIC 0 stats 2 line 7: 6 LocalVariableTable: Start Length Slot Name Signature a I

32 The Whole Assembler Code: stack=1, locals=1, args_size=0 0: ldc #2 2: invokestatic #3 5: istore_0 6: iload_0 7: ireturn

33 Physical Layout Code: stack=1, locals=1, args_size=0 0: ldc #2 2: invokestatic #3 5: istore_0 6: iload_0 7: ireturn od -x --endian=big./examples.class b b 1a ac

34 ldc Is 0x12, 1 Byte Reference to Constant Pool Code: stack=1, locals=1, args_size=0 0: ldc #2 2: invokestatic #3 5: istore_0 6: iload_0 7: ireturn od -x --endian=big./examples.class b b 1a #2 in Constant Pool: String 7 ac

35 invokestatic Is 0xb8, 2 Bytes Reference (00<<8+03==03) Code: stack=1, locals=1, args_size=0 0: ldc #2 2: invokestatic #3 5: istore_0 #3 in Constant Pool points: 6: iload_0 7: ireturn java/lang/integer.parseint: (Ljava/lang/String;)I od -x --endian=big./examples.class b b 1a ac

36 istore_0 Is 0x3b, iload_0 Is 0x1a, ireturn Is 0xac Code: stack=1, locals=1, args_size=0 0: ldc #2 2: invokestatic #3 5: istore_0 6: iload_0 7: ireturn od -x --endian=big./examples.class b b 1a ac

37 Let's Check Another Sentence public static void I_VIRTUAL() throws InterruptedException { "7".wait(3, 7); }

38 As Before Push Arguments Onto Stack, Invoke Name + Signature public static void I_VIRTUAL() Code: 0: ldc #2 // String 7 2: ldc2_w #4 // long 3l 5: bipush 7 7: invokevirtual #6 // java/lang/object.wait:(ji)v 10: return

39 Let's Check the Rest of Old Invoke Instructions public static int I_INTERFACE(){ return "7".compareTo("8"); } public static Object I_SPECIAL(){ return new Integer(5); } // also private methods, super

40 As Before Push Arguments Onto Stack, Invoke Name + Signature I_INTERFACE(); Code: 0: ldc #2 // "7" 2: ldc #7 // "8" 4: invokevirtual #8 // // String.compareTo 7: ireturn I_SPECIAL(); Code: 0: new #9 //class j/l/integer 3: dup 4: iconst_5 5: invokespecial #10 // Integer. //"<init>":(i)v 8: areturn

41 Fundamentally Traditional Invokes: Are scoped Java-ish (class or interface); Have a Java-ish receiver (single or none); And definitely do Java-ish dispatch; Everything else you have to simulate.

42 Now Here Comes Java 8, Functional Interfaces, Lambdas public static void notempty(collection<string> all) { all.removeif(string::isempty); }

43 Which is Syntactic Sugar for an Anonymous Inner Class public static void notemptyold(collection<string> all) { all.removeif(new Predicate<String>() public boolean test(string t) { return t.isempty(); } }); }

44 Which is Syntactic Sugar For An New Object Anonymous Inner Class Per Invocation public static void notemptyold(collection<string> all) { all.removeif(new Predicate<String>() public boolean test(string t) { return t.isempty(); } }); }

45 Which is Syntactic Sugar For An New Object Anonymous Inner Class Per Invocation public static void notemptyold(collection<string> all) { all.removeif(new Predicate<String>() public boolean test(string t) { return t.isempty(); } }); } A Whole New Class

46 Improve by Caching public static void nonemptyoldneat(collection<string> all) { all.removeif(nonemptyp); } private static Predicate<String> nonemptyp = new Predicate<String>() public boolean test(string t) { return t.isempty(); } };

47 Improve by Caching public static void nonemptyoldneat(collection<string> all) { all.removeif(nonemptyp); } private static Predicate<String> nonemptyp = new Predicate<String>() public boolean }; test(string t) { return t.isempty(); } A Whole New Class

48 Let's Disassemble nonempty nonempty Code: 0: aload_0 //Load ref to col on stack 1: invokedynamic #2, 0 // Here's Waldo // Magic! 6: invokeinterface #3, 2 // Collection.removeIf 11: pop // pop boolean from stack 12: return // we are ready }

49 Let's Disassemble nonempty 1: invokedynamic #2, 0 // That is ba when dumped // #2 in constant pool is: InvokeDynamic #0:test:()Ljava/util/function/Predicate; // void -> Predicate, has index 0, OK // Where is String.isEmpty?

50 At the End of the Class Bootstraps: 0: #25 invokestatic j/l/invoke/lambdametafactory.metafactory:( Ljava/lang/invoke/Handles$Lookup; Ljava/lang/String; Ljava/lang/invoke/Type; Ljava/lang/invoke/Type; Ljava/lang/invoke/Handle; Ljava/lang/invoke/Type;) Ljava/lang/invoke/CallSite; arguments: #26 (Ljava/lang/Object;)Z #27 invokevirtual j/l/string.isempty:()z #28 (Ljava/lang/String;)Z

51 At the End of the Class Index 0 Bootstraps: 0: #25 invokestatic j/l/invoke/lambdametafactory.metafactory:( Ljava/lang/invoke/Handles$Lookup; Ljava/lang/String; Ljava/lang/invoke/Type; Ljava/lang/invoke/Type; Ljava/lang/invoke/Handle; Ljava/lang/invoke/Type;) Ljava/lang/invoke/CallSite; arguments: #26 (Ljava/lang/Object;)Z #27 invokevirtual j/l/string.isempty:()z #28 (Ljava/lang/String;)Z

52 At the End of the Class Fat Factory Gives CallSite, not Predicate Bootstraps: 0: #25 invokestatic j/l/invoke/lambdametafactory.metafactory:( Ljava/lang/invoke/Handles$Lookup; Ljava/lang/String; Ljava/lang/invoke/Type; Ljava/lang/invoke/Type; Ljava/lang/invoke/Handle; Ljava/lang/invoke/Type;) Ljava/lang/invoke/CallSite; arguments: #26 (Ljava/lang/Object;)Z #27 invokevirtual j/l/string.isempty:()z #28 (Ljava/lang/String;)Z

53 At the End of the Class Bootstraps: 0: #25 invokestatic j/l/invoke/lambdametafactory.metafactory:( Ljava/lang/invoke/Handles$Lookup; Ljava/lang/String; Ljava/lang/invoke/Type; Ljava/lang/invoke/Type; Ljava/lang/invoke/Handle; Ljava/lang/invoke/Type;) Ljava/lang/invoke/CallSite; Here Is the Test arguments: #26 (Ljava/lang/Object;)Z #27 invokevirtual j/l/string.isempty:()z #28 (Ljava/lang/String;)Z

54 Let's Try a More Realistic nonempty public static void nonempty(collection<string> all) { all.removeif(s -> s == null s.trim().isempty()); }

55 The nonempty Stays the Same nonempty Code: 0: aload_0 //Load ref to col on stack 1: invokedynamic #2, 0 // Here's Waldo // Magic! 6: invokeinterface #3, 2 // Collection.removeIf 11: pop // pop boolean from stack 12: return // we are ready }

56 We Get a Private, Static, Synthetic lambda$nonempty$0 lambda$nonempty$0 // (Ljava/lang/String;)Z Code: 0: aload_0 1: ifnull 14 4: aload_0 5: invokevirtual #4 // String.trim 8: invokevirtual #5 // String.isEmpty 11: ifeq 18 14: iconst_1 15: goto 19 18: iconst_0 19: ireturn

57 Which in Java Terms is private static void lambda$nonempty$0(string s) { return s == null s.trim().isempty(); }

58 The Bootstap Glue Becomes Bootstraps: 0: #23 invokestatic j/l/invoke/lambdametafactory.metafactory:( Ljava/lang/invoke/Handles$Lookup; Ljava/lang/String; Ljava/lang/invoke/Type; Ljava/lang/invoke/Type; Ljava/lang/invoke/Handle; Ljava/lang/invoke/Type;) Ljava/lang/invoke/CallSite; arguments: #24 (Ljava/lang/Object;)Z #25 invokestatic org/kambanaria/invokedynamic/ Examples.lambda$nonEmpty$0:(Ljava/lang/String;)Z #26 (Ljava/lang/String;)Z

59 Seems We Are Winning Lambdas get to be called with invokedynamic Which refers some glue code (bootstrap method) Which refers either: Some existing method (String::isEmpty); A new custom method (lambda$nonempty$0). No need to reuse a static instance; No new inner class!

60 Another Win for the Fundamental Theorem of Software Engineering David Wheeler But what is that theorem?

61 The Traditional Invoke Instructions Have a precise Java-ish meaning; They point to some executable code by: Name; Signature. Somewhat eased by boxing/varargs. What they actually point to is a string in the constant pool that gives name + signature. Given that JVM does a predefined resolution.

62 Old Invokes invoke type Name + signature JVM Decision by JVM JVM code code code

63 Invokedynamic We Get to Decide (This Is not the Whole Picture) invoke dynamic Decision by Us Bootstrap CallSite JVM Decision by Us Handle Decision by Us JVM code code code

64 The Fundamental Theorem of Software Engineering All problems in computer science can be solved by another level of indirection, except of course for the problem of too many indirections. David Wheeler

65 Poetry

66 Prose Poetry Using invokedynamic we can tell the JVM that a particular phrase (callsite) points to a particular code has a particular meaning; This can be very dull, repetitive and prosaic; In poetry you can talk about one thing but mean another; And even when things are ambiguous or just not the right types, number or order it works fine; And it is always in vogue; And as rapping has shown it can be fast!

67 How Does Invokedynamic Exactly Work A dynamic call site is every lexical occurrence of invokedynamic; Thus EVERY occurrence can behave differently; The instruction is followed by 4 bytes, only the fist 2 of them are currently used, the rest must be 0; The 1 st 2 bytes point to an index in the constant that contains a call site specifier that leads to a j.l.invoke.handle that serves as a bootstrap method; The bootstrap method is invoked and returns a j.l.invoke.callsite, this is bound permanently to this call site; The CallSite object provides a Handle via gettarget() method which provides the exact behavior. The result of gettarget() CAN change!

68 Invokedynamic JVM JVM code invoke dynamic code code

69 Invokedynamic JVM JVM code invoke dynamic Handle Bootstrap code code

70 Invokedynamic JVM JVM code invoke dynamic Handle Bootstrap code CallSite code

71 Invokedynamic JVM JVM code invoke dynamic Handle Bootstrap code CallSite code

72 Invokedynamic JVM JVM code invoke dynamic CallSite code code

73 Invokedynamic JVM Handle JVM code invoke dynamic CallSite Handle code Handle code

74 Invokedynamic JVM Handle JVM code invoke dynamic CallSite Handle code Handle code

75 Invokedynamic JVM Handle JVM code invoke dynamic CallSite Handle code Handle code

76 Handles vs. Reflection Reflections allows you to look at yourself and discover things, they are closer to Java language constructs; Hadles assume you know what you are looking for no exploration, but they are closer to the way JVM functions they are fast. Using them is like shaving in the dark you have to know where the razor is, how much foam to squeeze, what you are shaving but you can do it fast since your hands know their way they have memory of their own.

77 But Wait Types Must Match! You cannot pass some number of arguments to a method that expects another number Except varargs You cannot pass different types of arguments Except boxing/unboxing You cannot reorder; You cannot group; You cannot aggregate.

78 You Cannot Put a Square Peg In a Round Whole

79 But You Actually Can

80 Reshape the Peg to Be No Longer Square But Round and It Fits

81 Handles Know Types JVM JVM code invoke dynamic CallSite Handle code Handle code

82 But You Can Convert/Reshape/ Rechisel the JVM Way JVM Handle JVM code invoke dynamic CallSite Handle code Handle Handle code

83 java.lang.invoke In a Nutshell CallSite (Constant/Mutable/Volatile) produces Handle Type represents types Handle reference to method, (static) field, array member access; Handles combining or producing handles; Handles.Lookup get a Handle referring to actual method, filed, array member; HandleProxies proxies interface-handle; SwitchPoint fast, one-way if-then-else for handles;

84 Example Curry public class Computer { public static int sum (int a, int b){ return a + b; } }

85 Example Curry Computer.sum(2, 7); // => 9 // What we can see Handles.Lookup lookup = Handles.lookup(); Type sumtype = Type.methodType( // result, 1 arg,, 2 arg int.class, int.class, int.class); Handle sumhandle = lookup.findstatic( Computer.class, "sum", sumtype); sumhandle.invoke(2, 7); // => 9 Handle add2handle = Handles. insertarguments(sumhandle, 0, 2); add2handle.invokewitharguments(7); // => 9

86 Example Switch Receiver and Arg "tom".concat("cat"); // => "tomcat" "cat".concat("tom"); // => "cattom"

87 Example Switch Receiver and Argument Type cattype = Type.methodType( // result, argument String.class, String.class); Handle cathandle = lookup.findvirtual( String.class, "concat",cattype); cathandle.invoke("tom", "cat"); // "tomcat" Type tactype = Type.methodType( // result, receiver, argument String.class, String.class, String.class); Handle tachandle = Handles. permutearguments(cathandle, tactype, 1, 0); tachandle.invoke("tom", "cat"); // "cattom"

88 Rhymes And Allusions Rhymes get from repetition of sounds and you get to make Handles from other Hadles all the way turtles go; You can adapt and convert types thus you can use a MethotHandle with one type for something else with a different type. You can write one stanza but use it for many contexts; JVM actually understands this algebra of handles and types and can optimize it.

89 If You Are Not So Much Into Poetry

90 Shameless Plug for Geertjan & NetBeans

91 Shameless Plug for Geertjan & NetBeans

92 Shameless Plug for Geertjan & NetBeans

93 Shameless Plug for Geertjan & NetBeans

94 Further Resources Nutter, Ch. (headius JRuby guy) Invokedynamic: Changing the JVM Forever Invokedynamic in 45 minutes Indy Deep Dive Worthington, J.: Using invokedynamic to teach the JVM a new language Rose, J.: Bytecodes meet combinators: invokedynamic on the JVM Ponge, J: Demystifying invokedynamic, Java Magazine 2013, January-February: Part 1, May-June: Part 2 Forax, R.: jsr292-cookbook

95 Images rosipaw: 146/365 square peg into a round hole CC BY-NC-SA 2.0 Eric: Lego Porn CC BY-NC-SA 2.0

Course Overview. PART I: overview material. PART II: inside a compiler. PART III: conclusion

Course Overview. PART I: overview material. PART II: inside a compiler. PART III: conclusion Course Overview PART I: overview material 1 Introduction (today) 2 Language Processors (basic terminology, tombstone diagrams, bootstrapping) 3 The architecture of a Compiler PART II: inside a compiler

More information

JVM. What This Topic is About. Course Overview. Recap: Interpretive Compilers. Abstract Machines. Abstract Machines. Class Files and Class File Format

JVM. What This Topic is About. Course Overview. Recap: Interpretive Compilers. Abstract Machines. Abstract Machines. Class Files and Class File Format Course Overview What This Topic is About PART I: overview material 1 Introduction 2 Language processors (tombstone diagrams, bootstrapping) 3 Architecture of a compiler PART II: inside a compiler 4 Syntax

More information

Under the Hood: The Java Virtual Machine. Problem: Too Many Platforms! Compiling for Different Platforms. Compiling for Different Platforms

Under the Hood: The Java Virtual Machine. Problem: Too Many Platforms! Compiling for Different Platforms. Compiling for Different Platforms Compiling for Different Platforms Under the Hood: The Java Virtual Machine Program written in some high-level language (C, Fortran, ML, ) Compiled to intermediate form Optimized Code generated for various

More information

JVML Instruction Set. How to get more than 256 local variables! Method Calls. Example. Method Calls

JVML Instruction Set. How to get more than 256 local variables! Method Calls. Example. Method Calls CS6: Program and Data Representation University of Virginia Computer Science Spring 006 David Evans Lecture 8: Code Safety and Virtual Machines (Duke suicide picture by Gary McGraw) pushing constants JVML

More information

Under the Hood: The Java Virtual Machine. Lecture 23 CS2110 Fall 2008

Under the Hood: The Java Virtual Machine. Lecture 23 CS2110 Fall 2008 Under the Hood: The Java Virtual Machine Lecture 23 CS2110 Fall 2008 Compiling for Different Platforms Program written in some high-level language (C, Fortran, ML,...) Compiled to intermediate form Optimized

More information

invokedynamic IN 45 MINUTES!!! Wednesday, February 6, 13

invokedynamic IN 45 MINUTES!!! Wednesday, February 6, 13 invokedynamic IN 45 MINUTES!!! Me Charles Oliver Nutter headius@headius.com, @headius blog.headius.com JRuby Guy at Sun, Engine Yard, Red Hat JVM enthusiast, educator, contributor Earliest adopter of invokedynamic

More information

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Copyright 2013, Oracle and/or its affiliates. All rights reserved. 1 Lambda: A peek under the hood Brian Goetz Java Language Architect, Oracle 2 The following is intended to outline our general product direction. It is intended for information purposes only, and may not

More information

JSR 292 Cookbook: Fresh Recipes with New Ingredients

JSR 292 Cookbook: Fresh Recipes with New Ingredients JSR 292 Cookbook: Fresh Recipes with New Ingredients John Rose Christian Thalinger Sun Microsystems Overview Got a language cooking on the JVM? JSR 292, a set of major changes to the JVM architecture,

More information

Over-view. CSc Java programs. Java programs. Logging on, and logging o. Slides by Michael Weeks Copyright Unix basics. javac.

Over-view. CSc Java programs. Java programs. Logging on, and logging o. Slides by Michael Weeks Copyright Unix basics. javac. Over-view CSc 3210 Slides by Michael Weeks Copyright 2015 Unix basics javac java.j files javap 1 2 jasmin converting from javap to jasmin classfile structure calling methods adding line numbers Java programs

More information

301AA - Advanced Programming [AP-2017]

301AA - Advanced Programming [AP-2017] 301AA - Advanced Programming [AP-2017] Lecturer: Andrea Corradini andrea@di.unipi.it Tutor: Lillo GalleBa galleba@di.unipi.it Department of Computer Science, Pisa Academic Year 2017/18 AP-2017-05: The

More information

SOFTWARE ARCHITECTURE 7. JAVA VIRTUAL MACHINE

SOFTWARE ARCHITECTURE 7. JAVA VIRTUAL MACHINE 1 SOFTWARE ARCHITECTURE 7. JAVA VIRTUAL MACHINE Tatsuya Hagino hagino@sfc.keio.ac.jp slides URL https://vu5.sfc.keio.ac.jp/sa/ Java Programming Language Java Introduced in 1995 Object-oriented programming

More information

Let s make some Marc R. Hoffmann Eclipse Summit Europe

Let s make some Marc R. Hoffmann Eclipse Summit Europe Let s make some Marc R. Hoffmann Eclipse Summit Europe 2012 24.10.2012 public class WhatIsFaster { int i; void inc1() { i = i + 1; } void inc2() { i += 1; } void inc3() { i++; } } Why? Compilers Scrip;ng

More information

Static Analysis of Dynamic Languages. Jennifer Strater

Static Analysis of Dynamic Languages. Jennifer Strater Static Analysis of Dynamic Languages Jennifer Strater 2017-06-01 Table of Contents Introduction............................................................................... 1 The Three Compiler Options...............................................................

More information

The Java Virtual Machine. CSc 553. Principles of Compilation. 3 : The Java VM. Department of Computer Science University of Arizona

The Java Virtual Machine. CSc 553. Principles of Compilation. 3 : The Java VM. Department of Computer Science University of Arizona The Java Virtual Machine CSc 553 Principles of Compilation 3 : The Java VM Department of Computer Science University of Arizona collberg@gmail.com Copyright c 2011 Christian Collberg The Java VM has gone

More information

invokedynamic under the hood

invokedynamic under the hood Nadeesh T V ORACLE India Pvt Ltd 26 Aug 2016 Outline 1 JVM Languages 2 PreInvokedynamic 3 Invokedynamic 4 MethodHandle 5 Summary JVM Languages Languages which can run on Java Virtual Machine (JVM) Should

More information

Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16

Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16 1 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 16 Towards JVM Dynamic Languages Toolchain Insert Picture Here Attila

More information

Agenda. CSE P 501 Compilers. Java Implementation Overview. JVM Architecture. JVM Runtime Data Areas (1) JVM Data Types. CSE P 501 Su04 T-1

Agenda. CSE P 501 Compilers. Java Implementation Overview. JVM Architecture. JVM Runtime Data Areas (1) JVM Data Types. CSE P 501 Su04 T-1 Agenda CSE P 501 Compilers Java Implementation JVMs, JITs &c Hal Perkins Summer 2004 Java virtual machine architecture.class files Class loading Execution engines Interpreters & JITs various strategies

More information

CS2110 Fall 2011 Lecture 25. Under the Hood: The Java Virtual Machine, Part II

CS2110 Fall 2011 Lecture 25. Under the Hood: The Java Virtual Machine, Part II CS2110 Fall 2011 Lecture 25 Under the Hood: The Java Virtual Machine, Part II 1 Java program last time Java compiler Java bytecode (.class files) Compile for platform with JIT Interpret with JVM run native

More information

CSC 4181 Handout : JVM

CSC 4181 Handout : JVM CSC 4181 Handout : JVM Note: This handout provides you with the basic information about JVM. Although we tried to be accurate about the description, there may be errors. Feel free to check your compiler

More information

Run-time Program Management. Hwansoo Han

Run-time Program Management. Hwansoo Han Run-time Program Management Hwansoo Han Run-time System Run-time system refers to Set of libraries needed for correct operation of language implementation Some parts obtain all the information from subroutine

More information

CSE P 501 Compilers. Java Implementation JVMs, JITs &c Hal Perkins Winter /11/ Hal Perkins & UW CSE V-1

CSE P 501 Compilers. Java Implementation JVMs, JITs &c Hal Perkins Winter /11/ Hal Perkins & UW CSE V-1 CSE P 501 Compilers Java Implementation JVMs, JITs &c Hal Perkins Winter 2008 3/11/2008 2002-08 Hal Perkins & UW CSE V-1 Agenda Java virtual machine architecture.class files Class loading Execution engines

More information

Java Class Loading and Bytecode Verification

Java Class Loading and Bytecode Verification Java Class Loading and Bytecode Verification Every object is a member of some class. The Class class: its members are the (definitions of) various classes that the JVM knows about. The classes can be dynamically

More information

Problem: Too Many Platforms!

Problem: Too Many Platforms! Compiling for Different Platforms 2 Program written in some high-level language (C, Fortran, ML,...) Compiled to intermediate form Optimized UNDE THE HOOD: THE JAVA VITUAL MACHINE Code generated for various

More information

Compiling Techniques

Compiling Techniques Lecture 10: Introduction to 10 November 2015 Coursework: Block and Procedure Table of contents Introduction 1 Introduction Overview Java Virtual Machine Frames and Function Call 2 JVM Types and Mnemonics

More information

JSR 292 backport. (Rémi Forax) University Paris East

JSR 292 backport. (Rémi Forax) University Paris East JSR 292 backport (Rémi Forax) University Paris East Interactive talk Ask your question when you want Just remember : Use only verbs understandable by a 4 year old kid Use any technical words you want A

More information

Java and C II. CSE 351 Spring Instructor: Ruth Anderson

Java and C II. CSE 351 Spring Instructor: Ruth Anderson Java and C II CSE 351 Spring 2017 Instructor: Ruth Anderson Teaching Assistants: Dylan Johnson Kevin Bi Linxing Preston Jiang Cody Ohlsen Yufang Sun Joshua Curtis Administrivia Lab 5 Due TONIGHT! Fri 6/2

More information

Java Instrumentation for Dynamic Analysis

Java Instrumentation for Dynamic Analysis Java Instrumentation for Dynamic Analysis and Michael Ernst MIT CSAIL Page 1 Java Instrumentation Approaches Instrument source files Java Debug Interface (JDI) Instrument class files Page 2 Advantages

More information

Compiler construction 2009

Compiler construction 2009 Compiler construction 2009 Lecture 2 Code generation 1: Generating Jasmin code JVM and Java bytecode Jasmin Naive code generation The Java Virtual Machine Data types Primitive types, including integer

More information

Compiling for Different Platforms. Problem: Too Many Platforms! Dream: Platform Independence. Java Platform 5/3/2011

Compiling for Different Platforms. Problem: Too Many Platforms! Dream: Platform Independence. Java Platform 5/3/2011 CS/ENGD 2110 Object-Oriented Programming and Data Structures Spring 2011 Thorsten Joachims Lecture 24: Java Virtual Machine Compiling for Different Platforms Program written in some high-level language

More information

Chapter 5. A Closer Look at Instruction Set Architectures. Chapter 5 Objectives. 5.1 Introduction. 5.2 Instruction Formats

Chapter 5. A Closer Look at Instruction Set Architectures. Chapter 5 Objectives. 5.1 Introduction. 5.2 Instruction Formats Chapter 5 Objectives Understand the factors involved in instruction set architecture design. Chapter 5 A Closer Look at Instruction Set Architectures Gain familiarity with memory addressing modes. Understand

More information

Chapter 5. A Closer Look at Instruction Set Architectures

Chapter 5. A Closer Look at Instruction Set Architectures Chapter 5 A Closer Look at Instruction Set Architectures Chapter 5 Objectives Understand the factors involved in instruction set architecture design. Gain familiarity with memory addressing modes. Understand

More information

02 B The Java Virtual Machine

02 B The Java Virtual Machine 02 B The Java Virtual Machine CS1102S: Data Structures and Algorithms Martin Henz January 22, 2010 Generated on Friday 22 nd January, 2010, 09:46 CS1102S: Data Structures and Algorithms 02 B The Java Virtual

More information

JSR 292 and companions Rémi Forax FOSDEM'09

JSR 292 and companions Rémi Forax FOSDEM'09 JSR 292 and companions Rémi Forax FOSDEM'09 Da Vinci Mission Prototype (J)VM extensions to run non-java languages efficiently Complete the existing architecture with general purpose extensions New languages

More information

The Java Virtual Machine

The Java Virtual Machine Virtual Machines in Compilation Abstract Syntax Tree Compilation 2007 The compile Virtual Machine Code interpret compile Native Binary Code Michael I. Schwartzbach BRICS, University of Aarhus 2 Virtual

More information

COMP3131/9102: Programming Languages and Compilers

COMP3131/9102: Programming Languages and Compilers COMP3131/9102: Programming Languages and Compilers Jingling Xue School of Computer Science and Engineering The University of New South Wales Sydney, NSW 2052, Australia http://www.cse.unsw.edu.au/~cs3131

More information

Joeq Analysis Framework. CS 243, Winter

Joeq Analysis Framework. CS 243, Winter Joeq Analysis Framework CS 243, Winter 2009-2010 Joeq Background Compiler backend for analyzing and optimizing Java bytecode Developed by John Whaley and others Implemented in Java Research project infrastructure:

More information

CSCE 314 Programming Languages

CSCE 314 Programming Languages CSCE 314 Programming Languages! JVM Dr. Hyunyoung Lee 1 Java Virtual Machine and Java The Java Virtual Machine (JVM) is a stack-based abstract computing machine. JVM was designed to support Java -- Some

More information

Compilation 2012 Code Generation

Compilation 2012 Code Generation Compilation 2012 Jan Midtgaard Michael I. Schwartzbach Aarhus University Phases Computing resources, such as: layout of data structures offsets register allocation Generating an internal representation

More information

EXAMINATIONS 2014 TRIMESTER 1 SWEN 430. Compiler Engineering. This examination will be marked out of 180 marks.

EXAMINATIONS 2014 TRIMESTER 1 SWEN 430. Compiler Engineering. This examination will be marked out of 180 marks. T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON EXAMINATIONS 2014 TRIMESTER 1 SWEN 430 Compiler Engineering Time Allowed: THREE HOURS Instructions:

More information

Exercise 7 Bytecode Verification self-study exercise sheet

Exercise 7 Bytecode Verification self-study exercise sheet Concepts of ObjectOriented Programming AS 2018 Exercise 7 Bytecode Verification selfstudy exercise sheet NOTE: There will not be a regular exercise session on 9th of November, because you will take the

More information

Translating JVM Code to MIPS Code 1 / 43

Translating JVM Code to MIPS Code 1 / 43 Translating JVM Code to MIPS Code 1 / 43 Outline 1 Introduction 2 SPIM and the MIPS Architecture 3 Our Translator 2 / 43 Introduction Compilation is not necessarily done after the class file is constructed

More information

Let's talk about invokedynamic

Let's talk about invokedynamic Let's talk about invokedynamic Me Charles Oliver Nutter headius@headius.com, @headius blog.headius.com JRuby Guy at Sun, Engine Yard, Red Hat JVM enthusiast, educator, contributor Earliest adopter of invokedynamic

More information

CSE 431S Final Review. Washington University Spring 2013

CSE 431S Final Review. Washington University Spring 2013 CSE 431S Final Review Washington University Spring 2013 What You Should Know The six stages of a compiler and what each stage does. The input to and output of each compilation stage (especially the back-end).

More information

Reverse Engineering of Managed Languages

Reverse Engineering of Managed Languages Reverse Engineering of Managed Languages IT Security Bootcamp 2017 Dorottya Papp Agenda Reverse engineering Managed languages Introduction: what makes a programming language managed? Intermediate language

More information

Java Security. Compiler. Compiler. Hardware. Interpreter. The virtual machine principle: Abstract Machine Code. Source Code

Java Security. Compiler. Compiler. Hardware. Interpreter. The virtual machine principle: Abstract Machine Code. Source Code Java Security The virtual machine principle: Source Code Compiler Abstract Machine Code Abstract Machine Code Compiler Concrete Machine Code Input Hardware Input Interpreter Output 236 Java programs: definitions

More information

Improving Java Performance

Improving Java Performance Improving Java Performance #perfmatters Raimon Ràfols ...or the mumbo-jumbo behind the java compiler Agenda - Disclaimer - Who am I? - Our friend the java compiler - Language additions & things to consider

More information

JAM 16: The Instruction Set & Sample Programs

JAM 16: The Instruction Set & Sample Programs JAM 16: The Instruction Set & Sample Programs Copyright Peter M. Kogge CSE Dept. Univ. of Notre Dame Jan. 8, 1999, modified 4/4/01 Revised to 16 bits: Dec. 5, 2007 JAM 16: 1 Java Terms Java: A simple,

More information

Java byte code verification

Java byte code verification Java byte code verification SOS Master Science Informatique U. Rennes 1 Thomas Jensen SOS Java byte code verification 1 / 26 Java security architecture Java: programming applications with code from different

More information

The Java Virtual Machine

The Java Virtual Machine The Java Virtual Machine Norman Matloff and Thomas Fifield University of California at Davis c 2001-2007, N. Matloff December 11, 2006 Contents 1 Background Needed 3 2 Goal 3 3 Why Is It a Virtual Machine?

More information

Scala: Byte-code Fancypants. David Pollak JVM Language Summit 2009

Scala: Byte-code Fancypants. David Pollak JVM Language Summit 2009 Scala: Byte-code Fancypants David Pollak JVM Language Summit 2009 http://github.com/dpp/jvm_summit_2009 About DPP Author Beginning Scala BDFL Lift Wrote some spreadsheets What is Scala? A pile of short-cuts

More information

Taming the Java Virtual Machine. Li Haoyi, Chicago Scala Meetup, 19 Apr 2017

Taming the Java Virtual Machine. Li Haoyi, Chicago Scala Meetup, 19 Apr 2017 Taming the Java Virtual Machine Li Haoyi, Chicago Scala Meetup, 19 Apr 2017 Who Am I? Previously: Dropbox Engineering Currently: Bright Technology Services - Data Science, Scala consultancy Fluent Code

More information

Tutorial 3: Code Generation

Tutorial 3: Code Generation S C I E N C E P A S S I O N T E C H N O L O G Y Tutorial 3: Code Generation Univ.-Prof. Dr. Franz Wotawa, DI Roxane Koitz, Stephan Frühwirt, Christopher Liebmann, Martin Zimmermann Institute for Software

More information

Why GC is eating all my CPU? Aprof - Java Memory Allocation Profiler Roman Elizarov, Devexperts Joker Conference, St.

Why GC is eating all my CPU? Aprof - Java Memory Allocation Profiler Roman Elizarov, Devexperts Joker Conference, St. Why GC is eating all my CPU? Aprof - Java Memory Allocation Profiler Roman Elizarov, Devexperts Joker Conference, St. Petersburg, 2014 Java Memory Allocation Profiler Why it is needed? When to use it?

More information

April 15, 2009 John R. Rose, Sr. Staff Engineer

April 15, 2009 John R. Rose, Sr. Staff Engineer New JVM Plumbing: Method Handles and More April 15, 2009 John R. Rose, Sr. Staff Engineer john.rose@sun.com http://blogs.sun.com/jrose 1 Method Handles are Anonymous references to JVM methods Like methods,

More information

Code Generation Introduction

Code Generation Introduction Code Generation Introduction i = 0 LF w h i l e i=0 while (i < 10) { a[i] = 7*i+3 i = i + 1 lexer i = 0 while ( i < 10 ) source code (e.g. Scala, Java,C) easy to write Compiler (scalac, gcc) parser type

More information

<Insert Picture Here> Implementing lambda expressions in Java

<Insert Picture Here> Implementing lambda expressions in Java Implementing lambda expressions in Java Brian Goetz Java Language Architect Adding lambda expressions to Java In adding lambda expressions to Java, the obvious question is: what is

More information

Plan for Today. Safe Programming Languages. What is a secure programming language?

Plan for Today. Safe Programming Languages. What is a secure programming language? cs2220: Engineering Software Class 19: Java Security Java Security Plan for Today Java Byte s () and Verification Fall 2010 UVa David Evans Reminder: Project Team Requests are due before midnight tomorrow

More information

Programming Language Systems

Programming Language Systems Programming Language Systems Instructors: Taiichi Yuasa and Masahiro Yasugi Course Description (overview, purpose): The course provides an introduction to run-time mechanisms such as memory allocation,

More information

Advances in Programming Languages: Generics, interoperability and implementation

Advances in Programming Languages: Generics, interoperability and implementation Advances in Programming Languages: Generics, interoperability and implementation Stephen Gilmore The University of Edinburgh February 1, 2007 Understanding generic code Generic Java extends Java with generic

More information

Java Code Coverage Mechanics

Java Code Coverage Mechanics at by Evgeny Mandrikov Java Code Coverage Mechanics #DevoxxFR Evgeny Mandrikov @_Godin_.com/Godin one of JaCoCo and Eclipse EclEmma Project Leads Disclaimer /* TODO don't forget to add huge disclaimer

More information

CS263: Runtime Systems Lecture: High-level language virtual machines. Part 1 of 2. Chandra Krintz UCSB Computer Science Department

CS263: Runtime Systems Lecture: High-level language virtual machines. Part 1 of 2. Chandra Krintz UCSB Computer Science Department CS263: Runtime Systems Lecture: High-level language virtual machines Part 1 of 2 Chandra Krintz UCSB Computer Science Department Portable, Mobile, OO Execution Model Execution model embodied by recent

More information

JoeQ Framework CS243, Winter 20156

JoeQ Framework CS243, Winter 20156 Overview Java Intermediate representation JoeQ Framework CS243, Winter 20156 Bytecode JoeQ Framework Quads: Instruction set used in JoeQ JoeQ constructs Writing analysis in JoeQ HW 2 Typical Compiler Infrastructure

More information

Space Exploration EECS /25

Space Exploration EECS /25 1/25 Space Exploration EECS 4315 www.eecs.yorku.ca/course/4315/ Nondeterminism 2/25 Nondeterministic code is code that, even for the same input, can exhibit different behaviours on different runs, as opposed

More information

Compiler construction 2009

Compiler construction 2009 Compiler construction 2009 Lecture 3 JVM and optimization. A first look at optimization: Peephole optimization. A simple example A Java class public class A { public static int f (int x) { int r = 3; int

More information

Improving Java Code Performance. Make your Java/Dalvik VM happier

Improving Java Code Performance. Make your Java/Dalvik VM happier Improving Java Code Performance Make your Java/Dalvik VM happier Agenda - Who am I - Java vs optimizing compilers - Java & Dalvik - Examples - Do & dont's - Tooling Who am I? (Mobile) Software Engineering

More information

MethodHandle Introspection: Internals

MethodHandle Introspection: Internals Dan Heidinga J9 Virtual Machine 30 July 2012 MethodHandle Introspection: Internals Standard disclaimer IBM s statements regarding its plans, directions and intent are subject to change or withdrawal at

More information

Chapter 5. A Closer Look at Instruction Set Architectures. Chapter 5 Objectives. 5.1 Introduction. 5.2 Instruction Formats

Chapter 5. A Closer Look at Instruction Set Architectures. Chapter 5 Objectives. 5.1 Introduction. 5.2 Instruction Formats Chapter 5 Objectives Chapter 5 A Closer Look at Instruction Set Architectures Understand the factors involved in instruction set architecture design. Gain familiarity with memory addressing modes. Understand

More information

Chapter 5. A Closer Look at Instruction Set Architectures

Chapter 5. A Closer Look at Instruction Set Architectures Chapter 5 A Closer Look at Instruction Set Architectures Chapter 5 Objectives Understand the factors involved in instruction set architecture design. Gain familiarity with memory addressing modes. Understand

More information

Roadmap. Java: Assembly language: OS: Machine code: Computer system:

Roadmap. Java: Assembly language: OS: Machine code: Computer system: Roadmap C: car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly language: Machine code: Computer system: get_mpg: pushq movq... popq ret %rbp %rsp, %rbp

More information

Java Code Coverage Mechanics. by Evgeny Mandrikov at EclipseCon Europe 2017

Java Code Coverage Mechanics. by Evgeny Mandrikov at EclipseCon Europe 2017 Java Code Coverage Mechanics by Evgeny Mandrikov at EclipseCon Europe 2017 Evgeny Mandrikov @_Godin_ Godin Marc Hoffmann @marcandsweep marchof JaCoCo and Eclipse EclEmma Project Leads /* TODO Don't forget

More information

Invokedynamic in Practice. Adding invokedynamic support to JRuby

Invokedynamic in Practice. Adding invokedynamic support to JRuby Invokedynamic in Practice Adding invokedynamic support to JRuby Intro Charles Nutter @headius headius@headius.com JRuby guy at Engine Yard JVM enthusiast JRuby Ruby language on JVM Pushes JVM/platform

More information

Java TM. Multi-Dispatch in the. Virtual Machine: Design and Implementation. Computing Science University of Saskatchewan

Java TM. Multi-Dispatch in the. Virtual Machine: Design and Implementation. Computing Science University of Saskatchewan Multi-Dispatch in the Java TM Virtual Machine: Design and Implementation Computing Science University of Saskatchewan Chris Dutchyn (dutchyn@cs.ualberta.ca) September 22, 08 Multi-Dispatch in the Java

More information

The following presentation is provided under DHMB license. (Do Not Hurt My Brain). Lecturer is not responsible for the financial and moral

The following presentation is provided under DHMB license. (Do Not Hurt My Brain). Lecturer is not responsible for the financial and moral The following presentation is provided under DHMB license (Do Not Hurt My Brain). Lecturer is not responsible for the financial and moral damages resulting from taking too seriously the content of the

More information

Program Dynamic Analysis. Overview

Program Dynamic Analysis. Overview Program Dynamic Analysis Overview Dynamic Analysis JVM & Java Bytecode [2] A Java bytecode engineering library: ASM [1] 2 1 What is dynamic analysis? [3] The investigation of the properties of a running

More information

3/15/18. Overview. Program Dynamic Analysis. What is dynamic analysis? [3] Why dynamic analysis? Why dynamic analysis? [3]

3/15/18. Overview. Program Dynamic Analysis. What is dynamic analysis? [3] Why dynamic analysis? Why dynamic analysis? [3] Overview Program Dynamic Analysis Dynamic Analysis JVM & Java Bytecode [2] A Java bytecode engineering library: ASM [1] 2 What is dynamic analysis? [3] The investigation of the properties of a running

More information

javac 29: pop 30: iconst_0 31: istore_3 32: jsr [label_51]

javac 29: pop 30: iconst_0 31: istore_3 32: jsr [label_51] Analyzing Control Flow in Java Bytecode Jianjun Zhao Department of Computer Science and Engineering Fukuoka Institute of Technology 3-10-1 Wajiro-Higashi, Higashi-ku, Fukuoka 811-02, Japan zhao@cs.t.ac.jp

More information

Operational Semantics. One-Slide Summary. Lecture Outline

Operational Semantics. One-Slide Summary. Lecture Outline Operational Semantics #1 One-Slide Summary Operational semantics are a precise way of specifying how to evaluate a program. A formal semantics tells you what each expression means. Meaning depends on context:

More information

Java Code Coverage Mechanics Evgeny Mandrikov Marc Hoffmann #JokerConf 2017, Saint-Petersburg

Java Code Coverage Mechanics Evgeny Mandrikov Marc Hoffmann #JokerConf 2017, Saint-Petersburg Java Code Coverage Mechanics Evgeny Mandrikov Marc Hoffmann #JokerConf 2017, Saint-Petersburg Evgeny Mandrikov @_Godin_ Godin Marc Hoffmann @marcandsweep marchof JaCoCo and Eclipse EclEmma Project Leads

More information

Shared Mutable State SWEN-220

Shared Mutable State SWEN-220 Shared Mutable State SWEN-220 The Ultimate Culprit - Shared, Mutable State Most of your development has been in imperative languages. The fundamental operation is assignment to change state. Assignable

More information

Understand Every Line of Your Codebase

Understand Every Line of Your Codebase Understand Every Line of Your Codebase Victoria Gonda Boris Farber Speakers Victoria Developer at Collective Idea Android and Rails Boris Partner Engineer at Google Android Partnerships Android and Java

More information

COMP 520 Fall 2013 Code generation (1) Code generation

COMP 520 Fall 2013 Code generation (1) Code generation COMP 520 Fall 2013 Code generation (1) Code generation COMP 520 Fall 2013 Code generation (2) The code generation phase has several sub-phases: computing resources such as stack layouts, offsets, labels,

More information

Operating Systems CMPSCI 377, Lec 2 Intro to C/C++ Prashant Shenoy University of Massachusetts Amherst

Operating Systems CMPSCI 377, Lec 2 Intro to C/C++ Prashant Shenoy University of Massachusetts Amherst Operating Systems CMPSCI 377, Lec 2 Intro to C/C++ Prashant Shenoy University of Massachusetts Amherst Department of Computer Science Why C? Low-level Direct access to memory WYSIWYG (more or less) Effectively

More information

Static Program Analysis

Static Program Analysis Static Program Analysis Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ws-1617/spa/ Recap: Taking Conditional Branches into Account Extending

More information

Java: framework overview and in-the-small features

Java: framework overview and in-the-small features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: framework overview and in-the-small features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer

More information

MethodHandle implemention tips and tricks

MethodHandle implemention tips and tricks MethodHandle implemention tips and tricks Dan Heidinga J9 VM Software Developer daniel_heidinga@ca.ibm.com J9 Virtual Machine 2011 IBM Corporation MethodHandles: a 30 sec introduction A method handle is

More information

Running Mistyped Code. Lecture 19: Java Security. Running Mistyped Code. Java Security Architecture. JavaVM. Reference Monitors

Running Mistyped Code. Lecture 19: Java Security. Running Mistyped Code. Java Security Architecture. JavaVM. Reference Monitors CS16: Program and Data Representation University of Virginia Computer Science Spring 006 David Evans Lecture 19: Java Security PS6 Submission: Only to be eligible for the Byte Code Wizard awards. If the

More information

Today. Instance Method Dispatch. Instance Method Dispatch. Instance Method Dispatch 11/29/11. today. last time

Today. Instance Method Dispatch. Instance Method Dispatch. Instance Method Dispatch 11/29/11. today. last time CS2110 Fall 2011 Lecture 25 Java program last time Java compiler Java bytecode (.class files) Compile for platform with JIT Interpret with JVM Under the Hood: The Java Virtual Machine, Part II 1 run native

More information

Class, Variable, Constructor, Object, Method Questions

Class, Variable, Constructor, Object, Method Questions Class, Variable, Constructor, Object, Method Questions http://www.wideskills.com/java-interview-questions/java-classes-andobjects-interview-questions https://www.careerride.com/java-objects-classes-methods.aspx

More information

Dynalink. Dynamic Linker Framework for Languages on the JVM. Attila Szegedi, Software Engineer, Twitter

Dynalink. Dynamic Linker Framework for Languages on the JVM. Attila Szegedi, Software Engineer, Twitter Dynalink Dynamic Linker Framework for Languages on the JVM Attila Szegedi, Software Engineer, Twitter Inc. @asz 1 What s the problem? circle.color = 0xae17e3 class Circle def color=(value)... end end public

More information

Code Profiling. CSE260, Computer Science B: Honors Stony Brook University

Code Profiling. CSE260, Computer Science B: Honors Stony Brook University Code Profiling CSE260, Computer Science B: Honors Stony Brook University http://www.cs.stonybrook.edu/~cse260 Performance Programs should: solve a problem correctly be readable be flexible (for future

More information

Part VII : Code Generation

Part VII : Code Generation Part VII : Code Generation Code Generation Stack vs Register Machines JVM Instructions Code for arithmetic Expressions Code for variable access Indexed variables Code for assignments Items How to use items

More information

The Java Language Implementation

The Java Language Implementation CS 242 2012 The Java Language Implementation Reading Chapter 13, sections 13.4 and 13.5 Optimizing Dynamically-Typed Object-Oriented Languages With Polymorphic Inline Caches, pages 1 5. Outline Java virtual

More information

Array. Prepared By - Rifat Shahriyar

Array. Prepared By - Rifat Shahriyar Java More Details Array 2 Arrays A group of variables containing values that all have the same type Arrays are fixed length entities In Java, arrays are objects, so they are considered reference types

More information

1 Shyam sir JAVA Notes

1 Shyam sir JAVA Notes 1 Shyam sir JAVA Notes 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write

More information

Implementing on Object-Oriented Language 2.14

Implementing on Object-Oriented Language 2.14 2.14 Implementing on Object-Oriented Language 2.14 This section is for readers interested in seeing how an objected-oriented language like Java executes on a MIPS architecture. It shows the Java bytecodes

More information

Inheritance, Polymorphism and the Object Memory Model

Inheritance, Polymorphism and the Object Memory Model Inheritance, Polymorphism and the Object Memory Model 1 how objects are stored in memory at runtime? compiler - operations such as access to a member of an object are compiled runtime - implementation

More information

Compiling Faster, Compiling Better with Falcon. Iván

Compiling Faster, Compiling Better with Falcon. Iván Compiling Faster, Compiling Better with Falcon Iván Krȳlov @JohnWings Compiling Faster, Compiling Better with Falcon Overview of 3 technologies Falcon compiler ReadyNow & Compile Stashing Challenges (largely

More information

Recap: Printing Trees into Bytecodes

Recap: Printing Trees into Bytecodes Recap: Printing Trees into Bytecodes To evaluate e 1 *e 2 interpreter evaluates e 1 evaluates e 2 combines the result using * Compiler for e 1 *e 2 emits: code for e 1 that leaves result on the stack,

More information

Course Overview. Levels of Programming Languages. Compilers and other translators. Tombstone Diagrams. Syntax Specification

Course Overview. Levels of Programming Languages. Compilers and other translators. Tombstone Diagrams. Syntax Specification Course Overview Levels of Programming Languages PART I: overview material 1 Introduction 2 Language processors (tombstone diagrams, bootstrapping) 3 Architecture of a compiler PART II: inse a compiler

More information

Building a Compiler with. JoeQ. Outline of this lecture. Building a compiler: what pieces we need? AKA, how to solve Homework 2

Building a Compiler with. JoeQ. Outline of this lecture. Building a compiler: what pieces we need? AKA, how to solve Homework 2 Building a Compiler with JoeQ AKA, how to solve Homework 2 Outline of this lecture Building a compiler: what pieces we need? An effective IR for Java joeq Homework hints How to Build a Compiler 1. Choose

More information