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

Side by Side Diff: src/objects.cc

Issue 762773002: Don't use ConsStringIterator to compute string hashes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 <sstream> 5 #include <sstream>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/accessors.h" 9 #include "src/accessors.h"
10 #include "src/allocation-site-scopes.h" 10 #include "src/allocation-site-scopes.h"
(...skipping 9265 matching lines...) Expand 10 before | Expand all | Expand 10 after
9276 if (is_index) is_index = hasher.UpdateIndex(c); 9276 if (is_index) is_index = hasher.UpdateIndex(c);
9277 } 9277 }
9278 } 9278 }
9279 *utf16_length_out = static_cast<int>(utf16_length); 9279 *utf16_length_out = static_cast<int>(utf16_length);
9280 // Must set length here so that hash computation is correct. 9280 // Must set length here so that hash computation is correct.
9281 hasher.length_ = utf16_length; 9281 hasher.length_ = utf16_length;
9282 return hasher.GetHashField(); 9282 return hasher.GetHashField();
9283 } 9283 }
9284 9284
9285 9285
9286 void IteratingStringHasher::VisitConsString(ConsString* cons_string) {
9287 int length = cons_string->length();
9288 uint16_t* buffer = cons_string->GetIsolate()->cons_string_hashing_buffer();
9289 if (cons_string->HasOnlyOneByteChars()) {
9290 uint8_t* one_byte_buffer = reinterpret_cast<uint8_t*>(buffer);
9291 String::WriteToFlat(cons_string, one_byte_buffer, 0, length);
Yang 2014/11/26 10:46:15 Wouldn't this cause OOB writes for large strings?
9292 AddCharacters(one_byte_buffer, length);
9293 } else {
9294 String::WriteToFlat(cons_string, buffer, 0, length);
9295 AddCharacters(buffer, length);
9296 }
9297 }
9298
9299
9286 void String::PrintOn(FILE* file) { 9300 void String::PrintOn(FILE* file) {
9287 int length = this->length(); 9301 int length = this->length();
9288 for (int i = 0; i < length; i++) { 9302 for (int i = 0; i < length; i++) {
9289 PrintF(file, "%c", Get(i)); 9303 PrintF(file, "%c", Get(i));
9290 } 9304 }
9291 } 9305 }
9292 9306
9293 9307
9294 inline static uint32_t ObjectAddressForHashing(Object* object) { 9308 inline static uint32_t ObjectAddressForHashing(Object* object) {
9295 uint32_t value = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(object)); 9309 uint32_t value = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(object));
(...skipping 7512 matching lines...) Expand 10 before | Expand all | Expand 10 after
16808 Handle<DependentCode> codes = 16822 Handle<DependentCode> codes =
16809 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), 16823 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()),
16810 DependentCode::kPropertyCellChangedGroup, 16824 DependentCode::kPropertyCellChangedGroup,
16811 info->object_wrapper()); 16825 info->object_wrapper());
16812 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); 16826 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes);
16813 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( 16827 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add(
16814 cell, info->zone()); 16828 cell, info->zone());
16815 } 16829 }
16816 16830
16817 } } // namespace v8::internal 16831 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698