Index: src/mips/code-stubs-mips.cc |
diff --git a/src/mips/code-stubs-mips.cc b/src/mips/code-stubs-mips.cc |
index 6a3d1504358bbb73ffc53088b9d7abcd428023ed..272fedafe8b6746659147219fca607d26cc33ed0 100644 |
--- a/src/mips/code-stubs-mips.cc |
+++ b/src/mips/code-stubs-mips.cc |
@@ -5270,6 +5270,155 @@ void InternalArrayConstructorStub::Generate(MacroAssembler* masm) { |
} |
+void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { |
+ Register context_reg = cp; |
+ Register slot_reg = a2; |
+ Register name_reg = a3; |
+ Register result_reg = v0; |
+ Label slow_case; |
+ |
+ // Go up context chain to the script context. |
+ for (int i = 0; i < depth(); ++i) { |
+ __ lw(result_reg, ContextOperand(context_reg, Context::PREVIOUS_INDEX)); |
+ context_reg = result_reg; |
+ } |
+ |
+ // Load the PropertyCell value at the specified slot. |
+ __ sll(at, slot_reg, kPointerSizeLog2); |
+ __ Addu(at, at, Operand(cp)); |
Igor Sheludko
2015/07/24 11:10:01
We should load the cell from context_reg here.
|
+ __ Addu(at, at, Context::SlotOffset(0)); |
+ __ lw(result_reg, MemOperand(at)); |
+ __ lw(result_reg, FieldMemOperand(result_reg, PropertyCell::kValueOffset)); |
+ |
+ // Check that value is not the_hole. |
+ __ LoadRoot(at, Heap::kTheHoleValueRootIndex); |
+ __ Branch(&slow_case, eq, result_reg, Operand(at)); |
+ __ Ret(); |
+ |
+ // Fallback to the runtime. |
+ __ bind(&slow_case); |
+ __ SmiTag(slot_reg); |
+ __ Drop(1); // Pop return address. |
+ __ Push(slot_reg, name_reg, result_reg); |
+ __ TailCallRuntime(Runtime::kLoadGlobalViaContext, 2, 1); |
+} |
+ |
+ |
+void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { |
+ Register context_reg = cp; |
+ Register slot_reg = a2; |
+ Register name_reg = a3; |
+ Register value_reg = a0; |
+ Register cell_reg = t0; |
+ Register cell_details_reg = t1; |
+ Label fast_heapobject_case, fast_smi_case, slow_case; |
+ |
+ if (FLAG_debug_code) { |
+ __ LoadRoot(at, Heap::kTheHoleValueRootIndex); |
+ __ Check(ne, kUnexpectedValue, value_reg, Operand(at)); |
+ __ AssertName(name_reg); |
+ } |
+ |
+ // Go up context chain to the script context. |
+ for (int i = 0; i < depth(); ++i) { |
+ __ lw(cell_reg, ContextOperand(context_reg, Context::PREVIOUS_INDEX)); |
+ context_reg = cell_reg; |
+ } |
+ |
+ // Load the PropertyCell at the specified slot. |
+ __ sll(at, slot_reg, kPointerSizeLog2); |
+ __ Addu(at, at, Operand(cp)); |
Igor Sheludko
2015/07/24 11:10:01
Same here.
|
+ __ Addu(at, at, Context::SlotOffset(0)); |
+ __ lw(cell_reg, MemOperand(at)); |
+ |
+ // Load PropertyDetails for the cell (actually only the cell_type and kind). |
+ __ lw(cell_details_reg, |
+ FieldMemOperand(cell_reg, PropertyCell::kDetailsOffset)); |
+ __ SmiUntag(cell_details_reg); |
+ __ And(cell_details_reg, cell_details_reg, |
+ PropertyDetails::PropertyCellTypeField::kMask | |
+ PropertyDetails::KindField::kMask); |
+ |
+ // Check if PropertyCell holds mutable data. |
+ Label not_mutable_data; |
+ __ Branch(¬_mutable_data, ne, cell_details_reg, |
+ Operand(PropertyDetails::PropertyCellTypeField::encode( |
+ PropertyCellType::kMutable) | |
+ PropertyDetails::KindField::encode(kData))); |
+ __ JumpIfSmi(value_reg, &fast_smi_case); |
+ __ bind(&fast_heapobject_case); |
+ __ sw(value_reg, FieldMemOperand(cell_reg, PropertyCell::kValueOffset)); |
+ __ RecordWriteField(cell_reg, PropertyCell::kValueOffset, value_reg, |
+ cell_details_reg, kRAHasNotBeenSaved, kDontSaveFPRegs, |
+ EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
+ // RecordWriteField clobbers the value register, so we need to reload. |
+ __ lw(value_reg, FieldMemOperand(cell_reg, PropertyCell::kValueOffset)); |
+ __ Ret(); |
+ __ bind(¬_mutable_data); |
+ |
+ // Check if PropertyCell value matches the new value (relevant for Constant, |
+ // ConstantType and Undefined cells). |
+ Label not_same_value; |
+ __ lw(at, FieldMemOperand(cell_reg, PropertyCell::kValueOffset)); |
+ __ Branch(¬_same_value, ne, value_reg, Operand(at)); |
+ if (FLAG_debug_code) { |
+ Label done; |
+ // This can only be true for Constant, ConstantType and Undefined cells, |
+ // because we never store the_hole via this stub. |
+ __ Branch(&done, eq, cell_details_reg, |
+ Operand(PropertyDetails::PropertyCellTypeField::encode( |
+ PropertyCellType::kConstant) | |
+ PropertyDetails::KindField::encode(kData))); |
+ __ Branch(&done, eq, cell_details_reg, |
+ Operand(PropertyDetails::PropertyCellTypeField::encode( |
+ PropertyCellType::kConstantType) | |
+ PropertyDetails::KindField::encode(kData))); |
+ __ Check(eq, kUnexpectedValue, cell_details_reg, |
+ Operand(PropertyDetails::PropertyCellTypeField::encode( |
+ PropertyCellType::kUndefined) | |
+ PropertyDetails::KindField::encode(kData))); |
+ __ bind(&done); |
+ } |
+ __ Ret(); |
+ __ bind(¬_same_value); |
+ |
+ // Check if PropertyCell contains data with constant type. |
+ __ Branch(&slow_case, ne, cell_details_reg, |
+ Operand(PropertyDetails::PropertyCellTypeField::encode( |
+ PropertyCellType::kConstantType) | |
+ PropertyDetails::KindField::encode(kData))); |
+ |
+ // Now either both old and new values must be SMIs or both must be heap |
+ // objects with same map. |
+ Label value_is_heap_object; |
+ Register cell_value_reg = cell_details_reg; |
+ __ lw(cell_value_reg, FieldMemOperand(cell_reg, PropertyCell::kValueOffset)); |
+ __ JumpIfNotSmi(value_reg, &value_is_heap_object); |
+ __ JumpIfNotSmi(cell_value_reg, &slow_case); |
+ // Old and new values are SMIs, no need for a write barrier here. |
+ __ bind(&fast_smi_case); |
+ __ Ret(USE_DELAY_SLOT); |
+ __ sw(value_reg, FieldMemOperand(cell_reg, PropertyCell::kValueOffset)); |
+ __ bind(&value_is_heap_object); |
+ __ JumpIfSmi(cell_value_reg, &slow_case); |
+ Register cell_value_map_reg = cell_value_reg; |
+ __ lw(cell_value_map_reg, |
+ FieldMemOperand(cell_value_reg, HeapObject::kMapOffset)); |
+ __ Branch(&fast_heapobject_case, eq, cell_value_map_reg, |
+ FieldMemOperand(value_reg, HeapObject::kMapOffset)); |
+ |
+ // Fallback to the runtime. |
+ __ bind(&slow_case); |
+ __ SmiTag(slot_reg); |
+ __ Drop(1); // Pop return address. |
+ __ Push(slot_reg, name_reg, value_reg, cell_reg); |
+ __ TailCallRuntime(is_strict(language_mode()) |
+ ? Runtime::kStoreGlobalViaContext_Strict |
+ : Runtime::kStoreGlobalViaContext_Sloppy, |
+ 3, 1); |
+} |
+ |
+ |
static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { |
return ref0.address() - ref1.address(); |
} |