| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 for (int i = 0; i < num_parameters; i++) { | 110 for (int i = 0; i < num_parameters; i++) { |
| 111 Slot* slot = scope()->parameter(i)->AsSlot(); | 111 Slot* slot = scope()->parameter(i)->AsSlot(); |
| 112 if (slot != NULL && slot->type() == Slot::CONTEXT) { | 112 if (slot != NULL && slot->type() == Slot::CONTEXT) { |
| 113 int parameter_offset = StandardFrameConstants::kCallerSPOffset + | 113 int parameter_offset = StandardFrameConstants::kCallerSPOffset + |
| 114 (num_parameters - 1 - i) * kPointerSize; | 114 (num_parameters - 1 - i) * kPointerSize; |
| 115 // Load parameter from stack. | 115 // Load parameter from stack. |
| 116 __ mov(eax, Operand(ebp, parameter_offset)); | 116 __ mov(eax, Operand(ebp, parameter_offset)); |
| 117 // Store it in the context. | 117 // Store it in the context. |
| 118 int context_offset = Context::SlotOffset(slot->index()); | 118 int context_offset = Context::SlotOffset(slot->index()); |
| 119 __ mov(Operand(esi, context_offset), eax); | 119 __ mov(Operand(esi, context_offset), eax); |
| 120 #ifdef ENABLE_CARDMARKING_WRITE_BARRIER |
| 120 // Update the write barrier. This clobbers all involved | 121 // Update the write barrier. This clobbers all involved |
| 121 // registers, so we have use a third register to avoid | 122 // registers, so we have use a third register to avoid |
| 122 // clobbering esi. | 123 // clobbering esi. |
| 123 __ mov(ecx, esi); | 124 __ mov(ecx, esi); |
| 124 __ RecordWrite(ecx, context_offset, eax, ebx); | 125 __ RecordWrite(ecx, context_offset, eax, ebx); |
| 126 #endif |
| 125 } | 127 } |
| 126 } | 128 } |
| 127 } | 129 } |
| 128 | 130 |
| 129 Variable* arguments = scope()->arguments(); | 131 Variable* arguments = scope()->arguments(); |
| 130 if (arguments != NULL) { | 132 if (arguments != NULL) { |
| 131 // Function uses arguments object. | 133 // Function uses arguments object. |
| 132 Comment cmnt(masm_, "[ Allocate arguments object"); | 134 Comment cmnt(masm_, "[ Allocate arguments object"); |
| 133 if (function_in_register) { | 135 if (function_in_register) { |
| 134 __ push(edi); | 136 __ push(edi); |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 | 537 |
| 536 | 538 |
| 537 void FullCodeGenerator::Move(Slot* dst, | 539 void FullCodeGenerator::Move(Slot* dst, |
| 538 Register src, | 540 Register src, |
| 539 Register scratch1, | 541 Register scratch1, |
| 540 Register scratch2) { | 542 Register scratch2) { |
| 541 ASSERT(dst->type() != Slot::LOOKUP); // Not yet implemented. | 543 ASSERT(dst->type() != Slot::LOOKUP); // Not yet implemented. |
| 542 ASSERT(!scratch1.is(src) && !scratch2.is(src)); | 544 ASSERT(!scratch1.is(src) && !scratch2.is(src)); |
| 543 MemOperand location = EmitSlotSearch(dst, scratch1); | 545 MemOperand location = EmitSlotSearch(dst, scratch1); |
| 544 __ mov(location, src); | 546 __ mov(location, src); |
| 547 |
| 548 #ifdef ENABLE_CARDMARKING_WRITE_BARRIER |
| 545 // Emit the write barrier code if the location is in the heap. | 549 // Emit the write barrier code if the location is in the heap. |
| 546 if (dst->type() == Slot::CONTEXT) { | 550 if (dst->type() == Slot::CONTEXT) { |
| 547 int offset = FixedArray::kHeaderSize + dst->index() * kPointerSize; | 551 int offset = FixedArray::kHeaderSize + dst->index() * kPointerSize; |
| 548 __ RecordWrite(scratch1, offset, src, scratch2); | 552 __ RecordWrite(scratch1, offset, src, scratch2); |
| 549 } | 553 } |
| 554 #endif |
| 550 } | 555 } |
| 551 | 556 |
| 552 | 557 |
| 553 void FullCodeGenerator::PrepareForBailoutBeforeSplit(State state, | 558 void FullCodeGenerator::PrepareForBailoutBeforeSplit(State state, |
| 554 bool should_normalize, | 559 bool should_normalize, |
| 555 Label* if_true, | 560 Label* if_true, |
| 556 Label* if_false) { | 561 Label* if_false) { |
| 557 // Only prepare for bailouts before splits if we're in a test | 562 // Only prepare for bailouts before splits if we're in a test |
| 558 // context. Otherwise, we let the Visit function deal with the | 563 // context. Otherwise, we let the Visit function deal with the |
| 559 // preparation to avoid preparing with the same AST id twice. | 564 // preparation to avoid preparing with the same AST id twice. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 __ cmp(ebx, Operand(esi)); | 613 __ cmp(ebx, Operand(esi)); |
| 609 __ Check(equal, "Unexpected declaration in current context."); | 614 __ Check(equal, "Unexpected declaration in current context."); |
| 610 } | 615 } |
| 611 if (mode == Variable::CONST) { | 616 if (mode == Variable::CONST) { |
| 612 __ mov(ContextOperand(esi, slot->index()), | 617 __ mov(ContextOperand(esi, slot->index()), |
| 613 Immediate(Factory::the_hole_value())); | 618 Immediate(Factory::the_hole_value())); |
| 614 // No write barrier since the hole value is in old space. | 619 // No write barrier since the hole value is in old space. |
| 615 } else if (function != NULL) { | 620 } else if (function != NULL) { |
| 616 VisitForAccumulatorValue(function); | 621 VisitForAccumulatorValue(function); |
| 617 __ mov(ContextOperand(esi, slot->index()), result_register()); | 622 __ mov(ContextOperand(esi, slot->index()), result_register()); |
| 623 #ifdef ENABLE_CARDMARKING_WRITE_BARRIER |
| 618 int offset = Context::SlotOffset(slot->index()); | 624 int offset = Context::SlotOffset(slot->index()); |
| 619 __ mov(ebx, esi); | 625 __ mov(ebx, esi); |
| 620 __ RecordWrite(ebx, offset, result_register(), ecx); | 626 __ RecordWrite(ebx, offset, result_register(), ecx); |
| 627 #endif |
| 621 } | 628 } |
| 622 break; | 629 break; |
| 623 | 630 |
| 624 case Slot::LOOKUP: { | 631 case Slot::LOOKUP: { |
| 625 __ push(esi); | 632 __ push(esi); |
| 626 __ push(Immediate(variable->name())); | 633 __ push(Immediate(variable->name())); |
| 627 // Declaration nodes are always introduced in one of two modes. | 634 // Declaration nodes are always introduced in one of two modes. |
| 628 ASSERT(mode == Variable::VAR || mode == Variable::CONST); | 635 ASSERT(mode == Variable::VAR || mode == Variable::CONST); |
| 629 PropertyAttributes attr = (mode == Variable::VAR) ? NONE : READ_ONLY; | 636 PropertyAttributes attr = (mode == Variable::VAR) ? NONE : READ_ONLY; |
| 630 __ push(Immediate(Smi::FromInt(attr))); | 637 __ push(Immediate(Smi::FromInt(attr))); |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1381 result_saved = true; | 1388 result_saved = true; |
| 1382 } | 1389 } |
| 1383 VisitForAccumulatorValue(subexpr); | 1390 VisitForAccumulatorValue(subexpr); |
| 1384 | 1391 |
| 1385 // Store the subexpression value in the array's elements. | 1392 // Store the subexpression value in the array's elements. |
| 1386 __ mov(ebx, Operand(esp, 0)); // Copy of array literal. | 1393 __ mov(ebx, Operand(esp, 0)); // Copy of array literal. |
| 1387 __ mov(ebx, FieldOperand(ebx, JSObject::kElementsOffset)); | 1394 __ mov(ebx, FieldOperand(ebx, JSObject::kElementsOffset)); |
| 1388 int offset = FixedArray::kHeaderSize + (i * kPointerSize); | 1395 int offset = FixedArray::kHeaderSize + (i * kPointerSize); |
| 1389 __ mov(FieldOperand(ebx, offset), result_register()); | 1396 __ mov(FieldOperand(ebx, offset), result_register()); |
| 1390 | 1397 |
| 1398 #ifdef ENABLE_CARDMARKING_WRITE_BARRIER |
| 1391 // Update the write barrier for the array store. | 1399 // Update the write barrier for the array store. |
| 1392 __ RecordWrite(ebx, offset, result_register(), ecx); | 1400 __ RecordWrite(ebx, offset, result_register(), ecx); |
| 1401 #endif |
| 1393 | 1402 |
| 1394 PrepareForBailoutForId(expr->GetIdForElement(i), NO_REGISTERS); | 1403 PrepareForBailoutForId(expr->GetIdForElement(i), NO_REGISTERS); |
| 1395 } | 1404 } |
| 1396 | 1405 |
| 1397 if (result_saved) { | 1406 if (result_saved) { |
| 1398 context()->PlugTOS(); | 1407 context()->PlugTOS(); |
| 1399 } else { | 1408 } else { |
| 1400 context()->Plug(eax); | 1409 context()->Plug(eax); |
| 1401 } | 1410 } |
| 1402 } | 1411 } |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1944 case Slot::CONTEXT: { | 1953 case Slot::CONTEXT: { |
| 1945 MemOperand target = EmitSlotSearch(slot, ecx); | 1954 MemOperand target = EmitSlotSearch(slot, ecx); |
| 1946 if (op == Token::INIT_CONST) { | 1955 if (op == Token::INIT_CONST) { |
| 1947 // Detect const reinitialization by checking for the hole value. | 1956 // Detect const reinitialization by checking for the hole value. |
| 1948 __ mov(edx, target); | 1957 __ mov(edx, target); |
| 1949 __ cmp(edx, Factory::the_hole_value()); | 1958 __ cmp(edx, Factory::the_hole_value()); |
| 1950 __ j(not_equal, &done); | 1959 __ j(not_equal, &done); |
| 1951 } | 1960 } |
| 1952 // Perform the assignment and issue the write barrier. | 1961 // Perform the assignment and issue the write barrier. |
| 1953 __ mov(target, eax); | 1962 __ mov(target, eax); |
| 1963 |
| 1964 #ifdef ENABLE_CARDMARKING_WRITE_BARRIER |
| 1954 // The value of the assignment is in eax. RecordWrite clobbers its | 1965 // The value of the assignment is in eax. RecordWrite clobbers its |
| 1955 // register arguments. | 1966 // register arguments. |
| 1956 __ mov(edx, eax); | 1967 __ mov(edx, eax); |
| 1957 int offset = FixedArray::kHeaderSize + slot->index() * kPointerSize; | 1968 int offset = FixedArray::kHeaderSize + slot->index() * kPointerSize; |
| 1958 __ RecordWrite(ecx, offset, edx, ebx); | 1969 __ RecordWrite(ecx, offset, edx, ebx); |
| 1970 #endif |
| 1959 break; | 1971 break; |
| 1960 } | 1972 } |
| 1961 | 1973 |
| 1962 case Slot::LOOKUP: | 1974 case Slot::LOOKUP: |
| 1963 // Call the runtime for the assignment. The runtime will ignore | 1975 // Call the runtime for the assignment. The runtime will ignore |
| 1964 // const reinitialization. | 1976 // const reinitialization. |
| 1965 __ push(eax); // Value. | 1977 __ push(eax); // Value. |
| 1966 __ push(esi); // Context. | 1978 __ push(esi); // Context. |
| 1967 __ push(Immediate(var->name())); | 1979 __ push(Immediate(var->name())); |
| 1968 if (op == Token::INIT_CONST) { | 1980 if (op == Token::INIT_CONST) { |
| (...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2835 // If the object is a smi, return the value. | 2847 // If the object is a smi, return the value. |
| 2836 __ test(ebx, Immediate(kSmiTagMask)); | 2848 __ test(ebx, Immediate(kSmiTagMask)); |
| 2837 __ j(zero, &done); | 2849 __ j(zero, &done); |
| 2838 | 2850 |
| 2839 // If the object is not a value type, return the value. | 2851 // If the object is not a value type, return the value. |
| 2840 __ CmpObjectType(ebx, JS_VALUE_TYPE, ecx); | 2852 __ CmpObjectType(ebx, JS_VALUE_TYPE, ecx); |
| 2841 __ j(not_equal, &done); | 2853 __ j(not_equal, &done); |
| 2842 | 2854 |
| 2843 // Store the value. | 2855 // Store the value. |
| 2844 __ mov(FieldOperand(ebx, JSValue::kValueOffset), eax); | 2856 __ mov(FieldOperand(ebx, JSValue::kValueOffset), eax); |
| 2857 |
| 2858 #ifdef ENABLE_CARDMARKING_WRITE_BARRIER |
| 2845 // Update the write barrier. Save the value as it will be | 2859 // Update the write barrier. Save the value as it will be |
| 2846 // overwritten by the write barrier code and is needed afterward. | 2860 // overwritten by the write barrier code and is needed afterward. |
| 2847 __ mov(edx, eax); | 2861 __ mov(edx, eax); |
| 2848 __ RecordWrite(ebx, JSValue::kValueOffset, edx, ecx); | 2862 __ RecordWrite(ebx, JSValue::kValueOffset, edx, ecx); |
| 2863 #endif |
| 2849 | 2864 |
| 2850 __ bind(&done); | 2865 __ bind(&done); |
| 2851 context()->Plug(eax); | 2866 context()->Plug(eax); |
| 2852 } | 2867 } |
| 2853 | 2868 |
| 2854 | 2869 |
| 2855 void FullCodeGenerator::EmitNumberToString(ZoneList<Expression*>* args) { | 2870 void FullCodeGenerator::EmitNumberToString(ZoneList<Expression*>* args) { |
| 2856 ASSERT_EQ(args->length(), 1); | 2871 ASSERT_EQ(args->length(), 1); |
| 2857 | 2872 |
| 2858 // Load the argument on the stack and call the stub. | 2873 // Load the argument on the stack and call the stub. |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3111 // Bring addresses into index1 and index2. | 3126 // Bring addresses into index1 and index2. |
| 3112 __ lea(index_1, CodeGenerator::FixedArrayElementOperand(elements, index_1)); | 3127 __ lea(index_1, CodeGenerator::FixedArrayElementOperand(elements, index_1)); |
| 3113 __ lea(index_2, CodeGenerator::FixedArrayElementOperand(elements, index_2)); | 3128 __ lea(index_2, CodeGenerator::FixedArrayElementOperand(elements, index_2)); |
| 3114 | 3129 |
| 3115 // Swap elements. Use object and temp as scratch registers. | 3130 // Swap elements. Use object and temp as scratch registers. |
| 3116 __ mov(object, Operand(index_1, 0)); | 3131 __ mov(object, Operand(index_1, 0)); |
| 3117 __ mov(temp, Operand(index_2, 0)); | 3132 __ mov(temp, Operand(index_2, 0)); |
| 3118 __ mov(Operand(index_2, 0), object); | 3133 __ mov(Operand(index_2, 0), object); |
| 3119 __ mov(Operand(index_1, 0), temp); | 3134 __ mov(Operand(index_1, 0), temp); |
| 3120 | 3135 |
| 3136 #ifdef ENABLE_CARDMARKING_WRITE_BARRIER |
| 3121 Label new_space; | 3137 Label new_space; |
| 3122 __ InNewSpace(elements, temp, equal, &new_space); | 3138 __ InNewSpace(elements, temp, equal, &new_space); |
| 3123 | 3139 |
| 3124 __ mov(object, elements); | 3140 __ mov(object, elements); |
| 3125 __ RecordWriteHelper(object, index_1, temp); | 3141 __ RecordWriteHelper(object, index_1, temp); |
| 3126 __ RecordWriteHelper(elements, index_2, temp); | 3142 __ RecordWriteHelper(elements, index_2, temp); |
| 3127 | 3143 |
| 3128 __ bind(&new_space); | 3144 __ bind(&new_space); |
| 3145 #endif |
| 3146 |
| 3129 // We are done. Drop elements from the stack, and return undefined. | 3147 // We are done. Drop elements from the stack, and return undefined. |
| 3130 __ add(Operand(esp), Immediate(3 * kPointerSize)); | 3148 __ add(Operand(esp), Immediate(3 * kPointerSize)); |
| 3131 __ mov(eax, Factory::undefined_value()); | 3149 __ mov(eax, Factory::undefined_value()); |
| 3132 __ jmp(&done); | 3150 __ jmp(&done); |
| 3133 | 3151 |
| 3134 __ bind(&slow_case); | 3152 __ bind(&slow_case); |
| 3135 __ CallRuntime(Runtime::kSwapElements, 3); | 3153 __ CallRuntime(Runtime::kSwapElements, 3); |
| 3136 | 3154 |
| 3137 __ bind(&done); | 3155 __ bind(&done); |
| 3138 context()->Plug(eax); | 3156 context()->Plug(eax); |
| (...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4174 // And return. | 4192 // And return. |
| 4175 __ ret(0); | 4193 __ ret(0); |
| 4176 } | 4194 } |
| 4177 | 4195 |
| 4178 | 4196 |
| 4179 #undef __ | 4197 #undef __ |
| 4180 | 4198 |
| 4181 } } // namespace v8::internal | 4199 } } // namespace v8::internal |
| 4182 | 4200 |
| 4183 #endif // V8_TARGET_ARCH_IA32 | 4201 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |