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

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

Issue 1878063004: Revert of 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: 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
« no previous file with comments | « src/ia32/builtins-ia32.cc ('k') | src/mips64/builtins-mips64.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 #if V8_TARGET_ARCH_MIPS 5 #if V8_TARGET_ARCH_MIPS
6 6
7 #include "src/codegen.h" 7 #include "src/codegen.h"
8 #include "src/debug/debug.h" 8 #include "src/debug/debug.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/full-codegen/full-codegen.h" 10 #include "src/full-codegen/full-codegen.h"
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 // This simulates the initial call to bytecode handlers in interpreter entry 1219 // This simulates the initial call to bytecode handlers in interpreter entry
1220 // trampoline. The return will never actually be taken, but our stack walker 1220 // trampoline. The return will never actually be taken, but our stack walker
1221 // uses this address to determine whether a frame is interpreted. 1221 // uses this address to determine whether a frame is interpreted.
1222 __ li(ra, Operand(masm->isolate()->builtins()->InterpreterEntryTrampoline())); 1222 __ li(ra, Operand(masm->isolate()->builtins()->InterpreterEntryTrampoline()));
1223 1223
1224 Generate_EnterBytecodeDispatch(masm); 1224 Generate_EnterBytecodeDispatch(masm);
1225 } 1225 }
1226 1226
1227 1227
1228 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { 1228 void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
1229 // ----------- S t a t e -------------
1230 // -- a0 : argument count (preserved for callee)
1231 // -- a3 : new target (preserved for callee)
1232 // -- a1 : target function (preserved for callee)
1233 // -----------------------------------
1234 // First lookup code, maybe we don't need to compile!
1235 Label gotta_call_runtime, gotta_call_runtime_no_stack;
1236 Label maybe_call_runtime;
1237 Label try_shared;
1238 Label loop_top, loop_bottom;
1239
1240 Register argument_count = a0;
1241 Register closure = a1;
1242 Register new_target = a3;
1243 __ push(argument_count);
1244 __ push(new_target);
1245 __ push(closure);
1246
1247 Register map = a0;
1248 Register index = a2;
1249 __ lw(map, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset));
1250 __ lw(map, FieldMemOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset));
1251 __ lw(index, FieldMemOperand(map, FixedArray::kLengthOffset));
1252 __ Branch(&gotta_call_runtime, lt, index, Operand(Smi::FromInt(2)));
1253
1254 // Find literals.
1255 // a3 : native context
1256 // a2 : length / index
1257 // a0 : optimized code map
1258 // stack[0] : new target
1259 // stack[4] : closure
1260 Register native_context = a3;
1261 __ lw(native_context, NativeContextMemOperand());
1262
1263 __ bind(&loop_top);
1264 Register temp = a1;
1265 Register array_pointer = t1;
1266
1267 // Does the native context match?
1268 __ sll(at, index, kPointerSizeLog2 - kSmiTagSize);
1269 __ Addu(array_pointer, map, Operand(at));
1270 __ lw(temp, FieldMemOperand(array_pointer,
1271 SharedFunctionInfo::kOffsetToPreviousContext));
1272 __ lw(temp, FieldMemOperand(temp, WeakCell::kValueOffset));
1273 __ Branch(&loop_bottom, ne, temp, Operand(native_context));
1274 // OSR id set to none?
1275 __ lw(temp, FieldMemOperand(array_pointer,
1276 SharedFunctionInfo::kOffsetToPreviousOsrAstId));
1277 const int bailout_id = BailoutId::None().ToInt();
1278 __ Branch(&loop_bottom, ne, temp, Operand(Smi::FromInt(bailout_id)));
1279 // Literals available?
1280 __ lw(temp, FieldMemOperand(array_pointer,
1281 SharedFunctionInfo::kOffsetToPreviousLiterals));
1282 __ lw(temp, FieldMemOperand(temp, WeakCell::kValueOffset));
1283 __ JumpIfSmi(temp, &gotta_call_runtime);
1284
1285 // Save the literals in the closure.
1286 __ lw(t0, MemOperand(sp, 0));
1287 __ sw(temp, FieldMemOperand(t0, JSFunction::kLiteralsOffset));
1288 __ push(index);
1289 __ RecordWriteField(t0, JSFunction::kLiteralsOffset, temp, index,
1290 kRAHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET,
1291 OMIT_SMI_CHECK);
1292 __ pop(index);
1293
1294 // Code available?
1295 Register entry = t0;
1296 __ lw(entry,
1297 FieldMemOperand(array_pointer,
1298 SharedFunctionInfo::kOffsetToPreviousCachedCode));
1299 __ lw(entry, FieldMemOperand(entry, WeakCell::kValueOffset));
1300 __ JumpIfSmi(entry, &maybe_call_runtime);
1301
1302 // Found literals and code. Get them into the closure and return.
1303 __ pop(closure);
1304 // Store code entry in the closure.
1305 __ Addu(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag));
1306
1307 Label install_optimized_code_and_tailcall;
1308 __ bind(&install_optimized_code_and_tailcall);
1309 __ sw(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset));
1310 __ RecordWriteCodeEntryField(closure, entry, t1);
1311
1312 // Link the closure into the optimized function list.
1313 // t0 : code entry
1314 // a3 : native context
1315 // a1 : closure
1316 __ lw(t1,
1317 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST));
1318 __ sw(t1, FieldMemOperand(closure, JSFunction::kNextFunctionLinkOffset));
1319 __ RecordWriteField(closure, JSFunction::kNextFunctionLinkOffset, t1, a0,
1320 kRAHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET,
1321 OMIT_SMI_CHECK);
1322 const int function_list_offset =
1323 Context::SlotOffset(Context::OPTIMIZED_FUNCTIONS_LIST);
1324 __ sw(closure,
1325 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST));
1326 // Save closure before the write barrier.
1327 __ mov(t1, closure);
1328 __ RecordWriteContextSlot(native_context, function_list_offset, closure, a0,
1329 kRAHasNotBeenSaved, kDontSaveFPRegs);
1330 __ mov(closure, t1);
1331 __ pop(new_target);
1332 __ pop(argument_count);
1333 __ Jump(entry);
1334
1335 __ bind(&loop_bottom);
1336 __ Subu(index, index,
1337 Operand(Smi::FromInt(SharedFunctionInfo::kEntryLength)));
1338 __ Branch(&loop_top, gt, index, Operand(Smi::FromInt(1)));
1339
1340 // We found neither literals nor code.
1341 __ jmp(&gotta_call_runtime);
1342
1343 __ bind(&maybe_call_runtime);
1344 __ pop(closure);
1345
1346 // Last possibility. Check the context free optimized code map entry.
1347 __ lw(entry, FieldMemOperand(map, FixedArray::kHeaderSize +
1348 SharedFunctionInfo::kSharedCodeIndex));
1349 __ lw(entry, FieldMemOperand(entry, WeakCell::kValueOffset));
1350 __ JumpIfSmi(entry, &try_shared);
1351
1352 // Store code entry in the closure.
1353 __ Addu(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag));
1354 __ jmp(&install_optimized_code_and_tailcall);
1355
1356 __ bind(&try_shared);
1357 __ pop(new_target);
1358 __ pop(argument_count);
1359 // Is the full code valid?
1360 __ lw(entry, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset));
1361 __ lw(entry, FieldMemOperand(entry, SharedFunctionInfo::kCodeOffset));
1362 __ lw(t1, FieldMemOperand(entry, Code::kFlagsOffset));
1363 __ And(t1, t1, Operand(Code::KindField::kMask));
1364 __ srl(t1, t1, Code::KindField::kShift);
1365 __ Branch(&gotta_call_runtime_no_stack, eq, t1, Operand(Code::BUILTIN));
1366 // Yes, install the full code.
1367 __ Addu(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag));
1368 __ sw(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset));
1369 __ RecordWriteCodeEntryField(closure, entry, t1);
1370 __ Jump(entry);
1371
1372 __ bind(&gotta_call_runtime);
1373 __ pop(closure);
1374 __ pop(new_target);
1375 __ pop(argument_count);
1376 __ bind(&gotta_call_runtime_no_stack);
1377 GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); 1229 GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy);
1378 } 1230 }
1379 1231
1380 1232
1381 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { 1233 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) {
1382 GenerateTailCallToReturnedCode(masm, 1234 GenerateTailCallToReturnedCode(masm,
1383 Runtime::kCompileOptimized_NotConcurrent); 1235 Runtime::kCompileOptimized_NotConcurrent);
1384 } 1236 }
1385 1237
1386 1238
(...skipping 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after
2856 } 2708 }
2857 } 2709 }
2858 2710
2859 2711
2860 #undef __ 2712 #undef __
2861 2713
2862 } // namespace internal 2714 } // namespace internal
2863 } // namespace v8 2715 } // namespace v8
2864 2716
2865 #endif // V8_TARGET_ARCH_MIPS 2717 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/ia32/builtins-ia32.cc ('k') | src/mips64/builtins-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698