| 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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 Register scratch); | 376 Register scratch); |
| 369 | 377 |
| 370 private: | 378 private: |
| 371 DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper); | 379 DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper); |
| 372 }; | 380 }; |
| 373 | 381 |
| 374 | 382 |
| 375 // Flag that indicates how to generate code for the stub StringAddStub. | 383 // Flag that indicates how to generate code for the stub StringAddStub. |
| 376 enum StringAddFlags { | 384 enum StringAddFlags { |
| 377 NO_STRING_ADD_FLAGS = 0, | 385 NO_STRING_ADD_FLAGS = 0, |
| 378 NO_STRING_CHECK_IN_STUB = 1 << 0 // Omit string check in stub. | 386 // Omit left string check in stub (left is definitely a string). |
| 387 NO_STRING_CHECK_LEFT_IN_STUB = 1 << 0, |
| 388 // Omit right string check in stub (right is definitely a string). |
| 389 NO_STRING_CHECK_RIGHT_IN_STUB = 1 << 1, |
| 390 // Omit both string checks in stub. |
| 391 NO_STRING_CHECK_IN_STUB = |
| 392 NO_STRING_CHECK_LEFT_IN_STUB | NO_STRING_CHECK_RIGHT_IN_STUB |
| 379 }; | 393 }; |
| 380 | 394 |
| 381 | 395 |
| 382 class StringAddStub: public CodeStub { | 396 class StringAddStub: public CodeStub { |
| 383 public: | 397 public: |
| 384 explicit StringAddStub(StringAddFlags flags) { | 398 explicit StringAddStub(StringAddFlags flags) : flags_(flags) {} |
| 385 string_check_ = ((flags & NO_STRING_CHECK_IN_STUB) == 0); | |
| 386 } | |
| 387 | 399 |
| 388 private: | 400 private: |
| 389 Major MajorKey() { return StringAdd; } | 401 Major MajorKey() { return StringAdd; } |
| 390 int MinorKey() { return string_check_ ? 0 : 1; } | 402 int MinorKey() { return flags_; } |
| 391 | 403 |
| 392 void Generate(MacroAssembler* masm); | 404 void Generate(MacroAssembler* masm); |
| 393 | 405 |
| 394 // Should the stub check whether arguments are strings? | 406 void GenerateConvertArgument(MacroAssembler* masm, |
| 395 bool string_check_; | 407 int stack_offset, |
| 408 Register arg, |
| 409 Register scratch1, |
| 410 Register scratch2, |
| 411 Register scratch3, |
| 412 Label* slow); |
| 413 |
| 414 const StringAddFlags flags_; |
| 396 }; | 415 }; |
| 397 | 416 |
| 398 | 417 |
| 399 class SubStringStub: public CodeStub { | 418 class SubStringStub: public CodeStub { |
| 400 public: | 419 public: |
| 401 SubStringStub() {} | 420 SubStringStub() {} |
| 402 | 421 |
| 403 private: | 422 private: |
| 404 Major MajorKey() { return SubString; } | 423 Major MajorKey() { return SubString; } |
| 405 int MinorKey() { return 0; } | 424 int MinorKey() { return 0; } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 const char* GetName() { return "NumberToStringStub"; } | 479 const char* GetName() { return "NumberToStringStub"; } |
| 461 | 480 |
| 462 #ifdef DEBUG | 481 #ifdef DEBUG |
| 463 void Print() { | 482 void Print() { |
| 464 PrintF("NumberToStringStub\n"); | 483 PrintF("NumberToStringStub\n"); |
| 465 } | 484 } |
| 466 #endif | 485 #endif |
| 467 }; | 486 }; |
| 468 | 487 |
| 469 | 488 |
| 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 | |
| 513 } } // namespace v8::internal | 489 } } // namespace v8::internal |
| 514 | 490 |
| 515 #endif // V8_X64_CODE_STUBS_X64_H_ | 491 #endif // V8_X64_CODE_STUBS_X64_H_ |
| OLD | NEW |