Index: runtime/vm/benchmark_test.cc |
diff --git a/runtime/vm/benchmark_test.cc b/runtime/vm/benchmark_test.cc |
index 90cf8e682ce4c9eb81fccde7e501196f2670cd5e..f626ee9ed2d98b56aba5ec0a8f9ec618d9b432b8 100644 |
--- a/runtime/vm/benchmark_test.cc |
+++ b/runtime/vm/benchmark_test.cc |
@@ -6,6 +6,7 @@ |
#include "bin/builtin.h" |
#include "bin/file.h" |
+#include "bin/isolate_data.h" |
#include "platform/assert.h" |
#include "platform/globals.h" |
@@ -33,6 +34,16 @@ void Benchmark::RunAll(const char* executable) { |
} |
+Dart_Isolate Benchmark::CreateIsolate(const uint8_t* buffer) { |
+ bin::IsolateData* isolate_data = new bin::IsolateData(NULL, NULL, NULL); |
+ char* err = NULL; |
+ isolate_ = Dart_CreateIsolate(NULL, NULL, buffer, NULL, isolate_data, &err); |
+ EXPECT(isolate_ != NULL); |
+ free(err); |
+ return isolate_; |
+} |
+ |
+ |
// |
// Measure compile of all functions in dart core lib classes. |
// |
@@ -278,68 +289,6 @@ static void func(Dart_NativeArguments args) { |
} |
-// Emulates DartUtils::PrepareForScriptLoading. |
-static Dart_Handle PreparePackageRoot(const char* package_root, |
- Dart_Handle builtin_lib) { |
- // First ensure all required libraries are available. |
- Dart_Handle url = NewString(bin::DartUtils::kCoreLibURL); |
- DART_CHECK_VALID(url); |
- Dart_Handle core_lib = Dart_LookupLibrary(url); |
- DART_CHECK_VALID(core_lib); |
- url = NewString(bin::DartUtils::kAsyncLibURL); |
- DART_CHECK_VALID(url); |
- Dart_Handle async_lib = Dart_LookupLibrary(url); |
- DART_CHECK_VALID(async_lib); |
- url = NewString(bin::DartUtils::kIsolateLibURL); |
- DART_CHECK_VALID(url); |
- Dart_Handle isolate_lib = Dart_LookupLibrary(url); |
- DART_CHECK_VALID(isolate_lib); |
- url = NewString(bin::DartUtils::kInternalLibURL); |
- DART_CHECK_VALID(url); |
- Dart_Handle internal_lib = Dart_LookupLibrary(url); |
- DART_CHECK_VALID(internal_lib); |
- Dart_Handle io_lib = |
- bin::Builtin::LoadAndCheckLibrary(bin::Builtin::kIOLibrary); |
- DART_CHECK_VALID(io_lib); |
- |
- // We need to ensure that all the scripts loaded so far are finalized |
- // as we are about to invoke some Dart code below to setup closures. |
- Dart_Handle result = Dart_FinalizeLoading(false); |
- DART_CHECK_VALID(result); |
- |
- // Necessary parts from PrepareBuiltinLibrary. |
- // Setup the internal library's 'internalPrint' function. |
- result = Dart_Invoke(builtin_lib, NewString("_getPrintClosure"), 0, NULL); |
- DART_CHECK_VALID(result); |
- result = Dart_SetField(internal_lib, NewString("_printClosure"), result); |
- DART_CHECK_VALID(result); |
-#if defined(TARGET_OS_WINDOWS) |
- result = Dart_SetField(builtin_lib, NewString("_isWindows"), Dart_True()); |
- DART_CHECK_VALID(result); |
-#endif // defined(TARGET_OS_WINDOWS) |
- // Set current working directory. |
- result = bin::DartUtils::SetWorkingDirectory(builtin_lib); |
- DART_CHECK_VALID(result); |
- // Set the package root for builtin.dart. |
- result = NewString(package_root); |
- DART_CHECK_VALID(result); |
- const int kNumArgs = 1; |
- Dart_Handle dart_args[kNumArgs]; |
- dart_args[0] = result; |
- result = Dart_Invoke(builtin_lib, |
- NewString("_setPackageRoot"), |
- kNumArgs, |
- dart_args); |
- DART_CHECK_VALID(result); |
- |
- bin::DartUtils::PrepareAsyncLibrary(async_lib, isolate_lib); |
- bin::DartUtils::PrepareCoreLibrary(core_lib, builtin_lib, false); |
- bin::DartUtils::PrepareIsolateLibrary(isolate_lib); |
- bin::DartUtils::PrepareIOLibrary(io_lib); |
- return Dart_True(); |
-} |
- |
- |
static Dart_NativeFunction NativeResolver(Dart_Handle name, |
int arg_count, |
bool* auto_setup_scope) { |
@@ -349,12 +298,13 @@ static Dart_NativeFunction NativeResolver(Dart_Handle name, |
} |
static void SetupDart2JSPackagePath() { |
- Dart_Handle builtin_lib = |
- bin::Builtin::LoadAndCheckLibrary(bin::Builtin::kBuiltinLibrary); |
- DART_CHECK_VALID(builtin_lib); |
- |
bool worked = bin::DartUtils::SetOriginalWorkingDirectory(); |
EXPECT(worked); |
+ |
+ Dart_Handle result = bin::DartUtils::PrepareForScriptLoading(false, false); |
+ DART_CHECK_VALID(result); |
+ |
+ // Setup package root. |
char buffer[2048]; |
char* executable_path = |
strdup(File::GetCanonicalPath(Benchmark::Executable())); |
@@ -362,7 +312,7 @@ static void SetupDart2JSPackagePath() { |
const char* path_separator = File::PathSeparator(); |
OS::SNPrint(buffer, 2048, packages_path, |
executable_path, path_separator, path_separator); |
- Dart_Handle result = PreparePackageRoot(buffer, builtin_lib); |
+ result = bin::DartUtils::SetupPackageRoot(buffer, NULL); |
DART_CHECK_VALID(result); |
} |