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

Unified Diff: samples/shell.cc

Issue 1209403005: Let the second pass phantom callbacks run in a separate task on the foreground thread. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Run second pass callbacks synchronously when GC is forced. Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samples/process.cc ('k') | src/d8.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/shell.cc
diff --git a/samples/shell.cc b/samples/shell.cc
index 3a743d6c13bebe4e919bb69f01146fb3568363ab..a6b01d99e7a51d07226700d63a07a7a33cfc3e7d 100644
--- a/samples/shell.cc
+++ b/samples/shell.cc
@@ -45,8 +45,9 @@
v8::Local<v8::Context> CreateShellContext(v8::Isolate* isolate);
-void RunShell(v8::Local<v8::Context> context);
-int RunMain(v8::Isolate* isolate, int argc, char* argv[]);
+void RunShell(v8::Local<v8::Context> context, v8::Platform* platform);
+int RunMain(v8::Isolate* isolate, v8::Platform* platform, int argc,
+ char* argv[]);
bool ExecuteString(v8::Isolate* isolate, v8::Local<v8::String> source,
v8::Local<v8::Value> name, bool print_result,
bool report_exceptions);
@@ -94,8 +95,8 @@ int main(int argc, char* argv[]) {
return 1;
}
v8::Context::Scope context_scope(context);
- result = RunMain(isolate, argc, argv);
- if (run_shell) RunShell(context);
+ result = RunMain(isolate, platform, argc, argv);
+ if (run_shell) RunShell(context, platform);
}
isolate->Dispose();
v8::V8::Dispose();
@@ -269,7 +270,8 @@ v8::MaybeLocal<v8::String> ReadFile(v8::Isolate* isolate, const char* name) {
// Process remaining command line arguments and execute files
-int RunMain(v8::Isolate* isolate, int argc, char* argv[]) {
+int RunMain(v8::Isolate* isolate, v8::Platform* platform, int argc,
+ char* argv[]) {
for (int i = 1; i < argc; i++) {
const char* str = argv[i];
if (strcmp(str, "--shell") == 0) {
@@ -292,7 +294,9 @@ int RunMain(v8::Isolate* isolate, int argc, char* argv[]) {
.ToLocal(&source)) {
return 1;
}
- if (!ExecuteString(isolate, source, file_name, false, true)) return 1;
+ bool success = ExecuteString(isolate, source, file_name, false, true);
+ while (v8::platform::PumpMessageLoop(platform, isolate)) continue;
+ if (!success) return 1;
} else {
// Use all other arguments as names of files to load and run.
v8::Local<v8::String> file_name =
@@ -303,7 +307,9 @@ int RunMain(v8::Isolate* isolate, int argc, char* argv[]) {
fprintf(stderr, "Error reading '%s'\n", str);
continue;
}
- if (!ExecuteString(isolate, source, file_name, false, true)) return 1;
+ bool success = ExecuteString(isolate, source, file_name, false, true);
+ while (v8::platform::PumpMessageLoop(platform, isolate)) continue;
+ if (!success) return 1;
}
}
return 0;
@@ -311,7 +317,7 @@ int RunMain(v8::Isolate* isolate, int argc, char* argv[]) {
// The read-eval-execute loop of the shell.
-void RunShell(v8::Local<v8::Context> context) {
+void RunShell(v8::Local<v8::Context> context, v8::Platform* platform) {
fprintf(stderr, "V8 version %s [sample shell]\n", v8::V8::GetVersion());
static const int kBufferSize = 256;
// Enter the execution environment before evaluating any code.
@@ -330,6 +336,8 @@ void RunShell(v8::Local<v8::Context> context) {
v8::String::NewFromUtf8(context->GetIsolate(), str,
v8::NewStringType::kNormal).ToLocalChecked(),
name, true, true);
+ while (v8::platform::PumpMessageLoop(platform, context->GetIsolate()))
+ continue;
}
fprintf(stderr, "\n");
}
« no previous file with comments | « samples/process.cc ('k') | src/d8.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698