1 / 24

Bypassing Portability Pitfalls of High-level Low-level Programming

Bypassing Portability Pitfalls of High-level Low-level Programming. Yi Lin, Steve Blackburn The Australian National University. Introduction Portability issues of high-level low-level programming. Introduction. Program Portability. Portability across platforms Portability across runtimes.

zavad
Télécharger la présentation

Bypassing Portability Pitfalls of High-level Low-level Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. BypassingPortabilityPitfallsof High-levelLow-level Programming Yi Lin, Steve Blackburn The Australian National University

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

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

  4. Introduction 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 Robustness Productivity Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12

  5. Introduction 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 Code reusability Development Cost Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12

  6. Introduction 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 Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12

  7. Introduction 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 facilitatetranslation to LLL Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12

  8. Introduction 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 Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12

  9. HLL Restrictionin Systems ProgrammingObservations, Design Concerns and Concrete RJava, Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12

  10. HLL Restriction Observations Studied use of language features in four non-trivial contexts unrestricted most restricted Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12

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

  12. HLL Restriction 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 • Restricted HLL has advantages over LLL Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12

  13. HLL Restriction 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 Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12

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

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

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

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

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

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

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

  21. Translating R-HLL to LL 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 Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12

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

  23. Summary & Future 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 Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12

  24. Summary & Future 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/RPythonapproach • Better VM portability Lin & Blackburn | Bypassing Portability Pitfalls | VMIL’12

More Related