| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 170 |
| 171 | 171 |
| 172 void VirtualFrame::EmitPop(const Operand& operand) { | 172 void VirtualFrame::EmitPop(const Operand& operand) { |
| 173 ASSERT(stack_pointer_ == element_count() - 1); | 173 ASSERT(stack_pointer_ == element_count() - 1); |
| 174 stack_pointer_--; | 174 stack_pointer_--; |
| 175 elements_.RemoveLast(); | 175 elements_.RemoveLast(); |
| 176 __ pop(operand); | 176 __ pop(operand); |
| 177 } | 177 } |
| 178 | 178 |
| 179 | 179 |
| 180 void VirtualFrame::EmitPush(Register reg, NumberInfo info) { | 180 void VirtualFrame::EmitPush(Register reg, TypeInfo info) { |
| 181 ASSERT(stack_pointer_ == element_count() - 1); | 181 ASSERT(stack_pointer_ == element_count() - 1); |
| 182 elements_.Add(FrameElement::MemoryElement(info)); | 182 elements_.Add(FrameElement::MemoryElement(info)); |
| 183 stack_pointer_++; | 183 stack_pointer_++; |
| 184 __ push(reg); | 184 __ push(reg); |
| 185 } | 185 } |
| 186 | 186 |
| 187 | 187 |
| 188 void VirtualFrame::EmitPush(const Operand& operand, NumberInfo info) { | 188 void VirtualFrame::EmitPush(const Operand& operand, TypeInfo info) { |
| 189 ASSERT(stack_pointer_ == element_count() - 1); | 189 ASSERT(stack_pointer_ == element_count() - 1); |
| 190 elements_.Add(FrameElement::MemoryElement(info)); | 190 elements_.Add(FrameElement::MemoryElement(info)); |
| 191 stack_pointer_++; | 191 stack_pointer_++; |
| 192 __ push(operand); | 192 __ push(operand); |
| 193 } | 193 } |
| 194 | 194 |
| 195 | 195 |
| 196 void VirtualFrame::EmitPush(Immediate immediate, NumberInfo info) { | 196 void VirtualFrame::EmitPush(Immediate immediate, TypeInfo info) { |
| 197 ASSERT(stack_pointer_ == element_count() - 1); | 197 ASSERT(stack_pointer_ == element_count() - 1); |
| 198 elements_.Add(FrameElement::MemoryElement(info)); | 198 elements_.Add(FrameElement::MemoryElement(info)); |
| 199 stack_pointer_++; | 199 stack_pointer_++; |
| 200 __ push(immediate); | 200 __ push(immediate); |
| 201 } | 201 } |
| 202 | 202 |
| 203 | 203 |
| 204 void VirtualFrame::EmitPush(Smi* smi_value) { | 204 void VirtualFrame::EmitPush(Smi* smi_value) { |
| 205 ASSERT(stack_pointer_ == element_count() - 1); | 205 ASSERT(stack_pointer_ == element_count() - 1); |
| 206 elements_.Add(FrameElement::MemoryElement(NumberInfo::Smi())); | 206 elements_.Add(FrameElement::MemoryElement(TypeInfo::Smi())); |
| 207 stack_pointer_++; | 207 stack_pointer_++; |
| 208 __ Push(smi_value); | 208 __ Push(smi_value); |
| 209 } | 209 } |
| 210 | 210 |
| 211 | 211 |
| 212 void VirtualFrame::EmitPush(Handle<Object> value) { | 212 void VirtualFrame::EmitPush(Handle<Object> value) { |
| 213 ASSERT(stack_pointer_ == element_count() - 1); | 213 ASSERT(stack_pointer_ == element_count() - 1); |
| 214 NumberInfo info = NumberInfo::TypeFromValue(value); | 214 TypeInfo info = TypeInfo::TypeFromValue(value); |
| 215 elements_.Add(FrameElement::MemoryElement(info)); | 215 elements_.Add(FrameElement::MemoryElement(info)); |
| 216 stack_pointer_++; | 216 stack_pointer_++; |
| 217 __ Push(value); | 217 __ Push(value); |
| 218 } | 218 } |
| 219 | 219 |
| 220 | 220 |
| 221 void VirtualFrame::EmitPush(Heap::RootListIndex index, NumberInfo info) { | 221 void VirtualFrame::EmitPush(Heap::RootListIndex index, TypeInfo info) { |
| 222 ASSERT(stack_pointer_ == element_count() - 1); | 222 ASSERT(stack_pointer_ == element_count() - 1); |
| 223 elements_.Add(FrameElement::MemoryElement(info)); | 223 elements_.Add(FrameElement::MemoryElement(info)); |
| 224 stack_pointer_++; | 224 stack_pointer_++; |
| 225 __ PushRoot(index); | 225 __ PushRoot(index); |
| 226 } | 226 } |
| 227 | 227 |
| 228 | 228 |
| 229 void VirtualFrame::Drop(int count) { | 229 void VirtualFrame::Drop(int count) { |
| 230 ASSERT(count >= 0); | 230 ASSERT(count >= 0); |
| 231 ASSERT(height() >= count); | 231 ASSERT(height() >= count); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 backing_reg = original.reg(); | 285 backing_reg = original.reg(); |
| 286 set_register_location(backing_reg, new_backing_index); | 286 set_register_location(backing_reg, new_backing_index); |
| 287 } | 287 } |
| 288 // Invalidate the element at index. | 288 // Invalidate the element at index. |
| 289 elements_[index] = FrameElement::InvalidElement(); | 289 elements_[index] = FrameElement::InvalidElement(); |
| 290 // Set the new backing element. | 290 // Set the new backing element. |
| 291 if (elements_[new_backing_index].is_synced()) { | 291 if (elements_[new_backing_index].is_synced()) { |
| 292 elements_[new_backing_index] = | 292 elements_[new_backing_index] = |
| 293 FrameElement::RegisterElement(backing_reg, | 293 FrameElement::RegisterElement(backing_reg, |
| 294 FrameElement::SYNCED, | 294 FrameElement::SYNCED, |
| 295 original.number_info()); | 295 original.type_info()); |
| 296 } else { | 296 } else { |
| 297 elements_[new_backing_index] = | 297 elements_[new_backing_index] = |
| 298 FrameElement::RegisterElement(backing_reg, | 298 FrameElement::RegisterElement(backing_reg, |
| 299 FrameElement::NOT_SYNCED, | 299 FrameElement::NOT_SYNCED, |
| 300 original.number_info()); | 300 original.type_info()); |
| 301 } | 301 } |
| 302 // Update the other copies. | 302 // Update the other copies. |
| 303 for (int i = new_backing_index + 1; i < element_count(); i++) { | 303 for (int i = new_backing_index + 1; i < element_count(); i++) { |
| 304 if (elements_[i].is_copy() && elements_[i].index() == index) { | 304 if (elements_[i].is_copy() && elements_[i].index() == index) { |
| 305 elements_[i].set_index(new_backing_index); | 305 elements_[i].set_index(new_backing_index); |
| 306 elements_[new_backing_index].set_copied(); | 306 elements_[new_backing_index].set_copied(); |
| 307 } | 307 } |
| 308 } | 308 } |
| 309 return new_backing_index; | 309 return new_backing_index; |
| 310 } | 310 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 322 | 322 |
| 323 switch (original.type()) { | 323 switch (original.type()) { |
| 324 case FrameElement::MEMORY: { | 324 case FrameElement::MEMORY: { |
| 325 // Emit code to load the original element's data into a register. | 325 // Emit code to load the original element's data into a register. |
| 326 // Push that register as a FrameElement on top of the frame. | 326 // Push that register as a FrameElement on top of the frame. |
| 327 Result fresh = cgen()->allocator()->Allocate(); | 327 Result fresh = cgen()->allocator()->Allocate(); |
| 328 ASSERT(fresh.is_valid()); | 328 ASSERT(fresh.is_valid()); |
| 329 FrameElement new_element = | 329 FrameElement new_element = |
| 330 FrameElement::RegisterElement(fresh.reg(), | 330 FrameElement::RegisterElement(fresh.reg(), |
| 331 FrameElement::NOT_SYNCED, | 331 FrameElement::NOT_SYNCED, |
| 332 original.number_info()); | 332 original.type_info()); |
| 333 Use(fresh.reg(), element_count()); | 333 Use(fresh.reg(), element_count()); |
| 334 elements_.Add(new_element); | 334 elements_.Add(new_element); |
| 335 __ movq(fresh.reg(), Operand(rbp, fp_relative(index))); | 335 __ movq(fresh.reg(), Operand(rbp, fp_relative(index))); |
| 336 break; | 336 break; |
| 337 } | 337 } |
| 338 case FrameElement::REGISTER: | 338 case FrameElement::REGISTER: |
| 339 Use(original.reg(), element_count()); | 339 Use(original.reg(), element_count()); |
| 340 // Fall through. | 340 // Fall through. |
| 341 case FrameElement::CONSTANT: | 341 case FrameElement::CONSTANT: |
| 342 case FrameElement::COPY: | 342 case FrameElement::COPY: |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 | 468 |
| 469 void VirtualFrame::MakeMergable() { | 469 void VirtualFrame::MakeMergable() { |
| 470 for (int i = 0; i < element_count(); i++) { | 470 for (int i = 0; i < element_count(); i++) { |
| 471 FrameElement element = elements_[i]; | 471 FrameElement element = elements_[i]; |
| 472 | 472 |
| 473 // In all cases we have to reset the number type information | 473 // In all cases we have to reset the number type information |
| 474 // to unknown for a mergable frame because of incoming back edges. | 474 // to unknown for a mergable frame because of incoming back edges. |
| 475 if (element.is_constant() || element.is_copy()) { | 475 if (element.is_constant() || element.is_copy()) { |
| 476 if (element.is_synced()) { | 476 if (element.is_synced()) { |
| 477 // Just spill. | 477 // Just spill. |
| 478 elements_[i] = FrameElement::MemoryElement(NumberInfo::Unknown()); | 478 elements_[i] = FrameElement::MemoryElement(TypeInfo::Unknown()); |
| 479 } else { | 479 } else { |
| 480 // Allocate to a register. | 480 // Allocate to a register. |
| 481 FrameElement backing_element; // Invalid if not a copy. | 481 FrameElement backing_element; // Invalid if not a copy. |
| 482 if (element.is_copy()) { | 482 if (element.is_copy()) { |
| 483 backing_element = elements_[element.index()]; | 483 backing_element = elements_[element.index()]; |
| 484 } | 484 } |
| 485 Result fresh = cgen()->allocator()->Allocate(); | 485 Result fresh = cgen()->allocator()->Allocate(); |
| 486 ASSERT(fresh.is_valid()); // A register was spilled if all were in use. | 486 ASSERT(fresh.is_valid()); // A register was spilled if all were in use. |
| 487 elements_[i] = | 487 elements_[i] = |
| 488 FrameElement::RegisterElement(fresh.reg(), | 488 FrameElement::RegisterElement(fresh.reg(), |
| 489 FrameElement::NOT_SYNCED, | 489 FrameElement::NOT_SYNCED, |
| 490 NumberInfo::Unknown()); | 490 TypeInfo::Unknown()); |
| 491 Use(fresh.reg(), i); | 491 Use(fresh.reg(), i); |
| 492 | 492 |
| 493 // Emit a move. | 493 // Emit a move. |
| 494 if (element.is_constant()) { | 494 if (element.is_constant()) { |
| 495 __ Move(fresh.reg(), element.handle()); | 495 __ Move(fresh.reg(), element.handle()); |
| 496 } else { | 496 } else { |
| 497 ASSERT(element.is_copy()); | 497 ASSERT(element.is_copy()); |
| 498 // Copies are only backed by register or memory locations. | 498 // Copies are only backed by register or memory locations. |
| 499 if (backing_element.is_register()) { | 499 if (backing_element.is_register()) { |
| 500 // The backing store may have been spilled by allocating, | 500 // The backing store may have been spilled by allocating, |
| 501 // but that's OK. If it was, the value is right where we | 501 // but that's OK. If it was, the value is right where we |
| 502 // want it. | 502 // want it. |
| 503 if (!fresh.reg().is(backing_element.reg())) { | 503 if (!fresh.reg().is(backing_element.reg())) { |
| 504 __ movq(fresh.reg(), backing_element.reg()); | 504 __ movq(fresh.reg(), backing_element.reg()); |
| 505 } | 505 } |
| 506 } else { | 506 } else { |
| 507 ASSERT(backing_element.is_memory()); | 507 ASSERT(backing_element.is_memory()); |
| 508 __ movq(fresh.reg(), Operand(rbp, fp_relative(element.index()))); | 508 __ movq(fresh.reg(), Operand(rbp, fp_relative(element.index()))); |
| 509 } | 509 } |
| 510 } | 510 } |
| 511 } | 511 } |
| 512 // No need to set the copied flag --- there are no copies. | 512 // No need to set the copied flag --- there are no copies. |
| 513 } else { | 513 } else { |
| 514 // Clear the copy flag of non-constant, non-copy elements. | 514 // Clear the copy flag of non-constant, non-copy elements. |
| 515 // They cannot be copied because copies are not allowed. | 515 // They cannot be copied because copies are not allowed. |
| 516 // The copy flag is not relied on before the end of this loop, | 516 // The copy flag is not relied on before the end of this loop, |
| 517 // including when registers are spilled. | 517 // including when registers are spilled. |
| 518 elements_[i].clear_copied(); | 518 elements_[i].clear_copied(); |
| 519 elements_[i].set_number_info(NumberInfo::Unknown()); | 519 elements_[i].set_type_info(TypeInfo::Unknown()); |
| 520 } | 520 } |
| 521 } | 521 } |
| 522 } | 522 } |
| 523 | 523 |
| 524 | 524 |
| 525 void VirtualFrame::MergeTo(VirtualFrame* expected) { | 525 void VirtualFrame::MergeTo(VirtualFrame* expected) { |
| 526 Comment cmnt(masm(), "[ Merge frame"); | 526 Comment cmnt(masm(), "[ Merge frame"); |
| 527 // We should always be merging the code generator's current frame to an | 527 // We should always be merging the code generator's current frame to an |
| 528 // expected frame. | 528 // expected frame. |
| 529 ASSERT(cgen()->frame() == this); | 529 ASSERT(cgen()->frame() == this); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 } | 716 } |
| 717 } | 717 } |
| 718 | 718 |
| 719 | 719 |
| 720 Result VirtualFrame::Pop() { | 720 Result VirtualFrame::Pop() { |
| 721 FrameElement element = elements_.RemoveLast(); | 721 FrameElement element = elements_.RemoveLast(); |
| 722 int index = element_count(); | 722 int index = element_count(); |
| 723 ASSERT(element.is_valid()); | 723 ASSERT(element.is_valid()); |
| 724 | 724 |
| 725 // Get number type information of the result. | 725 // Get number type information of the result. |
| 726 NumberInfo info; | 726 TypeInfo info; |
| 727 if (!element.is_copy()) { | 727 if (!element.is_copy()) { |
| 728 info = element.number_info(); | 728 info = element.type_info(); |
| 729 } else { | 729 } else { |
| 730 info = elements_[element.index()].number_info(); | 730 info = elements_[element.index()].type_info(); |
| 731 } | 731 } |
| 732 | 732 |
| 733 bool pop_needed = (stack_pointer_ == index); | 733 bool pop_needed = (stack_pointer_ == index); |
| 734 if (pop_needed) { | 734 if (pop_needed) { |
| 735 stack_pointer_--; | 735 stack_pointer_--; |
| 736 if (element.is_memory()) { | 736 if (element.is_memory()) { |
| 737 Result temp = cgen()->allocator()->Allocate(); | 737 Result temp = cgen()->allocator()->Allocate(); |
| 738 ASSERT(temp.is_valid()); | 738 ASSERT(temp.is_valid()); |
| 739 __ pop(temp.reg()); | 739 __ pop(temp.reg()); |
| 740 temp.set_number_info(info); | 740 temp.set_type_info(info); |
| 741 return temp; | 741 return temp; |
| 742 } | 742 } |
| 743 | 743 |
| 744 __ addq(rsp, Immediate(kPointerSize)); | 744 __ addq(rsp, Immediate(kPointerSize)); |
| 745 } | 745 } |
| 746 ASSERT(!element.is_memory()); | 746 ASSERT(!element.is_memory()); |
| 747 | 747 |
| 748 // The top element is a register, constant, or a copy. Unuse | 748 // The top element is a register, constant, or a copy. Unuse |
| 749 // registers and follow copies to their backing store. | 749 // registers and follow copies to their backing store. |
| 750 if (element.is_register()) { | 750 if (element.is_register()) { |
| 751 Unuse(element.reg()); | 751 Unuse(element.reg()); |
| 752 } else if (element.is_copy()) { | 752 } else if (element.is_copy()) { |
| 753 ASSERT(element.index() < index); | 753 ASSERT(element.index() < index); |
| 754 index = element.index(); | 754 index = element.index(); |
| 755 element = elements_[index]; | 755 element = elements_[index]; |
| 756 } | 756 } |
| 757 ASSERT(!element.is_copy()); | 757 ASSERT(!element.is_copy()); |
| 758 | 758 |
| 759 // The element is memory, a register, or a constant. | 759 // The element is memory, a register, or a constant. |
| 760 if (element.is_memory()) { | 760 if (element.is_memory()) { |
| 761 // Memory elements could only be the backing store of a copy. | 761 // Memory elements could only be the backing store of a copy. |
| 762 // Allocate the original to a register. | 762 // Allocate the original to a register. |
| 763 ASSERT(index <= stack_pointer_); | 763 ASSERT(index <= stack_pointer_); |
| 764 Result temp = cgen()->allocator()->Allocate(); | 764 Result temp = cgen()->allocator()->Allocate(); |
| 765 ASSERT(temp.is_valid()); | 765 ASSERT(temp.is_valid()); |
| 766 Use(temp.reg(), index); | 766 Use(temp.reg(), index); |
| 767 FrameElement new_element = | 767 FrameElement new_element = |
| 768 FrameElement::RegisterElement(temp.reg(), | 768 FrameElement::RegisterElement(temp.reg(), |
| 769 FrameElement::SYNCED, | 769 FrameElement::SYNCED, |
| 770 element.number_info()); | 770 element.type_info()); |
| 771 // Preserve the copy flag on the element. | 771 // Preserve the copy flag on the element. |
| 772 if (element.is_copied()) new_element.set_copied(); | 772 if (element.is_copied()) new_element.set_copied(); |
| 773 elements_[index] = new_element; | 773 elements_[index] = new_element; |
| 774 __ movq(temp.reg(), Operand(rbp, fp_relative(index))); | 774 __ movq(temp.reg(), Operand(rbp, fp_relative(index))); |
| 775 return Result(temp.reg(), info); | 775 return Result(temp.reg(), info); |
| 776 } else if (element.is_register()) { | 776 } else if (element.is_register()) { |
| 777 return Result(element.reg(), info); | 777 return Result(element.reg(), info); |
| 778 } else { | 778 } else { |
| 779 ASSERT(element.is_constant()); | 779 ASSERT(element.is_constant()); |
| 780 return Result(element.handle()); | 780 return Result(element.handle()); |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 // Grow the expression stack by handler size less one (the return | 1112 // Grow the expression stack by handler size less one (the return |
| 1113 // address is already pushed by a call instruction). | 1113 // address is already pushed by a call instruction). |
| 1114 Adjust(kHandlerSize - 1); | 1114 Adjust(kHandlerSize - 1); |
| 1115 __ PushTryHandler(IN_JAVASCRIPT, type); | 1115 __ PushTryHandler(IN_JAVASCRIPT, type); |
| 1116 } | 1116 } |
| 1117 | 1117 |
| 1118 | 1118 |
| 1119 #undef __ | 1119 #undef __ |
| 1120 | 1120 |
| 1121 } } // namespace v8::internal | 1121 } } // namespace v8::internal |
| OLD | NEW |