The data contained in this repository can be downloaded to your computer using one of several clients.
Please see the documentation of your version control software client for more information.
Please select the desired protocol below to get the URL.
This URL has Read-Only access.
main_repo / deps / v8 / src / x64 / codegen-x64.h @ f230a1cf
History | View | Annotate | Download (6 KB)
1 |
// Copyright 2011 the V8 project authors. All rights reserved.
|
---|---|
2 |
// Redistribution and use in source and binary forms, with or without
|
3 |
// modification, are permitted provided that the following conditions are
|
4 |
// met:
|
5 |
//
|
6 |
// * Redistributions of source code must retain the above copyright
|
7 |
// notice, this list of conditions and the following disclaimer.
|
8 |
// * Redistributions in binary form must reproduce the above
|
9 |
// copyright notice, this list of conditions and the following
|
10 |
// disclaimer in the documentation and/or other materials provided
|
11 |
// with the distribution.
|
12 |
// * Neither the name of Google Inc. nor the names of its
|
13 |
// contributors may be used to endorse or promote products derived
|
14 |
// from this software without specific prior written permission.
|
15 |
//
|
16 |
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17 |
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18 |
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19 |
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
20 |
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 |
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 |
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
23 |
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
24 |
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
25 |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
26 |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27 |
|
28 |
#ifndef V8_X64_CODEGEN_X64_H_
|
29 |
#define V8_X64_CODEGEN_X64_H_
|
30 |
|
31 |
#include "ast.h" |
32 |
#include "ic-inl.h" |
33 |
|
34 |
namespace v8 { |
35 |
namespace internal { |
36 |
|
37 |
// Forward declarations
|
38 |
class CompilationInfo; |
39 |
|
40 |
enum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF };
|
41 |
|
42 |
// -------------------------------------------------------------------------
|
43 |
// CodeGenerator
|
44 |
|
45 |
class CodeGenerator: public AstVisitor { |
46 |
public:
|
47 |
explicit CodeGenerator(Isolate* isolate) { |
48 |
InitializeAstVisitor(isolate); |
49 |
} |
50 |
|
51 |
static bool MakeCode(CompilationInfo* info); |
52 |
|
53 |
// Printing of AST, etc. as requested by flags.
|
54 |
static void MakeCodePrologue(CompilationInfo* info, const char* kind); |
55 |
|
56 |
// Allocate and install the code.
|
57 |
static Handle<Code> MakeCodeEpilogue(MacroAssembler* masm,
|
58 |
Code::Flags flags, |
59 |
CompilationInfo* info); |
60 |
|
61 |
// Print the code after compiling it.
|
62 |
static void PrintCode(Handle<Code> code, CompilationInfo* info); |
63 |
|
64 |
static bool ShouldGenerateLog(Isolate* isolate, Expression* type); |
65 |
|
66 |
static bool RecordPositions(MacroAssembler* masm, |
67 |
int pos,
|
68 |
bool right_here = false); |
69 |
|
70 |
DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
71 |
|
72 |
private:
|
73 |
DISALLOW_COPY_AND_ASSIGN(CodeGenerator); |
74 |
}; |
75 |
|
76 |
|
77 |
class StringCharLoadGenerator : public AllStatic { |
78 |
public:
|
79 |
// Generates the code for handling different string types and loading the
|
80 |
// indexed character into |result|. We expect |index| as untagged input and
|
81 |
// |result| as untagged output.
|
82 |
static void Generate(MacroAssembler* masm, |
83 |
Register string, |
84 |
Register index, |
85 |
Register result, |
86 |
Label* call_runtime); |
87 |
|
88 |
private:
|
89 |
DISALLOW_COPY_AND_ASSIGN(StringCharLoadGenerator); |
90 |
}; |
91 |
|
92 |
|
93 |
class MathExpGenerator : public AllStatic { |
94 |
public:
|
95 |
static void EmitMathExp(MacroAssembler* masm, |
96 |
XMMRegister input, |
97 |
XMMRegister result, |
98 |
XMMRegister double_scratch, |
99 |
Register temp1, |
100 |
Register temp2); |
101 |
|
102 |
private:
|
103 |
DISALLOW_COPY_AND_ASSIGN(MathExpGenerator); |
104 |
}; |
105 |
|
106 |
|
107 |
enum StackArgumentsAccessorReceiverMode {
|
108 |
ARGUMENTS_CONTAIN_RECEIVER, |
109 |
ARGUMENTS_DONT_CONTAIN_RECEIVER |
110 |
}; |
111 |
|
112 |
|
113 |
class StackArgumentsAccessor BASE_EMBEDDED { |
114 |
public:
|
115 |
StackArgumentsAccessor( |
116 |
Register base_reg, |
117 |
int argument_count_immediate,
|
118 |
StackArgumentsAccessorReceiverMode receiver_mode = |
119 |
ARGUMENTS_CONTAIN_RECEIVER, |
120 |
int extra_displacement_to_last_argument = 0) |
121 |
: base_reg_(base_reg), |
122 |
argument_count_reg_(no_reg), |
123 |
argument_count_immediate_(argument_count_immediate), |
124 |
receiver_mode_(receiver_mode), |
125 |
extra_displacement_to_last_argument_( |
126 |
extra_displacement_to_last_argument) { } |
127 |
|
128 |
StackArgumentsAccessor( |
129 |
Register base_reg, |
130 |
Register argument_count_reg, |
131 |
StackArgumentsAccessorReceiverMode receiver_mode = |
132 |
ARGUMENTS_CONTAIN_RECEIVER, |
133 |
int extra_displacement_to_last_argument = 0) |
134 |
: base_reg_(base_reg), |
135 |
argument_count_reg_(argument_count_reg), |
136 |
argument_count_immediate_(0),
|
137 |
receiver_mode_(receiver_mode), |
138 |
extra_displacement_to_last_argument_( |
139 |
extra_displacement_to_last_argument) { } |
140 |
|
141 |
StackArgumentsAccessor( |
142 |
Register base_reg, |
143 |
const ParameterCount& parameter_count,
|
144 |
StackArgumentsAccessorReceiverMode receiver_mode = |
145 |
ARGUMENTS_CONTAIN_RECEIVER, |
146 |
int extra_displacement_to_last_argument = 0) |
147 |
: base_reg_(base_reg), |
148 |
argument_count_reg_(parameter_count.is_reg() ? |
149 |
parameter_count.reg() : no_reg), |
150 |
argument_count_immediate_(parameter_count.is_immediate() ? |
151 |
parameter_count.immediate() : 0),
|
152 |
receiver_mode_(receiver_mode), |
153 |
extra_displacement_to_last_argument_( |
154 |
extra_displacement_to_last_argument) { } |
155 |
|
156 |
Operand GetArgumentOperand(int index);
|
157 |
Operand GetReceiverOperand() { |
158 |
ASSERT(receiver_mode_ == ARGUMENTS_CONTAIN_RECEIVER); |
159 |
return GetArgumentOperand(0); |
160 |
} |
161 |
|
162 |
private:
|
163 |
const Register base_reg_;
|
164 |
const Register argument_count_reg_;
|
165 |
const int argument_count_immediate_; |
166 |
const StackArgumentsAccessorReceiverMode receiver_mode_;
|
167 |
const int extra_displacement_to_last_argument_; |
168 |
|
169 |
DISALLOW_IMPLICIT_CONSTRUCTORS(StackArgumentsAccessor); |
170 |
}; |
171 |
|
172 |
|
173 |
} } // namespace v8::internal
|
174 |
|
175 |
#endif // V8_X64_CODEGEN_X64_H_ |