| 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 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1450 int index = | 1450 int index = |
| 1451 ComputeContinuationIndexFromPcOffset(function->code(), pc_offset); | 1451 ComputeContinuationIndexFromPcOffset(function->code(), pc_offset); |
| 1452 generator_obj->set_continuation(index); | 1452 generator_obj->set_continuation(index); |
| 1453 suspended_generators.Add(handle(generator_obj)); | 1453 suspended_generators.Add(handle(generator_obj)); |
| 1454 } | 1454 } |
| 1455 } | 1455 } |
| 1456 } | 1456 } |
| 1457 | 1457 |
| 1458 if (!shared->HasDebugCode()) { | 1458 if (!shared->HasDebugCode()) { |
| 1459 DCHECK(functions.length() > 0); | 1459 DCHECK(functions.length() > 0); |
| 1460 if (Compiler::GetDebugCode(functions.first()).is_null()) { | 1460 if (!Compiler::CompileDebugCode(functions.first())) return false; |
| 1461 return false; | |
| 1462 } | |
| 1463 } | 1461 } |
| 1464 | 1462 |
| 1465 for (Handle<JSFunction> const function : functions) { | 1463 for (Handle<JSFunction> const function : functions) { |
| 1466 function->ReplaceCode(shared->code()); | 1464 function->ReplaceCode(shared->code()); |
| 1467 } | 1465 } |
| 1468 | 1466 |
| 1469 for (Handle<JSGeneratorObject> const generator_obj : suspended_generators) { | 1467 for (Handle<JSGeneratorObject> const generator_obj : suspended_generators) { |
| 1470 int index = generator_obj->continuation(); | 1468 int index = generator_obj->continuation(); |
| 1471 int pc_offset = ComputePcOffsetFromContinuationIndex(shared->code(), index); | 1469 int pc_offset = ComputePcOffsetFromContinuationIndex(shared->code(), index); |
| 1472 generator_obj->set_continuation(pc_offset); | 1470 generator_obj->set_continuation(pc_offset); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1553 finder.NewCandidate(SharedFunctionInfo::cast(item)); | 1551 finder.NewCandidate(SharedFunctionInfo::cast(item)); |
| 1554 } | 1552 } |
| 1555 shared = finder.Result(); | 1553 shared = finder.Result(); |
| 1556 if (shared == NULL) break; | 1554 if (shared == NULL) break; |
| 1557 // We found it if it's already compiled and has debug code. | 1555 // We found it if it's already compiled and has debug code. |
| 1558 if (shared->HasDebugCode()) return handle(shared); | 1556 if (shared->HasDebugCode()) return handle(shared); |
| 1559 } | 1557 } |
| 1560 // If not, compile to reveal inner functions, if possible. | 1558 // If not, compile to reveal inner functions, if possible. |
| 1561 if (shared->allows_lazy_compilation_without_context()) { | 1559 if (shared->allows_lazy_compilation_without_context()) { |
| 1562 HandleScope scope(isolate_); | 1560 HandleScope scope(isolate_); |
| 1563 if (Compiler::GetDebugCode(handle(shared)).is_null()) break; | 1561 if (!Compiler::CompileDebugCode(handle(shared))) break; |
| 1564 continue; | 1562 continue; |
| 1565 } | 1563 } |
| 1566 | 1564 |
| 1567 // If not possible, comb the heap for the best suitable compile target. | 1565 // If not possible, comb the heap for the best suitable compile target. |
| 1568 JSFunction* closure; | 1566 JSFunction* closure; |
| 1569 { | 1567 { |
| 1570 HeapIterator it(isolate_->heap()); | 1568 HeapIterator it(isolate_->heap()); |
| 1571 SharedFunctionInfoFinder finder(position); | 1569 SharedFunctionInfoFinder finder(position); |
| 1572 while (HeapObject* object = it.next()) { | 1570 while (HeapObject* object = it.next()) { |
| 1573 JSFunction* candidate_closure = NULL; | 1571 JSFunction* candidate_closure = NULL; |
| 1574 SharedFunctionInfo* candidate = NULL; | 1572 SharedFunctionInfo* candidate = NULL; |
| 1575 if (object->IsJSFunction()) { | 1573 if (object->IsJSFunction()) { |
| 1576 candidate_closure = JSFunction::cast(object); | 1574 candidate_closure = JSFunction::cast(object); |
| 1577 candidate = candidate_closure->shared(); | 1575 candidate = candidate_closure->shared(); |
| 1578 } else if (object->IsSharedFunctionInfo()) { | 1576 } else if (object->IsSharedFunctionInfo()) { |
| 1579 candidate = SharedFunctionInfo::cast(object); | 1577 candidate = SharedFunctionInfo::cast(object); |
| 1580 if (!candidate->allows_lazy_compilation_without_context()) continue; | 1578 if (!candidate->allows_lazy_compilation_without_context()) continue; |
| 1581 } else { | 1579 } else { |
| 1582 continue; | 1580 continue; |
| 1583 } | 1581 } |
| 1584 if (candidate->script() == *script) { | 1582 if (candidate->script() == *script) { |
| 1585 finder.NewCandidate(candidate, candidate_closure); | 1583 finder.NewCandidate(candidate, candidate_closure); |
| 1586 } | 1584 } |
| 1587 } | 1585 } |
| 1588 closure = finder.ResultClosure(); | 1586 closure = finder.ResultClosure(); |
| 1589 shared = finder.Result(); | 1587 shared = finder.Result(); |
| 1590 } | 1588 } |
| 1591 HandleScope scope(isolate_); | 1589 HandleScope scope(isolate_); |
| 1592 if (closure == NULL) { | 1590 if (closure == NULL) { |
| 1593 if (Compiler::GetDebugCode(handle(shared)).is_null()) break; | 1591 if (!Compiler::CompileDebugCode(handle(shared))) break; |
| 1594 } else { | 1592 } else { |
| 1595 if (Compiler::GetDebugCode(handle(closure)).is_null()) break; | 1593 if (!Compiler::CompileDebugCode(handle(closure))) break; |
| 1596 } | 1594 } |
| 1597 } | 1595 } |
| 1598 return isolate_->factory()->undefined_value(); | 1596 return isolate_->factory()->undefined_value(); |
| 1599 } | 1597 } |
| 1600 | 1598 |
| 1601 | 1599 |
| 1602 // Ensures the debug information is present for shared. | 1600 // Ensures the debug information is present for shared. |
| 1603 bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared, | 1601 bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared, |
| 1604 Handle<JSFunction> function) { | 1602 Handle<JSFunction> function) { |
| 1605 if (!shared->IsSubjectToDebugging()) return false; | 1603 if (!shared->IsSubjectToDebugging()) return false; |
| (...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2776 } | 2774 } |
| 2777 | 2775 |
| 2778 | 2776 |
| 2779 void LockingCommandMessageQueue::Clear() { | 2777 void LockingCommandMessageQueue::Clear() { |
| 2780 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 2778 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
| 2781 queue_.Clear(); | 2779 queue_.Clear(); |
| 2782 } | 2780 } |
| 2783 | 2781 |
| 2784 } // namespace internal | 2782 } // namespace internal |
| 2785 } // namespace v8 | 2783 } // namespace v8 |
| OLD | NEW |