| 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 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 TokenStream& token_stream = TokenStream::ZoneHandle( | 899 TokenStream& token_stream = TokenStream::ZoneHandle( |
| 900 reader->zone(), NEW_OBJECT_WITH_LEN(TokenStream, len)); | 900 reader->zone(), NEW_OBJECT_WITH_LEN(TokenStream, len)); |
| 901 reader->AddBackRef(object_id, &token_stream, kIsDeserialized); | 901 reader->AddBackRef(object_id, &token_stream, kIsDeserialized); |
| 902 | 902 |
| 903 // Set the object tags. | 903 // Set the object tags. |
| 904 token_stream.set_tags(tags); | 904 token_stream.set_tags(tags); |
| 905 | 905 |
| 906 // Read the stream of tokens into the TokenStream object for script | 906 // Read the stream of tokens into the TokenStream object for script |
| 907 // snapshots as we made a copy of token stream. | 907 // snapshots as we made a copy of token stream. |
| 908 if (kind == Snapshot::kScript) { | 908 if (kind == Snapshot::kScript) { |
| 909 NoGCScope no_gc; | 909 NoSafepointScope no_safepoint; |
| 910 RawExternalTypedData* stream = token_stream.GetStream(); | 910 RawExternalTypedData* stream = token_stream.GetStream(); |
| 911 reader->ReadBytes(stream->ptr()->data_, len); | 911 reader->ReadBytes(stream->ptr()->data_, len); |
| 912 } | 912 } |
| 913 | 913 |
| 914 // Read in the literal/identifier token array. | 914 // Read in the literal/identifier token array. |
| 915 *(reader->TokensHandle()) ^= reader->ReadObjectImpl(); | 915 *(reader->TokensHandle()) ^= reader->ReadObjectImpl(); |
| 916 token_stream.SetTokenObjects(*(reader->TokensHandle())); | 916 token_stream.SetTokenObjects(*(reader->TokensHandle())); |
| 917 // Read in the private key in use by the token stream. | 917 // Read in the private key in use by the token stream. |
| 918 *(reader->StringHandle()) ^= reader->ReadObjectImpl(); | 918 *(reader->StringHandle()) ^= reader->ReadObjectImpl(); |
| 919 token_stream.SetPrivateKey(*(reader->StringHandle())); | 919 token_stream.SetPrivateKey(*(reader->StringHandle())); |
| (...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1896 } | 1896 } |
| 1897 *str_obj ^= (*new_symbol)(ptr, len); | 1897 *str_obj ^= (*new_symbol)(ptr, len); |
| 1898 } else { | 1898 } else { |
| 1899 // Set up the string object. | 1899 // Set up the string object. |
| 1900 *str_obj = StringType::New(len, HEAP_SPACE(kind)); | 1900 *str_obj = StringType::New(len, HEAP_SPACE(kind)); |
| 1901 str_obj->set_tags(tags); | 1901 str_obj->set_tags(tags); |
| 1902 str_obj->SetHash(0); // Will get computed when needed. | 1902 str_obj->SetHash(0); // Will get computed when needed. |
| 1903 if (len == 0) { | 1903 if (len == 0) { |
| 1904 return; | 1904 return; |
| 1905 } | 1905 } |
| 1906 NoGCScope no_gc; | 1906 NoSafepointScope no_safepoint; |
| 1907 CharacterType* str_addr = StringType::CharAddr(*str_obj, 0); | 1907 CharacterType* str_addr = StringType::CharAddr(*str_obj, 0); |
| 1908 for (intptr_t i = 0; i < len; i++) { | 1908 for (intptr_t i = 0; i < len; i++) { |
| 1909 *str_addr = reader->Read<CharacterType>(); | 1909 *str_addr = reader->Read<CharacterType>(); |
| 1910 str_addr++; | 1910 str_addr++; |
| 1911 } | 1911 } |
| 1912 } | 1912 } |
| 1913 } | 1913 } |
| 1914 | 1914 |
| 1915 | 1915 |
| 1916 RawOneByteString* OneByteString::ReadFrom(SnapshotReader* reader, | 1916 RawOneByteString* OneByteString::ReadFrom(SnapshotReader* reader, |
| 1917 intptr_t object_id, | 1917 intptr_t object_id, |
| 1918 intptr_t tags, | 1918 intptr_t tags, |
| 1919 Snapshot::Kind kind) { | 1919 Snapshot::Kind kind) { |
| 1920 // Read the length so that we can determine instance size to allocate. | 1920 // Read the length so that we can determine instance size to allocate. |
| 1921 ASSERT(reader != NULL); | 1921 ASSERT(reader != NULL); |
| 1922 intptr_t len = reader->ReadSmiValue(); | 1922 intptr_t len = reader->ReadSmiValue(); |
| 1923 intptr_t hash = reader->ReadSmiValue(); | 1923 intptr_t hash = reader->ReadSmiValue(); |
| 1924 String& str_obj = String::Handle(reader->zone(), String::null()); | 1924 String& str_obj = String::Handle(reader->zone(), String::null()); |
| 1925 | 1925 |
| 1926 if (kind == Snapshot::kFull) { | 1926 if (kind == Snapshot::kFull) { |
| 1927 ASSERT(reader->isolate()->no_gc_scope_depth() != 0); | 1927 ASSERT(reader->isolate()->no_safepoint_scope_depth() != 0); |
| 1928 RawOneByteString* obj = reader->NewOneByteString(len); | 1928 RawOneByteString* obj = reader->NewOneByteString(len); |
| 1929 str_obj = obj; | 1929 str_obj = obj; |
| 1930 str_obj.set_tags(tags); | 1930 str_obj.set_tags(tags); |
| 1931 str_obj.SetHash(hash); | 1931 str_obj.SetHash(hash); |
| 1932 if (len > 0) { | 1932 if (len > 0) { |
| 1933 uint8_t* raw_ptr = CharAddr(str_obj, 0); | 1933 uint8_t* raw_ptr = CharAddr(str_obj, 0); |
| 1934 reader->ReadBytes(raw_ptr, len); | 1934 reader->ReadBytes(raw_ptr, len); |
| 1935 } | 1935 } |
| 1936 ASSERT((hash == 0) || (String::Hash(str_obj, 0, str_obj.Length()) == hash)); | 1936 ASSERT((hash == 0) || (String::Hash(str_obj, 0, str_obj.Length()) == hash)); |
| 1937 } else { | 1937 } else { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1951 ASSERT(reader != NULL); | 1951 ASSERT(reader != NULL); |
| 1952 intptr_t len = reader->ReadSmiValue(); | 1952 intptr_t len = reader->ReadSmiValue(); |
| 1953 intptr_t hash = reader->ReadSmiValue(); | 1953 intptr_t hash = reader->ReadSmiValue(); |
| 1954 String& str_obj = String::Handle(reader->zone(), String::null()); | 1954 String& str_obj = String::Handle(reader->zone(), String::null()); |
| 1955 | 1955 |
| 1956 if (kind == Snapshot::kFull) { | 1956 if (kind == Snapshot::kFull) { |
| 1957 RawTwoByteString* obj = reader->NewTwoByteString(len); | 1957 RawTwoByteString* obj = reader->NewTwoByteString(len); |
| 1958 str_obj = obj; | 1958 str_obj = obj; |
| 1959 str_obj.set_tags(tags); | 1959 str_obj.set_tags(tags); |
| 1960 str_obj.SetHash(hash); | 1960 str_obj.SetHash(hash); |
| 1961 NoGCScope no_gc; | 1961 NoSafepointScope no_safepoint; |
| 1962 uint16_t* raw_ptr = (len > 0)? CharAddr(str_obj, 0) : NULL; | 1962 uint16_t* raw_ptr = (len > 0)? CharAddr(str_obj, 0) : NULL; |
| 1963 for (intptr_t i = 0; i < len; i++) { | 1963 for (intptr_t i = 0; i < len; i++) { |
| 1964 ASSERT(CharAddr(str_obj, i) == raw_ptr); // Will trigger assertions. | 1964 ASSERT(CharAddr(str_obj, i) == raw_ptr); // Will trigger assertions. |
| 1965 *raw_ptr = reader->Read<uint16_t>(); | 1965 *raw_ptr = reader->Read<uint16_t>(); |
| 1966 raw_ptr += 1; | 1966 raw_ptr += 1; |
| 1967 } | 1967 } |
| 1968 ASSERT(String::Hash(str_obj, 0, str_obj.Length()) == hash); | 1968 ASSERT(String::Hash(str_obj, 0, str_obj.Length()) == hash); |
| 1969 } else { | 1969 } else { |
| 1970 String::ReadFromImpl<TwoByteString, uint16_t>( | 1970 String::ReadFromImpl<TwoByteString, uint16_t>( |
| 1971 reader, &str_obj, len, tags, Symbols::FromUTF16, kind); | 1971 reader, &str_obj, len, tags, Symbols::FromUTF16, kind); |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2425 // Set the object tags. | 2425 // Set the object tags. |
| 2426 result.set_tags(tags); | 2426 result.set_tags(tags); |
| 2427 | 2427 |
| 2428 // Setup the array elements. | 2428 // Setup the array elements. |
| 2429 intptr_t element_size = ElementSizeInBytes(cid); | 2429 intptr_t element_size = ElementSizeInBytes(cid); |
| 2430 intptr_t length_in_bytes = len * element_size; | 2430 intptr_t length_in_bytes = len * element_size; |
| 2431 switch (cid) { | 2431 switch (cid) { |
| 2432 case kTypedDataInt8ArrayCid: | 2432 case kTypedDataInt8ArrayCid: |
| 2433 case kTypedDataUint8ArrayCid: | 2433 case kTypedDataUint8ArrayCid: |
| 2434 case kTypedDataUint8ClampedArrayCid: { | 2434 case kTypedDataUint8ClampedArrayCid: { |
| 2435 NoGCScope no_gc; | 2435 NoSafepointScope no_safepoint; |
| 2436 uint8_t* data = reinterpret_cast<uint8_t*>(result.DataAddr(0)); | 2436 uint8_t* data = reinterpret_cast<uint8_t*>(result.DataAddr(0)); |
| 2437 reader->ReadBytes(data, length_in_bytes); | 2437 reader->ReadBytes(data, length_in_bytes); |
| 2438 break; | 2438 break; |
| 2439 } | 2439 } |
| 2440 case kTypedDataInt16ArrayCid: | 2440 case kTypedDataInt16ArrayCid: |
| 2441 TYPED_DATA_READ(Int16, int16_t); | 2441 TYPED_DATA_READ(Int16, int16_t); |
| 2442 break; | 2442 break; |
| 2443 case kTypedDataUint16ArrayCid: | 2443 case kTypedDataUint16ArrayCid: |
| 2444 TYPED_DATA_READ(Uint16, uint16_t); | 2444 TYPED_DATA_READ(Uint16, uint16_t); |
| 2445 break; | 2445 break; |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2903 // We do not allow objects with native fields in an isolate message. | 2903 // We do not allow objects with native fields in an isolate message. |
| 2904 writer->SetWriteException(Exceptions::kArgument, | 2904 writer->SetWriteException(Exceptions::kArgument, |
| 2905 "Illegal argument in isolate message" | 2905 "Illegal argument in isolate message" |
| 2906 " : (object is a UserTag)"); | 2906 " : (object is a UserTag)"); |
| 2907 } else { | 2907 } else { |
| 2908 UNREACHABLE(); | 2908 UNREACHABLE(); |
| 2909 } | 2909 } |
| 2910 } | 2910 } |
| 2911 | 2911 |
| 2912 } // namespace dart | 2912 } // namespace dart |
| OLD | NEW |