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

Side by Side Diff: runtime/vm/raw_object_snapshot.cc

Issue 612133004: Write barrier audit: const raw_ptr() (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 2 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 | « runtime/vm/raw_object.h ('k') | runtime/vm/service.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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object.h" 5 #include "vm/object.h"
6 #include "vm/object_store.h" 6 #include "vm/object_store.h"
7 #include "vm/snapshot.h" 7 #include "vm/snapshot.h"
8 #include "vm/stub_code.h" 8 #include "vm/stub_code.h"
9 #include "vm/symbols.h" 9 #include "vm/symbols.h"
10 #include "vm/visitor.h" 10 #include "vm/visitor.h"
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 // TODO(5411462): Need to assert No GC can happen here, even though 942 // TODO(5411462): Need to assert No GC can happen here, even though
943 // allocations may happen. 943 // allocations may happen.
944 *reader->StringHandle() ^= reader->ReadObjectImpl(); 944 *reader->StringHandle() ^= reader->ReadObjectImpl();
945 script.set_url(*reader->StringHandle()); 945 script.set_url(*reader->StringHandle());
946 *reader->StringHandle() ^= String::null(); 946 *reader->StringHandle() ^= String::null();
947 script.set_source(*reader->StringHandle()); 947 script.set_source(*reader->StringHandle());
948 TokenStream& stream = TokenStream::Handle(); 948 TokenStream& stream = TokenStream::Handle();
949 stream ^= reader->ReadObjectImpl(); 949 stream ^= reader->ReadObjectImpl();
950 script.set_tokens(stream); 950 script.set_tokens(stream);
951 951
952 script.raw_ptr()->line_offset_ = reader->Read<int32_t>(); 952 script.StoreNonPointer(&script.raw_ptr()->line_offset_,
953 script.raw_ptr()->col_offset_ = reader->Read<int32_t>(); 953 reader->Read<int32_t>());
954 script.raw_ptr()->kind_ = reader->Read<int8_t>(); 954 script.StoreNonPointer(&script.raw_ptr()->col_offset_,
955 reader->Read<int32_t>());
956 script.StoreNonPointer(&script.raw_ptr()->kind_,
957 reader->Read<int8_t>());
955 958
956 return script.raw(); 959 return script.raw();
957 } 960 }
958 961
959 962
960 void RawScript::WriteTo(SnapshotWriter* writer, 963 void RawScript::WriteTo(SnapshotWriter* writer,
961 intptr_t object_id, 964 intptr_t object_id,
962 Snapshot::Kind kind) { 965 Snapshot::Kind kind) {
963 ASSERT(writer != NULL); 966 ASSERT(writer != NULL);
964 ASSERT(tokens_ != TokenStream::null()); 967 ASSERT(tokens_ != TokenStream::null());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 *reader->StringHandle() ^= reader->ReadObjectImpl(); 1002 *reader->StringHandle() ^= reader->ReadObjectImpl();
1000 library = Library::LookupLibrary(*reader->StringHandle()); 1003 library = Library::LookupLibrary(*reader->StringHandle());
1001 } else { 1004 } else {
1002 // Allocate library object. 1005 // Allocate library object.
1003 library = NEW_OBJECT(Library); 1006 library = NEW_OBJECT(Library);
1004 1007
1005 // Set the object tags. 1008 // Set the object tags.
1006 library.set_tags(tags); 1009 library.set_tags(tags);
1007 1010
1008 // Set all non object fields. 1011 // Set all non object fields.
1009 library.raw_ptr()->index_ = reader->Read<int32_t>(); 1012 library.StoreNonPointer(&library.raw_ptr()->index_,
1010 library.raw_ptr()->num_imports_ = reader->Read<int32_t>(); 1013 reader->Read<int32_t>());
1011 library.raw_ptr()->num_anonymous_ = reader->Read<int32_t>(); 1014 library.StoreNonPointer(&library.raw_ptr()->num_imports_,
1012 library.raw_ptr()->corelib_imported_ = reader->Read<bool>(); 1015 reader->Read<int32_t>());
1013 library.raw_ptr()->is_dart_scheme_ = reader->Read<bool>(); 1016 library.StoreNonPointer(&library.raw_ptr()->num_anonymous_,
1014 library.raw_ptr()->debuggable_ = reader->Read<bool>(); 1017 reader->Read<int32_t>());
1015 library.raw_ptr()->load_state_ = reader->Read<int8_t>(); 1018 library.StoreNonPointer(&library.raw_ptr()->corelib_imported_,
1019 reader->Read<bool>());
1020 library.StoreNonPointer(&library.raw_ptr()->is_dart_scheme_,
1021 reader->Read<bool>());
1022 library.StoreNonPointer(&library.raw_ptr()->debuggable_,
1023 reader->Read<bool>());
1024 library.StoreNonPointer(&library.raw_ptr()->load_state_,
1025 reader->Read<int8_t>());
1016 // The native resolver is not serialized. 1026 // The native resolver is not serialized.
1017 Dart_NativeEntryResolver resolver = 1027 Dart_NativeEntryResolver resolver =
1018 reader->Read<Dart_NativeEntryResolver>(); 1028 reader->Read<Dart_NativeEntryResolver>();
1019 ASSERT(resolver == NULL); 1029 ASSERT(resolver == NULL);
1020 library.set_native_entry_resolver(resolver); 1030 library.set_native_entry_resolver(resolver);
1021 // The symbol resolver is not serialized. 1031 // The symbol resolver is not serialized.
1022 Dart_NativeEntrySymbol symbol_resolver = 1032 Dart_NativeEntrySymbol symbol_resolver =
1023 reader->Read<Dart_NativeEntrySymbol>(); 1033 reader->Read<Dart_NativeEntrySymbol>();
1024 ASSERT(symbol_resolver == NULL); 1034 ASSERT(symbol_resolver == NULL);
1025 library.set_native_entry_symbol_resolver(symbol_resolver); 1035 library.set_native_entry_symbol_resolver(symbol_resolver);
1026 // The cache of loaded scripts is not serialized. 1036 // The cache of loaded scripts is not serialized.
1027 library.raw_ptr()->loaded_scripts_ = Array::null(); 1037 library.StorePointer(&library.raw_ptr()->loaded_scripts_, Array::null());
1028 1038
1029 // Set all the object fields. 1039 // Set all the object fields.
1030 // TODO(5411462): Need to assert No GC can happen here, even though 1040 // TODO(5411462): Need to assert No GC can happen here, even though
1031 // allocations may happen. 1041 // allocations may happen.
1032 intptr_t num_flds = (library.raw()->to() - library.raw()->from()); 1042 intptr_t num_flds = (library.raw()->to() - library.raw()->from());
1033 for (intptr_t i = 0; i <= num_flds; i++) { 1043 for (intptr_t i = 0; i <= num_flds; i++) {
1034 *(library.raw()->from() + i) = reader->ReadObjectRef(); 1044 *(library.raw()->from() + i) = reader->ReadObjectRef();
1035 } 1045 }
1036 if (kind != Snapshot::kFull) { 1046 if (kind != Snapshot::kFull) {
1037 library.Register(); 1047 library.Register();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 1106
1097 // Allocate library prefix object. 1107 // Allocate library prefix object.
1098 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle( 1108 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(
1099 reader->isolate(), NEW_OBJECT(LibraryPrefix)); 1109 reader->isolate(), NEW_OBJECT(LibraryPrefix));
1100 reader->AddBackRef(object_id, &prefix, kIsDeserialized); 1110 reader->AddBackRef(object_id, &prefix, kIsDeserialized);
1101 1111
1102 // Set the object tags. 1112 // Set the object tags.
1103 prefix.set_tags(tags); 1113 prefix.set_tags(tags);
1104 1114
1105 // Set all non object fields. 1115 // Set all non object fields.
1106 prefix.raw_ptr()->num_imports_ = reader->Read<int32_t>(); 1116 prefix.StoreNonPointer(&prefix.raw_ptr()->num_imports_,
1107 prefix.raw_ptr()->is_deferred_load_ = reader->Read<bool>(); 1117 reader->Read<int32_t>());
1108 prefix.raw_ptr()->is_loaded_ = reader->Read<bool>(); 1118 prefix.StoreNonPointer(&prefix.raw_ptr()->is_deferred_load_,
1119 reader->Read<bool>());
1120 prefix.StoreNonPointer(&prefix.raw_ptr()->is_loaded_, reader->Read<bool>());
1109 1121
1110 // Set all the object fields. 1122 // Set all the object fields.
1111 // TODO(5411462): Need to assert No GC can happen here, even though 1123 // TODO(5411462): Need to assert No GC can happen here, even though
1112 // allocations may happen. 1124 // allocations may happen.
1113 intptr_t num_flds = (prefix.raw()->to() - prefix.raw()->from()); 1125 intptr_t num_flds = (prefix.raw()->to() - prefix.raw()->from());
1114 for (intptr_t i = 0; i <= num_flds; i++) { 1126 for (intptr_t i = 0; i <= num_flds; i++) {
1115 *(prefix.raw()->from() + i) = reader->ReadObjectRef(); 1127 *(prefix.raw()->from() + i) = reader->ReadObjectRef();
1116 } 1128 }
1117 1129
1118 return prefix.raw(); 1130 return prefix.raw();
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
1847 isolate->current_zone()->Alloc<CharacterType>(len); 1859 isolate->current_zone()->Alloc<CharacterType>(len);
1848 for (intptr_t i = 0; i < len; i++) { 1860 for (intptr_t i = 0; i < len; i++) {
1849 ptr[i] = reader->Read<CharacterType>(); 1861 ptr[i] = reader->Read<CharacterType>();
1850 } 1862 }
1851 *str_obj ^= (*new_symbol)(ptr, len); 1863 *str_obj ^= (*new_symbol)(ptr, len);
1852 } else { 1864 } else {
1853 // Set up the string object. 1865 // Set up the string object.
1854 *str_obj = StringType::New(len, HEAP_SPACE(kind)); 1866 *str_obj = StringType::New(len, HEAP_SPACE(kind));
1855 str_obj->set_tags(tags); 1867 str_obj->set_tags(tags);
1856 str_obj->SetHash(0); // Will get computed when needed. 1868 str_obj->SetHash(0); // Will get computed when needed.
1869 NoGCScope no_gc;
1857 for (intptr_t i = 0; i < len; i++) { 1870 for (intptr_t i = 0; i < len; i++) {
1858 *StringType::CharAddr(*str_obj, i) = reader->Read<CharacterType>(); 1871 *StringType::CharAddr(*str_obj, i) = reader->Read<CharacterType>();
1859 } 1872 }
1860 } 1873 }
1861 } 1874 }
1862 1875
1863 1876
1864 RawOneByteString* OneByteString::ReadFrom(SnapshotReader* reader, 1877 RawOneByteString* OneByteString::ReadFrom(SnapshotReader* reader,
1865 intptr_t object_id, 1878 intptr_t object_id,
1866 intptr_t tags, 1879 intptr_t tags,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1899 ASSERT(reader != NULL); 1912 ASSERT(reader != NULL);
1900 intptr_t len = reader->ReadSmiValue(); 1913 intptr_t len = reader->ReadSmiValue();
1901 intptr_t hash = reader->ReadSmiValue(); 1914 intptr_t hash = reader->ReadSmiValue();
1902 String& str_obj = String::Handle(reader->isolate(), String::null()); 1915 String& str_obj = String::Handle(reader->isolate(), String::null());
1903 1916
1904 if (kind == Snapshot::kFull) { 1917 if (kind == Snapshot::kFull) {
1905 RawTwoByteString* obj = reader->NewTwoByteString(len); 1918 RawTwoByteString* obj = reader->NewTwoByteString(len);
1906 str_obj = obj; 1919 str_obj = obj;
1907 str_obj.set_tags(tags); 1920 str_obj.set_tags(tags);
1908 obj->ptr()->hash_ = Smi::New(hash); 1921 obj->ptr()->hash_ = Smi::New(hash);
1922 NoGCScope no_gc;
1909 uint16_t* raw_ptr = (len > 0)? CharAddr(str_obj, 0) : NULL; 1923 uint16_t* raw_ptr = (len > 0)? CharAddr(str_obj, 0) : NULL;
1910 for (intptr_t i = 0; i < len; i++) { 1924 for (intptr_t i = 0; i < len; i++) {
1911 ASSERT(CharAddr(str_obj, i) == raw_ptr); // Will trigger assertions. 1925 ASSERT(CharAddr(str_obj, i) == raw_ptr); // Will trigger assertions.
1912 *raw_ptr = reader->Read<uint16_t>(); 1926 *raw_ptr = reader->Read<uint16_t>();
1913 raw_ptr += 1; 1927 raw_ptr += 1;
1914 } 1928 }
1915 ASSERT(String::Hash(str_obj, 0, str_obj.Length()) == hash); 1929 ASSERT(String::Hash(str_obj, 0, str_obj.Length()) == hash);
1916 } else { 1930 } else {
1917 String::ReadFromImpl<TwoByteString, uint16_t>( 1931 String::ReadFromImpl<TwoByteString, uint16_t>(
1918 reader, &str_obj, len, tags, Symbols::FromUTF16, kind); 1932 reader, &str_obj, len, tags, Symbols::FromUTF16, kind);
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
2367 // Set the object tags. 2381 // Set the object tags.
2368 result.set_tags(tags); 2382 result.set_tags(tags);
2369 2383
2370 // Setup the array elements. 2384 // Setup the array elements.
2371 intptr_t element_size = ElementSizeInBytes(cid); 2385 intptr_t element_size = ElementSizeInBytes(cid);
2372 intptr_t length_in_bytes = len * element_size; 2386 intptr_t length_in_bytes = len * element_size;
2373 switch (cid) { 2387 switch (cid) {
2374 case kTypedDataInt8ArrayCid: 2388 case kTypedDataInt8ArrayCid:
2375 case kTypedDataUint8ArrayCid: 2389 case kTypedDataUint8ArrayCid:
2376 case kTypedDataUint8ClampedArrayCid: { 2390 case kTypedDataUint8ClampedArrayCid: {
2391 NoGCScope no_gc;
2377 uint8_t* data = reinterpret_cast<uint8_t*>(result.DataAddr(0)); 2392 uint8_t* data = reinterpret_cast<uint8_t*>(result.DataAddr(0));
2378 reader->ReadBytes(data, length_in_bytes); 2393 reader->ReadBytes(data, length_in_bytes);
2379 break; 2394 break;
2380 } 2395 }
2381 case kTypedDataInt16ArrayCid: 2396 case kTypedDataInt16ArrayCid:
2382 TYPED_DATA_READ(Int16, int16_t); 2397 TYPED_DATA_READ(Int16, int16_t);
2383 break; 2398 break;
2384 case kTypedDataUint16ArrayCid: 2399 case kTypedDataUint16ArrayCid:
2385 TYPED_DATA_READ(Uint16, uint16_t); 2400 TYPED_DATA_READ(Uint16, uint16_t);
2386 break; 2401 break;
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
2715 2730
2716 // Allocate JSRegExp object. 2731 // Allocate JSRegExp object.
2717 JSRegExp& regex = JSRegExp::ZoneHandle( 2732 JSRegExp& regex = JSRegExp::ZoneHandle(
2718 reader->isolate(), JSRegExp::New(len, HEAP_SPACE(kind))); 2733 reader->isolate(), JSRegExp::New(len, HEAP_SPACE(kind)));
2719 reader->AddBackRef(object_id, &regex, kIsDeserialized); 2734 reader->AddBackRef(object_id, &regex, kIsDeserialized);
2720 2735
2721 // Set the object tags. 2736 // Set the object tags.
2722 regex.set_tags(tags); 2737 regex.set_tags(tags);
2723 2738
2724 // Read and Set all the other fields. 2739 // Read and Set all the other fields.
2725 regex.raw_ptr()->num_bracket_expressions_ = reader->ReadAsSmi(); 2740 regex.StoreSmi(&regex.raw_ptr()->num_bracket_expressions_,
2741 reader->ReadAsSmi());
2726 *reader->StringHandle() ^= reader->ReadObjectImpl(); 2742 *reader->StringHandle() ^= reader->ReadObjectImpl();
2727 regex.set_pattern(*reader->StringHandle()); 2743 regex.set_pattern(*reader->StringHandle());
2728 regex.raw_ptr()->type_flags_ = reader->Read<int8_t>(); 2744 regex.StoreNonPointer(&regex.raw_ptr()->type_flags_,
2745 reader->Read<int8_t>());
2729 2746
2730 // TODO(5411462): Need to implement a way of recompiling the regex. 2747 // TODO(5411462): Need to implement a way of recompiling the regex.
2731 2748
2732 return regex.raw(); 2749 return regex.raw();
2733 } 2750 }
2734 2751
2735 2752
2736 void RawJSRegExp::WriteTo(SnapshotWriter* writer, 2753 void RawJSRegExp::WriteTo(SnapshotWriter* writer,
2737 intptr_t object_id, 2754 intptr_t object_id,
2738 Snapshot::Kind kind) { 2755 Snapshot::Kind kind) {
(...skipping 27 matching lines...) Expand all
2766 2783
2767 // Allocate the weak property object. 2784 // Allocate the weak property object.
2768 WeakProperty& weak_property = WeakProperty::ZoneHandle( 2785 WeakProperty& weak_property = WeakProperty::ZoneHandle(
2769 reader->isolate(), WeakProperty::New(HEAP_SPACE(kind))); 2786 reader->isolate(), WeakProperty::New(HEAP_SPACE(kind)));
2770 reader->AddBackRef(object_id, &weak_property, kIsDeserialized); 2787 reader->AddBackRef(object_id, &weak_property, kIsDeserialized);
2771 2788
2772 // Set the object tags. 2789 // Set the object tags.
2773 weak_property.set_tags(tags); 2790 weak_property.set_tags(tags);
2774 2791
2775 // Set all the object fields. 2792 // Set all the object fields.
2776 weak_property.raw_ptr()->key_ = reader->ReadObjectRef(); 2793 weak_property.StorePointer(&weak_property.raw_ptr()->key_,
2777 weak_property.raw_ptr()->value_ = reader->ReadObjectRef(); 2794 reader->ReadObjectRef());
2795 weak_property.StorePointer(&weak_property.raw_ptr()->value_,
2796 reader->ReadObjectRef());
2778 2797
2779 return weak_property.raw(); 2798 return weak_property.raw();
2780 } 2799 }
2781 2800
2782 2801
2783 void RawWeakProperty::WriteTo(SnapshotWriter* writer, 2802 void RawWeakProperty::WriteTo(SnapshotWriter* writer,
2784 intptr_t object_id, 2803 intptr_t object_id,
2785 Snapshot::Kind kind) { 2804 Snapshot::Kind kind) {
2786 ASSERT(writer != NULL); 2805 ASSERT(writer != NULL);
2787 2806
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2837 // We do not allow objects with native fields in an isolate message. 2856 // We do not allow objects with native fields in an isolate message.
2838 writer->SetWriteException(Exceptions::kArgument, 2857 writer->SetWriteException(Exceptions::kArgument,
2839 "Illegal argument in isolate message" 2858 "Illegal argument in isolate message"
2840 " : (object is a UserTag)"); 2859 " : (object is a UserTag)");
2841 } else { 2860 } else {
2842 UNREACHABLE(); 2861 UNREACHABLE();
2843 } 2862 }
2844 } 2863 }
2845 2864
2846 } // namespace dart 2865 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.h ('k') | runtime/vm/service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698