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

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

Issue 1412633007: Save the native name on the function instead of finding it in the token stream for lazily-linked na… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « runtime/vm/raw_object.h ('k') | no next file » | 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/native_entry.h" 5 #include "vm/native_entry.h"
6 #include "vm/object.h" 6 #include "vm/object.h"
7 #include "vm/object_store.h" 7 #include "vm/object_store.h"
8 #include "vm/snapshot.h" 8 #include "vm/snapshot.h"
9 #include "vm/stub_code.h" 9 #include "vm/stub_code.h"
10 #include "vm/symbols.h" 10 #include "vm/symbols.h"
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 Script& script = Script::ZoneHandle(reader->zone(), NEW_OBJECT(Script)); 977 Script& script = Script::ZoneHandle(reader->zone(), NEW_OBJECT(Script));
978 reader->AddBackRef(object_id, &script, kIsDeserialized); 978 reader->AddBackRef(object_id, &script, kIsDeserialized);
979 979
980 script.StoreNonPointer(&script.raw_ptr()->line_offset_, 980 script.StoreNonPointer(&script.raw_ptr()->line_offset_,
981 reader->Read<int32_t>()); 981 reader->Read<int32_t>());
982 script.StoreNonPointer(&script.raw_ptr()->col_offset_, 982 script.StoreNonPointer(&script.raw_ptr()->col_offset_,
983 reader->Read<int32_t>()); 983 reader->Read<int32_t>());
984 script.StoreNonPointer(&script.raw_ptr()->kind_, 984 script.StoreNonPointer(&script.raw_ptr()->kind_,
985 reader->Read<int8_t>()); 985 reader->Read<int8_t>());
986 986
987 *reader->StringHandle() ^= String::null();
988 script.set_source(*reader->StringHandle());
989 *reader->StreamHandle() ^= TokenStream::null();
990 script.set_tokens(*reader->StreamHandle());
991
987 // Set all the object fields. 992 // Set all the object fields.
988 // TODO(5411462): Need to assert No GC can happen here, even though 993 // TODO(5411462): Need to assert No GC can happen here, even though
989 // allocations may happen. 994 // allocations may happen.
990 intptr_t num_flds = (script.raw()->to_snapshot() - script.raw()->from()); 995 RawObject** toobj = reader->snapshot_code()
996 ? script.raw()->to_precompiled_snapshot()
997 : script.raw()->to_snapshot();
998 intptr_t num_flds = (toobj - script.raw()->from());
991 for (intptr_t i = 0; i <= num_flds; i++) { 999 for (intptr_t i = 0; i <= num_flds; i++) {
992 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); 1000 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference);
993 script.StorePointer((script.raw()->from() + i), 1001 script.StorePointer((script.raw()->from() + i),
994 reader->PassiveObjectHandle()->raw()); 1002 reader->PassiveObjectHandle()->raw());
995 } 1003 }
996 // Script wasn't allocated with nulls?
997 *reader->StringHandle() ^= String::null();
998 script.set_source(*reader->StringHandle());
999 1004
1000 return script.raw(); 1005 return script.raw();
1001 } 1006 }
1002 1007
1003 1008
1004 void RawScript::WriteTo(SnapshotWriter* writer, 1009 void RawScript::WriteTo(SnapshotWriter* writer,
1005 intptr_t object_id, 1010 intptr_t object_id,
1006 Snapshot::Kind kind, 1011 Snapshot::Kind kind,
1007 bool as_reference) { 1012 bool as_reference) {
1008 ASSERT(writer != NULL); 1013 ASSERT(writer != NULL);
1009 ASSERT(tokens_ != TokenStream::null()); 1014 ASSERT(tokens_ != TokenStream::null());
1010 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 1015 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
1011 1016
1012 // Write out the serialization header value for this object. 1017 // Write out the serialization header value for this object.
1013 writer->WriteInlinedObjectHeader(object_id); 1018 writer->WriteInlinedObjectHeader(object_id);
1014 1019
1015 // Write out the class and tags information. 1020 // Write out the class and tags information.
1016 writer->WriteVMIsolateObject(kScriptCid); 1021 writer->WriteVMIsolateObject(kScriptCid);
1017 writer->WriteTags(writer->GetObjectTags(this)); 1022 writer->WriteTags(writer->GetObjectTags(this));
1018 1023
1019 // Write out all the non object fields. 1024 // Write out all the non object fields.
1020 writer->Write<int32_t>(ptr()->line_offset_); 1025 writer->Write<int32_t>(ptr()->line_offset_);
1021 writer->Write<int32_t>(ptr()->col_offset_); 1026 writer->Write<int32_t>(ptr()->col_offset_);
1022 writer->Write<int8_t>(ptr()->kind_); 1027 writer->Write<int8_t>(ptr()->kind_);
1023 1028
1024 // Write out all the object pointer fields. 1029 // Write out all the object pointer fields.
1025 SnapshotWriterVisitor visitor(writer, kAsReference); 1030 SnapshotWriterVisitor visitor(writer, kAsReference);
1026 visitor.VisitPointers(from(), to_snapshot()); 1031 RawObject** toobj = writer->snapshot_code() ? to_precompiled_snapshot()
1032 : to_snapshot();
1033 visitor.VisitPointers(from(), toobj);
1027 } 1034 }
1028 1035
1029 1036
1030 RawLibrary* Library::ReadFrom(SnapshotReader* reader, 1037 RawLibrary* Library::ReadFrom(SnapshotReader* reader,
1031 intptr_t object_id, 1038 intptr_t object_id,
1032 intptr_t tags, 1039 intptr_t tags,
1033 Snapshot::Kind kind, 1040 Snapshot::Kind kind,
1034 bool as_reference) { 1041 bool as_reference) {
1035 ASSERT(reader != NULL); 1042 ASSERT(reader != NULL);
1036 ASSERT(kind != Snapshot::kMessage); 1043 ASSERT(kind != Snapshot::kMessage);
(...skipping 2437 matching lines...) Expand 10 before | Expand all | Expand 10 after
3474 // We do not allow objects with native fields in an isolate message. 3481 // We do not allow objects with native fields in an isolate message.
3475 writer->SetWriteException(Exceptions::kArgument, 3482 writer->SetWriteException(Exceptions::kArgument,
3476 "Illegal argument in isolate message" 3483 "Illegal argument in isolate message"
3477 " : (object is a UserTag)"); 3484 " : (object is a UserTag)");
3478 } else { 3485 } else {
3479 UNREACHABLE(); 3486 UNREACHABLE();
3480 } 3487 }
3481 } 3488 }
3482 3489
3483 } // namespace dart 3490 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698