Changeset 180958 in webkit


Ignore:
Timestamp:
Mar 3, 2015 2:45:59 PM (9 years ago)
Author:
ggaren@apple.com
Message:

bmalloc: Added missing features to the malloc zone introspection API
https://bugs.webkit.org/show_bug.cgi?id=142235

Reviewed by Andreas Kling.

This should fix the crash we saw on the iOS PLT bot
(c.f. http://trac.webkit.org/changeset/180604).

  • bmalloc/Zone.cpp:

(bmalloc::good_size):
(bmalloc::check):
(bmalloc::print):
(bmalloc::log):
(bmalloc::force_lock):
(bmalloc::force_unlock):
(bmalloc::statistics):
(bmalloc::size):
(bmalloc::enumerator): Provide all of these functions since they are called
indiscriminately on all zones.

(bmalloc::Zone::Zone):
(bmalloc::Zone::size): Deleted.
(bmalloc::Zone::enumerator): Deleted. Moved these functions out of the
Zone class since they can stand alone.

  • bmalloc/Zone.h:
Location:
trunk/Source/bmalloc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/bmalloc/ChangeLog

    r180954 r180958  
     12015-03-03  Geoffrey Garen  <ggaren@apple.com>
     2
     3        bmalloc: Added missing features to the malloc zone introspection API
     4        https://bugs.webkit.org/show_bug.cgi?id=142235
     5
     6        Reviewed by Andreas Kling.
     7
     8        This should fix the crash we saw on the iOS PLT bot
     9        (c.f. http://trac.webkit.org/changeset/180604).
     10
     11        * bmalloc/Zone.cpp:
     12        (bmalloc::good_size):
     13        (bmalloc::check):
     14        (bmalloc::print):
     15        (bmalloc::log):
     16        (bmalloc::force_lock):
     17        (bmalloc::force_unlock):
     18        (bmalloc::statistics):
     19        (bmalloc::size):
     20        (bmalloc::enumerator): Provide all of these functions since they are called
     21        indiscriminately on all zones.
     22
     23        (bmalloc::Zone::Zone):
     24        (bmalloc::Zone::size): Deleted.
     25        (bmalloc::Zone::enumerator): Deleted. Moved these functions out of the
     26        Zone class since they can stand alone.
     27
     28        * bmalloc/Zone.h:
     29
    1302015-03-03  Geoffrey Garen  <ggaren@apple.com>
    231
  • trunk/Source/bmalloc/bmalloc/Zone.cpp

    r180954 r180958  
    2929namespace bmalloc {
    3030
    31 // The memory analysis API requires the contents of this struct to be a static
    32 // constant in the program binary. The leaks process will load this struct
    33 // out of the program binary (and not out of the running process).
    34 static malloc_introspection_t introspect = {
    35     .enumerator = Zone::enumerator
    36 };
    37 
    3831template<typename T> static void remoteRead(task_t task, memory_reader_t reader, vm_address_t pointer, T& result)
    3932{
     
    4336}
    4437
    45 // Support malloc_zone_from_ptr, which calls size() on each registered zone.
    46 size_t Zone::size(malloc_zone_t*, const void*)
     38// These function pointers are invoked unconditionally on all zones by various
     39// system tools. We don't support any of these features, but we provide
     40// just enough functionality not to crash.
     41
     42static size_t good_size(malloc_zone_t*, size_t size)
     43{
     44    return size;
     45}
     46
     47static boolean_t check(malloc_zone_t*)
     48{
     49    return true;
     50}
     51
     52static void print(malloc_zone_t*, boolean_t)
     53{
     54}
     55
     56static void log(malloc_zone_t*, void*)
     57{
     58}
     59
     60static void force_lock(malloc_zone_t*)
     61{
     62}
     63
     64static void force_unlock(malloc_zone_t*)
     65{
     66}
     67
     68static void statistics(malloc_zone_t*, malloc_statistics_t* statistics)
     69{
     70    memset(statistics, 0, sizeof(malloc_statistics_t));
     71}
     72
     73static size_t size(malloc_zone_t*, const void*)
    4774{
    4875    // Our zone is not public API, so no pointer can belong to us.
     
    5178
    5279// This function runs inside the leaks process.
    53 kern_return_t Zone::enumerator(task_t task, void* context, unsigned type_mask, vm_address_t zone_address, memory_reader_t reader, vm_range_recorder_t recorder)
     80static kern_return_t enumerator(task_t task, void* context, unsigned type_mask, vm_address_t zone_address, memory_reader_t reader, vm_range_recorder_t recorder)
    5481{
    5582    Zone remoteZone;
     
    6996}
    7097
     98// The memory analysis API requires the contents of this struct to be a static
     99// constant in the program binary. The leaks process will load this struct
     100// out of the program binary (and not out of the running process).
     101static malloc_introspection_t introspect = {
     102    .enumerator = bmalloc::enumerator,
     103    .good_size = bmalloc::good_size,
     104    .check = bmalloc::check,
     105    .print = bmalloc::print,
     106    .log = bmalloc::log,
     107    .force_lock = bmalloc::force_lock,
     108    .force_unlock = bmalloc::force_unlock,
     109    .statistics = bmalloc::statistics
     110};
     111
    71112Zone::Zone()
    72113{
    73     malloc_zone_t::size = size;
     114    malloc_zone_t::size = &bmalloc::size;
    74115    malloc_zone_t::zone_name = "WebKit Malloc";
    75116    malloc_zone_t::introspect = &bmalloc::introspect;
  • trunk/Source/bmalloc/bmalloc/Zone.h

    r180954 r180958  
    3939    static const size_t capacity = 2048;
    4040
    41     static size_t size(malloc_zone_t*, const void*);
    42     static kern_return_t enumerator(task_t, void* context, unsigned type_mask, vm_address_t, memory_reader_t, vm_range_recorder_t);
    43 
    4441    Zone();
    4542
Note: See TracChangeset for help on using the changeset viewer.