Presentation is loading. Please wait.

Presentation is loading. Please wait.

Yi Lin, Steve Blackburn The Australian National University Bypassing Portability Pitfalls of High-level Low-level Programming.

Similar presentations


Presentation on theme: "Yi Lin, Steve Blackburn The Australian National University Bypassing Portability Pitfalls of High-level Low-level Programming."— Presentation transcript:

1 Yi Lin, Steve Blackburn The Australian National University Bypassing Portability Pitfalls of High-level Low-level Programming

2 Introduction Portability issues of high-level low-level programming 2Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12

3 Program Portability Portability across platforms Portability across runtimes 3 low-level codehigh-level languages Introduction Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12

4 High-level Low-level Programming High-level languages (HLL) ✔ Correctness (memory-safety, type-safety) ✔ Software engineering tools: a(abstraction, encapsulation) Applied to low-level systems programming 4 Robustness  Productivity  Introduction Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12

5 The Portability Pitfalls of HLLL ✘ Hardware portability –Low-level code is hardware-sensitive ✘ Portability between runtimes –High-level languages need to be extended, and cannot run on a stock runtime 5 Code reusability  Development Cost  Introduction Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12

6 Example: Portable MMTk Started in JikesRVM, ported to VMKit, Rotor Shortcomings of previous porting –Inconvenient/slow integration with legacy code: FFI –Repeated work for each porting. Language extensions need to be implemented for different targets 6 Introduction Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12

7 Possibility of Translation Into LLL ✔ Portable low-level languages (LLL) ✗ Difficult to map full HLL into LLL –Dynamic dispatch, exceptions, dynamic dispatch, GC, etc. ✔ High-level low-level lang. is restricted –Restrictions may facilitate translation to LLL 7 Introduction Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12

8 Presentation Outline Two topics, key to our approach: HLL restrictions in systems programming Translation into LLL Outcome: RJava (restricted subset of Java) –Application to VM implementation –Explicit restriction definition –High-level benefits –Improved portability 8Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12 Introduction

9 HLL Restriction in Systems Programming Observations, Design Concerns and Concrete RJava, 9Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12

10 Observations MMTkB/L CompilerJikesRVMEclipse Lines of Code2993317762113359n/a new / LOC 0.59%0.86%2.40%4.47% throws / LOC --0.21%1.33% import java.* / LOC -0.03%0.40%0.82% 10 most restricted unrestricted HLL Restriction Studied use of language features in four non-trivial contexts Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12

11 Observations (cont.) Restrictions exist for: Correctness –No GC/allocation in Memory manager  use raw memory –No threading/scheduling in Scheduler  use primitive locks Performance –Avoid dynamic dispatch in performance-critical areas –Avoid array bound checks in uninterruptible area 11Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12 HLL Restriction

12 Observations (cont.) Benefits of restricted HLL Benefits reduced, principally static –Type/memory-safety at source code level –Software engineering tools Restrictions are applied to limited scope –Maximizing benefits 12 Restricted HLL has advantages over LLL Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12 HLL Restriction

13 Design Concerns of RJava Expressiveness vs. Restriction –Mappability to LL –We do not introduce more restrictions than necessary Fixed vs. Flexible Restrictions for scope –Restrictions are different among different VM components –Restrictions may be still different within one VM component 13Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12 HLL Restriction

14 Concrete RJava: Extensions vmmagic extensions [1] Type-system extensions –Raw storage –Unboxed types Semantic extensions –Intrinsic functions –Semantic regimes [1] Frampton et al., VEE09 14Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12 HLL Restriction

15 Concrete RJava: Restrictions Restriction Rules –Forbid language features –Allow static checking Restriction Rulesets –1-to-1 mapping with scopes @RJavaCore Ruleset –Predefined ruleset –Defines RJava –Minimum restriction 15 @RestrictionRule public @interface NoDynamicLoading { } @RestrictionRule public @interface NoDynamicLoading { } compiler intrinsicschecking rule @RestrictionRuleset @NoDynamicLoading @NoReflection @NoException @NoCastOnMagicType public @interface RJavaCore { } @RestrictionRuleset @NoDynamicLoading @NoReflection @NoException @NoCastOnMagicType public @interface RJavaCore { } @RJavaCore public class SomeRJavaClass { } @RJavaCore public class SomeRJavaClass { } Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12 HLL Restriction

16 Example: MMTk with RJava 16 MMTk codebase @RestrictedRuleset @RJavaCore @NoRunTimeAllocation @NoClassLibrary @Uninterruptible public @interface MMTk { } @RestrictedRuleset @RJavaCore @NoRunTimeAllocation @NoClassLibrary @Uninterruptible public @interface MMTk { } disallow infinite regress disallow thread switching Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12 HLL Restriction

17 Example: MMTk with RJava (cont.) 17 @RestrictedRuleset @MMTk @NoVirtualMethod public @interface MMTkFastpath { } @RestrictedRuleset @MMTk @NoVirtualMethod public @interface MMTkFastpath { } avoid dynamic dispatch fast path MMTk codebase Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12 HLL Restriction

18 Example: MMTk with RJava (cont.) 18 @RestrictedRuleset @MMTkFastpath @NoPutfield @NoPutstatic public @interface MMTkWriteBarrier { } @RestrictedRuleset @MMTkFastpath @NoPutfield @NoPutstatic public @interface MMTkWriteBarrier { } disallow infinite regress MMTk codebase fast path write barrier Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12 HLL Restriction

19 Translation into LLL Current Work, RJava Toolchain, RJava frontend 19Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12

20 Bypass Approach 20 RJava Toolchain: 1.Static constraint checking tool 2.Frontend: RJava into LLL 3.Backend: LLL into executable Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12 Translating R-HLL to LL

21 RJava Frontend Generating plain LL code, with no dependency on Java runtime. Besides syntax mapping, the frontend needs to: –Implement compiler intrinsics –Unbox magic types –Remove dependencies on class library 21Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12 Translating R-HLL to LL

22 Summary and Future Work RJava Toolchain, frontend 22Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12

23 Summary Portability pitfalls of HL-LL programming –Affecting code reusability and development cost –Possibility of low-level language bypass HLL restriction and RJava –Observations, design concerns, concrete RJava LLL bypass and RJava toolchain 23Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12 Summary & Future

24 Future Work - Bootstrapping Java VM VMKit –RJava frontend to LLVM, use to compile MMTk Bootstrapping Java VM –Interpreter/baseline compiler in RJava –Similar to PyPy/RPython approach –Better VM portability 24Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12 Summary & Future


Download ppt "Yi Lin, Steve Blackburn The Australian National University Bypassing Portability Pitfalls of High-level Low-level Programming."

Similar presentations


Ads by Google