Commit 2d655a2f authored by andersca@apple.com's avatar andersca@apple.com

VectorMover should use std::move

https://bugs.webkit.org/show_bug.cgi?id=120959

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

Work around a bug in GCC by changing the type of the callType bitfield
in CallLinkInfo to be unsigned instead of CallType.

* bytecode/CallLinkInfo.h:

Source/WTF:

This lets the compiler use move constructors when moving data, which can be a performance improvement.
If the vector element type isn't movable it will be copied instead.

* wtf/Vector.h:
(WTF::VectorTypeOperations::move):
(WTF::VectorTypeOperations::moveOverlapping):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155258 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a1e36412
2013-09-07 Anders Carlsson <andersca@apple.com>
VectorMover should use std::move
https://bugs.webkit.org/show_bug.cgi?id=120959
Reviewed by Geoffrey Garen.
Work around a bug in GCC by changing the type of the callType bitfield
in CallLinkInfo to be unsigned instead of CallType.
* bytecode/CallLinkInfo.h:
2013-09-07 Anders Carlsson <andersca@apple.com> 2013-09-07 Anders Carlsson <andersca@apple.com>
Get rid of FastAllocBase.h Get rid of FastAllocBase.h
......
...@@ -82,7 +82,7 @@ struct CallLinkInfo : public BasicRawSentinelNode<CallLinkInfo> { ...@@ -82,7 +82,7 @@ struct CallLinkInfo : public BasicRawSentinelNode<CallLinkInfo> {
bool hasSeenShouldRepatch : 1; bool hasSeenShouldRepatch : 1;
bool isDFG : 1; bool isDFG : 1;
bool hasSeenClosure : 1; bool hasSeenClosure : 1;
CallType callType : 5; unsigned callType : 5; // CallType
unsigned calleeGPR : 8; unsigned calleeGPR : 8;
CodeOrigin codeOrigin; CodeOrigin codeOrigin;
......
2013-09-07 Anders Carlsson <andersca@apple.com>
VectorMover should use std::move
https://bugs.webkit.org/show_bug.cgi?id=120959
Reviewed by Geoffrey Garen.
This lets the compiler use move constructors when moving data, which can be a performance improvement.
If the vector element type isn't movable it will be copied instead.
* wtf/Vector.h:
(WTF::VectorTypeOperations::move):
(WTF::VectorTypeOperations::moveOverlapping):
2013-09-07 Anders Carlsson <andersca@apple.com> 2013-09-07 Anders Carlsson <andersca@apple.com>
Get rid of FastAllocBase.h Get rid of FastAllocBase.h
......
...@@ -90,20 +90,16 @@ struct VectorMover; ...@@ -90,20 +90,16 @@ struct VectorMover;
template<typename T> template<typename T>
struct VectorMover<false, T> struct VectorMover<false, T>
{ {
static void move(const T* src, const T* srcEnd, T* dst) static void move(T* src, T* srcEnd, T* dst)
{ {
while (src != srcEnd) { while (src != srcEnd) {
new (NotNull, dst) T(*src); new (NotNull, dst) T(std::move(*src));
#if COMPILER(SUNCC) && __SUNPRO_CC <= 0x590
const_cast<T*>(src)->~T(); // Work around obscure SunCC 12 compiler bug.
#else
src->~T(); src->~T();
#endif
++dst; ++dst;
++src; ++src;
} }
} }
static void moveOverlapping(const T* src, const T* srcEnd, T* dst) static void moveOverlapping(T* src, T* srcEnd, T* dst)
{ {
if (src > dst) if (src > dst)
move(src, srcEnd, dst); move(src, srcEnd, dst);
...@@ -112,7 +108,7 @@ struct VectorMover<false, T> ...@@ -112,7 +108,7 @@ struct VectorMover<false, T>
while (src != srcEnd) { while (src != srcEnd) {
--srcEnd; --srcEnd;
--dstEnd; --dstEnd;
new (NotNull, dstEnd) T(*srcEnd); new (NotNull, dstEnd) T(std::move(*srcEnd));
srcEnd->~T(); srcEnd->~T();
} }
} }
...@@ -222,12 +218,12 @@ struct VectorTypeOperations ...@@ -222,12 +218,12 @@ struct VectorTypeOperations
VectorInitializer<VectorTraits<T>::needsInitialization, VectorTraits<T>::canInitializeWithMemset, T>::initialize(begin, end); VectorInitializer<VectorTraits<T>::needsInitialization, VectorTraits<T>::canInitializeWithMemset, T>::initialize(begin, end);
} }
static void move(const T* src, const T* srcEnd, T* dst) static void move(T* src, T* srcEnd, T* dst)
{ {
VectorMover<VectorTraits<T>::canMoveWithMemcpy, T>::move(src, srcEnd, dst); VectorMover<VectorTraits<T>::canMoveWithMemcpy, T>::move(src, srcEnd, dst);
} }
static void moveOverlapping(const T* src, const T* srcEnd, T* dst) static void moveOverlapping(T* src, T* srcEnd, T* dst)
{ {
VectorMover<VectorTraits<T>::canMoveWithMemcpy, T>::moveOverlapping(src, srcEnd, dst); VectorMover<VectorTraits<T>::canMoveWithMemcpy, T>::moveOverlapping(src, srcEnd, dst);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment