OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
848 int scope_info_length = 0; | 848 int scope_info_length = 0; |
849 | 849 |
850 // Saves some description of scope. It stores name and indexes of | 850 // Saves some description of scope. It stores name and indexes of |
851 // variables in the whole scope chain. Null-named slots delimit | 851 // variables in the whole scope chain. Null-named slots delimit |
852 // scopes of this chain. | 852 // scopes of this chain. |
853 Scope* outer_scope = scope->outer_scope(); | 853 Scope* outer_scope = scope->outer_scope(); |
854 if (outer_scope == NULL) { | 854 if (outer_scope == NULL) { |
855 return HEAP->undefined_value(); | 855 return HEAP->undefined_value(); |
856 } | 856 } |
857 do { | 857 do { |
858 ZoneList<Variable*> list(10); | 858 ZoneList<Variable*> stack_list(outer_scope->StackLocalCount()); |
859 outer_scope->CollectUsedVariables(&list); | 859 ZoneList<Variable*> context_list(outer_scope->ContextLocalCount()); |
860 int j = 0; | 860 outer_scope->CollectStackAndContextLocals(&stack_list, &context_list); |
861 for (int i = 0; i < list.length(); i++) { | |
862 Variable* var1 = list[i]; | |
863 if (var1->IsContextSlot()) { | |
864 if (j != i) { | |
865 list[j] = var1; | |
866 } | |
867 j++; | |
868 } | |
869 } | |
870 | 861 |
871 // Sort it. | 862 // Sort it. |
872 for (int k = 1; k < j; k++) { | 863 for (int k = 1; k < context_list.length(); k++) { |
Steven
2011/11/03 12:39:39
Why does the iteration start at 1 here? Is this ma
Kevin Millikin (Chromium)
2011/11/03 13:12:20
It does look like a bug. I'm not even sure whethe
Steven
2011/11/03 14:55:59
Done.
| |
873 int l = k; | 864 int l = k; |
874 for (int m = k + 1; m < j; m++) { | 865 for (int m = k + 1; m < context_list.length(); m++) { |
875 if (list[l]->index() > list[m]->index()) { | 866 if (context_list[l]->index() > context_list[m]->index()) { |
876 l = m; | 867 l = m; |
877 } | 868 } |
878 } | 869 } |
879 list[k] = list[l]; | 870 context_list[k] = context_list[l]; |
Steven
2011/11/03 14:55:59
Honestly this whole code looks like a giant bug to
| |
880 } | 871 } |
881 for (int i = 0; i < j; i++) { | 872 for (int i = 0; i < context_list.length(); i++) { |
882 SetElementNonStrict(scope_info_list, | 873 SetElementNonStrict(scope_info_list, |
883 scope_info_length, | 874 scope_info_length, |
884 list[i]->name()); | 875 context_list[i]->name()); |
885 scope_info_length++; | 876 scope_info_length++; |
886 SetElementNonStrict( | 877 SetElementNonStrict( |
887 scope_info_list, | 878 scope_info_list, |
888 scope_info_length, | 879 scope_info_length, |
889 Handle<Smi>(Smi::FromInt(list[i]->index()))); | 880 Handle<Smi>(Smi::FromInt(context_list[i]->index()))); |
890 scope_info_length++; | 881 scope_info_length++; |
891 } | 882 } |
892 SetElementNonStrict(scope_info_list, | 883 SetElementNonStrict(scope_info_list, |
893 scope_info_length, | 884 scope_info_length, |
894 Handle<Object>(HEAP->null_value())); | 885 Handle<Object>(HEAP->null_value())); |
895 scope_info_length++; | 886 scope_info_length++; |
896 | 887 |
897 outer_scope = outer_scope->outer_scope(); | 888 outer_scope = outer_scope->outer_scope(); |
898 } while (outer_scope != NULL); | 889 } while (outer_scope != NULL); |
899 | 890 |
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1782 | 1773 |
1783 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { | 1774 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { |
1784 return false; | 1775 return false; |
1785 } | 1776 } |
1786 | 1777 |
1787 #endif // ENABLE_DEBUGGER_SUPPORT | 1778 #endif // ENABLE_DEBUGGER_SUPPORT |
1788 | 1779 |
1789 | 1780 |
1790 | 1781 |
1791 } } // namespace v8::internal | 1782 } } // namespace v8::internal |
OLD | NEW |