Skip to content
Permalink
Browse files
Refactor SpeculativeJIT::emitAllocateJSFinalObject
https://bugs.webkit.org/show_bug.cgi?id=79801

Reviewed by Filip Pizlo.

* dfg/DFGSpeculativeJIT.h:
(JSC::DFG::SpeculativeJIT::emitAllocateBasicJSObject): Split emitAllocateJSFinalObject out to form this
function, which is more generic in that it can allocate a variety of classes.
(SpeculativeJIT):
(JSC::DFG::SpeculativeJIT::emitAllocateJSFinalObject): Changed to use the new helper function.


Canonical link: https://commits.webkit.org/96951@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@109194 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Mark Hahnenberg committed Feb 29, 2012
1 parent 7e022fe commit d72d47141e91f94cd1f55acab346c805feb8986d
Showing with 31 additions and 8 deletions.
  1. +13 −0 Source/JavaScriptCore/ChangeLog
  2. +18 −8 Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h
@@ -1,3 +1,16 @@
2012-02-28 Mark Hahnenberg <mhahnenberg@apple.com>

Refactor SpeculativeJIT::emitAllocateJSFinalObject
https://bugs.webkit.org/show_bug.cgi?id=79801

Reviewed by Filip Pizlo.

* dfg/DFGSpeculativeJIT.h:
(JSC::DFG::SpeculativeJIT::emitAllocateBasicJSObject): Split emitAllocateJSFinalObject out to form this
function, which is more generic in that it can allocate a variety of classes.
(SpeculativeJIT):
(JSC::DFG::SpeculativeJIT::emitAllocateJSFinalObject): Changed to use the new helper function.

2012-02-28 Gavin Barraclough <barraclough@apple.com>

[[Get]]/[[Put]] for primitives should not wrap on strict accessor call
@@ -1737,13 +1737,15 @@ class SpeculativeJIT {
void compileNewFunctionNoCheck(Node& node);
void compileNewFunctionExpression(Node& node);

// It is acceptable to have structure be equal to scratch, so long as you're fine
// with the structure GPR being clobbered.
template<typename T>
void emitAllocateJSFinalObject(T structure, GPRReg resultGPR, GPRReg scratchGPR, MacroAssembler::JumpList& slowPath)
template <typename ClassType, bool destructor, typename StructureType>
void emitAllocateBasicJSObject(StructureType structure, GPRReg resultGPR, GPRReg scratchGPR, MacroAssembler::JumpList& slowPath)
{
MarkedAllocator* allocator = &m_jit.globalData()->heap.allocatorForObjectWithoutDestructor(sizeof(JSFinalObject));

MarkedAllocator* allocator = 0;
if (destructor)
allocator = &m_jit.globalData()->heap.allocatorForObjectWithDestructor(sizeof(ClassType));
else
allocator = &m_jit.globalData()->heap.allocatorForObjectWithoutDestructor(sizeof(ClassType));

m_jit.loadPtr(&allocator->m_firstFreeCell, resultGPR);
slowPath.append(m_jit.branchTestPtr(MacroAssembler::Zero, resultGPR));

@@ -1759,14 +1761,22 @@ class SpeculativeJIT {
m_jit.storePtr(scratchGPR, &allocator->m_firstFreeCell);

// Initialize the object's classInfo pointer
m_jit.storePtr(MacroAssembler::TrustedImmPtr(&JSFinalObject::s_info), MacroAssembler::Address(resultGPR, JSCell::classInfoOffset()));
m_jit.storePtr(MacroAssembler::TrustedImmPtr(&ClassType::s_info), MacroAssembler::Address(resultGPR, JSCell::classInfoOffset()));

// Initialize the object's inheritorID.
m_jit.storePtr(MacroAssembler::TrustedImmPtr(0), MacroAssembler::Address(resultGPR, JSObject::offsetOfInheritorID()));

// Initialize the object's property storage pointer.
m_jit.addPtr(MacroAssembler::TrustedImm32(sizeof(JSObject)), resultGPR, scratchGPR);
m_jit.storePtr(scratchGPR, MacroAssembler::Address(resultGPR, JSFinalObject::offsetOfPropertyStorage()));
m_jit.storePtr(scratchGPR, MacroAssembler::Address(resultGPR, ClassType::offsetOfPropertyStorage()));
}

// It is acceptable to have structure be equal to scratch, so long as you're fine
// with the structure GPR being clobbered.
template<typename T>
void emitAllocateJSFinalObject(T structure, GPRReg resultGPR, GPRReg scratchGPR, MacroAssembler::JumpList& slowPath)
{
return emitAllocateBasicJSObject<JSFinalObject, false>(structure, resultGPR, scratchGPR, slowPath);
}

#if USE(JSVALUE64)

0 comments on commit d72d471

Please sign in to comment.