| 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 29 matching lines...) Expand all Loading... |
| 40 #include "scopeinfo.h" | 40 #include "scopeinfo.h" |
| 41 #include "scopes.h" | 41 #include "scopes.h" |
| 42 | 42 |
| 43 namespace v8 { | 43 namespace v8 { |
| 44 namespace internal { | 44 namespace internal { |
| 45 | 45 |
| 46 | 46 |
| 47 #ifdef ENABLE_DEBUGGER_SUPPORT | 47 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 48 | 48 |
| 49 | 49 |
| 50 void SetElementNonStrict(Handle<JSObject> object, |
| 51 uint32_t index, |
| 52 Handle<Object> value) { |
| 53 // Ignore return value from SetElement. It can only be a failure if there |
| 54 // are element setters causing exceptions and the debugger context has none |
| 55 // of these. |
| 56 Handle<Object> no_failure; |
| 57 no_failure = SetElement(object, index, value, kNonStrictMode); |
| 58 ASSERT(!no_failure.is_null()); |
| 59 USE(no_failure); |
| 60 } |
| 61 |
| 50 // A simple implementation of dynamic programming algorithm. It solves | 62 // A simple implementation of dynamic programming algorithm. It solves |
| 51 // the problem of finding the difference of 2 arrays. It uses a table of results | 63 // the problem of finding the difference of 2 arrays. It uses a table of results |
| 52 // of subproblems. Each cell contains a number together with 2-bit flag | 64 // of subproblems. Each cell contains a number together with 2-bit flag |
| 53 // that helps building the chunk list. | 65 // that helps building the chunk list. |
| 54 class Differencer { | 66 class Differencer { |
| 55 public: | 67 public: |
| 56 explicit Differencer(Comparator::Input* input) | 68 explicit Differencer(Comparator::Input* input) |
| 57 : input_(input), len1_(input->getLength1()), len2_(input->getLength2()) { | 69 : input_(input), len1_(input->getLength1()), len2_(input->getLength2()) { |
| 58 buffer_ = NewArray<int>(len1_ * len2_); | 70 buffer_ = NewArray<int>(len1_ * len2_); |
| 59 } | 71 } |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 class CompareOutputArrayWriter { | 291 class CompareOutputArrayWriter { |
| 280 public: | 292 public: |
| 281 CompareOutputArrayWriter() | 293 CompareOutputArrayWriter() |
| 282 : array_(Factory::NewJSArray(10)), current_size_(0) {} | 294 : array_(Factory::NewJSArray(10)), current_size_(0) {} |
| 283 | 295 |
| 284 Handle<JSArray> GetResult() { | 296 Handle<JSArray> GetResult() { |
| 285 return array_; | 297 return array_; |
| 286 } | 298 } |
| 287 | 299 |
| 288 void WriteChunk(int char_pos1, int char_pos2, int char_len1, int char_len2) { | 300 void WriteChunk(int char_pos1, int char_pos2, int char_len1, int char_len2) { |
| 289 SetElement(array_, current_size_, Handle<Object>(Smi::FromInt(char_pos1))); | 301 SetElementNonStrict(array_, |
| 290 SetElement(array_, current_size_ + 1, | 302 current_size_, |
| 291 Handle<Object>(Smi::FromInt(char_pos1 + char_len1))); | 303 Handle<Object>(Smi::FromInt(char_pos1))); |
| 292 SetElement(array_, current_size_ + 2, | 304 SetElementNonStrict(array_, |
| 293 Handle<Object>(Smi::FromInt(char_pos2 + char_len2))); | 305 current_size_ + 1, |
| 306 Handle<Object>(Smi::FromInt(char_pos1 + char_len1))); |
| 307 SetElementNonStrict(array_, |
| 308 current_size_ + 2, |
| 309 Handle<Object>(Smi::FromInt(char_pos2 + char_len2))); |
| 294 current_size_ += 3; | 310 current_size_ += 3; |
| 295 } | 311 } |
| 296 | 312 |
| 297 private: | 313 private: |
| 298 Handle<JSArray> array_; | 314 Handle<JSArray> array_; |
| 299 int current_size_; | 315 int current_size_; |
| 300 }; | 316 }; |
| 301 | 317 |
| 302 | 318 |
| 303 // Represents 2 strings as 2 arrays of tokens. | 319 // Represents 2 strings as 2 arrays of tokens. |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 return S(array_handle); | 554 return S(array_handle); |
| 539 } | 555 } |
| 540 explicit JSArrayBasedStruct(Handle<JSArray> array) : array_(array) { | 556 explicit JSArrayBasedStruct(Handle<JSArray> array) : array_(array) { |
| 541 } | 557 } |
| 542 Handle<JSArray> GetJSArray() { | 558 Handle<JSArray> GetJSArray() { |
| 543 return array_; | 559 return array_; |
| 544 } | 560 } |
| 545 | 561 |
| 546 protected: | 562 protected: |
| 547 void SetField(int field_position, Handle<Object> value) { | 563 void SetField(int field_position, Handle<Object> value) { |
| 548 SetElement(array_, field_position, value); | 564 SetElementNonStrict(array_, field_position, value); |
| 549 } | 565 } |
| 550 void SetSmiValueField(int field_position, int value) { | 566 void SetSmiValueField(int field_position, int value) { |
| 551 SetElement(array_, field_position, Handle<Smi>(Smi::FromInt(value))); | 567 SetElementNonStrict(array_, |
| 568 field_position, |
| 569 Handle<Smi>(Smi::FromInt(value))); |
| 552 } | 570 } |
| 553 Object* GetField(int field_position) { | 571 Object* GetField(int field_position) { |
| 554 return array_->GetElementNoExceptionThrown(field_position); | 572 return array_->GetElementNoExceptionThrown(field_position); |
| 555 } | 573 } |
| 556 int GetSmiValueField(int field_position) { | 574 int GetSmiValueField(int field_position) { |
| 557 Object* res = GetField(field_position); | 575 Object* res = GetField(field_position); |
| 558 return Smi::cast(res)->value(); | 576 return Smi::cast(res)->value(); |
| 559 } | 577 } |
| 560 | 578 |
| 561 private: | 579 private: |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 result_ = Factory::NewJSArray(10); | 698 result_ = Factory::NewJSArray(10); |
| 681 } | 699 } |
| 682 | 700 |
| 683 void FunctionStarted(FunctionLiteral* fun) { | 701 void FunctionStarted(FunctionLiteral* fun) { |
| 684 HandleScope scope; | 702 HandleScope scope; |
| 685 FunctionInfoWrapper info = FunctionInfoWrapper::Create(); | 703 FunctionInfoWrapper info = FunctionInfoWrapper::Create(); |
| 686 info.SetInitialProperties(fun->name(), fun->start_position(), | 704 info.SetInitialProperties(fun->name(), fun->start_position(), |
| 687 fun->end_position(), fun->num_parameters(), | 705 fun->end_position(), fun->num_parameters(), |
| 688 current_parent_index_); | 706 current_parent_index_); |
| 689 current_parent_index_ = len_; | 707 current_parent_index_ = len_; |
| 690 SetElement(result_, len_, info.GetJSArray()); | 708 SetElementNonStrict(result_, len_, info.GetJSArray()); |
| 691 len_++; | 709 len_++; |
| 692 } | 710 } |
| 693 | 711 |
| 694 void FunctionDone() { | 712 void FunctionDone() { |
| 695 HandleScope scope; | 713 HandleScope scope; |
| 696 FunctionInfoWrapper info = | 714 FunctionInfoWrapper info = |
| 697 FunctionInfoWrapper::cast( | 715 FunctionInfoWrapper::cast( |
| 698 result_->GetElementNoExceptionThrown(current_parent_index_)); | 716 result_->GetElementNoExceptionThrown(current_parent_index_)); |
| 699 current_parent_index_ = info.GetParentIndex(); | 717 current_parent_index_ = info.GetParentIndex(); |
| 700 } | 718 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 for (int k = 1; k < j; k++) { | 778 for (int k = 1; k < j; k++) { |
| 761 int l = k; | 779 int l = k; |
| 762 for (int m = k + 1; m < j; m++) { | 780 for (int m = k + 1; m < j; m++) { |
| 763 if (list[l]->AsSlot()->index() > list[m]->AsSlot()->index()) { | 781 if (list[l]->AsSlot()->index() > list[m]->AsSlot()->index()) { |
| 764 l = m; | 782 l = m; |
| 765 } | 783 } |
| 766 } | 784 } |
| 767 list[k] = list[l]; | 785 list[k] = list[l]; |
| 768 } | 786 } |
| 769 for (int i = 0; i < j; i++) { | 787 for (int i = 0; i < j; i++) { |
| 770 SetElement(scope_info_list, scope_info_length, list[i]->name()); | 788 SetElementNonStrict(scope_info_list, |
| 789 scope_info_length, |
| 790 list[i]->name()); |
| 771 scope_info_length++; | 791 scope_info_length++; |
| 772 SetElement(scope_info_list, scope_info_length, | 792 SetElementNonStrict( |
| 773 Handle<Smi>(Smi::FromInt(list[i]->AsSlot()->index()))); | 793 scope_info_list, |
| 794 scope_info_length, |
| 795 Handle<Smi>(Smi::FromInt(list[i]->AsSlot()->index()))); |
| 774 scope_info_length++; | 796 scope_info_length++; |
| 775 } | 797 } |
| 776 SetElement(scope_info_list, scope_info_length, | 798 SetElementNonStrict(scope_info_list, |
| 777 Handle<Object>(Heap::null_value())); | 799 scope_info_length, |
| 800 Handle<Object>(Heap::null_value())); |
| 778 scope_info_length++; | 801 scope_info_length++; |
| 779 | 802 |
| 780 outer_scope = outer_scope->outer_scope(); | 803 outer_scope = outer_scope->outer_scope(); |
| 781 } while (outer_scope != NULL); | 804 } while (outer_scope != NULL); |
| 782 | 805 |
| 783 return *scope_info_list; | 806 return *scope_info_list; |
| 784 } | 807 } |
| 785 | 808 |
| 786 Handle<JSArray> result_; | 809 Handle<JSArray> result_; |
| 787 int len_; | 810 int len_; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 810 void LiveEdit::WrapSharedFunctionInfos(Handle<JSArray> array) { | 833 void LiveEdit::WrapSharedFunctionInfos(Handle<JSArray> array) { |
| 811 HandleScope scope; | 834 HandleScope scope; |
| 812 int len = Smi::cast(array->length())->value(); | 835 int len = Smi::cast(array->length())->value(); |
| 813 for (int i = 0; i < len; i++) { | 836 for (int i = 0; i < len; i++) { |
| 814 Handle<SharedFunctionInfo> info( | 837 Handle<SharedFunctionInfo> info( |
| 815 SharedFunctionInfo::cast(array->GetElementNoExceptionThrown(i))); | 838 SharedFunctionInfo::cast(array->GetElementNoExceptionThrown(i))); |
| 816 SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create(); | 839 SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create(); |
| 817 Handle<String> name_handle(String::cast(info->name())); | 840 Handle<String> name_handle(String::cast(info->name())); |
| 818 info_wrapper.SetProperties(name_handle, info->start_position(), | 841 info_wrapper.SetProperties(name_handle, info->start_position(), |
| 819 info->end_position(), info); | 842 info->end_position(), info); |
| 820 SetElement(array, i, info_wrapper.GetJSArray()); | 843 SetElementNonStrict(array, i, info_wrapper.GetJSArray()); |
| 821 } | 844 } |
| 822 } | 845 } |
| 823 | 846 |
| 824 | 847 |
| 825 // Visitor that collects all references to a particular code object, | 848 // Visitor that collects all references to a particular code object, |
| 826 // including "CODE_TARGET" references in other code objects. | 849 // including "CODE_TARGET" references in other code objects. |
| 827 // It works in context of ZoneScope. | 850 // It works in context of ZoneScope. |
| 828 class ReferenceCollectorVisitor : public ObjectVisitor { | 851 class ReferenceCollectorVisitor : public ObjectVisitor { |
| 829 public: | 852 public: |
| 830 explicit ReferenceCollectorVisitor(Code* original) | 853 explicit ReferenceCollectorVisitor(Code* original) |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1310 JSFunction::cast(JavaScriptFrame::cast(frame)->function())); | 1333 JSFunction::cast(JavaScriptFrame::cast(frame)->function())); |
| 1311 | 1334 |
| 1312 int len = Smi::cast(shared_info_array->length())->value(); | 1335 int len = Smi::cast(shared_info_array->length())->value(); |
| 1313 for (int i = 0; i < len; i++) { | 1336 for (int i = 0; i < len; i++) { |
| 1314 JSValue* wrapper = | 1337 JSValue* wrapper = |
| 1315 JSValue::cast(shared_info_array->GetElementNoExceptionThrown(i)); | 1338 JSValue::cast(shared_info_array->GetElementNoExceptionThrown(i)); |
| 1316 Handle<SharedFunctionInfo> shared( | 1339 Handle<SharedFunctionInfo> shared( |
| 1317 SharedFunctionInfo::cast(wrapper->value())); | 1340 SharedFunctionInfo::cast(wrapper->value())); |
| 1318 | 1341 |
| 1319 if (function->shared() == *shared || IsInlined(*function, *shared)) { | 1342 if (function->shared() == *shared || IsInlined(*function, *shared)) { |
| 1320 SetElement(result, i, Handle<Smi>(Smi::FromInt(status))); | 1343 SetElementNonStrict(result, i, Handle<Smi>(Smi::FromInt(status))); |
| 1321 return true; | 1344 return true; |
| 1322 } | 1345 } |
| 1323 } | 1346 } |
| 1324 return false; | 1347 return false; |
| 1325 } | 1348 } |
| 1326 | 1349 |
| 1327 | 1350 |
| 1328 // Iterates over handler chain and removes all elements that are inside | 1351 // Iterates over handler chain and removes all elements that are inside |
| 1329 // frames being dropped. | 1352 // frames being dropped. |
| 1330 static bool FixTryCatchHandler(StackFrame* top_frame, | 1353 static bool FixTryCatchHandler(StackFrame* top_frame, |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1515 } | 1538 } |
| 1516 Debug::FramesHaveBeenDropped(new_id, drop_mode, | 1539 Debug::FramesHaveBeenDropped(new_id, drop_mode, |
| 1517 restarter_frame_function_pointer); | 1540 restarter_frame_function_pointer); |
| 1518 | 1541 |
| 1519 // Replace "blocked on active" with "replaced on active" status. | 1542 // Replace "blocked on active" with "replaced on active" status. |
| 1520 for (int i = 0; i < array_len; i++) { | 1543 for (int i = 0; i < array_len; i++) { |
| 1521 if (result->GetElement(i) == | 1544 if (result->GetElement(i) == |
| 1522 Smi::FromInt(LiveEdit::FUNCTION_BLOCKED_ON_ACTIVE_STACK)) { | 1545 Smi::FromInt(LiveEdit::FUNCTION_BLOCKED_ON_ACTIVE_STACK)) { |
| 1523 Handle<Object> replaced( | 1546 Handle<Object> replaced( |
| 1524 Smi::FromInt(LiveEdit::FUNCTION_REPLACED_ON_ACTIVE_STACK)); | 1547 Smi::FromInt(LiveEdit::FUNCTION_REPLACED_ON_ACTIVE_STACK)); |
| 1525 SetElement(result, i, replaced); | 1548 SetElementNonStrict(result, i, replaced); |
| 1526 } | 1549 } |
| 1527 } | 1550 } |
| 1528 return NULL; | 1551 return NULL; |
| 1529 } | 1552 } |
| 1530 | 1553 |
| 1531 | 1554 |
| 1532 class InactiveThreadActivationsChecker : public ThreadVisitor { | 1555 class InactiveThreadActivationsChecker : public ThreadVisitor { |
| 1533 public: | 1556 public: |
| 1534 InactiveThreadActivationsChecker(Handle<JSArray> shared_info_array, | 1557 InactiveThreadActivationsChecker(Handle<JSArray> shared_info_array, |
| 1535 Handle<JSArray> result) | 1558 Handle<JSArray> result) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1555 | 1578 |
| 1556 | 1579 |
| 1557 Handle<JSArray> LiveEdit::CheckAndDropActivations( | 1580 Handle<JSArray> LiveEdit::CheckAndDropActivations( |
| 1558 Handle<JSArray> shared_info_array, bool do_drop) { | 1581 Handle<JSArray> shared_info_array, bool do_drop) { |
| 1559 int len = Smi::cast(shared_info_array->length())->value(); | 1582 int len = Smi::cast(shared_info_array->length())->value(); |
| 1560 | 1583 |
| 1561 Handle<JSArray> result = Factory::NewJSArray(len); | 1584 Handle<JSArray> result = Factory::NewJSArray(len); |
| 1562 | 1585 |
| 1563 // Fill the default values. | 1586 // Fill the default values. |
| 1564 for (int i = 0; i < len; i++) { | 1587 for (int i = 0; i < len; i++) { |
| 1565 SetElement(result, i, | 1588 SetElementNonStrict( |
| 1566 Handle<Smi>(Smi::FromInt(FUNCTION_AVAILABLE_FOR_PATCH))); | 1589 result, |
| 1590 i, |
| 1591 Handle<Smi>(Smi::FromInt(FUNCTION_AVAILABLE_FOR_PATCH))); |
| 1567 } | 1592 } |
| 1568 | 1593 |
| 1569 | 1594 |
| 1570 // First check inactive threads. Fail if some functions are blocked there. | 1595 // First check inactive threads. Fail if some functions are blocked there. |
| 1571 InactiveThreadActivationsChecker inactive_threads_checker(shared_info_array, | 1596 InactiveThreadActivationsChecker inactive_threads_checker(shared_info_array, |
| 1572 result); | 1597 result); |
| 1573 ThreadManager::IterateArchivedThreads(&inactive_threads_checker); | 1598 ThreadManager::IterateArchivedThreads(&inactive_threads_checker); |
| 1574 if (inactive_threads_checker.HasBlockedFunctions()) { | 1599 if (inactive_threads_checker.HasBlockedFunctions()) { |
| 1575 return result; | 1600 return result; |
| 1576 } | 1601 } |
| 1577 | 1602 |
| 1578 // Try to drop activations from the current stack. | 1603 // Try to drop activations from the current stack. |
| 1579 const char* error_message = | 1604 const char* error_message = |
| 1580 DropActivationsInActiveThread(shared_info_array, result, do_drop); | 1605 DropActivationsInActiveThread(shared_info_array, result, do_drop); |
| 1581 if (error_message != NULL) { | 1606 if (error_message != NULL) { |
| 1582 // Add error message as an array extra element. | 1607 // Add error message as an array extra element. |
| 1583 Vector<const char> vector_message(error_message, StrLength(error_message)); | 1608 Vector<const char> vector_message(error_message, StrLength(error_message)); |
| 1584 Handle<String> str = Factory::NewStringFromAscii(vector_message); | 1609 Handle<String> str = Factory::NewStringFromAscii(vector_message); |
| 1585 SetElement(result, len, str); | 1610 SetElementNonStrict(result, len, str); |
| 1586 } | 1611 } |
| 1587 return result; | 1612 return result; |
| 1588 } | 1613 } |
| 1589 | 1614 |
| 1590 | 1615 |
| 1591 LiveEditFunctionTracker::LiveEditFunctionTracker(FunctionLiteral* fun) { | 1616 LiveEditFunctionTracker::LiveEditFunctionTracker(FunctionLiteral* fun) { |
| 1592 if (active_function_info_listener != NULL) { | 1617 if (active_function_info_listener != NULL) { |
| 1593 active_function_info_listener->FunctionStarted(fun); | 1618 active_function_info_listener->FunctionStarted(fun); |
| 1594 } | 1619 } |
| 1595 } | 1620 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1643 | 1668 |
| 1644 bool LiveEditFunctionTracker::IsActive() { | 1669 bool LiveEditFunctionTracker::IsActive() { |
| 1645 return false; | 1670 return false; |
| 1646 } | 1671 } |
| 1647 | 1672 |
| 1648 #endif // ENABLE_DEBUGGER_SUPPORT | 1673 #endif // ENABLE_DEBUGGER_SUPPORT |
| 1649 | 1674 |
| 1650 | 1675 |
| 1651 | 1676 |
| 1652 } } // namespace v8::internal | 1677 } } // namespace v8::internal |
| OLD | NEW |