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 16 matching lines...) Expand all Loading... |
27 | 27 |
28 #ifdef V8_SHARED | 28 #ifdef V8_SHARED |
29 #include "include/v8-testing.h" | 29 #include "include/v8-testing.h" |
30 #endif // V8_SHARED | 30 #endif // V8_SHARED |
31 | 31 |
32 #ifdef ENABLE_VTUNE_JIT_INTERFACE | 32 #ifdef ENABLE_VTUNE_JIT_INTERFACE |
33 #include "src/third_party/vtune/v8-vtune.h" | 33 #include "src/third_party/vtune/v8-vtune.h" |
34 #endif | 34 #endif |
35 | 35 |
36 #include "src/d8.h" | 36 #include "src/d8.h" |
| 37 #include "src/api.h" |
37 | 38 |
38 #ifndef V8_SHARED | 39 #ifndef V8_SHARED |
39 #include "src/api.h" | |
40 #include "src/base/cpu.h" | 40 #include "src/base/cpu.h" |
41 #include "src/base/logging.h" | 41 #include "src/base/logging.h" |
42 #include "src/base/platform/platform.h" | 42 #include "src/base/platform/platform.h" |
43 #include "src/d8-debug.h" | 43 #include "src/d8-debug.h" |
44 #include "src/debug.h" | 44 #include "src/debug.h" |
45 #include "src/natives.h" | 45 #include "src/natives.h" |
46 #include "src/v8.h" | 46 #include "src/v8.h" |
47 #endif // !V8_SHARED | 47 #endif // !V8_SHARED |
48 | 48 |
| 49 #include "src/sampler-thread.h" |
| 50 |
49 #if !defined(_WIN32) && !defined(_WIN64) | 51 #if !defined(_WIN32) && !defined(_WIN64) |
50 #include <unistd.h> // NOLINT | 52 #include <unistd.h> // NOLINT |
51 #endif | 53 #endif |
52 | 54 |
53 #ifndef ASSERT | 55 #ifndef ASSERT |
54 #define ASSERT(condition) assert(condition) | 56 #define ASSERT(condition) assert(condition) |
55 #endif | 57 #endif |
56 | 58 |
57 namespace v8 { | 59 namespace v8 { |
58 | 60 |
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1151 Handle<String> file_name = String::NewFromUtf8(isolate, "unnamed"); | 1153 Handle<String> file_name = String::NewFromUtf8(isolate, "unnamed"); |
1152 Handle<String> source = String::NewFromUtf8(isolate, argv_[i + 1]); | 1154 Handle<String> source = String::NewFromUtf8(isolate, argv_[i + 1]); |
1153 if (!Shell::ExecuteString(isolate, source, file_name, false, true)) { | 1155 if (!Shell::ExecuteString(isolate, source, file_name, false, true)) { |
1154 exception_was_thrown = true; | 1156 exception_was_thrown = true; |
1155 break; | 1157 break; |
1156 } | 1158 } |
1157 ++i; | 1159 ++i; |
1158 } else if (arg[0] == '-') { | 1160 } else if (arg[0] == '-') { |
1159 // Ignore other options. They have been parsed already. | 1161 // Ignore other options. They have been parsed already. |
1160 } else { | 1162 } else { |
| 1163 v8::SamplerThread* sampler = new SamplerThread(isolate); |
1161 // Use all other arguments as names of files to load and run. | 1164 // Use all other arguments as names of files to load and run. |
1162 HandleScope handle_scope(isolate); | 1165 HandleScope handle_scope(isolate); |
1163 Handle<String> file_name = String::NewFromUtf8(isolate, arg); | 1166 Handle<String> file_name = String::NewFromUtf8(isolate, arg); |
1164 Handle<String> source = ReadFile(isolate, arg); | 1167 Handle<String> source = ReadFile(isolate, arg); |
1165 if (source.IsEmpty()) { | 1168 if (source.IsEmpty()) { |
1166 printf("Error reading '%s'\n", arg); | 1169 printf("Error reading '%s'\n", arg); |
1167 Shell::Exit(1); | 1170 Shell::Exit(1); |
1168 } | 1171 } |
| 1172 sampler->Start(); |
1169 if (!Shell::ExecuteString(isolate, source, file_name, false, true)) { | 1173 if (!Shell::ExecuteString(isolate, source, file_name, false, true)) { |
1170 exception_was_thrown = true; | 1174 exception_was_thrown = true; |
1171 break; | 1175 break; |
1172 } | 1176 } |
| 1177 sampler->Stop(); |
1173 } | 1178 } |
1174 } | 1179 } |
1175 if (exception_was_thrown != Shell::options.expected_to_throw) { | 1180 if (exception_was_thrown != Shell::options.expected_to_throw) { |
1176 Shell::Exit(1); | 1181 Shell::Exit(1); |
1177 } | 1182 } |
1178 } | 1183 } |
1179 | 1184 |
1180 | 1185 |
1181 Handle<String> SourceGroup::ReadFile(Isolate* isolate, const char* name) { | 1186 Handle<String> SourceGroup::ReadFile(Isolate* isolate, const char* name) { |
1182 int size; | 1187 int size; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1358 | 1363 |
1359 if (!logfile_per_isolate && options.num_isolates) { | 1364 if (!logfile_per_isolate && options.num_isolates) { |
1360 SetFlagsFromString("--nologfile_per_isolate"); | 1365 SetFlagsFromString("--nologfile_per_isolate"); |
1361 } | 1366 } |
1362 | 1367 |
1363 return true; | 1368 return true; |
1364 } | 1369 } |
1365 | 1370 |
1366 | 1371 |
1367 int Shell::RunMain(Isolate* isolate, int argc, char* argv[]) { | 1372 int Shell::RunMain(Isolate* isolate, int argc, char* argv[]) { |
| 1373 v8::SamplerThread* sampler = new SamplerThread(isolate); |
| 1374 delete sampler; |
1368 #ifndef V8_SHARED | 1375 #ifndef V8_SHARED |
1369 for (int i = 1; i < options.num_isolates; ++i) { | 1376 for (int i = 1; i < options.num_isolates; ++i) { |
1370 options.isolate_sources[i].StartExecuteInThread(); | 1377 options.isolate_sources[i].StartExecuteInThread(); |
1371 } | 1378 } |
1372 #endif // !V8_SHARED | 1379 #endif // !V8_SHARED |
1373 { | 1380 { |
1374 HandleScope scope(isolate); | 1381 HandleScope scope(isolate); |
1375 Local<Context> context = CreateEvaluationContext(isolate); | 1382 Local<Context> context = CreateEvaluationContext(isolate); |
1376 if (options.last_run && options.use_interactive_shell()) { | 1383 if (options.last_run && options.use_interactive_shell()) { |
1377 // Keep using the same context in the interactive shell. | 1384 // Keep using the same context in the interactive shell. |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1633 } | 1640 } |
1634 | 1641 |
1635 } // namespace v8 | 1642 } // namespace v8 |
1636 | 1643 |
1637 | 1644 |
1638 #ifndef GOOGLE3 | 1645 #ifndef GOOGLE3 |
1639 int main(int argc, char* argv[]) { | 1646 int main(int argc, char* argv[]) { |
1640 return v8::Shell::Main(argc, argv); | 1647 return v8::Shell::Main(argc, argv); |
1641 } | 1648 } |
1642 #endif | 1649 #endif |
OLD | NEW |