| 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_, | 301 SetElementNonStrict(array_, |
| 290 current_size_, | 302 current_size_, |
| 291 Handle<Object>(Smi::FromInt(char_pos1)), | 303 Handle<Object>(Smi::FromInt(char_pos1))); |
| 292 kNonStrictMode); | 304 SetElementNonStrict(array_, |
| 293 SetElement(array_, | 305 current_size_ + 1, |
| 294 current_size_ + 1, | 306 Handle<Object>(Smi::FromInt(char_pos1 + char_len1))); |
| 295 Handle<Object>(Smi::FromInt(char_pos1 + char_len1)), | 307 SetElementNonStrict(array_, |
| 296 kNonStrictMode); | 308 current_size_ + 2, |
| 297 SetElement(array_, | 309 Handle<Object>(Smi::FromInt(char_pos2 + char_len2))); |
| 298 current_size_ + 2, | |
| 299 Handle<Object>(Smi::FromInt(char_pos2 + char_len2)), | |
| 300 kNonStrictMode); | |
| 301 current_size_ += 3; | 310 current_size_ += 3; |
| 302 } | 311 } |
| 303 | 312 |
| 304 private: | 313 private: |
| 305 Handle<JSArray> array_; | 314 Handle<JSArray> array_; |
| 306 int current_size_; | 315 int current_size_; |
| 307 }; | 316 }; |
| 308 | 317 |
| 309 | 318 |
| 310 // Represents 2 strings as 2 arrays of tokens. | 319 // Represents 2 strings as 2 arrays of tokens. |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 return S(array_handle); | 559 return S(array_handle); |
| 551 } | 560 } |
| 552 explicit JSArrayBasedStruct(Handle<JSArray> array) : array_(array) { | 561 explicit JSArrayBasedStruct(Handle<JSArray> array) : array_(array) { |
| 553 } | 562 } |
| 554 Handle<JSArray> GetJSArray() { | 563 Handle<JSArray> GetJSArray() { |
| 555 return array_; | 564 return array_; |
| 556 } | 565 } |
| 557 | 566 |
| 558 protected: | 567 protected: |
| 559 void SetField(int field_position, Handle<Object> value) { | 568 void SetField(int field_position, Handle<Object> value) { |
| 560 SetElement(array_, field_position, value, kNonStrictMode); | 569 SetElementNonStrict(array_, field_position, value); |
| 561 } | 570 } |
| 562 void SetSmiValueField(int field_position, int value) { | 571 void SetSmiValueField(int field_position, int value) { |
| 563 SetElement(array_, | 572 SetElementNonStrict(array_, |
| 564 field_position, | 573 field_position, |
| 565 Handle<Smi>(Smi::FromInt(value)), | 574 Handle<Smi>(Smi::FromInt(value))); |
| 566 kNonStrictMode); | |
| 567 } | 575 } |
| 568 Object* GetField(int field_position) { | 576 Object* GetField(int field_position) { |
| 569 return array_->GetElementNoExceptionThrown(field_position); | 577 return array_->GetElementNoExceptionThrown(field_position); |
| 570 } | 578 } |
| 571 int GetSmiValueField(int field_position) { | 579 int GetSmiValueField(int field_position) { |
| 572 Object* res = GetField(field_position); | 580 Object* res = GetField(field_position); |
| 573 return Smi::cast(res)->value(); | 581 return Smi::cast(res)->value(); |
| 574 } | 582 } |
| 575 | 583 |
| 576 private: | 584 private: |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 result_ = FACTORY->NewJSArray(10); | 703 result_ = FACTORY->NewJSArray(10); |
| 696 } | 704 } |
| 697 | 705 |
| 698 void FunctionStarted(FunctionLiteral* fun) { | 706 void FunctionStarted(FunctionLiteral* fun) { |
| 699 HandleScope scope; | 707 HandleScope scope; |
| 700 FunctionInfoWrapper info = FunctionInfoWrapper::Create(); | 708 FunctionInfoWrapper info = FunctionInfoWrapper::Create(); |
| 701 info.SetInitialProperties(fun->name(), fun->start_position(), | 709 info.SetInitialProperties(fun->name(), fun->start_position(), |
| 702 fun->end_position(), fun->num_parameters(), | 710 fun->end_position(), fun->num_parameters(), |
| 703 current_parent_index_); | 711 current_parent_index_); |
| 704 current_parent_index_ = len_; | 712 current_parent_index_ = len_; |
| 705 SetElement(result_, len_, info.GetJSArray(), kNonStrictMode); | 713 SetElementNonStrict(result_, len_, info.GetJSArray()); |
| 706 len_++; | 714 len_++; |
| 707 } | 715 } |
| 708 | 716 |
| 709 void FunctionDone() { | 717 void FunctionDone() { |
| 710 HandleScope scope; | 718 HandleScope scope; |
| 711 FunctionInfoWrapper info = | 719 FunctionInfoWrapper info = |
| 712 FunctionInfoWrapper::cast( | 720 FunctionInfoWrapper::cast( |
| 713 result_->GetElementNoExceptionThrown(current_parent_index_)); | 721 result_->GetElementNoExceptionThrown(current_parent_index_)); |
| 714 current_parent_index_ = info.GetParentIndex(); | 722 current_parent_index_ = info.GetParentIndex(); |
| 715 } | 723 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 for (int k = 1; k < j; k++) { | 783 for (int k = 1; k < j; k++) { |
| 776 int l = k; | 784 int l = k; |
| 777 for (int m = k + 1; m < j; m++) { | 785 for (int m = k + 1; m < j; m++) { |
| 778 if (list[l]->AsSlot()->index() > list[m]->AsSlot()->index()) { | 786 if (list[l]->AsSlot()->index() > list[m]->AsSlot()->index()) { |
| 779 l = m; | 787 l = m; |
| 780 } | 788 } |
| 781 } | 789 } |
| 782 list[k] = list[l]; | 790 list[k] = list[l]; |
| 783 } | 791 } |
| 784 for (int i = 0; i < j; i++) { | 792 for (int i = 0; i < j; i++) { |
| 785 SetElement(scope_info_list, scope_info_length, | 793 SetElementNonStrict(scope_info_list, |
| 786 list[i]->name(), kNonStrictMode); | 794 scope_info_length, |
| 795 list[i]->name()); |
| 787 scope_info_length++; | 796 scope_info_length++; |
| 788 SetElement(scope_info_list, scope_info_length, | 797 SetElementNonStrict( |
| 789 Handle<Smi>(Smi::FromInt(list[i]->AsSlot()->index())), | 798 scope_info_list, |
| 790 kNonStrictMode); | 799 scope_info_length, |
| 800 Handle<Smi>(Smi::FromInt(list[i]->AsSlot()->index()))); |
| 791 scope_info_length++; | 801 scope_info_length++; |
| 792 } | 802 } |
| 793 SetElement(scope_info_list, scope_info_length, | 803 SetElementNonStrict(scope_info_list, |
| 794 Handle<Object>(HEAP->null_value()), kNonStrictMode); | 804 scope_info_length, |
| 805 Handle<Object>(HEAP->null_value())); |
| 795 scope_info_length++; | 806 scope_info_length++; |
| 796 | 807 |
| 797 outer_scope = outer_scope->outer_scope(); | 808 outer_scope = outer_scope->outer_scope(); |
| 798 } while (outer_scope != NULL); | 809 } while (outer_scope != NULL); |
| 799 | 810 |
| 800 return *scope_info_list; | 811 return *scope_info_list; |
| 801 } | 812 } |
| 802 | 813 |
| 803 Handle<JSArray> result_; | 814 Handle<JSArray> result_; |
| 804 int len_; | 815 int len_; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 826 void LiveEdit::WrapSharedFunctionInfos(Handle<JSArray> array) { | 837 void LiveEdit::WrapSharedFunctionInfos(Handle<JSArray> array) { |
| 827 HandleScope scope; | 838 HandleScope scope; |
| 828 int len = Smi::cast(array->length())->value(); | 839 int len = Smi::cast(array->length())->value(); |
| 829 for (int i = 0; i < len; i++) { | 840 for (int i = 0; i < len; i++) { |
| 830 Handle<SharedFunctionInfo> info( | 841 Handle<SharedFunctionInfo> info( |
| 831 SharedFunctionInfo::cast(array->GetElementNoExceptionThrown(i))); | 842 SharedFunctionInfo::cast(array->GetElementNoExceptionThrown(i))); |
| 832 SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create(); | 843 SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create(); |
| 833 Handle<String> name_handle(String::cast(info->name())); | 844 Handle<String> name_handle(String::cast(info->name())); |
| 834 info_wrapper.SetProperties(name_handle, info->start_position(), | 845 info_wrapper.SetProperties(name_handle, info->start_position(), |
| 835 info->end_position(), info); | 846 info->end_position(), info); |
| 836 SetElement(array, i, info_wrapper.GetJSArray(), kNonStrictMode); | 847 SetElementNonStrict(array, i, info_wrapper.GetJSArray()); |
| 837 } | 848 } |
| 838 } | 849 } |
| 839 | 850 |
| 840 | 851 |
| 841 // Visitor that collects all references to a particular code object, | 852 // Visitor that collects all references to a particular code object, |
| 842 // including "CODE_TARGET" references in other code objects. | 853 // including "CODE_TARGET" references in other code objects. |
| 843 // It works in context of ZoneScope. | 854 // It works in context of ZoneScope. |
| 844 class ReferenceCollectorVisitor : public ObjectVisitor { | 855 class ReferenceCollectorVisitor : public ObjectVisitor { |
| 845 public: | 856 public: |
| 846 explicit ReferenceCollectorVisitor(Code* original) | 857 explicit ReferenceCollectorVisitor(Code* original) |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1326 JSFunction::cast(JavaScriptFrame::cast(frame)->function())); | 1337 JSFunction::cast(JavaScriptFrame::cast(frame)->function())); |
| 1327 | 1338 |
| 1328 int len = Smi::cast(shared_info_array->length())->value(); | 1339 int len = Smi::cast(shared_info_array->length())->value(); |
| 1329 for (int i = 0; i < len; i++) { | 1340 for (int i = 0; i < len; i++) { |
| 1330 JSValue* wrapper = | 1341 JSValue* wrapper = |
| 1331 JSValue::cast(shared_info_array->GetElementNoExceptionThrown(i)); | 1342 JSValue::cast(shared_info_array->GetElementNoExceptionThrown(i)); |
| 1332 Handle<SharedFunctionInfo> shared( | 1343 Handle<SharedFunctionInfo> shared( |
| 1333 SharedFunctionInfo::cast(wrapper->value())); | 1344 SharedFunctionInfo::cast(wrapper->value())); |
| 1334 | 1345 |
| 1335 if (function->shared() == *shared || IsInlined(*function, *shared)) { | 1346 if (function->shared() == *shared || IsInlined(*function, *shared)) { |
| 1336 SetElement(result, i, Handle<Smi>(Smi::FromInt(status)), kNonStrictMode); | 1347 SetElementNonStrict(result, i, Handle<Smi>(Smi::FromInt(status))); |
| 1337 return true; | 1348 return true; |
| 1338 } | 1349 } |
| 1339 } | 1350 } |
| 1340 return false; | 1351 return false; |
| 1341 } | 1352 } |
| 1342 | 1353 |
| 1343 | 1354 |
| 1344 // Iterates over handler chain and removes all elements that are inside | 1355 // Iterates over handler chain and removes all elements that are inside |
| 1345 // frames being dropped. | 1356 // frames being dropped. |
| 1346 static bool FixTryCatchHandler(StackFrame* top_frame, | 1357 static bool FixTryCatchHandler(StackFrame* top_frame, |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1536 } | 1547 } |
| 1537 debug->FramesHaveBeenDropped(new_id, drop_mode, | 1548 debug->FramesHaveBeenDropped(new_id, drop_mode, |
| 1538 restarter_frame_function_pointer); | 1549 restarter_frame_function_pointer); |
| 1539 | 1550 |
| 1540 // Replace "blocked on active" with "replaced on active" status. | 1551 // Replace "blocked on active" with "replaced on active" status. |
| 1541 for (int i = 0; i < array_len; i++) { | 1552 for (int i = 0; i < array_len; i++) { |
| 1542 if (result->GetElement(i) == | 1553 if (result->GetElement(i) == |
| 1543 Smi::FromInt(LiveEdit::FUNCTION_BLOCKED_ON_ACTIVE_STACK)) { | 1554 Smi::FromInt(LiveEdit::FUNCTION_BLOCKED_ON_ACTIVE_STACK)) { |
| 1544 Handle<Object> replaced( | 1555 Handle<Object> replaced( |
| 1545 Smi::FromInt(LiveEdit::FUNCTION_REPLACED_ON_ACTIVE_STACK)); | 1556 Smi::FromInt(LiveEdit::FUNCTION_REPLACED_ON_ACTIVE_STACK)); |
| 1546 SetElement(result, i, replaced, kNonStrictMode); | 1557 SetElementNonStrict(result, i, replaced); |
| 1547 } | 1558 } |
| 1548 } | 1559 } |
| 1549 return NULL; | 1560 return NULL; |
| 1550 } | 1561 } |
| 1551 | 1562 |
| 1552 | 1563 |
| 1553 class InactiveThreadActivationsChecker : public ThreadVisitor { | 1564 class InactiveThreadActivationsChecker : public ThreadVisitor { |
| 1554 public: | 1565 public: |
| 1555 InactiveThreadActivationsChecker(Handle<JSArray> shared_info_array, | 1566 InactiveThreadActivationsChecker(Handle<JSArray> shared_info_array, |
| 1556 Handle<JSArray> result) | 1567 Handle<JSArray> result) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1576 | 1587 |
| 1577 | 1588 |
| 1578 Handle<JSArray> LiveEdit::CheckAndDropActivations( | 1589 Handle<JSArray> LiveEdit::CheckAndDropActivations( |
| 1579 Handle<JSArray> shared_info_array, bool do_drop) { | 1590 Handle<JSArray> shared_info_array, bool do_drop) { |
| 1580 int len = Smi::cast(shared_info_array->length())->value(); | 1591 int len = Smi::cast(shared_info_array->length())->value(); |
| 1581 | 1592 |
| 1582 Handle<JSArray> result = FACTORY->NewJSArray(len); | 1593 Handle<JSArray> result = FACTORY->NewJSArray(len); |
| 1583 | 1594 |
| 1584 // Fill the default values. | 1595 // Fill the default values. |
| 1585 for (int i = 0; i < len; i++) { | 1596 for (int i = 0; i < len; i++) { |
| 1586 SetElement(result, i, | 1597 SetElementNonStrict( |
| 1587 Handle<Smi>(Smi::FromInt(FUNCTION_AVAILABLE_FOR_PATCH)), | 1598 result, |
| 1588 kNonStrictMode); | 1599 i, |
| 1600 Handle<Smi>(Smi::FromInt(FUNCTION_AVAILABLE_FOR_PATCH))); |
| 1589 } | 1601 } |
| 1590 | 1602 |
| 1591 | 1603 |
| 1592 // First check inactive threads. Fail if some functions are blocked there. | 1604 // First check inactive threads. Fail if some functions are blocked there. |
| 1593 InactiveThreadActivationsChecker inactive_threads_checker(shared_info_array, | 1605 InactiveThreadActivationsChecker inactive_threads_checker(shared_info_array, |
| 1594 result); | 1606 result); |
| 1595 Isolate::Current()->thread_manager()->IterateArchivedThreads( | 1607 Isolate::Current()->thread_manager()->IterateArchivedThreads( |
| 1596 &inactive_threads_checker); | 1608 &inactive_threads_checker); |
| 1597 if (inactive_threads_checker.HasBlockedFunctions()) { | 1609 if (inactive_threads_checker.HasBlockedFunctions()) { |
| 1598 return result; | 1610 return result; |
| 1599 } | 1611 } |
| 1600 | 1612 |
| 1601 // Try to drop activations from the current stack. | 1613 // Try to drop activations from the current stack. |
| 1602 const char* error_message = | 1614 const char* error_message = |
| 1603 DropActivationsInActiveThread(shared_info_array, result, do_drop); | 1615 DropActivationsInActiveThread(shared_info_array, result, do_drop); |
| 1604 if (error_message != NULL) { | 1616 if (error_message != NULL) { |
| 1605 // Add error message as an array extra element. | 1617 // Add error message as an array extra element. |
| 1606 Vector<const char> vector_message(error_message, StrLength(error_message)); | 1618 Vector<const char> vector_message(error_message, StrLength(error_message)); |
| 1607 Handle<String> str = FACTORY->NewStringFromAscii(vector_message); | 1619 Handle<String> str = FACTORY->NewStringFromAscii(vector_message); |
| 1608 SetElement(result, len, str, kNonStrictMode); | 1620 SetElementNonStrict(result, len, str); |
| 1609 } | 1621 } |
| 1610 return result; | 1622 return result; |
| 1611 } | 1623 } |
| 1612 | 1624 |
| 1613 | 1625 |
| 1614 LiveEditFunctionTracker::LiveEditFunctionTracker(Isolate* isolate, | 1626 LiveEditFunctionTracker::LiveEditFunctionTracker(Isolate* isolate, |
| 1615 FunctionLiteral* fun) | 1627 FunctionLiteral* fun) |
| 1616 : isolate_(isolate) { | 1628 : isolate_(isolate) { |
| 1617 if (isolate_->active_function_info_listener() != NULL) { | 1629 if (isolate_->active_function_info_listener() != NULL) { |
| 1618 isolate_->active_function_info_listener()->FunctionStarted(fun); | 1630 isolate_->active_function_info_listener()->FunctionStarted(fun); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1669 | 1681 |
| 1670 bool LiveEditFunctionTracker::IsActive() { | 1682 bool LiveEditFunctionTracker::IsActive() { |
| 1671 return false; | 1683 return false; |
| 1672 } | 1684 } |
| 1673 | 1685 |
| 1674 #endif // ENABLE_DEBUGGER_SUPPORT | 1686 #endif // ENABLE_DEBUGGER_SUPPORT |
| 1675 | 1687 |
| 1676 | 1688 |
| 1677 | 1689 |
| 1678 } } // namespace v8::internal | 1690 } } // namespace v8::internal |
| OLD | NEW |