OLD | NEW |
1 /* -*- Mode: C; tab-width: 8; c-basic-offset: 8 -*- */ | 1 /* -*- Mode: C; tab-width: 8; c-basic-offset: 8 -*- */ |
2 /* vim:set softtabstop=8 shiftwidth=8: */ | 2 /* vim:set softtabstop=8 shiftwidth=8: */ |
3 /*- | 3 /*- |
4 * Copyright (C) 2006-2008 Jason Evans <jasone@FreeBSD.org>. | 4 * Copyright (C) 2006-2008 Jason Evans <jasone@FreeBSD.org>. |
5 * All rights reserved. | 5 * All rights reserved. |
6 * | 6 * |
7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
9 * are met: | 9 * are met: |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 4806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4817 | 4817 |
4818 /* Initialize bins. */ | 4818 /* Initialize bins. */ |
4819 prev_run_size = pagesize; | 4819 prev_run_size = pagesize; |
4820 | 4820 |
4821 /* (2^n)-spaced tiny bins. */ | 4821 /* (2^n)-spaced tiny bins. */ |
4822 for (i = 0; i < ntbins; i++) { | 4822 for (i = 0; i < ntbins; i++) { |
4823 bin = &arena->bins[i]; | 4823 bin = &arena->bins[i]; |
4824 bin->runcur = NULL; | 4824 bin->runcur = NULL; |
4825 arena_run_tree_new(&bin->runs); | 4825 arena_run_tree_new(&bin->runs); |
4826 | 4826 |
4827 » » bin->reg_size = (1U << (TINY_MIN_2POW + i)); | 4827 » » bin->reg_size = ((size_t)1 << (TINY_MIN_2POW + i)); |
4828 | 4828 |
4829 prev_run_size = arena_bin_run_size_calc(bin, prev_run_size); | 4829 prev_run_size = arena_bin_run_size_calc(bin, prev_run_size); |
4830 | 4830 |
4831 #ifdef MALLOC_STATS | 4831 #ifdef MALLOC_STATS |
4832 memset(&bin->stats, 0, sizeof(malloc_bin_stats_t)); | 4832 memset(&bin->stats, 0, sizeof(malloc_bin_stats_t)); |
4833 #endif | 4833 #endif |
4834 } | 4834 } |
4835 | 4835 |
4836 /* Quantum-spaced bins. */ | 4836 /* Quantum-spaced bins. */ |
4837 for (; i < ntbins + nqbins; i++) { | 4837 for (; i < ntbins + nqbins; i++) { |
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5868 } | 5868 } |
5869 | 5869 |
5870 #if (!defined(MOZ_MEMORY_WINDOWS) && !defined(MOZ_MEMORY_DARWIN)) | 5870 #if (!defined(MOZ_MEMORY_WINDOWS) && !defined(MOZ_MEMORY_DARWIN)) |
5871 /* Prevent potential deadlock on malloc locks after fork. */ | 5871 /* Prevent potential deadlock on malloc locks after fork. */ |
5872 pthread_atfork(_malloc_prefork, _malloc_postfork, _malloc_postfork); | 5872 pthread_atfork(_malloc_prefork, _malloc_postfork, _malloc_postfork); |
5873 #endif | 5873 #endif |
5874 | 5874 |
5875 /* Set variables according to the value of opt_small_max_2pow. */ | 5875 /* Set variables according to the value of opt_small_max_2pow. */ |
5876 if (opt_small_max_2pow < opt_quantum_2pow) | 5876 if (opt_small_max_2pow < opt_quantum_2pow) |
5877 opt_small_max_2pow = opt_quantum_2pow; | 5877 opt_small_max_2pow = opt_quantum_2pow; |
5878 » small_max = (1U << opt_small_max_2pow); | 5878 » small_max = ((size_t)1 << opt_small_max_2pow); |
5879 | 5879 |
5880 /* Set bin-related variables. */ | 5880 /* Set bin-related variables. */ |
5881 bin_maxclass = (pagesize >> 1); | 5881 bin_maxclass = (pagesize >> 1); |
5882 assert(opt_quantum_2pow >= TINY_MIN_2POW); | 5882 assert(opt_quantum_2pow >= TINY_MIN_2POW); |
5883 ntbins = opt_quantum_2pow - TINY_MIN_2POW; | 5883 ntbins = opt_quantum_2pow - TINY_MIN_2POW; |
5884 assert(ntbins <= opt_quantum_2pow); | 5884 assert(ntbins <= opt_quantum_2pow); |
5885 nqbins = (small_max >> opt_quantum_2pow); | 5885 nqbins = (small_max >> opt_quantum_2pow); |
5886 nsbins = pagesize_2pow - opt_small_max_2pow - 1; | 5886 nsbins = pagesize_2pow - opt_small_max_2pow - 1; |
5887 | 5887 |
5888 /* Set variables according to the value of opt_quantum_2pow. */ | 5888 /* Set variables according to the value of opt_quantum_2pow. */ |
5889 » quantum = (1U << opt_quantum_2pow); | 5889 » quantum = ((size_t)1 << opt_quantum_2pow); |
5890 quantum_mask = quantum - 1; | 5890 quantum_mask = quantum - 1; |
5891 if (ntbins > 0) | 5891 if (ntbins > 0) |
5892 small_min = (quantum >> 1) + 1; | 5892 small_min = (quantum >> 1) + 1; |
5893 else | 5893 else |
5894 small_min = 1; | 5894 small_min = 1; |
5895 assert(small_min <= quantum); | 5895 assert(small_min <= quantum); |
5896 | 5896 |
5897 /* Set variables according to the value of opt_chunk_2pow. */ | 5897 /* Set variables according to the value of opt_chunk_2pow. */ |
5898 » chunksize = (1LU << opt_chunk_2pow); | 5898 » chunksize = ((size_t)1 << opt_chunk_2pow); |
5899 chunksize_mask = chunksize - 1; | 5899 chunksize_mask = chunksize - 1; |
5900 chunk_npages = (chunksize >> pagesize_2pow); | 5900 chunk_npages = (chunksize >> pagesize_2pow); |
5901 { | 5901 { |
5902 size_t header_size; | 5902 size_t header_size; |
5903 | 5903 |
5904 /* | 5904 /* |
5905 * Compute the header size such that it is large | 5905 * Compute the header size such that it is large |
5906 * enough to contain the page map and enough nodes for the | 5906 * enough to contain the page map and enough nodes for the |
5907 * worst case: one node per non-header page plus one extra for | 5907 * worst case: one node per non-header page plus one extra for |
5908 * situations where we briefly have one more node allocated | 5908 * situations where we briefly have one more node allocated |
(...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7268 | 7268 |
7269 #elif defined(RTLD_DEEPBIND) | 7269 #elif defined(RTLD_DEEPBIND) |
7270 /* | 7270 /* |
7271 * XXX On systems that support RTLD_GROUP or DF_1_GROUP, do their | 7271 * XXX On systems that support RTLD_GROUP or DF_1_GROUP, do their |
7272 * implementations permit similar inconsistencies? Should STV_SINGLETON | 7272 * implementations permit similar inconsistencies? Should STV_SINGLETON |
7273 * visibility be used for interposition where available? | 7273 * visibility be used for interposition where available? |
7274 */ | 7274 */ |
7275 # error "Interposing malloc is unsafe on this system without libc malloc hooks.
" | 7275 # error "Interposing malloc is unsafe on this system without libc malloc hooks.
" |
7276 #endif | 7276 #endif |
7277 | 7277 |
OLD | NEW |