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

Side by Side Diff: src/objects.cc

Issue 769453002: add fast path for hashing small cons strings (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase 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 | « no previous file | 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 9280 matching lines...) Expand 10 before | Expand all | Expand 10 after
9291 } 9291 }
9292 } 9292 }
9293 *utf16_length_out = static_cast<int>(utf16_length); 9293 *utf16_length_out = static_cast<int>(utf16_length);
9294 // Must set length here so that hash computation is correct. 9294 // Must set length here so that hash computation is correct.
9295 hasher.length_ = utf16_length; 9295 hasher.length_ = utf16_length;
9296 return hasher.GetHashField(); 9296 return hasher.GetHashField();
9297 } 9297 }
9298 9298
9299 9299
9300 void IteratingStringHasher::VisitConsString(ConsString* cons_string) { 9300 void IteratingStringHasher::VisitConsString(ConsString* cons_string) {
9301 // Run small ConsStrings through ConsStringIterator.
9302 if (cons_string->length() < 64) {
9303 ConsStringIterator iter(cons_string);
9304 int offset;
9305 String* string;
9306 while (nullptr != (string = iter.Next(&offset))) {
9307 DCHECK_EQ(0, offset);
9308 String::VisitFlat(this, string, 0);
9309 }
9310 return;
9311 }
9312 // Slow case.
9301 const int max_length = String::kMaxHashCalcLength; 9313 const int max_length = String::kMaxHashCalcLength;
9302 int length = std::min(cons_string->length(), max_length); 9314 int length = std::min(cons_string->length(), max_length);
9303 if (cons_string->HasOnlyOneByteChars()) { 9315 if (cons_string->HasOnlyOneByteChars()) {
9304 uint8_t* buffer = new uint8_t[length]; 9316 uint8_t* buffer = new uint8_t[length];
9305 String::WriteToFlat(cons_string, buffer, 0, length); 9317 String::WriteToFlat(cons_string, buffer, 0, length);
9306 AddCharacters(buffer, length); 9318 AddCharacters(buffer, length);
9307 delete[] buffer; 9319 delete[] buffer;
9308 } else { 9320 } else {
9309 uint16_t* buffer = new uint16_t[length]; 9321 uint16_t* buffer = new uint16_t[length];
9310 String::WriteToFlat(cons_string, buffer, 0, length); 9322 String::WriteToFlat(cons_string, buffer, 0, length);
(...skipping 7526 matching lines...) Expand 10 before | Expand all | Expand 10 after
16837 Handle<DependentCode> codes = 16849 Handle<DependentCode> codes =
16838 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), 16850 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()),
16839 DependentCode::kPropertyCellChangedGroup, 16851 DependentCode::kPropertyCellChangedGroup,
16840 info->object_wrapper()); 16852 info->object_wrapper());
16841 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); 16853 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes);
16842 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( 16854 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add(
16843 cell, info->zone()); 16855 cell, info->zone());
16844 } 16856 }
16845 16857
16846 } } // namespace v8::internal 16858 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698