Boost logo

Boost-Build :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2003-08-05 04:10:08


Hi,
during the last week I was playing with different optimization approaches,
and the final result is in CVS now.

The changes are
- IMPORT_MODULE builtin as I've described previously
- core support for classes (some docs are attached and class.jam docs are
updated)
- SORT builtin
- NORMALIZE_PATH builtin

On my project, user times for "bjam -n" invocation are

Original time : 18.7
IMPORT_MODULE 17.7
new classes : 13.31
SORT : 11.8
NORMALIZE_PATH: 8.8

So, we get about 2x speedup. Memory consumption is reduced too.

The profile we get as result is at

http://zigzag.cs.msu.su:7813/profile7.html

I think there's potential for further optimization, but it would be wise to
test optimization we have now.

I plan to post tarball later and would really appreciate if users could test
it. All regression tests pass for me on gcc,borland and mvsc, but maybe
something is not tested.

- Volodya
 --Boundary-00=_wR3L/95HL9RGYfh Content-Type: text/plain;
charset="us-ascii";
name="classes.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="classes.txt"

Core support for classes.

Both classes and class instances are special kinds of modules.
Class modules holds keeps methods (which are the same for all instances)
while instance modules only keep instance variables. The primary advantage of this scheme is that methods are defined only once, when declaring class, while in previous implemented, their were defined in symbol table of each instance, which used up a lot of memory.

The class is a regular module except that a convenient declaration syntax is provided. All non-local rules defined in in the module and all rules which are imported localized are class methods.

Class module can also import other modules via IMPORT_MODULE and import individual rules via IMPORT/EXPORT combination. Such rules will be seen in class instances.

Instance module is specially treated. Whenever lookup is done for a rule in this module, we're looking in associated class module. If a rule is found, and it's class method, the rule is executed in instance module's scope.
Otherwise, rule is executed as usual.

The class module should define rule __init__ which serves as constructor.

Details.

The syntax for class declaration is

class name [ : bases ]
{
# module-level declarations
}

Semantic:
1. An internal name for a class module is generated.
2. All rules from base class modules are imported in created class module as qualified names
Rule which were localized in base module are localized in class module,
and rules which were exported are exported.
3. All modules imported in base class modules are imported in created class module.
4. The body of class declaration is parsed, which creates class methods.

New instances are creates by calling

class.new class : [ arguments ] ;

Semantic:
1. A new instance module is created and associated with class module
2. The module is imported in global module via IMPORT_MODULE

When a class' rule is called:
1. The lookup for the rule is done in class module, not in instance module.
2. If the rule is marked as to be executed in class module, it's executed in
instance module.

 --Boundary-00=_wR3L/95HL9RGYfh--


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk