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

Side by Side Diff: src/serialize.h

Issue 390303002: Do not dump user source code in the code serializer. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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 | « src/compiler.cc ('k') | src/serialize.cc » ('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 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 #ifndef V8_SERIALIZE_H_ 5 #ifndef V8_SERIALIZE_H_
6 #define V8_SERIALIZE_H_ 6 #define V8_SERIALIZE_H_
7 7
8 #include "src/compiler.h" 8 #include "src/compiler.h"
9 #include "src/hashmap.h" 9 #include "src/hashmap.h"
10 #include "src/heap-profiler.h" 10 #include "src/heap-profiler.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 protected: 148 protected:
149 // Where the pointed-to object can be found: 149 // Where the pointed-to object can be found:
150 enum Where { 150 enum Where {
151 kNewObject = 0, // Object is next in snapshot. 151 kNewObject = 0, // Object is next in snapshot.
152 // 1-6 One per space. 152 // 1-6 One per space.
153 kRootArray = 0x9, // Object is found in root array. 153 kRootArray = 0x9, // Object is found in root array.
154 kPartialSnapshotCache = 0xa, // Object is in the cache. 154 kPartialSnapshotCache = 0xa, // Object is in the cache.
155 kExternalReference = 0xb, // Pointer to an external reference. 155 kExternalReference = 0xb, // Pointer to an external reference.
156 kSkip = 0xc, // Skip n bytes. 156 kSkip = 0xc, // Skip n bytes.
157 kBuiltin = 0xd, // Builtin code object. 157 kBuiltin = 0xd, // Builtin code object.
158 // 0xe Free. 158 kAttachedReference = 0xe, // Object is described in an attached list.
159 kNop = 0xf, // Does nothing, used to pad. 159 kNop = 0xf, // Does nothing, used to pad.
160 kBackref = 0x10, // Object is described relative to end. 160 kBackref = 0x10, // Object is described relative to end.
161 // 0x11-0x16 One per space. 161 // 0x11-0x16 One per space.
162 kBackrefWithSkip = 0x18, // Object is described relative to end. 162 kBackrefWithSkip = 0x18, // Object is described relative to end.
163 // 0x19-0x1e One per space. 163 // 0x19-0x1e One per space.
164 // 0x20-0x3f Used by misc. tags below. 164 // 0x20-0x3f Used by misc. tags below.
165 kPointedToMask = 0x3f 165 kPointedToMask = 0x3f
166 }; 166 };
167 167
168 // How to code the pointer to the object. 168 // How to code the pointer to the object.
169 enum HowToCode { 169 enum HowToCode {
170 kPlain = 0, // Straight pointer. 170 kPlain = 0, // Straight pointer.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 void DeserializePartial(Isolate* isolate, Object** root); 245 void DeserializePartial(Isolate* isolate, Object** root);
246 246
247 void set_reservation(int space_number, int reservation) { 247 void set_reservation(int space_number, int reservation) {
248 ASSERT(space_number >= 0); 248 ASSERT(space_number >= 0);
249 ASSERT(space_number <= LAST_SPACE); 249 ASSERT(space_number <= LAST_SPACE);
250 reservations_[space_number] = reservation; 250 reservations_[space_number] = reservation;
251 } 251 }
252 252
253 void FlushICacheForNewCodeObjects(); 253 void FlushICacheForNewCodeObjects();
254 254
255 // Call this to indicate that the serialized data represents user code. 255 // Serialized user code reference certain objects that are provided in a list
256 // There are some more wiring up required in this case. 256 // By calling this method, we assume that we are deserializing user code.
257 void ExpectSerializedCode() { deserialize_code_ = true; } 257 void SetAttachedObjects(List<Object*>* attached_objects) {
258 attached_objects_ = attached_objects;
259 }
260
261 bool deserializing_user_code() { return attached_objects_ != NULL; }
258 262
259 private: 263 private:
260 virtual void VisitPointers(Object** start, Object** end); 264 virtual void VisitPointers(Object** start, Object** end);
261 265
262 virtual void VisitRuntimeEntry(RelocInfo* rinfo) { 266 virtual void VisitRuntimeEntry(RelocInfo* rinfo) {
263 UNREACHABLE(); 267 UNREACHABLE();
264 } 268 }
265 269
266 // Allocation sites are present in the snapshot, and must be linked into 270 // Allocation sites are present in the snapshot, and must be linked into
267 // a list at deserialization time. 271 // a list at deserialization time.
(...skipping 22 matching lines...) Expand all
290 // This returns the address of an object that has been described in the 294 // This returns the address of an object that has been described in the
291 // snapshot as being offset bytes back in a particular space. 295 // snapshot as being offset bytes back in a particular space.
292 HeapObject* GetAddressFromEnd(int space) { 296 HeapObject* GetAddressFromEnd(int space) {
293 int offset = source_->GetInt(); 297 int offset = source_->GetInt();
294 offset <<= kObjectAlignmentBits; 298 offset <<= kObjectAlignmentBits;
295 return HeapObject::FromAddress(high_water_[space] - offset); 299 return HeapObject::FromAddress(high_water_[space] - offset);
296 } 300 }
297 301
298 // Cached current isolate. 302 // Cached current isolate.
299 Isolate* isolate_; 303 Isolate* isolate_;
300 bool deserialize_code_; 304
305 // Objects from the attached object descriptions in the serialized user code.
306 List<Object*>* attached_objects_;
301 307
302 SnapshotByteSource* source_; 308 SnapshotByteSource* source_;
303 // This is the address of the next object that will be allocated in each 309 // This is the address of the next object that will be allocated in each
304 // space. It is used to calculate the addresses of back-references. 310 // space. It is used to calculate the addresses of back-references.
305 Address high_water_[LAST_SPACE + 1]; 311 Address high_water_[LAST_SPACE + 1];
306 312
307 int reservations_[LAST_SPACE + 1]; 313 int reservations_[LAST_SPACE + 1];
308 static const intptr_t kUninitializedReservation = -1; 314 static const intptr_t kUninitializedReservation = -1;
309 315
310 ExternalReferenceDecoder* external_reference_decoder_; 316 ExternalReferenceDecoder* external_reference_decoder_;
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 virtual void SerializeObject(Object* o, 556 virtual void SerializeObject(Object* o,
551 HowToCode how_to_code, 557 HowToCode how_to_code,
552 WhereToPoint where_to_point, 558 WhereToPoint where_to_point,
553 int skip); 559 int skip);
554 void SerializeWeakReferences(); 560 void SerializeWeakReferences();
555 void Serialize() { 561 void Serialize() {
556 SerializeStrongReferences(); 562 SerializeStrongReferences();
557 SerializeWeakReferences(); 563 SerializeWeakReferences();
558 Pad(); 564 Pad();
559 } 565 }
566
567 private:
568 DISALLOW_COPY_AND_ASSIGN(StartupSerializer);
560 }; 569 };
561 570
562 571
563 class CodeSerializer : public Serializer { 572 class CodeSerializer : public Serializer {
564 public: 573 public:
565 CodeSerializer(Isolate* isolate, SnapshotByteSink* sink) 574 CodeSerializer(Isolate* isolate, SnapshotByteSink* sink, String* source)
566 : Serializer(isolate, sink) { 575 : Serializer(isolate, sink), source_(source) {
567 set_root_index_wave_front(Heap::kStrongRootListLength); 576 set_root_index_wave_front(Heap::kStrongRootListLength);
568 InitializeCodeAddressMap(); 577 InitializeCodeAddressMap();
569 } 578 }
570 579
571 static ScriptData* Serialize(Handle<SharedFunctionInfo> info); 580 static ScriptData* Serialize(Isolate* isolate,
581 Handle<SharedFunctionInfo> info,
582 Handle<String> source);
583
572 virtual void SerializeObject(Object* o, HowToCode how_to_code, 584 virtual void SerializeObject(Object* o, HowToCode how_to_code,
573 WhereToPoint where_to_point, int skip); 585 WhereToPoint where_to_point, int skip);
574 586
575 static Object* Deserialize(Isolate* isolate, ScriptData* data); 587 static Handle<SharedFunctionInfo> Deserialize(Isolate* isolate,
588 ScriptData* data,
589 Handle<String> source);
590
591 static const int kSourceObjectIndex = 0;
576 592
577 private: 593 private:
578 void SerializeBuiltin(Code* builtin, HowToCode how_to_code, 594 void SerializeBuiltin(Code* builtin, HowToCode how_to_code,
579 WhereToPoint where_to_point, int skip); 595 WhereToPoint where_to_point, int skip);
596 void SerializeSourceObject(HowToCode how_to_code, WhereToPoint where_to_point,
597 int skip);
598
599 DisallowHeapAllocation no_gc_;
600 String* source_;
601 DISALLOW_COPY_AND_ASSIGN(CodeSerializer);
580 }; 602 };
581 603
582 604
583 // Wrapper around ScriptData to provide code-serializer-specific functionality. 605 // Wrapper around ScriptData to provide code-serializer-specific functionality.
584 class SerializedCodeData { 606 class SerializedCodeData {
585 public: 607 public:
586 // Used by when consuming. 608 // Used by when consuming.
587 explicit SerializedCodeData(ScriptData* data) 609 explicit SerializedCodeData(ScriptData* data)
588 : script_data_(data), owns_script_data_(false) { 610 : script_data_(data), owns_script_data_(false) {
589 CHECK(IsSane()); 611 CHECK(IsSane());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 static const int kVersionHashOffset = 0; 657 static const int kVersionHashOffset = 0;
636 static const int kReservationsOffset = 1; 658 static const int kReservationsOffset = 1;
637 static const int kHeaderEntries = 8; 659 static const int kHeaderEntries = 8;
638 660
639 ScriptData* script_data_; 661 ScriptData* script_data_;
640 bool owns_script_data_; 662 bool owns_script_data_;
641 }; 663 };
642 } } // namespace v8::internal 664 } } // namespace v8::internal
643 665
644 #endif // V8_SERIALIZE_H_ 666 #endif // V8_SERIALIZE_H_
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698