| 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)); |
| 5175 | 5172 |
| 5176 // Check that cell value is not the_hole. | 5173 // Check that cell value is not the_hole. |
| 5177 { | 5174 { |
| 5178 // TODO(bmeurer): use ecx (name_reg) when name parameter is removed. | |
| 5179 Register cell_value_reg = cell_details_reg; | |
| 5180 __ mov(cell_value_reg, FieldOperand(cell_reg, PropertyCell::kValueOffset)); | 5175 __ mov(cell_value_reg, FieldOperand(cell_reg, PropertyCell::kValueOffset)); |
| 5181 __ CompareRoot(cell_value_reg, Heap::kTheHoleValueRootIndex); | 5176 __ CompareRoot(cell_value_reg, Heap::kTheHoleValueRootIndex); |
| 5182 __ j(equal, &slow_case, FLAG_debug_code ? Label::kFar : Label::kNear); | 5177 __ j(equal, &slow_case, FLAG_debug_code ? Label::kFar : Label::kNear); |
| 5183 } | 5178 } |
| 5184 | 5179 |
| 5185 // Load PropertyDetails for the cell (actually only the cell_type and kind). | 5180 // Load PropertyDetails for the cell (actually only the cell_type and kind). |
| 5186 __ mov(cell_details_reg, | 5181 __ mov(cell_details_reg, |
| 5187 FieldOperand(cell_reg, PropertyCell::kDetailsOffset)); | 5182 FieldOperand(cell_reg, PropertyCell::kDetailsOffset)); |
| 5188 __ SmiUntag(cell_details_reg); | 5183 __ SmiUntag(cell_details_reg); |
| 5189 __ and_(cell_details_reg, | 5184 __ and_(cell_details_reg, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5242 // Check if PropertyCell contains data with constant type. | 5237 // Check if PropertyCell contains data with constant type. |
| 5243 __ cmp(cell_details_reg, | 5238 __ cmp(cell_details_reg, |
| 5244 Immediate(PropertyDetails::PropertyCellTypeField::encode( | 5239 Immediate(PropertyDetails::PropertyCellTypeField::encode( |
| 5245 PropertyCellType::kConstantType) | | 5240 PropertyCellType::kConstantType) | |
| 5246 PropertyDetails::KindField::encode(kData))); | 5241 PropertyDetails::KindField::encode(kData))); |
| 5247 __ j(not_equal, &slow_case, Label::kNear); | 5242 __ j(not_equal, &slow_case, Label::kNear); |
| 5248 | 5243 |
| 5249 // Now either both old and new values must be SMIs or both must be heap | 5244 // Now either both old and new values must be SMIs or both must be heap |
| 5250 // objects with same map. | 5245 // objects with same map. |
| 5251 Label value_is_heap_object; | 5246 Label value_is_heap_object; |
| 5252 // TODO(bmeurer): use ecx (name_reg) when name parameter is removed. | |
| 5253 Register cell_value_reg = cell_details_reg; | |
| 5254 __ mov(cell_value_reg, FieldOperand(cell_reg, PropertyCell::kValueOffset)); | 5247 __ mov(cell_value_reg, FieldOperand(cell_reg, PropertyCell::kValueOffset)); |
| 5255 __ JumpIfNotSmi(value_reg, &value_is_heap_object, Label::kNear); | 5248 __ JumpIfNotSmi(value_reg, &value_is_heap_object, Label::kNear); |
| 5256 __ JumpIfNotSmi(cell_value_reg, &slow_case, Label::kNear); | 5249 __ JumpIfNotSmi(cell_value_reg, &slow_case, Label::kNear); |
| 5257 // Old and new values are SMIs, no need for a write barrier here. | 5250 // Old and new values are SMIs, no need for a write barrier here. |
| 5258 __ bind(&fast_smi_case); | 5251 __ bind(&fast_smi_case); |
| 5259 __ mov(FieldOperand(cell_reg, PropertyCell::kValueOffset), value_reg); | 5252 __ mov(FieldOperand(cell_reg, PropertyCell::kValueOffset), value_reg); |
| 5260 __ Ret(); | 5253 __ Ret(); |
| 5261 __ bind(&value_is_heap_object); | 5254 __ bind(&value_is_heap_object); |
| 5262 __ JumpIfSmi(cell_value_reg, &slow_case, Label::kNear); | 5255 __ JumpIfSmi(cell_value_reg, &slow_case, Label::kNear); |
| 5263 Register cell_value_map_reg = cell_value_reg; | 5256 Register cell_value_map_reg = cell_value_reg; |
| 5264 __ mov(cell_value_map_reg, | 5257 __ mov(cell_value_map_reg, |
| 5265 FieldOperand(cell_value_reg, HeapObject::kMapOffset)); | 5258 FieldOperand(cell_value_reg, HeapObject::kMapOffset)); |
| 5266 __ cmp(cell_value_map_reg, FieldOperand(value_reg, HeapObject::kMapOffset)); | 5259 __ cmp(cell_value_map_reg, FieldOperand(value_reg, HeapObject::kMapOffset)); |
| 5267 __ j(equal, &fast_heapobject_case); | 5260 __ j(equal, &fast_heapobject_case); |
| 5268 | 5261 |
| 5269 // Fallback to the runtime. | 5262 // Fallback to the runtime. |
| 5270 __ bind(&slow_case); | 5263 __ bind(&slow_case); |
| 5271 __ SmiTag(slot_reg); | 5264 __ SmiTag(slot_reg); |
| 5272 __ Pop(cell_reg); // Pop return address. | 5265 __ Pop(cell_reg); // Pop return address. |
| 5273 __ Push(slot_reg); | 5266 __ Push(slot_reg); |
| 5274 __ Push(name_reg); | |
| 5275 __ Push(value_reg); | 5267 __ Push(value_reg); |
| 5276 __ Push(cell_reg); // Push return address. | 5268 __ Push(cell_reg); // Push return address. |
| 5277 __ TailCallRuntime(is_strict(language_mode()) | 5269 __ TailCallRuntime(is_strict(language_mode()) |
| 5278 ? Runtime::kStoreGlobalViaContext_Strict | 5270 ? Runtime::kStoreGlobalViaContext_Strict |
| 5279 : Runtime::kStoreGlobalViaContext_Sloppy, | 5271 : Runtime::kStoreGlobalViaContext_Sloppy, |
| 5280 3, 1); | 5272 2, 1); |
| 5281 } | 5273 } |
| 5282 | 5274 |
| 5283 | 5275 |
| 5284 // Generates an Operand for saving parameters after PrepareCallApiFunction. | 5276 // Generates an Operand for saving parameters after PrepareCallApiFunction. |
| 5285 static Operand ApiParameterOperand(int index) { | 5277 static Operand ApiParameterOperand(int index) { |
| 5286 return Operand(esp, index * kPointerSize); | 5278 return Operand(esp, index * kPointerSize); |
| 5287 } | 5279 } |
| 5288 | 5280 |
| 5289 | 5281 |
| 5290 // Prepares stack to put arguments (aligns and so on). Reserves | 5282 // Prepares stack to put arguments (aligns and so on). Reserves |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5664 Operand(ebp, 7 * kPointerSize), NULL); | 5656 Operand(ebp, 7 * kPointerSize), NULL); |
| 5665 } | 5657 } |
| 5666 | 5658 |
| 5667 | 5659 |
| 5668 #undef __ | 5660 #undef __ |
| 5669 | 5661 |
| 5670 } // namespace internal | 5662 } // namespace internal |
| 5671 } // namespace v8 | 5663 } // namespace v8 |
| 5672 | 5664 |
| 5673 #endif // V8_TARGET_ARCH_IA32 | 5665 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |