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

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

Issue 1815733003: Remove recently introduced FunctionType vm class by merging it into class Type. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address comment Created 4 years, 9 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
« no previous file with comments | « runtime/vm/snapshot.h ('k') | runtime/vm/symbols.h » ('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/snapshot.h" 5 #include "vm/snapshot.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/bootstrap.h" 8 #include "vm/bootstrap.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/dart.h" 10 #include "vm/dart.h"
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 RawUnresolvedClass* SnapshotReader::NewUnresolvedClass() { 953 RawUnresolvedClass* SnapshotReader::NewUnresolvedClass() {
954 ALLOC_NEW_OBJECT(UnresolvedClass); 954 ALLOC_NEW_OBJECT(UnresolvedClass);
955 } 955 }
956 956
957 957
958 RawType* SnapshotReader::NewType() { 958 RawType* SnapshotReader::NewType() {
959 ALLOC_NEW_OBJECT(Type); 959 ALLOC_NEW_OBJECT(Type);
960 } 960 }
961 961
962 962
963 RawFunctionType* SnapshotReader::NewFunctionType() {
964 ALLOC_NEW_OBJECT(FunctionType);
965 }
966
967
968 RawTypeRef* SnapshotReader::NewTypeRef() { 963 RawTypeRef* SnapshotReader::NewTypeRef() {
969 ALLOC_NEW_OBJECT(TypeRef); 964 ALLOC_NEW_OBJECT(TypeRef);
970 } 965 }
971 966
972 967
973 RawTypeParameter* SnapshotReader::NewTypeParameter() { 968 RawTypeParameter* SnapshotReader::NewTypeParameter() {
974 ALLOC_NEW_OBJECT(TypeParameter); 969 ALLOC_NEW_OBJECT(TypeParameter);
975 } 970 }
976 971
977 972
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 ((c >= 'A') && (c <= 'Z')) || 1166 ((c >= 'A') && (c <= 'Z')) ||
1172 ((c >= '0') && (c <= '9'))) { 1167 ((c >= '0') && (c <= '9'))) {
1173 continue; 1168 continue;
1174 } 1169 }
1175 *label = '_'; 1170 *label = '_';
1176 } 1171 }
1177 } 1172 }
1178 1173
1179 1174
1180 void InstructionsWriter::WriteAssembly() { 1175 void InstructionsWriter::WriteAssembly() {
1181 Zone* Z = Thread::Current()->zone(); 1176 Zone* zone = Thread::Current()->zone();
1182 1177
1183 // Handlify collected raw pointers as building the names below 1178 // Handlify collected raw pointers as building the names below
1184 // will allocate on the Dart heap. 1179 // will allocate on the Dart heap.
1185 for (intptr_t i = 0; i < instructions_.length(); i++) { 1180 for (intptr_t i = 0; i < instructions_.length(); i++) {
1186 InstructionsData& data = instructions_[i]; 1181 InstructionsData& data = instructions_[i];
1187 data.insns_ = &Instructions::Handle(Z, data.raw_insns_); 1182 data.insns_ = &Instructions::Handle(zone, data.raw_insns_);
1188 ASSERT(data.raw_code_ != NULL); 1183 ASSERT(data.raw_code_ != NULL);
1189 data.code_ = &Code::Handle(Z, data.raw_code_); 1184 data.code_ = &Code::Handle(zone, data.raw_code_);
1190 } 1185 }
1191 for (intptr_t i = 0; i < objects_.length(); i++) { 1186 for (intptr_t i = 0; i < objects_.length(); i++) {
1192 ObjectData& data = objects_[i]; 1187 ObjectData& data = objects_[i];
1193 data.obj_ = &Object::Handle(Z, data.raw_obj_); 1188 data.obj_ = &Object::Handle(zone, data.raw_obj_);
1194 } 1189 }
1195 1190
1196 stream_.Print(".text\n"); 1191 stream_.Print(".text\n");
1197 stream_.Print(".globl _kInstructionsSnapshot\n"); 1192 stream_.Print(".globl _kInstructionsSnapshot\n");
1198 // Start snapshot at page boundary. 1193 // Start snapshot at page boundary.
1199 ASSERT(VirtualMemory::PageSize() >= OS::kMaxPreferredCodeAlignment); 1194 ASSERT(VirtualMemory::PageSize() >= OS::kMaxPreferredCodeAlignment);
1200 stream_.Print(".balign %" Pd ", 0\n", VirtualMemory::PageSize()); 1195 stream_.Print(".balign %" Pd ", 0\n", VirtualMemory::PageSize());
1201 stream_.Print("_kInstructionsSnapshot:\n"); 1196 stream_.Print("_kInstructionsSnapshot:\n");
1202 1197
1203 // This head also provides the gap to make the instructions snapshot 1198 // This head also provides the gap to make the instructions snapshot
1204 // look like a HeapPage. 1199 // look like a HeapPage.
1205 intptr_t instructions_length = next_offset_; 1200 intptr_t instructions_length = next_offset_;
1206 WriteWordLiteral(instructions_length); 1201 WriteWordLiteral(instructions_length);
1207 intptr_t header_words = InstructionsSnapshot::kHeaderSize / sizeof(uword); 1202 intptr_t header_words = InstructionsSnapshot::kHeaderSize / sizeof(uword);
1208 for (intptr_t i = 1; i < header_words; i++) { 1203 for (intptr_t i = 1; i < header_words; i++) {
1209 WriteWordLiteral(0); 1204 WriteWordLiteral(0);
1210 } 1205 }
1211 1206
1212 Object& owner = Object::Handle(Z); 1207 Object& owner = Object::Handle(zone);
1213 String& str = String::Handle(Z); 1208 String& str = String::Handle(zone);
1214 1209
1215 for (intptr_t i = 0; i < instructions_.length(); i++) { 1210 for (intptr_t i = 0; i < instructions_.length(); i++) {
1216 const Instructions& insns = *instructions_[i].insns_; 1211 const Instructions& insns = *instructions_[i].insns_;
1217 const Code& code = *instructions_[i].code_; 1212 const Code& code = *instructions_[i].code_;
1218 1213
1219 ASSERT(insns.raw()->Size() % sizeof(uint64_t) == 0); 1214 ASSERT(insns.raw()->Size() % sizeof(uint64_t) == 0);
1220 1215
1221 { 1216 {
1222 // 1. Write from the header to the entry point. 1217 // 1. Write from the header to the entry point.
1223 NoSafepointScope no_safepoint; 1218 NoSafepointScope no_safepoint;
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 index -= max_vm_isolate_object_id_; 1492 index -= max_vm_isolate_object_id_;
1498 ASSERT(index < backward_references_->length()); 1493 ASSERT(index < backward_references_->length());
1499 BackRefNode& ref = (*backward_references_)[index]; 1494 BackRefNode& ref = (*backward_references_)[index];
1500 ref.AddPatchRecord(patch_object_id, patch_offset); 1495 ref.AddPatchRecord(patch_object_id, patch_offset);
1501 } 1496 }
1502 } 1497 }
1503 1498
1504 1499
1505 void SnapshotReader::ProcessDeferredCanonicalizations() { 1500 void SnapshotReader::ProcessDeferredCanonicalizations() {
1506 Type& typeobj = Type::Handle(); 1501 Type& typeobj = Type::Handle();
1507 FunctionType& funtypeobj = FunctionType::Handle();
1508 TypeArguments& typeargs = TypeArguments::Handle(); 1502 TypeArguments& typeargs = TypeArguments::Handle();
1509 Object& newobj = Object::Handle(); 1503 Object& newobj = Object::Handle();
1510 for (intptr_t i = 0; i < backward_references_->length(); i++) { 1504 for (intptr_t i = 0; i < backward_references_->length(); i++) {
1511 BackRefNode& backref = (*backward_references_)[i]; 1505 BackRefNode& backref = (*backward_references_)[i];
1512 if (backref.defer_canonicalization()) { 1506 if (backref.defer_canonicalization()) {
1513 Object* objref = backref.reference(); 1507 Object* objref = backref.reference();
1514 // Object should either be a type, a function type, or a type argument. 1508 // Object should either be a type or a type argument.
1515 if (objref->IsType()) { 1509 if (objref->IsType()) {
1516 typeobj ^= objref->raw(); 1510 typeobj ^= objref->raw();
1517 newobj = typeobj.Canonicalize(); 1511 newobj = typeobj.Canonicalize();
1518 } else if (objref->IsFunctionType()) {
1519 funtypeobj ^= objref->raw();
1520 newobj = funtypeobj.Canonicalize();
1521 } else { 1512 } else {
1522 ASSERT(objref->IsTypeArguments()); 1513 ASSERT(objref->IsTypeArguments());
1523 typeargs ^= objref->raw(); 1514 typeargs ^= objref->raw();
1524 newobj = typeargs.Canonicalize(); 1515 newobj = typeargs.Canonicalize();
1525 } 1516 }
1526 if (newobj.raw() != objref->raw()) { 1517 if (newobj.raw() != objref->raw()) {
1527 ZoneGrowableArray<intptr_t>* patches = backref.patch_records(); 1518 ZoneGrowableArray<intptr_t>* patches = backref.patch_records();
1528 ASSERT(newobj.IsCanonical()); 1519 ASSERT(newobj.IsCanonical());
1529 ASSERT(patches != NULL); 1520 ASSERT(patches != NULL);
1530 // First we replace the back ref table with the canonical object. 1521 // First we replace the back ref table with the canonical object.
(...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after
2696 if (setjmp(*jump.Set()) == 0) { 2687 if (setjmp(*jump.Set()) == 0) {
2697 NoSafepointScope no_safepoint; 2688 NoSafepointScope no_safepoint;
2698 WriteObject(obj.raw()); 2689 WriteObject(obj.raw());
2699 } else { 2690 } else {
2700 ThrowException(exception_type(), exception_msg()); 2691 ThrowException(exception_type(), exception_msg());
2701 } 2692 }
2702 } 2693 }
2703 2694
2704 2695
2705 } // namespace dart 2696 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/snapshot.h ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698