| OLD | NEW |
| 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 1896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1907 ASSERT(reader != NULL); | 1907 ASSERT(reader != NULL); |
| 1908 intptr_t len = reader->ReadSmiValue(); | 1908 intptr_t len = reader->ReadSmiValue(); |
| 1909 intptr_t hash = reader->ReadSmiValue(); | 1909 intptr_t hash = reader->ReadSmiValue(); |
| 1910 String& str_obj = String::Handle(reader->isolate(), String::null()); | 1910 String& str_obj = String::Handle(reader->isolate(), String::null()); |
| 1911 | 1911 |
| 1912 if (kind == Snapshot::kFull) { | 1912 if (kind == Snapshot::kFull) { |
| 1913 ASSERT(reader->isolate()->no_gc_scope_depth() != 0); | 1913 ASSERT(reader->isolate()->no_gc_scope_depth() != 0); |
| 1914 RawOneByteString* obj = reader->NewOneByteString(len); | 1914 RawOneByteString* obj = reader->NewOneByteString(len); |
| 1915 str_obj = obj; | 1915 str_obj = obj; |
| 1916 str_obj.set_tags(tags); | 1916 str_obj.set_tags(tags); |
| 1917 obj->ptr()->hash_ = Smi::New(hash); | 1917 str_obj.SetHash(hash); |
| 1918 if (len > 0) { | 1918 if (len > 0) { |
| 1919 uint8_t* raw_ptr = CharAddr(str_obj, 0); | 1919 uint8_t* raw_ptr = CharAddr(str_obj, 0); |
| 1920 reader->ReadBytes(raw_ptr, len); | 1920 reader->ReadBytes(raw_ptr, len); |
| 1921 } | 1921 } |
| 1922 ASSERT((hash == 0) || (String::Hash(str_obj, 0, str_obj.Length()) == hash)); | 1922 ASSERT((hash == 0) || (String::Hash(str_obj, 0, str_obj.Length()) == hash)); |
| 1923 } else { | 1923 } else { |
| 1924 String::ReadFromImpl<OneByteString, uint8_t>( | 1924 String::ReadFromImpl<OneByteString, uint8_t>( |
| 1925 reader, &str_obj, len, tags, Symbols::FromLatin1, kind); | 1925 reader, &str_obj, len, tags, Symbols::FromLatin1, kind); |
| 1926 } | 1926 } |
| 1927 reader->AddBackRef(object_id, &str_obj, kIsDeserialized); | 1927 reader->AddBackRef(object_id, &str_obj, kIsDeserialized); |
| 1928 return raw(str_obj); | 1928 return raw(str_obj); |
| 1929 } | 1929 } |
| 1930 | 1930 |
| 1931 | 1931 |
| 1932 RawTwoByteString* TwoByteString::ReadFrom(SnapshotReader* reader, | 1932 RawTwoByteString* TwoByteString::ReadFrom(SnapshotReader* reader, |
| 1933 intptr_t object_id, | 1933 intptr_t object_id, |
| 1934 intptr_t tags, | 1934 intptr_t tags, |
| 1935 Snapshot::Kind kind) { | 1935 Snapshot::Kind kind) { |
| 1936 // Read the length so that we can determine instance size to allocate. | 1936 // Read the length so that we can determine instance size to allocate. |
| 1937 ASSERT(reader != NULL); | 1937 ASSERT(reader != NULL); |
| 1938 intptr_t len = reader->ReadSmiValue(); | 1938 intptr_t len = reader->ReadSmiValue(); |
| 1939 intptr_t hash = reader->ReadSmiValue(); | 1939 intptr_t hash = reader->ReadSmiValue(); |
| 1940 String& str_obj = String::Handle(reader->isolate(), String::null()); | 1940 String& str_obj = String::Handle(reader->isolate(), String::null()); |
| 1941 | 1941 |
| 1942 if (kind == Snapshot::kFull) { | 1942 if (kind == Snapshot::kFull) { |
| 1943 RawTwoByteString* obj = reader->NewTwoByteString(len); | 1943 RawTwoByteString* obj = reader->NewTwoByteString(len); |
| 1944 str_obj = obj; | 1944 str_obj = obj; |
| 1945 str_obj.set_tags(tags); | 1945 str_obj.set_tags(tags); |
| 1946 obj->ptr()->hash_ = Smi::New(hash); | 1946 str_obj.SetHash(hash); |
| 1947 NoGCScope no_gc; | 1947 NoGCScope no_gc; |
| 1948 uint16_t* raw_ptr = (len > 0)? CharAddr(str_obj, 0) : NULL; | 1948 uint16_t* raw_ptr = (len > 0)? CharAddr(str_obj, 0) : NULL; |
| 1949 for (intptr_t i = 0; i < len; i++) { | 1949 for (intptr_t i = 0; i < len; i++) { |
| 1950 ASSERT(CharAddr(str_obj, i) == raw_ptr); // Will trigger assertions. | 1950 ASSERT(CharAddr(str_obj, i) == raw_ptr); // Will trigger assertions. |
| 1951 *raw_ptr = reader->Read<uint16_t>(); | 1951 *raw_ptr = reader->Read<uint16_t>(); |
| 1952 raw_ptr += 1; | 1952 raw_ptr += 1; |
| 1953 } | 1953 } |
| 1954 ASSERT(String::Hash(str_obj, 0, str_obj.Length()) == hash); | 1954 ASSERT(String::Hash(str_obj, 0, str_obj.Length()) == hash); |
| 1955 } else { | 1955 } else { |
| 1956 String::ReadFromImpl<TwoByteString, uint16_t>( | 1956 String::ReadFromImpl<TwoByteString, uint16_t>( |
| (...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2882 // We do not allow objects with native fields in an isolate message. | 2882 // We do not allow objects with native fields in an isolate message. |
| 2883 writer->SetWriteException(Exceptions::kArgument, | 2883 writer->SetWriteException(Exceptions::kArgument, |
| 2884 "Illegal argument in isolate message" | 2884 "Illegal argument in isolate message" |
| 2885 " : (object is a UserTag)"); | 2885 " : (object is a UserTag)"); |
| 2886 } else { | 2886 } else { |
| 2887 UNREACHABLE(); | 2887 UNREACHABLE(); |
| 2888 } | 2888 } |
| 2889 } | 2889 } |
| 2890 | 2890 |
| 2891 } // namespace dart | 2891 } // namespace dart |
| OLD | NEW |