OLD | NEW |
---|---|
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 class CompareOutputArrayWriter { | 279 class CompareOutputArrayWriter { |
280 public: | 280 public: |
281 CompareOutputArrayWriter() | 281 CompareOutputArrayWriter() |
282 : array_(Factory::NewJSArray(10)), current_size_(0) {} | 282 : array_(Factory::NewJSArray(10)), current_size_(0) {} |
283 | 283 |
284 Handle<JSArray> GetResult() { | 284 Handle<JSArray> GetResult() { |
285 return array_; | 285 return array_; |
286 } | 286 } |
287 | 287 |
288 void WriteChunk(int char_pos1, int char_pos2, int char_len1, int char_len2) { | 288 void WriteChunk(int char_pos1, int char_pos2, int char_len1, int char_len2) { |
289 SetElement(array_, | 289 Handle<Object> no_failure; |
290 current_size_, | 290 no_failure = SetElement(array_, |
Lasse Reichstein
2011/03/08 09:26:08
Add a comment saying that we never set element acc
| |
291 Handle<Object>(Smi::FromInt(char_pos1)), | 291 current_size_, |
292 kNonStrictMode); | 292 Handle<Object>(Smi::FromInt(char_pos1)), |
293 SetElement(array_, | 293 kNonStrictMode); |
294 current_size_ + 1, | 294 ASSERT(!no_failure.is_null()); |
295 Handle<Object>(Smi::FromInt(char_pos1 + char_len1)), | 295 no_failure = SetElement(array_, |
296 kNonStrictMode); | 296 current_size_ + 1, |
297 SetElement(array_, | 297 Handle<Object>(Smi::FromInt(char_pos1 + char_len1)), |
298 current_size_ + 2, | 298 kNonStrictMode); |
299 Handle<Object>(Smi::FromInt(char_pos2 + char_len2)), | 299 ASSERT(!no_failure.is_null()); |
300 kNonStrictMode); | 300 no_failure = SetElement(array_, |
301 current_size_ + 2, | |
302 Handle<Object>(Smi::FromInt(char_pos2 + char_len2)), | |
303 kNonStrictMode); | |
Lasse Reichstein
2011/03/08 09:26:08
Are we sure we don't get any warnings from this as
| |
304 ASSERT(!no_failure.is_null()); | |
301 current_size_ += 3; | 305 current_size_ += 3; |
302 } | 306 } |
303 | 307 |
304 private: | 308 private: |
305 Handle<JSArray> array_; | 309 Handle<JSArray> array_; |
306 int current_size_; | 310 int current_size_; |
307 }; | 311 }; |
308 | 312 |
309 | 313 |
310 // Represents 2 strings as 2 arrays of tokens. | 314 // Represents 2 strings as 2 arrays of tokens. |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
545 return S(array_handle); | 549 return S(array_handle); |
546 } | 550 } |
547 explicit JSArrayBasedStruct(Handle<JSArray> array) : array_(array) { | 551 explicit JSArrayBasedStruct(Handle<JSArray> array) : array_(array) { |
548 } | 552 } |
549 Handle<JSArray> GetJSArray() { | 553 Handle<JSArray> GetJSArray() { |
550 return array_; | 554 return array_; |
551 } | 555 } |
552 | 556 |
553 protected: | 557 protected: |
554 void SetField(int field_position, Handle<Object> value) { | 558 void SetField(int field_position, Handle<Object> value) { |
555 SetElement(array_, field_position, value, kNonStrictMode); | 559 Handle<Object> no_failure = |
560 SetElement(array_, field_position, value, kNonStrictMode); | |
561 ASSERT(!no_failure.is_null()); | |
556 } | 562 } |
557 void SetSmiValueField(int field_position, int value) { | 563 void SetSmiValueField(int field_position, int value) { |
558 SetElement(array_, | 564 Handle<Object> no_failure = SetElement(array_, |
559 field_position, | 565 field_position, |
560 Handle<Smi>(Smi::FromInt(value)), | 566 Handle<Smi>(Smi::FromInt(value)), |
561 kNonStrictMode); | 567 kNonStrictMode); |
568 ASSERT(!no_failure.is_null()); | |
562 } | 569 } |
563 Object* GetField(int field_position) { | 570 Object* GetField(int field_position) { |
564 return array_->GetElementNoExceptionThrown(field_position); | 571 return array_->GetElementNoExceptionThrown(field_position); |
565 } | 572 } |
566 int GetSmiValueField(int field_position) { | 573 int GetSmiValueField(int field_position) { |
567 Object* res = GetField(field_position); | 574 Object* res = GetField(field_position); |
568 return Smi::cast(res)->value(); | 575 return Smi::cast(res)->value(); |
569 } | 576 } |
570 | 577 |
571 private: | 578 private: |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
690 result_ = Factory::NewJSArray(10); | 697 result_ = Factory::NewJSArray(10); |
691 } | 698 } |
692 | 699 |
693 void FunctionStarted(FunctionLiteral* fun) { | 700 void FunctionStarted(FunctionLiteral* fun) { |
694 HandleScope scope; | 701 HandleScope scope; |
695 FunctionInfoWrapper info = FunctionInfoWrapper::Create(); | 702 FunctionInfoWrapper info = FunctionInfoWrapper::Create(); |
696 info.SetInitialProperties(fun->name(), fun->start_position(), | 703 info.SetInitialProperties(fun->name(), fun->start_position(), |
697 fun->end_position(), fun->num_parameters(), | 704 fun->end_position(), fun->num_parameters(), |
698 current_parent_index_); | 705 current_parent_index_); |
699 current_parent_index_ = len_; | 706 current_parent_index_ = len_; |
700 SetElement(result_, len_, info.GetJSArray(), kNonStrictMode); | 707 Handle<Object> no_failure = |
708 SetElement(result_, len_, info.GetJSArray(), kNonStrictMode); | |
709 ASSERT(!no_failure.is_null()); | |
701 len_++; | 710 len_++; |
702 } | 711 } |
703 | 712 |
704 void FunctionDone() { | 713 void FunctionDone() { |
705 HandleScope scope; | 714 HandleScope scope; |
706 FunctionInfoWrapper info = | 715 FunctionInfoWrapper info = |
707 FunctionInfoWrapper::cast( | 716 FunctionInfoWrapper::cast( |
708 result_->GetElementNoExceptionThrown(current_parent_index_)); | 717 result_->GetElementNoExceptionThrown(current_parent_index_)); |
709 current_parent_index_ = info.GetParentIndex(); | 718 current_parent_index_ = info.GetParentIndex(); |
710 } | 719 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
769 // Sort it. | 778 // Sort it. |
770 for (int k = 1; k < j; k++) { | 779 for (int k = 1; k < j; k++) { |
771 int l = k; | 780 int l = k; |
772 for (int m = k + 1; m < j; m++) { | 781 for (int m = k + 1; m < j; m++) { |
773 if (list[l]->AsSlot()->index() > list[m]->AsSlot()->index()) { | 782 if (list[l]->AsSlot()->index() > list[m]->AsSlot()->index()) { |
774 l = m; | 783 l = m; |
775 } | 784 } |
776 } | 785 } |
777 list[k] = list[l]; | 786 list[k] = list[l]; |
778 } | 787 } |
788 Handle<Object> no_failure; | |
779 for (int i = 0; i < j; i++) { | 789 for (int i = 0; i < j; i++) { |
780 SetElement(scope_info_list, scope_info_length, | 790 no_failure = SetElement(scope_info_list, scope_info_length, |
781 list[i]->name(), kNonStrictMode); | 791 list[i]->name(), kNonStrictMode); |
792 ASSERT(!no_failure.is_null()); | |
782 scope_info_length++; | 793 scope_info_length++; |
783 SetElement(scope_info_list, scope_info_length, | 794 no_failure = SetElement( |
784 Handle<Smi>(Smi::FromInt(list[i]->AsSlot()->index())), | 795 scope_info_list, |
785 kNonStrictMode); | 796 scope_info_length, |
797 Handle<Smi>(Smi::FromInt(list[i]->AsSlot()->index())), | |
798 kNonStrictMode); | |
799 ASSERT(!no_failure.is_null()); | |
786 scope_info_length++; | 800 scope_info_length++; |
787 } | 801 } |
788 SetElement(scope_info_list, scope_info_length, | 802 no_failure = SetElement(scope_info_list, |
789 Handle<Object>(Heap::null_value()), kNonStrictMode); | 803 scope_info_length, |
804 Handle<Object>(Heap::null_value()), | |
805 kNonStrictMode); | |
806 ASSERT(!no_failure.is_null()); | |
790 scope_info_length++; | 807 scope_info_length++; |
791 | 808 |
792 outer_scope = outer_scope->outer_scope(); | 809 outer_scope = outer_scope->outer_scope(); |
793 } while (outer_scope != NULL); | 810 } while (outer_scope != NULL); |
794 | 811 |
795 return *scope_info_list; | 812 return *scope_info_list; |
796 } | 813 } |
797 | 814 |
798 Handle<JSArray> result_; | 815 Handle<JSArray> result_; |
799 int len_; | 816 int len_; |
(...skipping 22 matching lines...) Expand all Loading... | |
822 void LiveEdit::WrapSharedFunctionInfos(Handle<JSArray> array) { | 839 void LiveEdit::WrapSharedFunctionInfos(Handle<JSArray> array) { |
823 HandleScope scope; | 840 HandleScope scope; |
824 int len = Smi::cast(array->length())->value(); | 841 int len = Smi::cast(array->length())->value(); |
825 for (int i = 0; i < len; i++) { | 842 for (int i = 0; i < len; i++) { |
826 Handle<SharedFunctionInfo> info( | 843 Handle<SharedFunctionInfo> info( |
827 SharedFunctionInfo::cast(array->GetElementNoExceptionThrown(i))); | 844 SharedFunctionInfo::cast(array->GetElementNoExceptionThrown(i))); |
828 SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create(); | 845 SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create(); |
829 Handle<String> name_handle(String::cast(info->name())); | 846 Handle<String> name_handle(String::cast(info->name())); |
830 info_wrapper.SetProperties(name_handle, info->start_position(), | 847 info_wrapper.SetProperties(name_handle, info->start_position(), |
831 info->end_position(), info); | 848 info->end_position(), info); |
832 SetElement(array, i, info_wrapper.GetJSArray(), kNonStrictMode); | 849 Handle<Object> no_failure = |
850 SetElement(array, i, info_wrapper.GetJSArray(), kNonStrictMode); | |
851 ASSERT(!no_failure.is_null()); | |
833 } | 852 } |
834 } | 853 } |
835 | 854 |
836 | 855 |
837 // Visitor that collects all references to a particular code object, | 856 // Visitor that collects all references to a particular code object, |
838 // including "CODE_TARGET" references in other code objects. | 857 // including "CODE_TARGET" references in other code objects. |
839 // It works in context of ZoneScope. | 858 // It works in context of ZoneScope. |
840 class ReferenceCollectorVisitor : public ObjectVisitor { | 859 class ReferenceCollectorVisitor : public ObjectVisitor { |
841 public: | 860 public: |
842 explicit ReferenceCollectorVisitor(Code* original) | 861 explicit ReferenceCollectorVisitor(Code* original) |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1320 JSFunction::cast(JavaScriptFrame::cast(frame)->function())); | 1339 JSFunction::cast(JavaScriptFrame::cast(frame)->function())); |
1321 | 1340 |
1322 int len = Smi::cast(shared_info_array->length())->value(); | 1341 int len = Smi::cast(shared_info_array->length())->value(); |
1323 for (int i = 0; i < len; i++) { | 1342 for (int i = 0; i < len; i++) { |
1324 JSValue* wrapper = | 1343 JSValue* wrapper = |
1325 JSValue::cast(shared_info_array->GetElementNoExceptionThrown(i)); | 1344 JSValue::cast(shared_info_array->GetElementNoExceptionThrown(i)); |
1326 Handle<SharedFunctionInfo> shared( | 1345 Handle<SharedFunctionInfo> shared( |
1327 SharedFunctionInfo::cast(wrapper->value())); | 1346 SharedFunctionInfo::cast(wrapper->value())); |
1328 | 1347 |
1329 if (function->shared() == *shared || IsInlined(*function, *shared)) { | 1348 if (function->shared() == *shared || IsInlined(*function, *shared)) { |
1330 SetElement(result, i, Handle<Smi>(Smi::FromInt(status)), kNonStrictMode); | 1349 Handle<Object> no_failure = |
1350 SetElement(result, | |
1351 i, | |
1352 Handle<Smi>(Smi::FromInt(status)), | |
1353 kNonStrictMode); | |
1354 ASSERT(!no_failure.is_null()); | |
1331 return true; | 1355 return true; |
1332 } | 1356 } |
1333 } | 1357 } |
1334 return false; | 1358 return false; |
1335 } | 1359 } |
1336 | 1360 |
1337 | 1361 |
1338 // Iterates over handler chain and removes all elements that are inside | 1362 // Iterates over handler chain and removes all elements that are inside |
1339 // frames being dropped. | 1363 // frames being dropped. |
1340 static bool FixTryCatchHandler(StackFrame* top_frame, | 1364 static bool FixTryCatchHandler(StackFrame* top_frame, |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1525 } | 1549 } |
1526 Debug::FramesHaveBeenDropped(new_id, drop_mode, | 1550 Debug::FramesHaveBeenDropped(new_id, drop_mode, |
1527 restarter_frame_function_pointer); | 1551 restarter_frame_function_pointer); |
1528 | 1552 |
1529 // Replace "blocked on active" with "replaced on active" status. | 1553 // Replace "blocked on active" with "replaced on active" status. |
1530 for (int i = 0; i < array_len; i++) { | 1554 for (int i = 0; i < array_len; i++) { |
1531 if (result->GetElement(i) == | 1555 if (result->GetElement(i) == |
1532 Smi::FromInt(LiveEdit::FUNCTION_BLOCKED_ON_ACTIVE_STACK)) { | 1556 Smi::FromInt(LiveEdit::FUNCTION_BLOCKED_ON_ACTIVE_STACK)) { |
1533 Handle<Object> replaced( | 1557 Handle<Object> replaced( |
1534 Smi::FromInt(LiveEdit::FUNCTION_REPLACED_ON_ACTIVE_STACK)); | 1558 Smi::FromInt(LiveEdit::FUNCTION_REPLACED_ON_ACTIVE_STACK)); |
1535 SetElement(result, i, replaced, kNonStrictMode); | 1559 Handle<Object> no_failure = |
1560 SetElement(result, i, replaced, kNonStrictMode); | |
1561 ASSERT(!no_failure.is_null()); | |
1536 } | 1562 } |
1537 } | 1563 } |
1538 return NULL; | 1564 return NULL; |
1539 } | 1565 } |
1540 | 1566 |
1541 | 1567 |
1542 class InactiveThreadActivationsChecker : public ThreadVisitor { | 1568 class InactiveThreadActivationsChecker : public ThreadVisitor { |
1543 public: | 1569 public: |
1544 InactiveThreadActivationsChecker(Handle<JSArray> shared_info_array, | 1570 InactiveThreadActivationsChecker(Handle<JSArray> shared_info_array, |
1545 Handle<JSArray> result) | 1571 Handle<JSArray> result) |
(...skipping 19 matching lines...) Expand all Loading... | |
1565 | 1591 |
1566 | 1592 |
1567 Handle<JSArray> LiveEdit::CheckAndDropActivations( | 1593 Handle<JSArray> LiveEdit::CheckAndDropActivations( |
1568 Handle<JSArray> shared_info_array, bool do_drop) { | 1594 Handle<JSArray> shared_info_array, bool do_drop) { |
1569 int len = Smi::cast(shared_info_array->length())->value(); | 1595 int len = Smi::cast(shared_info_array->length())->value(); |
1570 | 1596 |
1571 Handle<JSArray> result = Factory::NewJSArray(len); | 1597 Handle<JSArray> result = Factory::NewJSArray(len); |
1572 | 1598 |
1573 // Fill the default values. | 1599 // Fill the default values. |
1574 for (int i = 0; i < len; i++) { | 1600 for (int i = 0; i < len; i++) { |
1575 SetElement(result, i, | 1601 Handle<Object> no_failure = |
1576 Handle<Smi>(Smi::FromInt(FUNCTION_AVAILABLE_FOR_PATCH)), | 1602 SetElement(result, i, |
1577 kNonStrictMode); | 1603 Handle<Smi>(Smi::FromInt(FUNCTION_AVAILABLE_FOR_PATCH)), |
1604 kNonStrictMode); | |
1605 ASSERT(!no_failure.is_null()); | |
1578 } | 1606 } |
1579 | 1607 |
1580 | 1608 |
1581 // First check inactive threads. Fail if some functions are blocked there. | 1609 // First check inactive threads. Fail if some functions are blocked there. |
1582 InactiveThreadActivationsChecker inactive_threads_checker(shared_info_array, | 1610 InactiveThreadActivationsChecker inactive_threads_checker(shared_info_array, |
1583 result); | 1611 result); |
1584 ThreadManager::IterateArchivedThreads(&inactive_threads_checker); | 1612 ThreadManager::IterateArchivedThreads(&inactive_threads_checker); |
1585 if (inactive_threads_checker.HasBlockedFunctions()) { | 1613 if (inactive_threads_checker.HasBlockedFunctions()) { |
1586 return result; | 1614 return result; |
1587 } | 1615 } |
1588 | 1616 |
1589 // Try to drop activations from the current stack. | 1617 // Try to drop activations from the current stack. |
1590 const char* error_message = | 1618 const char* error_message = |
1591 DropActivationsInActiveThread(shared_info_array, result, do_drop); | 1619 DropActivationsInActiveThread(shared_info_array, result, do_drop); |
1592 if (error_message != NULL) { | 1620 if (error_message != NULL) { |
1593 // Add error message as an array extra element. | 1621 // Add error message as an array extra element. |
1594 Vector<const char> vector_message(error_message, StrLength(error_message)); | 1622 Vector<const char> vector_message(error_message, StrLength(error_message)); |
1595 Handle<String> str = Factory::NewStringFromAscii(vector_message); | 1623 Handle<String> str = Factory::NewStringFromAscii(vector_message); |
1596 SetElement(result, len, str, kNonStrictMode); | 1624 Handle<Object> no_failure = SetElement(result, len, str, kNonStrictMode); |
1625 ASSERT(!no_failure.is_null()); | |
1597 } | 1626 } |
1598 return result; | 1627 return result; |
1599 } | 1628 } |
1600 | 1629 |
1601 | 1630 |
1602 LiveEditFunctionTracker::LiveEditFunctionTracker(FunctionLiteral* fun) { | 1631 LiveEditFunctionTracker::LiveEditFunctionTracker(FunctionLiteral* fun) { |
1603 if (active_function_info_listener != NULL) { | 1632 if (active_function_info_listener != NULL) { |
1604 active_function_info_listener->FunctionStarted(fun); | 1633 active_function_info_listener->FunctionStarted(fun); |
1605 } | 1634 } |
1606 } | 1635 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1654 | 1683 |
1655 bool LiveEditFunctionTracker::IsActive() { | 1684 bool LiveEditFunctionTracker::IsActive() { |
1656 return false; | 1685 return false; |
1657 } | 1686 } |
1658 | 1687 |
1659 #endif // ENABLE_DEBUGGER_SUPPORT | 1688 #endif // ENABLE_DEBUGGER_SUPPORT |
1660 | 1689 |
1661 | 1690 |
1662 | 1691 |
1663 } } // namespace v8::internal | 1692 } } // namespace v8::internal |
OLD | NEW |