2 * Copyright (C) 2013 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef JITInlineCacheGenerator_h
27 #define JITInlineCacheGenerator_h
31 #include "CodeOrigin.h"
32 #include "JITOperations.h"
33 #include "JSCJSValue.h"
35 #include "RegisterSet.h"
41 class JITInlineCacheGenerator
{
43 JITInlineCacheGenerator() { }
44 JITInlineCacheGenerator(CodeBlock
*, CodeOrigin
);
47 StructureStubInfo
* stubInfo() const { return m_stubInfo
; }
50 CodeBlock
* m_codeBlock
;
51 StructureStubInfo
* m_stubInfo
;
54 class JITByIdGenerator
: public JITInlineCacheGenerator
{
56 JITByIdGenerator() { }
59 CodeBlock
*, CodeOrigin
, const RegisterSet
&, JSValueRegs base
, JSValueRegs value
,
60 SpillRegistersMode spillMode
);
63 void reportSlowPathCall(MacroAssembler::Label slowPathBegin
, MacroAssembler::Call call
)
65 m_slowPathBegin
= slowPathBegin
;
69 MacroAssembler::Label
slowPathBegin() const { return m_slowPathBegin
; }
70 MacroAssembler::Jump
slowPathJump() const { return m_structureCheck
.m_jump
; }
72 void finalize(LinkBuffer
& fastPathLinkBuffer
, LinkBuffer
& slowPathLinkBuffer
);
73 void finalize(LinkBuffer
&);
76 void generateFastPathChecks(MacroAssembler
&, GPRReg butterfly
);
81 MacroAssembler::DataLabel32 m_structureImm
;
82 MacroAssembler::PatchableJump m_structureCheck
;
83 MacroAssembler::ConvertibleLoadLabel m_propertyStorageLoad
;
84 AssemblerLabel m_loadOrStore
;
86 AssemblerLabel m_tagLoadOrStore
;
88 MacroAssembler::Label m_done
;
89 MacroAssembler::Label m_slowPathBegin
;
90 MacroAssembler::Call m_call
;
93 class JITGetByIdGenerator
: public JITByIdGenerator
{
95 JITGetByIdGenerator() { }
98 CodeBlock
*, CodeOrigin
, const RegisterSet
& usedRegisters
, JSValueRegs base
,
99 JSValueRegs value
, SpillRegistersMode spillMode
);
101 void generateFastPath(MacroAssembler
&);
104 class JITPutByIdGenerator
: public JITByIdGenerator
{
106 JITPutByIdGenerator() { }
109 CodeBlock
*, CodeOrigin
, const RegisterSet
& usedRegisters
, JSValueRegs base
,
110 JSValueRegs
, GPRReg scratch
, SpillRegistersMode spillMode
, ECMAMode
, PutKind
);
112 void generateFastPath(MacroAssembler
&);
114 V_JITOperation_ESsiJJI
slowPathFunction();
124 #endif // ENABLE(JIT)
126 #endif // JITInlineCacheGenerator_h