| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 case FrameElement::COPY: | 66 case FrameElement::COPY: |
| 67 // We do not allow copies of copies, so we follow one link to | 67 // We do not allow copies of copies, so we follow one link to |
| 68 // the actual backing store of a copy before making a copy. | 68 // the actual backing store of a copy before making a copy. |
| 69 index = target.index(); | 69 index = target.index(); |
| 70 ASSERT(elements_[index].is_memory() || elements_[index].is_register()); | 70 ASSERT(elements_[index].is_memory() || elements_[index].is_register()); |
| 71 // Fall through. | 71 // Fall through. |
| 72 | 72 |
| 73 case FrameElement::MEMORY: // Fall through. | 73 case FrameElement::MEMORY: // Fall through. |
| 74 case FrameElement::REGISTER: | 74 case FrameElement::REGISTER: |
| 75 // All copies are backed by memory or register locations. | 75 // All copies are backed by memory or register locations. |
| 76 result.set_static_type(target.static_type()); | |
| 77 result.set_type(FrameElement::COPY); | 76 result.set_type(FrameElement::COPY); |
| 78 result.clear_copied(); | 77 result.clear_copied(); |
| 79 result.clear_sync(); | 78 result.clear_sync(); |
| 80 result.set_index(index); | 79 result.set_index(index); |
| 81 elements_[index].set_copied(); | 80 elements_[index].set_copied(); |
| 82 break; | 81 break; |
| 83 | 82 |
| 84 case FrameElement::INVALID: | 83 case FrameElement::INVALID: |
| 85 // We should not try to copy invalid elements. | 84 // We should not try to copy invalid elements. |
| 86 UNREACHABLE(); | 85 UNREACHABLE(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 145 |
| 147 SyncElementAt(index); | 146 SyncElementAt(index); |
| 148 // The element is now in memory. Its copied flag is preserved. | 147 // The element is now in memory. Its copied flag is preserved. |
| 149 FrameElement new_element = FrameElement::MemoryElement(); | 148 FrameElement new_element = FrameElement::MemoryElement(); |
| 150 if (elements_[index].is_copied()) { | 149 if (elements_[index].is_copied()) { |
| 151 new_element.set_copied(); | 150 new_element.set_copied(); |
| 152 } | 151 } |
| 153 if (elements_[index].is_register()) { | 152 if (elements_[index].is_register()) { |
| 154 Unuse(elements_[index].reg()); | 153 Unuse(elements_[index].reg()); |
| 155 } | 154 } |
| 156 new_element.set_static_type(elements_[index].static_type()); | |
| 157 elements_[index] = new_element; | 155 elements_[index] = new_element; |
| 158 } | 156 } |
| 159 | 157 |
| 160 | 158 |
| 161 // Clear the dirty bit for the element at a given index. | 159 // Clear the dirty bit for the element at a given index. |
| 162 void VirtualFrame::SyncElementAt(int index) { | 160 void VirtualFrame::SyncElementAt(int index) { |
| 163 if (index <= stack_pointer_) { | 161 if (index <= stack_pointer_) { |
| 164 if (!elements_[index].is_synced()) SyncElementBelowStackPointer(index); | 162 if (!elements_[index].is_synced()) SyncElementBelowStackPointer(index); |
| 165 } else if (index == stack_pointer_ + 1) { | 163 } else if (index == stack_pointer_ + 1) { |
| 166 SyncElementByPushing(index); | 164 SyncElementByPushing(index); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 } | 202 } |
| 205 elements_[i] = target; | 203 elements_[i] = target; |
| 206 } else if (target.is_register() && !target.is_synced() && | 204 } else if (target.is_register() && !target.is_synced() && |
| 207 !source.is_memory()) { | 205 !source.is_memory()) { |
| 208 // If an element's target is a register that doesn't need to be | 206 // If an element's target is a register that doesn't need to be |
| 209 // synced, and the element is not in memory, then the sync state | 207 // synced, and the element is not in memory, then the sync state |
| 210 // of the element is irrelevant. We clear the sync bit. | 208 // of the element is irrelevant. We clear the sync bit. |
| 211 ASSERT(source.is_valid()); | 209 ASSERT(source.is_valid()); |
| 212 elements_[i].clear_sync(); | 210 elements_[i].clear_sync(); |
| 213 } | 211 } |
| 214 // No code needs to be generated to change the static type of an | |
| 215 // element. | |
| 216 elements_[i].set_static_type(target.static_type()); | |
| 217 } | 212 } |
| 218 } | 213 } |
| 219 | 214 |
| 220 | 215 |
| 221 void VirtualFrame::PrepareForCall(int spilled_args, int dropped_args) { | 216 void VirtualFrame::PrepareForCall(int spilled_args, int dropped_args) { |
| 222 ASSERT(height() >= dropped_args); | 217 ASSERT(height() >= dropped_args); |
| 223 ASSERT(height() >= spilled_args); | 218 ASSERT(height() >= spilled_args); |
| 224 ASSERT(dropped_args <= spilled_args); | 219 ASSERT(dropped_args <= spilled_args); |
| 225 | 220 |
| 226 SyncRange(0, element_count() - 1); | 221 SyncRange(0, element_count() - 1); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 239 } | 234 } |
| 240 | 235 |
| 241 // Forget the frame elements that will be popped by the call. | 236 // Forget the frame elements that will be popped by the call. |
| 242 Forget(dropped_args); | 237 Forget(dropped_args); |
| 243 } | 238 } |
| 244 | 239 |
| 245 | 240 |
| 246 void VirtualFrame::PrepareForReturn() { | 241 void VirtualFrame::PrepareForReturn() { |
| 247 // Spill all locals. This is necessary to make sure all locals have | 242 // Spill all locals. This is necessary to make sure all locals have |
| 248 // the right value when breaking at the return site in the debugger. | 243 // the right value when breaking at the return site in the debugger. |
| 249 // Set their static type to unknown so that they will match the known | |
| 250 // return frame. | |
| 251 for (int i = 0; i < expression_base_index(); i++) { | 244 for (int i = 0; i < expression_base_index(); i++) { |
| 252 SpillElementAt(i); | 245 SpillElementAt(i); |
| 253 elements_[i].set_static_type(StaticType::unknown()); | |
| 254 } | 246 } |
| 255 } | 247 } |
| 256 | 248 |
| 257 | 249 |
| 258 void VirtualFrame::SetElementAt(int index, Result* value) { | 250 void VirtualFrame::SetElementAt(int index, Result* value) { |
| 259 int frame_index = element_count() - index - 1; | 251 int frame_index = element_count() - index - 1; |
| 260 ASSERT(frame_index >= 0); | 252 ASSERT(frame_index >= 0); |
| 261 ASSERT(frame_index < element_count()); | 253 ASSERT(frame_index < element_count()); |
| 262 ASSERT(value->is_valid()); | 254 ASSERT(value->is_valid()); |
| 263 FrameElement original = elements_[frame_index]; | 255 FrameElement original = elements_[frame_index]; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 276 | 268 |
| 277 InvalidateFrameSlotAt(frame_index); | 269 InvalidateFrameSlotAt(frame_index); |
| 278 | 270 |
| 279 FrameElement new_element; | 271 FrameElement new_element; |
| 280 if (value->is_register()) { | 272 if (value->is_register()) { |
| 281 if (is_used(value->reg())) { | 273 if (is_used(value->reg())) { |
| 282 // The register already appears on the frame. Either the existing | 274 // The register already appears on the frame. Either the existing |
| 283 // register element, or the new element at frame_index, must be made | 275 // register element, or the new element at frame_index, must be made |
| 284 // a copy. | 276 // a copy. |
| 285 int i = register_location(value->reg()); | 277 int i = register_location(value->reg()); |
| 286 ASSERT(value->static_type() == elements_[i].static_type()); | |
| 287 | 278 |
| 288 if (i < frame_index) { | 279 if (i < frame_index) { |
| 289 // The register FrameElement is lower in the frame than the new copy. | 280 // The register FrameElement is lower in the frame than the new copy. |
| 290 elements_[frame_index] = CopyElementAt(i); | 281 elements_[frame_index] = CopyElementAt(i); |
| 291 } else { | 282 } else { |
| 292 // There was an early bailout for the case of setting a | 283 // There was an early bailout for the case of setting a |
| 293 // register element to itself. | 284 // register element to itself. |
| 294 ASSERT(i != frame_index); | 285 ASSERT(i != frame_index); |
| 295 elements_[frame_index] = elements_[i]; | 286 elements_[frame_index] = elements_[i]; |
| 296 elements_[i] = CopyElementAt(frame_index); | 287 elements_[i] = CopyElementAt(frame_index); |
| 297 if (elements_[frame_index].is_synced()) { | 288 if (elements_[frame_index].is_synced()) { |
| 298 elements_[i].set_sync(); | 289 elements_[i].set_sync(); |
| 299 } | 290 } |
| 300 elements_[frame_index].clear_sync(); | 291 elements_[frame_index].clear_sync(); |
| 301 set_register_location(value->reg(), frame_index); | 292 set_register_location(value->reg(), frame_index); |
| 302 for (int j = i + 1; j < element_count(); j++) { | 293 for (int j = i + 1; j < element_count(); j++) { |
| 303 if (elements_[j].is_copy() && elements_[j].index() == i) { | 294 if (elements_[j].is_copy() && elements_[j].index() == i) { |
| 304 elements_[j].set_index(frame_index); | 295 elements_[j].set_index(frame_index); |
| 305 } | 296 } |
| 306 } | 297 } |
| 307 } | 298 } |
| 308 } else { | 299 } else { |
| 309 // The register value->reg() was not already used on the frame. | 300 // The register value->reg() was not already used on the frame. |
| 310 Use(value->reg(), frame_index); | 301 Use(value->reg(), frame_index); |
| 311 elements_[frame_index] = | 302 elements_[frame_index] = |
| 312 FrameElement::RegisterElement(value->reg(), | 303 FrameElement::RegisterElement(value->reg(), |
| 313 FrameElement::NOT_SYNCED, | 304 FrameElement::NOT_SYNCED); |
| 314 value->static_type()); | |
| 315 } | 305 } |
| 316 } else { | 306 } else { |
| 317 ASSERT(value->is_constant()); | 307 ASSERT(value->is_constant()); |
| 318 elements_[frame_index] = | 308 elements_[frame_index] = |
| 319 FrameElement::ConstantElement(value->handle(), | 309 FrameElement::ConstantElement(value->handle(), |
| 320 FrameElement::NOT_SYNCED); | 310 FrameElement::NOT_SYNCED); |
| 321 } | 311 } |
| 322 value->Unuse(); | 312 value->Unuse(); |
| 323 } | 313 } |
| 324 | 314 |
| 325 | 315 |
| 326 void VirtualFrame::PushFrameSlotAt(int index) { | 316 void VirtualFrame::PushFrameSlotAt(int index) { |
| 327 elements_.Add(CopyElementAt(index)); | 317 elements_.Add(CopyElementAt(index)); |
| 328 } | 318 } |
| 329 | 319 |
| 330 | 320 |
| 331 void VirtualFrame::Push(Register reg, StaticType static_type) { | 321 void VirtualFrame::Push(Register reg) { |
| 332 if (is_used(reg)) { | 322 if (is_used(reg)) { |
| 333 int index = register_location(reg); | 323 int index = register_location(reg); |
| 334 FrameElement element = CopyElementAt(index); | 324 FrameElement element = CopyElementAt(index); |
| 335 ASSERT(static_type.merge(element.static_type()) == element.static_type()); | |
| 336 elements_.Add(element); | 325 elements_.Add(element); |
| 337 } else { | 326 } else { |
| 338 Use(reg, element_count()); | 327 Use(reg, element_count()); |
| 339 FrameElement element = | 328 FrameElement element = |
| 340 FrameElement::RegisterElement(reg, | 329 FrameElement::RegisterElement(reg, |
| 341 FrameElement::NOT_SYNCED, | 330 FrameElement::NOT_SYNCED); |
| 342 static_type); | |
| 343 elements_.Add(element); | 331 elements_.Add(element); |
| 344 } | 332 } |
| 345 } | 333 } |
| 346 | 334 |
| 347 | 335 |
| 348 void VirtualFrame::Push(Handle<Object> value) { | 336 void VirtualFrame::Push(Handle<Object> value) { |
| 349 FrameElement element = | 337 FrameElement element = |
| 350 FrameElement::ConstantElement(value, FrameElement::NOT_SYNCED); | 338 FrameElement::ConstantElement(value, FrameElement::NOT_SYNCED); |
| 351 elements_.Add(element); | 339 elements_.Add(element); |
| 352 } | 340 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 // Specialization of List::ResizeAdd to non-inlined version for FrameElements. | 372 // Specialization of List::ResizeAdd to non-inlined version for FrameElements. |
| 385 // The function ResizeAdd becomes a real function, whose implementation is the | 373 // The function ResizeAdd becomes a real function, whose implementation is the |
| 386 // inlined ResizeAddInternal. | 374 // inlined ResizeAddInternal. |
| 387 template <> | 375 template <> |
| 388 void List<FrameElement, | 376 void List<FrameElement, |
| 389 FreeStoreAllocationPolicy>::ResizeAdd(const FrameElement& element) { | 377 FreeStoreAllocationPolicy>::ResizeAdd(const FrameElement& element) { |
| 390 ResizeAddInternal(element); | 378 ResizeAddInternal(element); |
| 391 } | 379 } |
| 392 | 380 |
| 393 } } // namespace v8::internal | 381 } } // namespace v8::internal |
| OLD | NEW |