# Tamarin abcFormat

This document comes from an older version of the Javascript language implementation from the Mozilla project. It describes the compiled format of the ECMAScript version 4 (ECMA-262). Unfortunately, it looks like that document disappeared from the Mozilla website. The implementation can be found (I think) in the Tamarin project (also called Rhino—don't ask me about all these names... I have no clue.) The Tamarin project is what Adobe Flash officially uses for their Javascript player. What I have a hard time to understand is this: it looks like the Tamarin implementation is not in C nor C++ and yet the Flash players don't have 1 megazillion java or whatnot files to install. Hmmmm... They probably have one or two large libraries in some jarball. From the original document, I removed the top Mozilla logo (since you are viewing this page on a different website!) I have changed the broken links to a blue colored text. This gives you an idea of where things were and maybe to find the docs/implementations again. At some point, I will move this information to my reference instead. (See here: SWF Alexis' Reference) Alexis Wilke

LXR Roots - mozilla Cross Reference: mozilla mozilla/ js/ tamarin/ core/ abcFormat.txt |
CVS Log CVS Blame CVS Graph Raw output
changes to this file in the last: | day week month

      001  This file stays synchronized with the source code.  To view
      002  previous formats that we don't support, sync backwards in
      003  perforce.
      004
      005
      006  U30 - This is a 30 bit integer value encoded with a variable number of bytes to save space.
      007  All U30's are encoded as 1-5 bytes depending on the value (larger values need more space).
      008  The encoding method is if the hi bit in the current byte is set, then the next byte is also
      009  part of the value.  Each bit in a byte contributes 7 bits to the value, with the hi bit telling
      010  us whether to use the next byte, or if this is the last byte for the value.  This enables us to
      011  use 30 bit numbers for everything, but still not take up enormous amounts of space.
      012
      013  If more than 30 nonzero bits are present for a U30 field, a verify error will occur.
      014
      015  S32,U32 - same as U30 but 32 bits are allowed instead of being capped at 30.
      016
      017  The "0" entry of each constant pool is not used.  If the count for a given pool says there are
      018  "n" entries in the pool, there are "n-1" entries in the file, corresponding to indices 1..(n-1).
      019
      020  AbcFile {
      021     U16 minor_version                  // = 16 (0x10)
      022     U16 major_version                  // = 46 (0x2E)
      023     U30 constant_int_pool_count
      024     ConstantInteger[constant_int_pool_count]                // Cpool entries for integers
      025     U30 constant_uint_pool_count
      026     ConstantUInteger[constant_uint_pool_count]              // Cpool entries for uints
      027     U30 constant_double_pool_count
      028     ConstantDouble[constant_double_pool_count]              // Cpool entries for doubles
      029     U30 constant_string_pool_count
      030     ConstantString[constant_string_pool_count]              // Cpool entries for strings
      031     U30 constant_namespace_pool_count
      032     ConstantNamespace[constant_namespace_pool_count]        // Cpool entries for namespaces
      033     U30 constant_namespace_set_pool_count
      034     ConstantNamespaceSet[constant_namespace_set_pool_count] // Cpool entries for namespace sets
      035     U30 constant_multiname_pool_count
      036     ConstantMultiname[constant_multiname_pool_count]        // Cpool entries for Multinames, Qnames, RTQnames, and RTQnamesLate
      037     U30 methods_count
      038     MethodInfo[methods_count]
      039     U30 metadata_count
      040     MetadataInfo[metadata_count]
      041     U30 class_count
      042     InstanceInfo[class_count]
      043     ClassInfo[class_count]
      044     U30 script_count
      045     ScriptInfo[script_count]         // ScriptInfo[script_count-1] is main entry point
      046     U30 bodies_count
      047     MethodBody[bodies_count]
      048  }
      049
      050
      051  ConstantInteger {
      052     S32 value
      053  }
      054
      055  ConstantUInteger {
      056     U32 value
      057  }
      058
      059  ConstantDouble {
      060     U64 doublebits (little endian)
      061  }
      062
      063  ConstantString {
      064     U30 length
      065     U8[length]  // UTF-8 encoded string
      066  }
      067
      068  ConstantNamespace {
      069     U8 kind
      070     union {
      071        kind=8,5,22,23,24,25,26 {	// CONSTANT_Namespace,
      					// CONSTANT_PrivateNamespace,
    					// CONSTANT_PackageNamespace,
    					// CONSTANT_PacakgeInternalNamespace,
    					// CONSTANT_ProtectedNamespace,
    					// CONSTANT_ExplicitNamespace,
    					// CONSTANT_MultinameL
      072           U30 name_index          // CONSTANT_Utf8 uri (maybe 0)
      073        }
      074     }
      075  }
      076
      077  ConstantNamespaceSet {
      078     U30 namespace_count
      079     U30[namespace_count] // CONSTANT_Namespace
      080  }
      081
      082  ConstantMultiname {
      083     U8 kind
      084     union {
      085        kind=7,13 {               // CONSTANT_Qname + CONSTANT_QnameA
      086           U30 namespace_index             // CONSTANT_Namespace, 0=AnyNamespace wildcard
      087           U30 name_index                  // CONSTANT_Utf8, 0=AnyName wildcard
      088        }
      089        kind=9,14 {               // CONSTANT_Multiname, CONSTANT_MultinameA
      090           U30 name_index                  // CONSTANT_Utf8  simple name.  0=AnyName wildcard
      091           U30 namespace_set_index
      092        }
      093        kind=15,16 {              // CONSTANT_RTQname + CONSTANT_RTQnameA
      094           U30 name_index                  // CONSTANT_utf8, 0=AnyName wildcard
      095        }
      096        kind=27 {                 // CONSTANT_MultinameL
      097           U30 namespace_set_index
                 }
      098        kind=17,18                // CONSTANT_RTQnameL + CONSTANT_RTQnameLA
      099     }
      100  }
      101
      102  Traits {
      103      U30 count
      104      Trait[count] {
      105          U30 name_index                     // CONSTANT_QName
      106          U8  kind                           // hi 4 bits are flags, 0x04: (1=has_metadata, 0=no metadata)
      107          union {
      108             kind=0,6 { // slot, const
      109                U30 slot_id                  // 0=autoassign
      110                U30 type_index               // CONSTANT_Multiname, 0=Object
      111                U30 value_index              // CONSTANT_<kind> or 0 for undefined - <kind> depends on the value of value_kind
      112                U8  value_kind               // cpool kind the value is, only present if value_index != 0
      113             }
      114             kind=1,2,3 { // method, getter, setter
      115                U30 disp_id                         // 0=autoassign
      116                U30 method_info         // method must be parsed already
      117                       // attrs are stored in the hi 4 bits of the kind byte
      118               // 0x01: (1=final,0=virtual), 0x02: (1=override,0=new)
      119             }
      120             kind=4 { // class
      121                U30 slot_id                  // 0=autoassign
      122                U30 class_info               // class must have been parsed already
      123             }
      124             kind=5 { // function
      125                U30 slot_index          // 0=autoassign
      126                U30 method_info             // method_info of function residing in this slot
      127             }
      128          }
      129          if ( (kind >> 4) & 0x04 )  // these are only present when the kind contains the has_metadata flag
      130          {
      131              U30 metadata_count           // Number of metadata
      132              U30 metadata[count]          // MetadataInfo indices
      133          }
      134      }
      135  }
      136
      137  MetadataInfo {
      138      U30 name_index                         // CONSTANT_utf8
      139      U30 values_count                       // # of values in this metadata
      140      U30 keys[values_count]                 // CONSTANT_utf8, 0 = keyless
      141      U30 values[values_count]               // CONSTANT_utf8
      142  }
      143
      144  InstanceInfo {
      145      U30 name_index                    // CONSTANT_QName (definition)
      146      U30 super_index                   // CONSTANT_Multiname (reference)
      147      U8  flags                         // 1 = sealed, 0 = dynamic
      148                                        // 2 = final
      149                                        // 4 = interface
      150      U30 protectedNS                   if flags & 8
      151      U30 interfaces_count
      152      U30 interfaces[interfaces_count]  // CONSTANT_Multiname (references)
      153      U30 iinit_index                   // MethodInfo
      154      Traits instance_traits
      155  }
      156
      157  ClassInfo {
      158      U30 cinit_index                     // MethodInfo
      159      Traits static_traits
      160  }
      161
      162  ScriptInfo {
      163      U30 init_index                      // MethodInfo
      164      Traits traits
      165  }
      166
      167  // A MethodInfo describes the method signature
      168  MethodInfo {
      169      U30 param_count
      170      U30 ret_type                                          // CONSTANT_Multiname, 0=any type (*)
      171      U30 param_types[param_count]          // CONSTANT_Multiname, 0=any type (*)
      172      U30 name_index                    // 0=no name.
      173      // 1=need_arguments, 2=need_activation, 4=need_rest 8=has_optional 16=ignore_rest, 32=explicit, 64=setsdxns, 128=has_paramnames
      174      U8 flags
      175      U30 optional_count                // if has_optional
      176      ValueKind[optional_count]         // if has_optional
      177      U30 param_names[param_count]      // if has_paramnames
      178  }
      179
      180  ValueKind {
      181      U30 value_index   // the index for the value in the cpool
      182      U8 value_kind     // the kind indicating which cpool the value is in
      183  }
      184
      185  // A MethodBody describes the method implementation.
      186  // not required for native methods or interface methods.
      187  MethodBody {
      188      U30 method_info
      189      U30 max_stack
      190      U30 max_regs
      191      U30 scope_depth
      192      U30 max_scope
      193      U30 code_length
      194      U8 code[code_length]
      195      U30 ex_count
      196      Exception[ex_count]
      197      Traits traits       // activation traits
      198  }
      199
      200  Exception {
      201      U30 start                           // Offsets of beginning and
      202      U30 end                             // end of the try block
      203      U30 target                          // Target PC to transfer control to (catch)
      204      U30 type_index                      // Type matched by this exception handler
      205      U30 name_index                      // Name of the exception variable
      206  }

This page was automatically generated by LXR.