Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/ast.h" | 8 #include "src/ast.h" |
| 9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
| 10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
| (...skipping 5285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5296 Handle<String> source(String::cast(script()->source())); | 5296 Handle<String> source(String::cast(script()->source())); |
| 5297 | 5297 |
| 5298 raw_strings = new (zone()) ZoneList<Expression*>(total, zone()); | 5298 raw_strings = new (zone()) ZoneList<Expression*>(total, zone()); |
| 5299 | 5299 |
| 5300 int num_hash_chars = (total - 1) * 3; | 5300 int num_hash_chars = (total - 1) * 3; |
| 5301 for (int index = 0; index < total; ++index) { | 5301 for (int index = 0; index < total; ++index) { |
| 5302 // Allow about length * 4 to handle most UTF8 sequences. | 5302 // Allow about length * 4 to handle most UTF8 sequences. |
| 5303 num_hash_chars += lengths->at(index) * 4; | 5303 num_hash_chars += lengths->at(index) * 4; |
| 5304 } | 5304 } |
| 5305 | 5305 |
| 5306 Vector<uint8_t> hash_string = Vector<uint8_t>::New(num_hash_chars); | 5306 Vector<uint8_t> hash_string = Vector<uint8_t>::New(num_hash_chars); |
|
arv (Not doing code reviews)
2014/11/21 06:12:49
One thing that seems strange to me is that we have
| |
| 5307 num_hash_chars = 0; | 5307 num_hash_chars = 0; |
| 5308 | 5308 |
| 5309 for (int index = 0; index < total; ++index) { | 5309 for (int index = 0; index < total; ++index) { |
| 5310 int span_start = cooked_strings->at(index)->position() + 1; | 5310 int span_start = cooked_strings->at(index)->position() + 1; |
| 5311 int span_end = lengths->at(index) - 1; | 5311 int span_end = lengths->at(index) - 1; |
| 5312 int length; | 5312 int length; |
| 5313 int to_index = 0; | 5313 int to_index = 0; |
| 5314 | 5314 |
| 5315 if (index) { | 5315 if (index) { |
| 5316 hash_string[num_hash_chars++] = '$'; | 5316 hash_string[num_hash_chars++] = '$'; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 5329 if (ch == '\r') { | 5329 if (ch == '\r') { |
| 5330 ch = '\n'; | 5330 ch = '\n'; |
| 5331 if (from_index + 1 < length && raw_chars[from_index + 1] == '\n') { | 5331 if (from_index + 1 < length && raw_chars[from_index + 1] == '\n') { |
| 5332 ++from_index; | 5332 ++from_index; |
| 5333 } | 5333 } |
| 5334 } | 5334 } |
| 5335 hash_string[num_hash_chars++] = ch; | 5335 hash_string[num_hash_chars++] = ch; |
| 5336 raw_chars[to_index++] = ch; | 5336 raw_chars[to_index++] = ch; |
| 5337 } | 5337 } |
| 5338 | 5338 |
| 5339 const AstRawString* raw_str = ast_value_factory()->GetOneByteString( | 5339 unibrow::Utf8Decoder<256> decoder(raw_chars.get(), to_index); |
|
Dmitry Lomov (no reviews)
2014/11/25 13:16:21
Use cached decoder from isoalte()->unicode_cache()
caitp (gmail)
2014/11/26 14:12:01
Should this be cached outside of the loop? But, do
| |
| 5340 OneByteVector(raw_chars.get(), to_index)); | 5340 int utf16_length = decoder.Utf16Length(); |
| 5341 uc16* utf16_buffer = zone()->NewArray<uc16>(utf16_length); | |
| 5342 to_index = decoder.WriteUtf16(utf16_buffer, utf16_length); | |
| 5343 const AstRawString* raw_str = ast_value_factory()->GetTwoByteString( | |
| 5344 Vector<const uint16_t>(reinterpret_cast<const uint16_t*>(utf16_buffer), | |
| 5345 to_index)); | |
| 5341 Literal* raw_lit = factory()->NewStringLiteral(raw_str, span_start - 1); | 5346 Literal* raw_lit = factory()->NewStringLiteral(raw_str, span_start - 1); |
| 5342 raw_strings->Add(raw_lit, zone()); | 5347 raw_strings->Add(raw_lit, zone()); |
| 5343 } | 5348 } |
| 5344 | 5349 |
| 5345 hash_string.Truncate(num_hash_chars); | 5350 hash_string.Truncate(num_hash_chars); |
| 5346 int utf16_length; | 5351 int utf16_length; |
| 5347 *hash = StringHasher::ComputeUtf8Hash(Vector<const char>::cast(hash_string), | 5352 *hash = StringHasher::ComputeUtf8Hash(Vector<const char>::cast(hash_string), |
| 5348 num_hash_chars, &utf16_length); | 5353 num_hash_chars, &utf16_length); |
| 5349 hash_string.Dispose(); | 5354 hash_string.Dispose(); |
| 5350 | 5355 |
| 5351 return raw_strings; | 5356 return raw_strings; |
| 5352 } | 5357 } |
| 5353 } } // namespace v8::internal | 5358 } } // namespace v8::internal |
| OLD | NEW |