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

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

Issue 1686773002: Precompilation: drop unused types and type arguments and empty classes and libraries. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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/raw_object_snapshot.cc ('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/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 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 const char* expected_version = Version::SnapshotString(); 676 const char* expected_version = Version::SnapshotString();
677 ASSERT(expected_version != NULL); 677 ASSERT(expected_version != NULL);
678 const intptr_t version_len = strlen(expected_version); 678 const intptr_t version_len = strlen(expected_version);
679 if (PendingBytes() < version_len) { 679 if (PendingBytes() < version_len) {
680 const intptr_t kMessageBufferSize = 128; 680 const intptr_t kMessageBufferSize = 128;
681 char message_buffer[kMessageBufferSize]; 681 char message_buffer[kMessageBufferSize];
682 OS::SNPrint(message_buffer, 682 OS::SNPrint(message_buffer,
683 kMessageBufferSize, 683 kMessageBufferSize,
684 "No full snapshot version found, expected '%s'", 684 "No full snapshot version found, expected '%s'",
685 Version::SnapshotString()); 685 Version::SnapshotString());
686 const String& msg = String::Handle(String::New(message_buffer)); 686 // This can also fail while bringing up the VM isolate, so make sure to
687 return ApiError::New(msg); 687 // allocate the error message in old space.
688 const String& msg = String::Handle(String::New(message_buffer, Heap::kOld));
689 return ApiError::New(msg, Heap::kOld);
688 } 690 }
689 691
690 const char* version = reinterpret_cast<const char*>(CurrentBufferAddress()); 692 const char* version = reinterpret_cast<const char*>(CurrentBufferAddress());
691 ASSERT(version != NULL); 693 ASSERT(version != NULL);
692 if (strncmp(version, expected_version, version_len)) { 694 if (strncmp(version, expected_version, version_len)) {
693 const intptr_t kMessageBufferSize = 256; 695 const intptr_t kMessageBufferSize = 256;
694 char message_buffer[kMessageBufferSize]; 696 char message_buffer[kMessageBufferSize];
695 char* actual_version = OS::StrNDup(version, version_len); 697 char* actual_version = OS::StrNDup(version, version_len);
696 OS::SNPrint(message_buffer, 698 OS::SNPrint(message_buffer,
697 kMessageBufferSize, 699 kMessageBufferSize,
(...skipping 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after
2156 } 2158 }
2157 2159
2158 // Check if object has already been serialized, in that case just write 2160 // Check if object has already been serialized, in that case just write
2159 // the object id out. 2161 // the object id out.
2160 intptr_t object_id = forward_list_->FindObject(rawobj); 2162 intptr_t object_id = forward_list_->FindObject(rawobj);
2161 if (object_id != kInvalidIndex) { 2163 if (object_id != kInvalidIndex) {
2162 WriteIndexedObject(object_id); 2164 WriteIndexedObject(object_id);
2163 return true; 2165 return true;
2164 } 2166 }
2165 2167
2166 // Now check if it is an object from the VM isolate (NOTE: premarked objects 2168 // Now check if it is an object from the VM isolate. These objects are shared
2167 // are considered to be objects in the VM isolate). These objects are shared
2168 // by all isolates. 2169 // by all isolates.
2169 if (rawobj->IsVMHeapObject() && HandleVMIsolateObject(rawobj)) { 2170 if (rawobj->IsVMHeapObject() && HandleVMIsolateObject(rawobj)) {
2170 return true; 2171 return true;
2171 } 2172 }
2172 2173
2173 // Check if it is a code object in that case just write a Null object 2174 // Check if it is a code object in that case just write a Null object
2174 // as we do not want code objects in the snapshot. 2175 // as we do not want code objects in the snapshot.
2175 if (cid == kCodeCid && !snapshot_code()) { 2176 if (cid == kCodeCid && !snapshot_code()) {
2176 WriteVMIsolateObject(kNullObject); 2177 WriteVMIsolateObject(kNullObject);
2177 return true; 2178 return true;
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
2677 if (setjmp(*jump.Set()) == 0) { 2678 if (setjmp(*jump.Set()) == 0) {
2678 NoSafepointScope no_safepoint; 2679 NoSafepointScope no_safepoint;
2679 WriteObject(obj.raw()); 2680 WriteObject(obj.raw());
2680 } else { 2681 } else {
2681 ThrowException(exception_type(), exception_msg()); 2682 ThrowException(exception_type(), exception_msg());
2682 } 2683 }
2683 } 2684 }
2684 2685
2685 2686
2686 } // namespace dart 2687 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object_snapshot.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698