| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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/isolate_reload.h" | 5 #include "vm/isolate_reload.h" |
| 6 | 6 |
| 7 #include "vm/become.h" | 7 #include "vm/become.h" |
| 8 #include "vm/code_generator.h" | 8 #include "vm/code_generator.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 void InstanceMorpher::Dump() const { | 155 void InstanceMorpher::Dump() const { |
| 156 LogBlock blocker; | 156 LogBlock blocker; |
| 157 THR_Print("Morphing from "); | 157 THR_Print("Morphing from "); |
| 158 DumpFormatFor(from_); | 158 DumpFormatFor(from_); |
| 159 THR_Print("To "); | 159 THR_Print("To "); |
| 160 DumpFormatFor(to_); | 160 DumpFormatFor(to_); |
| 161 THR_Print("\n"); | 161 THR_Print("\n"); |
| 162 } | 162 } |
| 163 | 163 |
| 164 | 164 |
| 165 void InstanceMorpher::AppendTo(JSONArray* array) { |
| 166 JSONObject jsobj(array); |
| 167 jsobj.AddProperty("type", "Morpher"); |
| 168 jsobj.AddProperty("class", to_); |
| 169 jsobj.AddProperty("instances", before()->length()); |
| 170 JSONArray map(&jsobj, "mapping"); |
| 171 for (int i = 0; i < mapping_.length(); i += 2) { |
| 172 JSONArray pair(&map); |
| 173 pair.AddValue(mapping_.At(i)); |
| 174 pair.AddValue(mapping_.At(i+1)); |
| 175 } |
| 176 } |
| 177 |
| 178 |
| 165 void ReasonForCancelling::Report(IsolateReloadContext* context) { | 179 void ReasonForCancelling::Report(IsolateReloadContext* context) { |
| 166 const Error& error = Error::Handle(ToError()); | 180 const Error& error = Error::Handle(ToError()); |
| 167 context->ReportError(error); | 181 context->ReportError(error); |
| 168 } | 182 } |
| 169 | 183 |
| 170 | 184 |
| 171 RawError* ReasonForCancelling::ToError() { | 185 RawError* ReasonForCancelling::ToError() { |
| 172 // By default create the error returned from ToString. | 186 // By default create the error returned from ToString. |
| 173 const String& message = String::Handle(ToString()); | 187 const String& message = String::Handle(ToString()); |
| 174 return LanguageError::New(message); | 188 return LanguageError::New(message); |
| 175 } | 189 } |
| 176 | 190 |
| 177 | 191 |
| 178 RawString* ReasonForCancelling::ToString() { | 192 RawString* ReasonForCancelling::ToString() { |
| 179 UNREACHABLE(); | 193 UNREACHABLE(); |
| 180 return NULL; | 194 return NULL; |
| 181 } | 195 } |
| 182 | 196 |
| 183 | 197 |
| 198 void ReasonForCancelling::AppendTo(JSONArray* array) { |
| 199 JSONObject jsobj(array); |
| 200 jsobj.AddProperty("type", "ReasonForCancelling"); |
| 201 const String& message = String::Handle(ToString()); |
| 202 jsobj.AddProperty("message", message); |
| 203 } |
| 204 |
| 205 |
| 206 void ClassReasonForCancelling::AppendTo(JSONArray* array) { |
| 207 JSONObject jsobj(array); |
| 208 jsobj.AddProperty("type", "ReasonForCancelling"); |
| 209 jsobj.AddProperty("class", from_); |
| 210 const String& message = String::Handle(ToString()); |
| 211 jsobj.AddProperty("message", message); |
| 212 } |
| 213 |
| 184 RawError* IsolateReloadContext::error() const { | 214 RawError* IsolateReloadContext::error() const { |
| 185 ASSERT(has_error()); | 215 ASSERT(has_error()); |
| 186 // Report the first error to the surroundings. | 216 // Report the first error to the surroundings. |
| 187 const Error& error = | 217 const Error& error = |
| 188 Error::Handle(reasons_to_cancel_reload_.At(0)->ToError()); | 218 Error::Handle(reasons_to_cancel_reload_.At(0)->ToError()); |
| 189 OS::Print("[[%s]]\n", error.ToCString()); | 219 OS::Print("[[%s]]\n", error.ToCString()); |
| 190 return error.raw(); | 220 return error.raw(); |
| 191 } | 221 } |
| 192 | 222 |
| 223 |
| 193 class ScriptUrlSetTraits { | 224 class ScriptUrlSetTraits { |
| 194 public: | 225 public: |
| 195 static bool ReportStats() { return false; } | 226 static bool ReportStats() { return false; } |
| 196 static const char* Name() { return "ScriptUrlSetTraits"; } | 227 static const char* Name() { return "ScriptUrlSetTraits"; } |
| 197 | 228 |
| 198 static bool IsMatch(const Object& a, const Object& b) { | 229 static bool IsMatch(const Object& a, const Object& b) { |
| 199 if (!a.IsString() || !b.IsString()) { | 230 if (!a.IsString() || !b.IsString()) { |
| 200 return false; | 231 return false; |
| 201 } | 232 } |
| 202 | 233 |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 // not remove dead subclasses. Rebuild the direct subclass | 514 // not remove dead subclasses. Rebuild the direct subclass |
| 484 // information from scratch. | 515 // information from scratch. |
| 485 RebuildDirectSubclasses(); | 516 RebuildDirectSubclasses(); |
| 486 | 517 |
| 487 if (FLAG_write_protect_code) { | 518 if (FLAG_write_protect_code) { |
| 488 // Disable code page write protection while we are reloading. | 519 // Disable code page write protection while we are reloading. |
| 489 I->heap()->WriteProtectCode(true); | 520 I->heap()->WriteProtectCode(true); |
| 490 } | 521 } |
| 491 | 522 |
| 492 BackgroundCompiler::Enable(); | 523 BackgroundCompiler::Enable(); |
| 524 |
| 525 if (FLAG_trace_reload) { |
| 526 JSONStream stream; |
| 527 ReportOnJSON(&stream); |
| 528 OS::Print("\nJSON report:\n %s\n", stream.ToCString()); |
| 529 } |
| 493 } | 530 } |
| 494 | 531 |
| 495 | 532 |
| 533 void IsolateReloadContext::ReportOnJSON(JSONStream* stream) { |
| 534 JSONObject jsobj(stream); |
| 535 jsobj.AddProperty("type", "Reload"); |
| 536 jsobj.AddProperty("succeeded", !HasReasonsForCancelling()); |
| 537 if (HasReasonsForCancelling()) { |
| 538 JSONArray array(&jsobj, "reasons"); |
| 539 for (intptr_t i = 0; i < reasons_to_cancel_reload_.length(); i++) { |
| 540 ReasonForCancelling* reason = reasons_to_cancel_reload_.At(i); |
| 541 reason->AppendTo(&array); |
| 542 } |
| 543 } else { |
| 544 JSONArray array(&jsobj, "changes"); |
| 545 for (intptr_t i = 0; i < instance_morphers_.length(); i++) { |
| 546 instance_morphers_.At(i)->AppendTo(&array); |
| 547 } |
| 548 } |
| 549 } |
| 550 |
| 551 |
| 496 void IsolateReloadContext::AbortReload(const Error& error) { | 552 void IsolateReloadContext::AbortReload(const Error& error) { |
| 497 AddReasonForCancelling(new Aborted(error)); | 553 AddReasonForCancelling(new Aborted(error)); |
| 498 ReportReasonsForCancelling(); | 554 ReportReasonsForCancelling(); |
| 499 Rollback(); | 555 Rollback(); |
| 500 } | 556 } |
| 501 | 557 |
| 502 | 558 |
| 503 void IsolateReloadContext::EnsuredUnoptimizedCodeForStack() { | 559 void IsolateReloadContext::EnsuredUnoptimizedCodeForStack() { |
| 504 TIMELINE_SCOPE(EnsuredUnoptimizedCodeForStack); | 560 TIMELINE_SCOPE(EnsuredUnoptimizedCodeForStack); |
| 505 StackFrameIterator it(StackFrameIterator::kDontValidateFrames); | 561 StackFrameIterator it(StackFrameIterator::kDontValidateFrames); |
| (...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1391 ASSERT(!super_cls.IsNull()); | 1447 ASSERT(!super_cls.IsNull()); |
| 1392 super_cls.AddDirectSubclass(cls); | 1448 super_cls.AddDirectSubclass(cls); |
| 1393 } | 1449 } |
| 1394 } | 1450 } |
| 1395 } | 1451 } |
| 1396 } | 1452 } |
| 1397 | 1453 |
| 1398 #endif // !PRODUCT | 1454 #endif // !PRODUCT |
| 1399 | 1455 |
| 1400 } // namespace dart | 1456 } // namespace dart |
| OLD | NEW |