Fix Spidermonkey android build issues
This commit is contained in:
parent
7483966da7
commit
ac6727a636
|
|
@ -99,6 +99,14 @@ include $(PREBUILT_STATIC_LIBRARY)
|
|||
#======================================
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := cocos_mozglue_static
|
||||
LOCAL_MODULE_FILENAME := mozglue
|
||||
LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libmozglue.a
|
||||
include $(PREBUILT_STATIC_LIBRARY)
|
||||
|
||||
#======================================
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := spidermonkey_static
|
||||
LOCAL_MODULE_FILENAME := js_static
|
||||
LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libjs_static.a
|
||||
|
|
@ -106,7 +114,7 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/$(TARGET_ARCH_ABI)/include/spidermonkey
|
|||
|
||||
LOCAL_CPPFLAGS := -D__STDC_LIMIT_MACROS=1 -Wno-invalid-offsetof
|
||||
LOCAL_EXPORT_CPPFLAGS := -D__STDC_LIMIT_MACROS=1 -Wno-invalid-offsetof
|
||||
|
||||
LOCAL_STATIC_LIBRARIES += cocos_mozglue_static
|
||||
include $(PREBUILT_STATIC_LIBRARY)
|
||||
|
||||
#======================================
|
||||
|
|
|
|||
|
|
@ -1,91 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 8; c-basic-offset: 8 -*- */
|
||||
/* vim:set softtabstop=8 shiftwidth=8: */
|
||||
/*-
|
||||
* Copyright (C) 2006-2008 Jason Evans <jasone@FreeBSD.org>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice(s), this list of conditions and the following disclaimer as
|
||||
* the first lines of this file unmodified other than the possible
|
||||
* addition of one or more copyright notices.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice(s), this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _JEMALLOC_TYPES_H_
|
||||
#define _JEMALLOC_TYPES_H_
|
||||
|
||||
/* grab size_t */
|
||||
#ifdef _MSC_VER
|
||||
#include <crtdefs.h>
|
||||
#else
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef unsigned char jemalloc_bool;
|
||||
|
||||
/*
|
||||
* jemalloc_stats() is not a stable interface. When using jemalloc_stats_t, be
|
||||
* sure that the compiled results of jemalloc.c are in sync with this header
|
||||
* file.
|
||||
*/
|
||||
typedef struct {
|
||||
/*
|
||||
* Run-time configuration settings.
|
||||
*/
|
||||
jemalloc_bool opt_abort; /* abort(3) on error? */
|
||||
jemalloc_bool opt_junk; /* Fill allocated memory with 0xe4? */
|
||||
jemalloc_bool opt_poison; /* Fill free memory with 0xe5? */
|
||||
jemalloc_bool opt_utrace; /* Trace all allocation events? */
|
||||
jemalloc_bool opt_sysv; /* SysV semantics? */
|
||||
jemalloc_bool opt_xmalloc; /* abort(3) on OOM? */
|
||||
jemalloc_bool opt_zero; /* Fill allocated memory with 0x0? */
|
||||
size_t narenas; /* Number of arenas. */
|
||||
size_t balance_threshold; /* Arena contention rebalance threshold. */
|
||||
size_t quantum; /* Allocation quantum. */
|
||||
size_t small_max; /* Max quantum-spaced allocation size. */
|
||||
size_t large_max; /* Max sub-chunksize allocation size. */
|
||||
size_t chunksize; /* Size of each virtual memory mapping. */
|
||||
size_t dirty_max; /* Max dirty pages per arena. */
|
||||
|
||||
/*
|
||||
* Current memory usage statistics.
|
||||
*/
|
||||
size_t mapped; /* Bytes mapped (not necessarily committed). */
|
||||
size_t allocated; /* Bytes allocated (committed, in use by application). */
|
||||
size_t waste; /* Bytes committed, not in use by the
|
||||
application, and not intentionally left
|
||||
unused (i.e., not dirty). */
|
||||
size_t page_cache; /* Committed, unused pages kept around as a
|
||||
cache. (jemalloc calls these "dirty".) */
|
||||
size_t bookkeeping; /* Committed bytes used internally by the
|
||||
allocator. */
|
||||
size_t bin_unused; /* Bytes committed to a bin but currently unused. */
|
||||
} jemalloc_stats_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* _JEMALLOC_TYPES_H_ */
|
||||
|
|
@ -49,10 +49,10 @@
|
|||
/* #undef JS_CRASH_DIAGNOSTICS */
|
||||
|
||||
/* Define to 1 if SpiderMonkey is in NUNBOX32 mode. */
|
||||
#define JS_NUNBOX32 1
|
||||
/* #undef JS_NUNBOX32 */
|
||||
|
||||
/* Define to 1 if SpiderMonkey is in PUNBOX64 mode. */
|
||||
/* #undef JS_PUNBOX64 */
|
||||
#define JS_PUNBOX64 1
|
||||
|
||||
/* MOZILLA JSAPI version number components */
|
||||
#define MOZJS_MAJOR_VERSION 52
|
||||
|
|
|
|||
|
|
@ -7,10 +7,6 @@
|
|||
#ifndef js_HashTable_h
|
||||
#define js_HashTable_h
|
||||
|
||||
#ifndef UINT64_C
|
||||
#define UINT64_C(value) __CONCAT(value, ULL)
|
||||
#endif
|
||||
|
||||
#include "mozilla/Alignment.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
|
|
|||
|
|
@ -1,91 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozmemory_h
|
||||
#define mozmemory_h
|
||||
|
||||
/*
|
||||
* This header is meant to be used when the following functions are
|
||||
* necessary:
|
||||
* - malloc_good_size (used to be called je_malloc_usable_in_advance)
|
||||
* - jemalloc_stats
|
||||
* - jemalloc_purge_freed_pages
|
||||
* - jemalloc_free_dirty_pages
|
||||
*/
|
||||
|
||||
#ifndef MOZ_MEMORY
|
||||
# error Should not include mozmemory.h when MOZ_MEMORY is not set
|
||||
#endif
|
||||
|
||||
#include "mozmemory_wrap.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/Types.h"
|
||||
#include "jemalloc_types.h"
|
||||
|
||||
MOZ_BEGIN_EXTERN_C
|
||||
|
||||
/*
|
||||
* On OSX, malloc/malloc.h contains the declaration for malloc_good_size,
|
||||
* which will call back in jemalloc, through the zone allocator so just use it.
|
||||
*/
|
||||
#ifdef XP_DARWIN
|
||||
# include <malloc/malloc.h>
|
||||
#else
|
||||
MOZ_MEMORY_API size_t malloc_good_size_impl(size_t size);
|
||||
|
||||
/* Note: the MOZ_GLUE_IN_PROGRAM ifdef below is there to avoid -Werror turning
|
||||
* the protective if into errors. MOZ_GLUE_IN_PROGRAM is what triggers MFBT_API
|
||||
* to use weak imports. */
|
||||
|
||||
static inline size_t _malloc_good_size(size_t size) {
|
||||
# if defined(MOZ_GLUE_IN_PROGRAM) && !defined(IMPL_MFBT)
|
||||
if (!malloc_good_size)
|
||||
return size;
|
||||
# endif
|
||||
return malloc_good_size_impl(size);
|
||||
}
|
||||
|
||||
# define malloc_good_size _malloc_good_size
|
||||
#endif
|
||||
|
||||
MOZ_JEMALLOC_API void jemalloc_stats(jemalloc_stats_t *stats);
|
||||
|
||||
/*
|
||||
* On some operating systems (Mac), we use madvise(MADV_FREE) to hand pages
|
||||
* back to the operating system. On Mac, the operating system doesn't take
|
||||
* this memory back immediately; instead, the OS takes it back only when the
|
||||
* machine is running out of physical memory.
|
||||
*
|
||||
* This is great from the standpoint of efficiency, but it makes measuring our
|
||||
* actual RSS difficult, because pages which we've MADV_FREE'd shouldn't count
|
||||
* against our RSS.
|
||||
*
|
||||
* This function explicitly purges any MADV_FREE'd pages from physical memory,
|
||||
* causing our reported RSS match the amount of memory we're actually using.
|
||||
*
|
||||
* Note that this call is expensive in two ways. First, it may be slow to
|
||||
* execute, because it may make a number of slow syscalls to free memory. This
|
||||
* function holds the big jemalloc locks, so basically all threads are blocked
|
||||
* while this function runs.
|
||||
*
|
||||
* This function is also expensive in that the next time we go to access a page
|
||||
* which we've just explicitly decommitted, the operating system has to attach
|
||||
* to it a physical page! If we hadn't run this function, the OS would have
|
||||
* less work to do.
|
||||
*
|
||||
* If MALLOC_DOUBLE_PURGE is not defined, this function does nothing.
|
||||
*/
|
||||
MOZ_JEMALLOC_API void jemalloc_purge_freed_pages();
|
||||
|
||||
/*
|
||||
* Free all unused dirty pages in all arenas. Calling this function will slow
|
||||
* down subsequent allocations so it is recommended to use it only when
|
||||
* memory needs to be reclaimed at all costs (see bug 805855). This function
|
||||
* provides functionality similar to mallctl("arenas.purge") in jemalloc 3.
|
||||
*/
|
||||
MOZ_JEMALLOC_API void jemalloc_free_dirty_pages();
|
||||
|
||||
MOZ_END_EXTERN_C
|
||||
|
||||
#endif /* mozmemory_h */
|
||||
|
|
@ -1,219 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozmemory_wrap_h
|
||||
#define mozmemory_wrap_h
|
||||
|
||||
/*
|
||||
* This header contains #defines which tweak the names of various memory
|
||||
* allocation functions.
|
||||
*
|
||||
* There are several types of functions related to memory allocation
|
||||
* that are meant to be used publicly by the Gecko codebase:
|
||||
*
|
||||
* - malloc implementation functions:
|
||||
* - malloc
|
||||
* - posix_memalign
|
||||
* - aligned_alloc
|
||||
* - calloc
|
||||
* - realloc
|
||||
* - free
|
||||
* - memalign
|
||||
* - valloc
|
||||
* - malloc_usable_size
|
||||
* - malloc_good_size
|
||||
* Some of these functions are specific to some systems, but for
|
||||
* convenience, they are treated as being cross-platform, and available
|
||||
* as such.
|
||||
*
|
||||
* - duplication functions:
|
||||
* - strndup
|
||||
* - strdup
|
||||
* - wcsdup (Windows only)
|
||||
*
|
||||
* - jemalloc specific functions:
|
||||
* - jemalloc_stats
|
||||
* - jemalloc_purge_freed_pages
|
||||
* - jemalloc_free_dirty_pages
|
||||
* (these functions are native to mozjemalloc, and have compatibility
|
||||
* implementations for jemalloc3)
|
||||
*
|
||||
* These functions are all exported as part of libmozglue (see
|
||||
* $(topsrcdir)/mozglue/build/Makefile.in), with a few implementation
|
||||
* peculiarities:
|
||||
*
|
||||
* - On Windows, the malloc implementation functions are all prefixed with
|
||||
* "je_", the duplication functions are prefixed with "wrap_", and jemalloc
|
||||
* specific functions are left unprefixed. All these functions are however
|
||||
* aliased when exporting them, such that the resulting mozglue.dll exports
|
||||
* them unprefixed (see $(topsrcdir)/mozglue/build/mozglue.def.in). The
|
||||
* prefixed malloc implementation and duplication functions are not
|
||||
* exported.
|
||||
*
|
||||
* - On MacOSX, the system libc has a zone allocator, which allows us to
|
||||
* hook custom malloc implementation functions without exporting them.
|
||||
* The malloc implementation functions are all prefixed with "je_" and used
|
||||
* this way from the custom zone allocator. They are not exported.
|
||||
* Duplication functions are not included, since they will call the custom
|
||||
* zone allocator anyways. Jemalloc-specific functions are also left
|
||||
* unprefixed.
|
||||
*
|
||||
* - On Android and Gonk, all functions are left unprefixed. Additionally,
|
||||
* C++ allocation functions (operator new/delete) are also exported and
|
||||
* unprefixed.
|
||||
*
|
||||
* - On other systems (mostly Linux), all functions are left unprefixed.
|
||||
*
|
||||
* Only Android and Gonk add C++ allocation functions.
|
||||
*
|
||||
* Proper exporting of the various functions is done with the MOZ_MEMORY_API
|
||||
* and MOZ_JEMALLOC_API macros. MOZ_MEMORY_API is meant to be used for malloc
|
||||
* implementation and duplication functions, while MOZ_JEMALLOC_API is
|
||||
* dedicated to jemalloc specific functions.
|
||||
*
|
||||
*
|
||||
* All these functions are meant to be called with no prefix from Gecko code.
|
||||
* In most cases, this is because that's how they are available at runtime.
|
||||
* However, on Android, this relies on faulty.lib (the custom dynamic linker)
|
||||
* resolving mozglue symbols before libc symbols, which is guaranteed by the
|
||||
* way faulty.lib works (it respects the DT_NEEDED order, and libc always
|
||||
* appears after mozglue ; which we double check when building anyways)
|
||||
*
|
||||
*
|
||||
* Within libmozglue (when MOZ_MEMORY_IMPL is defined), all the functions
|
||||
* should be suffixed with "_impl" both for declarations and use.
|
||||
* That is, the implementation declaration for e.g. strdup would look like:
|
||||
* char* strdup_impl(const char *)
|
||||
* That implementation would call malloc by using "malloc_impl".
|
||||
*
|
||||
* While mozjemalloc uses these "_impl" suffixed helpers, jemalloc3, being
|
||||
* third-party code, doesn't, but instead has an elaborate way to mangle
|
||||
* individual functions. See under "Run jemalloc configure script" in
|
||||
* $(topsrcdir)/configure.in.
|
||||
*
|
||||
*
|
||||
* When building with replace-malloc support, the above still holds, but
|
||||
* the malloc implementation and jemalloc specific functions are the
|
||||
* replace-malloc functions from replace_malloc.c.
|
||||
*
|
||||
* The actual jemalloc/mozjemalloc implementation is prefixed with "je_".
|
||||
*
|
||||
* Thus, when MOZ_REPLACE_MALLOC is defined, the "_impl" suffixed macros
|
||||
* expand to "je_" prefixed function when building mozjemalloc or
|
||||
* jemalloc3/mozjemalloc_compat, where MOZ_JEMALLOC_IMPL is defined.
|
||||
*
|
||||
* In other cases, the "_impl" suffixed macros follow the original scheme,
|
||||
* except on Windows and MacOSX, where they would expand to "je_" prefixed
|
||||
* functions. Instead, they are left unmodified (malloc_impl expands to
|
||||
* malloc_impl).
|
||||
*/
|
||||
|
||||
#ifndef MOZ_MEMORY
|
||||
# error Should only include mozmemory_wrap.h when MOZ_MEMORY is set.
|
||||
#endif
|
||||
|
||||
#if defined(MOZ_JEMALLOC_IMPL) && !defined(MOZ_MEMORY_IMPL)
|
||||
# define MOZ_MEMORY_IMPL
|
||||
#endif
|
||||
#if defined(MOZ_MEMORY_IMPL) && !defined(IMPL_MFBT)
|
||||
# ifdef MFBT_API /* mozilla/Types.h was already included */
|
||||
# error mozmemory_wrap.h has to be included before mozilla/Types.h when MOZ_MEMORY_IMPL is set and IMPL_MFBT is not.
|
||||
# endif
|
||||
# define IMPL_MFBT
|
||||
#endif
|
||||
|
||||
#include "mozilla/Types.h"
|
||||
|
||||
#if !defined(MOZ_SYSTEM_JEMALLOC)
|
||||
# ifdef MOZ_MEMORY_IMPL
|
||||
# if defined(MOZ_JEMALLOC_IMPL) && defined(MOZ_REPLACE_MALLOC) && !defined(MOZ_REPLACE_JEMALLOC)
|
||||
# define mozmem_malloc_impl(a) je_ ## a
|
||||
# define mozmem_jemalloc_impl(a) je_ ## a
|
||||
# else
|
||||
# define MOZ_JEMALLOC_API MFBT_API
|
||||
# ifdef MOZ_REPLACE_JEMALLOC
|
||||
# define MOZ_MEMORY_API MFBT_API
|
||||
# define mozmem_malloc_impl(a) replace_ ## a
|
||||
# define mozmem_jemalloc_impl(a) replace_ ## a
|
||||
# elif (defined(XP_WIN) || defined(XP_DARWIN))
|
||||
# if defined(MOZ_REPLACE_MALLOC)
|
||||
# define mozmem_malloc_impl(a) a ## _impl
|
||||
# else
|
||||
# define mozmem_malloc_impl(a) je_ ## a
|
||||
# endif
|
||||
# else
|
||||
# define MOZ_MEMORY_API MFBT_API
|
||||
# if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK)
|
||||
# define MOZ_WRAP_NEW_DELETE
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
# ifdef XP_WIN
|
||||
# define mozmem_dup_impl(a) wrap_ ## a
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* All other jemalloc3 functions are prefixed with "je_", except when
|
||||
* building against an unprefixed system jemalloc library */
|
||||
# define je_(a) je_ ## a
|
||||
#else /* defined(MOZ_SYSTEM_JEMALLOC) */
|
||||
# define je_(a) a
|
||||
#endif
|
||||
|
||||
#if !defined(MOZ_MEMORY_IMPL) || defined(MOZ_SYSTEM_JEMALLOC)
|
||||
# define MOZ_MEMORY_API MFBT_API
|
||||
# define MOZ_JEMALLOC_API MFBT_API
|
||||
#endif
|
||||
|
||||
#ifndef MOZ_MEMORY_API
|
||||
# define MOZ_MEMORY_API
|
||||
#endif
|
||||
#ifndef MOZ_JEMALLOC_API
|
||||
# define MOZ_JEMALLOC_API
|
||||
#endif
|
||||
|
||||
#ifndef mozmem_malloc_impl
|
||||
# define mozmem_malloc_impl(a) a
|
||||
#endif
|
||||
#ifndef mozmem_dup_impl
|
||||
# define mozmem_dup_impl(a) a
|
||||
#endif
|
||||
#ifndef mozmem_jemalloc_impl
|
||||
# define mozmem_jemalloc_impl(a) a
|
||||
#endif
|
||||
|
||||
/* Malloc implementation functions */
|
||||
#define malloc_impl mozmem_malloc_impl(malloc)
|
||||
#define posix_memalign_impl mozmem_malloc_impl(posix_memalign)
|
||||
#define aligned_alloc_impl mozmem_malloc_impl(aligned_alloc)
|
||||
#define calloc_impl mozmem_malloc_impl(calloc)
|
||||
#define realloc_impl mozmem_malloc_impl(realloc)
|
||||
#define free_impl mozmem_malloc_impl(free)
|
||||
#define memalign_impl mozmem_malloc_impl(memalign)
|
||||
#define valloc_impl mozmem_malloc_impl(valloc)
|
||||
#define malloc_usable_size_impl mozmem_malloc_impl(malloc_usable_size)
|
||||
#define malloc_good_size_impl mozmem_malloc_impl(malloc_good_size)
|
||||
|
||||
/* Duplication functions */
|
||||
#define strndup_impl mozmem_dup_impl(strndup)
|
||||
#define strdup_impl mozmem_dup_impl(strdup)
|
||||
#ifdef XP_WIN
|
||||
# define wcsdup_impl mozmem_dup_impl(wcsdup)
|
||||
#endif
|
||||
|
||||
/* String functions */
|
||||
#ifdef ANDROID
|
||||
/* Bug 801571 and Bug 879668, libstagefright uses vasprintf, causing malloc()/
|
||||
* free() to be mismatched between bionic and mozglue implementation.
|
||||
*/
|
||||
#define vasprintf_impl mozmem_dup_impl(vasprintf)
|
||||
#define asprintf_impl mozmem_dup_impl(asprintf)
|
||||
#endif
|
||||
|
||||
/* Jemalloc specific function */
|
||||
#define jemalloc_stats_impl mozmem_jemalloc_impl(jemalloc_stats)
|
||||
#define jemalloc_purge_freed_pages_impl mozmem_jemalloc_impl(jemalloc_purge_freed_pages)
|
||||
#define jemalloc_free_dirty_pages_impl mozmem_jemalloc_impl(jemalloc_free_dirty_pages)
|
||||
|
||||
#endif /* mozmemory_wrap_h */
|
||||
|
|
@ -55,6 +55,11 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
/* Define UINT64_C */
|
||||
#ifndef UINT64_C
|
||||
#define UINT64_C(value) __CONCAT(value,ULL)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace mozilla {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue