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

Side by Side Diff: src/x87/code-stubs-x87.cc

Issue 1258513003: X87: [stubs] Optimize LoadGlobalViaContextStub and StoreGlobalViaContextStub. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/x87/full-codegen-x87.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_X87 7 #if V8_TARGET_ARCH_X87
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 4763 matching lines...) Expand 10 before | Expand all | Expand 10 after
4774 Label fast_elements_case; 4774 Label fast_elements_case;
4775 __ cmp(ecx, Immediate(FAST_ELEMENTS)); 4775 __ cmp(ecx, Immediate(FAST_ELEMENTS));
4776 __ j(equal, &fast_elements_case); 4776 __ j(equal, &fast_elements_case);
4777 GenerateCase(masm, FAST_HOLEY_ELEMENTS); 4777 GenerateCase(masm, FAST_HOLEY_ELEMENTS);
4778 4778
4779 __ bind(&fast_elements_case); 4779 __ bind(&fast_elements_case);
4780 GenerateCase(masm, FAST_ELEMENTS); 4780 GenerateCase(masm, FAST_ELEMENTS);
4781 } 4781 }
4782 4782
4783 4783
4784 void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) {
4785 Register context_reg = esi;
4786 Register slot_reg = ebx;
4787 Register name_reg = ecx;
4788 Register result_reg = eax;
4789 Label slow_case;
4790
4791 // Go up context chain to the script context.
4792 for (int i = 0; i < depth(); ++i) {
4793 __ mov(result_reg, ContextOperand(context_reg, Context::PREVIOUS_INDEX));
4794 context_reg = result_reg;
4795 }
4796
4797 // Load the PropertyCell value at the specified slot.
4798 __ mov(result_reg, ContextOperand(context_reg, slot_reg));
4799 __ mov(result_reg, FieldOperand(result_reg, PropertyCell::kValueOffset));
4800
4801 // Check that value is not the_hole.
4802 __ CompareRoot(result_reg, Heap::kTheHoleValueRootIndex);
4803 __ j(equal, &slow_case, Label::kNear);
4804 __ Ret();
4805
4806 // Fallback to the runtime.
4807 __ bind(&slow_case);
4808 __ SmiTag(slot_reg);
4809 __ Pop(result_reg); // Pop return address.
4810 __ Push(slot_reg);
4811 __ Push(name_reg);
4812 __ Push(result_reg); // Push return address.
4813 __ TailCallRuntime(Runtime::kLoadGlobalViaContext, 2, 1);
4814 }
4815
4816
4817 void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) {
4818 Register context_reg = esi;
4819 Register slot_reg = ebx;
4820 Register name_reg = ecx;
4821 Register value_reg = eax;
4822 Register cell_reg = edi;
4823 Register cell_details_reg = edx;
4824 Label fast_heapobject_case, fast_smi_case, slow_case;
4825
4826 if (FLAG_debug_code) {
4827 __ CompareRoot(value_reg, Heap::kTheHoleValueRootIndex);
4828 __ Check(not_equal, kUnexpectedValue);
4829 __ AssertName(name_reg);
4830 }
4831
4832 // Go up context chain to the script context.
4833 for (int i = 0; i < depth(); ++i) {
4834 __ mov(cell_reg, ContextOperand(context_reg, Context::PREVIOUS_INDEX));
4835 context_reg = cell_reg;
4836 }
4837
4838 // Load the PropertyCell at the specified slot.
4839 __ mov(cell_reg, ContextOperand(context_reg, slot_reg));
4840
4841 // Load PropertyDetails for the cell (actually only the cell_type and kind).
4842 __ mov(cell_details_reg,
4843 FieldOperand(cell_reg, PropertyCell::kDetailsOffset));
4844 __ SmiUntag(cell_details_reg);
4845 __ and_(cell_details_reg,
4846 Immediate(PropertyDetails::PropertyCellTypeField::kMask |
4847 PropertyDetails::KindField::kMask));
4848
4849
4850 // Check if PropertyCell holds mutable data.
4851 Label not_mutable_data;
4852 __ cmp(cell_details_reg,
4853 Immediate(PropertyDetails::PropertyCellTypeField::encode(
4854 PropertyCellType::kMutable) |
4855 PropertyDetails::KindField::encode(kData)));
4856 __ j(not_equal, &not_mutable_data);
4857 __ JumpIfSmi(value_reg, &fast_smi_case);
4858 __ bind(&fast_heapobject_case);
4859 __ mov(FieldOperand(cell_reg, PropertyCell::kValueOffset), value_reg);
4860 __ RecordWriteField(cell_reg, PropertyCell::kValueOffset, value_reg,
4861 cell_details_reg, kDontSaveFPRegs, EMIT_REMEMBERED_SET,
4862 OMIT_SMI_CHECK);
4863 // RecordWriteField clobbers the value register, so we need to reload.
4864 __ mov(value_reg, FieldOperand(cell_reg, PropertyCell::kValueOffset));
4865 __ Ret();
4866 __ bind(&not_mutable_data);
4867
4868 // Check if PropertyCell value matches the new value (relevant for Constant,
4869 // ConstantType and Undefined cells).
4870 Label not_same_value;
4871 __ cmp(value_reg, FieldOperand(cell_reg, PropertyCell::kValueOffset));
4872 __ j(not_equal, &not_same_value,
4873 FLAG_debug_code ? Label::kFar : Label::kNear);
4874 if (FLAG_debug_code) {
4875 Label done;
4876 // This can only be true for Constant, ConstantType and Undefined cells,
4877 // because we never store the_hole via this stub.
4878 __ cmp(cell_details_reg,
4879 Immediate(PropertyDetails::PropertyCellTypeField::encode(
4880 PropertyCellType::kConstant) |
4881 PropertyDetails::KindField::encode(kData)));
4882 __ j(equal, &done);
4883 __ cmp(cell_details_reg,
4884 Immediate(PropertyDetails::PropertyCellTypeField::encode(
4885 PropertyCellType::kConstantType) |
4886 PropertyDetails::KindField::encode(kData)));
4887 __ j(equal, &done);
4888 __ cmp(cell_details_reg,
4889 Immediate(PropertyDetails::PropertyCellTypeField::encode(
4890 PropertyCellType::kUndefined) |
4891 PropertyDetails::KindField::encode(kData)));
4892 __ Check(equal, kUnexpectedValue);
4893 __ bind(&done);
4894 }
4895 __ Ret();
4896 __ bind(&not_same_value);
4897
4898 // Check if PropertyCell contains data with constant type.
4899 __ cmp(cell_details_reg,
4900 Immediate(PropertyDetails::PropertyCellTypeField::encode(
4901 PropertyCellType::kConstantType) |
4902 PropertyDetails::KindField::encode(kData)));
4903 __ j(not_equal, &slow_case, Label::kNear);
4904
4905 // Now either both old and new values must be SMIs or both must be heap
4906 // objects with same map.
4907 Label value_is_heap_object;
4908 Register cell_value_reg = cell_details_reg;
4909 __ mov(cell_value_reg, FieldOperand(cell_reg, PropertyCell::kValueOffset));
4910 __ JumpIfNotSmi(value_reg, &value_is_heap_object, Label::kNear);
4911 __ JumpIfNotSmi(cell_value_reg, &slow_case, Label::kNear);
4912 // Old and new values are SMIs, no need for a write barrier here.
4913 __ bind(&fast_smi_case);
4914 __ mov(FieldOperand(cell_reg, PropertyCell::kValueOffset), value_reg);
4915 __ Ret();
4916 __ bind(&value_is_heap_object);
4917 __ JumpIfSmi(cell_value_reg, &slow_case, Label::kNear);
4918 Register cell_value_map_reg = cell_value_reg;
4919 __ mov(cell_value_map_reg,
4920 FieldOperand(cell_value_reg, HeapObject::kMapOffset));
4921 __ cmp(cell_value_map_reg, FieldOperand(value_reg, HeapObject::kMapOffset));
4922 __ j(equal, &fast_heapobject_case);
4923
4924 // Fallback to the runtime.
4925 __ bind(&slow_case);
4926 __ SmiTag(slot_reg);
4927 __ Pop(cell_reg); // Pop return address.
4928 __ Push(slot_reg);
4929 __ Push(name_reg);
4930 __ Push(value_reg);
4931 __ Push(cell_reg); // Push return address.
4932 __ TailCallRuntime(is_strict(language_mode())
4933 ? Runtime::kStoreGlobalViaContext_Strict
4934 : Runtime::kStoreGlobalViaContext_Sloppy,
4935 3, 1);
4936 }
4937
4938
4784 // Generates an Operand for saving parameters after PrepareCallApiFunction. 4939 // Generates an Operand for saving parameters after PrepareCallApiFunction.
4785 static Operand ApiParameterOperand(int index) { 4940 static Operand ApiParameterOperand(int index) {
4786 return Operand(esp, index * kPointerSize); 4941 return Operand(esp, index * kPointerSize);
4787 } 4942 }
4788 4943
4789 4944
4790 // Prepares stack to put arguments (aligns and so on). Reserves 4945 // Prepares stack to put arguments (aligns and so on). Reserves
4791 // space for return value if needed (assumes the return value is a handle). 4946 // space for return value if needed (assumes the return value is a handle).
4792 // Arguments must be stored in ApiParameterOperand(0), ApiParameterOperand(1) 4947 // Arguments must be stored in ApiParameterOperand(0), ApiParameterOperand(1)
4793 // etc. Saves context (esi). If space was reserved for return value then 4948 // etc. Saves context (esi). If space was reserved for return value then
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
5164 Operand(ebp, 7 * kPointerSize), NULL); 5319 Operand(ebp, 7 * kPointerSize), NULL);
5165 } 5320 }
5166 5321
5167 5322
5168 #undef __ 5323 #undef __
5169 5324
5170 } // namespace internal 5325 } // namespace internal
5171 } // namespace v8 5326 } // namespace v8
5172 5327
5173 #endif // V8_TARGET_ARCH_X87 5328 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « no previous file | src/x87/full-codegen-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698