mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-14 22:13:31 +00:00
Bug 609896 - Optimize copy and initialization of DenseElements; r=billm
--HG-- extra : rebase_source : a0cf2605a7f1277352ff9163379632992c56d09a
This commit is contained in:
parent
808f6c29de
commit
50dcb5f560
@ -8,7 +8,7 @@
|
||||
#define js_GCAPI_h
|
||||
|
||||
#include "mozilla/NullPtr.h"
|
||||
|
||||
|
||||
#include "js/HeapAPI.h"
|
||||
#include "js/RootingAPI.h"
|
||||
#include "js/Value.h"
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
|
||||
#include "gc/Marking.h"
|
||||
#include "js/GCAPI.h"
|
||||
#include "vm/ObjectImpl.h"
|
||||
#include "vm/Shape.h"
|
||||
|
||||
@ -638,16 +639,21 @@ class JSObject : public js::ObjectImpl
|
||||
|
||||
void copyDenseElements(uint32_t dstStart, const js::Value *src, uint32_t count) {
|
||||
JS_ASSERT(dstStart + count <= getDenseCapacity());
|
||||
JS::Zone *zone = this->zone();
|
||||
for (uint32_t i = 0; i < count; ++i)
|
||||
elements[dstStart + i].set(zone, this, js::HeapSlot::Element, dstStart + i, src[i]);
|
||||
JSRuntime *rt = runtimeFromMainThread();
|
||||
if (JS::IsIncrementalBarrierNeeded(rt)) {
|
||||
JS::Zone *zone = this->zone();
|
||||
for (uint32_t i = 0; i < count; ++i)
|
||||
elements[dstStart + i].set(zone, this, js::HeapSlot::Element, dstStart + i, src[i]);
|
||||
} else {
|
||||
memcpy(&elements[dstStart], src, count * sizeof(js::HeapSlot));
|
||||
DenseRangeWriteBarrierPost(rt, this, dstStart, count);
|
||||
}
|
||||
}
|
||||
|
||||
void initDenseElements(uint32_t dstStart, const js::Value *src, uint32_t count) {
|
||||
JS_ASSERT(dstStart + count <= getDenseCapacity());
|
||||
JSRuntime *rt = runtimeFromMainThread();
|
||||
for (uint32_t i = 0; i < count; ++i)
|
||||
elements[dstStart + i].init(rt, this, js::HeapSlot::Element, dstStart + i, src[i]);
|
||||
memcpy(&elements[dstStart], src, count * sizeof(js::HeapSlot));
|
||||
DenseRangeWriteBarrierPost(runtimeFromMainThread(), this, dstStart, count);
|
||||
}
|
||||
|
||||
void moveDenseElements(uint32_t dstStart, uint32_t srcStart, uint32_t count) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user