| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 160 } |
| 161 if (!has_error()) { | 161 if (!has_error()) { |
| 162 symbol_store_.WriteTo( | 162 symbol_store_.WriteTo( |
| 163 Vector<byte>::cast(data.SubVector(symbol_start, total_size))); | 163 Vector<byte>::cast(data.SubVector(symbol_start, total_size))); |
| 164 } | 164 } |
| 165 return data; | 165 return data; |
| 166 } | 166 } |
| 167 | 167 |
| 168 | 168 |
| 169 void CompleteParserRecorder::WriteNumber(int number) { | 169 void CompleteParserRecorder::WriteNumber(int number) { |
| 170 // Split the number into chunks of 7 bits. Write them one after another (the | |
| 171 // most significant first). Use the MSB of each byte for signalling that the | |
| 172 // number continues. See ScriptDataImpl::ReadNumber for the reading side. | |
| 173 ASSERT(number >= 0); | 170 ASSERT(number >= 0); |
| 174 | 171 |
| 175 int mask = (1 << 28) - 1; | 172 int mask = (1 << 28) - 1; |
| 176 int i = 28; | 173 for (int i = 28; i > 0; i -= 7) { |
| 177 // 26 million symbols ought to be enough for anybody. | 174 if (number > mask) { |
| 178 ASSERT(number <= mask); | 175 symbol_store_.Add(static_cast<byte>(number >> i) | 0x80u); |
| 179 while (number < mask) { | 176 number &= mask; |
| 177 } |
| 180 mask >>= 7; | 178 mask >>= 7; |
| 181 i -= 7; | |
| 182 } | 179 } |
| 183 while (i > 0) { | |
| 184 symbol_store_.Add(static_cast<byte>(number >> i) | 0x80u); | |
| 185 number &= mask; | |
| 186 mask >>= 7; | |
| 187 i -= 7; | |
| 188 } | |
| 189 ASSERT(number < (1 << 7)); | |
| 190 symbol_store_.Add(static_cast<byte>(number)); | 180 symbol_store_.Add(static_cast<byte>(number)); |
| 191 } | 181 } |
| 192 | 182 |
| 193 | 183 |
| 194 } } // namespace v8::internal. | 184 } } // namespace v8::internal. |
| OLD | NEW |