Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (265044 => 265045)
--- trunk/Source/_javascript_Core/ChangeLog 2020-07-29 16:36:40 UTC (rev 265044)
+++ trunk/Source/_javascript_Core/ChangeLog 2020-07-29 16:54:11 UTC (rev 265045)
@@ -1,3 +1,17 @@
+2020-07-29 Mark Lam <[email protected]>
+
+ Update some JSArrayBufferView comments and add some assertions.
+ https://bugs.webkit.org/show_bug.cgi?id=214914
+
+ Reviewed by Darin Adler.
+
+ * runtime/ArrayBuffer.cpp:
+ (JSC::ArrayBuffer::createAdopted):
+ * runtime/JSArrayBufferView.cpp:
+ (JSC::JSArrayBufferView::ConstructionContext::ConstructionContext):
+ (JSC::JSArrayBufferView::finalize):
+ * runtime/JSArrayBufferView.h:
+
2020-07-29 Paulo Matos <[email protected]>
for..of intrinsics implementation for 32bits
Modified: trunk/Source/_javascript_Core/runtime/ArrayBuffer.cpp (265044 => 265045)
--- trunk/Source/_javascript_Core/runtime/ArrayBuffer.cpp 2020-07-29 16:36:40 UTC (rev 265044)
+++ trunk/Source/_javascript_Core/runtime/ArrayBuffer.cpp 2020-07-29 16:54:11 UTC (rev 265045)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2009-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -210,6 +210,7 @@
// from the cage.
Ref<ArrayBuffer> ArrayBuffer::createAdopted(const void* data, unsigned byteLength)
{
+ ASSERT(!Gigacage::isEnabled() || (Gigacage::contains(data) && Gigacage::contains(static_cast<const uint8_t*>(data) + byteLength - 1)));
return createFromBytes(data, byteLength, ArrayBuffer::primitiveGigacageDestructor());
}
Modified: trunk/Source/_javascript_Core/runtime/JSArrayBufferView.cpp (265044 => 265045)
--- trunk/Source/_javascript_Core/runtime/JSArrayBufferView.cpp 2020-07-29 16:36:40 UTC (rev 265044)
+++ trunk/Source/_javascript_Core/runtime/JSArrayBufferView.cpp 2020-07-29 16:54:11 UTC (rev 265045)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -48,6 +48,7 @@
, m_mode(FastTypedArray)
, m_butterfly(nullptr)
{
+ ASSERT(!Gigacage::isEnabled() || (Gigacage::contains(vector) && Gigacage::contains(static_cast<const uint8_t*>(vector) + length - 1)));
ASSERT(vector == removeArrayPtrTag(vector));
RELEASE_ASSERT(length <= fastSizeLimit);
}
@@ -190,6 +191,10 @@
void JSArrayBufferView::finalize(JSCell* cell)
{
JSArrayBufferView* thisObject = static_cast<JSArrayBufferView*>(cell);
+
+ // This JSArrayBufferView could be an OversizeTypedArray that was converted
+ // to a WastefulTypedArray via slowDownAndWasteMemory(). Hence, it is possible
+ // to get to this finalizer and found the mode to be WastefulTypedArray.
ASSERT(thisObject->m_mode == OversizeTypedArray || thisObject->m_mode == WastefulTypedArray);
if (thisObject->m_mode == OversizeTypedArray)
Gigacage::free(Gigacage::Primitive, thisObject->vector());
Modified: trunk/Source/_javascript_Core/runtime/JSArrayBufferView.h (265044 => 265045)
--- trunk/Source/_javascript_Core/runtime/JSArrayBufferView.h 2020-07-29 16:36:40 UTC (rev 265044)
+++ trunk/Source/_javascript_Core/runtime/JSArrayBufferView.h 2020-07-29 16:54:11 UTC (rev 265045)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -55,18 +55,23 @@
// whether the user has done anything that requires a separate backing
// buffer or the DOM-specified neutering capabilities.
enum TypedArrayMode : uint32_t {
+ // Legend:
+ // B: JSArrayBufferView::m_butterfly pointer
+ // V: JSArrayBufferView::m_vector pointer
+ // M: JSArrayBufferView::m_mode
+
// Small and fast typed array. B is unused, V points to a vector
- // allocated in copied space, and M = FastTypedArray. V's liveness is
- // determined entirely by the view's liveness.
+ // allocated in the primitive Gigacage, and M = FastTypedArray. V's
+ // liveness is determined entirely by the view's liveness.
FastTypedArray,
-
+
// A large typed array that still attempts not to waste too much
- // memory. B is initialized to point to a slot that could hold a
- // buffer pointer, V points to a vector allocated using fastCalloc(),
- // and M = OversizeTypedArray. V's liveness is determined entirely by
- // the view's liveness, and the view will add a finalizer to delete V.
+ // memory. B is unused, V points to a vector allocated using
+ // Gigacage::tryMalloc(), and M = OversizeTypedArray. V's liveness is
+ // determined entirely by the view's liveness, and the view will add a
+ // finalizer to delete V.
OversizeTypedArray,
-
+
// A typed array that was used in some crazy way. B's IndexingHeader
// is hijacked to contain a reference to the native array buffer. The
// native typed array view points back to the JS view. V points to a
@@ -73,7 +78,7 @@
// vector allocated using who-knows-what, and M = WastefulTypedArray.
// The view does not own the vector.
WastefulTypedArray,
-
+
// A data view. B is unused, V points to a vector allocated using who-
// knows-what, and M = DataViewMode. The view does not own the vector.
// There is an extra field (in JSDataView) that points to the