| 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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 // Trace the call. | 321 // Trace the call. |
| 321 if (FLAG_trace && info()->IsOptimizing()) { | 322 if (FLAG_trace && info()->IsOptimizing()) { |
| 322 // We have not executed any compiled code yet, so esi still holds the | 323 // We have not executed any compiled code yet, so esi still holds the |
| 323 // incoming context. | 324 // incoming context. |
| 324 __ CallRuntime(Runtime::kTraceEnter, 0); | 325 __ CallRuntime(Runtime::kTraceEnter, 0); |
| 325 } | 326 } |
| 326 return !is_aborted(); | 327 return !is_aborted(); |
| 327 } | 328 } |
| 328 | 329 |
| 329 | 330 |
| 331 void LCodeGen::GenerateOsrPrologue() { |
| 332 // Generate the OSR entry prologue at the first unknown OSR value, or if there |
| 333 // are none, at the OSR entrypoint instruction. |
| 334 if (osr_pc_offset_ >= 0) return; |
| 335 |
| 336 osr_pc_offset_ = masm()->pc_offset(); |
| 337 |
| 338 // Save the first local, which is overwritten by the alignment state. |
| 339 Operand alignment_loc = MemOperand(ebp, -3 * kPointerSize); |
| 340 __ push(alignment_loc); |
| 341 |
| 342 // Set the dynamic frame alignment state to "not aligned". |
| 343 __ mov(alignment_loc, Immediate(kNoAlignmentPadding)); |
| 344 |
| 345 // Adjust the frame size, subsuming the unoptimized frame into the |
| 346 // optimized frame. |
| 347 int slots = GetStackSlotCount() - graph()->osr()->UnoptimizedFrameSlots(); |
| 348 ASSERT(slots >= 1); |
| 349 __ sub(esp, Immediate((slots - 1) * kPointerSize)); |
| 350 } |
| 351 |
| 352 |
| 330 bool LCodeGen::GenerateBody() { | 353 bool LCodeGen::GenerateBody() { |
| 331 ASSERT(is_generating()); | 354 ASSERT(is_generating()); |
| 332 bool emit_instructions = true; | 355 bool emit_instructions = true; |
| 333 for (current_instruction_ = 0; | 356 for (current_instruction_ = 0; |
| 334 !is_aborted() && current_instruction_ < instructions_->length(); | 357 !is_aborted() && current_instruction_ < instructions_->length(); |
| 335 current_instruction_++) { | 358 current_instruction_++) { |
| 336 LInstruction* instr = instructions_->at(current_instruction_); | 359 LInstruction* instr = instructions_->at(current_instruction_); |
| 337 | 360 |
| 338 // Don't emit code for basic blocks with a replacement. | 361 // Don't emit code for basic blocks with a replacement. |
| 339 if (instr->IsLabel()) { | 362 if (instr->IsLabel()) { |
| (...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1243 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | 1266 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); |
| 1244 break; | 1267 break; |
| 1245 } | 1268 } |
| 1246 default: | 1269 default: |
| 1247 UNREACHABLE(); | 1270 UNREACHABLE(); |
| 1248 } | 1271 } |
| 1249 } | 1272 } |
| 1250 | 1273 |
| 1251 | 1274 |
| 1252 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { | 1275 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { |
| 1253 // Record the address of the first unknown OSR value as the place to enter. | 1276 GenerateOsrPrologue(); |
| 1254 if (osr_pc_offset_ == -1) osr_pc_offset_ = masm()->pc_offset(); | |
| 1255 } | 1277 } |
| 1256 | 1278 |
| 1257 | 1279 |
| 1258 void LCodeGen::DoModI(LModI* instr) { | 1280 void LCodeGen::DoModI(LModI* instr) { |
| 1259 HMod* hmod = instr->hydrogen(); | 1281 HMod* hmod = instr->hydrogen(); |
| 1260 HValue* left = hmod->left(); | 1282 HValue* left = hmod->left(); |
| 1261 HValue* right = hmod->right(); | 1283 HValue* right = hmod->right(); |
| 1262 if (hmod->HasPowerOf2Divisor()) { | 1284 if (hmod->HasPowerOf2Divisor()) { |
| 1263 // TODO(svenpanne) We should really do the strength reduction on the | 1285 // TODO(svenpanne) We should really do the strength reduction on the |
| 1264 // Hydrogen level. | 1286 // Hydrogen level. |
| (...skipping 5166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6431 // This is a pseudo-instruction that ensures that the environment here is | 6453 // This is a pseudo-instruction that ensures that the environment here is |
| 6432 // properly registered for deoptimization and records the assembler's PC | 6454 // properly registered for deoptimization and records the assembler's PC |
| 6433 // offset. | 6455 // offset. |
| 6434 LEnvironment* environment = instr->environment(); | 6456 LEnvironment* environment = instr->environment(); |
| 6435 | 6457 |
| 6436 // If the environment were already registered, we would have no way of | 6458 // If the environment were already registered, we would have no way of |
| 6437 // backpatching it with the spill slot operands. | 6459 // backpatching it with the spill slot operands. |
| 6438 ASSERT(!environment->HasBeenRegistered()); | 6460 ASSERT(!environment->HasBeenRegistered()); |
| 6439 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); | 6461 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); |
| 6440 | 6462 |
| 6441 // Normally we record the first unknown OSR value as the entrypoint to the OSR | 6463 GenerateOsrPrologue(); |
| 6442 // code, but if there were none, record the entrypoint here. | |
| 6443 if (osr_pc_offset_ == -1) osr_pc_offset_ = masm()->pc_offset(); | |
| 6444 } | 6464 } |
| 6445 | 6465 |
| 6446 | 6466 |
| 6447 void LCodeGen::DoForInPrepareMap(LForInPrepareMap* instr) { | 6467 void LCodeGen::DoForInPrepareMap(LForInPrepareMap* instr) { |
| 6448 __ cmp(eax, isolate()->factory()->undefined_value()); | 6468 __ cmp(eax, isolate()->factory()->undefined_value()); |
| 6449 DeoptimizeIf(equal, instr->environment()); | 6469 DeoptimizeIf(equal, instr->environment()); |
| 6450 | 6470 |
| 6451 __ cmp(eax, isolate()->factory()->null_value()); | 6471 __ cmp(eax, isolate()->factory()->null_value()); |
| 6452 DeoptimizeIf(equal, instr->environment()); | 6472 DeoptimizeIf(equal, instr->environment()); |
| 6453 | 6473 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6529 FixedArray::kHeaderSize - kPointerSize)); | 6549 FixedArray::kHeaderSize - kPointerSize)); |
| 6530 __ bind(&done); | 6550 __ bind(&done); |
| 6531 } | 6551 } |
| 6532 | 6552 |
| 6533 | 6553 |
| 6534 #undef __ | 6554 #undef __ |
| 6535 | 6555 |
| 6536 } } // namespace v8::internal | 6556 } } // namespace v8::internal |
| 6537 | 6557 |
| 6538 #endif // V8_TARGET_ARCH_IA32 | 6558 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |