OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 5101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5112 GenerateCase(masm, FAST_HOLEY_ELEMENTS); | 5112 GenerateCase(masm, FAST_HOLEY_ELEMENTS); |
5113 | 5113 |
5114 __ bind(&fast_elements_case); | 5114 __ bind(&fast_elements_case); |
5115 GenerateCase(masm, FAST_ELEMENTS); | 5115 GenerateCase(masm, FAST_ELEMENTS); |
5116 } | 5116 } |
5117 | 5117 |
5118 | 5118 |
5119 void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { | 5119 void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { |
5120 Register context_reg = esi; | 5120 Register context_reg = esi; |
5121 Register slot_reg = ebx; | 5121 Register slot_reg = ebx; |
5122 Register name_reg = ecx; | |
5123 Register result_reg = eax; | 5122 Register result_reg = eax; |
5124 Label slow_case; | 5123 Label slow_case; |
5125 | 5124 |
5126 // Go up context chain to the script context. | 5125 // Go up context chain to the script context. |
5127 for (int i = 0; i < depth(); ++i) { | 5126 for (int i = 0; i < depth(); ++i) { |
5128 __ mov(result_reg, ContextOperand(context_reg, Context::PREVIOUS_INDEX)); | 5127 __ mov(result_reg, ContextOperand(context_reg, Context::PREVIOUS_INDEX)); |
5129 context_reg = result_reg; | 5128 context_reg = result_reg; |
5130 } | 5129 } |
5131 | 5130 |
5132 // Load the PropertyCell value at the specified slot. | 5131 // Load the PropertyCell value at the specified slot. |
5133 __ mov(result_reg, ContextOperand(context_reg, slot_reg)); | 5132 __ mov(result_reg, ContextOperand(context_reg, slot_reg)); |
5134 __ mov(result_reg, FieldOperand(result_reg, PropertyCell::kValueOffset)); | 5133 __ mov(result_reg, FieldOperand(result_reg, PropertyCell::kValueOffset)); |
5135 | 5134 |
5136 // Check that value is not the_hole. | 5135 // Check that value is not the_hole. |
5137 __ CompareRoot(result_reg, Heap::kTheHoleValueRootIndex); | 5136 __ CompareRoot(result_reg, Heap::kTheHoleValueRootIndex); |
5138 __ j(equal, &slow_case, Label::kNear); | 5137 __ j(equal, &slow_case, Label::kNear); |
5139 __ Ret(); | 5138 __ Ret(); |
5140 | 5139 |
5141 // Fallback to the runtime. | 5140 // Fallback to the runtime. |
5142 __ bind(&slow_case); | 5141 __ bind(&slow_case); |
5143 __ SmiTag(slot_reg); | 5142 __ SmiTag(slot_reg); |
5144 __ Pop(result_reg); // Pop return address. | 5143 __ Pop(result_reg); // Pop return address. |
5145 __ Push(slot_reg); | 5144 __ Push(slot_reg); |
5146 __ Push(name_reg); | |
5147 __ Push(result_reg); // Push return address. | 5145 __ Push(result_reg); // Push return address. |
5148 __ TailCallRuntime(Runtime::kLoadGlobalViaContext, 2, 1); | 5146 __ TailCallRuntime(Runtime::kLoadGlobalViaContext, 1, 1); |
5149 } | 5147 } |
5150 | 5148 |
5151 | 5149 |
5152 void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { | 5150 void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { |
5153 Register context_reg = esi; | 5151 Register context_reg = esi; |
5154 Register slot_reg = ebx; | 5152 Register slot_reg = ebx; |
5155 Register name_reg = ecx; | |
5156 Register value_reg = eax; | 5153 Register value_reg = eax; |
5157 Register cell_reg = edi; | 5154 Register cell_reg = edi; |
5158 Register cell_details_reg = edx; | 5155 Register cell_details_reg = edx; |
| 5156 Register cell_value_reg = ecx; |
5159 Label fast_heapobject_case, fast_smi_case, slow_case; | 5157 Label fast_heapobject_case, fast_smi_case, slow_case; |
5160 | 5158 |
5161 if (FLAG_debug_code) { | 5159 if (FLAG_debug_code) { |
5162 __ CompareRoot(value_reg, Heap::kTheHoleValueRootIndex); | 5160 __ CompareRoot(value_reg, Heap::kTheHoleValueRootIndex); |
5163 __ Check(not_equal, kUnexpectedValue); | 5161 __ Check(not_equal, kUnexpectedValue); |
5164 __ AssertName(name_reg); | |
5165 } | 5162 } |
5166 | 5163 |
5167 // Go up context chain to the script context. | 5164 // Go up context chain to the script context. |
5168 for (int i = 0; i < depth(); ++i) { | 5165 for (int i = 0; i < depth(); ++i) { |
5169 __ mov(cell_reg, ContextOperand(context_reg, Context::PREVIOUS_INDEX)); | 5166 __ mov(cell_reg, ContextOperand(context_reg, Context::PREVIOUS_INDEX)); |
5170 context_reg = cell_reg; | 5167 context_reg = cell_reg; |
5171 } | 5168 } |
5172 | 5169 |
5173 // Load the PropertyCell at the specified slot. | 5170 // Load the PropertyCell at the specified slot. |
5174 __ mov(cell_reg, ContextOperand(context_reg, slot_reg)); | 5171 __ mov(cell_reg, ContextOperand(context_reg, slot_reg)); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5233 // Check if PropertyCell contains data with constant type. | 5230 // Check if PropertyCell contains data with constant type. |
5234 __ cmp(cell_details_reg, | 5231 __ cmp(cell_details_reg, |
5235 Immediate(PropertyDetails::PropertyCellTypeField::encode( | 5232 Immediate(PropertyDetails::PropertyCellTypeField::encode( |
5236 PropertyCellType::kConstantType) | | 5233 PropertyCellType::kConstantType) | |
5237 PropertyDetails::KindField::encode(kData))); | 5234 PropertyDetails::KindField::encode(kData))); |
5238 __ j(not_equal, &slow_case, Label::kNear); | 5235 __ j(not_equal, &slow_case, Label::kNear); |
5239 | 5236 |
5240 // Now either both old and new values must be SMIs or both must be heap | 5237 // Now either both old and new values must be SMIs or both must be heap |
5241 // objects with same map. | 5238 // objects with same map. |
5242 Label value_is_heap_object; | 5239 Label value_is_heap_object; |
5243 Register cell_value_reg = cell_details_reg; | |
5244 __ mov(cell_value_reg, FieldOperand(cell_reg, PropertyCell::kValueOffset)); | 5240 __ mov(cell_value_reg, FieldOperand(cell_reg, PropertyCell::kValueOffset)); |
5245 __ JumpIfNotSmi(value_reg, &value_is_heap_object, Label::kNear); | 5241 __ JumpIfNotSmi(value_reg, &value_is_heap_object, Label::kNear); |
5246 __ JumpIfNotSmi(cell_value_reg, &slow_case, Label::kNear); | 5242 __ JumpIfNotSmi(cell_value_reg, &slow_case, Label::kNear); |
5247 // Old and new values are SMIs, no need for a write barrier here. | 5243 // Old and new values are SMIs, no need for a write barrier here. |
5248 __ bind(&fast_smi_case); | 5244 __ bind(&fast_smi_case); |
5249 __ mov(FieldOperand(cell_reg, PropertyCell::kValueOffset), value_reg); | 5245 __ mov(FieldOperand(cell_reg, PropertyCell::kValueOffset), value_reg); |
5250 __ Ret(); | 5246 __ Ret(); |
5251 __ bind(&value_is_heap_object); | 5247 __ bind(&value_is_heap_object); |
5252 __ JumpIfSmi(cell_value_reg, &slow_case, Label::kNear); | 5248 __ JumpIfSmi(cell_value_reg, &slow_case, Label::kNear); |
5253 Register cell_value_map_reg = cell_value_reg; | 5249 Register cell_value_map_reg = cell_value_reg; |
5254 __ mov(cell_value_map_reg, | 5250 __ mov(cell_value_map_reg, |
5255 FieldOperand(cell_value_reg, HeapObject::kMapOffset)); | 5251 FieldOperand(cell_value_reg, HeapObject::kMapOffset)); |
5256 __ cmp(cell_value_map_reg, FieldOperand(value_reg, HeapObject::kMapOffset)); | 5252 __ cmp(cell_value_map_reg, FieldOperand(value_reg, HeapObject::kMapOffset)); |
5257 __ j(equal, &fast_heapobject_case); | 5253 __ j(equal, &fast_heapobject_case); |
5258 | 5254 |
5259 // Fallback to the runtime. | 5255 // Fallback to the runtime. |
5260 __ bind(&slow_case); | 5256 __ bind(&slow_case); |
5261 __ SmiTag(slot_reg); | 5257 __ SmiTag(slot_reg); |
5262 __ Pop(cell_reg); // Pop return address. | 5258 __ Pop(cell_reg); // Pop return address. |
5263 __ Push(slot_reg); | 5259 __ Push(slot_reg); |
5264 __ Push(name_reg); | |
5265 __ Push(value_reg); | 5260 __ Push(value_reg); |
5266 __ Push(cell_reg); // Push return address. | 5261 __ Push(cell_reg); // Push return address. |
5267 __ TailCallRuntime(is_strict(language_mode()) | 5262 __ TailCallRuntime(is_strict(language_mode()) |
5268 ? Runtime::kStoreGlobalViaContext_Strict | 5263 ? Runtime::kStoreGlobalViaContext_Strict |
5269 : Runtime::kStoreGlobalViaContext_Sloppy, | 5264 : Runtime::kStoreGlobalViaContext_Sloppy, |
5270 3, 1); | 5265 2, 1); |
5271 } | 5266 } |
5272 | 5267 |
5273 | 5268 |
5274 // Generates an Operand for saving parameters after PrepareCallApiFunction. | 5269 // Generates an Operand for saving parameters after PrepareCallApiFunction. |
5275 static Operand ApiParameterOperand(int index) { | 5270 static Operand ApiParameterOperand(int index) { |
5276 return Operand(esp, index * kPointerSize); | 5271 return Operand(esp, index * kPointerSize); |
5277 } | 5272 } |
5278 | 5273 |
5279 | 5274 |
5280 // Prepares stack to put arguments (aligns and so on). Reserves | 5275 // Prepares stack to put arguments (aligns and so on). Reserves |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5654 Operand(ebp, 7 * kPointerSize), NULL); | 5649 Operand(ebp, 7 * kPointerSize), NULL); |
5655 } | 5650 } |
5656 | 5651 |
5657 | 5652 |
5658 #undef __ | 5653 #undef __ |
5659 | 5654 |
5660 } // namespace internal | 5655 } // namespace internal |
5661 } // namespace v8 | 5656 } // namespace v8 |
5662 | 5657 |
5663 #endif // V8_TARGET_ARCH_IA32 | 5658 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |