OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1330 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 1330 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
1331 | 1331 |
1332 // Pass the function to optimize as the argument to the on-stack | 1332 // Pass the function to optimize as the argument to the on-stack |
1333 // replacement runtime function. | 1333 // replacement runtime function. |
1334 { | 1334 { |
1335 FrameScope scope(masm, StackFrame::INTERNAL); | 1335 FrameScope scope(masm, StackFrame::INTERNAL); |
1336 __ push(eax); | 1336 __ push(eax); |
1337 __ CallRuntime(Runtime::kCompileForOnStackReplacement, 1); | 1337 __ CallRuntime(Runtime::kCompileForOnStackReplacement, 1); |
1338 } | 1338 } |
1339 | 1339 |
1340 // If the result was -1 it means that we couldn't optimize the | |
1341 // function. Just return and continue in the unoptimized version. | |
1342 Label skip; | 1340 Label skip; |
1343 __ cmp(eax, Immediate(Smi::FromInt(-1))); | 1341 // If the code object is null, just return to the unoptimized code. |
1342 __ cmp(eax, Immediate(0)); | |
1344 __ j(not_equal, &skip, Label::kNear); | 1343 __ j(not_equal, &skip, Label::kNear); |
1345 __ ret(0); | 1344 __ ret(0); |
1346 | 1345 |
1347 __ bind(&skip); | 1346 __ bind(&skip); |
1348 // Untag the AST id and push it on the stack. | |
1349 __ SmiUntag(eax); | |
1350 __ push(eax); | |
1351 | 1347 |
1352 // Generate the code for doing the frame-to-frame translation using | 1348 // Load deoptimization data from the code object. |
1353 // the deoptimizer infrastructure. | 1349 __ mov(ebx, Operand(eax, Code::kDeoptimizationDataOffset - kHeapObjectTag)); |
1354 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); | 1350 |
1355 generator.Generate(); | 1351 // Load the OSR entrypoint offset from the deoptimization data. |
1352 __ mov(ebx, Operand(ebx, FixedArray::kHeaderSize + | |
Michael Starzinger
2013/07/31 14:55:50
nit: Use the following instead, easier to read ...
| |
1353 DeoptimizationInputData::kOsrPcOffsetIndex * kPointerSize | |
1354 - kHeapObjectTag)); | |
1355 __ SmiUntag(ebx); | |
1356 | |
1357 // Compute the target address = code_obj + header_size + osr_offset | |
1358 __ lea(eax, Operand(eax, ebx, times_1, Code::kHeaderSize - kHeapObjectTag)); | |
1359 | |
1360 // Overwrite the return address on the stack. | |
1361 __ mov(Operand(esp, 0), eax); | |
1362 | |
1363 // And "return" to the OSR entry point of the function. | |
1364 __ ret(0); | |
1356 } | 1365 } |
1357 | 1366 |
1358 | 1367 |
1359 #undef __ | 1368 #undef __ |
1360 } | 1369 } |
1361 } // namespace v8::internal | 1370 } // namespace v8::internal |
1362 | 1371 |
1363 #endif // V8_TARGET_ARCH_IA32 | 1372 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |