Skip to content

Commit ff8eb3c

Browse files
Ingo MuschenetzIngo Muschenetz
authored andcommitted
2 parents c8af8fd + ec40151 commit ff8eb3c

File tree

9 files changed

+68
-47
lines changed

9 files changed

+68
-47
lines changed

JavaScriptCore/runtime/ArgumentsIteratorConstructor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "JSCJSValueInlines.h"
3232
#include "JSCellInlines.h"
3333
#include "JSGlobalObject.h"
34+
#include "StructureInlines.h"
3435

3536
namespace JSC {
3637

JavaScriptCore/runtime/JSPromiseFunctions.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "JSPromise.h"
3535
#include "JSPromiseConstructor.h"
3636
#include "JSPromiseDeferred.h"
37+
#include "StructureInlines.h"
3738

3839
namespace JSC {
3940

JavaScriptCore/runtime/MapConstructor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "JSGlobalObject.h"
3333
#include "JSMap.h"
3434
#include "MapPrototype.h"
35+
#include "StructureInlines.h"
3536

3637
namespace JSC {
3738

JavaScriptCore/runtime/MapIteratorConstructor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "JSGlobalObject.h"
3232
#include "JSMapIterator.h"
3333
#include "MapIteratorPrototype.h"
34+
#include "StructureInlines.h"
3435

3536
namespace JSC {
3637

JavaScriptCore/runtime/SetConstructor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "JSSet.h"
3434
#include "MapData.h"
3535
#include "SetPrototype.h"
36+
#include "StructureInlines.h"
3637

3738
namespace JSC {
3839

JavaScriptCore/runtime/SetIteratorConstructor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "JSGlobalObject.h"
3232
#include "JSSetIterator.h"
3333
#include "SetIteratorPrototype.h"
34+
#include "StructureInlines.h"
3435

3536
namespace JSC {
3637

JavaScriptCore/runtime/WeakMapConstructor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "JSGlobalObject.h"
3232
#include "JSWeakMap.h"
3333
#include "WeakMapPrototype.h"
34+
#include "StructureInlines.h"
3435

3536
namespace JSC {
3637

WTF/wtf/FastMalloc.cpp

Lines changed: 55 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
#include <wtf/StdLibExtras.h>
9292

9393
#if OS(DARWIN)
94+
#include <mach/mach_init.h>
9495
#include <malloc/malloc.h>
9596
#endif
9697

@@ -628,29 +629,23 @@ static ALWAYS_INLINE uint32_t freedObjectEndPoison()
628629
//-------------------------------------------------------------------
629630
// Configuration
630631
//-------------------------------------------------------------------
631-
632-
// Not all possible combinations of the following parameters make
633-
// sense. In particular, if kMaxSize increases, you may have to
634-
// increase kNumClasses as well.
635-
#if OS(DARWIN)
636-
# define K_PAGE_SHIFT PAGE_SHIFT
637-
# if (K_PAGE_SHIFT == 12)
638-
# define K_NUM_CLASSES 68
639-
# elif (K_PAGE_SHIFT == 14)
640-
# define K_NUM_CLASSES 77
641-
# else
642-
# error "Unsupported PAGE_SHIFT amount"
643-
# endif
644-
#else
645-
# define K_PAGE_SHIFT 12
646-
# define K_NUM_CLASSES 68
647-
#endif
648-
static const size_t kPageShift = K_PAGE_SHIFT;
649-
static const size_t kPageSize = 1 << kPageShift;
650-
static const size_t kMaxSize = 32u * 1024;
651-
static const size_t kAlignShift = 3;
652-
static const size_t kAlignment = 1 << kAlignShift;
653-
static const size_t kNumClasses = K_NUM_CLASSES;
632+
633+
// Type that can hold the length of a run of pages
634+
typedef uintptr_t Length;
635+
636+
// Not all possible combinations of the following parameters make
637+
// sense. In particular, if kMaxSize increases, you may have to
638+
// increase kNumClasses as well.
639+
#define K_PAGE_SHIFT_MIN 12
640+
#define K_PAGE_SHIFT_MAX 14
641+
#define K_NUM_CLASSES_MAX 77
642+
static size_t kPageShift = 0;
643+
static size_t kNumClasses = 0;
644+
static size_t kPageSize = 0;
645+
static Length kMaxValidPages = 0;
646+
static const size_t kMaxSize = 32u * 1024;
647+
static const size_t kAlignShift = 3;
648+
static const size_t kAlignment = 1 << kAlignShift;
654649

655650
// Allocates a big block of memory for the pagemap once we reach more than
656651
// 128MB
@@ -662,14 +657,14 @@ static const size_t kPageMapBigAllocationThreshold = 128 << 20;
662657
// should keep this value big because various incarnations of Linux
663658
// have small limits on the number of mmap() regions per
664659
// address-space.
665-
static const size_t kMinSystemAlloc = 1 << (20 - kPageShift);
660+
static const size_t kMinSystemAlloc = 1 << (20 - K_PAGE_SHIFT_MAX);
666661

667662
// Number of objects to move between a per-thread list and a central
668663
// list in one shot. We want this to be not too small so we can
669664
// amortize the lock overhead for accessing the central list. Making
670665
// it too big may temporarily cause unnecessary memory wastage in the
671666
// per-thread free list until the scavenger cleans up the list.
672-
static int num_objects_to_move[kNumClasses];
667+
static int num_objects_to_move[K_NUM_CLASSES_MAX];
673668

674669
// Maximum length we allow a per-thread free-list to have before we
675670
// move objects from it into the corresponding central free-list. We
@@ -765,10 +760,10 @@ static inline int ClassIndex(size_t s) {
765760
}
766761

767762
// Mapping from size class to max size storable in that class
768-
static size_t class_to_size[kNumClasses];
763+
static size_t class_to_size[K_NUM_CLASSES_MAX];
769764

770765
// Mapping from size class to number of pages to allocate at a time
771-
static size_t class_to_pages[kNumClasses];
766+
static size_t class_to_pages[K_NUM_CLASSES_MAX];
772767

773768
// Hardened singly linked list. We make this a class to allow compiler to
774769
// statically prevent mismatching hardened and non-hardened list
@@ -808,12 +803,13 @@ struct TCEntry {
808803
HardenedSLL head; // Head of chain of objects.
809804
HardenedSLL tail; // Tail of chain of objects.
810805
};
811-
// A central cache freelist can have anywhere from 0 to kNumTransferEntries
812-
// slots to put link list chains into. To keep memory usage bounded the total
813-
// number of TCEntries across size classes is fixed. Currently each size
814-
// class is initially given one TCEntry which also means that the maximum any
815-
// one class can have is kNumClasses.
816-
static const int kNumTransferEntries = kNumClasses;
806+
// A central cache freelist can have anywhere from 0 to kNumTransferEntries
807+
// slots to put link list chains into. To keep memory usage bounded the total
808+
// number of TCEntries across size classes is fixed. Currently each size
809+
// class is initially given one TCEntry which also means that the maximum any
810+
// one class can have is kNumClasses.
811+
#define K_NUM_TRANSFER_ENTRIES_MAX static_cast<int>(K_NUM_CLASSES_MAX)
812+
#define kNumTransferEntries static_cast<int>(kNumClasses)
817813

818814
// Note: the following only works for "n"s that fit in 32-bits, but
819815
// that is fine since we only use it for small sizes.
@@ -917,6 +913,25 @@ static int NumMoveSize(size_t size) {
917913

918914
// Initialize the mapping arrays
919915
static void InitSizeClasses() {
916+
#if OS(DARWIN)
917+
kPageShift = vm_page_shift;
918+
switch (kPageShift) {
919+
case 12:
920+
kNumClasses = 68;
921+
break;
922+
case 14:
923+
kNumClasses = 77;
924+
break;
925+
default:
926+
CRASH();
927+
};
928+
#else
929+
kPageShift = 12;
930+
kNumClasses = 68;
931+
#endif
932+
kPageSize = 1 << kPageShift;
933+
kMaxValidPages = (~static_cast<Length>(0)) >> kPageShift;
934+
920935
// Do some sanity checking on add_amount[]/shift_amount[]/class_array[]
921936
if (ClassIndex(0) < 0) {
922937
MESSAGE("Invalid class index %d for size 0\n", ClassIndex(0));
@@ -1144,11 +1159,6 @@ class PageHeapAllocator {
11441159
// Type that can hold a page number
11451160
typedef uintptr_t PageID;
11461161

1147-
// Type that can hold the length of a run of pages
1148-
typedef uintptr_t Length;
1149-
1150-
static const Length kMaxValidPages = (~static_cast<Length>(0)) >> kPageShift;
1151-
11521162
// Convert byte size into pages. This won't overflow, but may return
11531163
// an unreasonably large value if bytes is huge enough.
11541164
static inline Length pages(size_t bytes) {
@@ -1431,7 +1441,7 @@ class TCMalloc_Central_FreeList {
14311441
// Here we reserve space for TCEntry cache slots. Since one size class can
14321442
// end up getting all the TCEntries quota in the system we just preallocate
14331443
// sufficient number of entries here.
1434-
TCEntry tc_slots_[kNumTransferEntries];
1444+
TCEntry tc_slots_[K_NUM_TRANSFER_ENTRIES_MAX];
14351445

14361446
// Number of currently used cached entries in tc_slots_. This variable is
14371447
// updated under a lock but can be read without one.
@@ -1677,16 +1687,16 @@ static const size_t kBitsUnusedOn64Bit = 0;
16771687
// A three-level map for 64-bit machines
16781688
template <> class MapSelector<64> {
16791689
public:
1680-
typedef TCMalloc_PageMap3<64 - kPageShift - kBitsUnusedOn64Bit> Type;
1690+
typedef TCMalloc_PageMap3<64 - K_PAGE_SHIFT_MIN - kBitsUnusedOn64Bit> Type;
16811691
typedef PackedCache<64, uint64_t> CacheType;
16821692
};
16831693
#endif
16841694

16851695
// A two-level map for 32-bit machines
16861696
template <> class MapSelector<32> {
16871697
public:
1688-
typedef TCMalloc_PageMap2<32 - kPageShift> Type;
1689-
typedef PackedCache<32 - kPageShift, uint16_t> CacheType;
1698+
typedef TCMalloc_PageMap2<32 - K_PAGE_SHIFT_MIN> Type;
1699+
typedef PackedCache<32 - K_PAGE_SHIFT_MIN, uint16_t> CacheType;
16901700
};
16911701

16921702
// -------------------------------------------------------------------------
@@ -1932,7 +1942,7 @@ void TCMalloc_PageHeap::init()
19321942
scavenge_counter_ = 0;
19331943
// Start scavenging at kMaxPages list
19341944
scavenge_index_ = kMaxPages-1;
1935-
COMPILE_ASSERT(kNumClasses <= (1 << PageMapCache::kValuebits), valuebits);
1945+
ASSERT(kNumClasses <= (1 << PageMapCache::kValuebits));
19361946
DLL_Init(&large_.normal, entropy_);
19371947
DLL_Init(&large_.returned, entropy_);
19381948
for (size_t i = 0; i < kMaxPages; i++) {
@@ -2744,7 +2754,7 @@ class TCMalloc_ThreadCache {
27442754
size_t size_; // Combined size of data
27452755
ThreadIdentifier tid_; // Which thread owns it
27462756
bool in_setspecific_; // Called pthread_setspecific?
2747-
FreeList list_[kNumClasses]; // Array indexed by size-class
2757+
FreeList list_[K_NUM_CLASSES_MAX]; // Array indexed by size-class
27482758

27492759
// We sample allocations, biased by the size of the allocation
27502760
uint32_t rnd_; // Cheap random number generator
@@ -2812,7 +2822,7 @@ class TCMalloc_ThreadCache {
28122822

28132823
// Central cache -- a collection of free-lists, one per size-class.
28142824
// We have a separate lock per free-list to reduce contention.
2815-
static TCMalloc_Central_FreeListPadded central_cache[kNumClasses];
2825+
static TCMalloc_Central_FreeListPadded central_cache[K_NUM_CLASSES_MAX];
28162826

28172827
// Page-level allocator
28182828
static AllocAlignmentInteger pageheap_memory[(sizeof(TCMalloc_PageHeap) + sizeof(AllocAlignmentInteger) - 1) / sizeof(AllocAlignmentInteger)];

xcodebuild.py

100644100755
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def _get_sdk_string(self):
4444
if arch.startswith("arm")]) > 0
4545
is_simulator = len([arch for arch in self.archs
4646
if arch.startswith("i386") or
47-
arch.startswith("x64")]) > 0
47+
arch.startswith("x86_64")]) > 0
4848
if is_device and is_simulator:
4949
raise PebbleXcodeBuildException("Can't build for Device and"
5050
"Simulator in one go! (archs=%s)" %
@@ -127,11 +127,13 @@ def __init__(self, project=None, workspace=None, scheme=None,
127127
self.devicebuildarmv7 = XcodeBuild(project, derived_data_path=derived_data_path)
128128
self.devicebuildarmv7s = XcodeBuild(project, derived_data_path=derived_data_path)
129129
self.simulatorbuild = XcodeBuild(project, derived_data_path=derived_data_path)
130+
self.simulatorbuild64 = XcodeBuild(project, derived_data_path=derived_data_path)
130131
self.outdir = outdir
131132
for (bld, archs) in [self.devicebuildarm64, ["arm64"]], \
132133
[self.devicebuildarmv7, ["armv7"]], \
133134
[self.devicebuildarmv7s, ["armv7s"]], \
134-
[self.simulatorbuild, ["i386"]]:
135+
[self.simulatorbuild, ["i386"]], \
136+
[self.simulatorbuild64, ["x86_64"]]:
135137
bld.archs = archs
136138
bld.scheme = scheme
137139
bld.conf = conf
@@ -146,6 +148,7 @@ def build(self):
146148
self.devicebuildarmv7.build()
147149
self.devicebuildarmv7s.build()
148150
self.simulatorbuild.build()
151+
self.simulatorbuild64.build()
149152

150153
# Create the framework directory structure:
151154
temp_dir = tempfile.mkdtemp()
@@ -171,6 +174,7 @@ def build(self):
171174
self.devicebuildarmv7.built_product_path(),
172175
self.devicebuildarmv7s.built_product_path(),
173176
self.simulatorbuild.built_product_path(),
177+
self.simulatorbuild64.built_product_path(),
174178
"-output", lib_path]
175179
logging.debug("Executing: %s" % " ".join(lipo_cmd))
176180
if subprocess.call(lipo_cmd):

0 commit comments

Comments
 (0)