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/bytecode/ObjectAllocationProfile.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/JavaScriptCore/bytecode/ObjectAllocationProfile.h')
-rw-r--r-- | Source/JavaScriptCore/bytecode/ObjectAllocationProfile.h | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/Source/JavaScriptCore/bytecode/ObjectAllocationProfile.h b/Source/JavaScriptCore/bytecode/ObjectAllocationProfile.h index 9a9db0bc7..301a3580c 100644 --- a/Source/JavaScriptCore/bytecode/ObjectAllocationProfile.h +++ b/Source/JavaScriptCore/bytecode/ObjectAllocationProfile.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2013-2017 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,8 +23,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef ObjectAllocationProfile_h -#define ObjectAllocationProfile_h +#pragma once #include "VM.h" #include "JSGlobalObject.h" @@ -39,18 +38,21 @@ class ObjectAllocationProfile { public: static ptrdiff_t offsetOfAllocator() { return OBJECT_OFFSETOF(ObjectAllocationProfile, m_allocator); } static ptrdiff_t offsetOfStructure() { return OBJECT_OFFSETOF(ObjectAllocationProfile, m_structure); } + static ptrdiff_t offsetOfInlineCapacity() { return OBJECT_OFFSETOF(ObjectAllocationProfile, m_inlineCapacity); } ObjectAllocationProfile() : m_allocator(0) + , m_inlineCapacity(0) { } - bool isNull() { return !m_allocator; } + bool isNull() { return !m_structure; } - void initialize(VM& vm, JSCell* owner, JSObject* prototype, unsigned inferredInlineCapacity) + void initialize(VM& vm, JSGlobalObject* globalObject, JSCell* owner, JSObject* prototype, unsigned inferredInlineCapacity) { ASSERT(!m_allocator); ASSERT(!m_structure); + ASSERT(!m_inlineCapacity); unsigned inlineCapacity = 0; if (inferredInlineCapacity < JSFinalObject::defaultInlineCapacity()) { @@ -80,33 +82,46 @@ public: ASSERT(inlineCapacity <= JSFinalObject::maxInlineCapacity()); size_t allocationSize = JSFinalObject::allocationSize(inlineCapacity); - MarkedAllocator* allocator = &vm.heap.allocatorForObjectWithoutDestructor(allocationSize); - ASSERT(allocator->cellSize()); - + MarkedAllocator* allocator = vm.cellSpace.allocatorFor(allocationSize); + // Take advantage of extra inline capacity available in the size class. - size_t slop = (allocator->cellSize() - allocationSize) / sizeof(WriteBarrier<Unknown>); - inlineCapacity += slop; - if (inlineCapacity > JSFinalObject::maxInlineCapacity()) - inlineCapacity = JSFinalObject::maxInlineCapacity(); + if (allocator) { + size_t slop = (allocator->cellSize() - allocationSize) / sizeof(WriteBarrier<Unknown>); + inlineCapacity += slop; + if (inlineCapacity > JSFinalObject::maxInlineCapacity()) + inlineCapacity = JSFinalObject::maxInlineCapacity(); + } + + Structure* structure = vm.prototypeMap.emptyObjectStructureForPrototype(globalObject, prototype, inlineCapacity); + + // Ensure that if another thread sees the structure, it will see it properly created + WTF::storeStoreFence(); m_allocator = allocator; - m_structure.set(vm, owner, - vm.prototypeMap.emptyObjectStructureForPrototype(prototype, inlineCapacity)); + m_structure.set(vm, owner, structure); + m_inlineCapacity = inlineCapacity; } - Structure* structure() { return m_structure.get(); } - unsigned inlineCapacity() { return m_structure->inlineCapacity(); } + Structure* structure() + { + Structure* structure = m_structure.get(); + // Ensure that if we see the structure, it has been properly created + WTF::loadLoadFence(); + return structure; + } + unsigned inlineCapacity() { return m_inlineCapacity; } void clear() { m_allocator = 0; m_structure.clear(); + m_inlineCapacity = 0; ASSERT(isNull()); } void visitAggregate(SlotVisitor& visitor) { - visitor.append(&m_structure); + visitor.append(m_structure); } private: @@ -117,14 +132,14 @@ private: return 0; size_t count = 0; - PropertyNameArray propertyNameArray(&vm); - prototype->structure()->getPropertyNamesFromStructure(vm, propertyNameArray, ExcludeDontEnumProperties); + PropertyNameArray propertyNameArray(&vm, PropertyNameMode::StringsAndSymbols); + prototype->structure()->getPropertyNamesFromStructure(vm, propertyNameArray, EnumerationMode()); PropertyNameArrayData::PropertyNameVector& propertyNameVector = propertyNameArray.data()->propertyNameVector(); for (size_t i = 0; i < propertyNameVector.size(); ++i) { JSValue value = prototype->getDirect(vm, propertyNameVector[i]); // Functions are common, and are usually class-level objects that are not overridden. - if (jsDynamicCast<JSFunction*>(value)) + if (jsDynamicCast<JSFunction*>(vm, value)) continue; ++count; @@ -135,8 +150,7 @@ private: MarkedAllocator* m_allocator; // Precomputed to make things easier for generated code. WriteBarrier<Structure> m_structure; + unsigned m_inlineCapacity; }; } // namespace JSC - -#endif // ObjectAllocationProfile_h |