| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // Operand type information determined at runtime. | 139 // Operand type information determined at runtime. |
| 140 BinaryOpIC::TypeInfo runtime_operands_type_; | 140 BinaryOpIC::TypeInfo runtime_operands_type_; |
| 141 | 141 |
| 142 char* name_; | 142 char* name_; |
| 143 | 143 |
| 144 const char* GetName(); | 144 const char* GetName(); |
| 145 | 145 |
| 146 #ifdef DEBUG | 146 #ifdef DEBUG |
| 147 void Print() { | 147 void Print() { |
| 148 PrintF("GenericBinaryOpStub %d (op %s), " | 148 PrintF("GenericBinaryOpStub %d (op %s), " |
| 149 "(mode %d, flags %d, registers %d, reversed %d, only_numbers %s)\n", | 149 "(mode %d, flags %d, registers %d, reversed %d, type_info %s)\n", |
| 150 MinorKey(), | 150 MinorKey(), |
| 151 Token::String(op_), | 151 Token::String(op_), |
| 152 static_cast<int>(mode_), | 152 static_cast<int>(mode_), |
| 153 static_cast<int>(flags_), | 153 static_cast<int>(flags_), |
| 154 static_cast<int>(args_in_registers_), | 154 static_cast<int>(args_in_registers_), |
| 155 static_cast<int>(args_reversed_), | 155 static_cast<int>(args_reversed_), |
| 156 static_operands_type_.ToString()); | 156 static_operands_type_.ToString()); |
| 157 } | 157 } |
| 158 #endif | 158 #endif |
| 159 | 159 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 return runtime_operands_type_ != BinaryOpIC::STRINGS; | 206 return runtime_operands_type_ != BinaryOpIC::STRINGS; |
| 207 } | 207 } |
| 208 | 208 |
| 209 virtual int GetCodeKind() { return Code::BINARY_OP_IC; } | 209 virtual int GetCodeKind() { return Code::BINARY_OP_IC; } |
| 210 | 210 |
| 211 virtual InlineCacheState GetICState() { | 211 virtual InlineCacheState GetICState() { |
| 212 return BinaryOpIC::ToState(runtime_operands_type_); | 212 return BinaryOpIC::ToState(runtime_operands_type_); |
| 213 } | 213 } |
| 214 | 214 |
| 215 friend class CodeGenerator; | 215 friend class CodeGenerator; |
| 216 friend class LCodeGen; |
| 217 }; |
| 218 |
| 219 |
| 220 class TypeRecordingBinaryOpStub: public CodeStub { |
| 221 public: |
| 222 TypeRecordingBinaryOpStub(Token::Value op, OverwriteMode mode) |
| 223 : op_(op), |
| 224 mode_(mode), |
| 225 operands_type_(TRBinaryOpIC::UNINITIALIZED), |
| 226 result_type_(TRBinaryOpIC::UNINITIALIZED), |
| 227 name_(NULL) { |
| 228 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); |
| 229 } |
| 230 |
| 231 TypeRecordingBinaryOpStub( |
| 232 int key, |
| 233 TRBinaryOpIC::TypeInfo operands_type, |
| 234 TRBinaryOpIC::TypeInfo result_type = TRBinaryOpIC::UNINITIALIZED) |
| 235 : op_(OpBits::decode(key)), |
| 236 mode_(ModeBits::decode(key)), |
| 237 operands_type_(operands_type), |
| 238 result_type_(result_type), |
| 239 name_(NULL) { } |
| 240 |
| 241 private: |
| 242 enum SmiCodeGenerateHeapNumberResults { |
| 243 ALLOW_HEAPNUMBER_RESULTS, |
| 244 NO_HEAPNUMBER_RESULTS |
| 245 }; |
| 246 |
| 247 Token::Value op_; |
| 248 OverwriteMode mode_; |
| 249 |
| 250 // Operand type information determined at runtime. |
| 251 TRBinaryOpIC::TypeInfo operands_type_; |
| 252 TRBinaryOpIC::TypeInfo result_type_; |
| 253 |
| 254 char* name_; |
| 255 |
| 256 const char* GetName(); |
| 257 |
| 258 #ifdef DEBUG |
| 259 void Print() { |
| 260 PrintF("TypeRecordingBinaryOpStub %d (op %s), " |
| 261 "(mode %d, runtime_type_info %s)\n", |
| 262 MinorKey(), |
| 263 Token::String(op_), |
| 264 static_cast<int>(mode_), |
| 265 TRBinaryOpIC::GetName(operands_type_)); |
| 266 } |
| 267 #endif |
| 268 |
| 269 // Minor key encoding in 15 bits RRRTTTOOOOOOOMM. |
| 270 class ModeBits: public BitField<OverwriteMode, 0, 2> {}; |
| 271 class OpBits: public BitField<Token::Value, 2, 7> {}; |
| 272 class OperandTypeInfoBits: public BitField<TRBinaryOpIC::TypeInfo, 9, 3> {}; |
| 273 class ResultTypeInfoBits: public BitField<TRBinaryOpIC::TypeInfo, 12, 3> {}; |
| 274 |
| 275 Major MajorKey() { return TypeRecordingBinaryOp; } |
| 276 int MinorKey() { |
| 277 return OpBits::encode(op_) |
| 278 | ModeBits::encode(mode_) |
| 279 | OperandTypeInfoBits::encode(operands_type_) |
| 280 | ResultTypeInfoBits::encode(result_type_); |
| 281 } |
| 282 |
| 283 void Generate(MacroAssembler* masm); |
| 284 void GenerateGeneric(MacroAssembler* masm); |
| 285 void GenerateSmiCode(MacroAssembler* masm, |
| 286 Label* slow, |
| 287 SmiCodeGenerateHeapNumberResults heapnumber_results); |
| 288 void GenerateFloatingPointCode(MacroAssembler* masm, |
| 289 Label* allocation_failure, |
| 290 Label* non_numeric_failure); |
| 291 void GenerateStringAddCode(MacroAssembler* masm); |
| 292 void GenerateCallRuntimeCode(MacroAssembler* masm); |
| 293 void GenerateLoadArguments(MacroAssembler* masm); |
| 294 void GenerateReturn(MacroAssembler* masm); |
| 295 void GenerateUninitializedStub(MacroAssembler* masm); |
| 296 void GenerateSmiStub(MacroAssembler* masm); |
| 297 void GenerateInt32Stub(MacroAssembler* masm); |
| 298 void GenerateHeapNumberStub(MacroAssembler* masm); |
| 299 void GenerateStringStub(MacroAssembler* masm); |
| 300 void GenerateGenericStub(MacroAssembler* masm); |
| 301 |
| 302 void GenerateHeapResultAllocation(MacroAssembler* masm, Label* alloc_failure); |
| 303 void GenerateRegisterArgsPush(MacroAssembler* masm); |
| 304 void GenerateTypeTransition(MacroAssembler* masm); |
| 305 void GenerateTypeTransitionWithSavedArgs(MacroAssembler* masm); |
| 306 |
| 307 virtual int GetCodeKind() { return Code::TYPE_RECORDING_BINARY_OP_IC; } |
| 308 |
| 309 virtual InlineCacheState GetICState() { |
| 310 return TRBinaryOpIC::ToState(operands_type_); |
| 311 } |
| 312 |
| 313 virtual void FinishCode(Code* code) { |
| 314 code->set_type_recording_binary_op_type(operands_type_); |
| 315 code->set_type_recording_binary_op_result_type(result_type_); |
| 316 } |
| 317 |
| 318 friend class CodeGenerator; |
| 216 }; | 319 }; |
| 217 | 320 |
| 321 |
| 218 class StringHelper : public AllStatic { | 322 class StringHelper : public AllStatic { |
| 219 public: | 323 public: |
| 220 // Generate code for copying characters using a simple loop. This should only | 324 // Generate code for copying characters using a simple loop. This should only |
| 221 // be used in places where the number of characters is small and the | 325 // be used in places where the number of characters is small and the |
| 222 // additional setup and checking in GenerateCopyCharactersREP adds too much | 326 // additional setup and checking in GenerateCopyCharactersREP adds too much |
| 223 // overhead. Copying of overlapping regions is not supported. | 327 // overhead. Copying of overlapping regions is not supported. |
| 224 static void GenerateCopyCharacters(MacroAssembler* masm, | 328 static void GenerateCopyCharacters(MacroAssembler* masm, |
| 225 Register dest, | 329 Register dest, |
| 226 Register src, | 330 Register src, |
| 227 Register count, | 331 Register count, |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 const char* GetName() { return "NumberToStringStub"; } | 460 const char* GetName() { return "NumberToStringStub"; } |
| 357 | 461 |
| 358 #ifdef DEBUG | 462 #ifdef DEBUG |
| 359 void Print() { | 463 void Print() { |
| 360 PrintF("NumberToStringStub\n"); | 464 PrintF("NumberToStringStub\n"); |
| 361 } | 465 } |
| 362 #endif | 466 #endif |
| 363 }; | 467 }; |
| 364 | 468 |
| 365 | 469 |
| 470 // Generate code to load an element from a pixel array. The receiver is assumed |
| 471 // to not be a smi and to have elements, the caller must guarantee this |
| 472 // precondition. If key is not a smi, then the generated code branches to |
| 473 // key_not_smi. Callers can specify NULL for key_not_smi to signal that a smi |
| 474 // check has already been performed on key so that the smi check is not |
| 475 // generated. If key is not a valid index within the bounds of the pixel array, |
| 476 // the generated code jumps to out_of_range. receiver, key and elements are |
| 477 // unchanged throughout the generated code sequence. |
| 478 void GenerateFastPixelArrayLoad(MacroAssembler* masm, |
| 479 Register receiver, |
| 480 Register key, |
| 481 Register elements, |
| 482 Register untagged_key, |
| 483 Register result, |
| 484 Label* not_pixel_array, |
| 485 Label* key_not_smi, |
| 486 Label* out_of_range); |
| 487 |
| 488 // Generate code to store an element into a pixel array, clamping values between |
| 489 // [0..255]. The receiver is assumed to not be a smi and to have elements, the |
| 490 // caller must guarantee this precondition. If key is not a smi, then the |
| 491 // generated code branches to key_not_smi. Callers can specify NULL for |
| 492 // key_not_smi to signal that a smi check has already been performed on key so |
| 493 // that the smi check is not generated. If the value is not a smi, the |
| 494 // generated code will branch to value_not_smi. If the receiver |
| 495 // doesn't have pixel array elements, the generated code will branch to |
| 496 // not_pixel_array, unless not_pixel_array is NULL, in which case the caller |
| 497 // must ensure that the receiver has pixel array elements. If key is not a |
| 498 // valid index within the bounds of the pixel array, the generated code jumps to |
| 499 // out_of_range. |
| 500 void GenerateFastPixelArrayStore(MacroAssembler* masm, |
| 501 Register receiver, |
| 502 Register key, |
| 503 Register value, |
| 504 Register elements, |
| 505 Register scratch1, |
| 506 bool load_elements_from_receiver, |
| 507 bool key_is_untagged, |
| 508 Label* key_not_smi, |
| 509 Label* value_not_smi, |
| 510 Label* not_pixel_array, |
| 511 Label* out_of_range); |
| 512 |
| 366 } } // namespace v8::internal | 513 } } // namespace v8::internal |
| 367 | 514 |
| 368 #endif // V8_X64_CODE_STUBS_X64_H_ | 515 #endif // V8_X64_CODE_STUBS_X64_H_ |
| OLD | NEW |