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

Unified Diff: runtime/bin/gen_snapshot.cc

Issue 2518233003: Wire up the stub native resolver for all libraries in gen_snapshot (Closed)
Patch Set: rmacnak in person review 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/include/dart_api.h » ('j') | runtime/vm/dart_api_impl.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/gen_snapshot.cc
diff --git a/runtime/bin/gen_snapshot.cc b/runtime/bin/gen_snapshot.cc
index 53babb7c9ae823aa44e9bbe500a8ebba655c5cc2..6f4c67ed9feb2b8db6f5ab8f71cf2b4c89adb7f1 100644
--- a/runtime/bin/gen_snapshot.cc
+++ b/runtime/bin/gen_snapshot.cc
@@ -22,6 +22,7 @@
#include "bin/vmservice_impl.h"
#include "include/dart_api.h"
+#include "include/dart_tools_api.h"
#include "platform/hashmap.h"
#include "platform/globals.h"
@@ -684,7 +685,8 @@ static const char StubNativeFunctionName[] = "StubNativeFunction";
void StubNativeFunction(Dart_NativeArguments arguments) {
// This is a stub function for the resolver
- UNREACHABLE();
+ Dart_SetReturnValue(
+ arguments, Dart_NewApiError("<EMBEDDER DID NOT SETUP NATIVE RESOLVER>"));
}
@@ -735,6 +737,31 @@ static void SetupStubNativeResolver(size_t lib_index,
}
+// Iterate over all libraries and setup the stub native lookup. This must be
+// run after |SetupStubNativeResolversForPrecompilation| because the former
+// loads some libraries.
+static void SetupStubNativeResolvers() {
+ Dart_Handle library_ids = Dart_GetLibraryIds();
+ intptr_t library_ids_length;
+ Dart_ListLength(library_ids, &library_ids_length);
+ for (intptr_t i = 0; i < library_ids_length; i++) {
+ Dart_Handle library_id_handle = Dart_ListGetAt(library_ids, i);
+ DART_CHECK_VALID(library_id_handle);
+ int64_t library_id;
+ Dart_IntegerToInt64(library_id_handle, &library_id);
+ Dart_Handle library = Dart_GetLibraryFromId(library_id);
+ DART_CHECK_VALID(library);
+ Dart_NativeEntryResolver old_resolver = NULL;
+ Dart_GetNativeResolver(library, &old_resolver);
+ if (old_resolver == NULL) {
+ Dart_Handle result =
+ Dart_SetNativeResolver(library, &StubNativeLookup, &StubNativeSymbol);
+ DART_CHECK_VALID(result);
+ }
+ }
+}
+
+
static void ImportNativeEntryPointLibrariesIntoRoot(
const Dart_QualifiedFunctionName* entries) {
if (entries == NULL) {
@@ -1305,6 +1332,8 @@ int main(int argc, char** argv) {
SetupStubNativeResolversForPrecompilation(entry_points);
+ SetupStubNativeResolvers();
+
if (!is_kernel_file) {
// Load the specified script.
library = LoadSnapshotCreationScript(app_script_name);
« no previous file with comments | « no previous file | runtime/include/dart_api.h » ('j') | runtime/vm/dart_api_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698