| 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 return S(array_handle); | 545 return S(array_handle); |
| 539 } | 546 } |
| 540 explicit JSArrayBasedStruct(Handle<JSArray> array) : array_(array) { | 547 explicit JSArrayBasedStruct(Handle<JSArray> array) : array_(array) { |
| 541 } | 548 } |
| 542 Handle<JSArray> GetJSArray() { | 549 Handle<JSArray> GetJSArray() { |
| 543 return array_; | 550 return array_; |
| 544 } | 551 } |
| 545 | 552 |
| 546 protected: | 553 protected: |
| 547 void SetField(int field_position, Handle<Object> value) { | 554 void SetField(int field_position, Handle<Object> value) { |
| 548 SetElement(array_, field_position, value); | 555 SetElement(array_, field_position, value, kNonStrictMode); |
| 549 } | 556 } |
| 550 void SetSmiValueField(int field_position, int value) { | 557 void SetSmiValueField(int field_position, int value) { |
| 551 SetElement(array_, field_position, Handle<Smi>(Smi::FromInt(value))); | 558 SetElement(array_, |
| 559 field_position, |
| 560 Handle<Smi>(Smi::FromInt(value)), |
| 561 kNonStrictMode); |
| 552 } | 562 } |
| 553 Object* GetField(int field_position) { | 563 Object* GetField(int field_position) { |
| 554 return array_->GetElementNoExceptionThrown(field_position); | 564 return array_->GetElementNoExceptionThrown(field_position); |
| 555 } | 565 } |
| 556 int GetSmiValueField(int field_position) { | 566 int GetSmiValueField(int field_position) { |
| 557 Object* res = GetField(field_position); | 567 Object* res = GetField(field_position); |
| 558 return Smi::cast(res)->value(); | 568 return Smi::cast(res)->value(); |
| 559 } | 569 } |
| 560 | 570 |
| 561 private: | 571 private: |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 result_ = Factory::NewJSArray(10); | 690 result_ = Factory::NewJSArray(10); |
| 681 } | 691 } |
| 682 | 692 |
| 683 void FunctionStarted(FunctionLiteral* fun) { | 693 void FunctionStarted(FunctionLiteral* fun) { |
| 684 HandleScope scope; | 694 HandleScope scope; |
| 685 FunctionInfoWrapper info = FunctionInfoWrapper::Create(); | 695 FunctionInfoWrapper info = FunctionInfoWrapper::Create(); |
| 686 info.SetInitialProperties(fun->name(), fun->start_position(), | 696 info.SetInitialProperties(fun->name(), fun->start_position(), |
| 687 fun->end_position(), fun->num_parameters(), | 697 fun->end_position(), fun->num_parameters(), |
| 688 current_parent_index_); | 698 current_parent_index_); |
| 689 current_parent_index_ = len_; | 699 current_parent_index_ = len_; |
| 690 SetElement(result_, len_, info.GetJSArray()); | 700 SetElement(result_, len_, info.GetJSArray(), kNonStrictMode); |
| 691 len_++; | 701 len_++; |
| 692 } | 702 } |
| 693 | 703 |
| 694 void FunctionDone() { | 704 void FunctionDone() { |
| 695 HandleScope scope; | 705 HandleScope scope; |
| 696 FunctionInfoWrapper info = | 706 FunctionInfoWrapper info = |
| 697 FunctionInfoWrapper::cast( | 707 FunctionInfoWrapper::cast( |
| 698 result_->GetElementNoExceptionThrown(current_parent_index_)); | 708 result_->GetElementNoExceptionThrown(current_parent_index_)); |
| 699 current_parent_index_ = info.GetParentIndex(); | 709 current_parent_index_ = info.GetParentIndex(); |
| 700 } | 710 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 for (int k = 1; k < j; k++) { | 770 for (int k = 1; k < j; k++) { |
| 761 int l = k; | 771 int l = k; |
| 762 for (int m = k + 1; m < j; m++) { | 772 for (int m = k + 1; m < j; m++) { |
| 763 if (list[l]->AsSlot()->index() > list[m]->AsSlot()->index()) { | 773 if (list[l]->AsSlot()->index() > list[m]->AsSlot()->index()) { |
| 764 l = m; | 774 l = m; |
| 765 } | 775 } |
| 766 } | 776 } |
| 767 list[k] = list[l]; | 777 list[k] = list[l]; |
| 768 } | 778 } |
| 769 for (int i = 0; i < j; i++) { | 779 for (int i = 0; i < j; i++) { |
| 770 SetElement(scope_info_list, scope_info_length, list[i]->name()); | 780 SetElement(scope_info_list, scope_info_length, |
| 781 list[i]->name(), kNonStrictMode); |
| 771 scope_info_length++; | 782 scope_info_length++; |
| 772 SetElement(scope_info_list, scope_info_length, | 783 SetElement(scope_info_list, scope_info_length, |
| 773 Handle<Smi>(Smi::FromInt(list[i]->AsSlot()->index()))); | 784 Handle<Smi>(Smi::FromInt(list[i]->AsSlot()->index())), |
| 785 kNonStrictMode); |
| 774 scope_info_length++; | 786 scope_info_length++; |
| 775 } | 787 } |
| 776 SetElement(scope_info_list, scope_info_length, | 788 SetElement(scope_info_list, scope_info_length, |
| 777 Handle<Object>(Heap::null_value())); | 789 Handle<Object>(Heap::null_value()), kNonStrictMode); |
| 778 scope_info_length++; | 790 scope_info_length++; |
| 779 | 791 |
| 780 outer_scope = outer_scope->outer_scope(); | 792 outer_scope = outer_scope->outer_scope(); |
| 781 } while (outer_scope != NULL); | 793 } while (outer_scope != NULL); |
| 782 | 794 |
| 783 return *scope_info_list; | 795 return *scope_info_list; |
| 784 } | 796 } |
| 785 | 797 |
| 786 Handle<JSArray> result_; | 798 Handle<JSArray> result_; |
| 787 int len_; | 799 int len_; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 810 void LiveEdit::WrapSharedFunctionInfos(Handle<JSArray> array) { | 822 void LiveEdit::WrapSharedFunctionInfos(Handle<JSArray> array) { |
| 811 HandleScope scope; | 823 HandleScope scope; |
| 812 int len = Smi::cast(array->length())->value(); | 824 int len = Smi::cast(array->length())->value(); |
| 813 for (int i = 0; i < len; i++) { | 825 for (int i = 0; i < len; i++) { |
| 814 Handle<SharedFunctionInfo> info( | 826 Handle<SharedFunctionInfo> info( |
| 815 SharedFunctionInfo::cast(array->GetElementNoExceptionThrown(i))); | 827 SharedFunctionInfo::cast(array->GetElementNoExceptionThrown(i))); |
| 816 SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create(); | 828 SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create(); |
| 817 Handle<String> name_handle(String::cast(info->name())); | 829 Handle<String> name_handle(String::cast(info->name())); |
| 818 info_wrapper.SetProperties(name_handle, info->start_position(), | 830 info_wrapper.SetProperties(name_handle, info->start_position(), |
| 819 info->end_position(), info); | 831 info->end_position(), info); |
| 820 SetElement(array, i, info_wrapper.GetJSArray()); | 832 SetElement(array, i, info_wrapper.GetJSArray(), kNonStrictMode); |
| 821 } | 833 } |
| 822 } | 834 } |
| 823 | 835 |
| 824 | 836 |
| 825 // Visitor that collects all references to a particular code object, | 837 // Visitor that collects all references to a particular code object, |
| 826 // including "CODE_TARGET" references in other code objects. | 838 // including "CODE_TARGET" references in other code objects. |
| 827 // It works in context of ZoneScope. | 839 // It works in context of ZoneScope. |
| 828 class ReferenceCollectorVisitor : public ObjectVisitor { | 840 class ReferenceCollectorVisitor : public ObjectVisitor { |
| 829 public: | 841 public: |
| 830 explicit ReferenceCollectorVisitor(Code* original) | 842 explicit ReferenceCollectorVisitor(Code* original) |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1308 JSFunction::cast(JavaScriptFrame::cast(frame)->function())); | 1320 JSFunction::cast(JavaScriptFrame::cast(frame)->function())); |
| 1309 | 1321 |
| 1310 int len = Smi::cast(shared_info_array->length())->value(); | 1322 int len = Smi::cast(shared_info_array->length())->value(); |
| 1311 for (int i = 0; i < len; i++) { | 1323 for (int i = 0; i < len; i++) { |
| 1312 JSValue* wrapper = | 1324 JSValue* wrapper = |
| 1313 JSValue::cast(shared_info_array->GetElementNoExceptionThrown(i)); | 1325 JSValue::cast(shared_info_array->GetElementNoExceptionThrown(i)); |
| 1314 Handle<SharedFunctionInfo> shared( | 1326 Handle<SharedFunctionInfo> shared( |
| 1315 SharedFunctionInfo::cast(wrapper->value())); | 1327 SharedFunctionInfo::cast(wrapper->value())); |
| 1316 | 1328 |
| 1317 if (function->shared() == *shared || IsInlined(*function, *shared)) { | 1329 if (function->shared() == *shared || IsInlined(*function, *shared)) { |
| 1318 SetElement(result, i, Handle<Smi>(Smi::FromInt(status))); | 1330 SetElement(result, i, Handle<Smi>(Smi::FromInt(status)), kNonStrictMode); |
| 1319 return true; | 1331 return true; |
| 1320 } | 1332 } |
| 1321 } | 1333 } |
| 1322 return false; | 1334 return false; |
| 1323 } | 1335 } |
| 1324 | 1336 |
| 1325 | 1337 |
| 1326 // Iterates over handler chain and removes all elements that are inside | 1338 // Iterates over handler chain and removes all elements that are inside |
| 1327 // frames being dropped. | 1339 // frames being dropped. |
| 1328 static bool FixTryCatchHandler(StackFrame* top_frame, | 1340 static bool FixTryCatchHandler(StackFrame* top_frame, |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1513 } | 1525 } |
| 1514 Debug::FramesHaveBeenDropped(new_id, drop_mode, | 1526 Debug::FramesHaveBeenDropped(new_id, drop_mode, |
| 1515 restarter_frame_function_pointer); | 1527 restarter_frame_function_pointer); |
| 1516 | 1528 |
| 1517 // Replace "blocked on active" with "replaced on active" status. | 1529 // Replace "blocked on active" with "replaced on active" status. |
| 1518 for (int i = 0; i < array_len; i++) { | 1530 for (int i = 0; i < array_len; i++) { |
| 1519 if (result->GetElement(i) == | 1531 if (result->GetElement(i) == |
| 1520 Smi::FromInt(LiveEdit::FUNCTION_BLOCKED_ON_ACTIVE_STACK)) { | 1532 Smi::FromInt(LiveEdit::FUNCTION_BLOCKED_ON_ACTIVE_STACK)) { |
| 1521 Handle<Object> replaced( | 1533 Handle<Object> replaced( |
| 1522 Smi::FromInt(LiveEdit::FUNCTION_REPLACED_ON_ACTIVE_STACK)); | 1534 Smi::FromInt(LiveEdit::FUNCTION_REPLACED_ON_ACTIVE_STACK)); |
| 1523 SetElement(result, i, replaced); | 1535 SetElement(result, i, replaced, kNonStrictMode); |
| 1524 } | 1536 } |
| 1525 } | 1537 } |
| 1526 return NULL; | 1538 return NULL; |
| 1527 } | 1539 } |
| 1528 | 1540 |
| 1529 | 1541 |
| 1530 class InactiveThreadActivationsChecker : public ThreadVisitor { | 1542 class InactiveThreadActivationsChecker : public ThreadVisitor { |
| 1531 public: | 1543 public: |
| 1532 InactiveThreadActivationsChecker(Handle<JSArray> shared_info_array, | 1544 InactiveThreadActivationsChecker(Handle<JSArray> shared_info_array, |
| 1533 Handle<JSArray> result) | 1545 Handle<JSArray> result) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1554 | 1566 |
| 1555 Handle<JSArray> LiveEdit::CheckAndDropActivations( | 1567 Handle<JSArray> LiveEdit::CheckAndDropActivations( |
| 1556 Handle<JSArray> shared_info_array, bool do_drop) { | 1568 Handle<JSArray> shared_info_array, bool do_drop) { |
| 1557 int len = Smi::cast(shared_info_array->length())->value(); | 1569 int len = Smi::cast(shared_info_array->length())->value(); |
| 1558 | 1570 |
| 1559 Handle<JSArray> result = Factory::NewJSArray(len); | 1571 Handle<JSArray> result = Factory::NewJSArray(len); |
| 1560 | 1572 |
| 1561 // Fill the default values. | 1573 // Fill the default values. |
| 1562 for (int i = 0; i < len; i++) { | 1574 for (int i = 0; i < len; i++) { |
| 1563 SetElement(result, i, | 1575 SetElement(result, i, |
| 1564 Handle<Smi>(Smi::FromInt(FUNCTION_AVAILABLE_FOR_PATCH))); | 1576 Handle<Smi>(Smi::FromInt(FUNCTION_AVAILABLE_FOR_PATCH)), |
| 1577 kNonStrictMode); |
| 1565 } | 1578 } |
| 1566 | 1579 |
| 1567 | 1580 |
| 1568 // First check inactive threads. Fail if some functions are blocked there. | 1581 // First check inactive threads. Fail if some functions are blocked there. |
| 1569 InactiveThreadActivationsChecker inactive_threads_checker(shared_info_array, | 1582 InactiveThreadActivationsChecker inactive_threads_checker(shared_info_array, |
| 1570 result); | 1583 result); |
| 1571 ThreadManager::IterateArchivedThreads(&inactive_threads_checker); | 1584 ThreadManager::IterateArchivedThreads(&inactive_threads_checker); |
| 1572 if (inactive_threads_checker.HasBlockedFunctions()) { | 1585 if (inactive_threads_checker.HasBlockedFunctions()) { |
| 1573 return result; | 1586 return result; |
| 1574 } | 1587 } |
| 1575 | 1588 |
| 1576 // Try to drop activations from the current stack. | 1589 // Try to drop activations from the current stack. |
| 1577 const char* error_message = | 1590 const char* error_message = |
| 1578 DropActivationsInActiveThread(shared_info_array, result, do_drop); | 1591 DropActivationsInActiveThread(shared_info_array, result, do_drop); |
| 1579 if (error_message != NULL) { | 1592 if (error_message != NULL) { |
| 1580 // Add error message as an array extra element. | 1593 // Add error message as an array extra element. |
| 1581 Vector<const char> vector_message(error_message, StrLength(error_message)); | 1594 Vector<const char> vector_message(error_message, StrLength(error_message)); |
| 1582 Handle<String> str = Factory::NewStringFromAscii(vector_message); | 1595 Handle<String> str = Factory::NewStringFromAscii(vector_message); |
| 1583 SetElement(result, len, str); | 1596 SetElement(result, len, str, kNonStrictMode); |
| 1584 } | 1597 } |
| 1585 return result; | 1598 return result; |
| 1586 } | 1599 } |
| 1587 | 1600 |
| 1588 | 1601 |
| 1589 LiveEditFunctionTracker::LiveEditFunctionTracker(FunctionLiteral* fun) { | 1602 LiveEditFunctionTracker::LiveEditFunctionTracker(FunctionLiteral* fun) { |
| 1590 if (active_function_info_listener != NULL) { | 1603 if (active_function_info_listener != NULL) { |
| 1591 active_function_info_listener->FunctionStarted(fun); | 1604 active_function_info_listener->FunctionStarted(fun); |
| 1592 } | 1605 } |
| 1593 } | 1606 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1641 | 1654 |
| 1642 bool LiveEditFunctionTracker::IsActive() { | 1655 bool LiveEditFunctionTracker::IsActive() { |
| 1643 return false; | 1656 return false; |
| 1644 } | 1657 } |
| 1645 | 1658 |
| 1646 #endif // ENABLE_DEBUGGER_SUPPORT | 1659 #endif // ENABLE_DEBUGGER_SUPPORT |
| 1647 | 1660 |
| 1648 | 1661 |
| 1649 | 1662 |
| 1650 } } // namespace v8::internal | 1663 } } // namespace v8::internal |
| OLD | NEW |