Chromium Code Reviews| 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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 328 bool Shell::ExecuteString(Isolate* isolate, Local<String> source, | 328 bool Shell::ExecuteString(Isolate* isolate, Local<String> source, |
| 329 Local<Value> name, bool print_result, | 329 Local<Value> name, bool print_result, |
| 330 bool report_exceptions, SourceType source_type) { | 330 bool report_exceptions, SourceType source_type) { |
| 331 #ifndef V8_SHARED | 331 #ifndef V8_SHARED |
| 332 bool FLAG_debugger = i::FLAG_debugger; | 332 bool FLAG_debugger = i::FLAG_debugger; |
| 333 #else | 333 #else |
| 334 bool FLAG_debugger = false; | 334 bool FLAG_debugger = false; |
| 335 #endif // !V8_SHARED | 335 #endif // !V8_SHARED |
| 336 HandleScope handle_scope(isolate); | 336 HandleScope handle_scope(isolate); |
| 337 TryCatch try_catch(isolate); | 337 TryCatch try_catch(isolate); |
| 338 options.script_executed = true; | 338 options.set_script_executed(true); |
|
Jarin
2015/07/23 06:49:14
It looks like the set_script_executed could be cal
binji
2015/07/24 23:13:08
Done.
| |
| 339 if (FLAG_debugger) { | 339 if (FLAG_debugger) { |
| 340 // When debugging make exceptions appear to be uncaught. | 340 // When debugging make exceptions appear to be uncaught. |
| 341 try_catch.SetVerbose(true); | 341 try_catch.SetVerbose(true); |
| 342 } | 342 } |
| 343 | 343 |
| 344 MaybeLocal<Value> maybe_result; | 344 MaybeLocal<Value> maybe_result; |
| 345 { | 345 { |
| 346 PerIsolateData* data = PerIsolateData::Get(isolate); | 346 PerIsolateData* data = PerIsolateData::Get(isolate); |
| 347 Local<Context> realm = | 347 Local<Context> realm = |
| 348 Local<Context>::New(isolate, data->realms_[data->realm_current_]); | 348 Local<Context>::New(isolate, data->realms_[data->realm_current_]); |
| (...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1638 Local<Context> context = Shell::CreateEvaluationContext(isolate); | 1638 Local<Context> context = Shell::CreateEvaluationContext(isolate); |
| 1639 { | 1639 { |
| 1640 Context::Scope cscope(context); | 1640 Context::Scope cscope(context); |
| 1641 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate)); | 1641 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate)); |
| 1642 Execute(isolate); | 1642 Execute(isolate); |
| 1643 } | 1643 } |
| 1644 } | 1644 } |
| 1645 Shell::CollectGarbage(isolate); | 1645 Shell::CollectGarbage(isolate); |
| 1646 } | 1646 } |
| 1647 done_semaphore_.Signal(); | 1647 done_semaphore_.Signal(); |
| 1648 } while (!Shell::options.last_run); | 1648 } while (!Shell::options.last_run()); |
| 1649 | 1649 |
| 1650 isolate->Dispose(); | 1650 isolate->Dispose(); |
| 1651 } | 1651 } |
| 1652 | 1652 |
| 1653 | 1653 |
| 1654 void SourceGroup::StartExecuteInThread() { | 1654 void SourceGroup::StartExecuteInThread() { |
| 1655 if (thread_ == NULL) { | 1655 if (thread_ == NULL) { |
| 1656 thread_ = new IsolateThread(this); | 1656 thread_ = new IsolateThread(this); |
| 1657 thread_->Start(); | 1657 thread_->Start(); |
| 1658 } | 1658 } |
| 1659 next_semaphore_.Signal(); | 1659 next_semaphore_.Signal(); |
| 1660 } | 1660 } |
| 1661 | 1661 |
| 1662 | 1662 |
| 1663 void SourceGroup::WaitForThread() { | 1663 void SourceGroup::WaitForThread() { |
| 1664 if (thread_ == NULL) return; | 1664 if (thread_ == NULL) return; |
| 1665 if (Shell::options.last_run) { | 1665 if (Shell::options.last_run()) { |
| 1666 thread_->Join(); | 1666 thread_->Join(); |
| 1667 } else { | 1667 } else { |
| 1668 done_semaphore_.Wait(); | 1668 done_semaphore_.Wait(); |
| 1669 } | 1669 } |
| 1670 } | 1670 } |
| 1671 | 1671 |
| 1672 | 1672 |
| 1673 SerializationData::~SerializationData() { | 1673 SerializationData::~SerializationData() { |
| 1674 // Any ArrayBuffer::Contents are owned by this SerializationData object if | 1674 // Any ArrayBuffer::Contents are owned by this SerializationData object if |
| 1675 // ownership hasn't been transferred out via ReadArrayBufferContents. | 1675 // ownership hasn't been transferred out via ReadArrayBufferContents. |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2093 | 2093 |
| 2094 int Shell::RunMain(Isolate* isolate, int argc, char* argv[]) { | 2094 int Shell::RunMain(Isolate* isolate, int argc, char* argv[]) { |
| 2095 #ifndef V8_SHARED | 2095 #ifndef V8_SHARED |
| 2096 for (int i = 1; i < options.num_isolates; ++i) { | 2096 for (int i = 1; i < options.num_isolates; ++i) { |
| 2097 options.isolate_sources[i].StartExecuteInThread(); | 2097 options.isolate_sources[i].StartExecuteInThread(); |
| 2098 } | 2098 } |
| 2099 #endif // !V8_SHARED | 2099 #endif // !V8_SHARED |
| 2100 { | 2100 { |
| 2101 HandleScope scope(isolate); | 2101 HandleScope scope(isolate); |
| 2102 Local<Context> context = CreateEvaluationContext(isolate); | 2102 Local<Context> context = CreateEvaluationContext(isolate); |
| 2103 if (options.last_run && options.use_interactive_shell()) { | 2103 if (options.last_run() && options.use_interactive_shell()) { |
| 2104 // Keep using the same context in the interactive shell. | 2104 // Keep using the same context in the interactive shell. |
| 2105 evaluation_context_.Reset(isolate, context); | 2105 evaluation_context_.Reset(isolate, context); |
| 2106 #ifndef V8_SHARED | 2106 #ifndef V8_SHARED |
| 2107 // If the interactive debugger is enabled make sure to activate | 2107 // If the interactive debugger is enabled make sure to activate |
| 2108 // it before running the files passed on the command line. | 2108 // it before running the files passed on the command line. |
| 2109 if (i::FLAG_debugger) { | 2109 if (i::FLAG_debugger) { |
| 2110 InstallUtilityScript(isolate); | 2110 InstallUtilityScript(isolate); |
| 2111 } | 2111 } |
| 2112 #endif // !V8_SHARED | 2112 #endif // !V8_SHARED |
| 2113 } | 2113 } |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2239 if (!FindInObjectList(sab, to_transfer)) { | 2239 if (!FindInObjectList(sab, to_transfer)) { |
| 2240 Throw(isolate, "SharedArrayBuffer must be transferred"); | 2240 Throw(isolate, "SharedArrayBuffer must be transferred"); |
| 2241 return false; | 2241 return false; |
| 2242 } | 2242 } |
| 2243 | 2243 |
| 2244 SharedArrayBuffer::Contents contents; | 2244 SharedArrayBuffer::Contents contents; |
| 2245 if (sab->IsExternal()) { | 2245 if (sab->IsExternal()) { |
| 2246 contents = sab->GetContents(); | 2246 contents = sab->GetContents(); |
| 2247 } else { | 2247 } else { |
| 2248 contents = sab->Externalize(); | 2248 contents = sab->Externalize(); |
| 2249 base::LockGuard<base::Mutex> lock_guard(workers_mutex_.Pointer()); | |
| 2249 externalized_shared_contents_.Add(contents); | 2250 externalized_shared_contents_.Add(contents); |
| 2250 } | 2251 } |
| 2251 out_data->WriteSharedArrayBufferContents(contents); | 2252 out_data->WriteSharedArrayBufferContents(contents); |
| 2252 } else if (value->IsObject()) { | 2253 } else if (value->IsObject()) { |
| 2253 Local<Object> object = Local<Object>::Cast(value); | 2254 Local<Object> object = Local<Object>::Cast(value); |
| 2254 if (FindInObjectList(object, *seen_objects)) { | 2255 if (FindInObjectList(object, *seen_objects)) { |
| 2255 Throw(isolate, "Duplicated objects not supported"); | 2256 Throw(isolate, "Duplicated objects not supported"); |
| 2256 return false; | 2257 return false; |
| 2257 } | 2258 } |
| 2258 seen_objects->Add(object); | 2259 seen_objects->Add(object); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2394 workers_.Clear(); | 2395 workers_.Clear(); |
| 2395 } | 2396 } |
| 2396 | 2397 |
| 2397 for (int i = 0; i < workers_copy.length(); ++i) { | 2398 for (int i = 0; i < workers_copy.length(); ++i) { |
| 2398 Worker* worker = workers_copy[i]; | 2399 Worker* worker = workers_copy[i]; |
| 2399 worker->WaitForThread(); | 2400 worker->WaitForThread(); |
| 2400 delete worker; | 2401 delete worker; |
| 2401 } | 2402 } |
| 2402 | 2403 |
| 2403 // Now that all workers are terminated, we can re-enable Worker creation. | 2404 // Now that all workers are terminated, we can re-enable Worker creation. |
| 2404 { | 2405 base::LockGuard<base::Mutex> lock_guard(workers_mutex_.Pointer()); |
| 2405 base::LockGuard<base::Mutex> lock_guard(workers_mutex_.Pointer()); | 2406 allow_new_workers_ = true; |
| 2406 allow_new_workers_ = true; | |
| 2407 } | |
| 2408 | 2407 |
| 2409 for (int i = 0; i < externalized_shared_contents_.length(); ++i) { | 2408 for (int i = 0; i < externalized_shared_contents_.length(); ++i) { |
| 2410 const SharedArrayBuffer::Contents& contents = | 2409 const SharedArrayBuffer::Contents& contents = |
| 2411 externalized_shared_contents_[i]; | 2410 externalized_shared_contents_[i]; |
| 2412 Shell::array_buffer_allocator->Free(contents.Data(), contents.ByteLength()); | 2411 Shell::array_buffer_allocator->Free(contents.Data(), contents.ByteLength()); |
| 2413 } | 2412 } |
| 2414 externalized_shared_contents_.Clear(); | 2413 externalized_shared_contents_.Clear(); |
| 2415 } | 2414 } |
| 2416 | 2415 |
| 2417 | 2416 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2545 #endif | 2544 #endif |
| 2546 | 2545 |
| 2547 if (options.stress_opt || options.stress_deopt) { | 2546 if (options.stress_opt || options.stress_deopt) { |
| 2548 Testing::SetStressRunType(options.stress_opt | 2547 Testing::SetStressRunType(options.stress_opt |
| 2549 ? Testing::kStressTypeOpt | 2548 ? Testing::kStressTypeOpt |
| 2550 : Testing::kStressTypeDeopt); | 2549 : Testing::kStressTypeDeopt); |
| 2551 int stress_runs = Testing::GetStressRuns(); | 2550 int stress_runs = Testing::GetStressRuns(); |
| 2552 for (int i = 0; i < stress_runs && result == 0; i++) { | 2551 for (int i = 0; i < stress_runs && result == 0; i++) { |
| 2553 printf("============ Stress %d/%d ============\n", i + 1, stress_runs); | 2552 printf("============ Stress %d/%d ============\n", i + 1, stress_runs); |
| 2554 Testing::PrepareStressRun(i); | 2553 Testing::PrepareStressRun(i); |
| 2555 options.last_run = (i == stress_runs - 1); | 2554 options.set_last_run(i == stress_runs - 1); |
|
Jarin
2015/07/23 06:49:14
I am a bit confused about how this can be run in p
binji
2015/07/24 23:13:08
No, the SourceGroup spawns a thread per isolate th
| |
| 2556 result = RunMain(isolate, argc, argv); | 2555 result = RunMain(isolate, argc, argv); |
| 2557 } | 2556 } |
| 2558 printf("======== Full Deoptimization =======\n"); | 2557 printf("======== Full Deoptimization =======\n"); |
| 2559 Testing::DeoptimizeAll(); | 2558 Testing::DeoptimizeAll(); |
| 2560 #if !defined(V8_SHARED) | 2559 #if !defined(V8_SHARED) |
| 2561 } else if (i::FLAG_stress_runs > 0) { | 2560 } else if (i::FLAG_stress_runs > 0) { |
| 2562 int stress_runs = i::FLAG_stress_runs; | 2561 int stress_runs = i::FLAG_stress_runs; |
| 2563 for (int i = 0; i < stress_runs && result == 0; i++) { | 2562 for (int i = 0; i < stress_runs && result == 0; i++) { |
| 2564 printf("============ Run %d/%d ============\n", i + 1, stress_runs); | 2563 printf("============ Run %d/%d ============\n", i + 1, stress_runs); |
| 2565 options.last_run = (i == stress_runs - 1); | 2564 options.set_last_run(i == stress_runs - 1); |
|
Jarin
2015/07/23 06:49:14
Same here.
| |
| 2566 result = RunMain(isolate, argc, argv); | 2565 result = RunMain(isolate, argc, argv); |
| 2567 } | 2566 } |
| 2568 #endif | 2567 #endif |
| 2569 } else { | 2568 } else { |
| 2570 result = RunMain(isolate, argc, argv); | 2569 result = RunMain(isolate, argc, argv); |
| 2571 } | 2570 } |
| 2572 | 2571 |
| 2573 // Run interactive shell if explicitly requested or if no script has been | 2572 // Run interactive shell if explicitly requested or if no script has been |
| 2574 // executed, but never on --test | 2573 // executed, but never on --test |
| 2575 if (options.use_interactive_shell()) { | 2574 if (options.use_interactive_shell()) { |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 2606 } | 2605 } |
| 2607 | 2606 |
| 2608 } // namespace v8 | 2607 } // namespace v8 |
| 2609 | 2608 |
| 2610 | 2609 |
| 2611 #ifndef GOOGLE3 | 2610 #ifndef GOOGLE3 |
| 2612 int main(int argc, char* argv[]) { | 2611 int main(int argc, char* argv[]) { |
| 2613 return v8::Shell::Main(argc, argv); | 2612 return v8::Shell::Main(argc, argv); |
| 2614 } | 2613 } |
| 2615 #endif | 2614 #endif |
| OLD | NEW |