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

Side by Side Diff: src/utils.h

Issue 196133017: Experimental parser: merge r19949 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 9 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/unique.h ('k') | src/utils.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 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 x >>= 8; 98 x >>= 8;
99 } 99 }
100 if (x & 0xf0) { 100 if (x & 0xf0) {
101 nibble += 4; 101 nibble += 4;
102 x >>= 4; 102 x >>= 4;
103 } 103 }
104 return nibble + msb4[x]; 104 return nibble + msb4[x];
105 } 105 }
106 106
107 107
108 // Magic numbers for integer division.
109 // These are kind of 2's complement reciprocal of the divisors.
110 // Details and proofs can be found in:
111 // - Hacker's Delight, Henry S. Warren, Jr.
112 // - The PowerPC Compiler Writer’s Guide
113 // and probably many others.
114 // See details in the implementation of the algorithm in
115 // lithium-codegen-arm.cc : LCodeGen::TryEmitSignedIntegerDivisionByConstant().
116 struct DivMagicNumbers {
117 unsigned M;
118 unsigned s;
119 };
120
121 const DivMagicNumbers InvalidDivMagicNumber= {0, 0};
122 const DivMagicNumbers DivMagicNumberFor3 = {0x55555556, 0};
123 const DivMagicNumbers DivMagicNumberFor5 = {0x66666667, 1};
124 const DivMagicNumbers DivMagicNumberFor7 = {0x92492493, 2};
125 const DivMagicNumbers DivMagicNumberFor9 = {0x38e38e39, 1};
126 const DivMagicNumbers DivMagicNumberFor11 = {0x2e8ba2e9, 1};
127 const DivMagicNumbers DivMagicNumberFor25 = {0x51eb851f, 3};
128 const DivMagicNumbers DivMagicNumberFor125 = {0x10624dd3, 3};
129 const DivMagicNumbers DivMagicNumberFor625 = {0x68db8bad, 8};
130
131 const DivMagicNumbers DivMagicNumberFor(int32_t divisor);
132
133
134 // The C++ standard leaves the semantics of '>>' undefined for 108 // The C++ standard leaves the semantics of '>>' undefined for
135 // negative signed operands. Most implementations do the right thing, 109 // negative signed operands. Most implementations do the right thing,
136 // though. 110 // though.
137 inline int ArithmeticShiftRight(int x, int s) { 111 inline int ArithmeticShiftRight(int x, int s) {
138 return x >> s; 112 return x >> s;
139 } 113 }
140 114
141 115
142 // Compute the 0-relative offset of some absolute value x of type T. 116 // Compute the 0-relative offset of some absolute value x of type T.
143 // This allows conversion of Addresses and integral types into 117 // This allows conversion of Addresses and integral types into
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 } 250 }
277 251
278 252
279 inline int StrLength(const char* string) { 253 inline int StrLength(const char* string) {
280 size_t length = strlen(string); 254 size_t length = strlen(string);
281 ASSERT(length == static_cast<size_t>(static_cast<int>(length))); 255 ASSERT(length == static_cast<size_t>(static_cast<int>(length)));
282 return static_cast<int>(length); 256 return static_cast<int>(length);
283 } 257 }
284 258
285 259
260 // TODO(svenpanne) Clean up the whole power-of-2 mess.
261 inline int32_t WhichPowerOf2Abs(int32_t x) {
262 return (x == kMinInt) ? 31 : WhichPowerOf2(Abs(x));
263 }
264
265
286 // ---------------------------------------------------------------------------- 266 // ----------------------------------------------------------------------------
287 // BitField is a help template for encoding and decode bitfield with 267 // BitField is a help template for encoding and decode bitfield with
288 // unsigned content. 268 // unsigned content.
289 269
290 template<class T, int shift, int size, class U> 270 template<class T, int shift, int size, class U>
291 class BitFieldBase { 271 class BitFieldBase {
292 public: 272 public:
293 // A type U mask of bit field. To use all bits of a type U of x bits 273 // A type U mask of bit field. To use all bits of a type U of x bits
294 // in a bitfield without compiler warnings we have to compute 2^x 274 // in a bitfield without compiler warnings we have to compute 2^x
295 // without using a shift count of x in the computation. 275 // without using a shift count of x in the computation.
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 iterator end() { return container_->end(); } 1202 iterator end() { return container_->end(); }
1223 reverse_iterator rbegin() { return container_->rbegin(); } 1203 reverse_iterator rbegin() { return container_->rbegin(); }
1224 reverse_iterator rend() { return container_->rend(); } 1204 reverse_iterator rend() { return container_->rend(); }
1225 private: 1205 private:
1226 C* container_; 1206 C* container_;
1227 }; 1207 };
1228 1208
1229 } } // namespace v8::internal 1209 } } // namespace v8::internal
1230 1210
1231 #endif // V8_UTILS_H_ 1211 #endif // V8_UTILS_H_
OLDNEW
« no previous file with comments | « src/unique.h ('k') | src/utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698