OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 // Defined when linking against shared lib on Windows. | 6 // Defined when linking against shared lib on Windows. |
7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) | 7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) |
8 #define V8_SHARED | 8 #define V8_SHARED |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 global_template->Set(String::NewFromUtf8(isolate, "write"), | 917 global_template->Set(String::NewFromUtf8(isolate, "write"), |
918 FunctionTemplate::New(isolate, Write)); | 918 FunctionTemplate::New(isolate, Write)); |
919 global_template->Set(String::NewFromUtf8(isolate, "read"), | 919 global_template->Set(String::NewFromUtf8(isolate, "read"), |
920 FunctionTemplate::New(isolate, Read)); | 920 FunctionTemplate::New(isolate, Read)); |
921 global_template->Set(String::NewFromUtf8(isolate, "readbuffer"), | 921 global_template->Set(String::NewFromUtf8(isolate, "readbuffer"), |
922 FunctionTemplate::New(isolate, ReadBuffer)); | 922 FunctionTemplate::New(isolate, ReadBuffer)); |
923 global_template->Set(String::NewFromUtf8(isolate, "readline"), | 923 global_template->Set(String::NewFromUtf8(isolate, "readline"), |
924 FunctionTemplate::New(isolate, ReadLine)); | 924 FunctionTemplate::New(isolate, ReadLine)); |
925 global_template->Set(String::NewFromUtf8(isolate, "load"), | 925 global_template->Set(String::NewFromUtf8(isolate, "load"), |
926 FunctionTemplate::New(isolate, Load)); | 926 FunctionTemplate::New(isolate, Load)); |
927 global_template->Set(String::NewFromUtf8(isolate, "quit"), | 927 // Some Emscripten-generated code tries to call 'quit', which in turn would |
928 FunctionTemplate::New(isolate, Quit)); | 928 // call C's exit(). This would lead to memory leaks, because there is no way |
| 929 // we can terminate cleanly then, so we need a way to hide 'quit'. |
| 930 if (!options.omit_quit) { |
| 931 global_template->Set(String::NewFromUtf8(isolate, "quit"), |
| 932 FunctionTemplate::New(isolate, Quit)); |
| 933 } |
929 global_template->Set(String::NewFromUtf8(isolate, "version"), | 934 global_template->Set(String::NewFromUtf8(isolate, "version"), |
930 FunctionTemplate::New(isolate, Version)); | 935 FunctionTemplate::New(isolate, Version)); |
931 | 936 |
932 // Bind the Realm object. | 937 // Bind the Realm object. |
933 Handle<ObjectTemplate> realm_template = ObjectTemplate::New(isolate); | 938 Handle<ObjectTemplate> realm_template = ObjectTemplate::New(isolate); |
934 realm_template->Set(String::NewFromUtf8(isolate, "current"), | 939 realm_template->Set(String::NewFromUtf8(isolate, "current"), |
935 FunctionTemplate::New(isolate, RealmCurrent)); | 940 FunctionTemplate::New(isolate, RealmCurrent)); |
936 realm_template->Set(String::NewFromUtf8(isolate, "owner"), | 941 realm_template->Set(String::NewFromUtf8(isolate, "owner"), |
937 FunctionTemplate::New(isolate, RealmOwner)); | 942 FunctionTemplate::New(isolate, RealmOwner)); |
938 realm_template->Set(String::NewFromUtf8(isolate, "global"), | 943 realm_template->Set(String::NewFromUtf8(isolate, "global"), |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1367 options.test_shell = true; | 1372 options.test_shell = true; |
1368 argv[i] = NULL; | 1373 argv[i] = NULL; |
1369 } else if (strcmp(argv[i], "--send-idle-notification") == 0) { | 1374 } else if (strcmp(argv[i], "--send-idle-notification") == 0) { |
1370 options.send_idle_notification = true; | 1375 options.send_idle_notification = true; |
1371 argv[i] = NULL; | 1376 argv[i] = NULL; |
1372 } else if (strcmp(argv[i], "--invoke-weak-callbacks") == 0) { | 1377 } else if (strcmp(argv[i], "--invoke-weak-callbacks") == 0) { |
1373 options.invoke_weak_callbacks = true; | 1378 options.invoke_weak_callbacks = true; |
1374 // TODO(jochen) See issue 3351 | 1379 // TODO(jochen) See issue 3351 |
1375 options.send_idle_notification = true; | 1380 options.send_idle_notification = true; |
1376 argv[i] = NULL; | 1381 argv[i] = NULL; |
| 1382 } else if (strcmp(argv[i], "--omit-quit") == 0) { |
| 1383 options.omit_quit = true; |
| 1384 argv[i] = NULL; |
1377 } else if (strcmp(argv[i], "-f") == 0) { | 1385 } else if (strcmp(argv[i], "-f") == 0) { |
1378 // Ignore any -f flags for compatibility with other stand-alone | 1386 // Ignore any -f flags for compatibility with other stand-alone |
1379 // JavaScript engines. | 1387 // JavaScript engines. |
1380 continue; | 1388 continue; |
1381 } else if (strcmp(argv[i], "--isolate") == 0) { | 1389 } else if (strcmp(argv[i], "--isolate") == 0) { |
1382 #ifdef V8_SHARED | 1390 #ifdef V8_SHARED |
1383 printf("D8 with shared library does not support multi-threading\n"); | 1391 printf("D8 with shared library does not support multi-threading\n"); |
1384 return false; | 1392 return false; |
1385 #endif // V8_SHARED | 1393 #endif // V8_SHARED |
1386 options.num_isolates++; | 1394 options.num_isolates++; |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1717 } | 1725 } |
1718 | 1726 |
1719 } // namespace v8 | 1727 } // namespace v8 |
1720 | 1728 |
1721 | 1729 |
1722 #ifndef GOOGLE3 | 1730 #ifndef GOOGLE3 |
1723 int main(int argc, char* argv[]) { | 1731 int main(int argc, char* argv[]) { |
1724 return v8::Shell::Main(argc, argv); | 1732 return v8::Shell::Main(argc, argv); |
1725 } | 1733 } |
1726 #endif | 1734 #endif |
OLD | NEW |