Branch: Tag:

2013-11-02

2013-11-02 10:28:47 by Per Hedbor <ph@opera.com>

More changes

3:   -- New language features      o local:: +    o variant    | class Test1 { int b(); }    | class Test2 { int a(); }
25:   o Allow '.' to be used as an index operator in the few places id did    not work before.    - o safe index -  + X[?10] -- index X with 10, or if X is null, evaulates to 0. -  + X?->foo -- index X with foo, or if X is null, evaluates to 0. + o "Safe" index +  Copied from a popular extension to other C-like languages.    -  +  X[?ind] is equivalent to ((auto _ = X),(_ && _[ind])) +  while X?->ind is equivalent to ((auto _ = X),(_ && _->ind)) +  +  The main use is 'deep indexing' where some elements can be 0: +  +  | request_id?->user?->misc?->x +  +  vs +  +  | request_id && request_id->user && request_id->user->misc +  | && request_id->user->misc->x +    o Added the '?:' operator for compatibility with other C-like languages. -  It is identical to '||' in pike. +  It is identical to '||' in pike, and this is not /really/ needed.    - o && changed, when doing A && B, and A is false, keep A instead of -  pushing 0. + o The && operator changed, when doing A && B, and A is false, keep A +  instead of pushing 0.    - o X::this +  This is especially useful then A is not actually 0, but an object +  that evaluates to false, or UNDEFINED.    - o dynamic macros (master()->add_predefine("MACRO()", callback) etc) -  | > master()->add_predefine("RND()", lambda( string arg1 ) { return random((int)arg1); }); -  | > RND(10); -  | (2) Result: 9 -  | > cpp("RND(123)") -  | (3) Result: "19" + o Added new syntax that can be used to return an object as if it was a +  class you are inheriting, X::this where X is the inheriting class. +  + o Dynamic macros +  You can now add programatic macros. There is currently no syntax +  that can be used to define these while compiling code, but you can +  add them from one program before compiling plugins/modules. +  +  The main use is macros like DEBUG(...) and IFDEBUG() that would +  expand to something if a debug setting is enabled in the module but +  nothing otherwise, or, to take an actual example from the Opera +  Mini source code: +  +  | add_predefine( "METRIC()", +  | lambda( string name, string ... code ) +  | { +  | string type = type_of( code ); +  | string aggregate = aggregate_of( code ); +  | string format = format_of( code ); +  | code -= ({ 0 }); +  | return replace( base_metric_class, +  | (["ID":(string)next_metric_id++, +  | "NAME":stringify(name), +  | "TYPE":type, +  | "AGGREGATE":aggregate, +  | "FORMAT":format, +  | "CODE":make_value_function(code), +  | ])); +  | }); +  +  +  That is, a macro that needs does some calculations, and rewrite the +  code more than is possible in normal macros.. +  +  This one expands something along the lines of +  +  | METRIC("requests", Summarize, PerSecond, floating_average_diff(requests)); +  +  into +  +  | class Metric_requests_01 +  | { +  | inherit Server.Metric; +  | constant name = "transcoder:requests"; +  | constant type = Float; +  | constant format = PerSecond; +  | constant aggregate = Summarize;    | -  | It can also be used to override the default builtin macros. If you -  | want "fun" debug information (not used for backtraces, but code using -  | __LINE__ will be confused): -  | -  | > master()->add_predefine("__LINE__", lambda() { return random(4711); }); -  | > __LINE__; -  | (6) Result: 2593 -  | > __LINE__; -  | (7) Result: 1780 +  | float value() { +  | return floating_average_diff(requests); +  | } +  | }    -  +    --- optimizations      o New significantly faster block allocator -  +  The free in the old one was O(n), which means that as an example +  creating a lot of objects and then free:ing them mainly used CPU in +  the block allocator. +  +  This fix changed the ordo of one of the tests that did that very +  thing (binarytrees) from O(n) to O(n), and as such is more than a +  simple percentual speedup. +    o Power-of-two hashtables are now used for most hashtables - o Significantly changd x86-32 and new AMD64/x86-64 machinecode -  compilation backend - o svalue type renumbering +  +  This speeds up mappings and other hashtables a few percent, and also +  simplifies the code. +  + o Significantly changed x86-32 and an entirely new AMD64/x86-64 +  machinecode compilation backend +  +  The main feature with the x86-32 edition is that it is now using +  normal function call mechanics, which means that it now works with +  modern GCC:s. +  +  The x86-64 backends has been rewritten so that it is easier to add +  new instructions (x86-64) and opcodes (pike) to it. +  + o Svalue type renumbering +  +  PIKE_T_INT is now type #0, which makes certain things significantly +  faster. +  +  As an example, clearing of object variables is now done +  automatically when the object is created since all object memory is +  set to 0. +  +  The same thing happens when clearing values on the stack. +    o string(x..y) (constant) types    | > typeof("foo");    | (1) Result: string(102..111)    also used to optimize lower_case/upper_case search and    string_has_null etc.    -  +  The strings now keep track of the min/max values in addition to two +  new flags: all-uppercase and all-lowercase. +  +  The fairly common case where you are doing lower_case or upper_case +  on an already lower or uppercase strings is now significantly +  faster. +    o Several other optimizations to execution speed has been done -  +  + object indexing (cache, generic speedups) +  + lower_apply, changes to apply in general +  Taken together these individuallt small optimizations speeds up at +  least pike -x benchmark more than 5%.    -  +  + A lot of opcodes implemented in machinecode for x86-64 +  This speed up the loop benchmarks close to a factor of 3. But then +  again, most real code is nothing like that benchmark. +  +  + Several new opcodes added +  As an example an observation was that most branch_if_zero is +  followed by an is_eq, is_lt or is_gt or similar. Those opcodes +  always return 1 or 0. +  +  So, two new opcodes, fast_branch_if_zero and +  fast_branch_if_non_zero were added that map directly to three x86-64 +  opcodes, there is no need to check the types, do a real pop_stack +  etc. +    --- removed stuff -  +    o Removed bundles   o Removed facets   o The built in sandbox is now deprecated
106:      o Serializer    APIs useful to simplify serialization and deserialization of objects -  + Serializer.Encodable +  Mainly it allows you to easily iterate over the object variables, +  including the private ones. +  +  + Serializer.Encodable    A class that can be inherit to make an object easily serializable    using encode_value.    - o Filesystem.Monitor (System.Inotify, System.FSEvents) + o Filesystem.Monitor and the lowlevel System.Inotify + System.FSEvents    Basic filesystem monitor.       This module is intended to be used for incremental scanning of a
161:      -- UNSORTED    + o clang compatibility   o SDL.Music added to SDL.    Allows the playback of audio/music files.    Requires the SDL_mixed library.
217:    from the controlling terminal and run in the background as system    daemons.   o Crypto.PGP - support more hash functions. +    o String.levenshtein_distance()    That function calculates the Levenshtein distance between two    strings. The Levenshtein distance describes the minimum number of
226:    The algorithm can be used in approximate string matching to find    matches for a short string in many longer texts, when a small    number of differences is expected. +    o Unicode databases updated to 6.2.0 -  +    o Timezone databases updated to tzdata2013d -  +    o inherit ::this_program    This syntax refers to the previous definition of the current class    in its parent, and is typically used with inherit like:
240:    inherit ::this_program;    // ...    } +    o precompile    + inherit "identifier"    -- inherit the program returned by calling master()->resolve() on