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

Side by Side Diff: src/snapshot/serialize.cc

Issue 1186173004: Revert of Serializer: clear string hash for code serializer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « src/snapshot/serialize.h ('k') | no next file » | 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 // 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/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/base/platform/platform.h" 9 #include "src/base/platform/platform.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 return handle(string_, isolate); 707 return handle(string_, isolate);
708 } 708 }
709 709
710 String* string_; 710 String* string_;
711 uint32_t hash_; 711 uint32_t hash_;
712 }; 712 };
713 713
714 714
715 HeapObject* Deserializer::PostProcessNewObject(HeapObject* obj, int space) { 715 HeapObject* Deserializer::PostProcessNewObject(HeapObject* obj, int space) {
716 if (deserializing_user_code()) { 716 if (deserializing_user_code()) {
717 if (obj->IsInternalizedString()) { 717 if (obj->IsString()) {
718 // Canonicalize the internalized string. If it already exists in the
719 // string table, set it to forward to the existing one.
720 DisallowHeapAllocation no_gc;
721 String* string = String::cast(obj); 718 String* string = String::cast(obj);
722 HandleScope scope(isolate_); 719 // Uninitialize hash field as the hash seed may have changed.
723 StringTableInsertionKey key(string); 720 string->set_hash_field(String::kEmptyHashField);
724 String* canonical = *StringTable::LookupKey(isolate_, &key); 721 if (string->IsInternalizedString()) {
725 string->SetForwardedInternalizedString(canonical); 722 // Canonicalize the internalized string. If it already exists in the
726 return canonical; 723 // string table, set it to forward to the existing one.
724 DisallowHeapAllocation no_gc;
725 HandleScope scope(isolate_);
726 StringTableInsertionKey key(string);
727 String* canonical = *StringTable::LookupKey(isolate_, &key);
728 string->SetForwardedInternalizedString(canonical);
729 return canonical;
730 }
727 } else if (obj->IsScript()) { 731 } else if (obj->IsScript()) {
728 // Assign a new script id to avoid collision. 732 // Assign a new script id to avoid collision.
729 Script::cast(obj)->set_id(isolate_->heap()->NextScriptId()); 733 Script::cast(obj)->set_id(isolate_->heap()->NextScriptId());
730 } else { 734 } else {
731 DCHECK(CanBeDeferred(obj)); 735 DCHECK(CanBeDeferred(obj));
732 } 736 }
733 } 737 }
734 if (obj->IsAllocationSite()) { 738 if (obj->IsAllocationSite()) {
735 DCHECK(obj->IsAllocationSite()); 739 DCHECK(obj->IsAllocationSite());
736 // Allocation sites are present in the snapshot, and must be linked into 740 // Allocation sites are present in the snapshot, and must be linked into
(...skipping 1556 matching lines...) Expand 10 before | Expand all | Expand 10 after
2293 // We expect no instantiated function objects or contexts. 2297 // We expect no instantiated function objects or contexts.
2294 CHECK(!obj->IsJSFunction() && !obj->IsContext()); 2298 CHECK(!obj->IsJSFunction() && !obj->IsContext());
2295 2299
2296 SerializeGeneric(obj, how_to_code, where_to_point); 2300 SerializeGeneric(obj, how_to_code, where_to_point);
2297 } 2301 }
2298 2302
2299 2303
2300 void CodeSerializer::SerializeGeneric(HeapObject* heap_object, 2304 void CodeSerializer::SerializeGeneric(HeapObject* heap_object,
2301 HowToCode how_to_code, 2305 HowToCode how_to_code,
2302 WhereToPoint where_to_point) { 2306 WhereToPoint where_to_point) {
2303 int string_hash = String::kEmptyHashField; 2307 if (heap_object->IsInternalizedString()) num_internalized_strings_++;
2304 if (heap_object->IsString()) {
2305 String* string = String::cast(heap_object);
2306 if (string->IsInternalizedString()) num_internalized_strings_++;
2307 // Temporarily clear string hash.
2308 string_hash = string->hash_field();
2309 string->set_hash_field(String::kEmptyHashField);
2310 }
2311 2308
2312 // Object has not yet been serialized. Serialize it here. 2309 // Object has not yet been serialized. Serialize it here.
2313 ObjectSerializer serializer(this, heap_object, sink_, how_to_code, 2310 ObjectSerializer serializer(this, heap_object, sink_, how_to_code,
2314 where_to_point); 2311 where_to_point);
2315 serializer.Serialize(); 2312 serializer.Serialize();
2316
2317 if (string_hash != String::kEmptyHashField) {
2318 // Restore string hash.
2319 String::cast(heap_object)->set_hash_field(String::kEmptyHashField);
2320 }
2321 } 2313 }
2322 2314
2323 2315
2324 void CodeSerializer::SerializeBuiltin(int builtin_index, HowToCode how_to_code, 2316 void CodeSerializer::SerializeBuiltin(int builtin_index, HowToCode how_to_code,
2325 WhereToPoint where_to_point) { 2317 WhereToPoint where_to_point) {
2326 DCHECK((how_to_code == kPlain && where_to_point == kStartOfObject) || 2318 DCHECK((how_to_code == kPlain && where_to_point == kStartOfObject) ||
2327 (how_to_code == kPlain && where_to_point == kInnerPointer) || 2319 (how_to_code == kPlain && where_to_point == kInnerPointer) ||
2328 (how_to_code == kFromCode && where_to_point == kInnerPointer)); 2320 (how_to_code == kFromCode && where_to_point == kInnerPointer));
2329 DCHECK_LT(builtin_index, Builtins::builtin_count); 2321 DCHECK_LT(builtin_index, Builtins::builtin_count);
2330 DCHECK_LE(0, builtin_index); 2322 DCHECK_LE(0, builtin_index);
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
2698 SerializedCodeData* scd = new SerializedCodeData(cached_data); 2690 SerializedCodeData* scd = new SerializedCodeData(cached_data);
2699 SanityCheckResult r = scd->SanityCheck(isolate, source); 2691 SanityCheckResult r = scd->SanityCheck(isolate, source);
2700 if (r == CHECK_SUCCESS) return scd; 2692 if (r == CHECK_SUCCESS) return scd;
2701 cached_data->Reject(); 2693 cached_data->Reject();
2702 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); 2694 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r);
2703 delete scd; 2695 delete scd;
2704 return NULL; 2696 return NULL;
2705 } 2697 }
2706 } // namespace internal 2698 } // namespace internal
2707 } // namespace v8 2699 } // namespace v8
OLDNEW
« no previous file with comments | « src/snapshot/serialize.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698