]> git.saurik.com Git - apple/javascriptcore.git/blame - jit/JITInlineCacheGenerator.h
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / jit / JITInlineCacheGenerator.h
CommitLineData
81345200
A
1/*
2 * Copyright (C) 2013 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
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.
12 *
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.
24 */
25
26#ifndef JITInlineCacheGenerator_h
27#define JITInlineCacheGenerator_h
28
29#if ENABLE(JIT)
30
31#include "CodeOrigin.h"
32#include "JITOperations.h"
33#include "JSCJSValue.h"
34#include "PutKind.h"
35#include "RegisterSet.h"
36
37namespace JSC {
38
39class CodeBlock;
40
41class JITInlineCacheGenerator {
42protected:
43 JITInlineCacheGenerator() { }
44 JITInlineCacheGenerator(CodeBlock*, CodeOrigin);
45
46public:
47 StructureStubInfo* stubInfo() const { return m_stubInfo; }
48
49protected:
50 CodeBlock* m_codeBlock;
51 StructureStubInfo* m_stubInfo;
52};
53
54class JITByIdGenerator : public JITInlineCacheGenerator {
55protected:
56 JITByIdGenerator() { }
57
58 JITByIdGenerator(
59 CodeBlock*, CodeOrigin, const RegisterSet&, JSValueRegs base, JSValueRegs value,
60 SpillRegistersMode spillMode);
61
62public:
63 void reportSlowPathCall(MacroAssembler::Label slowPathBegin, MacroAssembler::Call call)
64 {
65 m_slowPathBegin = slowPathBegin;
66 m_call = call;
67 }
68
69 MacroAssembler::Label slowPathBegin() const { return m_slowPathBegin; }
70 MacroAssembler::Jump slowPathJump() const { return m_structureCheck.m_jump; }
71
72 void finalize(LinkBuffer& fastPathLinkBuffer, LinkBuffer& slowPathLinkBuffer);
73 void finalize(LinkBuffer&);
74
75protected:
76 void generateFastPathChecks(MacroAssembler&, GPRReg butterfly);
77
78 JSValueRegs m_base;
79 JSValueRegs m_value;
80
81 MacroAssembler::DataLabel32 m_structureImm;
82 MacroAssembler::PatchableJump m_structureCheck;
83 MacroAssembler::ConvertibleLoadLabel m_propertyStorageLoad;
84 AssemblerLabel m_loadOrStore;
85#if USE(JSVALUE32_64)
86 AssemblerLabel m_tagLoadOrStore;
87#endif
88 MacroAssembler::Label m_done;
89 MacroAssembler::Label m_slowPathBegin;
90 MacroAssembler::Call m_call;
91};
92
93class JITGetByIdGenerator : public JITByIdGenerator {
94public:
95 JITGetByIdGenerator() { }
96
97 JITGetByIdGenerator(
98 CodeBlock*, CodeOrigin, const RegisterSet& usedRegisters, JSValueRegs base,
99 JSValueRegs value, SpillRegistersMode spillMode);
100
101 void generateFastPath(MacroAssembler&);
102};
103
104class JITPutByIdGenerator : public JITByIdGenerator {
105public:
106 JITPutByIdGenerator() { }
107
108 JITPutByIdGenerator(
109 CodeBlock*, CodeOrigin, const RegisterSet& usedRegisters, JSValueRegs base,
110 JSValueRegs, GPRReg scratch, SpillRegistersMode spillMode, ECMAMode, PutKind);
111
112 void generateFastPath(MacroAssembler&);
113
114 V_JITOperation_ESsiJJI slowPathFunction();
115
116private:
117 GPRReg m_scratch;
118 ECMAMode m_ecmaMode;
119 PutKind m_putKind;
120};
121
122} // namespace JSC
123
124#endif // ENABLE(JIT)
125
126#endif // JITInlineCacheGenerator_h
127