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

Side by Side Diff: src/diy-fp.h

Issue 7308004: Extract string->double and double->string conversions for use in the preparser. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: git utd Created 9 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « src/conversions-inl.h ('k') | src/diy-fp.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 return result; 73 return result;
74 } 74 }
75 75
76 void Normalize() { 76 void Normalize() {
77 ASSERT(f_ != 0); 77 ASSERT(f_ != 0);
78 uint64_t f = f_; 78 uint64_t f = f_;
79 int e = e_; 79 int e = e_;
80 80
81 // This method is mainly called for normalizing boundaries. In general 81 // This method is mainly called for normalizing boundaries. In general
82 // boundaries need to be shifted by 10 bits. We thus optimize for this case. 82 // boundaries need to be shifted by 10 bits. We thus optimize for this case.
83 const uint64_t k10MSBits = V8_2PART_UINT64_C(0xFFC00000, 00000000); 83 const uint64_t k10MSBits = static_cast<uint64_t>(0x3FF) << 54;
84 while ((f & k10MSBits) == 0) { 84 while ((f & k10MSBits) == 0) {
85 f <<= 10; 85 f <<= 10;
86 e -= 10; 86 e -= 10;
87 } 87 }
88 while ((f & kUint64MSB) == 0) { 88 while ((f & kUint64MSB) == 0) {
89 f <<= 1; 89 f <<= 1;
90 e--; 90 e--;
91 } 91 }
92 f_ = f; 92 f_ = f;
93 e_ = e; 93 e_ = e;
94 } 94 }
95 95
96 static DiyFp Normalize(const DiyFp& a) { 96 static DiyFp Normalize(const DiyFp& a) {
97 DiyFp result = a; 97 DiyFp result = a;
98 result.Normalize(); 98 result.Normalize();
99 return result; 99 return result;
100 } 100 }
101 101
102 uint64_t f() const { return f_; } 102 uint64_t f() const { return f_; }
103 int e() const { return e_; } 103 int e() const { return e_; }
104 104
105 void set_f(uint64_t new_value) { f_ = new_value; } 105 void set_f(uint64_t new_value) { f_ = new_value; }
106 void set_e(int new_value) { e_ = new_value; } 106 void set_e(int new_value) { e_ = new_value; }
107 107
108 private: 108 private:
109 static const uint64_t kUint64MSB = V8_2PART_UINT64_C(0x80000000, 00000000); 109 static const uint64_t kUint64MSB = static_cast<uint64_t>(1) << 63;
110 110
111 uint64_t f_; 111 uint64_t f_;
112 int e_; 112 int e_;
113 }; 113 };
114 114
115 } } // namespace v8::internal 115 } } // namespace v8::internal
116 116
117 #endif // V8_DIY_FP_H_ 117 #endif // V8_DIY_FP_H_
OLDNEW
« no previous file with comments | « src/conversions-inl.h ('k') | src/diy-fp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698