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

Side by Side Diff: src/serialize.h

Issue 394793002: Verify that source string matches serialized code. (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
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 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 583
584 virtual void SerializeObject(Object* o, HowToCode how_to_code, 584 virtual void SerializeObject(Object* o, HowToCode how_to_code,
585 WhereToPoint where_to_point, int skip); 585 WhereToPoint where_to_point, int skip);
586 586
587 static Handle<SharedFunctionInfo> Deserialize(Isolate* isolate, 587 static Handle<SharedFunctionInfo> Deserialize(Isolate* isolate,
588 ScriptData* data, 588 ScriptData* data,
589 Handle<String> source); 589 Handle<String> source);
590 590
591 static const int kSourceObjectIndex = 0; 591 static const int kSourceObjectIndex = 0;
592 592
593 String* source() {
594 ASSERT(!AllowHeapAllocation::IsAllowed());
595 return source_;
596 }
597
593 private: 598 private:
594 void SerializeBuiltin(Code* builtin, HowToCode how_to_code, 599 void SerializeBuiltin(Code* builtin, HowToCode how_to_code,
595 WhereToPoint where_to_point, int skip); 600 WhereToPoint where_to_point, int skip);
596 void SerializeSourceObject(HowToCode how_to_code, WhereToPoint where_to_point, 601 void SerializeSourceObject(HowToCode how_to_code, WhereToPoint where_to_point,
597 int skip); 602 int skip);
598 603
599 DisallowHeapAllocation no_gc_; 604 DisallowHeapAllocation no_gc_;
600 String* source_; 605 String* source_;
601 DISALLOW_COPY_AND_ASSIGN(CodeSerializer); 606 DISALLOW_COPY_AND_ASSIGN(CodeSerializer);
602 }; 607 };
603 608
604 609
605 // Wrapper around ScriptData to provide code-serializer-specific functionality. 610 // Wrapper around ScriptData to provide code-serializer-specific functionality.
606 class SerializedCodeData { 611 class SerializedCodeData {
607 public: 612 public:
608 // Used by when consuming. 613 // Used by when consuming.
609 explicit SerializedCodeData(ScriptData* data) 614 explicit SerializedCodeData(ScriptData* data, String* source)
610 : script_data_(data), owns_script_data_(false) { 615 : script_data_(data), owns_script_data_(false) {
611 CHECK(IsSane()); 616 DisallowHeapAllocation no_gc;
617 CHECK(IsSane(source));
612 } 618 }
613 619
614 // Used when producing. 620 // Used when producing.
615 SerializedCodeData(List<byte>* payload, CodeSerializer* cs); 621 SerializedCodeData(List<byte>* payload, CodeSerializer* cs);
616 622
617 ~SerializedCodeData() { 623 ~SerializedCodeData() {
618 if (owns_script_data_) delete script_data_; 624 if (owns_script_data_) delete script_data_;
619 } 625 }
620 626
621 // Return ScriptData object and relinquish ownership over it to the caller. 627 // Return ScriptData object and relinquish ownership over it to the caller.
(...skipping 20 matching lines...) Expand all
642 private: 648 private:
643 void SetHeaderValue(int offset, int value) { 649 void SetHeaderValue(int offset, int value) {
644 reinterpret_cast<int*>(const_cast<byte*>(script_data_->data()))[offset] = 650 reinterpret_cast<int*>(const_cast<byte*>(script_data_->data()))[offset] =
645 value; 651 value;
646 } 652 }
647 653
648 int GetHeaderValue(int offset) const { 654 int GetHeaderValue(int offset) const {
649 return reinterpret_cast<const int*>(script_data_->data())[offset]; 655 return reinterpret_cast<const int*>(script_data_->data())[offset];
650 } 656 }
651 657
652 bool IsSane(); 658 bool IsSane(String* source);
659
660 int CheckSum(String* source);
653 661
654 // The data header consists of int-sized entries: 662 // The data header consists of int-sized entries:
655 // [0] version hash 663 // [0] version hash
656 // [1..7] reservation sizes for spaces from NEW_SPACE to PROPERTY_CELL_SPACE. 664 // [1..7] reservation sizes for spaces from NEW_SPACE to PROPERTY_CELL_SPACE.
657 static const int kVersionHashOffset = 0; 665 static const int kCheckSumOffset = 0;
658 static const int kReservationsOffset = 1; 666 static const int kReservationsOffset = 1;
659 static const int kHeaderEntries = 8; 667 static const int kHeaderEntries = 8;
660 668
661 ScriptData* script_data_; 669 ScriptData* script_data_;
662 bool owns_script_data_; 670 bool owns_script_data_;
663 }; 671 };
664 } } // namespace v8::internal 672 } } // namespace v8::internal
665 673
666 #endif // V8_SERIALIZE_H_ 674 #endif // V8_SERIALIZE_H_
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | src/serialize.cc » ('j') | test/cctest/test-serialize.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698