OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #if V8_TARGET_ARCH_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
(...skipping 4154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4165 DCHECK(expr->arguments()->length() == 0); | 4165 DCHECK(expr->arguments()->length() == 0); |
4166 ExternalReference debug_is_active = | 4166 ExternalReference debug_is_active = |
4167 ExternalReference::debug_is_active_address(isolate()); | 4167 ExternalReference::debug_is_active_address(isolate()); |
4168 __ Mov(x10, debug_is_active); | 4168 __ Mov(x10, debug_is_active); |
4169 __ Ldrb(x0, MemOperand(x10)); | 4169 __ Ldrb(x0, MemOperand(x10)); |
4170 __ SmiTag(x0); | 4170 __ SmiTag(x0); |
4171 context()->Plug(x0); | 4171 context()->Plug(x0); |
4172 } | 4172 } |
4173 | 4173 |
4174 | 4174 |
| 4175 void FullCodeGenerator::EmitCreateIterResultObject(CallRuntime* expr) { |
| 4176 ZoneList<Expression*>* args = expr->arguments(); |
| 4177 DCHECK_EQ(2, args->length()); |
| 4178 VisitForStackValue(args->at(0)); |
| 4179 VisitForStackValue(args->at(1)); |
| 4180 |
| 4181 Label runtime, done; |
| 4182 |
| 4183 Register result = x0; |
| 4184 __ Allocate(JSIteratorResult::kSize, result, x10, x11, &runtime, TAG_OBJECT); |
| 4185 Register map_reg = x1; |
| 4186 Register result_value = x2; |
| 4187 Register boolean_done = x3; |
| 4188 Register empty_fixed_array = x4; |
| 4189 Register untagged_result = x5; |
| 4190 __ Ldr(map_reg, GlobalObjectMemOperand()); |
| 4191 __ Ldr(map_reg, FieldMemOperand(map_reg, GlobalObject::kNativeContextOffset)); |
| 4192 __ Ldr(map_reg, |
| 4193 ContextMemOperand(map_reg, Context::ITERATOR_RESULT_MAP_INDEX)); |
| 4194 __ Pop(boolean_done); |
| 4195 __ Pop(result_value); |
| 4196 __ LoadRoot(empty_fixed_array, Heap::kEmptyFixedArrayRootIndex); |
| 4197 STATIC_ASSERT(JSObject::kPropertiesOffset + kPointerSize == |
| 4198 JSObject::kElementsOffset); |
| 4199 STATIC_ASSERT(JSIteratorResult::kValueOffset + kPointerSize == |
| 4200 JSIteratorResult::kDoneOffset); |
| 4201 __ ObjectUntag(untagged_result, result); |
| 4202 __ Str(map_reg, MemOperand(untagged_result, HeapObject::kMapOffset)); |
| 4203 __ Stp(empty_fixed_array, empty_fixed_array, |
| 4204 MemOperand(untagged_result, JSObject::kPropertiesOffset)); |
| 4205 __ Stp(result_value, boolean_done, |
| 4206 MemOperand(untagged_result, JSIteratorResult::kValueOffset)); |
| 4207 STATIC_ASSERT(JSIteratorResult::kSize == 5 * kPointerSize); |
| 4208 __ B(&done); |
| 4209 |
| 4210 __ Bind(&runtime); |
| 4211 __ CallRuntime(Runtime::kCreateIterResultObject, 2); |
| 4212 |
| 4213 __ Bind(&done); |
| 4214 context()->Plug(x0); |
| 4215 } |
| 4216 |
| 4217 |
4175 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { | 4218 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { |
4176 // Push undefined as the receiver. | 4219 // Push undefined as the receiver. |
4177 __ LoadRoot(x0, Heap::kUndefinedValueRootIndex); | 4220 __ LoadRoot(x0, Heap::kUndefinedValueRootIndex); |
4178 __ Push(x0); | 4221 __ Push(x0); |
4179 | 4222 |
4180 __ Ldr(x0, GlobalObjectMemOperand()); | 4223 __ Ldr(x0, GlobalObjectMemOperand()); |
4181 __ Ldr(x0, FieldMemOperand(x0, GlobalObject::kNativeContextOffset)); | 4224 __ Ldr(x0, FieldMemOperand(x0, GlobalObject::kNativeContextOffset)); |
4182 __ Ldr(x0, ContextMemOperand(x0, expr->context_index())); | 4225 __ Ldr(x0, ContextMemOperand(x0, expr->context_index())); |
4183 } | 4226 } |
4184 | 4227 |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5078 __ CallRuntime(Runtime::kResumeJSGeneratorObject, 3); | 5121 __ CallRuntime(Runtime::kResumeJSGeneratorObject, 3); |
5079 // Not reached: the runtime call returns elsewhere. | 5122 // Not reached: the runtime call returns elsewhere. |
5080 __ Unreachable(); | 5123 __ Unreachable(); |
5081 | 5124 |
5082 __ Bind(&done); | 5125 __ Bind(&done); |
5083 context()->Plug(result_register()); | 5126 context()->Plug(result_register()); |
5084 } | 5127 } |
5085 | 5128 |
5086 | 5129 |
5087 void FullCodeGenerator::EmitCreateIteratorResult(bool done) { | 5130 void FullCodeGenerator::EmitCreateIteratorResult(bool done) { |
5088 Label gc_required; | 5131 Label allocate, done_allocate; |
5089 Label allocated; | |
5090 | |
5091 const int instance_size = 5 * kPointerSize; | |
5092 DCHECK_EQ(isolate()->native_context()->iterator_result_map()->instance_size(), | |
5093 instance_size); | |
5094 | 5132 |
5095 // Allocate and populate an object with this form: { value: VAL, done: DONE } | 5133 // Allocate and populate an object with this form: { value: VAL, done: DONE } |
5096 | 5134 |
5097 Register result = x0; | 5135 Register result = x0; |
5098 __ Allocate(instance_size, result, x10, x11, &gc_required, TAG_OBJECT); | 5136 __ Allocate(JSIteratorResult::kSize, result, x10, x11, &allocate, TAG_OBJECT); |
5099 __ B(&allocated); | 5137 __ B(&done_allocate); |
5100 | 5138 |
5101 __ Bind(&gc_required); | 5139 __ Bind(&allocate); |
5102 __ Push(Smi::FromInt(instance_size)); | 5140 __ Push(Smi::FromInt(JSIteratorResult::kSize)); |
5103 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); | 5141 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); |
5104 __ Ldr(context_register(), | |
5105 MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
5106 | 5142 |
5107 __ Bind(&allocated); | 5143 __ Bind(&done_allocate); |
5108 Register map_reg = x1; | 5144 Register map_reg = x1; |
5109 Register result_value = x2; | 5145 Register result_value = x2; |
5110 Register boolean_done = x3; | 5146 Register boolean_done = x3; |
5111 Register empty_fixed_array = x4; | 5147 Register empty_fixed_array = x4; |
5112 Register untagged_result = x5; | 5148 Register untagged_result = x5; |
5113 __ Ldr(map_reg, GlobalObjectMemOperand()); | 5149 __ Ldr(map_reg, GlobalObjectMemOperand()); |
5114 __ Ldr(map_reg, FieldMemOperand(map_reg, GlobalObject::kNativeContextOffset)); | 5150 __ Ldr(map_reg, FieldMemOperand(map_reg, GlobalObject::kNativeContextOffset)); |
5115 __ Ldr(map_reg, | 5151 __ Ldr(map_reg, |
5116 ContextMemOperand(map_reg, Context::ITERATOR_RESULT_MAP_INDEX)); | 5152 ContextMemOperand(map_reg, Context::ITERATOR_RESULT_MAP_INDEX)); |
5117 __ Pop(result_value); | 5153 __ Pop(result_value); |
5118 __ Mov(boolean_done, Operand(isolate()->factory()->ToBoolean(done))); | 5154 __ LoadRoot(boolean_done, |
5119 __ Mov(empty_fixed_array, Operand(isolate()->factory()->empty_fixed_array())); | 5155 done ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex); |
| 5156 __ LoadRoot(empty_fixed_array, Heap::kEmptyFixedArrayRootIndex); |
5120 STATIC_ASSERT(JSObject::kPropertiesOffset + kPointerSize == | 5157 STATIC_ASSERT(JSObject::kPropertiesOffset + kPointerSize == |
5121 JSObject::kElementsOffset); | 5158 JSObject::kElementsOffset); |
5122 STATIC_ASSERT(JSGeneratorObject::kResultValuePropertyOffset + kPointerSize == | 5159 STATIC_ASSERT(JSIteratorResult::kValueOffset + kPointerSize == |
5123 JSGeneratorObject::kResultDonePropertyOffset); | 5160 JSIteratorResult::kDoneOffset); |
5124 __ ObjectUntag(untagged_result, result); | 5161 __ ObjectUntag(untagged_result, result); |
5125 __ Str(map_reg, MemOperand(untagged_result, HeapObject::kMapOffset)); | 5162 __ Str(map_reg, MemOperand(untagged_result, HeapObject::kMapOffset)); |
5126 __ Stp(empty_fixed_array, empty_fixed_array, | 5163 __ Stp(empty_fixed_array, empty_fixed_array, |
5127 MemOperand(untagged_result, JSObject::kPropertiesOffset)); | 5164 MemOperand(untagged_result, JSObject::kPropertiesOffset)); |
5128 __ Stp(result_value, boolean_done, | 5165 __ Stp(result_value, boolean_done, |
5129 MemOperand(untagged_result, | 5166 MemOperand(untagged_result, JSIteratorResult::kValueOffset)); |
5130 JSGeneratorObject::kResultValuePropertyOffset)); | 5167 STATIC_ASSERT(JSIteratorResult::kSize == 5 * kPointerSize); |
5131 | |
5132 // Only the value field needs a write barrier, as the other values are in the | |
5133 // root set. | |
5134 __ RecordWriteField(result, JSGeneratorObject::kResultValuePropertyOffset, | |
5135 x10, x11, kLRHasBeenSaved, kDontSaveFPRegs); | |
5136 } | 5168 } |
5137 | 5169 |
5138 | 5170 |
5139 // TODO(all): I don't like this method. | 5171 // TODO(all): I don't like this method. |
5140 // It seems to me that in too many places x0 is used in place of this. | 5172 // It seems to me that in too many places x0 is used in place of this. |
5141 // Also, this function is not suitable for all places where x0 should be | 5173 // Also, this function is not suitable for all places where x0 should be |
5142 // abstracted (eg. when used as an argument). But some places assume that the | 5174 // abstracted (eg. when used as an argument). But some places assume that the |
5143 // first argument register is x0, and use this function instead. | 5175 // first argument register is x0, and use this function instead. |
5144 // Considering that most of the register allocation is hard-coded in the | 5176 // Considering that most of the register allocation is hard-coded in the |
5145 // FullCodeGen, that it is unlikely we will need to change it extensively, and | 5177 // FullCodeGen, that it is unlikely we will need to change it extensively, and |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5342 } | 5374 } |
5343 | 5375 |
5344 return INTERRUPT; | 5376 return INTERRUPT; |
5345 } | 5377 } |
5346 | 5378 |
5347 | 5379 |
5348 } // namespace internal | 5380 } // namespace internal |
5349 } // namespace v8 | 5381 } // namespace v8 |
5350 | 5382 |
5351 #endif // V8_TARGET_ARCH_ARM64 | 5383 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |