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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // Operand type information determined at runtime. | 124 // Operand type information determined at runtime. |
125 BinaryOpIC::TypeInfo runtime_operands_type_; | 125 BinaryOpIC::TypeInfo runtime_operands_type_; |
126 | 126 |
127 char* name_; | 127 char* name_; |
128 | 128 |
129 const char* GetName(); | 129 const char* GetName(); |
130 | 130 |
131 #ifdef DEBUG | 131 #ifdef DEBUG |
132 void Print() { | 132 void Print() { |
133 PrintF("GenericBinaryOpStub %d (op %s), " | 133 PrintF("GenericBinaryOpStub %d (op %s), " |
134 "(mode %d, flags %d, registers %d, reversed %d, only_numbers %s)\n", | 134 "(mode %d, flags %d, registers %d, reversed %d, type_info %s)\n", |
135 MinorKey(), | 135 MinorKey(), |
136 Token::String(op_), | 136 Token::String(op_), |
137 static_cast<int>(mode_), | 137 static_cast<int>(mode_), |
138 static_cast<int>(flags_), | 138 static_cast<int>(flags_), |
139 static_cast<int>(args_in_registers_), | 139 static_cast<int>(args_in_registers_), |
140 static_cast<int>(args_reversed_), | 140 static_cast<int>(args_reversed_), |
141 static_operands_type_.ToString()); | 141 static_operands_type_.ToString()); |
142 } | 142 } |
143 #endif | 143 #endif |
144 | 144 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 193 |
194 virtual int GetCodeKind() { return Code::BINARY_OP_IC; } | 194 virtual int GetCodeKind() { return Code::BINARY_OP_IC; } |
195 | 195 |
196 virtual InlineCacheState GetICState() { | 196 virtual InlineCacheState GetICState() { |
197 return BinaryOpIC::ToState(runtime_operands_type_); | 197 return BinaryOpIC::ToState(runtime_operands_type_); |
198 } | 198 } |
199 | 199 |
200 friend class CodeGenerator; | 200 friend class CodeGenerator; |
201 }; | 201 }; |
202 | 202 |
| 203 |
| 204 class TypeRecordingBinaryOpStub: public CodeStub { |
| 205 public: |
| 206 TypeRecordingBinaryOpStub(Token::Value op, OverwriteMode mode) |
| 207 : op_(op), |
| 208 mode_(mode), |
| 209 operands_type_(TRBinaryOpIC::UNINITIALIZED), |
| 210 result_type_(TRBinaryOpIC::UNINITIALIZED), |
| 211 name_(NULL) { |
| 212 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); |
| 213 } |
| 214 |
| 215 TypeRecordingBinaryOpStub( |
| 216 int key, |
| 217 TRBinaryOpIC::TypeInfo operands_type, |
| 218 TRBinaryOpIC::TypeInfo result_type = TRBinaryOpIC::UNINITIALIZED) |
| 219 : op_(OpBits::decode(key)), |
| 220 mode_(ModeBits::decode(key)), |
| 221 operands_type_(operands_type), |
| 222 result_type_(result_type), |
| 223 name_(NULL) { } |
| 224 |
| 225 private: |
| 226 enum SmiCodeGenerateHeapNumberResults { |
| 227 ALLOW_HEAPNUMBER_RESULTS, |
| 228 NO_HEAPNUMBER_RESULTS |
| 229 }; |
| 230 |
| 231 Token::Value op_; |
| 232 OverwriteMode mode_; |
| 233 |
| 234 // Operand type information determined at runtime. |
| 235 TRBinaryOpIC::TypeInfo operands_type_; |
| 236 TRBinaryOpIC::TypeInfo result_type_; |
| 237 |
| 238 char* name_; |
| 239 |
| 240 const char* GetName(); |
| 241 |
| 242 #ifdef DEBUG |
| 243 void Print() { |
| 244 PrintF("TypeRecordingBinaryOpStub %d (op %s), " |
| 245 "(mode %d, runtime_type_info %s)\n", |
| 246 MinorKey(), |
| 247 Token::String(op_), |
| 248 static_cast<int>(mode_), |
| 249 TRBinaryOpIC::GetName(operands_type_)); |
| 250 } |
| 251 #endif |
| 252 |
| 253 // Minor key encoding in 15 bits RRRTTTOOOOOOOMM. |
| 254 class ModeBits: public BitField<OverwriteMode, 0, 2> {}; |
| 255 class OpBits: public BitField<Token::Value, 2, 7> {}; |
| 256 class OperandTypeInfoBits: public BitField<TRBinaryOpIC::TypeInfo, 9, 3> {}; |
| 257 class ResultTypeInfoBits: public BitField<TRBinaryOpIC::TypeInfo, 12, 3> {}; |
| 258 |
| 259 Major MajorKey() { return TypeRecordingBinaryOp; } |
| 260 int MinorKey() { |
| 261 return OpBits::encode(op_) |
| 262 | ModeBits::encode(mode_) |
| 263 | OperandTypeInfoBits::encode(operands_type_) |
| 264 | ResultTypeInfoBits::encode(result_type_); |
| 265 } |
| 266 |
| 267 void Generate(MacroAssembler* masm); |
| 268 void GenerateGeneric(MacroAssembler* masm); |
| 269 void GenerateSmiCode(MacroAssembler* masm, |
| 270 Label* slow, |
| 271 SmiCodeGenerateHeapNumberResults heapnumber_results); |
| 272 void GenerateLoadArguments(MacroAssembler* masm); |
| 273 void GenerateReturn(MacroAssembler* masm); |
| 274 void GenerateUninitializedStub(MacroAssembler* masm); |
| 275 void GenerateSmiStub(MacroAssembler* masm); |
| 276 void GenerateInt32Stub(MacroAssembler* masm); |
| 277 void GenerateHeapNumberStub(MacroAssembler* masm); |
| 278 void GenerateStringStub(MacroAssembler* masm); |
| 279 void GenerateGenericStub(MacroAssembler* masm); |
| 280 |
| 281 void GenerateHeapResultAllocation(MacroAssembler* masm, Label* alloc_failure); |
| 282 void GenerateRegisterArgsPush(MacroAssembler* masm); |
| 283 void GenerateTypeTransition(MacroAssembler* masm); |
| 284 void GenerateTypeTransitionWithSavedArgs(MacroAssembler* masm); |
| 285 |
| 286 virtual int GetCodeKind() { return Code::TYPE_RECORDING_BINARY_OP_IC; } |
| 287 |
| 288 virtual InlineCacheState GetICState() { |
| 289 return TRBinaryOpIC::ToState(operands_type_); |
| 290 } |
| 291 |
| 292 virtual void FinishCode(Code* code) { |
| 293 code->set_type_recording_binary_op_type(operands_type_); |
| 294 code->set_type_recording_binary_op_result_type(result_type_); |
| 295 } |
| 296 |
| 297 friend class CodeGenerator; |
| 298 }; |
| 299 |
| 300 |
203 class StringHelper : public AllStatic { | 301 class StringHelper : public AllStatic { |
204 public: | 302 public: |
205 // Generate code for copying characters using a simple loop. This should only | 303 // Generate code for copying characters using a simple loop. This should only |
206 // be used in places where the number of characters is small and the | 304 // be used in places where the number of characters is small and the |
207 // additional setup and checking in GenerateCopyCharactersREP adds too much | 305 // additional setup and checking in GenerateCopyCharactersREP adds too much |
208 // overhead. Copying of overlapping regions is not supported. | 306 // overhead. Copying of overlapping regions is not supported. |
209 static void GenerateCopyCharacters(MacroAssembler* masm, | 307 static void GenerateCopyCharacters(MacroAssembler* masm, |
210 Register dest, | 308 Register dest, |
211 Register src, | 309 Register src, |
212 Register count, | 310 Register count, |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 void Print() { | 442 void Print() { |
345 PrintF("NumberToStringStub\n"); | 443 PrintF("NumberToStringStub\n"); |
346 } | 444 } |
347 #endif | 445 #endif |
348 }; | 446 }; |
349 | 447 |
350 | 448 |
351 } } // namespace v8::internal | 449 } } // namespace v8::internal |
352 | 450 |
353 #endif // V8_X64_CODE_STUBS_X64_H_ | 451 #endif // V8_X64_CODE_STUBS_X64_H_ |
OLD | NEW |