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

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

Issue 2481013006: Check that Dart_CreateIsolate is given a correct kind of snapshot. (Closed)
Patch Set: . Created 4 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/include/dart_api.h ('k') | runtime/vm/snapshot.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/dart.h" 5 #include "vm/dart.h"
6 6
7 #include "vm/become.h" 7 #include "vm/become.h"
8 #include "vm/clustered_snapshot.h" 8 #include "vm/clustered_snapshot.h"
9 #include "vm/code_observers.h" 9 #include "vm/code_observers.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 // Read the snapshot and setup the initial state. 523 // Read the snapshot and setup the initial state.
524 NOT_IN_PRODUCT(TimelineDurationScope tds(T, 524 NOT_IN_PRODUCT(TimelineDurationScope tds(T,
525 Timeline::GetIsolateStream(), "IsolateSnapshotReader")); 525 Timeline::GetIsolateStream(), "IsolateSnapshotReader"));
526 // TODO(turnidge): Remove once length is not part of the snapshot. 526 // TODO(turnidge): Remove once length is not part of the snapshot.
527 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); 527 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer);
528 if (snapshot == NULL) { 528 if (snapshot == NULL) {
529 const String& message = String::Handle( 529 const String& message = String::Handle(
530 String::New("Invalid snapshot")); 530 String::New("Invalid snapshot"));
531 return ApiError::New(message); 531 return ApiError::New(message);
532 } 532 }
533 if (snapshot->kind() != snapshot_kind_) {
534 const String& message = String::Handle(
535 String::NewFormatted("Invalid snapshot kind: got '%s', expected '%s'",
536 Snapshot::KindToCString(snapshot->kind()),
537 Snapshot::KindToCString(snapshot_kind_)));
538 return ApiError::New(message);
539 }
533 ASSERT(Snapshot::IsFull(snapshot->kind())); 540 ASSERT(Snapshot::IsFull(snapshot->kind()));
534 ASSERT(snapshot->kind() == snapshot_kind_);
535 if (FLAG_trace_isolates) { 541 if (FLAG_trace_isolates) {
536 OS::Print("Size of isolate snapshot = %" Pd "\n", snapshot->length()); 542 OS::Print("Size of isolate snapshot = %" Pd "\n", snapshot->length());
537 } 543 }
538 IsolateSnapshotReader reader(snapshot->kind(), 544 IsolateSnapshotReader reader(snapshot->kind(),
539 snapshot->content(), 545 snapshot->content(),
540 snapshot->length(), 546 snapshot->length(),
541 Dart::instructions_snapshot_buffer(), 547 Dart::instructions_snapshot_buffer(),
542 Dart::data_snapshot_buffer(), 548 Dart::data_snapshot_buffer(),
543 T); 549 T);
544 const Error& error = Error::Handle(reader.ReadFullSnapshot()); 550 const Error& error = Error::Handle(reader.ReadFullSnapshot());
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 return predefined_handles_->handles_.IsValidScopedHandle(address); 735 return predefined_handles_->handles_.IsValidScopedHandle(address);
730 } 736 }
731 737
732 738
733 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { 739 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) {
734 ASSERT(predefined_handles_ != NULL); 740 ASSERT(predefined_handles_ != NULL);
735 return predefined_handles_->api_handles_.IsValidHandle(handle); 741 return predefined_handles_->api_handles_.IsValidHandle(handle);
736 } 742 }
737 743
738 } // namespace dart 744 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698