OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 ToBooleanStub() { } | 65 ToBooleanStub() { } |
66 | 66 |
67 void Generate(MacroAssembler* masm); | 67 void Generate(MacroAssembler* masm); |
68 | 68 |
69 private: | 69 private: |
70 Major MajorKey() { return ToBoolean; } | 70 Major MajorKey() { return ToBoolean; } |
71 int MinorKey() { return 0; } | 71 int MinorKey() { return 0; } |
72 }; | 72 }; |
73 | 73 |
74 | 74 |
75 class TypeRecordingUnaryOpStub: public CodeStub { | 75 class UnaryOpStub: public CodeStub { |
76 public: | 76 public: |
77 TypeRecordingUnaryOpStub(Token::Value op, UnaryOverwriteMode mode) | 77 UnaryOpStub(Token::Value op, UnaryOverwriteMode mode) |
78 : op_(op), | 78 : op_(op), |
79 mode_(mode), | 79 mode_(mode), |
80 operand_type_(TRUnaryOpIC::UNINITIALIZED), | 80 operand_type_(UnaryOpIC::UNINITIALIZED), |
81 name_(NULL) { | 81 name_(NULL) { |
82 } | 82 } |
83 | 83 |
84 TypeRecordingUnaryOpStub( | 84 UnaryOpStub(int key, UnaryOpIC::TypeInfo operand_type) |
85 int key, | |
86 TRUnaryOpIC::TypeInfo operand_type) | |
87 : op_(OpBits::decode(key)), | 85 : op_(OpBits::decode(key)), |
88 mode_(ModeBits::decode(key)), | 86 mode_(ModeBits::decode(key)), |
89 operand_type_(operand_type), | 87 operand_type_(operand_type), |
90 name_(NULL) { | 88 name_(NULL) { |
91 } | 89 } |
92 | 90 |
93 private: | 91 private: |
94 Token::Value op_; | 92 Token::Value op_; |
95 UnaryOverwriteMode mode_; | 93 UnaryOverwriteMode mode_; |
96 | 94 |
97 // Operand type information determined at runtime. | 95 // Operand type information determined at runtime. |
98 TRUnaryOpIC::TypeInfo operand_type_; | 96 UnaryOpIC::TypeInfo operand_type_; |
99 | 97 |
100 char* name_; | 98 char* name_; |
101 | 99 |
102 const char* GetName(); | 100 const char* GetName(); |
103 | 101 |
104 #ifdef DEBUG | 102 #ifdef DEBUG |
105 void Print() { | 103 void Print() { |
106 PrintF("TypeRecordingUnaryOpStub %d (op %s), " | 104 PrintF("TypeRecordingUnaryOpStub %d (op %s), " |
107 "(mode %d, runtime_type_info %s)\n", | 105 "(mode %d, runtime_type_info %s)\n", |
108 MinorKey(), | 106 MinorKey(), |
109 Token::String(op_), | 107 Token::String(op_), |
110 static_cast<int>(mode_), | 108 static_cast<int>(mode_), |
111 TRUnaryOpIC::GetName(operand_type_)); | 109 UnaryOpIC::GetName(operand_type_)); |
112 } | 110 } |
113 #endif | 111 #endif |
114 | 112 |
115 class ModeBits: public BitField<UnaryOverwriteMode, 0, 1> {}; | 113 class ModeBits: public BitField<UnaryOverwriteMode, 0, 1> {}; |
116 class OpBits: public BitField<Token::Value, 1, 7> {}; | 114 class OpBits: public BitField<Token::Value, 1, 7> {}; |
117 class OperandTypeInfoBits: public BitField<TRUnaryOpIC::TypeInfo, 8, 3> {}; | 115 class OperandTypeInfoBits: public BitField<UnaryOpIC::TypeInfo, 8, 3> {}; |
118 | 116 |
119 Major MajorKey() { return TypeRecordingUnaryOp; } | 117 Major MajorKey() { return UnaryOp; } |
120 int MinorKey() { | 118 int MinorKey() { |
121 return ModeBits::encode(mode_) | 119 return ModeBits::encode(mode_) |
122 | OpBits::encode(op_) | 120 | OpBits::encode(op_) |
123 | OperandTypeInfoBits::encode(operand_type_); | 121 | OperandTypeInfoBits::encode(operand_type_); |
124 } | 122 } |
125 | 123 |
126 // Note: A lot of the helper functions below will vanish when we use virtual | 124 // Note: A lot of the helper functions below will vanish when we use virtual |
127 // function instead of switch more often. | 125 // function instead of switch more often. |
128 void Generate(MacroAssembler* masm); | 126 void Generate(MacroAssembler* masm); |
129 | 127 |
(...skipping 18 matching lines...) Expand all Loading... |
148 void GenerateHeapNumberStubSub(MacroAssembler* masm); | 146 void GenerateHeapNumberStubSub(MacroAssembler* masm); |
149 void GenerateHeapNumberStubBitNot(MacroAssembler* masm); | 147 void GenerateHeapNumberStubBitNot(MacroAssembler* masm); |
150 void GenerateHeapNumberCodeSub(MacroAssembler* masm, Label* slow); | 148 void GenerateHeapNumberCodeSub(MacroAssembler* masm, Label* slow); |
151 void GenerateHeapNumberCodeBitNot(MacroAssembler* masm, Label* slow); | 149 void GenerateHeapNumberCodeBitNot(MacroAssembler* masm, Label* slow); |
152 | 150 |
153 void GenerateGenericStub(MacroAssembler* masm); | 151 void GenerateGenericStub(MacroAssembler* masm); |
154 void GenerateGenericStubSub(MacroAssembler* masm); | 152 void GenerateGenericStubSub(MacroAssembler* masm); |
155 void GenerateGenericStubBitNot(MacroAssembler* masm); | 153 void GenerateGenericStubBitNot(MacroAssembler* masm); |
156 void GenerateGenericCodeFallback(MacroAssembler* masm); | 154 void GenerateGenericCodeFallback(MacroAssembler* masm); |
157 | 155 |
158 virtual int GetCodeKind() { return Code::TYPE_RECORDING_UNARY_OP_IC; } | 156 virtual int GetCodeKind() { return Code::UNARY_OP_IC; } |
159 | 157 |
160 virtual InlineCacheState GetICState() { | 158 virtual InlineCacheState GetICState() { |
161 return TRUnaryOpIC::ToState(operand_type_); | 159 return UnaryOpIC::ToState(operand_type_); |
162 } | 160 } |
163 | 161 |
164 virtual void FinishCode(Code* code) { | 162 virtual void FinishCode(Code* code) { |
165 code->set_type_recording_unary_op_type(operand_type_); | 163 code->set_unary_op_type(operand_type_); |
166 } | 164 } |
167 }; | 165 }; |
168 | 166 |
169 | 167 |
170 class TypeRecordingBinaryOpStub: public CodeStub { | 168 class BinaryOpStub: public CodeStub { |
171 public: | 169 public: |
172 TypeRecordingBinaryOpStub(Token::Value op, OverwriteMode mode) | 170 BinaryOpStub(Token::Value op, OverwriteMode mode) |
173 : op_(op), | 171 : op_(op), |
174 mode_(mode), | 172 mode_(mode), |
175 operands_type_(TRBinaryOpIC::UNINITIALIZED), | 173 operands_type_(BinaryOpIC::UNINITIALIZED), |
176 result_type_(TRBinaryOpIC::UNINITIALIZED), | 174 result_type_(BinaryOpIC::UNINITIALIZED), |
177 name_(NULL) { | 175 name_(NULL) { |
178 use_sse3_ = CpuFeatures::IsSupported(SSE3); | 176 use_sse3_ = CpuFeatures::IsSupported(SSE3); |
179 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); | 177 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); |
180 } | 178 } |
181 | 179 |
182 TypeRecordingBinaryOpStub( | 180 BinaryOpStub( |
183 int key, | 181 int key, |
184 TRBinaryOpIC::TypeInfo operands_type, | 182 BinaryOpIC::TypeInfo operands_type, |
185 TRBinaryOpIC::TypeInfo result_type = TRBinaryOpIC::UNINITIALIZED) | 183 BinaryOpIC::TypeInfo result_type = BinaryOpIC::UNINITIALIZED) |
186 : op_(OpBits::decode(key)), | 184 : op_(OpBits::decode(key)), |
187 mode_(ModeBits::decode(key)), | 185 mode_(ModeBits::decode(key)), |
188 use_sse3_(SSE3Bits::decode(key)), | 186 use_sse3_(SSE3Bits::decode(key)), |
189 operands_type_(operands_type), | 187 operands_type_(operands_type), |
190 result_type_(result_type), | 188 result_type_(result_type), |
191 name_(NULL) { } | 189 name_(NULL) { } |
192 | 190 |
193 private: | 191 private: |
194 enum SmiCodeGenerateHeapNumberResults { | 192 enum SmiCodeGenerateHeapNumberResults { |
195 ALLOW_HEAPNUMBER_RESULTS, | 193 ALLOW_HEAPNUMBER_RESULTS, |
196 NO_HEAPNUMBER_RESULTS | 194 NO_HEAPNUMBER_RESULTS |
197 }; | 195 }; |
198 | 196 |
199 Token::Value op_; | 197 Token::Value op_; |
200 OverwriteMode mode_; | 198 OverwriteMode mode_; |
201 bool use_sse3_; | 199 bool use_sse3_; |
202 | 200 |
203 // Operand type information determined at runtime. | 201 // Operand type information determined at runtime. |
204 TRBinaryOpIC::TypeInfo operands_type_; | 202 BinaryOpIC::TypeInfo operands_type_; |
205 TRBinaryOpIC::TypeInfo result_type_; | 203 BinaryOpIC::TypeInfo result_type_; |
206 | 204 |
207 char* name_; | 205 char* name_; |
208 | 206 |
209 const char* GetName(); | 207 const char* GetName(); |
210 | 208 |
211 #ifdef DEBUG | 209 #ifdef DEBUG |
212 void Print() { | 210 void Print() { |
213 PrintF("TypeRecordingBinaryOpStub %d (op %s), " | 211 PrintF("BinaryOpStub %d (op %s), " |
214 "(mode %d, runtime_type_info %s)\n", | 212 "(mode %d, runtime_type_info %s)\n", |
215 MinorKey(), | 213 MinorKey(), |
216 Token::String(op_), | 214 Token::String(op_), |
217 static_cast<int>(mode_), | 215 static_cast<int>(mode_), |
218 TRBinaryOpIC::GetName(operands_type_)); | 216 BinaryOpIC::GetName(operands_type_)); |
219 } | 217 } |
220 #endif | 218 #endif |
221 | 219 |
222 // Minor key encoding in 16 bits RRRTTTSOOOOOOOMM. | 220 // Minor key encoding in 16 bits RRRTTTSOOOOOOOMM. |
223 class ModeBits: public BitField<OverwriteMode, 0, 2> {}; | 221 class ModeBits: public BitField<OverwriteMode, 0, 2> {}; |
224 class OpBits: public BitField<Token::Value, 2, 7> {}; | 222 class OpBits: public BitField<Token::Value, 2, 7> {}; |
225 class SSE3Bits: public BitField<bool, 9, 1> {}; | 223 class SSE3Bits: public BitField<bool, 9, 1> {}; |
226 class OperandTypeInfoBits: public BitField<TRBinaryOpIC::TypeInfo, 10, 3> {}; | 224 class OperandTypeInfoBits: public BitField<BinaryOpIC::TypeInfo, 10, 3> {}; |
227 class ResultTypeInfoBits: public BitField<TRBinaryOpIC::TypeInfo, 13, 3> {}; | 225 class ResultTypeInfoBits: public BitField<BinaryOpIC::TypeInfo, 13, 3> {}; |
228 | 226 |
229 Major MajorKey() { return TypeRecordingBinaryOp; } | 227 Major MajorKey() { return BinaryOp; } |
230 int MinorKey() { | 228 int MinorKey() { |
231 return OpBits::encode(op_) | 229 return OpBits::encode(op_) |
232 | ModeBits::encode(mode_) | 230 | ModeBits::encode(mode_) |
233 | SSE3Bits::encode(use_sse3_) | 231 | SSE3Bits::encode(use_sse3_) |
234 | OperandTypeInfoBits::encode(operands_type_) | 232 | OperandTypeInfoBits::encode(operands_type_) |
235 | ResultTypeInfoBits::encode(result_type_); | 233 | ResultTypeInfoBits::encode(result_type_); |
236 } | 234 } |
237 | 235 |
238 void Generate(MacroAssembler* masm); | 236 void Generate(MacroAssembler* masm); |
239 void GenerateGeneric(MacroAssembler* masm); | 237 void GenerateGeneric(MacroAssembler* masm); |
(...skipping 10 matching lines...) Expand all Loading... |
250 void GenerateStringStub(MacroAssembler* masm); | 248 void GenerateStringStub(MacroAssembler* masm); |
251 void GenerateBothStringStub(MacroAssembler* masm); | 249 void GenerateBothStringStub(MacroAssembler* masm); |
252 void GenerateGenericStub(MacroAssembler* masm); | 250 void GenerateGenericStub(MacroAssembler* masm); |
253 void GenerateAddStrings(MacroAssembler* masm); | 251 void GenerateAddStrings(MacroAssembler* masm); |
254 | 252 |
255 void GenerateHeapResultAllocation(MacroAssembler* masm, Label* alloc_failure); | 253 void GenerateHeapResultAllocation(MacroAssembler* masm, Label* alloc_failure); |
256 void GenerateRegisterArgsPush(MacroAssembler* masm); | 254 void GenerateRegisterArgsPush(MacroAssembler* masm); |
257 void GenerateTypeTransition(MacroAssembler* masm); | 255 void GenerateTypeTransition(MacroAssembler* masm); |
258 void GenerateTypeTransitionWithSavedArgs(MacroAssembler* masm); | 256 void GenerateTypeTransitionWithSavedArgs(MacroAssembler* masm); |
259 | 257 |
260 virtual int GetCodeKind() { return Code::TYPE_RECORDING_BINARY_OP_IC; } | 258 virtual int GetCodeKind() { return Code::BINARY_OP_IC; } |
261 | 259 |
262 virtual InlineCacheState GetICState() { | 260 virtual InlineCacheState GetICState() { |
263 return TRBinaryOpIC::ToState(operands_type_); | 261 return BinaryOpIC::ToState(operands_type_); |
264 } | 262 } |
265 | 263 |
266 virtual void FinishCode(Code* code) { | 264 virtual void FinishCode(Code* code) { |
267 code->set_type_recording_binary_op_type(operands_type_); | 265 code->set_binary_op_type(operands_type_); |
268 code->set_type_recording_binary_op_result_type(result_type_); | 266 code->set_binary_op_result_type(result_type_); |
269 } | 267 } |
270 | 268 |
271 friend class CodeGenerator; | 269 friend class CodeGenerator; |
272 }; | 270 }; |
273 | 271 |
274 | 272 |
275 class StringHelper : public AllStatic { | 273 class StringHelper : public AllStatic { |
276 public: | 274 public: |
277 // Generate code for copying characters using a simple loop. This should only | 275 // Generate code for copying characters using a simple loop. This should only |
278 // be used in places where the number of characters is small and the | 276 // be used in places where the number of characters is small and the |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 Register dictionary_; | 508 Register dictionary_; |
511 Register result_; | 509 Register result_; |
512 Register index_; | 510 Register index_; |
513 LookupMode mode_; | 511 LookupMode mode_; |
514 }; | 512 }; |
515 | 513 |
516 | 514 |
517 } } // namespace v8::internal | 515 } } // namespace v8::internal |
518 | 516 |
519 #endif // V8_IA32_CODE_STUBS_IA32_H_ | 517 #endif // V8_IA32_CODE_STUBS_IA32_H_ |
OLD | NEW |