Merge remote-tracking branch 'redux/master' into sh4-pool
[tamarin-stm.git] / core / avmfeatures.as
blobb4847a5d9e2fed20f6720f9ea8b8357c632b12b5
1 /* -*- c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*-
2 vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5)
4 ***** BEGIN LICENSE BLOCK *****
5 Version: MPL 1.1/GPL 2.0/LGPL 2.1
7 The contents of this file are subject to the Mozilla Public License Version
8 1.1 (the "License"); you may not use this file except in compliance with
9 the License. You may obtain a copy of the License at
10 http://www.mozilla.org/MPL/
12 Software distributed under the License is distributed on an "AS IS" basis,
13 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 for the specific language governing rights and limitations under the
15 License.
17 The Original Code is [Open Source Virtual Machine.].
19 The Initial Developer of the Original Code is
20 Adobe System Incorporated.
21 Portions created by the Initial Developer are Copyright (C) 1993-2006
22 the Initial Developer. All Rights Reserved.
24 Contributor(s):
25 Adobe AS3 Team
27 Alternatively, the contents of this file may be used under the terms of
28 either the GNU General Public License Version 2 or later (the "GPL"), or
29 the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 in which case the provisions of the GPL or the LGPL are applicable instead
31 of those above. If you wish to allow use of your version of this file only
32 under the terms of either the GPL or the LGPL, and not to allow others to
33 use your version of this file under the terms of the MPL, indicate your
34 decision by deleting the provisions above and replace them with the notice
35 and other provisions required by the GPL or the LGPL. If you do not delete
36 the provisions above, a recipient may use your version of this file under
37 the terms of any one of the MPL, the GPL or the LGPL.
38 ***** END LICENSE BLOCK *****
41 This file defines the feature set for avmplus.
43 It is also a program to transform the feature definition into three files:
45 * a C++ header file, avmfeatures.h
46 * a C++ source file, avmfeatures.cpp
47 * a Python file, ../build/avmfeatures.py
50 The feature set is defined as an XML (really E4X) datum, see below.
52 Grammar for feature definitions.
54 features ::= "<features>" feature* at-least-one* at-most-one* exactly-one* "</features>"
55 feature ::= "<feature>" desc name defines+ precludes* requires* "</feature>"
56 | "<tweak>" desc name default defines+ precludes* requires* "</tweak>"
57 desc ::= "<desc>" TEXT "</desc>"
58 name ::= "<name>" TEXT "</name>"
59 default ::= "<default> "true" | "false" "</default>"
60 defines ::= "<defines>" TEXT "</defines>"
61 precludes ::= "<precludes>" TEXT "</precludes>"
62 requires ::= "<requires>" TEXT | at-most-one | at-least-one | exactly-one "</requires>"
63 at-least-one ::= "<at-least-one>" name+ "</at-least-one>"
64 at-most-one ::= "<at-most-one>" name+ "</at-most-one>"
65 exactly-one ::= "<exactly-one>" name+ "</exactly-one>"
66 TEXT ::= space* [a-zA-Z][a-zA-Z0-9_]* space*
68 Clause ordering is not significant anywhere and xml comments are
69 allowed everywhere. Leading and trailing whitespace in each element
70 is ignored.
72 Semantics:
74 Features are compile time constraints that select and deselect
75 aspects of the virtual machine code. At compile time, a value
76 (off or on) must be provided for every feature, there are no
77 default values.
79 A FEATURE clause defines a named feature, named by its NAME clause
80 and described in human terms by its DESC clause.
82 NOTE: A good description is absolutely essential. It should
83 state what the feature does, but also what the implications of
84 selecting or deselecting it might be.
86 A TWEAK clause defines a named feature with a default value, which
87 provides an opportunity for workarounds for bugs and other very
88 minor issues. TWEAKs should be used sparingly (and if they are
89 abused because it's convenient to introduce default values then
90 the default value facility will be removed).
92 No two FEATUREs or TWEAKSs may name the same feature.
94 Feature names named by PRECLUDES, REQUIRES, AT-LEAST-ONE, and
95 AT-MOST-ONE clauses must be defined by some FEATURE.
97 A PRECLUDES clause in a FEATURE adds a constraint that the
98 precluded feature cannot be turned on if the feature defined by
99 the present FEATURE is turned on.
101 A REQUIRES clause in a FEATURE adds a constraint that the
102 required feature must be turned on if the feature defined by
103 the present FEATURE is turned on.
105 A DEFINES clause in a FEATURE names a preprocessor macro that is
106 defined (with a simple "#define X") if the FEATURE is turned on.
107 This seems redundant until you consider that a FEATURE can define
108 multiple macros; this allows discrimination internally in the
109 module to be organized differently than feature definition
110 externally.
112 An AT-LEAST-ONE clause adds a constraint that at least one of
113 the features has been turned on.
115 An AT-MOST-ONE clause adds a constraint that at most one of the
116 features has been turned on. (The same can be expressed by
117 PRECLUDES clauses but that would be more error-prone.)
119 EXACTLY-ONE is an abbreviation for the combination of AT-LEAST-ONE
120 and AT-MOST-ONE.
122 This program processes the feature definition below to check static
123 constraints and produce the C++ header file core/avmfeatures.h; that
124 header file checks compile-time constraints and defines preprocessor
125 macros as appropriate.
127 The product's feature settings are imported through VMPI.h; see comments
128 in that file for how to provide the settings.
130 This program also produces a C++ compilation unit (.cpp file) that
131 contains a single string that lists the features that were enabled at
132 build time; it is used by the AVM shell for debugging purposes.
134 This program also produces a Python file that is used by the cross-platform
135 build system to handle configuration switches; see ../configure.py.
139 /****************************************************************************
140 ***** Start of feature definition ******************************************
141 ****************************************************************************/
143 var FEATURES =
144 <features>
146 <!-- Basic system characteristics -->
148 <feature>
149 <desc> Selects a 32-bit architecture </desc>
151 <name> AVMSYSTEM_32BIT </name>
152 <precludes> AVMSYSTEM_64BIT </precludes>
153 <defines> VMCFG_32BIT </defines>
154 </feature>
156 <feature>
157 <desc> Selects a 64-bit architecture </desc>
159 <name> AVMSYSTEM_64BIT </name>
160 <precludes> AVMSYSTEM_32BIT </precludes>
161 <defines> VMCFG_64BIT </defines>
162 <defines> MMGC_64BIT </defines> <!-- FIXME: Bug 536304 legacy name -->
163 <defines> AVMPLUS_64BIT </defines> <!-- FIXME: Bug 536304 legacy name -->
164 </feature>
166 <feature>
167 <desc> Selects an architecture that allows load/store of unaligned 16- and 32-bit ints.
168 There may be a performance penalty, but it will not generate a runtime
169 fault, and will be at least as efficient as separate instructions to load
170 and assembly the word one byte at a time.</desc>
172 <name> AVMSYSTEM_UNALIGNED_INT_ACCESS </name>
173 <defines> VMCFG_UNALIGNED_INT_ACCESS </defines>
174 </feature>
176 <feature>
177 <desc> Selects an architecture that allows load/store of unaligned 32- and 64-bit floats.
178 There may be a performance penalty, but it will not generate a runtime
179 fault, and will be at least as efficient as separate instructions to load
180 and assembly the word one byte at a time. (Note that if this is not set,
181 it is assumed that 64-bit floats require 8-byte alignment.)</desc>
183 <name> AVMSYSTEM_UNALIGNED_FP_ACCESS </name>
184 <defines> VMCFG_UNALIGNED_FP_ACCESS </defines>
185 </feature>
187 <feature>
188 <desc> Selects a big-endian architecture: the most significant byte of a word
189 is stored at the lowest byte address of the word </desc>
191 <name> AVMSYSTEM_BIG_ENDIAN </name>
192 <precludes> AVMSYSTEM_LITTLE_ENDIAN </precludes>
193 <defines> VMCFG_BIG_ENDIAN </defines>
194 </feature>
196 <feature>
197 <desc> Selects a little-endian architecture: the least significant byte of a word
198 is stored at the lowest byte address of the word </desc>
200 <name> AVMSYSTEM_LITTLE_ENDIAN </name>
201 <precludes> AVMSYSTEM_BIG_ENDIAN </precludes>
202 <defines> VMCFG_LITTLE_ENDIAN </defines>
203 </feature>
205 <feature>
206 <desc> Selects a reverse floating-point layout on little-endian systems:
207 the most significant word (containing the sign, exponent, and most
208 significant bits of the significand) are at the lower word address.
209 Each word is stored little-endian, however. </desc>
210 <name> AVMSYSTEM_DOUBLE_MSW_FIRST </name>
211 <requires> AVMSYSTEM_LITTLE_ENDIAN </requires>
212 <defines> VMCFG_DOUBLE_MSW_FIRST </defines>
213 </feature>
215 <!-- CPU architectures, one of these is required for the JIT -->
217 <feature>
218 <desc> Selects the x86-32 architecture </desc>
220 <name> AVMSYSTEM_IA32 </name>
221 <precludes> AVMSYSTEM_64BIT </precludes>
222 <defines> VMCFG_IA32 </defines>
223 <defines> MMGC_IA32 </defines> <!-- FIXME: Bug 536304 legacy name -->
224 <defines> AVMPLUS_IA32 </defines> <!-- FIXME: Bug 536304 legacy name -->
225 </feature>
227 <feature>
228 <desc> Selects the x86-64 architecture </desc>
230 <name> AVMSYSTEM_AMD64 </name>
231 <requires> AVMSYSTEM_64BIT </requires>
232 <defines> VMCFG_AMD64 </defines>
233 <defines> MMGC_AMD64 </defines> <!-- FIXME: Bug 536304 legacy name -->
234 <defines> AVMPLUS_AMD64 </defines> <!-- FIXME: Bug 536304 legacy name -->
235 </feature>
237 <feature>
238 <desc> Selects the ARM architecture (version left unspecified for now). </desc>
240 <name> AVMSYSTEM_ARM </name>
241 <precludes> AVMSYSTEM_64BIT </precludes>
242 <defines> VMCFG_ARM </defines>
243 <defines> MMGC_ARM </defines> <!-- FIXME: Bug 536304 legacy name -->
244 <defines> AVMPLUS_ARM </defines> <!-- FIXME: Bug 536304 legacy name -->
245 </feature>
247 <feature>
248 <desc> Selects the PowerPC / Power architecture. Whether it's the 32-bit or the
249 64-bit version of the architecture is controlled independently. </desc>
251 <name> AVMSYSTEM_PPC </name>
252 <defines> VMCFG_PPC </defines>
253 <defines> MMGC_PPC </defines> <!-- FIXME: Bug 536304 legacy name -->
254 <defines> AVMPLUS_PPC </defines> <!-- FIXME: Bug 536304 legacy name -->
255 </feature>
257 <feature>
258 <desc> Selects the 32-bit SPARC architecture. </desc>
260 <name> AVMSYSTEM_SPARC </name>
261 <precludes> AVMSYSTEM_64BIT </precludes>
262 <defines> VMCFG_SPARC </defines>
263 <defines> MMGC_SPARC </defines> <!-- FIXME: Bug 536304 legacy name -->
264 <defines> AVMPLUS_SPARC </defines> <!-- FIXME: Bug 536304 legacy name -->
265 </feature>
267 <feature>
268 <desc> Selects the MIPS architecture (version left unspecified for now). </desc>
270 <name> AVMSYSTEM_MIPS </name>
271 <defines> VMCFG_MIPS </defines>
272 <defines> AVMPLUS_MIPS </defines> <!-- FIXME: Bug 536304 legacy name -->
273 </feature>
275 <feature>
276 <desc> Selects the 32-bit SH4 architecture. </desc>
278 <name> AVMSYSTEM_SH4 </name>
279 <precludes> AVMSYSTEM_64BIT </precludes>
280 <defines> VMCFG_SH4 </defines>
281 </feature>
283 <at-most-one>
284 <!-- architectures are all mutually exclusive, but there can be "none", I believe (need to verify) -->
285 <name> AVMSYSTEM_IA32 </name>
286 <name> AVMSYSTEM_AMD64 </name>
287 <name> AVMSYSTEM_ARM </name>
288 <name> AVMSYSTEM_PPC </name>
289 <name> AVMSYSTEM_SPARC </name>
290 <name> AVMSYSTEM_MIPS </name>
291 <name> AVMSYSTEM_SH4 </name>
292 </at-most-one>
295 <!-- operating systems.
296 We might want more of these, I bet the code has a bunch of implied operating
297 systems (eg WIN32 && ARM usually means Windows Mobile...) -->
299 <feature>
300 <desc> Selects Unix / Linux (but not MacOS) </desc>
301 <name> AVMSYSTEM_UNIX </name>
302 <defines> AVMPLUS_UNIX </defines>
303 </feature>
305 <feature>
306 <desc> Selects MacOS X </desc>
307 <name> AVMSYSTEM_MAC </name>
308 <defines> AVMPLUS_MAC </defines>
309 <defines> MMGC_MAC </defines>
310 </feature>
312 <feature>
313 <desc> Selects Win32, Win64, Windows Mobile </desc>
314 <name> AVMSYSTEM_WIN32 </name>
315 <defines> AVMPLUS_WIN32 </defines>
316 </feature>
318 <feature>
319 <desc> Selects Symbian </desc>
320 <name> AVMSYSTEM_SYMBIAN </name>
321 <defines> VMCFG_SYMBIAN </defines>
322 </feature>
324 <exactly-one>
325 <name> AVMSYSTEM_UNIX </name>
326 <name> AVMSYSTEM_MAC </name>
327 <name> AVMSYSTEM_WIN32 </name>
328 <name> AVMSYSTEM_SYMBIAN </name>
329 </exactly-one>
332 <!-- VM facilities: AVMFEATURE_* -->
334 <feature>
335 <desc> Selects the AVM debugger API, including retaining debug information at
336 run-time and human-readable error messages for run-time errors.
338 There is a performance penalty to enabling this; clients that want
339 maximal execution performance and don't care about debugging should
340 disable it.
342 If you enable the debugger you may want to consider enabling support for
343 specific language strings for error messages in order to avoid getting
344 them all. See the AVMPLUS_ERROR_LANG_ macros in core/ErrorConstants.h.
345 It's easiest to define the ones you want in core/avmbuild.h.
346 </desc>
348 <name> AVMFEATURE_DEBUGGER </name>
349 <defines> VMCFG_DEBUGGER </defines>
350 <defines> VMCFG_VERIFYALL </defines>
351 <defines> AVMPLUS_VERBOSE </defines>
352 <defines> DEBUGGER </defines> <!-- FIXME: Bug 536304 legacy name -->
353 </feature>
355 <feature>
356 <desc> This is used to compile AVM with the debugger API enabled, but
357 certain bits of functionality reduced to no-ops. </desc>
359 <name> AVMFEATURE_DEBUGGER_STUB </name>
360 <requires> AVMFEATURE_DEBUGGER </requires>
361 <defines> VMCFG_DEBUGGER_STUB </defines>
362 </feature>
364 <feature>
365 <desc> Enable the sample-based memory profiler. This makes allocation a
366 little more expensive if a sampler callback is not installed, and
367 more expensive still if it is installed.
369 FIXME: more information needed.
371 Note that this is enabled always by AVMFEATURE_DEBUGGER.
373 It is known that the Flash Player wants to enable this if SCRIPT_DEBUGGER
374 is enabled in the Player code. </desc>
376 <name> AVMFEATURE_ALLOCATION_SAMPLER </name>
377 <defines> AVMPLUS_SAMPLER </defines>
378 </feature>
380 <feature>
381 <desc> Selects vtune profiling of jit'd code. Requires Windows x86,
382 and could support windows x64 after more testing.
383 turns on AVMPLUS_VERBOSE solely to get method/class names for profiling
384 </desc>
386 <name> AVMFEATURE_VTUNE </name>
387 <requires> AVMSYSTEM_WIN32 </requires>
388 <requires> AVMSYSTEM_IA32 </requires>
389 <defines> VMCFG_VTUNE </defines>
391 <defines> AVMPLUS_VERBOSE </defines>
392 </feature>
394 <feature>
395 <desc> Enables the just-in-time compiler. This will typically increase performance
396 significantly but may result in significantly higher memory consumption. </desc>
398 <name> AVMFEATURE_JIT </name>
399 <requires>
400 <exactly-one>
401 <name> AVMSYSTEM_IA32 </name>
402 <name> AVMSYSTEM_AMD64 </name>
403 <name> AVMSYSTEM_ARM </name>
404 <name> AVMSYSTEM_PPC </name>
405 <name> AVMSYSTEM_SPARC </name>
406 <name> AVMSYSTEM_MIPS </name>
407 <name> AVMSYSTEM_SH4 </name>
408 </exactly-one>
409 </requires>
410 <defines> VMCFG_NANOJIT </defines>
411 <defines> VMCFG_LOOKUP_CACHE </defines>
412 <defines> VMCFG_METHODENV_IMPL32 </defines>
413 <defines> FEATURE_NANOJIT </defines> <!-- referenced by nanojit module only -->
414 </feature>
416 <feature>
417 <desc>Enables the ahead-of-time compiler.</desc>
419 <name> AVMFEATURE_AOT </name>
420 <requires>
421 <exactly-one>
422 <name> AVMSYSTEM_IA32 </name>
423 <name> AVMSYSTEM_ARM </name>
424 </exactly-one>
425 </requires>
426 <defines> VMCFG_AOT </defines>
427 <defines> VMCFG_AOTSHELL </defines>
428 <defines> VMCFG_CDECL </defines>
429 <defines> VMCFG_METHODENV_IMPL32 </defines>
430 </feature>
432 <feature>
433 <desc>Enables the exception based caching code, right now this is used
434 exclusively by AOT.</desc>
436 <name> AVMFEATURE_BUFFER_GUARD </name>
437 <requires>
438 <exactly-one>
439 <name> AVMFEATURE_AOT </name>
440 </exactly-one>
441 </requires>
442 <defines> VMCFG_BUFFER_GUARD </defines>
443 <defines> VMCFG_MACH_EXCEPTIONS </defines>
444 </feature>
446 <feature>
447 <desc> Selects the ABC interpreter. Appropriate for platforms that run
448 the interpreter only for initialization code and for
449 platforms that are exceptionally memory-constrained. </desc>
451 <name> AVMFEATURE_ABC_INTERP </name>
452 <defines> VMCFG_INTERPRETER </defines>
453 </feature>
456 <feature>
457 <desc> Selects the wordcode interpreter. Appropriate for platforms that run the
458 interpreter for some or all methods and are not exceptionally memory-constrained. </desc>
460 <name> AVMFEATURE_WORDCODE_INTERP </name>
461 <defines> VMCFG_INTERPRETER </defines>
462 <defines> VMCFG_WORDCODE </defines>
463 <defines> VMCFG_WORDCODE_PEEPHOLE </defines>
464 <defines> VMCFG_LOOKUP_CACHE </defines>
465 </feature>
467 <feature>
468 <desc> Selects the faster, direct threaded wordcode interpreter.
469 This is appropriate only for C++ compilers that support GCC-style computed
470 "goto". It is believed that RCVT, Intel's C++ compiler, and the Sunpro
471 compiler all do. </desc>
473 <name> AVMFEATURE_THREADED_INTERP </name>
474 <requires> AVMFEATURE_WORDCODE_INTERP </requires>
475 <defines> VMCFG_DIRECT_THREADED </defines>
476 </feature>
478 <at-most-one>
479 <!-- Though it is believed that it is possible to run avmplus with just a JIT,
480 doing so is not supported at this time. Also note that some build configurations
481 (such as AOT) may wish to have no interpreter or JIT. -->
483 <name> AVMFEATURE_WORDCODE_INTERP </name>
484 <name> AVMFEATURE_ABC_INTERP </name>
485 </at-most-one>
487 <at-most-one>
488 <!-- The wordcode interpreter and JIT both use a LookupCache, and there can only
489 be one instance of said cache. We can fix this through some refactoring but
490 the expedient solution is to only ever allow one or the other -->
491 <name> AVMFEATURE_WORDCODE_INTERP </name>
492 <name> AVMFEATURE_JIT </name>
493 </at-most-one>
495 <at-most-one>
496 <!-- AOT currently implies no JIT or Interpreter, but this could be fixed
497 in the future if necessary -->
498 <name> AVMFEATURE_AOT </name>
499 <name> AVMFEATURE_JIT </name>
500 </at-most-one>
502 <at-most-one>
503 <!-- AOT currently implies no JIT or Interpreter, but this could be fixed
504 in the future if necessary -->
505 <name> AVMFEATURE_AOT </name>
506 <name> AVMFEATURE_ABC_INTERP </name>
507 </at-most-one>
509 <at-most-one>
510 <!-- AOT currently implies no JIT or Interpreter, but this could be fixed
511 in the future if necessary -->
512 <name> AVMFEATURE_AOT </name>
513 <name> AVMFEATURE_WORDCODE_INTERP </name>
514 </at-most-one>
516 <feature>
517 <desc> AVMFEATURE_SELFTEST enables the built-in selftests. These can be run by -Dselftest
518 at the shell or by calling the global function avmplus::selftests(), see extensions/Selftest.h.
519 Mostly they are useful for AVM development, not for embedders.
521 Apart from code size considerations this can be enabled for release builds. </desc>
523 <name> AVMFEATURE_SELFTEST </name>
524 <defines> VMCFG_SELFTEST </defines>
525 </feature>
527 <feature>
528 <desc> Select support for the AS3 run-time compiler. NOT RECOMMENDED. The run-time compiler
529 is still undergoing development. </desc>
531 <name> AVMFEATURE_EVAL </name>
532 <defines> VMCFG_EVAL </defines>
533 </feature>
535 <feature>
536 <desc> Makes all JIT code buffers read-only whenever JIT code is executing,
537 to reduce the probability of heap overflow attacks. </desc>
538 <name> AVMFEATURE_PROTECT_JITMEM </name>
539 <defines> AVMPLUS_JIT_READONLY </defines> <!-- fixme: Bug 536304 legacy name -->
540 <defines> VMCFG_PROTECT_JITMEM </defines>
541 </feature>
543 <feature>
544 <desc> Selects locking around calls to the memory block manager (GCHeap), allowing multiple
545 threads to share the block manager. Any client with more than one thread that uses
546 MMgc either for garbage collected or manually managed memory wants this; the Flash
547 Player requires it. </desc>
548 <name> AVMFEATURE_SHARED_GCHEAP </name>
549 <defines> MMGC_LOCKING </defines>
550 </feature>
552 <feature>
553 <desc> Make MMgc's overridden global new and delete operators delegate allocation and
554 deallocation to VMPI_alloc and VMPI_free instead of going to FixedMalloc.
556 Whether you want this or not probably depends on the performance of the
557 underlying malloc and might depend on memory consumption patterns. On desktop
558 systems you probably want this to be disabled. </desc>
559 <name> AVMFEATURE_USE_SYSTEM_MALLOC </name>
560 <defines> MMGC_USE_SYSTEM_MALLOC </defines>
561 </feature>
563 <feature>
564 <desc> Support C++ exceptions in the MMgc API. At the time of writing (Apr 2009)
565 this means decorating the global new and delete operator with appropriate 'throw'
566 clauses. It is unlikely to mean anything more, as AVM+ and MMgc do not use and
567 do not generally support C++ exceptions.
569 Note that even if this is enabled, the global new and delete operators may
570 not throw exceptions when memory can't be allocated, because the out-of-memory
571 handling in MMgc may take precedence.
573 FixedMalloc never throws an exception for a failed allocation. </desc>
575 <name> AVMFEATURE_CPP_EXCEPTIONS </name>
576 <defines> MMGC_ENABLE_CPP_EXCEPTIONS </defines>
577 </feature>
579 <feature>
580 <desc> Recognize a pointer or pointer-like value into anywhere in an object as referencing
581 that object during marking in the garbage collector.
583 Enabling this tends to be increase GC cost but it can be a useful debugging aid. </desc>
584 <name> AVMFEATURE_INTERIOR_POINTERS </name>
585 <defines> MMGC_INTERIOR_PTRS </defines>
586 </feature>
588 <feature>
589 <desc> Enable interfacing to Java so you can access java methods/properties like
590 native AS properties; e.g.
591 var hello = JObject.create("java.lang.String", " hello world ");
592 print(hello.indexOf('o'));
593 </desc>
594 <name> AVMFEATURE_JNI </name>
595 <defines> AVMPLUS_WITH_JNI </defines>
596 </feature>
598 <feature>
599 <desc> If enabled then always divert VMPI_alloca() to a separately managed stack,
600 to avoid blowing the stack on small systems or to support systems that
601 don't provide alloca(). If disabled then smallish allocations are handled
602 by the built-in alloca() (which must be provided) and larger allocations
603 are handled by diverting to a separately managed stack; the latter case is
604 mainly a security issue, as alloca() will do strange things if given sufficiently
605 large requests. </desc>
606 <name> AVMFEATURE_HEAP_ALLOCA </name>
607 <defines> AVMPLUS_HEAP_ALLOCA </defines>
608 </feature>
610 <feature>
611 <desc> Enabling this will cause the mmfx_* memory macros to use global new/delete.
612 By default we use specialized new/delete operators and avoid global new/delete. However
613 this requires some tricks to get multiple inheritance and private destructors to work
614 so some codebases may want to use the simpler path of overriding global new/delete.
615 Note that this feature works independently of AVMFEATURE_USE_SYSTEM_MALLOC.
616 </desc>
617 <name> AVMFEATURE_OVERRIDE_GLOBAL_NEW </name>
618 <defines> MMGC_OVERRIDE_GLOBAL_NEW </defines>
619 </feature>
621 <feature>
622 <desc> Enabling this will compile in code to enable memory profiling. (Must still be
623 enabled at runtime.)
624 </desc>
625 <name> AVMFEATURE_MEMORY_PROFILER </name>
626 <defines> MMGC_MEMORY_PROFILER </defines>
627 </feature>
629 <feature>
630 <desc> Enabling this will cache the result of getQualifiedClassName, making it run
631 much more quickly, at the expense of more memory usage.
632 </desc>
633 <name> AVMFEATURE_CACHE_GQCN </name>
634 <defines> VMCFG_CACHE_GQCN </defines>
635 </feature>
637 <feature>
638 <desc> Enabling this will compile in code to tell valgrind about how MMgc allocates memory.
639 </desc>
640 <name> AVMFEATURE_VALGRIND </name>
641 <defines> MMGC_VALGRIND </defines>
642 </feature>
644 <feature>
645 <desc> Enabling this will support SWF12 / ABC version 47.12 </desc>
646 <name> AVMFEATURE_SWF12 </name>
647 <defines> VMCFG_SWF12 </defines>
648 <defines> VMCFG_FLOAT </defines> <!-- Tentative! Intended for use *outside* the VM only, to see if the feature is present -->
649 <defines> VMCFG_FLOAT4 </defines> <!-- Tentative! Intended for use *outside* the VM only, to see if the feature is present -->
650 </feature>
652 <feature>
653 <desc> Enabling this will support SWF13 / ABC version 47.13 </desc>
654 <name> AVMFEATURE_SWF13 </name>
655 <defines> VMCFG_SWF13 </defines>
656 <requires> AVMFEATURE_SWF12 </requires>
657 </feature>
659 <feature>
660 <desc> Enabling this will support SWF14 / ABC version 47.14 </desc>
661 <name> AVMFEATURE_SWF14 </name>
662 <defines> VMCFG_SWF14 </defines>
663 <requires> AVMFEATURE_SWF13 </requires>
664 </feature>
666 <feature>
667 <desc> Enabling this will support SWF15 / ABC version 47.15 </desc>
668 <name> AVMFEATURE_SWF15 </name>
669 <defines> VMCFG_SWF15 </defines>
670 <requires> AVMFEATURE_SWF14 </requires>
671 </feature>
673 <feature>
674 <desc> Enabling this will support SWF16 / ABC version 47.16 </desc>
675 <name> AVMFEATURE_SWF16 </name>
676 <defines> VMCFG_SWF16 </defines>
677 <requires> AVMFEATURE_SWF15 </requires>
678 </feature>
680 <feature>
681 <desc> Enabling this will support SWF17 / ABC version 47.17 </desc>
682 <name> AVMFEATURE_SWF17 </name>
683 <defines> VMCFG_SWF17 </defines>
684 <requires> AVMFEATURE_SWF16 </requires>
685 </feature>
687 <feature>
688 <desc> Enabling this will support SWF18 / ABC version 47.18 </desc>
689 <name> AVMFEATURE_SWF18 </name>
690 <defines> VMCFG_SWF18 </defines>
691 <requires> AVMFEATURE_SWF17 </requires>
692 </feature>
694 <feature>
695 <desc> Enabling this will support SWF19 / ABC version 47.19 </desc>
696 <name> AVMFEATURE_SWF19 </name>
697 <defines> VMCFG_SWF19 </defines>
698 <requires> AVMFEATURE_SWF18 </requires>
699 </feature>
701 <feature>
702 <desc> Enabling this will support SWF20 / ABC version 47.20 </desc>
703 <name> AVMFEATURE_SWF20 </name>
704 <defines> VMCFG_SWF20 </defines>
705 <requires> AVMFEATURE_SWF19 </requires>
706 </feature>
708 <!-- VM adjustments for various oddities: AVMTWEAK_* -->
710 <tweak>
711 <desc> Various iphone SDK versions - at least - botch sin() and cos() around NaN
712 and infinity. See https://bugzilla.mozilla.org/show_bug.cgi?id=556149. </desc>
713 <name> AVMTWEAK_SIN_COS_NONFINITE </name>
714 <defines> VMCFG_TWEAK_SIN_COS_NONFINITE </defines>
715 <default> false </default>
716 </tweak>
718 <tweak>
719 <desc> The current (June 2010) EPOC/Symbian emulator has certain limitations,
720 described throughout the code where this tweak is used. </desc>
721 <name> AVMTWEAK_EPOC_EMULATOR </name>
722 <defines> VMCFG_EPOC_EMULATOR </defines>
723 <default> false </default>
724 </tweak>
726 <tweak>
727 <desc> Compile-time selected exact tracing </desc>
728 <name> AVMTWEAK_EXACT_TRACING </name>
729 <defines> VMCFG_EXACT_TRACING </defines>
730 <default> true </default>
731 </tweak>
733 <tweak>
734 <desc> Run-time selectable exact tracing, for experimentation </desc>
735 <name> AVMTWEAK_SELECTABLE_EXACT_TRACING </name>
736 <defines> VMCFG_SELECTABLE_EXACT_TRACING </defines>
737 <default> false </default>
738 </tweak>
740 <at-most-one>
741 <name> AVMTWEAK_EXACT_TRACING </name>
742 <name> AVMTWEAK_SELECTABLE_EXACT_TRACING </name>
743 </at-most-one>
745 </features>;
747 /****************************************************************************
748 ***** End of feature definition ********************************************
749 ****************************************************************************/
751 import avmplus.*;
752 import flash.utils.*;
754 var allnames = {};
756 main();
758 function main() {
760 // Generate avmfeatures.h
762 var s = newString();
763 var feature;
764 var x;
765 s += "\n";
766 for each ( feature in FEATURES.feature )
767 s += undefDefines(feature);
768 s += "\n";
769 for each ( feature in FEATURES.tweak )
770 s += undefDefines(feature);
771 s += "\n";
772 for each ( feature in FEATURES.feature )
773 s += testDefined(feature);
774 s += "\n";
775 for each ( feature in FEATURES.tweak )
776 s += testDefined(feature);
777 s += "\n";
778 for each ( feature in FEATURES.feature )
779 s += checkRequirements(feature);
780 s += "\n";
781 for each ( feature in FEATURES.tweak )
782 s += checkRequirements(feature);
783 s += "\n";
784 for each ( x in FEATURES["at-least-one"] )
785 s += atLeastOne(x);
786 s += "\n";
787 for each ( x in FEATURES["at-most-one"] )
788 s += atMostOne(x);
789 s += "\n";
790 for each ( x in FEATURES["exactly-one"] )
791 s += exactlyOne(x);
792 s += "\n";
793 for each ( feature in FEATURES.feature )
794 s += defineResults(feature);
795 s += "\n";
796 for each ( feature in FEATURES.tweak )
797 s += defineResults(feature);
798 s += "\n";
799 s += "#ifdef AVMSHELL_BUILD\n";
800 s += "extern const char * const avmfeatures;\n";
801 s += "#endif\n\n";
802 print('writing avmfeatures.h');
803 File.write("avmfeatures.h", s);
805 // Generate avmfeatures.cpp
807 s = newString();
808 s += "\n\n";
809 s += "#include \"avmplus.h\"\n\n";
810 s += "#ifdef AVMSHELL_BUILD\n\n";
811 s += "// The string avmfeatures contains the names of all features that were enabled\n";
812 s += "// when the program was compiled. Each feature name is terminated by a semicolon.\n";
813 s += "const char * const avmfeatures = \"\"\n"
814 for each ( feature in FEATURES.feature )
815 s += showFeature(feature);
816 for each ( feature in FEATURES.tweak )
817 s += showFeature(feature);
818 s += ";\n\n"
819 s += "#endif // AVMSHELL_BUILD\n";
820 print('writing avmfeatures.cpp');
821 File.write("avmfeatures.cpp", s);
823 // Generate ../build/avmfeatures.py
825 s = newString("#");
826 s += "\n\n";
827 s += "def featureSettings(o):\n";
828 s += " args = \"\"\n";
829 for each ( feature in FEATURES.feature )
830 s += configureFeature(feature);
831 for each ( feature in FEATURES.tweak )
832 s += configureFeature(feature);
833 s += " return args\n";
835 print('writing ../build/avmfeatures.py');
836 File.write("../build/avmfeatures.py", s);
839 function newString(prefix="//") {
840 var s = [" DO NOT EDIT THIS FILE",
842 " This file has been generated by the script core/avmfeatures.as,",
843 " from a set of configuration parameters in that file.",
845 " If you feel you need to make changes below, instead edit the configuration",
846 " file and rerun it to get a new version of this file.",
848 " ***** BEGIN LICENSE BLOCK *****",
849 " Version: MPL 1.1/GPL 2.0/LGPL 2.1",
851 " The contents of this file are subject to the Mozilla Public License Version",
852 " 1.1 (the \"License\"); you may not use this file except in compliance with",
853 " the License. You may obtain a copy of the License at",
854 " http://www.mozilla.org/MPL/",
856 " Software distributed under the License is distributed on an \"AS IS\" basis,",
857 " WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License",
858 " for the specific language governing rights and limitations under the",
859 " License.",
861 " The Original Code is [Open Source Virtual Machine.].",
863 " The Initial Developer of the Original Code is",
864 " Adobe System Incorporated.",
865 " Portions created by the Initial Developer are Copyright (C) 2009",
866 " the Initial Developer. All Rights Reserved.",
868 " Contributor(s):",
869 " Adobe AS3 Team",
871 " Alternatively, the contents of this file may be used under the terms of",
872 " either the GNU General Public License Version 2 or later (the \"GPL\"), or",
873 " the GNU Lesser General Public License Version 2.1 or later (the \"LGPL\"),",
874 " in which case the provisions of the GPL or the LGPL are applicable instead",
875 " of those above. If you wish to allow use of your version of this file only",
876 " under the terms of either the GPL or the LGPL, and not to allow others to",
877 " use your version of this file under the terms of the MPL, indicate your",
878 " decision by deleting the provisions above and replace them with the notice",
879 " and other provisions required by the GPL or the LGPL. If you do not delete",
880 " the provisions above, a recipient may use your version of this file under",
881 " the terms of any one of the MPL, the GPL or the LGPL.",
883 " ***** END LICENSE BLOCK ****"
884 ].map(function(x) { return prefix + x }).join("\n");
885 return s;
888 // Undefine all names that are going to be defined so that predefined values
889 // do not pollute the results.
891 function undefDefines(feature) {
892 var s = [];
893 var d;
894 for each ( d in feature.defines )
895 s.push("#undef " + d);
896 return s.join("\n") + "\n";
899 // Emit a description and a test of definedness and correct value for every feature;
900 // the description is located with this test because it will typically be this test
901 // that fails, so this is where the user will look.
903 function testDefined(feature) {
904 var name = feature.name;
905 var s = [];
907 if (!name)
908 fail("Feature with missing name");
910 if (allnames.hasOwnProperty(name))
911 fail("Duplicate name: " + name);
912 allnames[name] = true;
914 s.push("");
915 s.push("");
916 s.push("/* " + name + "\n *\n" + formatFeature(feature) + "\n */");
917 if (feature.name() == "tweak") {
918 s.push("#if !defined " + name);
919 if (feature.default.length() == 0)
920 fail("Tweak \"" + name + "\" is missing a 'default' clause.");
921 s.push("# define " + name + " " + (feature["default"] == "true" ? 1 : 0));
922 s.push("#endif");
923 s.push("#if " + name + " != 0 && " + name + " != 1");
924 s.push("# error \"" + name + " must be defined and 0 or 1 (only).\"");
925 s.push("#endif");
927 else {
928 if (feature.default.length() > 0)
929 fail("Feature \"" + name + "\" must not have a 'default' clause: " + feature.default);
930 s.push("#if !defined " + name + " || " + name + " != 0 && " + name + " != 1");
931 s.push("# error \"" + name + " must be defined and 0 or 1 (only).\"");
932 s.push("#endif");
934 return s.join("\n") + "\n";
937 function formatFeature(feature) {
938 // make the beginning of the line be " * " and then trim the extra space for empty lines
939 return feature.desc.toString().replace(/^[ \t]*/gm, " * ").replace(/[ ]+\n/g, "\n")
942 function checkRequirements(feature) {
943 var name = feature.name;
944 var requires = feature.requires;
945 var precludes = feature.precludes;
946 var defines = feature.defines;
947 var s = [];
948 var items;
950 if (defines.length() == 0)
951 fail("Feature has no DEFINES clauses: " + name);
953 if (requires.length() + precludes.length() > 0)
954 s.push("#if " + name);
956 for each ( var req in requires ) {
957 if ((items = req["at-most-one"]).length() > 0)
958 s.push(atMostOne(items));
959 else if ((items = req["at-least-one"]).length() > 0)
960 s.push(atLeastOne(items));
961 else if ((items = req["exactly-one"]).length() > 0)
962 s.push(exactlyOne(items));
963 else {
964 if (!allnames.hasOwnProperty(req))
965 fail("Name used in REQUIRES not defined: " + req);
966 s.push("# if !" + req);
967 s.push("# error \"" + req + " is required for " + name + "\"");
968 s.push("# endif");
972 for each ( var pre in precludes ) {
973 if (!allnames.hasOwnProperty(pre))
974 fail("Name used in PRECLUDES not defined: " + pre);
975 s.push("# if " + pre);
976 s.push("# error \"" + pre + " is precluded for " + name + "\"");
977 s.push("# endif");
980 if (requires.length() + precludes.length() > 0)
981 s.push("#endif");
982 return s.join("\n") + "\n";
985 function defineResults(feature) {
986 var name = feature.name;
987 var defines = feature.defines;
988 var s = [];
990 if (!defines)
991 fail(name + ": missing 'defines' clause");
993 for each ( var def in defines ) {
994 s.push("#if " + name);
995 s.push("# define " + def);
996 s.push("#endif");
998 return s.join("\n") + "\n";
1001 function showFeature(feature) {
1002 return (" #if " + feature.name + "\n" +
1003 " \"" + feature.name + ";\"\n" +
1004 " #endif\n");
1007 // We ignore AVMSYSTEM_ settings as they're always autodetected
1009 function configureFeature(feature) {
1010 // Public service: if a feature is exclusive with others, disable the others
1011 // if the one is set
1012 function complement(feature_name, candidates) {
1013 var res = "";
1014 for each (var x in candidates) {
1015 var mustDo = false;
1016 var s = "";
1017 for each (var n in x.name) {
1018 if (n == feature_name)
1019 mustDo = true;
1020 else
1021 s += "-D" + n + "=0 ";
1023 if (mustDo)
1024 res += s;
1026 return res;
1029 var len = 0;
1030 if (feature.name.indexOf("AVMFEATURE_") == 0)
1031 len = 11;
1032 else if (feature.name.indexOf("AVMTWEAK_") == 0)
1033 len = 9;
1035 if (len > 0) {
1036 var enable = "-D" + feature.name + "=1 ";
1037 var disable = "-D" + feature.name + "=0 ";
1038 var dependent = complement(feature.name, FEATURES["at-most-one"]) +
1039 complement(feature.name, FEATURES["exactly-one"]);
1040 var feature = feature.name.substring(len).toLowerCase().replace(/_/g,"-");
1042 // features without dependencies can be explicitly enabled or disabled
1043 if (dependent == "") {
1044 return (" arg = o.getBoolArg(\"" + feature + "\")\n" +
1045 " if (arg == True):\n" +
1046 " args += \"" + enable + "\"\n" +
1047 " if (arg == False):\n" +
1048 " args += \"" + disable + "\"\n");
1050 return (" if o.getBoolArg(\"" + feature + "\"):\n" +
1051 " args += \"" + enable + dependent + "\"\n");
1053 return "";
1056 function groupConstraint(x, tagname, condition, english_condition) {
1057 var names = [];
1058 for each ( var name in x.name ) {
1059 if (!allnames.hasOwnProperty(name))
1060 fail("Name used in \"" + tagname + "\" not defined: " + name);
1061 names.push(name);
1063 return "#if " + names.join("+") + " " + condition + " 1\n# error \"" + english_condition + " one of " + names.join(",") + " must be defined.\"\n#endif\n";
1066 function atLeastOne(x) {
1067 return groupConstraint(x, "at-least-one", "<", "At least");
1070 function atMostOne(x) {
1071 return groupConstraint(x, "at-most-one", ">", "At most");
1074 function exactlyOne(x) {
1075 return groupConstraint(x, "exactly-one", "!=", "Exactly");
1078 function fail(msg) {
1079 print("Error: " + msg);
1080 System.exit(1);