| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 return condition ? true_value() : false_value(); | 740 return condition ? true_value() : false_value(); |
| 741 } | 741 } |
| 742 | 742 |
| 743 | 743 |
| 744 void Heap::CompletelyClearInstanceofCache() { | 744 void Heap::CompletelyClearInstanceofCache() { |
| 745 set_instanceof_cache_map(the_hole_value()); | 745 set_instanceof_cache_map(the_hole_value()); |
| 746 set_instanceof_cache_function(the_hole_value()); | 746 set_instanceof_cache_function(the_hole_value()); |
| 747 } | 747 } |
| 748 | 748 |
| 749 | 749 |
| 750 MaybeObject* TranscendentalCache::Get(Type type, double input) { | |
| 751 SubCache* cache = caches_[type]; | |
| 752 if (cache == NULL) { | |
| 753 caches_[type] = cache = new SubCache(isolate_, type); | |
| 754 } | |
| 755 return cache->Get(input); | |
| 756 } | |
| 757 | |
| 758 | |
| 759 Address TranscendentalCache::cache_array_address() { | |
| 760 return reinterpret_cast<Address>(caches_); | |
| 761 } | |
| 762 | |
| 763 | |
| 764 double TranscendentalCache::SubCache::Calculate(double input) { | |
| 765 switch (type_) { | |
| 766 case LOG: | |
| 767 return fast_log(input); | |
| 768 default: | |
| 769 UNREACHABLE(); | |
| 770 return 0.0; // Never happens. | |
| 771 } | |
| 772 } | |
| 773 | |
| 774 | |
| 775 MaybeObject* TranscendentalCache::SubCache::Get(double input) { | |
| 776 Converter c; | |
| 777 c.dbl = input; | |
| 778 int hash = Hash(c); | |
| 779 Element e = elements_[hash]; | |
| 780 if (e.in[0] == c.integers[0] && | |
| 781 e.in[1] == c.integers[1]) { | |
| 782 ASSERT(e.output != NULL); | |
| 783 isolate_->counters()->transcendental_cache_hit()->Increment(); | |
| 784 return e.output; | |
| 785 } | |
| 786 double answer = Calculate(input); | |
| 787 isolate_->counters()->transcendental_cache_miss()->Increment(); | |
| 788 Object* heap_number; | |
| 789 { MaybeObject* maybe_heap_number = | |
| 790 isolate_->heap()->AllocateHeapNumber(answer); | |
| 791 if (!maybe_heap_number->ToObject(&heap_number)) return maybe_heap_number; | |
| 792 } | |
| 793 elements_[hash].in[0] = c.integers[0]; | |
| 794 elements_[hash].in[1] = c.integers[1]; | |
| 795 elements_[hash].output = heap_number; | |
| 796 return heap_number; | |
| 797 } | |
| 798 | |
| 799 | |
| 800 AlwaysAllocateScope::AlwaysAllocateScope() { | 750 AlwaysAllocateScope::AlwaysAllocateScope() { |
| 801 // We shouldn't hit any nested scopes, because that requires | 751 // We shouldn't hit any nested scopes, because that requires |
| 802 // non-handle code to call handle code. The code still works but | 752 // non-handle code to call handle code. The code still works but |
| 803 // performance will degrade, so we want to catch this situation | 753 // performance will degrade, so we want to catch this situation |
| 804 // in debug mode. | 754 // in debug mode. |
| 805 Isolate* isolate = Isolate::Current(); | 755 Isolate* isolate = Isolate::Current(); |
| 806 ASSERT(isolate->heap()->always_allocate_scope_depth_ == 0); | 756 ASSERT(isolate->heap()->always_allocate_scope_depth_ == 0); |
| 807 isolate->heap()->always_allocate_scope_depth_++; | 757 isolate->heap()->always_allocate_scope_depth_++; |
| 808 } | 758 } |
| 809 | 759 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 #ifdef DEBUG | 808 #ifdef DEBUG |
| 859 Isolate* isolate = Isolate::Current(); | 809 Isolate* isolate = Isolate::Current(); |
| 860 isolate->heap()->disallow_allocation_failure_ = old_state_; | 810 isolate->heap()->disallow_allocation_failure_ = old_state_; |
| 861 #endif | 811 #endif |
| 862 } | 812 } |
| 863 | 813 |
| 864 | 814 |
| 865 } } // namespace v8::internal | 815 } } // namespace v8::internal |
| 866 | 816 |
| 867 #endif // V8_HEAP_INL_H_ | 817 #endif // V8_HEAP_INL_H_ |
| OLD | NEW |