| 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 1460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1471 int index = | 1471 int index = |
| 1472 ComputeContinuationIndexFromPcOffset(function->code(), pc_offset); | 1472 ComputeContinuationIndexFromPcOffset(function->code(), pc_offset); |
| 1473 generator_obj->set_continuation(index); | 1473 generator_obj->set_continuation(index); |
| 1474 suspended_generators.Add(handle(generator_obj)); | 1474 suspended_generators.Add(handle(generator_obj)); |
| 1475 } | 1475 } |
| 1476 } | 1476 } |
| 1477 } | 1477 } |
| 1478 | 1478 |
| 1479 if (!shared->HasDebugCode()) { | 1479 if (!shared->HasDebugCode()) { |
| 1480 DCHECK(functions.length() > 0); | 1480 DCHECK(functions.length() > 0); |
| 1481 if (Compiler::GetDebugCode(functions.first()).is_null()) { | 1481 if (!Compiler::CompileDebugCode(functions.first())) return false; |
| 1482 return false; | |
| 1483 } | |
| 1484 } | 1482 } |
| 1485 | 1483 |
| 1486 for (Handle<JSFunction> const function : functions) { | 1484 for (Handle<JSFunction> const function : functions) { |
| 1487 function->ReplaceCode(shared->code()); | 1485 function->ReplaceCode(shared->code()); |
| 1488 } | 1486 } |
| 1489 | 1487 |
| 1490 for (Handle<JSGeneratorObject> const generator_obj : suspended_generators) { | 1488 for (Handle<JSGeneratorObject> const generator_obj : suspended_generators) { |
| 1491 int index = generator_obj->continuation(); | 1489 int index = generator_obj->continuation(); |
| 1492 int pc_offset = ComputePcOffsetFromContinuationIndex(shared->code(), index); | 1490 int pc_offset = ComputePcOffsetFromContinuationIndex(shared->code(), index); |
| 1493 generator_obj->set_continuation(pc_offset); | 1491 generator_obj->set_continuation(pc_offset); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1574 finder.NewCandidate(SharedFunctionInfo::cast(item)); | 1572 finder.NewCandidate(SharedFunctionInfo::cast(item)); |
| 1575 } | 1573 } |
| 1576 shared = finder.Result(); | 1574 shared = finder.Result(); |
| 1577 if (shared == NULL) break; | 1575 if (shared == NULL) break; |
| 1578 // We found it if it's already compiled and has debug code. | 1576 // We found it if it's already compiled and has debug code. |
| 1579 if (shared->HasDebugCode()) return handle(shared); | 1577 if (shared->HasDebugCode()) return handle(shared); |
| 1580 } | 1578 } |
| 1581 // If not, compile to reveal inner functions, if possible. | 1579 // If not, compile to reveal inner functions, if possible. |
| 1582 if (shared->allows_lazy_compilation_without_context()) { | 1580 if (shared->allows_lazy_compilation_without_context()) { |
| 1583 HandleScope scope(isolate_); | 1581 HandleScope scope(isolate_); |
| 1584 if (Compiler::GetDebugCode(handle(shared)).is_null()) break; | 1582 if (!Compiler::CompileDebugCode(handle(shared))) break; |
| 1585 continue; | 1583 continue; |
| 1586 } | 1584 } |
| 1587 | 1585 |
| 1588 // If not possible, comb the heap for the best suitable compile target. | 1586 // If not possible, comb the heap for the best suitable compile target. |
| 1589 JSFunction* closure; | 1587 JSFunction* closure; |
| 1590 { | 1588 { |
| 1591 HeapIterator it(isolate_->heap()); | 1589 HeapIterator it(isolate_->heap()); |
| 1592 SharedFunctionInfoFinder finder(position); | 1590 SharedFunctionInfoFinder finder(position); |
| 1593 while (HeapObject* object = it.next()) { | 1591 while (HeapObject* object = it.next()) { |
| 1594 JSFunction* candidate_closure = NULL; | 1592 JSFunction* candidate_closure = NULL; |
| 1595 SharedFunctionInfo* candidate = NULL; | 1593 SharedFunctionInfo* candidate = NULL; |
| 1596 if (object->IsJSFunction()) { | 1594 if (object->IsJSFunction()) { |
| 1597 candidate_closure = JSFunction::cast(object); | 1595 candidate_closure = JSFunction::cast(object); |
| 1598 candidate = candidate_closure->shared(); | 1596 candidate = candidate_closure->shared(); |
| 1599 } else if (object->IsSharedFunctionInfo()) { | 1597 } else if (object->IsSharedFunctionInfo()) { |
| 1600 candidate = SharedFunctionInfo::cast(object); | 1598 candidate = SharedFunctionInfo::cast(object); |
| 1601 if (!candidate->allows_lazy_compilation_without_context()) continue; | 1599 if (!candidate->allows_lazy_compilation_without_context()) continue; |
| 1602 } else { | 1600 } else { |
| 1603 continue; | 1601 continue; |
| 1604 } | 1602 } |
| 1605 if (candidate->script() == *script) { | 1603 if (candidate->script() == *script) { |
| 1606 finder.NewCandidate(candidate, candidate_closure); | 1604 finder.NewCandidate(candidate, candidate_closure); |
| 1607 } | 1605 } |
| 1608 } | 1606 } |
| 1609 closure = finder.ResultClosure(); | 1607 closure = finder.ResultClosure(); |
| 1610 shared = finder.Result(); | 1608 shared = finder.Result(); |
| 1611 } | 1609 } |
| 1612 HandleScope scope(isolate_); | 1610 HandleScope scope(isolate_); |
| 1613 if (closure == NULL) { | 1611 if (closure == NULL) { |
| 1614 if (Compiler::GetDebugCode(handle(shared)).is_null()) break; | 1612 if (!Compiler::CompileDebugCode(handle(shared))) break; |
| 1615 } else { | 1613 } else { |
| 1616 if (Compiler::GetDebugCode(handle(closure)).is_null()) break; | 1614 if (!Compiler::CompileDebugCode(handle(closure))) break; |
| 1617 } | 1615 } |
| 1618 } | 1616 } |
| 1619 return isolate_->factory()->undefined_value(); | 1617 return isolate_->factory()->undefined_value(); |
| 1620 } | 1618 } |
| 1621 | 1619 |
| 1622 | 1620 |
| 1623 // Ensures the debug information is present for shared. | 1621 // Ensures the debug information is present for shared. |
| 1624 bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared, | 1622 bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared, |
| 1625 Handle<JSFunction> function) { | 1623 Handle<JSFunction> function) { |
| 1626 if (!shared->IsSubjectToDebugging()) return false; | 1624 if (!shared->IsSubjectToDebugging()) return false; |
| (...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2825 } | 2823 } |
| 2826 | 2824 |
| 2827 | 2825 |
| 2828 void LockingCommandMessageQueue::Clear() { | 2826 void LockingCommandMessageQueue::Clear() { |
| 2829 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 2827 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
| 2830 queue_.Clear(); | 2828 queue_.Clear(); |
| 2831 } | 2829 } |
| 2832 | 2830 |
| 2833 } // namespace internal | 2831 } // namespace internal |
| 2834 } // namespace v8 | 2832 } // namespace v8 |
| OLD | NEW |