Remove unused external typed data factories.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2276803002 .
This commit is contained in:
Ryan Macnak 2016-08-25 10:29:17 -07:00
parent ce5a17ab63
commit 5c06127e2d
10 changed files with 0 additions and 227 deletions

View file

@ -41,13 +41,6 @@ static void LengthCheck(intptr_t len, intptr_t max) {
}
static void PeerFinalizer(void* isolate_callback_data,
Dart_WeakPersistentHandle handle,
void* peer) {
OS::AlignedFree(peer);
}
DEFINE_NATIVE_ENTRY(TypedData_length, 1) {
GET_NON_NULL_NATIVE_ARGUMENT(Instance, instance, arguments->NativeArgAt(0));
if (instance.IsTypedData()) {
@ -175,31 +168,8 @@ DEFINE_NATIVE_ENTRY(TypedData_##name##_new, 2) { \
} \
// We check the length parameter against a possible maximum length for the
// array based on available physical addressable memory on the system. The
// maximum possible length is a scaled value of kSmiMax which is set up based
// on whether the underlying architecture is 32-bit or 64-bit.
// Argument 0 is type arguments and is ignored.
#define EXT_TYPED_DATA_NEW(name) \
DEFINE_NATIVE_ENTRY(ExternalTypedData_##name##_new, 2) { \
const int kAlignment = 16; \
GET_NON_NULL_NATIVE_ARGUMENT(Smi, length, arguments->NativeArgAt(1)); \
intptr_t cid = kExternalTypedData##name##Cid; \
intptr_t len = length.Value(); \
intptr_t max = ExternalTypedData::MaxElements(cid); \
LengthCheck(len, max); \
intptr_t len_bytes = len * ExternalTypedData::ElementSizeInBytes(cid); \
uint8_t* data = OS::AllocateAlignedArray<uint8_t>(len_bytes, kAlignment); \
const ExternalTypedData& obj = \
ExternalTypedData::Handle(ExternalTypedData::New(cid, data, len)); \
obj.AddFinalizer(data, PeerFinalizer); \
return obj.raw(); \
} \
#define TYPED_DATA_NEW_NATIVE(name) \
TYPED_DATA_NEW(name) \
EXT_TYPED_DATA_NEW(name) \
CLASS_LIST_TYPED_DATA(TYPED_DATA_NEW_NATIVE)

View file

@ -1873,10 +1873,6 @@ class Float64x2List extends _TypedList with _Float64x2ListMixin implements List<
class _ExternalInt8Array extends _TypedList with _IntListMixin implements Int8List {
// Factory constructors.
factory _ExternalInt8Array(int length) native "ExternalTypedData_Int8Array_new";
// Method(s) implementing the List interface.
int operator[](int index) {
if (index < 0 || index >= length) {
@ -1909,10 +1905,6 @@ class _ExternalInt8Array extends _TypedList with _IntListMixin implements Int8Li
class _ExternalUint8Array extends _TypedList with _IntListMixin implements Uint8List {
// Factory constructors.
factory _ExternalUint8Array(int length) native "ExternalTypedData_Uint8Array_new";
// Method(s) implementing the List interface.
int operator[](int index) {
@ -1946,10 +1938,6 @@ class _ExternalUint8Array extends _TypedList with _IntListMixin implements Uint8
class _ExternalUint8ClampedArray extends _TypedList with _IntListMixin implements Uint8ClampedList {
// Factory constructors.
factory _ExternalUint8ClampedArray(int length) native "ExternalTypedData_Uint8ClampedArray_new";
// Method(s) implementing the List interface.
int operator[](int index) {
@ -1983,10 +1971,6 @@ class _ExternalUint8ClampedArray extends _TypedList with _IntListMixin implement
class _ExternalInt16Array extends _TypedList with _IntListMixin implements Int16List {
// Factory constructors.
factory _ExternalInt16Array(int length) native "ExternalTypedData_Int16Array_new";
// Method(s) implementing the List interface.
int operator[](int index) {
@ -2028,10 +2012,6 @@ class _ExternalInt16Array extends _TypedList with _IntListMixin implements Int16
class _ExternalUint16Array extends _TypedList with _IntListMixin implements Uint16List {
// Factory constructors.
factory _ExternalUint16Array(int length) native "ExternalTypedData_Uint16Array_new";
// Method(s) implementing the List interface.
int operator[](int index) {
@ -2073,10 +2053,6 @@ class _ExternalUint16Array extends _TypedList with _IntListMixin implements Uint
class _ExternalInt32Array extends _TypedList with _IntListMixin implements Int32List {
// Factory constructors.
factory _ExternalInt32Array(int length) native "ExternalTypedData_Int32Array_new";
// Method(s) implementing the List interface.
int operator[](int index) {
@ -2118,10 +2094,6 @@ class _ExternalInt32Array extends _TypedList with _IntListMixin implements Int32
class _ExternalUint32Array extends _TypedList with _IntListMixin implements Uint32List {
// Factory constructors.
factory _ExternalUint32Array(int length) native "ExternalTypedData_Uint32Array_new";
// Method(s) implementing the List interface.
int operator[](int index) {
@ -2163,10 +2135,6 @@ class _ExternalUint32Array extends _TypedList with _IntListMixin implements Uint
class _ExternalInt64Array extends _TypedList with _IntListMixin implements Int64List {
// Factory constructors.
factory _ExternalInt64Array(int length) native "ExternalTypedData_Int64Array_new";
// Method(s) implementing the List interface.
int operator[](int index) {
@ -2208,10 +2176,6 @@ class _ExternalInt64Array extends _TypedList with _IntListMixin implements Int64
class _ExternalUint64Array extends _TypedList with _IntListMixin implements Uint64List {
// Factory constructors.
factory _ExternalUint64Array(int length) native "ExternalTypedData_Uint64Array_new";
// Method(s) implementing the List interface.
int operator[](int index) {
@ -2253,10 +2217,6 @@ class _ExternalUint64Array extends _TypedList with _IntListMixin implements Uint
class _ExternalFloat32Array extends _TypedList with _DoubleListMixin implements Float32List {
// Factory constructors.
factory _ExternalFloat32Array(int length) native "ExternalTypedData_Float32Array_new";
// Method(s) implementing the List interface.
double operator[](int index) {
@ -2298,10 +2258,6 @@ class _ExternalFloat32Array extends _TypedList with _DoubleListMixin implements
class _ExternalFloat64Array extends _TypedList with _DoubleListMixin implements Float64List {
// Factory constructors.
factory _ExternalFloat64Array(int length) native "ExternalTypedData_Float64Array_new";
// Method(s) implementing the List interface.
double operator[](int index) {
@ -2343,10 +2299,6 @@ class _ExternalFloat64Array extends _TypedList with _DoubleListMixin implements
class _ExternalFloat32x4Array extends _TypedList with _Float32x4ListMixin implements Float32x4List {
// Factory constructors.
factory _ExternalFloat32x4Array(int length) native "ExternalTypedData_Float32x4Array_new";
// Method(s) implementing the List interface.
Float32x4 operator[](int index) {
@ -2388,10 +2340,6 @@ class _ExternalFloat32x4Array extends _TypedList with _Float32x4ListMixin implem
class _ExternalInt32x4Array extends _TypedList with _Int32x4ListMixin implements Int32x4List {
// Factory constructors.
factory _ExternalInt32x4Array(int length) native "ExternalTypedData_Int32x4Array_new";
// Method(s) implementing the List interface.
Int32x4 operator[](int index) {
@ -2433,10 +2381,6 @@ class _ExternalInt32x4Array extends _TypedList with _Int32x4ListMixin implements
class _ExternalFloat64x2Array extends _TypedList with _Float64x2ListMixin implements Float64x2List {
// Factory constructors.
factory _ExternalFloat64x2Array(int length) native "ExternalTypedData_Float64x2Array_new";
// Method(s) implementing the List interface.
Float64x2 operator[](int index) {

View file

@ -182,20 +182,6 @@ namespace dart {
V(TypedData_Float32x4Array_new, 2) \
V(TypedData_Int32x4Array_new, 2) \
V(TypedData_Float64x2Array_new, 2) \
V(ExternalTypedData_Int8Array_new, 2) \
V(ExternalTypedData_Uint8Array_new, 2) \
V(ExternalTypedData_Uint8ClampedArray_new, 2) \
V(ExternalTypedData_Int16Array_new, 2) \
V(ExternalTypedData_Uint16Array_new, 2) \
V(ExternalTypedData_Int32Array_new, 2) \
V(ExternalTypedData_Uint32Array_new, 2) \
V(ExternalTypedData_Int64Array_new, 2) \
V(ExternalTypedData_Uint64Array_new, 2) \
V(ExternalTypedData_Float32Array_new, 2) \
V(ExternalTypedData_Float64Array_new, 2) \
V(ExternalTypedData_Float32x4Array_new, 2) \
V(ExternalTypedData_Int32x4Array_new, 2) \
V(ExternalTypedData_Float64x2Array_new, 2) \
V(TypedData_length, 1) \
V(TypedData_setRange, 7) \
V(TypedData_GetInt8, 2) \

View file

@ -64,23 +64,6 @@ class OS {
// NOTE: This function will return -1 on OSs that are not supported.
static int64_t GetCurrentThreadCPUMicros();
// Returns a cleared aligned array of type T with n entries.
// Alignment must be >= 16 and a power of two.
template<typename T>
static T* AllocateAlignedArray(intptr_t n, intptr_t alignment) {
T* result = reinterpret_cast<T*>(OS::AlignedAllocate(n * sizeof(*result),
alignment));
memset(result, 0, n * sizeof(*result));
return result;
}
// Returns an aligned pointer in the C heap with room for size bytes.
// Alignment must be >= 16 and a power of two.
static void* AlignedAllocate(intptr_t size, intptr_t alignment);
// Frees a pointer returned from AlignedAllocate.
static void AlignedFree(void* ptr);
// Returns the activation frame alignment constraint or one if
// the platform doesn't care. Guaranteed to be a power of two.
static intptr_t ActivationFrameAlignment();

View file

@ -181,23 +181,6 @@ int64_t OS::GetCurrentThreadCPUMicros() {
}
void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) {
const int kMinimumAlignment = 16;
ASSERT(Utils::IsPowerOfTwo(alignment));
ASSERT(alignment >= kMinimumAlignment);
void* p = memalign(alignment, size);
if (p == NULL) {
UNREACHABLE();
}
return p;
}
void OS::AlignedFree(void* ptr) {
free(ptr);
}
// TODO(5411554): May need to hoist these architecture dependent code
// into a architecture specific file e.g: os_ia32_linux.cc
intptr_t OS::ActivationFrameAlignment() {

View file

@ -84,23 +84,6 @@ int64_t OS::GetCurrentThreadCPUMicros() {
}
void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) {
const int kMinimumAlignment = 16;
ASSERT(Utils::IsPowerOfTwo(alignment));
ASSERT(alignment >= kMinimumAlignment);
void* p = memalign(alignment, size);
if (p == NULL) {
UNREACHABLE();
}
return p;
}
void OS::AlignedFree(void* ptr) {
free(ptr);
}
// TODO(5411554): May need to hoist these architecture dependent code
// into a architecture specific file e.g: os_ia32_fuchsia.cc
intptr_t OS::ActivationFrameAlignment() {

View file

@ -188,23 +188,6 @@ int64_t OS::GetCurrentThreadCPUMicros() {
}
void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) {
const int kMinimumAlignment = 16;
ASSERT(Utils::IsPowerOfTwo(alignment));
ASSERT(alignment >= kMinimumAlignment);
void* p = memalign(alignment, size);
if (p == NULL) {
UNREACHABLE();
}
return p;
}
void OS::AlignedFree(void* ptr) {
free(ptr);
}
// TODO(5411554): May need to hoist these architecture dependent code
// into a architecture specific file e.g: os_ia32_linux.cc
intptr_t OS::ActivationFrameAlignment() {

View file

@ -166,24 +166,6 @@ int64_t OS::GetCurrentThreadCPUMicros() {
}
void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) {
const int kMinimumAlignment = 16;
ASSERT(Utils::IsPowerOfTwo(alignment));
ASSERT(alignment >= kMinimumAlignment);
// Temporary workaround until xcode is upgraded.
// Mac guarantees malloc returns a 16 byte aligned memory chunk.
// Currently we only allocate with 16-bye alignment.
ASSERT(alignment == 16);
// TODO(johnmccutchan): Remove hack and switch to posix_memalign.
return malloc(size);
}
void OS::AlignedFree(void* ptr) {
free(ptr);
}
intptr_t OS::ActivationFrameAlignment() {
#if TARGET_OS_IOS
#if TARGET_ARCH_ARM

View file

@ -53,28 +53,4 @@ UNIT_TEST_CASE(OsFuncs) {
EXPECT_LE(1, procs);
}
UNIT_TEST_CASE(OSAlignedAllocate) {
// TODO(johnmccutchan): Test other alignments, once we support
// alignments != 16 on Mac.
void* p1 = OS::AlignedAllocate(1023, 16);
void* p2 = OS::AlignedAllocate(1025, 16);
void* p3 = OS::AlignedAllocate(1025, 16);
void* p4 = OS::AlignedAllocate(1, 16);
void* p5 = OS::AlignedAllocate(2, 16);
void* p6 = OS::AlignedAllocate(4, 16);
EXPECT((reinterpret_cast<intptr_t>(p1) & 15) == 0);
EXPECT((reinterpret_cast<intptr_t>(p2) & 15) == 0);
EXPECT((reinterpret_cast<intptr_t>(p3) & 15) == 0);
EXPECT((reinterpret_cast<intptr_t>(p4) & 15) == 0);
EXPECT((reinterpret_cast<intptr_t>(p5) & 15) == 0);
EXPECT((reinterpret_cast<intptr_t>(p6) & 15) == 0);
OS::AlignedFree(p1);
OS::AlignedFree(p2);
OS::AlignedFree(p3);
OS::AlignedFree(p4);
OS::AlignedFree(p5);
OS::AlignedFree(p6);
}
} // namespace dart

View file

@ -190,23 +190,6 @@ int64_t OS::GetCurrentThreadCPUMicros() {
}
void* OS::AlignedAllocate(intptr_t size, intptr_t alignment) {
const int kMinimumAlignment = 16;
ASSERT(Utils::IsPowerOfTwo(alignment));
ASSERT(alignment >= kMinimumAlignment);
void* p = _aligned_malloc(size, alignment);
if (p == NULL) {
UNREACHABLE();
}
return p;
}
void OS::AlignedFree(void* ptr) {
_aligned_free(ptr);
}
intptr_t OS::ActivationFrameAlignment() {
#ifdef _WIN64
// Windows 64-bit ABI requires the stack to be 16-byte aligned.