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

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

Issue 1190943002: Version 4.5.60.1 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@4.5.60
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 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after
2307 // We expect no instantiated function objects or contexts. 2311 // We expect no instantiated function objects or contexts.
2308 CHECK(!obj->IsJSFunction() && !obj->IsContext()); 2312 CHECK(!obj->IsJSFunction() && !obj->IsContext());
2309 2313
2310 SerializeGeneric(obj, how_to_code, where_to_point); 2314 SerializeGeneric(obj, how_to_code, where_to_point);
2311 } 2315 }
2312 2316
2313 2317
2314 void CodeSerializer::SerializeGeneric(HeapObject* heap_object, 2318 void CodeSerializer::SerializeGeneric(HeapObject* heap_object,
2315 HowToCode how_to_code, 2319 HowToCode how_to_code,
2316 WhereToPoint where_to_point) { 2320 WhereToPoint where_to_point) {
2317 int string_hash = String::kEmptyHashField; 2321 if (heap_object->IsInternalizedString()) num_internalized_strings_++;
2318 if (heap_object->IsString()) {
2319 String* string = String::cast(heap_object);
2320 if (string->IsInternalizedString()) num_internalized_strings_++;
2321 // Temporarily clear string hash.
2322 string_hash = string->hash_field();
2323 string->set_hash_field(String::kEmptyHashField);
2324 }
2325 2322
2326 // Object has not yet been serialized. Serialize it here. 2323 // Object has not yet been serialized. Serialize it here.
2327 ObjectSerializer serializer(this, heap_object, sink_, how_to_code, 2324 ObjectSerializer serializer(this, heap_object, sink_, how_to_code,
2328 where_to_point); 2325 where_to_point);
2329 serializer.Serialize(); 2326 serializer.Serialize();
2330
2331 if (string_hash != String::kEmptyHashField) {
2332 // Restore string hash.
2333 String::cast(heap_object)->set_hash_field(String::kEmptyHashField);
2334 }
2335 } 2327 }
2336 2328
2337 2329
2338 void CodeSerializer::SerializeBuiltin(int builtin_index, HowToCode how_to_code, 2330 void CodeSerializer::SerializeBuiltin(int builtin_index, HowToCode how_to_code,
2339 WhereToPoint where_to_point) { 2331 WhereToPoint where_to_point) {
2340 DCHECK((how_to_code == kPlain && where_to_point == kStartOfObject) || 2332 DCHECK((how_to_code == kPlain && where_to_point == kStartOfObject) ||
2341 (how_to_code == kPlain && where_to_point == kInnerPointer) || 2333 (how_to_code == kPlain && where_to_point == kInnerPointer) ||
2342 (how_to_code == kFromCode && where_to_point == kInnerPointer)); 2334 (how_to_code == kFromCode && where_to_point == kInnerPointer));
2343 DCHECK_LT(builtin_index, Builtins::builtin_count); 2335 DCHECK_LT(builtin_index, Builtins::builtin_count);
2344 DCHECK_LE(0, builtin_index); 2336 DCHECK_LE(0, builtin_index);
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
2712 SerializedCodeData* scd = new SerializedCodeData(cached_data); 2704 SerializedCodeData* scd = new SerializedCodeData(cached_data);
2713 SanityCheckResult r = scd->SanityCheck(isolate, source); 2705 SanityCheckResult r = scd->SanityCheck(isolate, source);
2714 if (r == CHECK_SUCCESS) return scd; 2706 if (r == CHECK_SUCCESS) return scd;
2715 cached_data->Reject(); 2707 cached_data->Reject();
2716 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); 2708 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r);
2717 delete scd; 2709 delete scd;
2718 return NULL; 2710 return NULL;
2719 } 2711 }
2720 } // namespace internal 2712 } // namespace internal
2721 } // namespace v8 2713 } // 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