| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 // The stack size should be at least StackGuard::kLimitSize + some | 1014 // The stack size should be at least StackGuard::kLimitSize + some |
| 1015 // OS-specific padding for thread startup code. | 1015 // OS-specific padding for thread startup code. |
| 1016 options.stack_size = 2 << 20; // 2 Mb seems to be enough | 1016 options.stack_size = 2 << 20; // 2 Mb seems to be enough |
| 1017 return options; | 1017 return options; |
| 1018 } | 1018 } |
| 1019 | 1019 |
| 1020 | 1020 |
| 1021 void SourceGroup::ExecuteInThread() { | 1021 void SourceGroup::ExecuteInThread() { |
| 1022 Isolate* isolate = Isolate::New(); | 1022 Isolate* isolate = Isolate::New(); |
| 1023 do { | 1023 do { |
| 1024 if (next_semaphore_ != NULL) next_semaphore_->Wait(); | 1024 if (!next_semaphore_.is_empty()) next_semaphore_->Wait(); |
| 1025 { | 1025 { |
| 1026 Isolate::Scope iscope(isolate); | 1026 Isolate::Scope iscope(isolate); |
| 1027 Locker lock(isolate); | 1027 Locker lock(isolate); |
| 1028 HandleScope scope; | 1028 HandleScope scope; |
| 1029 Persistent<Context> context = Shell::CreateEvaluationContext(); | 1029 Persistent<Context> context = Shell::CreateEvaluationContext(); |
| 1030 { | 1030 { |
| 1031 Context::Scope cscope(context); | 1031 Context::Scope cscope(context); |
| 1032 Execute(); | 1032 Execute(); |
| 1033 } | 1033 } |
| 1034 context.Dispose(); | 1034 context.Dispose(); |
| 1035 } | 1035 } |
| 1036 if (done_semaphore_ != NULL) done_semaphore_->Signal(); | 1036 if (!done_semaphore_.is_empty()) done_semaphore_->Signal(); |
| 1037 } while (!Shell::options.last_run); | 1037 } while (!Shell::options.last_run); |
| 1038 isolate->Dispose(); | 1038 isolate->Dispose(); |
| 1039 } | 1039 } |
| 1040 | 1040 |
| 1041 | 1041 |
| 1042 void SourceGroup::StartExecuteInThread() { | 1042 void SourceGroup::StartExecuteInThread() { |
| 1043 if (thread_ == NULL) { | 1043 if (thread_.is_empty()) { |
| 1044 thread_ = new IsolateThread(this); | 1044 thread_ = i::SmartPointer<i::Thread>(new IsolateThread(this)); |
| 1045 thread_->Start(); | 1045 thread_->Start(); |
| 1046 } | 1046 } |
| 1047 next_semaphore_->Signal(); | 1047 next_semaphore_->Signal(); |
| 1048 } | 1048 } |
| 1049 | 1049 |
| 1050 | 1050 |
| 1051 void SourceGroup::WaitForThread() { | 1051 void SourceGroup::WaitForThread() { |
| 1052 if (thread_ == NULL) return; | 1052 if (thread_.is_empty()) return; |
| 1053 if (Shell::options.last_run) { | 1053 if (Shell::options.last_run) { |
| 1054 thread_->Join(); | 1054 thread_->Join(); |
| 1055 thread_ = NULL; | |
| 1056 } else { | 1055 } else { |
| 1057 done_semaphore_->Wait(); | 1056 done_semaphore_->Wait(); |
| 1058 } | 1057 } |
| 1059 } | 1058 } |
| 1060 #endif // V8_SHARED | 1059 #endif // V8_SHARED |
| 1061 | 1060 |
| 1062 | 1061 |
| 1063 bool Shell::SetOptions(int argc, char* argv[]) { | 1062 bool Shell::SetOptions(int argc, char* argv[]) { |
| 1064 for (int i = 0; i < argc; i++) { | 1063 for (int i = 0; i < argc; i++) { |
| 1065 if (strcmp(argv[i], "--stress-opt") == 0) { | 1064 if (strcmp(argv[i], "--stress-opt") == 0) { |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1298 } | 1297 } |
| 1299 | 1298 |
| 1300 } // namespace v8 | 1299 } // namespace v8 |
| 1301 | 1300 |
| 1302 | 1301 |
| 1303 #ifndef GOOGLE3 | 1302 #ifndef GOOGLE3 |
| 1304 int main(int argc, char* argv[]) { | 1303 int main(int argc, char* argv[]) { |
| 1305 return v8::Shell::Main(argc, argv); | 1304 return v8::Shell::Main(argc, argv); |
| 1306 } | 1305 } |
| 1307 #endif | 1306 #endif |
| OLD | NEW |