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

Side by Side Diff: src/serialize.cc

Issue 413663003: Add and move DisallowHeapAllocation scope. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 void Deserializer::DeserializePartial(Isolate* isolate, Object** root) { 785 void Deserializer::DeserializePartial(Isolate* isolate, Object** root) {
786 isolate_ = isolate; 786 isolate_ = isolate;
787 for (int i = NEW_SPACE; i < kNumberOfSpaces; i++) { 787 for (int i = NEW_SPACE; i < kNumberOfSpaces; i++) {
788 ASSERT(reservations_[i] != kUninitializedReservation); 788 ASSERT(reservations_[i] != kUninitializedReservation);
789 } 789 }
790 isolate_->heap()->ReserveSpace(reservations_, &high_water_[0]); 790 isolate_->heap()->ReserveSpace(reservations_, &high_water_[0]);
791 if (external_reference_decoder_ == NULL) { 791 if (external_reference_decoder_ == NULL) {
792 external_reference_decoder_ = new ExternalReferenceDecoder(isolate); 792 external_reference_decoder_ = new ExternalReferenceDecoder(isolate);
793 } 793 }
794 794
795 DisallowHeapAllocation no_gc;
796
795 // Keep track of the code space start and end pointers in case new 797 // Keep track of the code space start and end pointers in case new
796 // code objects were unserialized 798 // code objects were unserialized
797 OldSpace* code_space = isolate_->heap()->code_space(); 799 OldSpace* code_space = isolate_->heap()->code_space();
798 Address start_address = code_space->top(); 800 Address start_address = code_space->top();
799 VisitPointer(root); 801 VisitPointer(root);
800 802
801 // There's no code deserialized here. If this assert fires 803 // There's no code deserialized here. If this assert fires
802 // then that's changed and logging should be added to notify 804 // then that's changed and logging should be added to notify
803 // the profiler et al of the new code. 805 // the profiler et al of the new code.
804 CHECK_EQ(start_address, code_space->top()); 806 CHECK_EQ(start_address, code_space->top());
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 } 1904 }
1903 1905
1904 1906
1905 ScriptData* CodeSerializer::Serialize(Isolate* isolate, 1907 ScriptData* CodeSerializer::Serialize(Isolate* isolate,
1906 Handle<SharedFunctionInfo> info, 1908 Handle<SharedFunctionInfo> info,
1907 Handle<String> source) { 1909 Handle<String> source) {
1908 // Serialize code object. 1910 // Serialize code object.
1909 List<byte> payload; 1911 List<byte> payload;
1910 ListSnapshotSink list_sink(&payload); 1912 ListSnapshotSink list_sink(&payload);
1911 CodeSerializer cs(isolate, &list_sink, *source); 1913 CodeSerializer cs(isolate, &list_sink, *source);
1914 DisallowHeapAllocation no_gc;
1912 Object** location = Handle<Object>::cast(info).location(); 1915 Object** location = Handle<Object>::cast(info).location();
1913 cs.VisitPointer(location); 1916 cs.VisitPointer(location);
1914 cs.Pad(); 1917 cs.Pad();
1915 1918
1916 SerializedCodeData data(&payload, &cs); 1919 SerializedCodeData data(&payload, &cs);
1917 return data.GetScriptData(); 1920 return data.GetScriptData();
1918 } 1921 }
1919 1922
1920 1923
1921 void CodeSerializer::SerializeObject(Object* o, HowToCode how_to_code, 1924 void CodeSerializer::SerializeObject(Object* o, HowToCode how_to_code,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
2016 Handle<String> source) { 2019 Handle<String> source) {
2017 base::ElapsedTimer timer; 2020 base::ElapsedTimer timer;
2018 if (FLAG_profile_deserialization) timer.Start(); 2021 if (FLAG_profile_deserialization) timer.Start();
2019 SerializedCodeData scd(data, *source); 2022 SerializedCodeData scd(data, *source);
2020 SnapshotByteSource payload(scd.Payload(), scd.PayloadLength()); 2023 SnapshotByteSource payload(scd.Payload(), scd.PayloadLength());
2021 Deserializer deserializer(&payload); 2024 Deserializer deserializer(&payload);
2022 STATIC_ASSERT(NEW_SPACE == 0); 2025 STATIC_ASSERT(NEW_SPACE == 0);
2023 for (int i = NEW_SPACE; i <= PROPERTY_CELL_SPACE; i++) { 2026 for (int i = NEW_SPACE; i <= PROPERTY_CELL_SPACE; i++) {
2024 deserializer.set_reservation(i, scd.GetReservation(i)); 2027 deserializer.set_reservation(i, scd.GetReservation(i));
2025 } 2028 }
2026 DisallowHeapAllocation no_gc;
2027 2029
2028 // Prepare and register list of attached objects. 2030 // Prepare and register list of attached objects.
2029 Vector<Object*> attached_objects = Vector<Object*>::New(1); 2031 Vector<Object*> attached_objects = Vector<Object*>::New(1);
2030 attached_objects[kSourceObjectIndex] = *source; 2032 attached_objects[kSourceObjectIndex] = *source;
2031 deserializer.SetAttachedObjects(&attached_objects); 2033 deserializer.SetAttachedObjects(&attached_objects);
2032 2034
2033 Object* root; 2035 Object* root;
2034 deserializer.DeserializePartial(isolate, &root); 2036 deserializer.DeserializePartial(isolate, &root);
2035 deserializer.FlushICacheForNewCodeObjects(); 2037 deserializer.FlushICacheForNewCodeObjects();
2036 if (FLAG_profile_deserialization) { 2038 if (FLAG_profile_deserialization) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2068 2070
2069 int SerializedCodeData::CheckSum(String* string) { 2071 int SerializedCodeData::CheckSum(String* string) {
2070 int checksum = Version::Hash(); 2072 int checksum = Version::Hash();
2071 #ifdef DEBUG 2073 #ifdef DEBUG
2072 uint32_t seed = static_cast<uint32_t>(checksum); 2074 uint32_t seed = static_cast<uint32_t>(checksum);
2073 checksum = static_cast<int>(IteratingStringHasher::Hash(string, seed)); 2075 checksum = static_cast<int>(IteratingStringHasher::Hash(string, seed));
2074 #endif // DEBUG 2076 #endif // DEBUG
2075 return checksum; 2077 return checksum;
2076 } 2078 }
2077 } } // namespace v8::internal 2079 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698