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

Side by Side Diff: test/cctest/cctest.h

Issue 389573006: Change ScriptCompiler::CompileOptions and add d8 --cache. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: even more rebase Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « src/parser.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 static inline v8::Local<v8::Value> CompileRun(const char* source) { 364 static inline v8::Local<v8::Value> CompileRun(const char* source) {
365 return v8::Script::Compile(v8_str(source))->Run(); 365 return v8::Script::Compile(v8_str(source))->Run();
366 } 366 }
367 367
368 368
369 static inline v8::Local<v8::Value> CompileRun(v8::Local<v8::String> source) { 369 static inline v8::Local<v8::Value> CompileRun(v8::Local<v8::String> source) {
370 return v8::Script::Compile(source)->Run(); 370 return v8::Script::Compile(source)->Run();
371 } 371 }
372 372
373 373
374 static inline v8::Local<v8::Value> PreCompileCompileRun(const char* source) { 374 static inline v8::Local<v8::Value> ParserCacheCompileRun(const char* source) {
375 // Compile once just to get the preparse data, then compile the second time 375 // Compile once just to get the preparse data, then compile the second time
376 // using the data. 376 // using the data.
377 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 377 v8::Isolate* isolate = v8::Isolate::GetCurrent();
378 v8::ScriptCompiler::Source script_source(v8_str(source)); 378 v8::ScriptCompiler::Source script_source(v8_str(source));
379 v8::ScriptCompiler::Compile(isolate, &script_source, 379 v8::ScriptCompiler::Compile(isolate, &script_source,
380 v8::ScriptCompiler::kProduceDataToCache); 380 v8::ScriptCompiler::kProduceParserCache);
381 return v8::ScriptCompiler::Compile(isolate, &script_source)->Run(); 381
382 // Check whether we received cached data, and if so use it.
383 v8::ScriptCompiler::CompileOptions options =
384 script_source.GetCachedData() ? v8::ScriptCompiler::kConsumeParserCache
385 : v8::ScriptCompiler::kNoCompileOptions;
386
387 return v8::ScriptCompiler::Compile(isolate, &script_source, options)->Run();
382 } 388 }
383 389
384 390
385 // Helper functions that compile and run the source with given origin. 391 // Helper functions that compile and run the source with given origin.
386 static inline v8::Local<v8::Value> CompileRunWithOrigin(const char* source, 392 static inline v8::Local<v8::Value> CompileRunWithOrigin(const char* source,
387 const char* origin_url, 393 const char* origin_url,
388 int line_number, 394 int line_number,
389 int column_number) { 395 int column_number) {
390 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 396 v8::Isolate* isolate = v8::Isolate::GetCurrent();
391 v8::ScriptOrigin origin(v8_str(origin_url), 397 v8::ScriptOrigin origin(v8_str(origin_url),
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 CHECK_EQ(0, heap_profiler_->heap_object_map()->FindUntrackedObjects()); 500 CHECK_EQ(0, heap_profiler_->heap_object_map()->FindUntrackedObjects());
495 heap_profiler_->StopHeapObjectsTracking(); 501 heap_profiler_->StopHeapObjectsTracking();
496 } 502 }
497 503
498 private: 504 private:
499 i::HeapProfiler* heap_profiler_; 505 i::HeapProfiler* heap_profiler_;
500 }; 506 };
501 507
502 508
503 #endif // ifndef CCTEST_H_ 509 #endif // ifndef CCTEST_H_
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698