| 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_, current_size_, Handle<Object>(Smi::FromInt(char_pos1))); | 289 SetElement(array_, |
| 290 SetElement(array_, current_size_ + 1, | 290 current_size_, |
| 291 Handle<Object>(Smi::FromInt(char_pos1 + char_len1))); | 291 Handle<Object>(Smi::FromInt(char_pos1)), |
| 292 SetElement(array_, current_size_ + 2, | 292 kNonStrictMode); |
| 293 Handle<Object>(Smi::FromInt(char_pos2 + char_len2))); | 293 SetElement(array_, |
| 294 current_size_ + 1, |
| 295 Handle<Object>(Smi::FromInt(char_pos1 + char_len1)), |
| 296 kNonStrictMode); |
| 297 SetElement(array_, |
| 298 current_size_ + 2, |
| 299 Handle<Object>(Smi::FromInt(char_pos2 + char_len2)), |
| 300 kNonStrictMode); |
| 294 current_size_ += 3; | 301 current_size_ += 3; |
| 295 } | 302 } |
| 296 | 303 |
| 297 private: | 304 private: |
| 298 Handle<JSArray> array_; | 305 Handle<JSArray> array_; |
| 299 int current_size_; | 306 int current_size_; |
| 300 }; | 307 }; |
| 301 | 308 |
| 302 | 309 |
| 303 // Represents 2 strings as 2 arrays of tokens. | 310 // Represents 2 strings as 2 arrays of tokens. |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 return S(array_handle); | 550 return S(array_handle); |
| 544 } | 551 } |
| 545 explicit JSArrayBasedStruct(Handle<JSArray> array) : array_(array) { | 552 explicit JSArrayBasedStruct(Handle<JSArray> array) : array_(array) { |
| 546 } | 553 } |
| 547 Handle<JSArray> GetJSArray() { | 554 Handle<JSArray> GetJSArray() { |
| 548 return array_; | 555 return array_; |
| 549 } | 556 } |
| 550 | 557 |
| 551 protected: | 558 protected: |
| 552 void SetField(int field_position, Handle<Object> value) { | 559 void SetField(int field_position, Handle<Object> value) { |
| 553 SetElement(array_, field_position, value); | 560 SetElement(array_, field_position, value, kNonStrictMode); |
| 554 } | 561 } |
| 555 void SetSmiValueField(int field_position, int value) { | 562 void SetSmiValueField(int field_position, int value) { |
| 556 SetElement(array_, field_position, Handle<Smi>(Smi::FromInt(value))); | 563 SetElement(array_, |
| 564 field_position, |
| 565 Handle<Smi>(Smi::FromInt(value)), |
| 566 kNonStrictMode); |
| 557 } | 567 } |
| 558 Object* GetField(int field_position) { | 568 Object* GetField(int field_position) { |
| 559 return array_->GetElementNoExceptionThrown(field_position); | 569 return array_->GetElementNoExceptionThrown(field_position); |
| 560 } | 570 } |
| 561 int GetSmiValueField(int field_position) { | 571 int GetSmiValueField(int field_position) { |
| 562 Object* res = GetField(field_position); | 572 Object* res = GetField(field_position); |
| 563 return Smi::cast(res)->value(); | 573 return Smi::cast(res)->value(); |
| 564 } | 574 } |
| 565 | 575 |
| 566 private: | 576 private: |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 result_ = FACTORY->NewJSArray(10); | 695 result_ = FACTORY->NewJSArray(10); |
| 686 } | 696 } |
| 687 | 697 |
| 688 void FunctionStarted(FunctionLiteral* fun) { | 698 void FunctionStarted(FunctionLiteral* fun) { |
| 689 HandleScope scope; | 699 HandleScope scope; |
| 690 FunctionInfoWrapper info = FunctionInfoWrapper::Create(); | 700 FunctionInfoWrapper info = FunctionInfoWrapper::Create(); |
| 691 info.SetInitialProperties(fun->name(), fun->start_position(), | 701 info.SetInitialProperties(fun->name(), fun->start_position(), |
| 692 fun->end_position(), fun->num_parameters(), | 702 fun->end_position(), fun->num_parameters(), |
| 693 current_parent_index_); | 703 current_parent_index_); |
| 694 current_parent_index_ = len_; | 704 current_parent_index_ = len_; |
| 695 SetElement(result_, len_, info.GetJSArray()); | 705 SetElement(result_, len_, info.GetJSArray(), kNonStrictMode); |
| 696 len_++; | 706 len_++; |
| 697 } | 707 } |
| 698 | 708 |
| 699 void FunctionDone() { | 709 void FunctionDone() { |
| 700 HandleScope scope; | 710 HandleScope scope; |
| 701 FunctionInfoWrapper info = | 711 FunctionInfoWrapper info = |
| 702 FunctionInfoWrapper::cast( | 712 FunctionInfoWrapper::cast( |
| 703 result_->GetElementNoExceptionThrown(current_parent_index_)); | 713 result_->GetElementNoExceptionThrown(current_parent_index_)); |
| 704 current_parent_index_ = info.GetParentIndex(); | 714 current_parent_index_ = info.GetParentIndex(); |
| 705 } | 715 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 for (int k = 1; k < j; k++) { | 775 for (int k = 1; k < j; k++) { |
| 766 int l = k; | 776 int l = k; |
| 767 for (int m = k + 1; m < j; m++) { | 777 for (int m = k + 1; m < j; m++) { |
| 768 if (list[l]->AsSlot()->index() > list[m]->AsSlot()->index()) { | 778 if (list[l]->AsSlot()->index() > list[m]->AsSlot()->index()) { |
| 769 l = m; | 779 l = m; |
| 770 } | 780 } |
| 771 } | 781 } |
| 772 list[k] = list[l]; | 782 list[k] = list[l]; |
| 773 } | 783 } |
| 774 for (int i = 0; i < j; i++) { | 784 for (int i = 0; i < j; i++) { |
| 775 SetElement(scope_info_list, scope_info_length, list[i]->name()); | 785 SetElement(scope_info_list, scope_info_length, |
| 786 list[i]->name(), kNonStrictMode); |
| 776 scope_info_length++; | 787 scope_info_length++; |
| 777 SetElement(scope_info_list, scope_info_length, | 788 SetElement(scope_info_list, scope_info_length, |
| 778 Handle<Smi>(Smi::FromInt(list[i]->AsSlot()->index()))); | 789 Handle<Smi>(Smi::FromInt(list[i]->AsSlot()->index())), |
| 790 kNonStrictMode); |
| 779 scope_info_length++; | 791 scope_info_length++; |
| 780 } | 792 } |
| 781 SetElement(scope_info_list, scope_info_length, | 793 SetElement(scope_info_list, scope_info_length, |
| 782 Handle<Object>(HEAP->null_value())); | 794 Handle<Object>(HEAP->null_value()), kNonStrictMode); |
| 783 scope_info_length++; | 795 scope_info_length++; |
| 784 | 796 |
| 785 outer_scope = outer_scope->outer_scope(); | 797 outer_scope = outer_scope->outer_scope(); |
| 786 } while (outer_scope != NULL); | 798 } while (outer_scope != NULL); |
| 787 | 799 |
| 788 return *scope_info_list; | 800 return *scope_info_list; |
| 789 } | 801 } |
| 790 | 802 |
| 791 Handle<JSArray> result_; | 803 Handle<JSArray> result_; |
| 792 int len_; | 804 int len_; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 814 void LiveEdit::WrapSharedFunctionInfos(Handle<JSArray> array) { | 826 void LiveEdit::WrapSharedFunctionInfos(Handle<JSArray> array) { |
| 815 HandleScope scope; | 827 HandleScope scope; |
| 816 int len = Smi::cast(array->length())->value(); | 828 int len = Smi::cast(array->length())->value(); |
| 817 for (int i = 0; i < len; i++) { | 829 for (int i = 0; i < len; i++) { |
| 818 Handle<SharedFunctionInfo> info( | 830 Handle<SharedFunctionInfo> info( |
| 819 SharedFunctionInfo::cast(array->GetElementNoExceptionThrown(i))); | 831 SharedFunctionInfo::cast(array->GetElementNoExceptionThrown(i))); |
| 820 SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create(); | 832 SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create(); |
| 821 Handle<String> name_handle(String::cast(info->name())); | 833 Handle<String> name_handle(String::cast(info->name())); |
| 822 info_wrapper.SetProperties(name_handle, info->start_position(), | 834 info_wrapper.SetProperties(name_handle, info->start_position(), |
| 823 info->end_position(), info); | 835 info->end_position(), info); |
| 824 SetElement(array, i, info_wrapper.GetJSArray()); | 836 SetElement(array, i, info_wrapper.GetJSArray(), kNonStrictMode); |
| 825 } | 837 } |
| 826 } | 838 } |
| 827 | 839 |
| 828 | 840 |
| 829 // Visitor that collects all references to a particular code object, | 841 // Visitor that collects all references to a particular code object, |
| 830 // including "CODE_TARGET" references in other code objects. | 842 // including "CODE_TARGET" references in other code objects. |
| 831 // It works in context of ZoneScope. | 843 // It works in context of ZoneScope. |
| 832 class ReferenceCollectorVisitor : public ObjectVisitor { | 844 class ReferenceCollectorVisitor : public ObjectVisitor { |
| 833 public: | 845 public: |
| 834 explicit ReferenceCollectorVisitor(Code* original) | 846 explicit ReferenceCollectorVisitor(Code* original) |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1314 JSFunction::cast(JavaScriptFrame::cast(frame)->function())); | 1326 JSFunction::cast(JavaScriptFrame::cast(frame)->function())); |
| 1315 | 1327 |
| 1316 int len = Smi::cast(shared_info_array->length())->value(); | 1328 int len = Smi::cast(shared_info_array->length())->value(); |
| 1317 for (int i = 0; i < len; i++) { | 1329 for (int i = 0; i < len; i++) { |
| 1318 JSValue* wrapper = | 1330 JSValue* wrapper = |
| 1319 JSValue::cast(shared_info_array->GetElementNoExceptionThrown(i)); | 1331 JSValue::cast(shared_info_array->GetElementNoExceptionThrown(i)); |
| 1320 Handle<SharedFunctionInfo> shared( | 1332 Handle<SharedFunctionInfo> shared( |
| 1321 SharedFunctionInfo::cast(wrapper->value())); | 1333 SharedFunctionInfo::cast(wrapper->value())); |
| 1322 | 1334 |
| 1323 if (function->shared() == *shared || IsInlined(*function, *shared)) { | 1335 if (function->shared() == *shared || IsInlined(*function, *shared)) { |
| 1324 SetElement(result, i, Handle<Smi>(Smi::FromInt(status))); | 1336 SetElement(result, i, Handle<Smi>(Smi::FromInt(status)), kNonStrictMode); |
| 1325 return true; | 1337 return true; |
| 1326 } | 1338 } |
| 1327 } | 1339 } |
| 1328 return false; | 1340 return false; |
| 1329 } | 1341 } |
| 1330 | 1342 |
| 1331 | 1343 |
| 1332 // Iterates over handler chain and removes all elements that are inside | 1344 // Iterates over handler chain and removes all elements that are inside |
| 1333 // frames being dropped. | 1345 // frames being dropped. |
| 1334 static bool FixTryCatchHandler(StackFrame* top_frame, | 1346 static bool FixTryCatchHandler(StackFrame* top_frame, |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1524 } | 1536 } |
| 1525 debug->FramesHaveBeenDropped(new_id, drop_mode, | 1537 debug->FramesHaveBeenDropped(new_id, drop_mode, |
| 1526 restarter_frame_function_pointer); | 1538 restarter_frame_function_pointer); |
| 1527 | 1539 |
| 1528 // Replace "blocked on active" with "replaced on active" status. | 1540 // Replace "blocked on active" with "replaced on active" status. |
| 1529 for (int i = 0; i < array_len; i++) { | 1541 for (int i = 0; i < array_len; i++) { |
| 1530 if (result->GetElement(i) == | 1542 if (result->GetElement(i) == |
| 1531 Smi::FromInt(LiveEdit::FUNCTION_BLOCKED_ON_ACTIVE_STACK)) { | 1543 Smi::FromInt(LiveEdit::FUNCTION_BLOCKED_ON_ACTIVE_STACK)) { |
| 1532 Handle<Object> replaced( | 1544 Handle<Object> replaced( |
| 1533 Smi::FromInt(LiveEdit::FUNCTION_REPLACED_ON_ACTIVE_STACK)); | 1545 Smi::FromInt(LiveEdit::FUNCTION_REPLACED_ON_ACTIVE_STACK)); |
| 1534 SetElement(result, i, replaced); | 1546 SetElement(result, i, replaced, kNonStrictMode); |
| 1535 } | 1547 } |
| 1536 } | 1548 } |
| 1537 return NULL; | 1549 return NULL; |
| 1538 } | 1550 } |
| 1539 | 1551 |
| 1540 | 1552 |
| 1541 class InactiveThreadActivationsChecker : public ThreadVisitor { | 1553 class InactiveThreadActivationsChecker : public ThreadVisitor { |
| 1542 public: | 1554 public: |
| 1543 InactiveThreadActivationsChecker(Handle<JSArray> shared_info_array, | 1555 InactiveThreadActivationsChecker(Handle<JSArray> shared_info_array, |
| 1544 Handle<JSArray> result) | 1556 Handle<JSArray> result) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1565 | 1577 |
| 1566 Handle<JSArray> LiveEdit::CheckAndDropActivations( | 1578 Handle<JSArray> LiveEdit::CheckAndDropActivations( |
| 1567 Handle<JSArray> shared_info_array, bool do_drop) { | 1579 Handle<JSArray> shared_info_array, bool do_drop) { |
| 1568 int len = Smi::cast(shared_info_array->length())->value(); | 1580 int len = Smi::cast(shared_info_array->length())->value(); |
| 1569 | 1581 |
| 1570 Handle<JSArray> result = FACTORY->NewJSArray(len); | 1582 Handle<JSArray> result = FACTORY->NewJSArray(len); |
| 1571 | 1583 |
| 1572 // Fill the default values. | 1584 // Fill the default values. |
| 1573 for (int i = 0; i < len; i++) { | 1585 for (int i = 0; i < len; i++) { |
| 1574 SetElement(result, i, | 1586 SetElement(result, i, |
| 1575 Handle<Smi>(Smi::FromInt(FUNCTION_AVAILABLE_FOR_PATCH))); | 1587 Handle<Smi>(Smi::FromInt(FUNCTION_AVAILABLE_FOR_PATCH)), |
| 1588 kNonStrictMode); |
| 1576 } | 1589 } |
| 1577 | 1590 |
| 1578 | 1591 |
| 1579 // First check inactive threads. Fail if some functions are blocked there. | 1592 // First check inactive threads. Fail if some functions are blocked there. |
| 1580 InactiveThreadActivationsChecker inactive_threads_checker(shared_info_array, | 1593 InactiveThreadActivationsChecker inactive_threads_checker(shared_info_array, |
| 1581 result); | 1594 result); |
| 1582 Isolate::Current()->thread_manager()->IterateArchivedThreads( | 1595 Isolate::Current()->thread_manager()->IterateArchivedThreads( |
| 1583 &inactive_threads_checker); | 1596 &inactive_threads_checker); |
| 1584 if (inactive_threads_checker.HasBlockedFunctions()) { | 1597 if (inactive_threads_checker.HasBlockedFunctions()) { |
| 1585 return result; | 1598 return result; |
| 1586 } | 1599 } |
| 1587 | 1600 |
| 1588 // Try to drop activations from the current stack. | 1601 // Try to drop activations from the current stack. |
| 1589 const char* error_message = | 1602 const char* error_message = |
| 1590 DropActivationsInActiveThread(shared_info_array, result, do_drop); | 1603 DropActivationsInActiveThread(shared_info_array, result, do_drop); |
| 1591 if (error_message != NULL) { | 1604 if (error_message != NULL) { |
| 1592 // Add error message as an array extra element. | 1605 // Add error message as an array extra element. |
| 1593 Vector<const char> vector_message(error_message, StrLength(error_message)); | 1606 Vector<const char> vector_message(error_message, StrLength(error_message)); |
| 1594 Handle<String> str = FACTORY->NewStringFromAscii(vector_message); | 1607 Handle<String> str = FACTORY->NewStringFromAscii(vector_message); |
| 1595 SetElement(result, len, str); | 1608 SetElement(result, len, str, kNonStrictMode); |
| 1596 } | 1609 } |
| 1597 return result; | 1610 return result; |
| 1598 } | 1611 } |
| 1599 | 1612 |
| 1600 | 1613 |
| 1601 LiveEditFunctionTracker::LiveEditFunctionTracker(Isolate* isolate, | 1614 LiveEditFunctionTracker::LiveEditFunctionTracker(Isolate* isolate, |
| 1602 FunctionLiteral* fun) | 1615 FunctionLiteral* fun) |
| 1603 : isolate_(isolate) { | 1616 : isolate_(isolate) { |
| 1604 if (isolate_->active_function_info_listener() != NULL) { | 1617 if (isolate_->active_function_info_listener() != NULL) { |
| 1605 isolate_->active_function_info_listener()->FunctionStarted(fun); | 1618 isolate_->active_function_info_listener()->FunctionStarted(fun); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1656 | 1669 |
| 1657 bool LiveEditFunctionTracker::IsActive() { | 1670 bool LiveEditFunctionTracker::IsActive() { |
| 1658 return false; | 1671 return false; |
| 1659 } | 1672 } |
| 1660 | 1673 |
| 1661 #endif // ENABLE_DEBUGGER_SUPPORT | 1674 #endif // ENABLE_DEBUGGER_SUPPORT |
| 1662 | 1675 |
| 1663 | 1676 |
| 1664 | 1677 |
| 1665 } } // namespace v8::internal | 1678 } } // namespace v8::internal |
| OLD | NEW |