| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1213 } | 1213 } |
| 1214 | 1214 |
| 1215 ptr = next_line; | 1215 ptr = next_line; |
| 1216 } | 1216 } |
| 1217 } | 1217 } |
| 1218 #endif // V8_SHARED | 1218 #endif // V8_SHARED |
| 1219 | 1219 |
| 1220 | 1220 |
| 1221 SourceGroup::~SourceGroup() { | 1221 SourceGroup::~SourceGroup() { |
| 1222 #ifndef V8_SHARED | 1222 #ifndef V8_SHARED |
| 1223 delete next_semaphore_; | |
| 1224 next_semaphore_ = NULL; | |
| 1225 delete done_semaphore_; | |
| 1226 done_semaphore_ = NULL; | |
| 1227 delete thread_; | 1223 delete thread_; |
| 1228 thread_ = NULL; | 1224 thread_ = NULL; |
| 1229 #endif // V8_SHARED | 1225 #endif // V8_SHARED |
| 1230 } | 1226 } |
| 1231 | 1227 |
| 1232 | 1228 |
| 1233 void SourceGroup::Execute(Isolate* isolate) { | 1229 void SourceGroup::Execute(Isolate* isolate) { |
| 1234 for (int i = begin_offset_; i < end_offset_; ++i) { | 1230 for (int i = begin_offset_; i < end_offset_; ++i) { |
| 1235 const char* arg = argv_[i]; | 1231 const char* arg = argv_[i]; |
| 1236 if (strcmp(arg, "-e") == 0 && i + 1 < end_offset_) { | 1232 if (strcmp(arg, "-e") == 0 && i + 1 < end_offset_) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1277 // which is not enough to parse the big literal expressions used in tests. | 1273 // which is not enough to parse the big literal expressions used in tests. |
| 1278 // The stack size should be at least StackGuard::kLimitSize + some | 1274 // The stack size should be at least StackGuard::kLimitSize + some |
| 1279 // OS-specific padding for thread startup code. 2Mbytes seems to be enough. | 1275 // OS-specific padding for thread startup code. 2Mbytes seems to be enough. |
| 1280 return i::Thread::Options("IsolateThread", 2 * MB); | 1276 return i::Thread::Options("IsolateThread", 2 * MB); |
| 1281 } | 1277 } |
| 1282 | 1278 |
| 1283 | 1279 |
| 1284 void SourceGroup::ExecuteInThread() { | 1280 void SourceGroup::ExecuteInThread() { |
| 1285 Isolate* isolate = Isolate::New(); | 1281 Isolate* isolate = Isolate::New(); |
| 1286 do { | 1282 do { |
| 1287 if (next_semaphore_ != NULL) next_semaphore_->Wait(); | 1283 next_semaphore_.Wait(); |
| 1288 { | 1284 { |
| 1289 Isolate::Scope iscope(isolate); | 1285 Isolate::Scope iscope(isolate); |
| 1290 Locker lock(isolate); | 1286 Locker lock(isolate); |
| 1291 { | 1287 { |
| 1292 HandleScope scope(isolate); | 1288 HandleScope scope(isolate); |
| 1293 PerIsolateData data(isolate); | 1289 PerIsolateData data(isolate); |
| 1294 Local<Context> context = Shell::CreateEvaluationContext(isolate); | 1290 Local<Context> context = Shell::CreateEvaluationContext(isolate); |
| 1295 { | 1291 { |
| 1296 Context::Scope cscope(context); | 1292 Context::Scope cscope(context); |
| 1297 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate)); | 1293 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate)); |
| 1298 Execute(isolate); | 1294 Execute(isolate); |
| 1299 } | 1295 } |
| 1300 } | 1296 } |
| 1301 if (Shell::options.send_idle_notification) { | 1297 if (Shell::options.send_idle_notification) { |
| 1302 const int kLongIdlePauseInMs = 1000; | 1298 const int kLongIdlePauseInMs = 1000; |
| 1303 V8::ContextDisposedNotification(); | 1299 V8::ContextDisposedNotification(); |
| 1304 V8::IdleNotification(kLongIdlePauseInMs); | 1300 V8::IdleNotification(kLongIdlePauseInMs); |
| 1305 } | 1301 } |
| 1306 } | 1302 } |
| 1307 if (done_semaphore_ != NULL) done_semaphore_->Signal(); | 1303 done_semaphore_.Signal(); |
| 1308 } while (!Shell::options.last_run); | 1304 } while (!Shell::options.last_run); |
| 1309 isolate->Dispose(); | 1305 isolate->Dispose(); |
| 1310 } | 1306 } |
| 1311 | 1307 |
| 1312 | 1308 |
| 1313 void SourceGroup::StartExecuteInThread() { | 1309 void SourceGroup::StartExecuteInThread() { |
| 1314 if (thread_ == NULL) { | 1310 if (thread_ == NULL) { |
| 1315 thread_ = new IsolateThread(this); | 1311 thread_ = new IsolateThread(this); |
| 1316 thread_->Start(); | 1312 thread_->Start(); |
| 1317 } | 1313 } |
| 1318 next_semaphore_->Signal(); | 1314 next_semaphore_.Signal(); |
| 1319 } | 1315 } |
| 1320 | 1316 |
| 1321 | 1317 |
| 1322 void SourceGroup::WaitForThread() { | 1318 void SourceGroup::WaitForThread() { |
| 1323 if (thread_ == NULL) return; | 1319 if (thread_ == NULL) return; |
| 1324 if (Shell::options.last_run) { | 1320 if (Shell::options.last_run) { |
| 1325 thread_->Join(); | 1321 thread_->Join(); |
| 1326 } else { | 1322 } else { |
| 1327 done_semaphore_->Wait(); | 1323 done_semaphore_.Wait(); |
| 1328 } | 1324 } |
| 1329 } | 1325 } |
| 1330 #endif // V8_SHARED | 1326 #endif // V8_SHARED |
| 1331 | 1327 |
| 1332 | 1328 |
| 1333 bool Shell::SetOptions(int argc, char* argv[]) { | 1329 bool Shell::SetOptions(int argc, char* argv[]) { |
| 1334 for (int i = 0; i < argc; i++) { | 1330 for (int i = 0; i < argc; i++) { |
| 1335 if (strcmp(argv[i], "--stress-opt") == 0) { | 1331 if (strcmp(argv[i], "--stress-opt") == 0) { |
| 1336 options.stress_opt = true; | 1332 options.stress_opt = true; |
| 1337 argv[i] = NULL; | 1333 argv[i] = NULL; |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1728 } | 1724 } |
| 1729 | 1725 |
| 1730 } // namespace v8 | 1726 } // namespace v8 |
| 1731 | 1727 |
| 1732 | 1728 |
| 1733 #ifndef GOOGLE3 | 1729 #ifndef GOOGLE3 |
| 1734 int main(int argc, char* argv[]) { | 1730 int main(int argc, char* argv[]) { |
| 1735 return v8::Shell::Main(argc, argv); | 1731 return v8::Shell::Main(argc, argv); |
| 1736 } | 1732 } |
| 1737 #endif | 1733 #endif |
| OLD | NEW |