diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/runtime/ArrayConventions.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/JavaScriptCore/runtime/ArrayConventions.h')
-rw-r--r-- | Source/JavaScriptCore/runtime/ArrayConventions.h | 64 |
1 files changed, 51 insertions, 13 deletions
diff --git a/Source/JavaScriptCore/runtime/ArrayConventions.h b/Source/JavaScriptCore/runtime/ArrayConventions.h index e5ef96336..6aacb978c 100644 --- a/Source/JavaScriptCore/runtime/ArrayConventions.h +++ b/Source/JavaScriptCore/runtime/ArrayConventions.h @@ -1,6 +1,6 @@ /* * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2003, 2007, 2008, 2009, 2012 Apple Inc. All rights reserved. + * Copyright (C) 2003, 2007, 2008, 2009, 2012, 2016 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -18,8 +18,7 @@ * */ -#ifndef ArrayConventions_h -#define ArrayConventions_h +#pragma once #include "IndexingHeader.h" #include "WriteBarrier.h" @@ -38,7 +37,7 @@ namespace JSC { // (specifically, this is only one property - the value 0xFFFFFFFFU as an unsigned 32-bit // integer) are not considered array indices and will be stored in the JSObject property map. // -// All properties with a numeric identifer, representable as an unsigned integer i, +// All properties with a numeric identifier, representable as an unsigned integer i, // where (i <= MAX_ARRAY_INDEX), are an array index and will be stored in either the // storage vector or the sparse map. An array index i will be handled in the following // fashion: @@ -58,18 +57,27 @@ namespace JSC { // These values have to be macros to be used in max() and min() without introducing // a PIC branch in Mach-O binaries, see <rdar://problem/5971391>. + +// If you grow an ArrayStorage array by more than this, then the array will go sparse. Note that we +// could probably make this smaller (it's large because it used to be conflated with +// MIN_ARRAY_STORAGE_CONSTRUCTION_LENGTH). #define MIN_SPARSE_ARRAY_INDEX 100000U +// If you try to allocate a contiguous array larger than this, then we will allocate an ArrayStorage +// array instead. We allow for an array that occupies 1GB of VM. +#define MIN_ARRAY_STORAGE_CONSTRUCTION_LENGTH 1024 * 1024 * 1024 / 8 #define MAX_STORAGE_VECTOR_INDEX (MAX_STORAGE_VECTOR_LENGTH - 1) // 0xFFFFFFFF is a bit weird -- is not an array index even though it's an integer. #define MAX_ARRAY_INDEX 0xFFFFFFFEU -// The value BASE_VECTOR_LEN is the maximum number of vector elements we'll allocate +// The value BASE_XXX_VECTOR_LEN is the maximum number of vector elements we'll allocate // for an array that was created with a sepcified length (e.g. a = new Array(123)) -#define BASE_VECTOR_LEN 4U - +#define BASE_CONTIGUOUS_VECTOR_LEN 3U +#define BASE_CONTIGUOUS_VECTOR_LEN_EMPTY 5U +#define BASE_ARRAY_STORAGE_VECTOR_LEN 4U + // The upper bound to the size we'll grow a zero length array when the first element // is added. -#define FIRST_VECTOR_GROW 4U +#define FIRST_ARRAY_STORAGE_VECTOR_GROW 4U #define MIN_BEYOND_LENGTH_SPARSE_INDEX 1000 @@ -89,7 +97,7 @@ inline bool indexIsSufficientlyBeyondLengthForSparseMap(unsigned i, unsigned len return i >= MIN_BEYOND_LENGTH_SPARSE_INDEX && i > length; } -inline IndexingHeader indexingHeaderForArray(unsigned length, unsigned vectorLength) +inline IndexingHeader indexingHeaderForArrayStorage(unsigned length, unsigned vectorLength) { IndexingHeader result; result.setPublicLength(length); @@ -97,12 +105,42 @@ inline IndexingHeader indexingHeaderForArray(unsigned length, unsigned vectorLen return result; } -inline IndexingHeader baseIndexingHeaderForArray(unsigned length) +inline IndexingHeader baseIndexingHeaderForArrayStorage(unsigned length) { - return indexingHeaderForArray(length, BASE_VECTOR_LEN); + return indexingHeaderForArrayStorage(length, BASE_ARRAY_STORAGE_VECTOR_LEN); } -} // namespace JSC +#if USE(JSVALUE64) +JS_EXPORT_PRIVATE void clearArrayMemset(WriteBarrier<Unknown>* base, unsigned count); +JS_EXPORT_PRIVATE void clearArrayMemset(double* base, unsigned count); +#endif // USE(JSVALUE64) + +ALWAYS_INLINE void clearArray(WriteBarrier<Unknown>* base, unsigned count) +{ +#if USE(JSVALUE64) + const unsigned minCountForMemset = 100; + if (count >= minCountForMemset) { + clearArrayMemset(base, count); + return; + } +#endif + + for (unsigned i = count; i--;) + base[i].clear(); +} -#endif // ArrayConventions_h +ALWAYS_INLINE void clearArray(double* base, unsigned count) +{ +#if USE(JSVALUE64) + const unsigned minCountForMemset = 100; + if (count >= minCountForMemset) { + clearArrayMemset(base, count); + return; + } +#endif + + for (unsigned i = count; i--;) + base[i] = PNaN; +} +} // namespace JSC |