OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 25 matching lines...) Expand all Loading... |
36 | 36 |
37 // ------------------------------------------------------------------------- | 37 // ------------------------------------------------------------------------- |
38 // VirtualFrame implementation. | 38 // VirtualFrame implementation. |
39 | 39 |
40 // Create a duplicate of an existing valid frame element. | 40 // Create a duplicate of an existing valid frame element. |
41 // We can pass an optional number type information that will override the | 41 // We can pass an optional number type information that will override the |
42 // existing information about the backing element. The new information must | 42 // existing information about the backing element. The new information must |
43 // not conflict with the existing type information and must be equally or | 43 // not conflict with the existing type information and must be equally or |
44 // more precise. The default parameter value kUninitialized means that there | 44 // more precise. The default parameter value kUninitialized means that there |
45 // is no additional information. | 45 // is no additional information. |
46 FrameElement VirtualFrame::CopyElementAt(int index, NumberInfo::Type info) { | 46 FrameElement VirtualFrame::CopyElementAt(int index, NumberInfo info) { |
47 ASSERT(index >= 0); | 47 ASSERT(index >= 0); |
48 ASSERT(index < element_count()); | 48 ASSERT(index < element_count()); |
49 | 49 |
50 FrameElement target = elements_[index]; | 50 FrameElement target = elements_[index]; |
51 FrameElement result; | 51 FrameElement result; |
52 | 52 |
53 switch (target.type()) { | 53 switch (target.type()) { |
54 case FrameElement::CONSTANT: | 54 case FrameElement::CONSTANT: |
55 // We do not copy constants and instead return a fresh unsynced | 55 // We do not copy constants and instead return a fresh unsynced |
56 // constant. | 56 // constant. |
(...skipping 10 matching lines...) Expand all Loading... |
67 | 67 |
68 case FrameElement::MEMORY: // Fall through. | 68 case FrameElement::MEMORY: // Fall through. |
69 case FrameElement::REGISTER: { | 69 case FrameElement::REGISTER: { |
70 // All copies are backed by memory or register locations. | 70 // All copies are backed by memory or register locations. |
71 result.set_type(FrameElement::COPY); | 71 result.set_type(FrameElement::COPY); |
72 result.clear_copied(); | 72 result.clear_copied(); |
73 result.clear_sync(); | 73 result.clear_sync(); |
74 result.set_index(index); | 74 result.set_index(index); |
75 elements_[index].set_copied(); | 75 elements_[index].set_copied(); |
76 // Update backing element's number information. | 76 // Update backing element's number information. |
77 NumberInfo::Type existing = elements_[index].number_info(); | 77 NumberInfo existing = elements_[index].number_info(); |
78 ASSERT(existing != NumberInfo::kUninitialized); | 78 ASSERT(!existing.IsUninitialized()); |
79 // Assert that the new type information (a) does not conflict with the | 79 // Assert that the new type information (a) does not conflict with the exi
sting one and |
80 // existing one and (b) is equally or more precise. | 80 // (b) is equally or more precise. |
81 ASSERT((info == NumberInfo::kUninitialized) || | 81 ASSERT((info.ToInt() & existing.ToInt()) == existing.ToInt()); |
82 (existing | info) != NumberInfo::kUninitialized); | 82 ASSERT((info.ToInt() | existing.ToInt()) == info.ToInt()); |
83 ASSERT(existing <= info); | 83 |
84 elements_[index].set_number_info(info != NumberInfo::kUninitialized | 84 elements_[index].set_number_info(!info.IsUninitialized() |
85 ? info | 85 ? info |
86 : existing); | 86 : existing); |
87 break; | 87 break; |
88 } | 88 } |
89 case FrameElement::INVALID: | 89 case FrameElement::INVALID: |
90 // We should not try to copy invalid elements. | 90 // We should not try to copy invalid elements. |
91 UNREACHABLE(); | 91 UNREACHABLE(); |
92 break; | 92 break; |
93 } | 93 } |
94 return result; | 94 return result; |
95 } | 95 } |
96 | 96 |
97 | 97 |
98 // Modify the state of the virtual frame to match the actual frame by adding | 98 // Modify the state of the virtual frame to match the actual frame by adding |
99 // extra in-memory elements to the top of the virtual frame. The extra | 99 // extra in-memory elements to the top of the virtual frame. The extra |
100 // elements will be externally materialized on the actual frame (eg, by | 100 // elements will be externally materialized on the actual frame (eg, by |
101 // pushing an exception handler). No code is emitted. | 101 // pushing an exception handler). No code is emitted. |
102 void VirtualFrame::Adjust(int count) { | 102 void VirtualFrame::Adjust(int count) { |
103 ASSERT(count >= 0); | 103 ASSERT(count >= 0); |
104 ASSERT(stack_pointer_ == element_count() - 1); | 104 ASSERT(stack_pointer_ == element_count() - 1); |
105 | 105 |
106 for (int i = 0; i < count; i++) { | 106 for (int i = 0; i < count; i++) { |
107 elements_.Add(FrameElement::MemoryElement(NumberInfo::kUnknown)); | 107 elements_.Add(FrameElement::MemoryElement(NumberInfo::Unknown())); |
108 } | 108 } |
109 stack_pointer_ += count; | 109 stack_pointer_ += count; |
110 } | 110 } |
111 | 111 |
112 | 112 |
113 void VirtualFrame::ForgetElements(int count) { | 113 void VirtualFrame::ForgetElements(int count) { |
114 ASSERT(count >= 0); | 114 ASSERT(count >= 0); |
115 ASSERT(element_count() >= count); | 115 ASSERT(element_count() >= count); |
116 | 116 |
117 for (int i = 0; i < count; i++) { | 117 for (int i = 0; i < count; i++) { |
(...skipping 27 matching lines...) Expand all Loading... |
145 } | 145 } |
146 | 146 |
147 | 147 |
148 // Make the type of the element at a given index be MEMORY. | 148 // Make the type of the element at a given index be MEMORY. |
149 void VirtualFrame::SpillElementAt(int index) { | 149 void VirtualFrame::SpillElementAt(int index) { |
150 if (!elements_[index].is_valid()) return; | 150 if (!elements_[index].is_valid()) return; |
151 | 151 |
152 SyncElementAt(index); | 152 SyncElementAt(index); |
153 // Number type information is preserved. | 153 // Number type information is preserved. |
154 // Copies get their number information from their backing element. | 154 // Copies get their number information from their backing element. |
155 NumberInfo::Type info; | 155 NumberInfo info; |
156 if (!elements_[index].is_copy()) { | 156 if (!elements_[index].is_copy()) { |
157 info = elements_[index].number_info(); | 157 info = elements_[index].number_info(); |
158 } else { | 158 } else { |
159 info = elements_[elements_[index].index()].number_info(); | 159 info = elements_[elements_[index].index()].number_info(); |
160 } | 160 } |
161 // The element is now in memory. Its copied flag is preserved. | 161 // The element is now in memory. Its copied flag is preserved. |
162 FrameElement new_element = FrameElement::MemoryElement(info); | 162 FrameElement new_element = FrameElement::MemoryElement(info); |
163 if (elements_[index].is_copied()) { | 163 if (elements_[index].is_copied()) { |
164 new_element.set_copied(); | 164 new_element.set_copied(); |
165 } | 165 } |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 // Specialization of List::ResizeAdd to non-inlined version for FrameElements. | 330 // Specialization of List::ResizeAdd to non-inlined version for FrameElements. |
331 // The function ResizeAdd becomes a real function, whose implementation is the | 331 // The function ResizeAdd becomes a real function, whose implementation is the |
332 // inlined ResizeAddInternal. | 332 // inlined ResizeAddInternal. |
333 template <> | 333 template <> |
334 void List<FrameElement, | 334 void List<FrameElement, |
335 FreeStoreAllocationPolicy>::ResizeAdd(const FrameElement& element) { | 335 FreeStoreAllocationPolicy>::ResizeAdd(const FrameElement& element) { |
336 ResizeAddInternal(element); | 336 ResizeAddInternal(element); |
337 } | 337 } |
338 | 338 |
339 } } // namespace v8::internal | 339 } } // namespace v8::internal |
OLD | NEW |