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

Unified Diff: runtime/bin/loader.cc

Issue 2041173002: Fix Dart2js, analyzer bots (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/loader.cc
diff --git a/runtime/bin/loader.cc b/runtime/bin/loader.cc
index 58496c92def297030a6a65bf60374b2002a828f1..35a09357fdfec0bed534daf554b46b3c47f154b7 100644
--- a/runtime/bin/loader.cc
+++ b/runtime/bin/loader.cc
@@ -231,9 +231,24 @@ bool Loader::ProcessResultLocked(Loader::IOResult* result) {
library_uri =
Dart_NewStringFromCString(reinterpret_cast<char*>(result->library_uri));
}
- Dart_Handle source =
- Dart_NewStringFromUTF8(result->payload,
- result->payload_length);
+ // Check for payload and load accordingly.
+ bool is_snapshot = false;
+ const uint8_t* payload = result->payload;
+ intptr_t payload_length = result->payload_length;
+ payload =
+ DartUtils::SniffForMagicNumber(payload,
+ &payload_length,
+ &is_snapshot);
+ Dart_Handle source = Dart_Null();
+ if (!is_snapshot) {
+ source = Dart_NewStringFromUTF8(result->payload,
+ result->payload_length);
+ if (Dart_IsError(source)) {
+ error_ = DartUtils::NewError("%s is not a valid UTF-8 script",
+ reinterpret_cast<char*>(result->uri));
+ return false;
+ }
+ }
intptr_t tag = result->tag;
// No touching.
@@ -245,7 +260,6 @@ bool Loader::ProcessResultLocked(Loader::IOResult* result) {
Dart_Handle dart_result = Dart_Null();
-
switch (tag) {
case Dart_kImportTag:
dart_result = Dart_LoadLibrary(uri, source, 0, 0);
@@ -258,7 +272,11 @@ bool Loader::ProcessResultLocked(Loader::IOResult* result) {
}
break;
case Dart_kScriptTag:
- dart_result = Dart_LoadScript(uri, source, 0, 0);
+ if (is_snapshot) {
+ dart_result = Dart_LoadScriptFromSnapshot(payload, payload_length);
+ } else {
+ dart_result = Dart_LoadScript(uri, source, 0, 0);
+ }
break;
default:
UNREACHABLE();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698