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_MIPS | 7 #if V8_TARGET_ARCH_MIPS |
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 5291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5302 __ TailCallRuntime(Runtime::kLoadGlobalViaContext, 2, 1); | 5302 __ TailCallRuntime(Runtime::kLoadGlobalViaContext, 2, 1); |
5303 } | 5303 } |
5304 | 5304 |
5305 | 5305 |
5306 void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { | 5306 void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { |
5307 Register context_reg = cp; | 5307 Register context_reg = cp; |
5308 Register slot_reg = a2; | 5308 Register slot_reg = a2; |
5309 Register name_reg = a3; | 5309 Register name_reg = a3; |
5310 Register value_reg = a0; | 5310 Register value_reg = a0; |
5311 Register cell_reg = t0; | 5311 Register cell_reg = t0; |
5312 Register cell_details_reg = t1; | 5312 Register cell_value_reg = t1; |
| 5313 Register cell_details_reg = t2; |
5313 Label fast_heapobject_case, fast_smi_case, slow_case; | 5314 Label fast_heapobject_case, fast_smi_case, slow_case; |
5314 | 5315 |
5315 if (FLAG_debug_code) { | 5316 if (FLAG_debug_code) { |
5316 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); | 5317 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); |
5317 __ Check(ne, kUnexpectedValue, value_reg, Operand(at)); | 5318 __ Check(ne, kUnexpectedValue, value_reg, Operand(at)); |
5318 __ AssertName(name_reg); | 5319 __ AssertName(name_reg); |
5319 } | 5320 } |
5320 | 5321 |
5321 // Go up context chain to the script context. | 5322 // Go up context chain to the script context. |
5322 for (int i = 0; i < depth(); ++i) { | 5323 for (int i = 0; i < depth(); ++i) { |
5323 __ lw(cell_reg, ContextOperand(context_reg, Context::PREVIOUS_INDEX)); | 5324 __ lw(cell_reg, ContextOperand(context_reg, Context::PREVIOUS_INDEX)); |
5324 context_reg = cell_reg; | 5325 context_reg = cell_reg; |
5325 } | 5326 } |
5326 | 5327 |
5327 // Load the PropertyCell at the specified slot. | 5328 // Load the PropertyCell at the specified slot. |
5328 __ sll(at, slot_reg, kPointerSizeLog2); | 5329 __ sll(at, slot_reg, kPointerSizeLog2); |
5329 __ Addu(at, at, Operand(context_reg)); | 5330 __ Addu(at, at, Operand(context_reg)); |
5330 __ Addu(at, at, Context::SlotOffset(0)); | 5331 __ Addu(at, at, Context::SlotOffset(0)); |
5331 __ lw(cell_reg, MemOperand(at)); | 5332 __ lw(cell_reg, MemOperand(at)); |
5332 | 5333 |
| 5334 // Check that cell value is not the_hole. |
| 5335 __ lw(cell_value_reg, FieldMemOperand(cell_reg, PropertyCell::kValueOffset)); |
| 5336 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); |
| 5337 __ Branch(&slow_case, eq, cell_value_reg, Operand(at)); |
| 5338 |
5333 // Load PropertyDetails for the cell (actually only the cell_type and kind). | 5339 // Load PropertyDetails for the cell (actually only the cell_type and kind). |
5334 __ lw(cell_details_reg, | 5340 __ lw(cell_details_reg, |
5335 FieldMemOperand(cell_reg, PropertyCell::kDetailsOffset)); | 5341 FieldMemOperand(cell_reg, PropertyCell::kDetailsOffset)); |
5336 __ SmiUntag(cell_details_reg); | 5342 __ SmiUntag(cell_details_reg); |
5337 __ And(cell_details_reg, cell_details_reg, | 5343 __ And(cell_details_reg, cell_details_reg, |
5338 PropertyDetails::PropertyCellTypeField::kMask | | 5344 PropertyDetails::PropertyCellTypeField::kMask | |
5339 PropertyDetails::KindField::kMask); | 5345 PropertyDetails::KindField::kMask); |
5340 | 5346 |
5341 // Check if PropertyCell holds mutable data. | 5347 // Check if PropertyCell holds mutable data. |
5342 Label not_mutable_data; | 5348 Label not_mutable_data; |
5343 __ Branch(¬_mutable_data, ne, cell_details_reg, | 5349 __ Branch(¬_mutable_data, ne, cell_details_reg, |
5344 Operand(PropertyDetails::PropertyCellTypeField::encode( | 5350 Operand(PropertyDetails::PropertyCellTypeField::encode( |
5345 PropertyCellType::kMutable) | | 5351 PropertyCellType::kMutable) | |
5346 PropertyDetails::KindField::encode(kData))); | 5352 PropertyDetails::KindField::encode(kData))); |
5347 __ JumpIfSmi(value_reg, &fast_smi_case); | 5353 __ JumpIfSmi(value_reg, &fast_smi_case); |
5348 __ bind(&fast_heapobject_case); | 5354 __ bind(&fast_heapobject_case); |
5349 __ sw(value_reg, FieldMemOperand(cell_reg, PropertyCell::kValueOffset)); | 5355 __ sw(value_reg, FieldMemOperand(cell_reg, PropertyCell::kValueOffset)); |
5350 __ RecordWriteField(cell_reg, PropertyCell::kValueOffset, value_reg, | 5356 __ RecordWriteField(cell_reg, PropertyCell::kValueOffset, value_reg, |
5351 cell_details_reg, kRAHasNotBeenSaved, kDontSaveFPRegs, | 5357 cell_details_reg, kRAHasNotBeenSaved, kDontSaveFPRegs, |
5352 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); | 5358 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
5353 // RecordWriteField clobbers the value register, so we need to reload. | 5359 // RecordWriteField clobbers the value register, so we need to reload. |
5354 __ lw(value_reg, FieldMemOperand(cell_reg, PropertyCell::kValueOffset)); | 5360 __ lw(value_reg, FieldMemOperand(cell_reg, PropertyCell::kValueOffset)); |
5355 __ Ret(); | 5361 __ Ret(); |
5356 __ bind(¬_mutable_data); | 5362 __ bind(¬_mutable_data); |
5357 | 5363 |
5358 // Check if PropertyCell value matches the new value (relevant for Constant, | 5364 // Check if PropertyCell value matches the new value (relevant for Constant, |
5359 // ConstantType and Undefined cells). | 5365 // ConstantType and Undefined cells). |
5360 Label not_same_value; | 5366 Label not_same_value; |
5361 __ lw(at, FieldMemOperand(cell_reg, PropertyCell::kValueOffset)); | 5367 __ Branch(¬_same_value, ne, value_reg, Operand(cell_value_reg)); |
5362 __ Branch(¬_same_value, ne, value_reg, Operand(at)); | |
5363 if (FLAG_debug_code) { | 5368 if (FLAG_debug_code) { |
5364 Label done; | 5369 Label done; |
5365 // This can only be true for Constant, ConstantType and Undefined cells, | 5370 // This can only be true for Constant, ConstantType and Undefined cells, |
5366 // because we never store the_hole via this stub. | 5371 // because we never store the_hole via this stub. |
5367 __ Branch(&done, eq, cell_details_reg, | 5372 __ Branch(&done, eq, cell_details_reg, |
5368 Operand(PropertyDetails::PropertyCellTypeField::encode( | 5373 Operand(PropertyDetails::PropertyCellTypeField::encode( |
5369 PropertyCellType::kConstant) | | 5374 PropertyCellType::kConstant) | |
5370 PropertyDetails::KindField::encode(kData))); | 5375 PropertyDetails::KindField::encode(kData))); |
5371 __ Branch(&done, eq, cell_details_reg, | 5376 __ Branch(&done, eq, cell_details_reg, |
5372 Operand(PropertyDetails::PropertyCellTypeField::encode( | 5377 Operand(PropertyDetails::PropertyCellTypeField::encode( |
(...skipping 10 matching lines...) Expand all Loading... |
5383 | 5388 |
5384 // Check if PropertyCell contains data with constant type. | 5389 // Check if PropertyCell contains data with constant type. |
5385 __ Branch(&slow_case, ne, cell_details_reg, | 5390 __ Branch(&slow_case, ne, cell_details_reg, |
5386 Operand(PropertyDetails::PropertyCellTypeField::encode( | 5391 Operand(PropertyDetails::PropertyCellTypeField::encode( |
5387 PropertyCellType::kConstantType) | | 5392 PropertyCellType::kConstantType) | |
5388 PropertyDetails::KindField::encode(kData))); | 5393 PropertyDetails::KindField::encode(kData))); |
5389 | 5394 |
5390 // Now either both old and new values must be SMIs or both must be heap | 5395 // Now either both old and new values must be SMIs or both must be heap |
5391 // objects with same map. | 5396 // objects with same map. |
5392 Label value_is_heap_object; | 5397 Label value_is_heap_object; |
5393 Register cell_value_reg = cell_details_reg; | |
5394 __ lw(cell_value_reg, FieldMemOperand(cell_reg, PropertyCell::kValueOffset)); | |
5395 __ JumpIfNotSmi(value_reg, &value_is_heap_object); | 5398 __ JumpIfNotSmi(value_reg, &value_is_heap_object); |
5396 __ JumpIfNotSmi(cell_value_reg, &slow_case); | 5399 __ JumpIfNotSmi(cell_value_reg, &slow_case); |
5397 // Old and new values are SMIs, no need for a write barrier here. | 5400 // Old and new values are SMIs, no need for a write barrier here. |
5398 __ bind(&fast_smi_case); | 5401 __ bind(&fast_smi_case); |
5399 __ Ret(USE_DELAY_SLOT); | 5402 __ Ret(USE_DELAY_SLOT); |
5400 __ sw(value_reg, FieldMemOperand(cell_reg, PropertyCell::kValueOffset)); | 5403 __ sw(value_reg, FieldMemOperand(cell_reg, PropertyCell::kValueOffset)); |
5401 __ bind(&value_is_heap_object); | 5404 __ bind(&value_is_heap_object); |
5402 __ JumpIfSmi(cell_value_reg, &slow_case); | 5405 __ JumpIfSmi(cell_value_reg, &slow_case); |
5403 Register cell_value_map_reg = cell_value_reg; | 5406 Register cell_value_map_reg = cell_value_reg; |
5404 __ lw(cell_value_map_reg, | 5407 __ lw(cell_value_map_reg, |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5719 MemOperand(fp, 6 * kPointerSize), NULL); | 5722 MemOperand(fp, 6 * kPointerSize), NULL); |
5720 } | 5723 } |
5721 | 5724 |
5722 | 5725 |
5723 #undef __ | 5726 #undef __ |
5724 | 5727 |
5725 } // namespace internal | 5728 } // namespace internal |
5726 } // namespace v8 | 5729 } // namespace v8 |
5727 | 5730 |
5728 #endif // V8_TARGET_ARCH_MIPS | 5731 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |