| OLD | NEW |
| 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
| 2 // All Rights Reserved. | 2 // All Rights Reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
| 9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
| 10 // | 10 // |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 UNREACHABLE(); | 545 UNREACHABLE(); |
| 546 break; | 546 break; |
| 547 } | 547 } |
| 548 } | 548 } |
| 549 #endif // DEBUG | 549 #endif // DEBUG |
| 550 | 550 |
| 551 | 551 |
| 552 // ----------------------------------------------------------------------------- | 552 // ----------------------------------------------------------------------------- |
| 553 // Implementation of ExternalReference | 553 // Implementation of ExternalReference |
| 554 | 554 |
| 555 ExternalReference::ExternalReference(Builtins::CFunctionId id) | 555 ExternalReference::ExternalReference(Builtins::CFunctionId id, Isolate* isolate) |
| 556 : address_(Redirect(Builtins::c_function_address(id))) {} | 556 : address_(Redirect(isolate, Builtins::c_function_address(id))) {} |
| 557 | 557 |
| 558 | 558 |
| 559 ExternalReference::ExternalReference( | 559 ExternalReference::ExternalReference( |
| 560 ApiFunction* fun, Type type = ExternalReference::BUILTIN_CALL) | 560 ApiFunction* fun, |
| 561 : address_(Redirect(fun->address(), type)) {} | 561 Type type = ExternalReference::BUILTIN_CALL, |
| 562 Isolate* isolate = NULL) |
| 563 : address_(Redirect(isolate, fun->address(), type)) {} |
| 562 | 564 |
| 563 | 565 |
| 564 ExternalReference::ExternalReference(Builtins::Name name) | 566 ExternalReference::ExternalReference(Builtins::Name name, Isolate* isolate) |
| 565 : address_(Isolate::Current()->builtins()->builtin_address(name)) {} | 567 : address_(isolate->builtins()->builtin_address(name)) {} |
| 566 | 568 |
| 567 | 569 |
| 568 ExternalReference::ExternalReference(Runtime::FunctionId id) | 570 ExternalReference::ExternalReference(Runtime::FunctionId id, |
| 569 : address_(Redirect(Runtime::FunctionForId(id)->entry)) {} | 571 Isolate* isolate) |
| 572 : address_(Redirect(isolate, Runtime::FunctionForId(id)->entry)) {} |
| 570 | 573 |
| 571 | 574 |
| 572 ExternalReference::ExternalReference(const Runtime::Function* f) | 575 ExternalReference::ExternalReference(const Runtime::Function* f, |
| 573 : address_(Redirect(f->entry)) {} | 576 Isolate* isolate) |
| 577 : address_(Redirect(isolate, f->entry)) {} |
| 574 | 578 |
| 575 | 579 |
| 576 ExternalReference ExternalReference::isolate_address() { | 580 ExternalReference ExternalReference::isolate_address() { |
| 577 return ExternalReference(Isolate::Current()); | 581 return ExternalReference(Isolate::Current()); |
| 578 } | 582 } |
| 579 | 583 |
| 580 | 584 |
| 581 ExternalReference::ExternalReference(const IC_Utility& ic_utility) | 585 ExternalReference::ExternalReference(const IC_Utility& ic_utility, |
| 582 : address_(Redirect(ic_utility.address())) {} | 586 Isolate* isolate) |
| 587 : address_(Redirect(isolate, ic_utility.address())) {} |
| 583 | 588 |
| 584 #ifdef ENABLE_DEBUGGER_SUPPORT | 589 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 585 ExternalReference::ExternalReference(const Debug_Address& debug_address) | 590 ExternalReference::ExternalReference(const Debug_Address& debug_address, |
| 586 : address_(debug_address.address(Isolate::Current())) {} | 591 Isolate* isolate) |
| 592 : address_(debug_address.address(isolate)) {} |
| 587 #endif | 593 #endif |
| 588 | 594 |
| 589 ExternalReference::ExternalReference(StatsCounter* counter) | 595 ExternalReference::ExternalReference(StatsCounter* counter) |
| 590 : address_(reinterpret_cast<Address>(counter->GetInternalPointer())) {} | 596 : address_(reinterpret_cast<Address>(counter->GetInternalPointer())) {} |
| 591 | 597 |
| 592 | 598 |
| 593 ExternalReference::ExternalReference(Isolate::AddressId id) | 599 ExternalReference::ExternalReference(Isolate::AddressId id, Isolate* isolate) |
| 594 : address_(Isolate::Current()->get_address_from_id(id)) {} | 600 : address_(isolate->get_address_from_id(id)) {} |
| 595 | 601 |
| 596 | 602 |
| 597 ExternalReference::ExternalReference(const SCTableReference& table_ref) | 603 ExternalReference::ExternalReference(const SCTableReference& table_ref) |
| 598 : address_(table_ref.address()) {} | 604 : address_(table_ref.address()) {} |
| 599 | 605 |
| 600 | 606 |
| 601 ExternalReference ExternalReference::perform_gc_function() { | 607 ExternalReference ExternalReference::perform_gc_function(Isolate* isolate) { |
| 602 return ExternalReference(Redirect(FUNCTION_ADDR(Runtime::PerformGC))); | 608 return ExternalReference(Redirect(isolate, |
| 609 FUNCTION_ADDR(Runtime::PerformGC))); |
| 603 } | 610 } |
| 604 | 611 |
| 605 | 612 |
| 606 ExternalReference ExternalReference::fill_heap_number_with_random_function() { | 613 ExternalReference ExternalReference::fill_heap_number_with_random_function( |
| 607 return | 614 Isolate* isolate) { |
| 608 ExternalReference(Redirect(FUNCTION_ADDR(V8::FillHeapNumberWithRandom))); | 615 return ExternalReference(Redirect( |
| 616 isolate, |
| 617 FUNCTION_ADDR(V8::FillHeapNumberWithRandom))); |
| 609 } | 618 } |
| 610 | 619 |
| 611 | 620 |
| 612 ExternalReference ExternalReference::delete_handle_scope_extensions() { | 621 ExternalReference ExternalReference::delete_handle_scope_extensions( |
| 613 return ExternalReference(Redirect(FUNCTION_ADDR( | 622 Isolate* isolate) { |
| 614 HandleScope::DeleteExtensions))); | 623 return ExternalReference(Redirect( |
| 624 isolate, |
| 625 FUNCTION_ADDR(HandleScope::DeleteExtensions))); |
| 615 } | 626 } |
| 616 | 627 |
| 617 | 628 |
| 618 ExternalReference ExternalReference::random_uint32_function() { | 629 ExternalReference ExternalReference::random_uint32_function( |
| 619 return ExternalReference(Redirect(FUNCTION_ADDR(V8::Random))); | 630 Isolate* isolate) { |
| 631 return ExternalReference(Redirect(isolate, FUNCTION_ADDR(V8::Random))); |
| 620 } | 632 } |
| 621 | 633 |
| 622 | 634 |
| 623 ExternalReference ExternalReference::transcendental_cache_array_address() { | 635 ExternalReference ExternalReference::transcendental_cache_array_address( |
| 624 return ExternalReference(Isolate::Current()->transcendental_cache()-> | 636 Isolate* isolate) { |
| 625 cache_array_address()); | 637 return ExternalReference( |
| 638 isolate->transcendental_cache()->cache_array_address()); |
| 626 } | 639 } |
| 627 | 640 |
| 628 | 641 |
| 629 ExternalReference ExternalReference::new_deoptimizer_function() { | 642 ExternalReference ExternalReference::new_deoptimizer_function( |
| 643 Isolate* isolate) { |
| 630 return ExternalReference( | 644 return ExternalReference( |
| 631 Redirect(FUNCTION_ADDR(Deoptimizer::New))); | 645 Redirect(isolate, FUNCTION_ADDR(Deoptimizer::New))); |
| 632 } | 646 } |
| 633 | 647 |
| 634 | 648 |
| 635 ExternalReference ExternalReference::compute_output_frames_function() { | 649 ExternalReference ExternalReference::compute_output_frames_function( |
| 650 Isolate* isolate) { |
| 636 return ExternalReference( | 651 return ExternalReference( |
| 637 Redirect(FUNCTION_ADDR(Deoptimizer::ComputeOutputFrames))); | 652 Redirect(isolate, FUNCTION_ADDR(Deoptimizer::ComputeOutputFrames))); |
| 638 } | 653 } |
| 639 | 654 |
| 640 | 655 |
| 641 ExternalReference ExternalReference::global_contexts_list() { | 656 ExternalReference ExternalReference::global_contexts_list(Isolate* isolate) { |
| 642 return ExternalReference(Isolate::Current()-> | 657 return ExternalReference(isolate->heap()->global_contexts_list_address()); |
| 643 heap()->global_contexts_list_address()); | |
| 644 } | 658 } |
| 645 | 659 |
| 646 | 660 |
| 647 ExternalReference ExternalReference::keyed_lookup_cache_keys() { | 661 ExternalReference ExternalReference::keyed_lookup_cache_keys(Isolate* isolate) { |
| 648 return ExternalReference(Isolate::Current()-> | 662 return ExternalReference(isolate->keyed_lookup_cache()->keys_address()); |
| 649 keyed_lookup_cache()->keys_address()); | |
| 650 } | 663 } |
| 651 | 664 |
| 652 | 665 |
| 653 ExternalReference ExternalReference::keyed_lookup_cache_field_offsets() { | 666 ExternalReference ExternalReference::keyed_lookup_cache_field_offsets( |
| 654 return ExternalReference(Isolate::Current()-> | 667 Isolate* isolate) { |
| 655 keyed_lookup_cache()->field_offsets_address()); | 668 return ExternalReference( |
| 669 isolate->keyed_lookup_cache()->field_offsets_address()); |
| 656 } | 670 } |
| 657 | 671 |
| 658 | 672 |
| 659 ExternalReference ExternalReference::the_hole_value_location() { | 673 ExternalReference ExternalReference::the_hole_value_location(Isolate* isolate) { |
| 660 return ExternalReference(FACTORY->the_hole_value().location()); | 674 return ExternalReference(isolate->factory()->the_hole_value().location()); |
| 661 } | 675 } |
| 662 | 676 |
| 663 | 677 |
| 664 ExternalReference ExternalReference::arguments_marker_location() { | 678 ExternalReference ExternalReference::arguments_marker_location( |
| 665 return ExternalReference(FACTORY->arguments_marker().location()); | 679 Isolate* isolate) { |
| 680 return ExternalReference(isolate->factory()->arguments_marker().location()); |
| 666 } | 681 } |
| 667 | 682 |
| 668 | 683 |
| 669 ExternalReference ExternalReference::roots_address() { | 684 ExternalReference ExternalReference::roots_address(Isolate* isolate) { |
| 670 return ExternalReference(HEAP->roots_address()); | 685 return ExternalReference(isolate->heap()->roots_address()); |
| 671 } | 686 } |
| 672 | 687 |
| 673 | 688 |
| 674 ExternalReference ExternalReference::address_of_stack_limit() { | 689 ExternalReference ExternalReference::address_of_stack_limit(Isolate* isolate) { |
| 675 return ExternalReference( | 690 return ExternalReference(isolate->stack_guard()->address_of_jslimit()); |
| 676 Isolate::Current()->stack_guard()->address_of_jslimit()); | |
| 677 } | 691 } |
| 678 | 692 |
| 679 | 693 |
| 680 ExternalReference ExternalReference::address_of_real_stack_limit() { | 694 ExternalReference ExternalReference::address_of_real_stack_limit( |
| 681 return ExternalReference( | 695 Isolate* isolate) { |
| 682 Isolate::Current()->stack_guard()->address_of_real_jslimit()); | 696 return ExternalReference(isolate->stack_guard()->address_of_real_jslimit()); |
| 683 } | 697 } |
| 684 | 698 |
| 685 | 699 |
| 686 ExternalReference ExternalReference::address_of_regexp_stack_limit() { | 700 ExternalReference ExternalReference::address_of_regexp_stack_limit( |
| 687 return ExternalReference( | 701 Isolate* isolate) { |
| 688 Isolate::Current()->regexp_stack()->limit_address()); | 702 return ExternalReference(isolate->regexp_stack()->limit_address()); |
| 689 } | 703 } |
| 690 | 704 |
| 691 | 705 |
| 692 ExternalReference ExternalReference::new_space_start() { | 706 ExternalReference ExternalReference::new_space_start(Isolate* isolate) { |
| 693 return ExternalReference(HEAP->NewSpaceStart()); | 707 return ExternalReference(isolate->heap()->NewSpaceStart()); |
| 694 } | 708 } |
| 695 | 709 |
| 696 | 710 |
| 697 ExternalReference ExternalReference::new_space_mask() { | 711 ExternalReference ExternalReference::new_space_mask(Isolate* isolate) { |
| 698 return ExternalReference(reinterpret_cast<Address>(HEAP->NewSpaceMask())); | 712 Address mask = reinterpret_cast<Address>(isolate->heap()->NewSpaceMask()); |
| 713 return ExternalReference(mask); |
| 699 } | 714 } |
| 700 | 715 |
| 701 | 716 |
| 702 ExternalReference ExternalReference::new_space_allocation_top_address() { | 717 ExternalReference ExternalReference::new_space_allocation_top_address( |
| 703 return ExternalReference(HEAP->NewSpaceAllocationTopAddress()); | 718 Isolate* isolate) { |
| 719 return ExternalReference(isolate->heap()->NewSpaceAllocationTopAddress()); |
| 704 } | 720 } |
| 705 | 721 |
| 706 | 722 |
| 707 ExternalReference ExternalReference::heap_always_allocate_scope_depth() { | 723 ExternalReference ExternalReference::heap_always_allocate_scope_depth( |
| 708 return ExternalReference(HEAP->always_allocate_scope_depth_address()); | 724 Isolate* isolate) { |
| 725 Heap* heap = isolate->heap(); |
| 726 return ExternalReference(heap->always_allocate_scope_depth_address()); |
| 709 } | 727 } |
| 710 | 728 |
| 711 | 729 |
| 712 ExternalReference ExternalReference::new_space_allocation_limit_address() { | 730 ExternalReference ExternalReference::new_space_allocation_limit_address( |
| 713 return ExternalReference(HEAP->NewSpaceAllocationLimitAddress()); | 731 Isolate* isolate) { |
| 732 return ExternalReference(isolate->heap()->NewSpaceAllocationLimitAddress()); |
| 714 } | 733 } |
| 715 | 734 |
| 716 | 735 |
| 717 ExternalReference ExternalReference::handle_scope_level_address() { | 736 ExternalReference ExternalReference::handle_scope_level_address() { |
| 718 return ExternalReference(HandleScope::current_level_address()); | 737 return ExternalReference(HandleScope::current_level_address()); |
| 719 } | 738 } |
| 720 | 739 |
| 721 | 740 |
| 722 ExternalReference ExternalReference::handle_scope_next_address() { | 741 ExternalReference ExternalReference::handle_scope_next_address() { |
| 723 return ExternalReference(HandleScope::current_next_address()); | 742 return ExternalReference(HandleScope::current_next_address()); |
| 724 } | 743 } |
| 725 | 744 |
| 726 | 745 |
| 727 ExternalReference ExternalReference::handle_scope_limit_address() { | 746 ExternalReference ExternalReference::handle_scope_limit_address() { |
| 728 return ExternalReference(HandleScope::current_limit_address()); | 747 return ExternalReference(HandleScope::current_limit_address()); |
| 729 } | 748 } |
| 730 | 749 |
| 731 | 750 |
| 732 ExternalReference ExternalReference::scheduled_exception_address() { | 751 ExternalReference ExternalReference::scheduled_exception_address( |
| 733 return ExternalReference(Isolate::Current()->scheduled_exception_address()); | 752 Isolate* isolate) { |
| 753 return ExternalReference(isolate->scheduled_exception_address()); |
| 734 } | 754 } |
| 735 | 755 |
| 736 | 756 |
| 737 ExternalReference ExternalReference::address_of_min_int() { | 757 ExternalReference ExternalReference::address_of_min_int() { |
| 738 return ExternalReference(reinterpret_cast<void*>( | 758 return ExternalReference(reinterpret_cast<void*>( |
| 739 const_cast<double*>(&DoubleConstant::min_int))); | 759 const_cast<double*>(&DoubleConstant::min_int))); |
| 740 } | 760 } |
| 741 | 761 |
| 742 | 762 |
| 743 ExternalReference ExternalReference::address_of_one_half() { | 763 ExternalReference ExternalReference::address_of_one_half() { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 759 | 779 |
| 760 | 780 |
| 761 ExternalReference ExternalReference::address_of_nan() { | 781 ExternalReference ExternalReference::address_of_nan() { |
| 762 return ExternalReference(reinterpret_cast<void*>( | 782 return ExternalReference(reinterpret_cast<void*>( |
| 763 const_cast<double*>(&DoubleConstant::nan))); | 783 const_cast<double*>(&DoubleConstant::nan))); |
| 764 } | 784 } |
| 765 | 785 |
| 766 | 786 |
| 767 #ifndef V8_INTERPRETED_REGEXP | 787 #ifndef V8_INTERPRETED_REGEXP |
| 768 | 788 |
| 769 ExternalReference ExternalReference::re_check_stack_guard_state() { | 789 ExternalReference ExternalReference::re_check_stack_guard_state( |
| 790 Isolate* isolate) { |
| 770 Address function; | 791 Address function; |
| 771 #ifdef V8_TARGET_ARCH_X64 | 792 #ifdef V8_TARGET_ARCH_X64 |
| 772 function = FUNCTION_ADDR(RegExpMacroAssemblerX64::CheckStackGuardState); | 793 function = FUNCTION_ADDR(RegExpMacroAssemblerX64::CheckStackGuardState); |
| 773 #elif V8_TARGET_ARCH_IA32 | 794 #elif V8_TARGET_ARCH_IA32 |
| 774 function = FUNCTION_ADDR(RegExpMacroAssemblerIA32::CheckStackGuardState); | 795 function = FUNCTION_ADDR(RegExpMacroAssemblerIA32::CheckStackGuardState); |
| 775 #elif V8_TARGET_ARCH_ARM | 796 #elif V8_TARGET_ARCH_ARM |
| 776 function = FUNCTION_ADDR(RegExpMacroAssemblerARM::CheckStackGuardState); | 797 function = FUNCTION_ADDR(RegExpMacroAssemblerARM::CheckStackGuardState); |
| 777 #else | 798 #else |
| 778 UNREACHABLE(); | 799 UNREACHABLE(); |
| 779 #endif | 800 #endif |
| 780 return ExternalReference(Redirect(function)); | 801 return ExternalReference(Redirect(isolate, function)); |
| 781 } | 802 } |
| 782 | 803 |
| 783 ExternalReference ExternalReference::re_grow_stack() { | 804 ExternalReference ExternalReference::re_grow_stack(Isolate* isolate) { |
| 784 return ExternalReference( | 805 return ExternalReference( |
| 785 Redirect(FUNCTION_ADDR(NativeRegExpMacroAssembler::GrowStack))); | 806 Redirect(isolate, FUNCTION_ADDR(NativeRegExpMacroAssembler::GrowStack))); |
| 786 } | 807 } |
| 787 | 808 |
| 788 ExternalReference ExternalReference::re_case_insensitive_compare_uc16() { | 809 ExternalReference ExternalReference::re_case_insensitive_compare_uc16( |
| 810 Isolate* isolate) { |
| 789 return ExternalReference(Redirect( | 811 return ExternalReference(Redirect( |
| 812 isolate, |
| 790 FUNCTION_ADDR(NativeRegExpMacroAssembler::CaseInsensitiveCompareUC16))); | 813 FUNCTION_ADDR(NativeRegExpMacroAssembler::CaseInsensitiveCompareUC16))); |
| 791 } | 814 } |
| 792 | 815 |
| 793 ExternalReference ExternalReference::re_word_character_map() { | 816 ExternalReference ExternalReference::re_word_character_map() { |
| 794 return ExternalReference( | 817 return ExternalReference( |
| 795 NativeRegExpMacroAssembler::word_character_map_address()); | 818 NativeRegExpMacroAssembler::word_character_map_address()); |
| 796 } | 819 } |
| 797 | 820 |
| 798 ExternalReference ExternalReference::address_of_static_offsets_vector() { | 821 ExternalReference ExternalReference::address_of_static_offsets_vector( |
| 799 return ExternalReference(OffsetsVector::static_offsets_vector_address( | 822 Isolate* isolate) { |
| 800 Isolate::Current())); | 823 return ExternalReference( |
| 824 OffsetsVector::static_offsets_vector_address(isolate)); |
| 801 } | 825 } |
| 802 | 826 |
| 803 ExternalReference ExternalReference::address_of_regexp_stack_memory_address() { | 827 ExternalReference ExternalReference::address_of_regexp_stack_memory_address( |
| 828 Isolate* isolate) { |
| 804 return ExternalReference( | 829 return ExternalReference( |
| 805 Isolate::Current()->regexp_stack()->memory_address()); | 830 isolate->regexp_stack()->memory_address()); |
| 806 } | 831 } |
| 807 | 832 |
| 808 ExternalReference ExternalReference::address_of_regexp_stack_memory_size() { | 833 ExternalReference ExternalReference::address_of_regexp_stack_memory_size( |
| 809 return ExternalReference( | 834 Isolate* isolate) { |
| 810 Isolate::Current()->regexp_stack()->memory_size_address()); | 835 return ExternalReference(isolate->regexp_stack()->memory_size_address()); |
| 811 } | 836 } |
| 812 | 837 |
| 813 #endif // V8_INTERPRETED_REGEXP | 838 #endif // V8_INTERPRETED_REGEXP |
| 814 | 839 |
| 815 | 840 |
| 816 static double add_two_doubles(double x, double y) { | 841 static double add_two_doubles(double x, double y) { |
| 817 return x + y; | 842 return x + y; |
| 818 } | 843 } |
| 819 | 844 |
| 820 | 845 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 846 static double math_cos_double(double x) { | 871 static double math_cos_double(double x) { |
| 847 return cos(x); | 872 return cos(x); |
| 848 } | 873 } |
| 849 | 874 |
| 850 | 875 |
| 851 static double math_log_double(double x) { | 876 static double math_log_double(double x) { |
| 852 return log(x); | 877 return log(x); |
| 853 } | 878 } |
| 854 | 879 |
| 855 | 880 |
| 856 ExternalReference ExternalReference::math_sin_double_function() { | 881 ExternalReference ExternalReference::math_sin_double_function( |
| 857 return ExternalReference(Redirect(FUNCTION_ADDR(math_sin_double), | 882 Isolate* isolate) { |
| 883 return ExternalReference(Redirect(isolate, |
| 884 FUNCTION_ADDR(math_sin_double), |
| 858 FP_RETURN_CALL)); | 885 FP_RETURN_CALL)); |
| 859 } | 886 } |
| 860 | 887 |
| 861 | 888 |
| 862 ExternalReference ExternalReference::math_cos_double_function() { | 889 ExternalReference ExternalReference::math_cos_double_function( |
| 863 return ExternalReference(Redirect(FUNCTION_ADDR(math_cos_double), | 890 Isolate* isolate) { |
| 891 return ExternalReference(Redirect(isolate, |
| 892 FUNCTION_ADDR(math_cos_double), |
| 864 FP_RETURN_CALL)); | 893 FP_RETURN_CALL)); |
| 865 } | 894 } |
| 866 | 895 |
| 867 | 896 |
| 868 ExternalReference ExternalReference::math_log_double_function() { | 897 ExternalReference ExternalReference::math_log_double_function( |
| 869 return ExternalReference(Redirect(FUNCTION_ADDR(math_log_double), | 898 Isolate* isolate) { |
| 899 return ExternalReference(Redirect(isolate, |
| 900 FUNCTION_ADDR(math_log_double), |
| 870 FP_RETURN_CALL)); | 901 FP_RETURN_CALL)); |
| 871 } | 902 } |
| 872 | 903 |
| 873 | 904 |
| 874 // Helper function to compute x^y, where y is known to be an | 905 // Helper function to compute x^y, where y is known to be an |
| 875 // integer. Uses binary decomposition to limit the number of | 906 // integer. Uses binary decomposition to limit the number of |
| 876 // multiplications; see the discussion in "Hacker's Delight" by Henry | 907 // multiplications; see the discussion in "Hacker's Delight" by Henry |
| 877 // S. Warren, Jr., figure 11-6, page 213. | 908 // S. Warren, Jr., figure 11-6, page 213. |
| 878 double power_double_int(double x, int y) { | 909 double power_double_int(double x, int y) { |
| 879 double m = (y < 0) ? 1 / x : x; | 910 double m = (y < 0) ? 1 / x : x; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 899 if (y == 0.5) return sqrt(x + 0.0); // -0 must be converted to +0. | 930 if (y == 0.5) return sqrt(x + 0.0); // -0 must be converted to +0. |
| 900 if (y == -0.5) return 1.0 / sqrt(x + 0.0); | 931 if (y == -0.5) return 1.0 / sqrt(x + 0.0); |
| 901 } | 932 } |
| 902 if (isnan(y) || ((x == 1 || x == -1) && isinf(y))) { | 933 if (isnan(y) || ((x == 1 || x == -1) && isinf(y))) { |
| 903 return OS::nan_value(); | 934 return OS::nan_value(); |
| 904 } | 935 } |
| 905 return pow(x, y); | 936 return pow(x, y); |
| 906 } | 937 } |
| 907 | 938 |
| 908 | 939 |
| 909 ExternalReference ExternalReference::power_double_double_function() { | 940 ExternalReference ExternalReference::power_double_double_function( |
| 910 return ExternalReference(Redirect(FUNCTION_ADDR(power_double_double), | 941 Isolate* isolate) { |
| 942 return ExternalReference(Redirect(isolate, |
| 943 FUNCTION_ADDR(power_double_double), |
| 911 FP_RETURN_CALL)); | 944 FP_RETURN_CALL)); |
| 912 } | 945 } |
| 913 | 946 |
| 914 | 947 |
| 915 ExternalReference ExternalReference::power_double_int_function() { | 948 ExternalReference ExternalReference::power_double_int_function( |
| 916 return ExternalReference(Redirect(FUNCTION_ADDR(power_double_int), | 949 Isolate* isolate) { |
| 950 return ExternalReference(Redirect(isolate, |
| 951 FUNCTION_ADDR(power_double_int), |
| 917 FP_RETURN_CALL)); | 952 FP_RETURN_CALL)); |
| 918 } | 953 } |
| 919 | 954 |
| 920 | 955 |
| 921 static int native_compare_doubles(double y, double x) { | 956 static int native_compare_doubles(double y, double x) { |
| 922 if (x == y) return EQUAL; | 957 if (x == y) return EQUAL; |
| 923 return x < y ? LESS : GREATER; | 958 return x < y ? LESS : GREATER; |
| 924 } | 959 } |
| 925 | 960 |
| 926 | 961 |
| 927 ExternalReference ExternalReference::double_fp_operation( | 962 ExternalReference ExternalReference::double_fp_operation( |
| 928 Token::Value operation) { | 963 Token::Value operation, Isolate* isolate) { |
| 929 typedef double BinaryFPOperation(double x, double y); | 964 typedef double BinaryFPOperation(double x, double y); |
| 930 BinaryFPOperation* function = NULL; | 965 BinaryFPOperation* function = NULL; |
| 931 switch (operation) { | 966 switch (operation) { |
| 932 case Token::ADD: | 967 case Token::ADD: |
| 933 function = &add_two_doubles; | 968 function = &add_two_doubles; |
| 934 break; | 969 break; |
| 935 case Token::SUB: | 970 case Token::SUB: |
| 936 function = &sub_two_doubles; | 971 function = &sub_two_doubles; |
| 937 break; | 972 break; |
| 938 case Token::MUL: | 973 case Token::MUL: |
| 939 function = &mul_two_doubles; | 974 function = &mul_two_doubles; |
| 940 break; | 975 break; |
| 941 case Token::DIV: | 976 case Token::DIV: |
| 942 function = &div_two_doubles; | 977 function = &div_two_doubles; |
| 943 break; | 978 break; |
| 944 case Token::MOD: | 979 case Token::MOD: |
| 945 function = &mod_two_doubles; | 980 function = &mod_two_doubles; |
| 946 break; | 981 break; |
| 947 default: | 982 default: |
| 948 UNREACHABLE(); | 983 UNREACHABLE(); |
| 949 } | 984 } |
| 950 // Passing true as 2nd parameter indicates that they return an fp value. | 985 // Passing true as 2nd parameter indicates that they return an fp value. |
| 951 return ExternalReference(Redirect(FUNCTION_ADDR(function), FP_RETURN_CALL)); | 986 return ExternalReference(Redirect(isolate, |
| 987 FUNCTION_ADDR(function), |
| 988 FP_RETURN_CALL)); |
| 952 } | 989 } |
| 953 | 990 |
| 954 | 991 |
| 955 ExternalReference ExternalReference::compare_doubles() { | 992 ExternalReference ExternalReference::compare_doubles(Isolate* isolate) { |
| 956 return ExternalReference(Redirect(FUNCTION_ADDR(native_compare_doubles), | 993 return ExternalReference(Redirect(isolate, |
| 994 FUNCTION_ADDR(native_compare_doubles), |
| 957 BUILTIN_CALL)); | 995 BUILTIN_CALL)); |
| 958 } | 996 } |
| 959 | 997 |
| 960 | 998 |
| 961 #ifdef ENABLE_DEBUGGER_SUPPORT | 999 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 962 ExternalReference ExternalReference::debug_break() { | 1000 ExternalReference ExternalReference::debug_break(Isolate* isolate) { |
| 963 return ExternalReference(Redirect(FUNCTION_ADDR(Debug::Break))); | 1001 return ExternalReference(Redirect(isolate, FUNCTION_ADDR(Debug::Break))); |
| 964 } | 1002 } |
| 965 | 1003 |
| 966 | 1004 |
| 967 ExternalReference ExternalReference::debug_step_in_fp_address() { | 1005 ExternalReference ExternalReference::debug_step_in_fp_address( |
| 968 return ExternalReference(Isolate::Current()->debug()->step_in_fp_addr()); | 1006 Isolate* isolate) { |
| 1007 return ExternalReference(isolate->debug()->step_in_fp_addr()); |
| 969 } | 1008 } |
| 970 #endif | 1009 #endif |
| 971 | 1010 |
| 972 | 1011 |
| 973 void PositionsRecorder::RecordPosition(int pos) { | 1012 void PositionsRecorder::RecordPosition(int pos) { |
| 974 ASSERT(pos != RelocInfo::kNoPosition); | 1013 ASSERT(pos != RelocInfo::kNoPosition); |
| 975 ASSERT(pos >= 0); | 1014 ASSERT(pos >= 0); |
| 976 state_.current_position = pos; | 1015 state_.current_position = pos; |
| 977 #ifdef ENABLE_GDB_JIT_INTERFACE | 1016 #ifdef ENABLE_GDB_JIT_INTERFACE |
| 978 if (gdbjit_lineinfo_ != NULL) { | 1017 if (gdbjit_lineinfo_ != NULL) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position); | 1054 assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position); |
| 1016 state_.written_position = state_.current_position; | 1055 state_.written_position = state_.current_position; |
| 1017 written = true; | 1056 written = true; |
| 1018 } | 1057 } |
| 1019 | 1058 |
| 1020 // Return whether something was written. | 1059 // Return whether something was written. |
| 1021 return written; | 1060 return written; |
| 1022 } | 1061 } |
| 1023 | 1062 |
| 1024 } } // namespace v8::internal | 1063 } } // namespace v8::internal |
| OLD | NEW |