| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 32 #include "type-info.h" | 32 #include "type-info.h" |
| 33 | 33 |
| 34 namespace v8 { | 34 namespace v8 { |
| 35 namespace internal { | 35 namespace internal { |
| 36 | 36 |
| 37 | 37 |
| 38 // Compute a transcendental math function natively, or call the | 38 // Compute a transcendental math function natively, or call the |
| 39 // TranscendentalCache runtime function. | 39 // TranscendentalCache runtime function. |
| 40 class TranscendentalCacheStub: public CodeStub { | 40 class TranscendentalCacheStub: public CodeStub { |
| 41 public: | 41 public: |
| 42 explicit TranscendentalCacheStub(TranscendentalCache::Type type) | 42 enum ArgumentType { |
| 43 : type_(type) {} | 43 TAGGED = 0, |
| 44 UNTAGGED = 1 << TranscendentalCache::kTranscendentalTypeBits |
| 45 }; |
| 46 |
| 47 explicit TranscendentalCacheStub(TranscendentalCache::Type type, |
| 48 ArgumentType argument_type) |
| 49 : type_(type), argument_type_(argument_type) {} |
| 44 void Generate(MacroAssembler* masm); | 50 void Generate(MacroAssembler* masm); |
| 45 private: | 51 private: |
| 46 TranscendentalCache::Type type_; | 52 TranscendentalCache::Type type_; |
| 53 ArgumentType argument_type_; |
| 54 |
| 47 Major MajorKey() { return TranscendentalCache; } | 55 Major MajorKey() { return TranscendentalCache; } |
| 48 int MinorKey() { return type_; } | 56 int MinorKey() { return type_ | argument_type_; } |
| 49 Runtime::FunctionId RuntimeFunction(); | 57 Runtime::FunctionId RuntimeFunction(); |
| 50 void GenerateOperation(MacroAssembler* masm, Label* on_nan_result); | 58 void GenerateOperation(MacroAssembler* masm); |
| 51 }; | 59 }; |
| 52 | 60 |
| 53 | 61 |
| 54 class ToBooleanStub: public CodeStub { | 62 class ToBooleanStub: public CodeStub { |
| 55 public: | 63 public: |
| 56 ToBooleanStub() { } | 64 ToBooleanStub() { } |
| 57 | 65 |
| 58 void Generate(MacroAssembler* masm); | 66 void Generate(MacroAssembler* masm); |
| 59 | 67 |
| 60 private: | 68 private: |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 Register scratch); | 361 Register scratch); |
| 354 | 362 |
| 355 private: | 363 private: |
| 356 DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper); | 364 DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper); |
| 357 }; | 365 }; |
| 358 | 366 |
| 359 | 367 |
| 360 // Flag that indicates how to generate code for the stub StringAddStub. | 368 // Flag that indicates how to generate code for the stub StringAddStub. |
| 361 enum StringAddFlags { | 369 enum StringAddFlags { |
| 362 NO_STRING_ADD_FLAGS = 0, | 370 NO_STRING_ADD_FLAGS = 0, |
| 363 NO_STRING_CHECK_IN_STUB = 1 << 0 // Omit string check in stub. | 371 // Omit left string check in stub (left is definitely a string). |
| 372 NO_STRING_CHECK_LEFT_IN_STUB = 1 << 0, |
| 373 // Omit right string check in stub (right is definitely a string). |
| 374 NO_STRING_CHECK_RIGHT_IN_STUB = 1 << 1, |
| 375 // Omit both string checks in stub. |
| 376 NO_STRING_CHECK_IN_STUB = |
| 377 NO_STRING_CHECK_LEFT_IN_STUB | NO_STRING_CHECK_RIGHT_IN_STUB |
| 364 }; | 378 }; |
| 365 | 379 |
| 366 | 380 |
| 367 class StringAddStub: public CodeStub { | 381 class StringAddStub: public CodeStub { |
| 368 public: | 382 public: |
| 369 explicit StringAddStub(StringAddFlags flags) { | 383 explicit StringAddStub(StringAddFlags flags) : flags_(flags) {} |
| 370 string_check_ = ((flags & NO_STRING_CHECK_IN_STUB) == 0); | |
| 371 } | |
| 372 | 384 |
| 373 private: | 385 private: |
| 374 Major MajorKey() { return StringAdd; } | 386 Major MajorKey() { return StringAdd; } |
| 375 int MinorKey() { return string_check_ ? 0 : 1; } | 387 int MinorKey() { return flags_; } |
| 376 | 388 |
| 377 void Generate(MacroAssembler* masm); | 389 void Generate(MacroAssembler* masm); |
| 378 | 390 |
| 379 // Should the stub check whether arguments are strings? | 391 void GenerateConvertArgument(MacroAssembler* masm, |
| 380 bool string_check_; | 392 int stack_offset, |
| 393 Register arg, |
| 394 Register scratch1, |
| 395 Register scratch2, |
| 396 Register scratch3, |
| 397 Label* slow); |
| 398 |
| 399 const StringAddFlags flags_; |
| 381 }; | 400 }; |
| 382 | 401 |
| 383 | 402 |
| 384 class SubStringStub: public CodeStub { | 403 class SubStringStub: public CodeStub { |
| 385 public: | 404 public: |
| 386 SubStringStub() {} | 405 SubStringStub() {} |
| 387 | 406 |
| 388 private: | 407 private: |
| 389 Major MajorKey() { return SubString; } | 408 Major MajorKey() { return SubString; } |
| 390 int MinorKey() { return 0; } | 409 int MinorKey() { return 0; } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 const char* GetName() { return "NumberToStringStub"; } | 464 const char* GetName() { return "NumberToStringStub"; } |
| 446 | 465 |
| 447 #ifdef DEBUG | 466 #ifdef DEBUG |
| 448 void Print() { | 467 void Print() { |
| 449 PrintF("NumberToStringStub\n"); | 468 PrintF("NumberToStringStub\n"); |
| 450 } | 469 } |
| 451 #endif | 470 #endif |
| 452 }; | 471 }; |
| 453 | 472 |
| 454 | 473 |
| 455 // Generate code the to load an element from a pixel array. The receiver is | 474 // Generate code to load an element from a pixel array. The receiver is assumed |
| 456 // assumed to not be a smi and to have elements, the caller must guarantee this | 475 // to not be a smi and to have elements, the caller must guarantee this |
| 457 // precondition. If the receiver does not have elements that are pixel arrays, | 476 // precondition. If key is not a smi, then the generated code branches to |
| 458 // the generated code jumps to not_pixel_array. If key is not a smi, then the | 477 // key_not_smi. Callers can specify NULL for key_not_smi to signal that a smi |
| 459 // generated code branches to key_not_smi. Callers can specify NULL for | 478 // check has already been performed on key so that the smi check is not |
| 460 // key_not_smi to signal that a smi check has already been performed on key so | 479 // generated. If key is not a valid index within the bounds of the pixel array, |
| 461 // that the smi check is not generated . If key is not a valid index within the | 480 // the generated code jumps to out_of_range. receiver, key and elements are |
| 462 // bounds of the pixel array, the generated code jumps to out_of_range. | 481 // unchanged throughout the generated code sequence. |
| 463 void GenerateFastPixelArrayLoad(MacroAssembler* masm, | 482 void GenerateFastPixelArrayLoad(MacroAssembler* masm, |
| 464 Register receiver, | 483 Register receiver, |
| 465 Register key, | 484 Register key, |
| 466 Register elements, | 485 Register elements, |
| 467 Register untagged_key, | 486 Register untagged_key, |
| 468 Register result, | 487 Register result, |
| 469 Label* not_pixel_array, | 488 Label* not_pixel_array, |
| 470 Label* key_not_smi, | 489 Label* key_not_smi, |
| 471 Label* out_of_range); | 490 Label* out_of_range); |
| 472 | 491 |
| 492 // Generate code to store an element into a pixel array, clamping values between |
| 493 // [0..255]. The receiver is assumed to not be a smi and to have elements, the |
| 494 // caller must guarantee this precondition. If key is not a smi, then the |
| 495 // generated code branches to key_not_smi. Callers can specify NULL for |
| 496 // key_not_smi to signal that a smi check has already been performed on key so |
| 497 // that the smi check is not generated. If the value is not a smi, the |
| 498 // generated code will branch to value_not_smi. If the receiver |
| 499 // doesn't have pixel array elements, the generated code will branch to |
| 500 // not_pixel_array, unless not_pixel_array is NULL, in which case the caller |
| 501 // must ensure that the receiver has pixel array elements. If key is not a |
| 502 // valid index within the bounds of the pixel array, the generated code jumps to |
| 503 // out_of_range. |
| 504 void GenerateFastPixelArrayStore(MacroAssembler* masm, |
| 505 Register receiver, |
| 506 Register key, |
| 507 Register value, |
| 508 Register elements, |
| 509 Register scratch1, |
| 510 bool load_elements_from_receiver, |
| 511 bool key_is_untagged, |
| 512 Label* key_not_smi, |
| 513 Label* value_not_smi, |
| 514 Label* not_pixel_array, |
| 515 Label* out_of_range); |
| 473 | 516 |
| 474 } } // namespace v8::internal | 517 } } // namespace v8::internal |
| 475 | 518 |
| 476 #endif // V8_X64_CODE_STUBS_X64_H_ | 519 #endif // V8_X64_CODE_STUBS_X64_H_ |
| OLD | NEW |