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 17 matching lines...) Expand all Loading... |
28 #include "v8.h" | 28 #include "v8.h" |
29 | 29 |
30 #if V8_TARGET_ARCH_IA32 | 30 #if V8_TARGET_ARCH_IA32 |
31 | 31 |
32 #include "ia32/lithium-codegen-ia32.h" | 32 #include "ia32/lithium-codegen-ia32.h" |
33 #include "ic.h" | 33 #include "ic.h" |
34 #include "code-stubs.h" | 34 #include "code-stubs.h" |
35 #include "deoptimizer.h" | 35 #include "deoptimizer.h" |
36 #include "stub-cache.h" | 36 #include "stub-cache.h" |
37 #include "codegen.h" | 37 #include "codegen.h" |
| 38 #include "hydrogen-osr.h" |
38 | 39 |
39 namespace v8 { | 40 namespace v8 { |
40 namespace internal { | 41 namespace internal { |
41 | 42 |
42 | 43 |
43 static SaveFPRegsMode GetSaveFPRegsMode() { | 44 static SaveFPRegsMode GetSaveFPRegsMode() { |
44 // We don't need to save floating point regs when generating the snapshot | 45 // We don't need to save floating point regs when generating the snapshot |
45 return CpuFeatures::IsSafeForSnapshot(SSE2) ? kSaveFPRegs : kDontSaveFPRegs; | 46 return CpuFeatures::IsSafeForSnapshot(SSE2) ? kSaveFPRegs : kDontSaveFPRegs; |
46 } | 47 } |
47 | 48 |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 // Trace the call. | 326 // Trace the call. |
326 if (FLAG_trace && info()->IsOptimizing()) { | 327 if (FLAG_trace && info()->IsOptimizing()) { |
327 // We have not executed any compiled code yet, so esi still holds the | 328 // We have not executed any compiled code yet, so esi still holds the |
328 // incoming context. | 329 // incoming context. |
329 __ CallRuntime(Runtime::kTraceEnter, 0); | 330 __ CallRuntime(Runtime::kTraceEnter, 0); |
330 } | 331 } |
331 return !is_aborted(); | 332 return !is_aborted(); |
332 } | 333 } |
333 | 334 |
334 | 335 |
| 336 void LCodeGen::GenerateOsrPrologue() { |
| 337 // Generate the OSR entry prologue at the first unknown OSR value, or if there |
| 338 // are none, at the OSR entrypoint instruction. |
| 339 if (osr_pc_offset_ >= 0) return; |
| 340 |
| 341 osr_pc_offset_ = masm()->pc_offset(); |
| 342 |
| 343 // Save the first local, which is overwritten by the alignment state. |
| 344 Operand alignment_loc = MemOperand(ebp, -3 * kPointerSize); |
| 345 __ push(alignment_loc); |
| 346 |
| 347 // Set the dynamic frame alignment state to "not aligned". |
| 348 __ mov(alignment_loc, Immediate(kNoAlignmentPadding)); |
| 349 |
| 350 // Adjust the frame size, subsuming the unoptimized frame into the |
| 351 // optimized frame. |
| 352 int slots = GetStackSlotCount() - graph()->osr()->UnoptimizedFrameSlots(); |
| 353 ASSERT(slots >= 1); |
| 354 __ sub(esp, Immediate((slots - 1) * kPointerSize)); |
| 355 } |
| 356 |
| 357 |
335 bool LCodeGen::GenerateBody() { | 358 bool LCodeGen::GenerateBody() { |
336 ASSERT(is_generating()); | 359 ASSERT(is_generating()); |
337 bool emit_instructions = true; | 360 bool emit_instructions = true; |
338 for (current_instruction_ = 0; | 361 for (current_instruction_ = 0; |
339 !is_aborted() && current_instruction_ < instructions_->length(); | 362 !is_aborted() && current_instruction_ < instructions_->length(); |
340 current_instruction_++) { | 363 current_instruction_++) { |
341 LInstruction* instr = instructions_->at(current_instruction_); | 364 LInstruction* instr = instructions_->at(current_instruction_); |
342 | 365 |
343 // Don't emit code for basic blocks with a replacement. | 366 // Don't emit code for basic blocks with a replacement. |
344 if (instr->IsLabel()) { | 367 if (instr->IsLabel()) { |
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1310 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | 1333 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); |
1311 break; | 1334 break; |
1312 } | 1335 } |
1313 default: | 1336 default: |
1314 UNREACHABLE(); | 1337 UNREACHABLE(); |
1315 } | 1338 } |
1316 } | 1339 } |
1317 | 1340 |
1318 | 1341 |
1319 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { | 1342 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { |
1320 // Record the address of the first unknown OSR value as the place to enter. | 1343 GenerateOsrPrologue(); |
1321 if (osr_pc_offset_ == -1) osr_pc_offset_ = masm()->pc_offset(); | |
1322 } | 1344 } |
1323 | 1345 |
1324 | 1346 |
1325 void LCodeGen::DoModI(LModI* instr) { | 1347 void LCodeGen::DoModI(LModI* instr) { |
1326 HMod* hmod = instr->hydrogen(); | 1348 HMod* hmod = instr->hydrogen(); |
1327 HValue* left = hmod->left(); | 1349 HValue* left = hmod->left(); |
1328 HValue* right = hmod->right(); | 1350 HValue* right = hmod->right(); |
1329 if (hmod->HasPowerOf2Divisor()) { | 1351 if (hmod->HasPowerOf2Divisor()) { |
1330 // TODO(svenpanne) We should really do the strength reduction on the | 1352 // TODO(svenpanne) We should really do the strength reduction on the |
1331 // Hydrogen level. | 1353 // Hydrogen level. |
(...skipping 4875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6207 // This is a pseudo-instruction that ensures that the environment here is | 6229 // This is a pseudo-instruction that ensures that the environment here is |
6208 // properly registered for deoptimization and records the assembler's PC | 6230 // properly registered for deoptimization and records the assembler's PC |
6209 // offset. | 6231 // offset. |
6210 LEnvironment* environment = instr->environment(); | 6232 LEnvironment* environment = instr->environment(); |
6211 | 6233 |
6212 // If the environment were already registered, we would have no way of | 6234 // If the environment were already registered, we would have no way of |
6213 // backpatching it with the spill slot operands. | 6235 // backpatching it with the spill slot operands. |
6214 ASSERT(!environment->HasBeenRegistered()); | 6236 ASSERT(!environment->HasBeenRegistered()); |
6215 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); | 6237 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); |
6216 | 6238 |
6217 // Normally we record the first unknown OSR value as the entrypoint to the OSR | 6239 GenerateOsrPrologue(); |
6218 // code, but if there were none, record the entrypoint here. | |
6219 if (osr_pc_offset_ == -1) osr_pc_offset_ = masm()->pc_offset(); | |
6220 } | 6240 } |
6221 | 6241 |
6222 | 6242 |
6223 void LCodeGen::DoForInPrepareMap(LForInPrepareMap* instr) { | 6243 void LCodeGen::DoForInPrepareMap(LForInPrepareMap* instr) { |
6224 __ cmp(eax, isolate()->factory()->undefined_value()); | 6244 __ cmp(eax, isolate()->factory()->undefined_value()); |
6225 DeoptimizeIf(equal, instr->environment()); | 6245 DeoptimizeIf(equal, instr->environment()); |
6226 | 6246 |
6227 __ cmp(eax, isolate()->factory()->null_value()); | 6247 __ cmp(eax, isolate()->factory()->null_value()); |
6228 DeoptimizeIf(equal, instr->environment()); | 6248 DeoptimizeIf(equal, instr->environment()); |
6229 | 6249 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6305 FixedArray::kHeaderSize - kPointerSize)); | 6325 FixedArray::kHeaderSize - kPointerSize)); |
6306 __ bind(&done); | 6326 __ bind(&done); |
6307 } | 6327 } |
6308 | 6328 |
6309 | 6329 |
6310 #undef __ | 6330 #undef __ |
6311 | 6331 |
6312 } } // namespace v8::internal | 6332 } } // namespace v8::internal |
6313 | 6333 |
6314 #endif // V8_TARGET_ARCH_IA32 | 6334 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |