• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
张平:JavaScript引擎实现
 

张平:JavaScript引擎实现

on

  • 13,860 views

 

Statistics

Views

Total Views
13,860
Views on SlideShare
2,894
Embed Views
10,966

Actions

Likes
8
Downloads
83
Comments
1

8 Embeds 10,966

http://www.d2forum.org 10893
http://cache.baidu.com 58
http://www.itfeed.cn 4
http://translate.googleusercontent.com 3
http://xianguo.com 2
http://www.chengxuyuans.com 2
http://www.chengxuyuans.com 2
http://paper.li 2
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    张平:JavaScript引擎实现 张平:JavaScript引擎实现 Presentation Transcript

    • Javascript引擎实现
      Author:张平
      Email:p.zhang.9.25@gmail.com
    • Modules:
      Interpreter
      compiler:parse, tree-walker code generator
      memory manager and garbage collector
      standard library:
      debugger
      JIT
    • memory manager
      • Theoretical Basis:Fast Allocation and Deallocation of Memory Based on Object Lifetimes. Author : David Hanson.
    • GC
      • Mark-Sweep
      • Eliminate recursion:Automated Verification of the Deutsch-Schorr-Waite Tree-Traversal Algorithm。参考:http://www.cs.wisc.edu/wpis/papers/sas06-dsw.pdf
    • JS ObjectInternal:
      __proto__prototype chain
      __parent__scope chain
      __class__record object constructor
    • Prototype-based programming:
      • Class-base:class: structure, behaviorinstance: statefocus first on relationships between classes.
      • Prototype-based:
      No class
      Performed via process of clone objects(prototypes)
      focus on behavior of objects
    • JS prototype chain:
      • __proto__(object construction):Delegation pointer to prototype
      Donot clone prototype
      Propagate changes through the system.
    • JS Scope chain:
      • Scope:scope is an enclosing context where values and expressions are associated.
      • Dynamic scope:
      • Static(lexical scope):
    • JS lexical scope chain:
      • __parent__: Delegation pointer to function’s parent scope.function A{ function B{ print(c);}}A.__parent__ === globalB.__parent__ === A
    • Call Object:
      • Special temporary object that exists while a function is active.
      Provide a pointer to Arguments object.
      Administer the scope chain(closure).
      • Pseudo-code:before function f call:fScope = new CallObject()fScope.__parent__ = f.__parent__
    • Find name:
      fScope
      No failed
      hasProperty(c)
      fScope = fScope.__parent__
      • How to generate closure:
      Function use nonlocal variables
      Function will invoke again in another scope.
      • Call object: add function’s parameters and local variables to scope chain and serve as closure’s context.
      Closure:
    • Closure:
      • Pseudo-code:function A(){var a = 1; function B(){ return ++a; } return B}generate callA: callA.__parent__ === globalcloned function B as clonedB:clonedB.__proto__ === BclonedB.__parent__ === callAreturn clonedB
    • Thanks!