SlideShare a Scribd company logo
IN-DEPTH LOOK AT THE FLEX
   COMPILER AND HFCD

               Clement Wong
         clement@stopcoding.org
     http://stopcoding.wordpress.com
AGENDA

• Basic Architecture   of Flex Compiler

• Compiler    Extensibility

• Overview    of Flex Compiler API

• HellFire   Compiler Daemon (HFCD)

• Demo, Q/A
SPEAKER BIO

• Founder    of Bytecode Workshop; Creator of HFCD

• Former    Flex Compiler/Profiler Architect & Engineering Lead

• Former    ColdFusion MX Architect & Engineering Lead

• Licensed   Professional Engineer in the Province of Ontario

• Studied   CS and Mech. Eng. at the University of Waterloo
FLEX COMPILER TIMELINE
FLEX COMPILER 1.0-1.5


• Supports   MXML and AS2 (not AS3).

• Based   on the AS2 compiler from Flash Authoring.

• Ported   from C++ to Java for J2EE.

• Invoked   by a MXML servlet.
FLEX COMPILER 1.0-1.5

• Major   challenges from the AS2 compiler.

• Notarchitected or partitioned for Flex - no clear compilation
 phases defined - at least not clear enough for MXML.

• Difficult   to extend; not MXML friendly.

• Pre AS3/AVM+: classes   and assets were both first-class citizens
 - very difficult to implement a good linker.
FLEX COMPILER 2.0 - 4.0

• Itis a multi-language compiler. It supports mxml, as, css,
  properties and now fxg.

• There is a “mini compiler” for each language. Each “mini
  compiler” implements some well-defined compilation phases.

• The “top level” Flex compiler becomes a coordinator -
  responsible for looking up source and SWC files; determines
  when and which “mini compiler” to call; etc...
“MINI COMPILER” EXAMPLES

                  Package                 Class

                                     InterfaceCompiler,
 MXML        flex2.compiler.mxml
                                  ImplementationCompiler

   AS3        flex2.compiler.as3        As3Compiler
   CSS        flex2.compiler.css        CssCompiler
  ABC        flex2.compiler.abc         AbcCompiler
Properties   flex2.compiler.i18n       I18nCompiler
SPECIAL CASE: MXML

• Why    are there 2 “mini compilers” for MXML?

• InterfaceCompiler
                  for MXML produces API signature. Does
 not produce abc bytecode in generate().

• ImplementationCompiler   for MXML generates “full AS3
 source code” only after knowing dependent type info.
 Generates abc bytecode in generate().

• But   why?
SPECIAL CASE: MXML

• Consider   this: <c:MyComp ...><c:prop .../></c:MyComp>

• Need to know the meaning of every tag in MXML before
 accurate MXML-to-AS3 conversion could happen.

• Is “prop” a   component or is it a property of “MyComp”?

• We   must know the API signature of “MyComp”!
COMPILATION PHASES

• preprocess()   • analyze4()

• parse1()       • generate()

• parse2()       • postprocess()

• analyze1()

• analyze2()

• analyze3()
COMPILATION PHASES

preprocess() preparation works before parsing.

              generates syntax tree; identifies top-level
 parse1()
              definitions, superclasses and interfaces.
              rarely used. used only by the MXML “mini
 parse2()
              compiler” for data binding.
              performs flow analysis. can’t proceed without
 analyze1()   superclass and interface info. checks syntax tree
              and identifies namespaces.
COMPILATION PHASES

             flow analysis continued. identifies unknown
analyze2()
             references.
             performs constant and metadata evaluation.
analyze3()
             resolve unknown references in syntax trees.
             finalizes constant evaluation. all symbols fully
analyze4()
             resolved. also performs “lint” evaluation.
             performs code generation. produces abc
generate()
             bytecode.
A SIMPLE ILLUSTRATION
Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
A SIMPLE ILLUSTRATION
Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
A SIMPLE ILLUSTRATION
Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
A SIMPLE ILLUSTRATION
Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
A SIMPLE ILLUSTRATION
Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
A SIMPLE ILLUSTRATION
Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
A SIMPLE ILLUSTRATION
Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
A SIMPLE ILLUSTRATION
Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
A SIMPLE ILLUSTRATION
Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
A SIMPLE ILLUSTRATION
Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
A SIMPLE ILLUSTRATION
Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
A SIMPLE ILLUSTRATION
Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
A SIMPLE ILLUSTRATION
Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
A SIMPLE ILLUSTRATION
Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
A SIMPLE ILLUSTRATION
Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
COMPILER EXTENSIONS

• The “mini
         compiler” implementations are “shared” code
 among SDK tools.

• mxmlc, compc   and asdoc all use the “mini compilers” but they
 serve different purposes. They need to do different things at
 the end of each compilation phase.

• Solution: “mini   compiler” supports “compiler extension”.

• Implement   the “flex2.compiler.as3.Extension” interface.
EXTENSION EXAMPLES

• ASDocExtension

• DataBindingExtension

• EmbedExtension

• SignatureExtension

• StyleExtension
FLEX 4: YAFCEM

• YAFCEM?? Yet Another    Flex Compiler Extension Mechanism

• Introducedin Flex 4. Flex developers could insert Java code
 into the compiler. The compiler would execute the Java code
 at a number of locations defined by the extension interfaces.

• e.g. IApplicationExtension, ILibraryExtension.

• Note: Theyare not executed at the end of the mini compiler
 compilation phases. e.g. IApplicationExtension executed at the
 end of Application.build().
TRANSCODERS

• When there is an [Embed] in your code, how does the
 compiler process it?

• Answer: EmbedExtension. EmbedExtension        uses transcoders.

• Typically   generates an AS3 class and a SWF asset tag.

• The generated classes are handed to the “top-level” compiler
 “coordinator”. The classes are then scheduled to be compiled
 and linked.
TRANSCODERS

• Transcoders   implement the “flex2.compiler.Transcoder”
 interface.

• The interface looks simple. However, implementation could be
 tricky because:

 • one   must be familiar with the SWF file format.

 • one   must know what to generate for the asset classes.

 • use   -keep-generated-actionscript to learn about codegen.
TRANSCODER EXAMPLES

• DataTranscoder            • SVGTranscoder

• FontTranscoder            • morein the
                             “flex2.compiler.media”
• JPEGTranscoder             package.
• LosslessImageTranscoder

• MovieTranscoder

• SoundTranscoder
LINKER

• The   Flex compiler not just compiles. It also links.

• Application   SWFs and library (SWC) SWFs are different.

• Application SWFs typically have 2 frames: Preloader and
 essential Flex framework classes in the 1st frame. The rest of
 the application and framework classes in the 2nd frame.

• LibrarySWFs are simpler: everything in one frame. Debug info
 is always embedded. No SWF optimizations.
LINKER

• The SWF structure of these 2 SWF types are encapsulated in
 2 Flex classes.

• Application: flex2.linker.FlexMovie

• Library: flex2.compiler.swc.SwcMovie

• Both  classes (the generate() method) take a list of compilation
 units; run dependency analysis; determine export order and
 generate SWF.
LINKER

• Theexport order of application SWFs is important because
 the ActionScript VM in the Player demands the export order
 be based on type dependencies. It is a reasonable demand
 because that simplifies VM class loading and verification.

• Use topological sort to determine export order. In fact,
 topological sort is used in the compile phase as well (for
 processing AS3 inheritance chains in the AS3 compiler and for
 circular dependency detection).
TOPOLOGICAL SORT

•A     vertex represents a definition (e.g. a class or a function).

•A  directed edge between two vertices represents the
  dependency between the two definitions. For example, when
  vertex B points to vertex A, that means A depends on B.

• Ifa vertex has no arrow pointing towards it, it goes to the
  export order. The vertex is then removed. Its edges (all
  pointing outwards) are also removed. This step continues.
TOPOLOGICAL SORT


• The sorting ends when the in-degrees of all the vertices in the
  dependency graph are not zero.

• Ifthere are still vertices in the graph, those definitions are in
  some circular dependency loops.
POST-LINK

• Foreach file compiled, the compiler generates a set of
 ActionScript bytecode. It is self-contained, completed with a
 constant pool, a set of API signatures and a set of function
 bodies.

• Anapplication SWF, if un-optimized, can have a lot of constant
 pools. They can be quite overlapping.

• One   of the key steps in the post-link phase is “abc merging”.
FLEX COMPILER API

• Flex   toolchains need a simple way to invoke the compiler.

• Users    of the Flex Compiler API:

  • Flex   Builder

  • SAP

  • Flex   Data Services
FLEX COMPILER API

• Recently, one
             of the users of the Flex Compiler API is HellFire
 Compiler Daemon (HFCD).

• The APIclasses are in the flex2.tools.oem and
 flex2.tools.flexbuilder packages.

• Use
    flex2.tools.oem.Application to build applications and
 modules.

• Use   flex2.tools.oem.Library to build libraries.
FLEX COMPILER API

      Application app = new Application(new File(“HelloWorld.mxml”));
      app.setOutput(new File(“HelloWorld.swf ”));
      Configuration config = app.getDefaultConfiguration();
SWF   config.setXXX(...);
      app.setConfiguration(config);
      app.build(true);

      Library lib = new Library();
      lib.addComponent(...);
      lib.setOutput(...);
      Configuration config = app.getDefaultConfiguration();
SWC   config.setSourcePath(...);
      config.setXXX(...);
      lib.setConfiguration(config);
      lib.build(true);
FLEX COMPILER API

• The API
        usage is simple, but toolchains usually do more... They
 implement some of the following compiler interfaces.

 • Logger

 • ProgressMeter

 • PathResolver

 • Report
HELLFIRE COMPILER DAEMON

• What   is HFCD? It is an out-of-process Flex compiler.

• Socket, TCP/IP   based. Implemented a RPC version of the Flex
 Compiler API.

• Usehardware, multicore technologies to speed up build
 performance.

• Eclipse   based. Flex Builder compatible. FDT support coming
 soon.
HFCD ARCHITECTURE
HFCD ADVANTAGES

• Socket based. Could run HFCD on a second machine (i.e.
 access to more CPU and memory resources).

• Use Java server VM to run the compiler. Consistently 30%
 faster than Java client VM.

• Withmultiple CPU cores, HFCD builds applications/libraries
 concurrently if possible. Build speedup factor could reach the
 number of available CPUs.
HFCD ADVANTAGES

• Use
    HFCD ant tasks, the ant <parallel> task and multiple
 HFCD servers to build.

• For   more information, please visit:

  • http://bytecode-workshop.com

  • http://stopcoding.wordpress.com
HFCD DEMO
Q/A

More Related Content

What's hot

Introduction to ,NET Framework
Introduction to ,NET FrameworkIntroduction to ,NET Framework
Introduction to ,NET Framework
ANURAG SINGH
 
2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)
Shoaib Ghachi
 
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
yazad dumasia
 
Java v/s .NET - Which is Better?
Java v/s .NET - Which is Better?Java v/s .NET - Which is Better?
Java v/s .NET - Which is Better?
NIIT India
 
.NET Framework 4.0 – Changes & Benefits
.NET Framework 4.0 – Changes & Benefits .NET Framework 4.0 – Changes & Benefits
.NET Framework 4.0 – Changes & Benefits
Deepika Chaudhary
 
Dotnet framework
Dotnet frameworkDotnet framework
Dotnet frameworkNitu Pandey
 
PIL - A Platform Independent Language
PIL - A Platform Independent LanguagePIL - A Platform Independent Language
PIL - A Platform Independent Language
zefhemel
 
llvm-py: Writing Compilers In Python
llvm-py: Writing Compilers In Pythonllvm-py: Writing Compilers In Python
llvm-py: Writing Compilers In Python
mdevan
 
.NET Vs J2EE
.NET Vs J2EE.NET Vs J2EE
.NET Vs J2EE
ravikirantummala2000
 
What is-java
What is-javaWhat is-java
What is-java
Shahid Rasheed
 
Creating Windows Runtime Components
Creating Windows Runtime Components Creating Windows Runtime Components
Creating Windows Runtime Components
Mirco Vanini
 
The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)
The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)
The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)
citizenmatt
 
.Net framework
.Net framework.Net framework
.Net framework
Yogendra Tamang
 
Dev buchan leveraging the notes c api
Dev buchan leveraging the notes c apiDev buchan leveraging the notes c api
Dev buchan leveraging the notes c apiBill Buchan
 
C# 3.0 and 4.0
C# 3.0 and 4.0C# 3.0 and 4.0
C# 3.0 and 4.0
Buu Nguyen
 
Visual Studio 2010 and .NET Framework 4.0 Overview
Visual Studio 2010 and .NET Framework 4.0 OverviewVisual Studio 2010 and .NET Framework 4.0 Overview
Visual Studio 2010 and .NET Framework 4.0 Overview
Harish Ranganathan
 
Java byte code presentation
Java byte code presentationJava byte code presentation
Java byte code presentation
Mahnoor Hashmi
 
An Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and RuntimeAn Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and Runtime
Omar Bashir
 

What's hot (20)

Introduction to ,NET Framework
Introduction to ,NET FrameworkIntroduction to ,NET Framework
Introduction to ,NET Framework
 
2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)
 
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
 
Java v/s .NET - Which is Better?
Java v/s .NET - Which is Better?Java v/s .NET - Which is Better?
Java v/s .NET - Which is Better?
 
.NET Framework 4.0 – Changes & Benefits
.NET Framework 4.0 – Changes & Benefits .NET Framework 4.0 – Changes & Benefits
.NET Framework 4.0 – Changes & Benefits
 
History of java'
History of java'History of java'
History of java'
 
Dotnet framework
Dotnet frameworkDotnet framework
Dotnet framework
 
PIL - A Platform Independent Language
PIL - A Platform Independent LanguagePIL - A Platform Independent Language
PIL - A Platform Independent Language
 
Net framework
Net frameworkNet framework
Net framework
 
llvm-py: Writing Compilers In Python
llvm-py: Writing Compilers In Pythonllvm-py: Writing Compilers In Python
llvm-py: Writing Compilers In Python
 
.NET Vs J2EE
.NET Vs J2EE.NET Vs J2EE
.NET Vs J2EE
 
What is-java
What is-javaWhat is-java
What is-java
 
Creating Windows Runtime Components
Creating Windows Runtime Components Creating Windows Runtime Components
Creating Windows Runtime Components
 
The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)
The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)
The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)
 
.Net framework
.Net framework.Net framework
.Net framework
 
Dev buchan leveraging the notes c api
Dev buchan leveraging the notes c apiDev buchan leveraging the notes c api
Dev buchan leveraging the notes c api
 
C# 3.0 and 4.0
C# 3.0 and 4.0C# 3.0 and 4.0
C# 3.0 and 4.0
 
Visual Studio 2010 and .NET Framework 4.0 Overview
Visual Studio 2010 and .NET Framework 4.0 OverviewVisual Studio 2010 and .NET Framework 4.0 Overview
Visual Studio 2010 and .NET Framework 4.0 Overview
 
Java byte code presentation
Java byte code presentationJava byte code presentation
Java byte code presentation
 
An Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and RuntimeAn Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and Runtime
 

Viewers also liked

Gulf Coast HUG Meetup June 2015
Gulf Coast HUG Meetup June 2015Gulf Coast HUG Meetup June 2015
Gulf Coast HUG Meetup June 2015
SPROUT Content
 
Kentcources 110109221507-phpapp01
Kentcources 110109221507-phpapp01Kentcources 110109221507-phpapp01
Kentcources 110109221507-phpapp01Giang Nguyễn
 
Ios wordpress
Ios wordpressIos wordpress
Ios wordpress
Đô Nguyễn
 
初鄉親職講綱100.05.04正確
初鄉親職講綱100.05.04正確初鄉親職講綱100.05.04正確
初鄉親職講綱100.05.04正確Kuo-Yi Chen
 
Bandar berpusatkan rumah ibadah
Bandar berpusatkan rumah ibadahBandar berpusatkan rumah ibadah
Bandar berpusatkan rumah ibadah
miraisyaa Aisyah
 
Ten tips to quit coffee
Ten tips to quit coffeeTen tips to quit coffee
Ten tips to quit coffee
kapustak
 
Citizen Science: Association of American Medical Colleges
Citizen Science: Association of American Medical CollegesCitizen Science: Association of American Medical Colleges
Citizen Science: Association of American Medical CollegesDarlene Cavalier
 
Cynergi Project Portfolio
Cynergi Project PortfolioCynergi Project Portfolio
Cynergi Project Portfolio
rmaris
 
предложение для It партнеров клуба magnat - всем
предложение для It партнеров клуба magnat - всемпредложение для It партнеров клуба magnat - всем
предложение для It партнеров клуба magnat - всемSokirianskiy&Lazerson School
 
Chapter 11 presention
Chapter 11 presentionChapter 11 presention
Chapter 11 presentionsheila77reyes
 
Bill Kasdorf - Apex Content Solutions - Agile processes, agile publications (...
Bill Kasdorf - Apex Content Solutions - Agile processes, agile publications (...Bill Kasdorf - Apex Content Solutions - Agile processes, agile publications (...
Bill Kasdorf - Apex Content Solutions - Agile processes, agile publications (...Erich van Rijn
 
Super matematika gasing
Super matematika gasing Super matematika gasing
Super matematika gasing
Budi Santoso
 
There's an app for that (revalidatie blinde en slechtziende mensen)
There's an app for that (revalidatie blinde en slechtziende mensen)There's an app for that (revalidatie blinde en slechtziende mensen)
There's an app for that (revalidatie blinde en slechtziende mensen)
Christiaan Pinkster
 
Blog writing presentation
Blog writing presentationBlog writing presentation
Blog writing presentation
SPROUT Content
 
Main task evaluation
Main task evaluationMain task evaluation
Main task evaluation
nanzbx
 
2008 Anglers Catalog
2008 Anglers Catalog2008 Anglers Catalog
2008 Anglers Catalogflyfish49
 
Glossary on environmental health
Glossary on environmental healthGlossary on environmental health
Glossary on environmental healthmelo2008
 
Programa oficial 5 de junio Hipodromo Independencia ROSARIO (COPA UTTA)
Programa oficial 5 de junio Hipodromo Independencia ROSARIO (COPA UTTA)Programa oficial 5 de junio Hipodromo Independencia ROSARIO (COPA UTTA)
Programa oficial 5 de junio Hipodromo Independencia ROSARIO (COPA UTTA)
UTTA OSPAT
 
Thankful Journal- Jaden
Thankful Journal- JadenThankful Journal- Jaden
Thankful Journal- Jadenmicklethwait
 

Viewers also liked (20)

Gulf Coast HUG Meetup June 2015
Gulf Coast HUG Meetup June 2015Gulf Coast HUG Meetup June 2015
Gulf Coast HUG Meetup June 2015
 
Kentcources 110109221507-phpapp01
Kentcources 110109221507-phpapp01Kentcources 110109221507-phpapp01
Kentcources 110109221507-phpapp01
 
Ios wordpress
Ios wordpressIos wordpress
Ios wordpress
 
3 системы оплаты труда
3   системы оплаты труда3   системы оплаты труда
3 системы оплаты труда
 
初鄉親職講綱100.05.04正確
初鄉親職講綱100.05.04正確初鄉親職講綱100.05.04正確
初鄉親職講綱100.05.04正確
 
Bandar berpusatkan rumah ibadah
Bandar berpusatkan rumah ibadahBandar berpusatkan rumah ibadah
Bandar berpusatkan rumah ibadah
 
Ten tips to quit coffee
Ten tips to quit coffeeTen tips to quit coffee
Ten tips to quit coffee
 
Citizen Science: Association of American Medical Colleges
Citizen Science: Association of American Medical CollegesCitizen Science: Association of American Medical Colleges
Citizen Science: Association of American Medical Colleges
 
Cynergi Project Portfolio
Cynergi Project PortfolioCynergi Project Portfolio
Cynergi Project Portfolio
 
предложение для It партнеров клуба magnat - всем
предложение для It партнеров клуба magnat - всемпредложение для It партнеров клуба magnat - всем
предложение для It партнеров клуба magnat - всем
 
Chapter 11 presention
Chapter 11 presentionChapter 11 presention
Chapter 11 presention
 
Bill Kasdorf - Apex Content Solutions - Agile processes, agile publications (...
Bill Kasdorf - Apex Content Solutions - Agile processes, agile publications (...Bill Kasdorf - Apex Content Solutions - Agile processes, agile publications (...
Bill Kasdorf - Apex Content Solutions - Agile processes, agile publications (...
 
Super matematika gasing
Super matematika gasing Super matematika gasing
Super matematika gasing
 
There's an app for that (revalidatie blinde en slechtziende mensen)
There's an app for that (revalidatie blinde en slechtziende mensen)There's an app for that (revalidatie blinde en slechtziende mensen)
There's an app for that (revalidatie blinde en slechtziende mensen)
 
Blog writing presentation
Blog writing presentationBlog writing presentation
Blog writing presentation
 
Main task evaluation
Main task evaluationMain task evaluation
Main task evaluation
 
2008 Anglers Catalog
2008 Anglers Catalog2008 Anglers Catalog
2008 Anglers Catalog
 
Glossary on environmental health
Glossary on environmental healthGlossary on environmental health
Glossary on environmental health
 
Programa oficial 5 de junio Hipodromo Independencia ROSARIO (COPA UTTA)
Programa oficial 5 de junio Hipodromo Independencia ROSARIO (COPA UTTA)Programa oficial 5 de junio Hipodromo Independencia ROSARIO (COPA UTTA)
Programa oficial 5 de junio Hipodromo Independencia ROSARIO (COPA UTTA)
 
Thankful Journal- Jaden
Thankful Journal- JadenThankful Journal- Jaden
Thankful Journal- Jaden
 

Similar to In-depth look at the Flex compiler and HFCD

Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
AboutYouGmbH
 
Core JavaScript
Core JavaScriptCore JavaScript
Core JavaScript
Lilia Sfaxi
 
Chapter 1.pptx
Chapter 1.pptxChapter 1.pptx
Chapter 1.pptx
NesredinTeshome1
 
Lex
LexLex
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
corehard_by
 
.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3
aminmesbahi
 
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
Jung Kim
 
Binding Objective-C Libraries, Miguel de Icaza
Binding Objective-C Libraries, Miguel de IcazaBinding Objective-C Libraries, Miguel de Icaza
Binding Objective-C Libraries, Miguel de IcazaXamarin
 
Why scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with thisWhy scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with this
Ruslan Shevchenko
 
Unit1 cd
Unit1 cdUnit1 cd
Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?
Eelco Visser
 
Building Better AWS Lambdas: Unlocking the Power of Layers
Building Better AWS Lambdas: Unlocking the Power of LayersBuilding Better AWS Lambdas: Unlocking the Power of Layers
Building Better AWS Lambdas: Unlocking the Power of Layers
ujjwalsoni23
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Andres Baravalle
 
C++ on the Web: Run your big 3D game in the browser
C++ on the Web: Run your big 3D game in the browserC++ on the Web: Run your big 3D game in the browser
C++ on the Web: Run your big 3D game in the browser
Andre Weissflog
 
Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processors
Rebaz Najeeb
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
Akhil Kaushik
 
Unit 1.pptx
Unit 1.pptxUnit 1.pptx
Unit 1.pptx
NISHASOMSCS113
 
Introduction to the LLVM Compiler System
Introduction to the LLVM  Compiler SystemIntroduction to the LLVM  Compiler System
Introduction to the LLVM Compiler System
zionsaint
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.pptx
SubashiniRathinavel
 
Intro to Microsoft.NET
Intro to Microsoft.NET Intro to Microsoft.NET
Intro to Microsoft.NET rchakra
 

Similar to In-depth look at the Flex compiler and HFCD (20)

Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
 
Core JavaScript
Core JavaScriptCore JavaScript
Core JavaScript
 
Chapter 1.pptx
Chapter 1.pptxChapter 1.pptx
Chapter 1.pptx
 
Lex
LexLex
Lex
 
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
 
.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3
 
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
 
Binding Objective-C Libraries, Miguel de Icaza
Binding Objective-C Libraries, Miguel de IcazaBinding Objective-C Libraries, Miguel de Icaza
Binding Objective-C Libraries, Miguel de Icaza
 
Why scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with thisWhy scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with this
 
Unit1 cd
Unit1 cdUnit1 cd
Unit1 cd
 
Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?
 
Building Better AWS Lambdas: Unlocking the Power of Layers
Building Better AWS Lambdas: Unlocking the Power of LayersBuilding Better AWS Lambdas: Unlocking the Power of Layers
Building Better AWS Lambdas: Unlocking the Power of Layers
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
C++ on the Web: Run your big 3D game in the browser
C++ on the Web: Run your big 3D game in the browserC++ on the Web: Run your big 3D game in the browser
C++ on the Web: Run your big 3D game in the browser
 
Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processors
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
 
Unit 1.pptx
Unit 1.pptxUnit 1.pptx
Unit 1.pptx
 
Introduction to the LLVM Compiler System
Introduction to the LLVM  Compiler SystemIntroduction to the LLVM  Compiler System
Introduction to the LLVM Compiler System
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.pptx
 
Intro to Microsoft.NET
Intro to Microsoft.NET Intro to Microsoft.NET
Intro to Microsoft.NET
 

Recently uploaded

Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 

Recently uploaded (20)

Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 

In-depth look at the Flex compiler and HFCD

  • 1. IN-DEPTH LOOK AT THE FLEX COMPILER AND HFCD Clement Wong clement@stopcoding.org http://stopcoding.wordpress.com
  • 2. AGENDA • Basic Architecture of Flex Compiler • Compiler Extensibility • Overview of Flex Compiler API • HellFire Compiler Daemon (HFCD) • Demo, Q/A
  • 3. SPEAKER BIO • Founder of Bytecode Workshop; Creator of HFCD • Former Flex Compiler/Profiler Architect & Engineering Lead • Former ColdFusion MX Architect & Engineering Lead • Licensed Professional Engineer in the Province of Ontario • Studied CS and Mech. Eng. at the University of Waterloo
  • 5. FLEX COMPILER 1.0-1.5 • Supports MXML and AS2 (not AS3). • Based on the AS2 compiler from Flash Authoring. • Ported from C++ to Java for J2EE. • Invoked by a MXML servlet.
  • 6. FLEX COMPILER 1.0-1.5 • Major challenges from the AS2 compiler. • Notarchitected or partitioned for Flex - no clear compilation phases defined - at least not clear enough for MXML. • Difficult to extend; not MXML friendly. • Pre AS3/AVM+: classes and assets were both first-class citizens - very difficult to implement a good linker.
  • 7. FLEX COMPILER 2.0 - 4.0 • Itis a multi-language compiler. It supports mxml, as, css, properties and now fxg. • There is a “mini compiler” for each language. Each “mini compiler” implements some well-defined compilation phases. • The “top level” Flex compiler becomes a coordinator - responsible for looking up source and SWC files; determines when and which “mini compiler” to call; etc...
  • 8. “MINI COMPILER” EXAMPLES Package Class InterfaceCompiler, MXML flex2.compiler.mxml ImplementationCompiler AS3 flex2.compiler.as3 As3Compiler CSS flex2.compiler.css CssCompiler ABC flex2.compiler.abc AbcCompiler Properties flex2.compiler.i18n I18nCompiler
  • 9. SPECIAL CASE: MXML • Why are there 2 “mini compilers” for MXML? • InterfaceCompiler for MXML produces API signature. Does not produce abc bytecode in generate(). • ImplementationCompiler for MXML generates “full AS3 source code” only after knowing dependent type info. Generates abc bytecode in generate(). • But why?
  • 10. SPECIAL CASE: MXML • Consider this: <c:MyComp ...><c:prop .../></c:MyComp> • Need to know the meaning of every tag in MXML before accurate MXML-to-AS3 conversion could happen. • Is “prop” a component or is it a property of “MyComp”? • We must know the API signature of “MyComp”!
  • 11. COMPILATION PHASES • preprocess() • analyze4() • parse1() • generate() • parse2() • postprocess() • analyze1() • analyze2() • analyze3()
  • 12. COMPILATION PHASES preprocess() preparation works before parsing. generates syntax tree; identifies top-level parse1() definitions, superclasses and interfaces. rarely used. used only by the MXML “mini parse2() compiler” for data binding. performs flow analysis. can’t proceed without analyze1() superclass and interface info. checks syntax tree and identifies namespaces.
  • 13. COMPILATION PHASES flow analysis continued. identifies unknown analyze2() references. performs constant and metadata evaluation. analyze3() resolve unknown references in syntax trees. finalizes constant evaluation. all symbols fully analyze4() resolved. also performs “lint” evaluation. performs code generation. produces abc generate() bytecode.
  • 14. A SIMPLE ILLUSTRATION Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
  • 15. A SIMPLE ILLUSTRATION Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
  • 16. A SIMPLE ILLUSTRATION Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
  • 17. A SIMPLE ILLUSTRATION Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
  • 18. A SIMPLE ILLUSTRATION Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
  • 19. A SIMPLE ILLUSTRATION Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
  • 20. A SIMPLE ILLUSTRATION Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
  • 21. A SIMPLE ILLUSTRATION Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
  • 22. A SIMPLE ILLUSTRATION Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
  • 23. A SIMPLE ILLUSTRATION Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
  • 24. A SIMPLE ILLUSTRATION Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
  • 25. A SIMPLE ILLUSTRATION Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
  • 26. A SIMPLE ILLUSTRATION Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
  • 27. A SIMPLE ILLUSTRATION Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
  • 28. A SIMPLE ILLUSTRATION Assume ‘A’ is a subclass of ‘B’. ‘A’ and ‘B’ reference ‘C’.
  • 29. COMPILER EXTENSIONS • The “mini compiler” implementations are “shared” code among SDK tools. • mxmlc, compc and asdoc all use the “mini compilers” but they serve different purposes. They need to do different things at the end of each compilation phase. • Solution: “mini compiler” supports “compiler extension”. • Implement the “flex2.compiler.as3.Extension” interface.
  • 30. EXTENSION EXAMPLES • ASDocExtension • DataBindingExtension • EmbedExtension • SignatureExtension • StyleExtension
  • 31. FLEX 4: YAFCEM • YAFCEM?? Yet Another Flex Compiler Extension Mechanism • Introducedin Flex 4. Flex developers could insert Java code into the compiler. The compiler would execute the Java code at a number of locations defined by the extension interfaces. • e.g. IApplicationExtension, ILibraryExtension. • Note: Theyare not executed at the end of the mini compiler compilation phases. e.g. IApplicationExtension executed at the end of Application.build().
  • 32. TRANSCODERS • When there is an [Embed] in your code, how does the compiler process it? • Answer: EmbedExtension. EmbedExtension uses transcoders. • Typically generates an AS3 class and a SWF asset tag. • The generated classes are handed to the “top-level” compiler “coordinator”. The classes are then scheduled to be compiled and linked.
  • 33. TRANSCODERS • Transcoders implement the “flex2.compiler.Transcoder” interface. • The interface looks simple. However, implementation could be tricky because: • one must be familiar with the SWF file format. • one must know what to generate for the asset classes. • use -keep-generated-actionscript to learn about codegen.
  • 34. TRANSCODER EXAMPLES • DataTranscoder • SVGTranscoder • FontTranscoder • morein the “flex2.compiler.media” • JPEGTranscoder package. • LosslessImageTranscoder • MovieTranscoder • SoundTranscoder
  • 35. LINKER • The Flex compiler not just compiles. It also links. • Application SWFs and library (SWC) SWFs are different. • Application SWFs typically have 2 frames: Preloader and essential Flex framework classes in the 1st frame. The rest of the application and framework classes in the 2nd frame. • LibrarySWFs are simpler: everything in one frame. Debug info is always embedded. No SWF optimizations.
  • 36. LINKER • The SWF structure of these 2 SWF types are encapsulated in 2 Flex classes. • Application: flex2.linker.FlexMovie • Library: flex2.compiler.swc.SwcMovie • Both classes (the generate() method) take a list of compilation units; run dependency analysis; determine export order and generate SWF.
  • 37. LINKER • Theexport order of application SWFs is important because the ActionScript VM in the Player demands the export order be based on type dependencies. It is a reasonable demand because that simplifies VM class loading and verification. • Use topological sort to determine export order. In fact, topological sort is used in the compile phase as well (for processing AS3 inheritance chains in the AS3 compiler and for circular dependency detection).
  • 38. TOPOLOGICAL SORT •A vertex represents a definition (e.g. a class or a function). •A directed edge between two vertices represents the dependency between the two definitions. For example, when vertex B points to vertex A, that means A depends on B. • Ifa vertex has no arrow pointing towards it, it goes to the export order. The vertex is then removed. Its edges (all pointing outwards) are also removed. This step continues.
  • 39. TOPOLOGICAL SORT • The sorting ends when the in-degrees of all the vertices in the dependency graph are not zero. • Ifthere are still vertices in the graph, those definitions are in some circular dependency loops.
  • 40. POST-LINK • Foreach file compiled, the compiler generates a set of ActionScript bytecode. It is self-contained, completed with a constant pool, a set of API signatures and a set of function bodies. • Anapplication SWF, if un-optimized, can have a lot of constant pools. They can be quite overlapping. • One of the key steps in the post-link phase is “abc merging”.
  • 41. FLEX COMPILER API • Flex toolchains need a simple way to invoke the compiler. • Users of the Flex Compiler API: • Flex Builder • SAP • Flex Data Services
  • 42. FLEX COMPILER API • Recently, one of the users of the Flex Compiler API is HellFire Compiler Daemon (HFCD). • The APIclasses are in the flex2.tools.oem and flex2.tools.flexbuilder packages. • Use flex2.tools.oem.Application to build applications and modules. • Use flex2.tools.oem.Library to build libraries.
  • 43. FLEX COMPILER API Application app = new Application(new File(“HelloWorld.mxml”)); app.setOutput(new File(“HelloWorld.swf ”)); Configuration config = app.getDefaultConfiguration(); SWF config.setXXX(...); app.setConfiguration(config); app.build(true); Library lib = new Library(); lib.addComponent(...); lib.setOutput(...); Configuration config = app.getDefaultConfiguration(); SWC config.setSourcePath(...); config.setXXX(...); lib.setConfiguration(config); lib.build(true);
  • 44. FLEX COMPILER API • The API usage is simple, but toolchains usually do more... They implement some of the following compiler interfaces. • Logger • ProgressMeter • PathResolver • Report
  • 45. HELLFIRE COMPILER DAEMON • What is HFCD? It is an out-of-process Flex compiler. • Socket, TCP/IP based. Implemented a RPC version of the Flex Compiler API. • Usehardware, multicore technologies to speed up build performance. • Eclipse based. Flex Builder compatible. FDT support coming soon.
  • 47. HFCD ADVANTAGES • Socket based. Could run HFCD on a second machine (i.e. access to more CPU and memory resources). • Use Java server VM to run the compiler. Consistently 30% faster than Java client VM. • Withmultiple CPU cores, HFCD builds applications/libraries concurrently if possible. Build speedup factor could reach the number of available CPUs.
  • 48. HFCD ADVANTAGES • Use HFCD ant tasks, the ant <parallel> task and multiple HFCD servers to build. • For more information, please visit: • http://bytecode-workshop.com • http://stopcoding.wordpress.com
  • 50. Q/A

Editor's Notes