<<

Adobe® Flash® Player ActionScript (Tamarin)

Rick Reitmaier Sr. Scientist Adobe Systems

December 6, 2006

1 Copyright 2006 Adobe Systems Incorporated. Adobe Today

Worldwide Offices

Key Statistics

Adobe $1.966B FY 2005 Revenue

Macromedia $436M FY 2005 Revenue Corporate Headquarters – San Jose, California

Years in Business 23

Employees 5,000

2 Copyright 2006 Adobe Systems Incorporated. Widest Reach in the World

600 million PCs and devices

Source: NPD December 2005 3 Copyright 2006 Adobe Systems Incorporated. Device shipment growth is explosive

ƒ 150+ handset models

ƒ 300+ device models

ƒ Over 100 million devices shipped

4 Copyright 2006 Adobe Systems Incorporated. Plug-In Technology Penetration: Mature Markets

Internet Connected Desktops

ƒ Flash Player typically reaches 80% adoption in < 1yr each release.

ƒ Version 8 (Fall 2005) achieved a higher adoption in less time.

ƒ Version 9 (Summer 2006) appears to be following same curve as version 8.

* MillwardBrown, September 2006

5 Copyright 2006 Adobe Systems Incorporated. Momentum

Flash Video Growth MySpace 800x Yahoo YouTube 700x

Viacom 600x ABC/Disney 500x NBC CNET 400x

Comcast 300x Showtime E! OnLine 200x Ralph Lauren/Polo 100x Red Bull 0 ClickTV 2003 2006 2004 Motionbox 2005

6 Copyright 2006 Adobe Systems Incorporated. Anatomy of a Rich Internet Application Menus & Navigation Bi-Directional Controls Audio & Video Data Visualization & Collaboration Real Time Data Push & Alerting Resizable Views/Effects/ Transitions Chat Rich Data Entry Mapping, Geo-Coding, Data Annotations & Synchronization White & Conflict boarding Resolution

Offline

7 Copyright 2006 Adobe Systems Incorporated. All this using a scripting language?

ƒ Strengths

ƒ low barrier to entry

ƒ rapid, flexible development

ƒ familiar

ƒ pervasive (the web wouldn’t compile)

ƒ Opportunities

ƒ safe, predictable and efficient

ƒ debugging

8 Copyright 2006 Adobe Systems Incorporated. A Tale of Names

ECMA Adobe

ƒ 262 edition 2 ƒ JavaScript 1.3

ƒ JavaScript 1.4 ƒ ActionScript 1.0

ƒ 262 edition 3 ƒ JavaScript 1.5

ƒ JavaScript 1.6 ƒ ActionScript 2.0

ƒ JavaScript 1.7

ƒ 262 edition 4 ƒ JavaScript 2.0 ƒ ActionScript 3.0

* JavaScript and ActionScript are trademarked names by Sun Microsystems and Adobe Systems respectively

Copyright 2006 Adobe Systems Incorporated. 9 A bit of history

ƒ Prototype-based scripting language

ƒ no classes

ƒ instances created by cloning other instances

ƒ Self (Ungar, Smith 1987) influenced design

ƒ Object

ƒ consists of a collection of properties, also called ‘slots’

ƒ accessing a slot returns a value and may execute code.

10 Copyright 2006 Adobe Systems Incorporated. Prototype example

var myObj = {}; myObj.value = "this is string" myObj.addProperty("foo", function() { return "foo"; }, null); trace(myObj.value); // <= “this is string" trace(myObj.foo); // <= “foo"

11 Copyright 2006 Adobe Systems Incorporated. Objectifying

ƒ Customers requested “Class”

ƒ added support in Actionscript 2.0

ƒ stitched together using prototypes

ƒ pure compiler only change

ƒ based on unreleased ECMAScript edition 4 proposal

ƒ Explicit data types

ƒ used as annotation for the compiler to perform error checking

ƒ ignored when executing

12 Copyright 2006 Adobe Systems Incorporated. Object Example

class A { var value:String; function get foo():String { return "foo"; } }

var myObj:A = new A();

myObj.value = "this is string"

trace(myObj.value); // <= “this is string" trace(myObj.foo); // <= “foo"

13 Copyright 2006 Adobe Systems Incorporated. Workflow

ƒ Compiler

ƒ local to developers machine

ƒ generates bytecode for a stack based machine

ƒ Bytecode

ƒ bytecode is representative of evolution

ƒ crosses levels of abstraction ; eg. actionPush and actionGetTime

ƒ Run-time

ƒ simple interpreter

14 Copyright 2006 Adobe Systems Incorporated. AVM2

ƒ Trends

ƒ more code being written

ƒ complexity of web applications increasing

ƒ componentization is a growing market

ƒ ActionScript Virtual Machine 2

ƒ addresses performance

ƒ maintains backward compatibility; indirectly

ƒ allows revolutionary innovation to code base

15 Copyright 2006 Adobe Systems Incorporated. Flash Player 9

Enterprise-Class Runtime for Data- Rich Applications

ƒ New Virtual Machine

ƒ Terrific performance improvements

ƒ Reduced memory consumption

ƒ ActionScript 3.0 Flash Player 9 ƒ ECMAScript Edition 4 compliant ƒ Dynamic and typed programming language

ƒ External API integrates w/ AJAX & native apps

ƒ ECMAScript for XML (E4X)

ƒ Seamless Deployment AVM1 AVM2 ƒ One-click upgrade

ƒ Full backward compatibility

16 Copyright 2006 Adobe Systems Incorporated. Challenges

Constraint Solutions

ƒ Flash Player size is ~1MBytes ƒ tight budget for growth compressed

ƒ language specific operations ƒ amount of bytecode required for ƒ variable length encoding ‘typical’ application must remain small ƒ compression

ƒ startup speed critical for ƒ novel just-in-timer compiler interactive applications ƒ novel garbage collector

17 Copyright 2006 Adobe Systems Incorporated. AVM2 Design

ƒ Bytecode

ƒ constant data; strings, numbers, etc

ƒ type and method descriptors

ƒ exception tables

ƒ stack oriented abstract machine

ƒ object creation, slot access, property search

ƒ Run-time engine

ƒ separate verification from execution

ƒ leaner interpreter

ƒ 2-pass just-in-time compiler

ƒ revamped garbage collector

18 Copyright 2006 Adobe Systems Incorporated. AVM2 Architecture

19 Copyright 2006 Adobe Systems Incorporated. AVM2 Garbage collector

ƒ Reusable library

ƒ nothing specific to AVM2

ƒ new / delete (unmanaged memory)

ƒ new only (i.e garbage collected)

ƒ debugging aids, profiling

ƒ Characteristics

ƒ deferred reference counting (DRC)

ƒ backed by incremental, conservative mark and sweep

ƒ incremental = interruptible

ƒ conservative = random bit pattern in memory may be pointer

20 Copyright 2006 Adobe Systems Incorporated. AVM2 Verifier

ƒ Structural Integrity

ƒ ensure branches land on valid instructions

ƒ can’t fall off end of code

ƒ constant references are valid

ƒ Type Safety

ƒ dataflow analysis to track types

ƒ early binding

21 Copyright 2006 Adobe Systems Incorporated. AVM2 Interpreter

ƒ Stack oriented

ƒ no surprises here; non-threaded

ƒ all values boxed; 32bit encoding

ƒ executes directly from verified buffer

ƒ no bytecode modification

22 Copyright 2006 Adobe Systems Incorporated. AVM2 Just-in-Time Compiler (JIT)

ƒ First pass

ƒ intermediate representation (MIR) produced concurrent with verification

ƒ early binding

ƒ constant folding

ƒ copy and constant propagation

ƒ common sub-expression elimination (CSE)

ƒ Second pass

ƒ native code generation

ƒ instruction selection

ƒ register allocation

ƒ dead code elimination (DCE)

23 Copyright 2006 Adobe Systems Incorporated. Tamarin

ƒ AVM2 released to open source community The goal of the "Tamarin" project is to implement a high-performance, open source implementation of the ECMAScript 4th edition (ES4) language specification. The Tamarin virtual machine will be used by Mozilla within SpiderMonkey, the core JavaScript engine embedded in ®, and other products based on Mozilla technology. The code will continue to be used by Adobe as part of the ActionScript™ Virtual Machine within Adobe® Flash® Player.

ƒ Working intimately with Mozilla to integrate with JavaScript engine

ƒ See for yourself

ƒ http://www.mozilla.org/projects/tamarin/

24 Copyright 2006 Adobe Systems Incorporated. Interesting papers

ƒ M. Chen, K. Olukotun, “Targeting Dynamic Compilation for Embedded Environments”

ƒ Computer System Lab, Stanford University

ƒ M. Poletto, V. Sarkar, “Linear Scan Register Allocation”

ƒ U. Hölzle, D. Ungar, “Optimizing Dyamically-Dispatched Calls with Run- Time Type Feedback”

ƒ Computer System Lab, Stanford University / Sun Microsystems

ƒ J. Aycock, “A Brief History of Just-in-Time”

25 Copyright 2006 Adobe Systems Incorporated. 26 Copyright 2006 Adobe Systems Incorporated.