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/arm64/frames-arm64.h" | 7 #include "src/arm64/frames-arm64.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 // This simulates the initial call to bytecode handlers in interpreter entry | 1110 // This simulates the initial call to bytecode handlers in interpreter entry |
1111 // trampoline. The return will never actually be taken, but our stack walker | 1111 // trampoline. The return will never actually be taken, but our stack walker |
1112 // uses this address to determine whether a frame is interpreted. | 1112 // uses this address to determine whether a frame is interpreted. |
1113 __ LoadObject(lr, masm->isolate()->builtins()->InterpreterEntryTrampoline()); | 1113 __ LoadObject(lr, masm->isolate()->builtins()->InterpreterEntryTrampoline()); |
1114 | 1114 |
1115 Generate_EnterBytecodeDispatch(masm); | 1115 Generate_EnterBytecodeDispatch(masm); |
1116 } | 1116 } |
1117 | 1117 |
1118 | 1118 |
1119 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { | 1119 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { |
1120 // ----------- S t a t e ------------- | |
1121 // -- x3 : new target (preserved for callee) | |
1122 // -- x1 : target function (preserved for callee) | |
1123 // ----------------------------------- | |
1124 // First lookup code, maybe we don't need to compile! | |
1125 Label gotta_call_runtime; | |
1126 Label maybe_call_runtime; | |
1127 Label try_shared; | |
1128 Label loop_top, loop_bottom; | |
1129 | |
1130 Register closure = x1; | |
1131 Register new_target = x3; | |
1132 Register map = x0; | |
1133 Register index = x2; | |
1134 __ Ldr(map, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); | |
1135 __ Ldr(map, | |
1136 FieldMemOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset)); | |
1137 __ Ldrsw(index, UntagSmiFieldMemOperand(map, FixedArray::kLengthOffset)); | |
1138 __ Cmp(index, Operand(2)); | |
1139 __ B(lt, &gotta_call_runtime); | |
1140 | |
1141 // Find literals. | |
1142 // x3 : native context | |
1143 // x2 : length / index | |
1144 // x0 : optimized code map | |
1145 // stack[0] : new target | |
1146 // stack[4] : closure | |
1147 Register native_context = x4; | |
1148 __ Ldr(native_context, NativeContextMemOperand()); | |
1149 | |
1150 __ Bind(&loop_top); | |
1151 Register temp = x5; | |
1152 Register array_pointer = x6; | |
1153 | |
1154 // Does the native context match? | |
1155 __ Add(array_pointer, map, Operand(index, LSL, kPointerSizeLog2)); | |
1156 __ Ldr(temp, FieldMemOperand(array_pointer, | |
1157 SharedFunctionInfo::OffsetToPreviousContext())); | |
1158 __ Ldr(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); | |
1159 __ Cmp(temp, native_context); | |
1160 __ B(ne, &loop_bottom); | |
1161 // OSR id set to none? | |
1162 __ Ldr(temp, FieldMemOperand(array_pointer, | |
1163 SharedFunctionInfo::OffsetToPreviousOsrAstId())); | |
1164 const int bailout_id = BailoutId::None().ToInt(); | |
1165 __ Cmp(temp, Operand(Smi::FromInt(bailout_id))); | |
1166 __ B(ne, &loop_bottom); | |
1167 // Literals available? | |
1168 __ Ldr(temp, FieldMemOperand(array_pointer, | |
1169 SharedFunctionInfo::OffsetToPreviousLiterals())); | |
1170 __ Ldr(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); | |
1171 __ JumpIfSmi(temp, &gotta_call_runtime); | |
1172 | |
1173 // Save the literals in the closure. | |
1174 __ Str(temp, FieldMemOperand(closure, JSFunction::kLiteralsOffset)); | |
1175 __ RecordWriteField(closure, JSFunction::kLiteralsOffset, temp, x7, | |
1176 kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, | |
1177 OMIT_SMI_CHECK); | |
1178 | |
1179 // Code available? | |
1180 Register entry = x7; | |
1181 __ Ldr(entry, | |
1182 FieldMemOperand(array_pointer, | |
1183 SharedFunctionInfo::OffsetToPreviousCachedCode())); | |
1184 __ Ldr(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); | |
1185 __ JumpIfSmi(entry, &maybe_call_runtime); | |
1186 | |
1187 // Found literals and code. Get them into the closure and return. | |
1188 __ Add(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
1189 | |
1190 Label install_optimized_code_and_tailcall; | |
1191 __ Bind(&install_optimized_code_and_tailcall); | |
1192 __ Str(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset)); | |
1193 | |
1194 // Link the closure into the optimized function list. | |
1195 // x7 : code entry | |
1196 // x4 : native context | |
1197 // x1 : closure | |
1198 __ Ldr(x8, | |
1199 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); | |
1200 __ Str(x8, FieldMemOperand(closure, JSFunction::kNextFunctionLinkOffset)); | |
1201 __ RecordWriteField(closure, JSFunction::kNextFunctionLinkOffset, x8, x0, | |
1202 kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, | |
1203 OMIT_SMI_CHECK); | |
1204 const int function_list_offset = | |
1205 Context::SlotOffset(Context::OPTIMIZED_FUNCTIONS_LIST); | |
1206 __ Str(closure, | |
1207 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); | |
1208 __ Mov(x5, closure); | |
1209 __ RecordWriteContextSlot(native_context, function_list_offset, x5, x0, | |
1210 kLRHasNotBeenSaved, kDontSaveFPRegs); | |
1211 __ Jump(entry); | |
1212 | |
1213 __ Bind(&loop_bottom); | |
1214 __ Sub(index, index, Operand(SharedFunctionInfo::kEntryLength)); | |
1215 __ Cmp(index, Operand(1)); | |
1216 __ B(gt, &loop_top); | |
1217 | |
1218 // We found neither literals nor code. | |
1219 __ B(&gotta_call_runtime); | |
1220 | |
1221 __ Bind(&maybe_call_runtime); | |
1222 | |
1223 // Last possibility. Check the context free optimized code map entry. | |
1224 __ Ldr(entry, FieldMemOperand(map, FixedArray::kHeaderSize + | |
1225 SharedFunctionInfo::kSharedCodeIndex)); | |
1226 __ Ldr(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); | |
1227 __ JumpIfSmi(entry, &try_shared); | |
1228 | |
1229 // Store code entry in the closure. | |
1230 __ Add(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
1231 __ B(&install_optimized_code_and_tailcall); | |
1232 | |
1233 __ Bind(&try_shared); | |
1234 // Is the full code valid? | |
1235 __ Ldr(entry, | |
1236 FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); | |
1237 __ Ldr(entry, FieldMemOperand(entry, SharedFunctionInfo::kCodeOffset)); | |
1238 __ Ldr(x5, FieldMemOperand(entry, Code::kFlagsOffset)); | |
1239 __ and_(x5, x5, Operand(Code::KindField::kMask)); | |
1240 __ Mov(x5, Operand(x5, LSR, Code::KindField::kShift)); | |
1241 __ Cmp(x5, Operand(Code::BUILTIN)); | |
1242 __ B(eq, &gotta_call_runtime); | |
1243 // Yes, install the full code. | |
1244 __ Add(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
1245 __ Str(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset)); | |
1246 __ Jump(entry); | |
1247 | |
1248 __ Bind(&gotta_call_runtime); | |
1249 CallRuntimePassFunction(masm, Runtime::kCompileLazy); | 1120 CallRuntimePassFunction(masm, Runtime::kCompileLazy); |
1250 GenerateTailCallToReturnedCode(masm); | 1121 GenerateTailCallToReturnedCode(masm); |
1251 } | 1122 } |
1252 | 1123 |
1253 | 1124 |
1254 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { | 1125 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { |
1255 CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent); | 1126 CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent); |
1256 GenerateTailCallToReturnedCode(masm); | 1127 GenerateTailCallToReturnedCode(masm); |
1257 } | 1128 } |
1258 | 1129 |
(...skipping 1615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2874 } | 2745 } |
2875 } | 2746 } |
2876 | 2747 |
2877 | 2748 |
2878 #undef __ | 2749 #undef __ |
2879 | 2750 |
2880 } // namespace internal | 2751 } // namespace internal |
2881 } // namespace v8 | 2752 } // namespace v8 |
2882 | 2753 |
2883 #endif // V8_TARGET_ARCH_ARM | 2754 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |