Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: src/heap.h

Issue 652041: IA32: Native access to TranscendentalCache for sin/cos. (Closed)
Patch Set: Updated to head. Removed dead code. Ignore first patch. Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 1592 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 1603
1604 private: 1604 private:
1605 inline Object* Get(double input) { 1605 inline Object* Get(double input) {
1606 Converter c; 1606 Converter c;
1607 c.dbl = input; 1607 c.dbl = input;
1608 int hash = Hash(c); 1608 int hash = Hash(c);
1609 Element e = elements_[hash]; 1609 Element e = elements_[hash];
1610 if (e.in[0] == c.integers[0] && 1610 if (e.in[0] == c.integers[0] &&
1611 e.in[1] == c.integers[1]) { 1611 e.in[1] == c.integers[1]) {
1612 ASSERT(e.output != NULL); 1612 ASSERT(e.output != NULL);
1613 Counters::transcendental_cache_hit.Increment();
1613 return e.output; 1614 return e.output;
1614 } 1615 }
1615 double answer = Calculate(input); 1616 double answer = Calculate(input);
1616 Object* heap_number = Heap::AllocateHeapNumber(answer); 1617 Object* heap_number = Heap::AllocateHeapNumber(answer);
1617 if (!heap_number->IsFailure()) { 1618 if (!heap_number->IsFailure()) {
1618 elements_[hash].in[0] = c.integers[0]; 1619 elements_[hash].in[0] = c.integers[0];
1619 elements_[hash].in[1] = c.integers[1]; 1620 elements_[hash].in[1] = c.integers[1];
1620 elements_[hash].output = heap_number; 1621 elements_[hash].output = heap_number;
1621 } 1622 }
1623 Counters::transcendental_cache_miss.Increment();
1622 return heap_number; 1624 return heap_number;
1623 } 1625 }
1624 1626
1625 inline double Calculate(double input) { 1627 inline double Calculate(double input) {
1626 switch (type_) { 1628 switch (type_) {
1627 case ACOS: 1629 case ACOS:
1628 return acos(input); 1630 return acos(input);
1629 case ASIN: 1631 case ASIN:
1630 return asin(input); 1632 return asin(input);
1631 case ATAN: 1633 case ATAN:
(...skipping 20 matching lines...) Expand all
1652 union Converter { 1654 union Converter {
1653 double dbl; 1655 double dbl;
1654 uint32_t integers[2]; 1656 uint32_t integers[2];
1655 }; 1657 };
1656 inline static int Hash(const Converter& c) { 1658 inline static int Hash(const Converter& c) {
1657 uint32_t hash = (c.integers[0] ^ c.integers[1]); 1659 uint32_t hash = (c.integers[0] ^ c.integers[1]);
1658 hash ^= hash >> 16; 1660 hash ^= hash >> 16;
1659 hash ^= hash >> 8; 1661 hash ^= hash >> 8;
1660 return (hash & (kCacheSize - 1)); 1662 return (hash & (kCacheSize - 1));
1661 } 1663 }
1664
1665 static Address cache_array_address() {
1666 // Used to create an external reference.
1667 return reinterpret_cast<Address>(caches_);
1668 }
1669
1670 // Allow access to the caches_ array as an ExternalReference.
1671 friend class ExternalReference;
1672 // Inline implementation of the caching.
1673 friend class TranscendentalCacheStub;
1674
1662 static TranscendentalCache* caches_[kNumberOfCaches]; 1675 static TranscendentalCache* caches_[kNumberOfCaches];
1663 Element elements_[kCacheSize]; 1676 Element elements_[kCacheSize];
1664 Type type_; 1677 Type type_;
1665 }; 1678 };
1666 1679
1667 1680
1668 // External strings table is a place where all external strings are 1681 // External strings table is a place where all external strings are
1669 // registered. We need to keep track of such strings to properly 1682 // registered. We need to keep track of such strings to properly
1670 // finalize them. 1683 // finalize them.
1671 class ExternalStringTable : public AllStatic { 1684 class ExternalStringTable : public AllStatic {
(...skipping 22 matching lines...) Expand all
1694 1707
1695 // To speed up scavenge collections new space string are kept 1708 // To speed up scavenge collections new space string are kept
1696 // separate from old space strings. 1709 // separate from old space strings.
1697 static List<Object*> new_space_strings_; 1710 static List<Object*> new_space_strings_;
1698 static List<Object*> old_space_strings_; 1711 static List<Object*> old_space_strings_;
1699 }; 1712 };
1700 1713
1701 } } // namespace v8::internal 1714 } } // namespace v8::internal
1702 1715
1703 #endif // V8_HEAP_H_ 1716 #endif // V8_HEAP_H_
OLDNEW
« no previous file with comments | « src/codegen.cc ('k') | src/ia32/assembler-ia32.h » ('j') | src/ia32/codegen-ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698