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

Side by Side Diff: runtime/vm/benchmark_test.cc

Issue 1232593003: - Implement .packages specification. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address review comments. Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « runtime/lib/isolate_patch.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/benchmark_test.h" 5 #include "vm/benchmark_test.h"
6 6
7 #include "bin/builtin.h" 7 #include "bin/builtin.h"
8 #include "bin/file.h" 8 #include "bin/file.h"
9 9
10 #include "platform/assert.h" 10 #include "platform/assert.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 dart2js_path = NULL; 251 dart2js_path = NULL;
252 } 252 }
253 return dart2js_path; 253 return dart2js_path;
254 } 254 }
255 255
256 256
257 static void func(Dart_NativeArguments args) { 257 static void func(Dart_NativeArguments args) {
258 } 258 }
259 259
260 260
261 // Emulates DartUtils::PrepareForScriptLoading.
262 static Dart_Handle PreparePackageRoot(const char* package_root,
263 Dart_Handle builtin_lib) {
264 // First ensure all required libraries are available.
265 Dart_Handle url = NewString(bin::DartUtils::kCoreLibURL);
266 DART_CHECK_VALID(url);
267 Dart_Handle core_lib = Dart_LookupLibrary(url);
268 DART_CHECK_VALID(core_lib);
269 url = NewString(bin::DartUtils::kAsyncLibURL);
270 DART_CHECK_VALID(url);
271 Dart_Handle async_lib = Dart_LookupLibrary(url);
272 DART_CHECK_VALID(async_lib);
273 url = NewString(bin::DartUtils::kIsolateLibURL);
274 DART_CHECK_VALID(url);
275 Dart_Handle isolate_lib = Dart_LookupLibrary(url);
276 DART_CHECK_VALID(isolate_lib);
277 url = NewString(bin::DartUtils::kInternalLibURL);
278 DART_CHECK_VALID(url);
279 Dart_Handle internal_lib = Dart_LookupLibrary(url);
280 DART_CHECK_VALID(internal_lib);
281 Dart_Handle io_lib =
282 bin::Builtin::LoadAndCheckLibrary(bin::Builtin::kIOLibrary);
283 DART_CHECK_VALID(io_lib);
284
285 // We need to ensure that all the scripts loaded so far are finalized
286 // as we are about to invoke some Dart code below to setup closures.
287 Dart_Handle result = Dart_FinalizeLoading(false);
288 DART_CHECK_VALID(result);
289
290 // Necessary parts from PrepareBuiltinLibrary.
291 // Setup the internal library's 'internalPrint' function.
292 result = Dart_Invoke(builtin_lib, NewString("_getPrintClosure"), 0, NULL);
293 DART_CHECK_VALID(result);
294 result = Dart_SetField(internal_lib, NewString("_printClosure"), result);
295 DART_CHECK_VALID(result);
296 #if defined(TARGET_OS_WINDOWS)
297 result = Dart_SetField(builtin_lib, NewString("_isWindows"), Dart_True());
298 DART_CHECK_VALID(result);
299 #endif // defined(TARGET_OS_WINDOWS)
300 // Set current working directory.
301 result = bin::DartUtils::SetWorkingDirectory(builtin_lib);
302 DART_CHECK_VALID(result);
303 // Set the package root for builtin.dart.
304 result = NewString(package_root);
305 DART_CHECK_VALID(result);
306 const int kNumArgs = 1;
307 Dart_Handle dart_args[kNumArgs];
308 dart_args[0] = result;
309 result = Dart_Invoke(builtin_lib,
310 NewString("_setPackageRoot"),
311 kNumArgs,
312 dart_args);
313 DART_CHECK_VALID(result);
314
315 bin::DartUtils::PrepareAsyncLibrary(async_lib, isolate_lib);
316 bin::DartUtils::PrepareCoreLibrary(core_lib, builtin_lib, false);
317 bin::DartUtils::PrepareIsolateLibrary(isolate_lib);
318 bin::DartUtils::PrepareIOLibrary(io_lib);
319 return Dart_True();
320 }
321
322
261 static Dart_NativeFunction NativeResolver(Dart_Handle name, 323 static Dart_NativeFunction NativeResolver(Dart_Handle name,
262 int arg_count, 324 int arg_count,
263 bool* auto_setup_scope) { 325 bool* auto_setup_scope) {
264 ASSERT(auto_setup_scope != NULL); 326 ASSERT(auto_setup_scope != NULL);
265 *auto_setup_scope = false; 327 *auto_setup_scope = false;
266 return &func; 328 return &func;
267 } 329 }
268 330
269 static void SetupDart2JSPackagePath() { 331 static void SetupDart2JSPackagePath() {
270 Dart_Handle builtin_lib = 332 Dart_Handle builtin_lib =
271 bin::Builtin::LoadAndCheckLibrary(bin::Builtin::kBuiltinLibrary); 333 bin::Builtin::LoadAndCheckLibrary(bin::Builtin::kBuiltinLibrary);
272 DART_CHECK_VALID(builtin_lib); 334 DART_CHECK_VALID(builtin_lib);
273 335
274 bool worked = bin::DartUtils::SetOriginalWorkingDirectory(); 336 bool worked = bin::DartUtils::SetOriginalWorkingDirectory();
275 EXPECT(worked); 337 EXPECT(worked);
276 char buffer[2048]; 338 char buffer[2048];
277 char* executable_path = 339 char* executable_path =
278 strdup(File::GetCanonicalPath(Benchmark::Executable())); 340 strdup(File::GetCanonicalPath(Benchmark::Executable()));
279 const char* packages_path = "%s%s..%spackages"; 341 const char* packages_path = "%s%s..%spackages";
280 const char* path_separator = File::PathSeparator(); 342 const char* path_separator = File::PathSeparator();
281 OS::SNPrint(buffer, 2048, packages_path, 343 OS::SNPrint(buffer, 2048, packages_path,
282 executable_path, path_separator, path_separator); 344 executable_path, path_separator, path_separator);
283 bin::DartUtils::PrepareForScriptLoading(buffer, false, false, builtin_lib); 345 Dart_Handle result = PreparePackageRoot(buffer, builtin_lib);
346 DART_CHECK_VALID(result);
284 } 347 }
285 348
286 BENCHMARK(Dart2JSCompileAll) { 349 BENCHMARK(Dart2JSCompileAll) {
287 bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary); 350 bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary);
288 bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary); 351 bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary);
289 SetupDart2JSPackagePath(); 352 SetupDart2JSPackagePath();
290 char* dart_root = ComputeDart2JSPath(Benchmark::Executable()); 353 char* dart_root = ComputeDart2JSPath(Benchmark::Executable());
291 char* script = NULL; 354 char* script = NULL;
292 if (dart_root != NULL) { 355 if (dart_root != NULL) {
293 Isolate* isolate = Isolate::Current(); 356 Isolate* isolate = Isolate::Current();
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 zone.GetZone()); 702 zone.GetZone());
640 reader.ReadObject(); 703 reader.ReadObject();
641 free(buffer); 704 free(buffer);
642 } 705 }
643 timer.Stop(); 706 timer.Stop();
644 int64_t elapsed_time = timer.TotalElapsedTime(); 707 int64_t elapsed_time = timer.TotalElapsedTime();
645 benchmark->set_score(elapsed_time); 708 benchmark->set_score(elapsed_time);
646 } 709 }
647 710
648 } // namespace dart 711 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/isolate_patch.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698