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

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

Issue 1245983003: ARM: [stubs] Optimize LoadGlobalViaContextStub and StoreGlobalViaContextStub (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/arm/full-codegen-arm.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_ARM 7 #if V8_TARGET_ARCH_ARM
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 5041 matching lines...) Expand 10 before | Expand all | Expand 10 after
5052 Label fast_elements_case; 5052 Label fast_elements_case;
5053 __ cmp(r3, Operand(FAST_ELEMENTS)); 5053 __ cmp(r3, Operand(FAST_ELEMENTS));
5054 __ b(eq, &fast_elements_case); 5054 __ b(eq, &fast_elements_case);
5055 GenerateCase(masm, FAST_HOLEY_ELEMENTS); 5055 GenerateCase(masm, FAST_HOLEY_ELEMENTS);
5056 5056
5057 __ bind(&fast_elements_case); 5057 __ bind(&fast_elements_case);
5058 GenerateCase(masm, FAST_ELEMENTS); 5058 GenerateCase(masm, FAST_ELEMENTS);
5059 } 5059 }
5060 5060
5061 5061
5062 void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) {
5063 Register context = cp;
5064 Register result = r0;
5065 Register slot = r2;
5066 Register name = r3;
5067 Label slow_case;
5068
5069 // Go up the context chain to the script context.
5070 for (int i = 0; i < depth(); ++i) {
5071 __ ldr(result, ContextOperand(context, Context::PREVIOUS_INDEX));
5072 context = result;
5073 }
5074
5075 // Load the PropertyCell value at the specified slot.
5076 __ add(result, context, Operand(slot, LSL, kPointerSizeLog2));
5077 __ ldr(result, ContextOperand(result));
5078 __ ldr(result, FieldMemOperand(result, PropertyCell::kValueOffset));
5079
5080 // If the result is not the_hole, return. Otherwise, handle in the runtime.
5081 __ CompareRoot(result, Heap::kTheHoleValueRootIndex);
5082 __ Ret(ne);
5083
5084 // Fallback to runtime.
5085 __ bind(&slow_case);
5086 __ SmiTag(slot);
5087 __ push(slot);
5088 __ push(name);
5089 __ TailCallRuntime(Runtime::kLoadGlobalViaContext, 2, 1);
5090 }
5091
5092
5093 void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) {
5094 Register value = r0;
5095 Register slot = r2;
5096 Register name = r3;
5097
5098 Register cell = r1;
5099 Register cell_details = r4;
5100 Register cell_value = r5;
5101 Register cell_value_map = r6;
5102 Register scratch = r9;
5103
5104 Register context = cp;
5105 Register context_temp = cell;
5106
5107 Label fast_case, slow_case;
5108
5109 if (FLAG_debug_code) {
5110 __ CompareRoot(value, Heap::kTheHoleValueRootIndex);
5111 __ Check(ne, kUnexpectedValue);
5112 __ AssertName(name);
5113 }
5114
5115 // Go up the context chain to the script context.
5116 for (int i = 0; i < depth(); i++) {
5117 __ ldr(context_temp, ContextOperand(context, Context::PREVIOUS_INDEX));
5118 context = context_temp;
5119 }
5120
5121 // Load the PropertyCell at the specified slot.
5122 __ add(cell, context, Operand(slot, LSL, kPointerSizeLog2));
5123 __ ldr(cell, ContextOperand(cell));
5124
5125 // Load PropertyDetails for the cell (actually only the cell_type and kind).
5126 __ ldr(cell_details, FieldMemOperand(cell, PropertyCell::kDetailsOffset));
5127 __ SmiUntag(cell_details);
5128 __ and_(cell_details, cell_details,
5129 Operand(PropertyDetails::PropertyCellTypeField::kMask |
5130 PropertyDetails::KindField::kMask));
5131
5132 // Check if PropertyCell holds mutable data.
5133 Label not_mutable_data;
5134 __ cmp(cell_details,
5135 Operand(PropertyDetails::PropertyCellTypeField::encode(
5136 PropertyCellType::kMutable) |
5137 PropertyDetails::KindField::encode(kData)));
5138 __ b(ne, &not_mutable_data);
5139
5140 __ bind(&fast_case);
5141 __ str(value, FieldMemOperand(cell, PropertyCell::kValueOffset));
5142 // RecordWriteField clobbers the value register, so we copy it before the
5143 // call.
5144 __ mov(r4, Operand(value));
5145 __ RecordWriteField(cell, PropertyCell::kValueOffset, r4, scratch,
5146 kLRHasNotBeenSaved, kDontSaveFPRegs);
5147 __ Ret();
5148
5149 __ bind(&not_mutable_data);
5150 // Check if PropertyCell value matches the new value (relevant for Constant
5151 // and ConstantType cells).
5152 Label not_same_value;
5153 __ ldr(cell_value, FieldMemOperand(cell, PropertyCell::kValueOffset));
5154 __ cmp(cell_value, value);
5155 __ b(ne, &not_same_value);
5156
5157 if (FLAG_debug_code) {
5158 Label done;
5159 // This can only be true for Constant and ConstantType cells, because we
5160 // next store the hole via this stub.
5161 __ cmp(cell_details,
5162 Operand(PropertyDetails::PropertyCellTypeField::encode(
5163 PropertyCellType::kConstant) |
5164 PropertyDetails::KindField::encode(kData)));
5165 __ b(eq, &done);
5166 __ cmp(cell_details,
5167 Operand(PropertyDetails::PropertyCellTypeField::encode(
5168 PropertyCellType::kConstantType) |
5169 PropertyDetails::KindField::encode(kData)));
5170 __ Check(eq, kUnexpectedValue);
5171 __ bind(&done);
5172 }
5173 __ Ret();
5174 __ bind(&not_same_value);
5175
5176 // Check if PropertyCell contains data with constant type.
5177 __ cmp(cell_details,
5178 Operand(PropertyDetails::PropertyCellTypeField::encode(
5179 PropertyCellType::kConstantType) |
5180 PropertyDetails::KindField::encode(kData)));
5181 __ b(ne, &slow_case);
5182
5183 // Now either both old and new values must be smis or both must be heap
5184 // objects with same map.
5185 Label value_is_heap_object;
5186 __ JumpIfNotSmi(value, &value_is_heap_object);
5187 __ JumpIfNotSmi(cell_value, &slow_case);
5188 // Old and new values are smis, no need for a write barrier here.
5189 __ str(value, FieldMemOperand(cell, PropertyCell::kValueOffset));
5190 __ Ret();
5191
5192 __ bind(&value_is_heap_object);
5193 __ JumpIfSmi(cell_value, &slow_case);
5194
5195 __ ldr(cell_value_map, FieldMemOperand(cell_value, HeapObject::kMapOffset));
5196 __ ldr(scratch, FieldMemOperand(value, HeapObject::kMapOffset));
5197 __ cmp(cell_value_map, scratch);
5198 __ b(eq, &fast_case);
5199
5200 // Fallback to runtime.
5201 __ bind(&slow_case);
5202 __ SmiTag(slot);
5203 __ push(slot);
5204 __ push(name);
5205 __ push(value);
5206 __ TailCallRuntime(is_strict(language_mode())
5207 ? Runtime::kStoreGlobalViaContext_Strict
5208 : Runtime::kStoreGlobalViaContext_Sloppy,
5209 3, 1);
5210 }
5211
5212
5062 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { 5213 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) {
5063 return ref0.address() - ref1.address(); 5214 return ref0.address() - ref1.address();
5064 } 5215 }
5065 5216
5066 5217
5067 // Calls an API function. Allocates HandleScope, extracts returned value 5218 // Calls an API function. Allocates HandleScope, extracts returned value
5068 // from handle and propagates exceptions. Restores context. stack_space 5219 // from handle and propagates exceptions. Restores context. stack_space
5069 // - space to be unwound on exit (includes the call JS arguments space and 5220 // - space to be unwound on exit (includes the call JS arguments space and
5070 // the additional space allocated for the fast call). 5221 // the additional space allocated for the fast call).
5071 static void CallApiFunctionAndReturn(MacroAssembler* masm, 5222 static void CallApiFunctionAndReturn(MacroAssembler* masm,
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
5374 MemOperand(fp, 6 * kPointerSize), NULL); 5525 MemOperand(fp, 6 * kPointerSize), NULL);
5375 } 5526 }
5376 5527
5377 5528
5378 #undef __ 5529 #undef __
5379 5530
5380 } // namespace internal 5531 } // namespace internal
5381 } // namespace v8 5532 } // namespace v8
5382 5533
5383 #endif // V8_TARGET_ARCH_ARM 5534 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm/full-codegen-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698