| 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 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 #include "v8.h" | 28 #include "v8.h" |
| 29 | 29 |
| 30 #if defined(V8_TARGET_ARCH_IA32) | 30 #if defined(V8_TARGET_ARCH_IA32) |
| 31 | 31 |
| 32 #include "code-stubs.h" | 32 #include "code-stubs.h" |
| 33 #include "codegen-inl.h" | 33 #include "codegen-inl.h" |
| 34 #include "compiler.h" | 34 #include "compiler.h" |
| 35 #include "debug.h" | 35 #include "debug.h" |
| 36 #include "full-codegen.h" | 36 #include "full-codegen.h" |
| 37 #include "macro-assembler-ia32-inl.h" |
| 37 #include "parser.h" | 38 #include "parser.h" |
| 38 #include "scopes.h" | 39 #include "scopes.h" |
| 39 #include "stub-cache.h" | 40 #include "stub-cache.h" |
| 40 | 41 |
| 41 namespace v8 { | 42 namespace v8 { |
| 42 namespace internal { | 43 namespace internal { |
| 43 | 44 |
| 44 | 45 |
| 45 #define __ ACCESS_MASM(masm_) | 46 #define __ ACCESS_MASM(masm_) |
| 46 | 47 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 (num_parameters - 1 - i) * kPointerSize; | 167 (num_parameters - 1 - i) * kPointerSize; |
| 167 // Load parameter from stack. | 168 // Load parameter from stack. |
| 168 __ mov(eax, Operand(ebp, parameter_offset)); | 169 __ mov(eax, Operand(ebp, parameter_offset)); |
| 169 // Store it in the context. | 170 // Store it in the context. |
| 170 int context_offset = Context::SlotOffset(slot->index()); | 171 int context_offset = Context::SlotOffset(slot->index()); |
| 171 __ mov(Operand(esi, context_offset), eax); | 172 __ mov(Operand(esi, context_offset), eax); |
| 172 // Update the write barrier. This clobbers all involved | 173 // Update the write barrier. This clobbers all involved |
| 173 // registers, so we have use a third register to avoid | 174 // registers, so we have use a third register to avoid |
| 174 // clobbering esi. | 175 // clobbering esi. |
| 175 __ mov(ecx, esi); | 176 __ mov(ecx, esi); |
| 176 __ RecordWrite(ecx, context_offset, eax, ebx, kDontSaveFPRegs); | 177 __ RecordWriteContextSlot(ecx, |
| 178 context_offset, |
| 179 eax, |
| 180 ebx, |
| 181 kDontSaveFPRegs); |
| 177 } | 182 } |
| 178 } | 183 } |
| 179 } | 184 } |
| 180 | 185 |
| 181 Variable* arguments = scope()->arguments(); | 186 Variable* arguments = scope()->arguments(); |
| 182 if (arguments != NULL) { | 187 if (arguments != NULL) { |
| 183 // Function uses arguments object. | 188 // Function uses arguments object. |
| 184 Comment cmnt(masm_, "[ Allocate arguments object"); | 189 Comment cmnt(masm_, "[ Allocate arguments object"); |
| 185 if (function_in_register) { | 190 if (function_in_register) { |
| 186 __ push(edi); | 191 __ push(edi); |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 Register scratch2) { | 604 Register scratch2) { |
| 600 ASSERT(dst->type() != Slot::LOOKUP); // Not yet implemented. | 605 ASSERT(dst->type() != Slot::LOOKUP); // Not yet implemented. |
| 601 ASSERT(!scratch1.is(src) && !scratch2.is(src)); | 606 ASSERT(!scratch1.is(src) && !scratch2.is(src)); |
| 602 MemOperand location = EmitSlotSearch(dst, scratch1); | 607 MemOperand location = EmitSlotSearch(dst, scratch1); |
| 603 __ mov(location, src); | 608 __ mov(location, src); |
| 604 | 609 |
| 605 // Emit the write barrier code if the location is in the heap. | 610 // Emit the write barrier code if the location is in the heap. |
| 606 if (dst->type() == Slot::CONTEXT) { | 611 if (dst->type() == Slot::CONTEXT) { |
| 607 int offset = Context::SlotOffset(dst->index()); | 612 int offset = Context::SlotOffset(dst->index()); |
| 608 ASSERT(!scratch1.is(esi) && !src.is(esi) && !scratch2.is(esi)); | 613 ASSERT(!scratch1.is(esi) && !src.is(esi) && !scratch2.is(esi)); |
| 609 __ RecordWrite(scratch1, offset, src, scratch2, kDontSaveFPRegs); | 614 __ RecordWriteContextSlot(scratch1, offset, src, scratch2, kDontSaveFPRegs); |
| 610 } | 615 } |
| 611 } | 616 } |
| 612 | 617 |
| 613 | 618 |
| 614 void FullCodeGenerator::PrepareForBailoutBeforeSplit(State state, | 619 void FullCodeGenerator::PrepareForBailoutBeforeSplit(State state, |
| 615 bool should_normalize, | 620 bool should_normalize, |
| 616 Label* if_true, | 621 Label* if_true, |
| 617 Label* if_false) { | 622 Label* if_false) { |
| 618 // Only prepare for bailouts before splits if we're in a test | 623 // Only prepare for bailouts before splits if we're in a test |
| 619 // context. Otherwise, we let the Visit function deal with the | 624 // context. Otherwise, we let the Visit function deal with the |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 } | 678 } |
| 674 if (mode == Variable::CONST) { | 679 if (mode == Variable::CONST) { |
| 675 __ mov(ContextOperand(esi, slot->index()), | 680 __ mov(ContextOperand(esi, slot->index()), |
| 676 Immediate(Factory::the_hole_value())); | 681 Immediate(Factory::the_hole_value())); |
| 677 // No write barrier since the hole value is in old space. | 682 // No write barrier since the hole value is in old space. |
| 678 } else if (function != NULL) { | 683 } else if (function != NULL) { |
| 679 VisitForAccumulatorValue(function); | 684 VisitForAccumulatorValue(function); |
| 680 __ mov(ContextOperand(esi, slot->index()), result_register()); | 685 __ mov(ContextOperand(esi, slot->index()), result_register()); |
| 681 int offset = Context::SlotOffset(slot->index()); | 686 int offset = Context::SlotOffset(slot->index()); |
| 682 __ mov(ebx, esi); | 687 __ mov(ebx, esi); |
| 683 __ RecordWrite(ebx, offset, result_register(), ecx, kDontSaveFPRegs); | 688 __ RecordWriteContextSlot(ebx, |
| 689 offset, |
| 690 result_register(), |
| 691 ecx, |
| 692 kDontSaveFPRegs); |
| 684 } | 693 } |
| 685 break; | 694 break; |
| 686 | 695 |
| 687 case Slot::LOOKUP: { | 696 case Slot::LOOKUP: { |
| 688 __ push(esi); | 697 __ push(esi); |
| 689 __ push(Immediate(variable->name())); | 698 __ push(Immediate(variable->name())); |
| 690 // Declaration nodes are always introduced in one of two modes. | 699 // Declaration nodes are always introduced in one of two modes. |
| 691 ASSERT(mode == Variable::VAR || mode == Variable::CONST); | 700 ASSERT(mode == Variable::VAR || mode == Variable::CONST); |
| 692 PropertyAttributes attr = (mode == Variable::VAR) ? NONE : READ_ONLY; | 701 PropertyAttributes attr = (mode == Variable::VAR) ? NONE : READ_ONLY; |
| 693 __ push(Immediate(Smi::FromInt(attr))); | 702 __ push(Immediate(Smi::FromInt(attr))); |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1462 } | 1471 } |
| 1463 VisitForAccumulatorValue(subexpr); | 1472 VisitForAccumulatorValue(subexpr); |
| 1464 | 1473 |
| 1465 // Store the subexpression value in the array's elements. | 1474 // Store the subexpression value in the array's elements. |
| 1466 __ mov(ebx, Operand(esp, 0)); // Copy of array literal. | 1475 __ mov(ebx, Operand(esp, 0)); // Copy of array literal. |
| 1467 __ mov(ebx, FieldOperand(ebx, JSObject::kElementsOffset)); | 1476 __ mov(ebx, FieldOperand(ebx, JSObject::kElementsOffset)); |
| 1468 int offset = FixedArray::kHeaderSize + (i * kPointerSize); | 1477 int offset = FixedArray::kHeaderSize + (i * kPointerSize); |
| 1469 __ mov(FieldOperand(ebx, offset), result_register()); | 1478 __ mov(FieldOperand(ebx, offset), result_register()); |
| 1470 | 1479 |
| 1471 // Update the write barrier for the array store. | 1480 // Update the write barrier for the array store. |
| 1472 __ RecordWrite(ebx, offset, result_register(), ecx, kDontSaveFPRegs); | 1481 __ RecordWriteField(ebx, offset, result_register(), ecx, kDontSaveFPRegs); |
| 1473 | 1482 |
| 1474 PrepareForBailoutForId(expr->GetIdForElement(i), NO_REGISTERS); | 1483 PrepareForBailoutForId(expr->GetIdForElement(i), NO_REGISTERS); |
| 1475 } | 1484 } |
| 1476 | 1485 |
| 1477 if (result_saved) { | 1486 if (result_saved) { |
| 1478 context()->PlugTOS(); | 1487 context()->PlugTOS(); |
| 1479 } else { | 1488 } else { |
| 1480 context()->Plug(eax); | 1489 context()->Plug(eax); |
| 1481 } | 1490 } |
| 1482 } | 1491 } |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1838 __ mov(Operand(ebp, SlotOffset(slot)), eax); | 1847 __ mov(Operand(ebp, SlotOffset(slot)), eax); |
| 1839 break; | 1848 break; |
| 1840 case Slot::CONTEXT: { | 1849 case Slot::CONTEXT: { |
| 1841 __ mov(ecx, ContextOperand(esi, Context::FCONTEXT_INDEX)); | 1850 __ mov(ecx, ContextOperand(esi, Context::FCONTEXT_INDEX)); |
| 1842 __ mov(edx, ContextOperand(ecx, slot->index())); | 1851 __ mov(edx, ContextOperand(ecx, slot->index())); |
| 1843 __ cmp(edx, Factory::the_hole_value()); | 1852 __ cmp(edx, Factory::the_hole_value()); |
| 1844 __ j(not_equal, &skip); | 1853 __ j(not_equal, &skip); |
| 1845 __ mov(ContextOperand(ecx, slot->index()), eax); | 1854 __ mov(ContextOperand(ecx, slot->index()), eax); |
| 1846 int offset = Context::SlotOffset(slot->index()); | 1855 int offset = Context::SlotOffset(slot->index()); |
| 1847 __ mov(edx, eax); // Preserve the stored value in eax. | 1856 __ mov(edx, eax); // Preserve the stored value in eax. |
| 1848 __ RecordWrite(ecx, offset, edx, ebx, kDontSaveFPRegs); | 1857 __ RecordWriteContextSlot(ecx, offset, edx, ebx, kDontSaveFPRegs); |
| 1849 break; | 1858 break; |
| 1850 } | 1859 } |
| 1851 case Slot::LOOKUP: | 1860 case Slot::LOOKUP: |
| 1852 __ push(eax); | 1861 __ push(eax); |
| 1853 __ push(esi); | 1862 __ push(esi); |
| 1854 __ push(Immediate(var->name())); | 1863 __ push(Immediate(var->name())); |
| 1855 __ CallRuntime(Runtime::kInitializeConstContextSlot, 3); | 1864 __ CallRuntime(Runtime::kInitializeConstContextSlot, 3); |
| 1856 break; | 1865 break; |
| 1857 } | 1866 } |
| 1858 __ bind(&skip); | 1867 __ bind(&skip); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1870 | 1879 |
| 1871 case Slot::CONTEXT: { | 1880 case Slot::CONTEXT: { |
| 1872 MemOperand target = EmitSlotSearch(slot, ecx); | 1881 MemOperand target = EmitSlotSearch(slot, ecx); |
| 1873 // Perform the assignment and issue the write barrier. | 1882 // Perform the assignment and issue the write barrier. |
| 1874 __ mov(target, eax); | 1883 __ mov(target, eax); |
| 1875 | 1884 |
| 1876 // The value of the assignment is in eax. RecordWrite clobbers its | 1885 // The value of the assignment is in eax. RecordWrite clobbers its |
| 1877 // register arguments. | 1886 // register arguments. |
| 1878 __ mov(edx, eax); | 1887 __ mov(edx, eax); |
| 1879 int offset = Context::SlotOffset(slot->index()); | 1888 int offset = Context::SlotOffset(slot->index()); |
| 1880 __ RecordWrite(ecx, offset, edx, ebx, kDontSaveFPRegs); | 1889 __ RecordWriteContextSlot(ecx, offset, edx, ebx, kDontSaveFPRegs); |
| 1881 break; | 1890 break; |
| 1882 } | 1891 } |
| 1883 | 1892 |
| 1884 case Slot::LOOKUP: | 1893 case Slot::LOOKUP: |
| 1885 // Call the runtime for the assignment. | 1894 // Call the runtime for the assignment. |
| 1886 __ push(eax); // Value. | 1895 __ push(eax); // Value. |
| 1887 __ push(esi); // Context. | 1896 __ push(esi); // Context. |
| 1888 __ push(Immediate(var->name())); | 1897 __ push(Immediate(var->name())); |
| 1889 __ push(Immediate(Smi::FromInt(strict_mode_flag()))); | 1898 __ push(Immediate(Smi::FromInt(strict_mode_flag()))); |
| 1890 __ CallRuntime(Runtime::kStoreContextSlot, 4); | 1899 __ CallRuntime(Runtime::kStoreContextSlot, 4); |
| (...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2801 // If the object is not a value type, return the value. | 2810 // If the object is not a value type, return the value. |
| 2802 __ CmpObjectType(ebx, JS_VALUE_TYPE, ecx); | 2811 __ CmpObjectType(ebx, JS_VALUE_TYPE, ecx); |
| 2803 __ j(not_equal, &done); | 2812 __ j(not_equal, &done); |
| 2804 | 2813 |
| 2805 // Store the value. | 2814 // Store the value. |
| 2806 __ mov(FieldOperand(ebx, JSValue::kValueOffset), eax); | 2815 __ mov(FieldOperand(ebx, JSValue::kValueOffset), eax); |
| 2807 | 2816 |
| 2808 // Update the write barrier. Save the value as it will be | 2817 // Update the write barrier. Save the value as it will be |
| 2809 // overwritten by the write barrier code and is needed afterward. | 2818 // overwritten by the write barrier code and is needed afterward. |
| 2810 __ mov(edx, eax); | 2819 __ mov(edx, eax); |
| 2811 __ RecordWrite(ebx, JSValue::kValueOffset, edx, ecx, kDontSaveFPRegs); | 2820 __ RecordWriteField(ebx, JSValue::kValueOffset, edx, ecx, kDontSaveFPRegs); |
| 2812 | 2821 |
| 2813 __ bind(&done); | 2822 __ bind(&done); |
| 2814 context()->Plug(eax); | 2823 context()->Plug(eax); |
| 2815 } | 2824 } |
| 2816 | 2825 |
| 2817 | 2826 |
| 2818 void FullCodeGenerator::EmitNumberToString(ZoneList<Expression*>* args) { | 2827 void FullCodeGenerator::EmitNumberToString(ZoneList<Expression*>* args) { |
| 2819 ASSERT_EQ(args->length(), 1); | 2828 ASSERT_EQ(args->length(), 1); |
| 2820 | 2829 |
| 2821 // Load the argument on the stack and call the stub. | 2830 // Load the argument on the stack and call the stub. |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3084 // Bring addresses into index1 and index2. | 3093 // Bring addresses into index1 and index2. |
| 3085 __ lea(index_1, CodeGenerator::FixedArrayElementOperand(elements, index_1)); | 3094 __ lea(index_1, CodeGenerator::FixedArrayElementOperand(elements, index_1)); |
| 3086 __ lea(index_2, CodeGenerator::FixedArrayElementOperand(elements, index_2)); | 3095 __ lea(index_2, CodeGenerator::FixedArrayElementOperand(elements, index_2)); |
| 3087 | 3096 |
| 3088 // Swap elements. Use object and temp as scratch registers. | 3097 // Swap elements. Use object and temp as scratch registers. |
| 3089 __ mov(object, Operand(index_1, 0)); | 3098 __ mov(object, Operand(index_1, 0)); |
| 3090 __ mov(temp, Operand(index_2, 0)); | 3099 __ mov(temp, Operand(index_2, 0)); |
| 3091 __ mov(Operand(index_2, 0), object); | 3100 __ mov(Operand(index_2, 0), object); |
| 3092 __ mov(Operand(index_1, 0), temp); | 3101 __ mov(Operand(index_1, 0), temp); |
| 3093 | 3102 |
| 3094 Label new_space; | 3103 NearLabel no_remembered_set; |
| 3095 __ InNewSpace(elements, temp, equal, &new_space); | 3104 __ InNewSpace(elements, temp, equal, &no_remembered_set); |
| 3105 __ HasScanOnScavenge(elements, temp, &no_remembered_set); |
| 3096 | 3106 |
| 3097 __ mov(object, elements); | 3107 __ mov(object, elements); |
| 3098 // Since we are swapping two objects, the incremental marker is not disturbed, | 3108 // Since we are swapping two objects, the incremental marker is not disturbed, |
| 3099 // so we don't call the stub that handles this. TODO(gc): Optimize by | 3109 // so we don't call the stub that handles this. TODO(gc): Optimize by |
| 3100 // checking the scan_on_scavenge flag, probably by calling the stub. | 3110 // checking the scan_on_scavenge flag, probably by calling the stub. |
| 3101 __ RememberedSetHelper(object, index_1, temp, kDontSaveFPRegs); | 3111 __ RememberedSetHelper(index_1, temp, kDontSaveFPRegs); |
| 3102 __ RememberedSetHelper(elements, index_2, temp, kDontSaveFPRegs); | 3112 __ RememberedSetHelper(index_2, temp, kDontSaveFPRegs); |
| 3103 | 3113 |
| 3104 __ bind(&new_space); | 3114 __ bind(&no_remembered_set); |
| 3105 | 3115 |
| 3106 // We are done. Drop elements from the stack, and return undefined. | 3116 // We are done. Drop elements from the stack, and return undefined. |
| 3107 __ add(Operand(esp), Immediate(3 * kPointerSize)); | 3117 __ add(Operand(esp), Immediate(3 * kPointerSize)); |
| 3108 __ mov(eax, Factory::undefined_value()); | 3118 __ mov(eax, Factory::undefined_value()); |
| 3109 __ jmp(&done); | 3119 __ jmp(&done); |
| 3110 | 3120 |
| 3111 __ bind(&slow_case); | 3121 __ bind(&slow_case); |
| 3112 __ CallRuntime(Runtime::kSwapElements, 3); | 3122 __ CallRuntime(Runtime::kSwapElements, 3); |
| 3113 | 3123 |
| 3114 __ bind(&done); | 3124 __ bind(&done); |
| (...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4268 // And return. | 4278 // And return. |
| 4269 __ ret(0); | 4279 __ ret(0); |
| 4270 } | 4280 } |
| 4271 | 4281 |
| 4272 | 4282 |
| 4273 #undef __ | 4283 #undef __ |
| 4274 | 4284 |
| 4275 } } // namespace v8::internal | 4285 } } // namespace v8::internal |
| 4276 | 4286 |
| 4277 #endif // V8_TARGET_ARCH_IA32 | 4287 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |