Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: src/ia32/full-codegen-ia32.cc

Issue 6824078: Move most of the incremental marking write barrier to generated code. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/disasm-ia32.cc ('k') | src/ia32/ic-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 Register scratch2) { 606 Register scratch2) {
602 ASSERT(dst->type() != Slot::LOOKUP); // Not yet implemented. 607 ASSERT(dst->type() != Slot::LOOKUP); // Not yet implemented.
603 ASSERT(!scratch1.is(src) && !scratch2.is(src)); 608 ASSERT(!scratch1.is(src) && !scratch2.is(src));
604 MemOperand location = EmitSlotSearch(dst, scratch1); 609 MemOperand location = EmitSlotSearch(dst, scratch1);
605 __ mov(location, src); 610 __ mov(location, src);
606 611
607 // Emit the write barrier code if the location is in the heap. 612 // Emit the write barrier code if the location is in the heap.
608 if (dst->type() == Slot::CONTEXT) { 613 if (dst->type() == Slot::CONTEXT) {
609 int offset = Context::SlotOffset(dst->index()); 614 int offset = Context::SlotOffset(dst->index());
610 ASSERT(!scratch1.is(esi) && !src.is(esi) && !scratch2.is(esi)); 615 ASSERT(!scratch1.is(esi) && !src.is(esi) && !scratch2.is(esi));
611 __ RecordWrite(scratch1, offset, src, scratch2, kDontSaveFPRegs); 616 __ RecordWriteContextSlot(scratch1, offset, src, scratch2, kDontSaveFPRegs);
612 } 617 }
613 } 618 }
614 619
615 620
616 void FullCodeGenerator::PrepareForBailoutBeforeSplit(State state, 621 void FullCodeGenerator::PrepareForBailoutBeforeSplit(State state,
617 bool should_normalize, 622 bool should_normalize,
618 Label* if_true, 623 Label* if_true,
619 Label* if_false) { 624 Label* if_false) {
620 // Only prepare for bailouts before splits if we're in a test 625 // Only prepare for bailouts before splits if we're in a test
621 // context. Otherwise, we let the Visit function deal with the 626 // context. Otherwise, we let the Visit function deal with the
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 } 680 }
676 if (mode == Variable::CONST) { 681 if (mode == Variable::CONST) {
677 __ mov(ContextOperand(esi, slot->index()), 682 __ mov(ContextOperand(esi, slot->index()),
678 Immediate(isolate()->factory()->the_hole_value())); 683 Immediate(isolate()->factory()->the_hole_value()));
679 // No write barrier since the hole value is in old space. 684 // No write barrier since the hole value is in old space.
680 } else if (function != NULL) { 685 } else if (function != NULL) {
681 VisitForAccumulatorValue(function); 686 VisitForAccumulatorValue(function);
682 __ mov(ContextOperand(esi, slot->index()), result_register()); 687 __ mov(ContextOperand(esi, slot->index()), result_register());
683 int offset = Context::SlotOffset(slot->index()); 688 int offset = Context::SlotOffset(slot->index());
684 __ mov(ebx, esi); 689 __ mov(ebx, esi);
685 __ RecordWrite(ebx, offset, result_register(), ecx, kDontSaveFPRegs); 690 __ RecordWriteContextSlot(ebx,
691 offset,
692 result_register(),
693 ecx,
694 kDontSaveFPRegs);
686 } 695 }
687 break; 696 break;
688 697
689 case Slot::LOOKUP: { 698 case Slot::LOOKUP: {
690 __ push(esi); 699 __ push(esi);
691 __ push(Immediate(variable->name())); 700 __ push(Immediate(variable->name()));
692 // Declaration nodes are always introduced in one of two modes. 701 // Declaration nodes are always introduced in one of two modes.
693 ASSERT(mode == Variable::VAR || mode == Variable::CONST); 702 ASSERT(mode == Variable::VAR || mode == Variable::CONST);
694 PropertyAttributes attr = (mode == Variable::VAR) ? NONE : READ_ONLY; 703 PropertyAttributes attr = (mode == Variable::VAR) ? NONE : READ_ONLY;
695 __ push(Immediate(Smi::FromInt(attr))); 704 __ push(Immediate(Smi::FromInt(attr)));
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 } 1479 }
1471 VisitForAccumulatorValue(subexpr); 1480 VisitForAccumulatorValue(subexpr);
1472 1481
1473 // Store the subexpression value in the array's elements. 1482 // Store the subexpression value in the array's elements.
1474 __ mov(ebx, Operand(esp, 0)); // Copy of array literal. 1483 __ mov(ebx, Operand(esp, 0)); // Copy of array literal.
1475 __ mov(ebx, FieldOperand(ebx, JSObject::kElementsOffset)); 1484 __ mov(ebx, FieldOperand(ebx, JSObject::kElementsOffset));
1476 int offset = FixedArray::kHeaderSize + (i * kPointerSize); 1485 int offset = FixedArray::kHeaderSize + (i * kPointerSize);
1477 __ mov(FieldOperand(ebx, offset), result_register()); 1486 __ mov(FieldOperand(ebx, offset), result_register());
1478 1487
1479 // Update the write barrier for the array store. 1488 // Update the write barrier for the array store.
1480 __ RecordWrite(ebx, offset, result_register(), ecx, kDontSaveFPRegs); 1489 __ RecordWriteField(ebx, offset, result_register(), ecx, kDontSaveFPRegs);
1481 1490
1482 PrepareForBailoutForId(expr->GetIdForElement(i), NO_REGISTERS); 1491 PrepareForBailoutForId(expr->GetIdForElement(i), NO_REGISTERS);
1483 } 1492 }
1484 1493
1485 if (result_saved) { 1494 if (result_saved) {
1486 context()->PlugTOS(); 1495 context()->PlugTOS();
1487 } else { 1496 } else {
1488 context()->Plug(eax); 1497 context()->Plug(eax);
1489 } 1498 }
1490 } 1499 }
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1848 __ mov(Operand(ebp, SlotOffset(slot)), eax); 1857 __ mov(Operand(ebp, SlotOffset(slot)), eax);
1849 break; 1858 break;
1850 case Slot::CONTEXT: { 1859 case Slot::CONTEXT: {
1851 __ mov(ecx, ContextOperand(esi, Context::FCONTEXT_INDEX)); 1860 __ mov(ecx, ContextOperand(esi, Context::FCONTEXT_INDEX));
1852 __ mov(edx, ContextOperand(ecx, slot->index())); 1861 __ mov(edx, ContextOperand(ecx, slot->index()));
1853 __ cmp(edx, isolate()->factory()->the_hole_value()); 1862 __ cmp(edx, isolate()->factory()->the_hole_value());
1854 __ j(not_equal, &skip); 1863 __ j(not_equal, &skip);
1855 __ mov(ContextOperand(ecx, slot->index()), eax); 1864 __ mov(ContextOperand(ecx, slot->index()), eax);
1856 int offset = Context::SlotOffset(slot->index()); 1865 int offset = Context::SlotOffset(slot->index());
1857 __ mov(edx, eax); // Preserve the stored value in eax. 1866 __ mov(edx, eax); // Preserve the stored value in eax.
1858 __ RecordWrite(ecx, offset, edx, ebx, kDontSaveFPRegs); 1867 __ RecordWriteContextSlot(ecx, offset, edx, ebx, kDontSaveFPRegs);
1859 break; 1868 break;
1860 } 1869 }
1861 case Slot::LOOKUP: 1870 case Slot::LOOKUP:
1862 __ push(eax); 1871 __ push(eax);
1863 __ push(esi); 1872 __ push(esi);
1864 __ push(Immediate(var->name())); 1873 __ push(Immediate(var->name()));
1865 __ CallRuntime(Runtime::kInitializeConstContextSlot, 3); 1874 __ CallRuntime(Runtime::kInitializeConstContextSlot, 3);
1866 break; 1875 break;
1867 } 1876 }
1868 __ bind(&skip); 1877 __ bind(&skip);
(...skipping 11 matching lines...) Expand all
1880 1889
1881 case Slot::CONTEXT: { 1890 case Slot::CONTEXT: {
1882 MemOperand target = EmitSlotSearch(slot, ecx); 1891 MemOperand target = EmitSlotSearch(slot, ecx);
1883 // Perform the assignment and issue the write barrier. 1892 // Perform the assignment and issue the write barrier.
1884 __ mov(target, eax); 1893 __ mov(target, eax);
1885 1894
1886 // The value of the assignment is in eax. RecordWrite clobbers its 1895 // The value of the assignment is in eax. RecordWrite clobbers its
1887 // register arguments. 1896 // register arguments.
1888 __ mov(edx, eax); 1897 __ mov(edx, eax);
1889 int offset = Context::SlotOffset(slot->index()); 1898 int offset = Context::SlotOffset(slot->index());
1890 __ RecordWrite(ecx, offset, edx, ebx, kDontSaveFPRegs); 1899 __ RecordWriteContextSlot(ecx, offset, edx, ebx, kDontSaveFPRegs);
1891 break; 1900 break;
1892 } 1901 }
1893 1902
1894 case Slot::LOOKUP: 1903 case Slot::LOOKUP:
1895 // Call the runtime for the assignment. 1904 // Call the runtime for the assignment.
1896 __ push(eax); // Value. 1905 __ push(eax); // Value.
1897 __ push(esi); // Context. 1906 __ push(esi); // Context.
1898 __ push(Immediate(var->name())); 1907 __ push(Immediate(var->name()));
1899 __ push(Immediate(Smi::FromInt(strict_mode_flag()))); 1908 __ push(Immediate(Smi::FromInt(strict_mode_flag())));
1900 __ CallRuntime(Runtime::kStoreContextSlot, 4); 1909 __ CallRuntime(Runtime::kStoreContextSlot, 4);
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
2815 // If the object is not a value type, return the value. 2824 // If the object is not a value type, return the value.
2816 __ CmpObjectType(ebx, JS_VALUE_TYPE, ecx); 2825 __ CmpObjectType(ebx, JS_VALUE_TYPE, ecx);
2817 __ j(not_equal, &done); 2826 __ j(not_equal, &done);
2818 2827
2819 // Store the value. 2828 // Store the value.
2820 __ mov(FieldOperand(ebx, JSValue::kValueOffset), eax); 2829 __ mov(FieldOperand(ebx, JSValue::kValueOffset), eax);
2821 2830
2822 // Update the write barrier. Save the value as it will be 2831 // Update the write barrier. Save the value as it will be
2823 // overwritten by the write barrier code and is needed afterward. 2832 // overwritten by the write barrier code and is needed afterward.
2824 __ mov(edx, eax); 2833 __ mov(edx, eax);
2825 __ RecordWrite(ebx, JSValue::kValueOffset, edx, ecx, kDontSaveFPRegs); 2834 __ RecordWriteField(ebx, JSValue::kValueOffset, edx, ecx, kDontSaveFPRegs);
2826 2835
2827 __ bind(&done); 2836 __ bind(&done);
2828 context()->Plug(eax); 2837 context()->Plug(eax);
2829 } 2838 }
2830 2839
2831 2840
2832 void FullCodeGenerator::EmitNumberToString(ZoneList<Expression*>* args) { 2841 void FullCodeGenerator::EmitNumberToString(ZoneList<Expression*>* args) {
2833 ASSERT_EQ(args->length(), 1); 2842 ASSERT_EQ(args->length(), 1);
2834 2843
2835 // Load the argument on the stack and call the stub. 2844 // Load the argument on the stack and call the stub.
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
3098 // Bring addresses into index1 and index2. 3107 // Bring addresses into index1 and index2.
3099 __ lea(index_1, CodeGenerator::FixedArrayElementOperand(elements, index_1)); 3108 __ lea(index_1, CodeGenerator::FixedArrayElementOperand(elements, index_1));
3100 __ lea(index_2, CodeGenerator::FixedArrayElementOperand(elements, index_2)); 3109 __ lea(index_2, CodeGenerator::FixedArrayElementOperand(elements, index_2));
3101 3110
3102 // Swap elements. Use object and temp as scratch registers. 3111 // Swap elements. Use object and temp as scratch registers.
3103 __ mov(object, Operand(index_1, 0)); 3112 __ mov(object, Operand(index_1, 0));
3104 __ mov(temp, Operand(index_2, 0)); 3113 __ mov(temp, Operand(index_2, 0));
3105 __ mov(Operand(index_2, 0), object); 3114 __ mov(Operand(index_2, 0), object);
3106 __ mov(Operand(index_1, 0), temp); 3115 __ mov(Operand(index_1, 0), temp);
3107 3116
3108 Label new_space; 3117 NearLabel no_remembered_set;
3109 __ InNewSpace(elements, temp, equal, &new_space); 3118 __ InNewSpace(elements, temp, equal, &no_remembered_set);
3119 __ HasScanOnScavenge(elements, temp, &no_remembered_set);
3110 3120
3111 __ mov(object, elements); 3121 __ mov(object, elements);
3112 // Since we are swapping two objects, the incremental marker is not disturbed, 3122 // Since we are swapping two objects, the incremental marker is not disturbed,
3113 // so we don't call the stub that handles this. TODO(gc): Optimize by 3123 // so we don't call the stub that handles this. TODO(gc): Optimize by
3114 // checking the scan_on_scavenge flag, probably by calling the stub. 3124 // checking the scan_on_scavenge flag, probably by calling the stub.
3115 __ RememberedSetHelper(object, index_1, temp, kDontSaveFPRegs); 3125 __ RememberedSetHelper(index_1, temp, kDontSaveFPRegs);
3116 __ RememberedSetHelper(elements, index_2, temp, kDontSaveFPRegs); 3126 __ RememberedSetHelper(index_2, temp, kDontSaveFPRegs);
3117 3127
3118 __ bind(&new_space); 3128 __ bind(&no_remembered_set);
3119 3129
3120 // We are done. Drop elements from the stack, and return undefined. 3130 // We are done. Drop elements from the stack, and return undefined.
3121 __ add(Operand(esp), Immediate(3 * kPointerSize)); 3131 __ add(Operand(esp), Immediate(3 * kPointerSize));
3122 __ mov(eax, isolate()->factory()->undefined_value()); 3132 __ mov(eax, isolate()->factory()->undefined_value());
3123 __ jmp(&done); 3133 __ jmp(&done);
3124 3134
3125 __ bind(&slow_case); 3135 __ bind(&slow_case);
3126 __ CallRuntime(Runtime::kSwapElements, 3); 3136 __ CallRuntime(Runtime::kSwapElements, 3);
3127 3137
3128 __ bind(&done); 3138 __ bind(&done);
(...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after
4285 // And return. 4295 // And return.
4286 __ ret(0); 4296 __ ret(0);
4287 } 4297 }
4288 4298
4289 4299
4290 #undef __ 4300 #undef __
4291 4301
4292 } } // namespace v8::internal 4302 } } // namespace v8::internal
4293 4303
4294 #endif // V8_TARGET_ARCH_IA32 4304 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/disasm-ia32.cc ('k') | src/ia32/ic-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698