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

Side by Side Diff: src/arm64/builtins-arm64.cc

Issue 1670143002: Visit the Optimized Code Map on first call rather than closure creation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix mips64 rebase error. Created 4 years, 8 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
OLDNEW
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 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 // This simulates the initial call to bytecode handlers in interpreter entry 1172 // This simulates the initial call to bytecode handlers in interpreter entry
1173 // trampoline. The return will never actually be taken, but our stack walker 1173 // trampoline. The return will never actually be taken, but our stack walker
1174 // uses this address to determine whether a frame is interpreted. 1174 // uses this address to determine whether a frame is interpreted.
1175 __ LoadObject(lr, masm->isolate()->builtins()->InterpreterEntryTrampoline()); 1175 __ LoadObject(lr, masm->isolate()->builtins()->InterpreterEntryTrampoline());
1176 1176
1177 Generate_EnterBytecodeDispatch(masm); 1177 Generate_EnterBytecodeDispatch(masm);
1178 } 1178 }
1179 1179
1180 1180
1181 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { 1181 void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
1182 // ----------- S t a t e -------------
1183 // -- x0 : argument count (preserved for callee)
1184 // -- x3 : new target (preserved for callee)
1185 // -- x1 : target function (preserved for callee)
1186 // -----------------------------------
1187 // First lookup code, maybe we don't need to compile!
1188 Label gotta_call_runtime;
1189 Label maybe_call_runtime;
1190 Label try_shared;
1191 Label loop_top, loop_bottom;
1192
1193 Register closure = x1;
1194 Register new_target = x3;
1195 Register map = x13;
1196 Register index = x2;
1197 __ Ldr(map, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset));
1198 __ Ldr(map,
1199 FieldMemOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset));
1200 __ Ldrsw(index, UntagSmiFieldMemOperand(map, FixedArray::kLengthOffset));
1201 __ Cmp(index, Operand(2));
1202 __ B(lt, &gotta_call_runtime);
1203
1204 // Find literals.
1205 // x3 : native context
1206 // x2 : length / index
1207 // x13 : optimized code map
1208 // stack[0] : new target
1209 // stack[4] : closure
1210 Register native_context = x4;
1211 __ Ldr(native_context, NativeContextMemOperand());
1212
1213 __ Bind(&loop_top);
1214 Register temp = x5;
1215 Register array_pointer = x6;
1216
1217 // Does the native context match?
1218 __ Add(array_pointer, map, Operand(index, LSL, kPointerSizeLog2));
1219 __ Ldr(temp, FieldMemOperand(array_pointer,
1220 SharedFunctionInfo::OffsetToPreviousContext()));
1221 __ Ldr(temp, FieldMemOperand(temp, WeakCell::kValueOffset));
1222 __ Cmp(temp, native_context);
1223 __ B(ne, &loop_bottom);
1224 // OSR id set to none?
1225 __ Ldr(temp, FieldMemOperand(array_pointer,
1226 SharedFunctionInfo::OffsetToPreviousOsrAstId()));
1227 const int bailout_id = BailoutId::None().ToInt();
1228 __ Cmp(temp, Operand(Smi::FromInt(bailout_id)));
1229 __ B(ne, &loop_bottom);
1230 // Literals available?
1231 __ Ldr(temp, FieldMemOperand(array_pointer,
1232 SharedFunctionInfo::OffsetToPreviousLiterals()));
1233 __ Ldr(temp, FieldMemOperand(temp, WeakCell::kValueOffset));
1234 __ JumpIfSmi(temp, &gotta_call_runtime);
1235
1236 // Save the literals in the closure.
1237 __ Str(temp, FieldMemOperand(closure, JSFunction::kLiteralsOffset));
1238 __ RecordWriteField(closure, JSFunction::kLiteralsOffset, temp, x7,
1239 kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET,
1240 OMIT_SMI_CHECK);
1241
1242 // Code available?
1243 Register entry = x7;
1244 __ Ldr(entry,
1245 FieldMemOperand(array_pointer,
1246 SharedFunctionInfo::OffsetToPreviousCachedCode()));
1247 __ Ldr(entry, FieldMemOperand(entry, WeakCell::kValueOffset));
1248 __ JumpIfSmi(entry, &maybe_call_runtime);
1249
1250 // Found literals and code. Get them into the closure and return.
1251 __ Add(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag));
1252
1253 Label install_optimized_code_and_tailcall;
1254 __ Bind(&install_optimized_code_and_tailcall);
1255 __ Str(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset));
1256 __ RecordWriteCodeEntryField(closure, entry, x5);
1257
1258 // Link the closure into the optimized function list.
1259 // x7 : code entry
1260 // x4 : native context
1261 // x1 : closure
1262 __ Ldr(x8,
1263 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST));
1264 __ Str(x8, FieldMemOperand(closure, JSFunction::kNextFunctionLinkOffset));
1265 __ RecordWriteField(closure, JSFunction::kNextFunctionLinkOffset, x8, x13,
1266 kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET,
1267 OMIT_SMI_CHECK);
1268 const int function_list_offset =
1269 Context::SlotOffset(Context::OPTIMIZED_FUNCTIONS_LIST);
1270 __ Str(closure,
1271 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST));
1272 __ Mov(x5, closure);
1273 __ RecordWriteContextSlot(native_context, function_list_offset, x5, x13,
1274 kLRHasNotBeenSaved, kDontSaveFPRegs);
1275 __ Jump(entry);
1276
1277 __ Bind(&loop_bottom);
1278 __ Sub(index, index, Operand(SharedFunctionInfo::kEntryLength));
1279 __ Cmp(index, Operand(1));
1280 __ B(gt, &loop_top);
1281
1282 // We found neither literals nor code.
1283 __ B(&gotta_call_runtime);
1284
1285 __ Bind(&maybe_call_runtime);
1286
1287 // Last possibility. Check the context free optimized code map entry.
1288 __ Ldr(entry, FieldMemOperand(map, FixedArray::kHeaderSize +
1289 SharedFunctionInfo::kSharedCodeIndex));
1290 __ Ldr(entry, FieldMemOperand(entry, WeakCell::kValueOffset));
1291 __ JumpIfSmi(entry, &try_shared);
1292
1293 // Store code entry in the closure.
1294 __ Add(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag));
1295 __ B(&install_optimized_code_and_tailcall);
1296
1297 __ Bind(&try_shared);
1298 // Is the full code valid?
1299 __ Ldr(entry,
1300 FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset));
1301 __ Ldr(entry, FieldMemOperand(entry, SharedFunctionInfo::kCodeOffset));
1302 __ Ldr(x5, FieldMemOperand(entry, Code::kFlagsOffset));
1303 __ and_(x5, x5, Operand(Code::KindField::kMask));
1304 __ Mov(x5, Operand(x5, LSR, Code::KindField::kShift));
1305 __ Cmp(x5, Operand(Code::BUILTIN));
1306 __ B(eq, &gotta_call_runtime);
1307 // Yes, install the full code.
1308 __ Add(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag));
1309 __ Str(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset));
1310 __ RecordWriteCodeEntryField(closure, entry, x5);
1311 __ Jump(entry);
1312
1313 __ Bind(&gotta_call_runtime);
1182 GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); 1314 GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy);
1183 } 1315 }
1184 1316
1185 1317
1186 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { 1318 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) {
1187 GenerateTailCallToReturnedCode(masm, 1319 GenerateTailCallToReturnedCode(masm,
1188 Runtime::kCompileOptimized_NotConcurrent); 1320 Runtime::kCompileOptimized_NotConcurrent);
1189 } 1321 }
1190 1322
1191 1323
(...skipping 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after
2760 } 2892 }
2761 } 2893 }
2762 2894
2763 2895
2764 #undef __ 2896 #undef __
2765 2897
2766 } // namespace internal 2898 } // namespace internal
2767 } // namespace v8 2899 } // namespace v8
2768 2900
2769 #endif // V8_TARGET_ARCH_ARM 2901 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/builtins-arm.cc ('k') | src/code-stubs.cc » ('j') | src/compiler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698