Index: runtime/bin/loader.cc |
diff --git a/runtime/bin/loader.cc b/runtime/bin/loader.cc |
index b25f3c86f6fd5e2718cfba066d7cfd6f09a8abeb..f67c724568614911691de233d7241e6da46a3ca8 100644 |
--- a/runtime/bin/loader.cc |
+++ b/runtime/bin/loader.cc |
@@ -2,7 +2,6 @@ |
// for details. All rights reserved. Use of this source code is governed by a |
// BSD-style license that can be found in the LICENSE file. |
- |
#include "bin/loader.h" |
#include "bin/builtin.h" |
@@ -46,7 +45,6 @@ Loader::Loader(IsolateData* isolate_data) |
AddLoader(port_, isolate_data_); |
} |
- |
Loader::~Loader() { |
ASSERT(port_ != ILLEGAL_PORT); |
// Enter the monitor while we close the Dart port. After the Dart port is |
@@ -69,7 +67,6 @@ Loader::~Loader() { |
payload_length_ = 0; |
} |
- |
// Copy the contents of |message| into an |IOResult|. |
void Loader::IOResult::Setup(Dart_CObject* message) { |
ASSERT(message->type == Dart_CObject_kArray); |
@@ -122,7 +119,6 @@ void Loader::IOResult::Setup(Dart_CObject* message) { |
} |
} |
- |
void Loader::IOResult::Cleanup() { |
free(uri); |
free(resolved_uri); |
@@ -130,7 +126,6 @@ void Loader::IOResult::Cleanup() { |
free(payload); |
} |
- |
// Send the Loader Initialization message to the service isolate. This |
// message is sent the first time a loader is constructed for an isolate and |
// seeds the service isolate with some initial state about this isolate. |
@@ -150,31 +145,31 @@ void Loader::Init(const char* package_root, |
Dart_ListSetAt(request, 1, Dart_NewInteger(Dart_GetMainPortId())); |
Dart_ListSetAt(request, 2, Dart_NewInteger(_Dart_kInitLoader)); |
Dart_ListSetAt(request, 3, Dart_NewSendPort(port_)); |
- Dart_ListSetAt(request, 4, (package_root == NULL) |
- ? Dart_Null() |
- : Dart_NewStringFromCString(package_root)); |
- Dart_ListSetAt(request, 5, (packages_file == NULL) |
- ? Dart_Null() |
- : Dart_NewStringFromCString(packages_file)); |
+ Dart_ListSetAt(request, 4, |
+ (package_root == NULL) |
+ ? Dart_Null() |
+ : Dart_NewStringFromCString(package_root)); |
+ Dart_ListSetAt(request, 5, |
+ (packages_file == NULL) |
+ ? Dart_Null() |
+ : Dart_NewStringFromCString(packages_file)); |
Dart_ListSetAt(request, 6, Dart_NewStringFromCString(working_directory)); |
- Dart_ListSetAt(request, 7, (root_script_uri == NULL) |
- ? Dart_Null() |
- : Dart_NewStringFromCString(root_script_uri)); |
+ Dart_ListSetAt(request, 7, |
+ (root_script_uri == NULL) |
+ ? Dart_Null() |
+ : Dart_NewStringFromCString(root_script_uri)); |
Dart_ListSetAt(request, 8, Dart_NewBoolean(Dart_IsReloading())); |
- |
bool success = Dart_Post(loader_port, request); |
ASSERT(success); |
} |
- |
void Loader::SendImportExtensionRequest(Dart_Handle url, |
Dart_Handle library_url) { |
// This port delivers loading messages to the service isolate. |
Dart_Port loader_port = Builtin::LoadPort(); |
ASSERT(loader_port != ILLEGAL_PORT); |
- |
Dart_Handle request = Dart_NewList(6); |
Dart_ListSetAt(request, 0, trace_loader ? Dart_True() : Dart_False()); |
Dart_ListSetAt(request, 1, Dart_NewInteger(Dart_GetMainPortId())); |
@@ -190,7 +185,6 @@ void Loader::SendImportExtensionRequest(Dart_Handle url, |
} |
} |
- |
// Forward a request from the tag handler to the service isolate. |
void Loader::SendRequest(intptr_t tag, |
Dart_Handle url, |
@@ -214,7 +208,6 @@ void Loader::SendRequest(intptr_t tag, |
} |
} |
- |
// Forward a request from the tag handler to the kernel isolate. |
// [ tag, send port, url ] |
void Loader::SendKernelRequest(Dart_LibraryTag tag, Dart_Handle url) { |
@@ -232,7 +225,6 @@ void Loader::SendKernelRequest(Dart_LibraryTag tag, Dart_Handle url) { |
} |
} |
- |
void Loader::QueueMessage(Dart_CObject* message) { |
MonitorLocker ml(monitor_); |
if (results_length_ == results_capacity_) { |
@@ -249,7 +241,6 @@ void Loader::QueueMessage(Dart_CObject* message) { |
ml.Notify(); |
} |
- |
void Loader::BlockUntilComplete(ProcessResult process_result) { |
MonitorLocker ml(monitor_); |
@@ -270,7 +261,6 @@ void Loader::BlockUntilComplete(ProcessResult process_result) { |
} |
} |
- |
static bool LibraryHandleError(Dart_Handle library, Dart_Handle error) { |
if (!Dart_IsNull(library) && !Dart_IsError(library)) { |
ASSERT(Dart_IsLibrary(library)); |
@@ -283,14 +273,12 @@ static bool LibraryHandleError(Dart_Handle library, Dart_Handle error) { |
return false; |
} |
- |
static bool PathContainsSeparator(const char* path) { |
return (strchr(path, '/') != NULL) || |
((strncmp(File::PathSeparator(), "/", 1) != 0) && |
(strstr(path, File::PathSeparator()) != NULL)); |
} |
- |
void Loader::AddDependencyLocked(Loader* loader, const char* resolved_uri) { |
MallocGrowableArray<char*>* dependencies = |
loader->isolate_data_->dependencies(); |
@@ -300,7 +288,6 @@ void Loader::AddDependencyLocked(Loader* loader, const char* resolved_uri) { |
dependencies->Add(strdup(resolved_uri)); |
} |
- |
void Loader::ResolveDependenciesAsFilePaths() { |
IsolateData* isolate_data = |
reinterpret_cast<IsolateData*>(Dart_CurrentIsolateData()); |
@@ -331,7 +318,6 @@ void Loader::ResolveDependenciesAsFilePaths() { |
} |
} |
- |
bool Loader::ProcessResultLocked(Loader* loader, Loader::IOResult* result) { |
// We have to copy everything we care about out of |result| because after |
// dropping the lock below |result| may no longer valid. |
@@ -475,7 +461,6 @@ bool Loader::ProcessResultLocked(Loader* loader, Loader::IOResult* result) { |
return true; |
} |
- |
bool Loader::ProcessPayloadResultLocked(Loader* loader, |
Loader::IOResult* result) { |
// A negative result tag indicates a loading error occurred in the service |
@@ -493,7 +478,6 @@ bool Loader::ProcessPayloadResultLocked(Loader* loader, |
return true; |
} |
- |
bool Loader::ProcessQueueLocked(ProcessResult process_result) { |
bool hit_error = false; |
for (intptr_t i = 0; i < results_length(); i++) { |
@@ -508,7 +492,6 @@ bool Loader::ProcessQueueLocked(ProcessResult process_result) { |
return !hit_error; |
} |
- |
void Loader::InitForSnapshot(const char* snapshot_uri) { |
IsolateData* isolate_data = |
reinterpret_cast<IsolateData*>(Dart_CurrentIsolateData()); |
@@ -523,7 +506,6 @@ void Loader::InitForSnapshot(const char* snapshot_uri) { |
delete loader; |
} |
- |
#define RETURN_ERROR(result) \ |
if (Dart_IsError(result)) return result; |
@@ -568,7 +550,6 @@ Dart_Handle Loader::ReloadNativeExtensions() { |
return Dart_True(); |
} |
- |
Dart_Handle Loader::SendAndProcessReply(intptr_t tag, |
Dart_Handle url, |
uint8_t** payload, |
@@ -609,14 +590,12 @@ Dart_Handle Loader::SendAndProcessReply(intptr_t tag, |
return Dart_Null(); |
} |
- |
Dart_Handle Loader::LoadUrlContents(Dart_Handle url, |
uint8_t** payload, |
intptr_t* payload_length) { |
return SendAndProcessReply(Dart_kScriptTag, url, payload, payload_length); |
} |
- |
Dart_Handle Loader::ResolveAsFilePath(Dart_Handle url, |
uint8_t** payload, |
intptr_t* payload_length) { |
@@ -631,7 +610,6 @@ Dart_Handle Loader::LibraryTagHandler(Dart_LibraryTag tag, |
return Dart_Null(); |
} |
- |
Dart_Handle Loader::DartColonLibraryTagHandler(Dart_LibraryTag tag, |
Dart_Handle library, |
Dart_Handle url, |
@@ -749,9 +727,9 @@ Dart_Handle Loader::LibraryTagHandler(Dart_LibraryTag tag, |
if (Dart_KernelIsolateIsRunning()) { |
loader->SendKernelRequest(tag, url); |
} else { |
- loader->SendRequest(tag, url, (library != Dart_Null()) |
- ? Dart_LibraryUrl(library) |
- : Dart_Null()); |
+ loader->SendRequest( |
+ tag, url, |
+ (library != Dart_Null()) ? Dart_LibraryUrl(library) : Dart_Null()); |
} |
} |
@@ -795,7 +773,6 @@ Dart_Handle Loader::LibraryTagHandler(Dart_LibraryTag tag, |
return Dart_Null(); |
} |
- |
Dart_Handle Loader::DartColonLibraryTagHandler(Dart_LibraryTag tag, |
Dart_Handle library, |
Dart_Handle url, |
@@ -839,18 +816,15 @@ Dart_Handle Loader::DartColonLibraryTagHandler(Dart_LibraryTag tag, |
} |
#endif // !defined(DART_PRECOMPILED_RUNTIME) |
- |
void Loader::InitOnce() { |
loader_infos_lock_ = new Mutex(); |
} |
- |
Mutex* Loader::loader_infos_lock_; |
Loader::LoaderInfo* Loader::loader_infos_ = NULL; |
intptr_t Loader::loader_infos_length_ = 0; |
intptr_t Loader::loader_infos_capacity_ = 0; |
- |
// Add a mapping from |port| to |isolate_data| (really the loader). When a |
// native message arrives, we use this map to report the I/O result to the |
// correct loader. |
@@ -878,7 +852,6 @@ void Loader::AddLoader(Dart_Port port, IsolateData* isolate_data) { |
ASSERT(LoaderForLocked(port) != NULL); |
} |
- |
// Remove |port| from the map. |
// This happens once an isolate has finished loading. |
void Loader::RemoveLoader(Dart_Port port) { |
@@ -894,7 +867,6 @@ void Loader::RemoveLoader(Dart_Port port) { |
loader_infos_length_--; |
} |
- |
intptr_t Loader::LoaderIndexFor(Dart_Port port) { |
for (intptr_t i = 0; i < loader_infos_length_; i++) { |
if (loader_infos_[i].port == port) { |
@@ -904,7 +876,6 @@ intptr_t Loader::LoaderIndexFor(Dart_Port port) { |
return -1; |
} |
- |
Loader* Loader::LoaderForLocked(Dart_Port port) { |
intptr_t index = LoaderIndexFor(port); |
if (index < 0) { |
@@ -913,13 +884,11 @@ Loader* Loader::LoaderForLocked(Dart_Port port) { |
return loader_infos_[index].isolate_data->loader(); |
} |
- |
Loader* Loader::LoaderFor(Dart_Port port) { |
MutexLocker ml(loader_infos_lock_); |
return LoaderForLocked(port); |
} |
- |
void Loader::NativeMessageHandler(Dart_Port dest_port_id, |
Dart_CObject* message) { |
MutexLocker ml(loader_infos_lock_); |