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