| OLD | NEW |
| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 #else | 217 #else |
| 218 return strdup("JIT runtime cannot run a precompiled snapshot"); | 218 return strdup("JIT runtime cannot run a precompiled snapshot"); |
| 219 #endif | 219 #endif |
| 220 } | 220 } |
| 221 if (instructions_snapshot == NULL) { | 221 if (instructions_snapshot == NULL) { |
| 222 return strdup("Missing instructions snapshot"); | 222 return strdup("Missing instructions snapshot"); |
| 223 } | 223 } |
| 224 if (data_snapshot == NULL) { | 224 if (data_snapshot == NULL) { |
| 225 return strdup("Missing rodata snapshot"); | 225 return strdup("Missing rodata snapshot"); |
| 226 } | 226 } |
| 227 vm_isolate_->SetupInstructionsSnapshotPage(instructions_snapshot); | |
| 228 vm_isolate_->SetupDataSnapshotPage(data_snapshot); | |
| 229 } else if (Snapshot::IsFull(snapshot_kind_)) { | 227 } else if (Snapshot::IsFull(snapshot_kind_)) { |
| 230 #if defined(DART_PRECOMPILED_RUNTIME) | 228 #if defined(DART_PRECOMPILED_RUNTIME) |
| 231 return strdup("Precompiled runtime requires a precompiled snapshot"); | 229 return strdup("Precompiled runtime requires a precompiled snapshot"); |
| 232 #else | 230 #else |
| 233 if (instructions_snapshot != NULL) { | |
| 234 return strdup("Unexpected instructions snapshot"); | |
| 235 } | |
| 236 if (data_snapshot != NULL) { | |
| 237 return strdup("Unexpected rodata snapshot"); | |
| 238 } | |
| 239 StubCode::InitOnce(); | 231 StubCode::InitOnce(); |
| 240 #endif | 232 #endif |
| 241 } else { | 233 } else { |
| 242 return strdup("Invalid vm isolate snapshot seen"); | 234 return strdup("Invalid vm isolate snapshot seen"); |
| 243 } | 235 } |
| 236 if (instructions_snapshot != NULL) { |
| 237 vm_isolate_->SetupInstructionsSnapshotPage(instructions_snapshot); |
| 238 } |
| 239 if (instructions_snapshot != NULL) { |
| 240 vm_isolate_->SetupDataSnapshotPage(data_snapshot); |
| 241 } |
| 244 VmIsolateSnapshotReader reader(snapshot->kind(), snapshot->content(), | 242 VmIsolateSnapshotReader reader(snapshot->kind(), snapshot->content(), |
| 245 snapshot->length(), instructions_snapshot, | 243 snapshot->length(), instructions_snapshot, |
| 246 data_snapshot, T); | 244 data_snapshot, T); |
| 247 const Error& error = Error::Handle(reader.ReadVmIsolateSnapshot()); | 245 const Error& error = Error::Handle(reader.ReadVmIsolateSnapshot()); |
| 248 if (!error.IsNull()) { | 246 if (!error.IsNull()) { |
| 249 // Must copy before leaving the zone. | 247 // Must copy before leaving the zone. |
| 250 return strdup(error.ToErrorCString()); | 248 return strdup(error.ToErrorCString()); |
| 251 } | 249 } |
| 252 #if !defined(PRODUCT) | 250 #if !defined(PRODUCT) |
| 253 if (tds.enabled()) { | 251 if (tds.enabled()) { |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 if ((snapshot_buffer != NULL) && kernel_program == NULL) { | 522 if ((snapshot_buffer != NULL) && kernel_program == NULL) { |
| 525 // Read the snapshot and setup the initial state. | 523 // Read the snapshot and setup the initial state. |
| 526 NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(), | 524 NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(), |
| 527 "IsolateSnapshotReader")); | 525 "IsolateSnapshotReader")); |
| 528 // TODO(turnidge): Remove once length is not part of the snapshot. | 526 // TODO(turnidge): Remove once length is not part of the snapshot. |
| 529 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); | 527 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); |
| 530 if (snapshot == NULL) { | 528 if (snapshot == NULL) { |
| 531 const String& message = String::Handle(String::New("Invalid snapshot")); | 529 const String& message = String::Handle(String::New("Invalid snapshot")); |
| 532 return ApiError::New(message); | 530 return ApiError::New(message); |
| 533 } | 531 } |
| 534 if (snapshot->kind() != snapshot_kind_) { | 532 if (snapshot->kind() != snapshot_kind_ && |
| 533 !((snapshot->kind() == Snapshot::kAppJIT) && |
| 534 (snapshot_kind_ == Snapshot::kCore))) { |
| 535 const String& message = String::Handle( | 535 const String& message = String::Handle( |
| 536 String::NewFormatted("Invalid snapshot kind: got '%s', expected '%s'", | 536 String::NewFormatted("Invalid snapshot kind: got '%s', expected '%s'", |
| 537 Snapshot::KindToCString(snapshot->kind()), | 537 Snapshot::KindToCString(snapshot->kind()), |
| 538 Snapshot::KindToCString(snapshot_kind_))); | 538 Snapshot::KindToCString(snapshot_kind_))); |
| 539 return ApiError::New(message); | 539 return ApiError::New(message); |
| 540 } | 540 } |
| 541 ASSERT(Snapshot::IsFull(snapshot->kind())); | 541 ASSERT(Snapshot::IsFull(snapshot->kind())); |
| 542 if (FLAG_trace_isolates) { | 542 if (FLAG_trace_isolates) { |
| 543 OS::Print("Size of isolate snapshot = %" Pd "\n", snapshot->length()); | 543 OS::Print("Size of isolate snapshot = %" Pd "\n", snapshot->length()); |
| 544 } | 544 } |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 return predefined_handles_->handles_.IsValidScopedHandle(address); | 737 return predefined_handles_->handles_.IsValidScopedHandle(address); |
| 738 } | 738 } |
| 739 | 739 |
| 740 | 740 |
| 741 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { | 741 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { |
| 742 ASSERT(predefined_handles_ != NULL); | 742 ASSERT(predefined_handles_ != NULL); |
| 743 return predefined_handles_->api_handles_.IsValidHandle(handle); | 743 return predefined_handles_->api_handles_.IsValidHandle(handle); |
| 744 } | 744 } |
| 745 | 745 |
| 746 } // namespace dart | 746 } // namespace dart |
| OLD | NEW |