Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(533)

Unified Diff: src/mips64/code-stubs-mips64.cc

Issue 1238143002: [stubs] Optimize LoadGlobalViaContextStub and StoreGlobalViaContextStub. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix ARM typo. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/mips64/code-stubs-mips64.cc
diff --git a/src/mips64/code-stubs-mips64.cc b/src/mips64/code-stubs-mips64.cc
index b04b04217afe3ad0660551db6894adba01d077a8..d8797ffab7895c77b54bf29eca1c4c77403d9458 100644
--- a/src/mips64/code-stubs-mips64.cc
+++ b/src/mips64/code-stubs-mips64.cc
@@ -5301,6 +5301,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.
+ __ dsll(at, slot_reg, kPointerSizeLog2);
+ __ Daddu(at, at, Operand(cp));
Igor Sheludko 2015/07/24 11:10:01 We should load the cell from context_reg context.
+ __ Daddu(at, at, Context::SlotOffset(0));
+ __ ld(result_reg, MemOperand(at));
+ __ ld(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 = a4;
+ Register cell_details_reg = a5;
+ 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) {
+ __ ld(cell_reg, ContextOperand(context_reg, Context::PREVIOUS_INDEX));
+ context_reg = cell_reg;
+ }
+
+ // Load the PropertyCell at the specified slot.
+ __ dsll(at, slot_reg, kPointerSizeLog2);
+ __ Daddu(at, at, Operand(cp));
Igor Sheludko 2015/07/24 11:10:01 Same here.
+ __ Daddu(at, at, Context::SlotOffset(0));
+ __ ld(cell_reg, MemOperand(at));
+
+ // Load PropertyDetails for the cell (actually only the cell_type and kind).
+ __ ld(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(&not_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);
+ __ sd(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.
+ __ Ret(USE_DELAY_SLOT);
+ __ ld(value_reg, FieldMemOperand(cell_reg, PropertyCell::kValueOffset));
+ __ bind(&not_mutable_data);
+
+ // Check if PropertyCell value matches the new value (relevant for Constant,
+ // ConstantType and Undefined cells).
+ Label not_same_value;
+ __ ld(at, FieldMemOperand(cell_reg, PropertyCell::kValueOffset));
+ __ Branch(&not_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(&not_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;
+ __ ld(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);
+ __ sd(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;
+ __ ld(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) {
int64_t offset = (ref0.address() - ref1.address());
DCHECK(static_cast<int>(offset) == offset);

Powered by Google App Engine
This is Rietveld 408576698