| 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 5150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6415 // This is a pseudo-instruction that ensures that the environment here is | 6437 // This is a pseudo-instruction that ensures that the environment here is |
| 6416 // properly registered for deoptimization and records the assembler's PC | 6438 // properly registered for deoptimization and records the assembler's PC |
| 6417 // offset. | 6439 // offset. |
| 6418 LEnvironment* environment = instr->environment(); | 6440 LEnvironment* environment = instr->environment(); |
| 6419 | 6441 |
| 6420 // If the environment were already registered, we would have no way of | 6442 // If the environment were already registered, we would have no way of |
| 6421 // backpatching it with the spill slot operands. | 6443 // backpatching it with the spill slot operands. |
| 6422 ASSERT(!environment->HasBeenRegistered()); | 6444 ASSERT(!environment->HasBeenRegistered()); |
| 6423 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); | 6445 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); |
| 6424 | 6446 |
| 6425 // Normally we record the first unknown OSR value as the entrypoint to the OSR | 6447 GenerateOsrPrologue(); |
| 6426 // code, but if there were none, record the entrypoint here. | |
| 6427 if (osr_pc_offset_ == -1) osr_pc_offset_ = masm()->pc_offset(); | |
| 6428 } | 6448 } |
| 6429 | 6449 |
| 6430 | 6450 |
| 6431 void LCodeGen::DoForInPrepareMap(LForInPrepareMap* instr) { | 6451 void LCodeGen::DoForInPrepareMap(LForInPrepareMap* instr) { |
| 6432 __ cmp(eax, isolate()->factory()->undefined_value()); | 6452 __ cmp(eax, isolate()->factory()->undefined_value()); |
| 6433 DeoptimizeIf(equal, instr->environment()); | 6453 DeoptimizeIf(equal, instr->environment()); |
| 6434 | 6454 |
| 6435 __ cmp(eax, isolate()->factory()->null_value()); | 6455 __ cmp(eax, isolate()->factory()->null_value()); |
| 6436 DeoptimizeIf(equal, instr->environment()); | 6456 DeoptimizeIf(equal, instr->environment()); |
| 6437 | 6457 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6513 FixedArray::kHeaderSize - kPointerSize)); | 6533 FixedArray::kHeaderSize - kPointerSize)); |
| 6514 __ bind(&done); | 6534 __ bind(&done); |
| 6515 } | 6535 } |
| 6516 | 6536 |
| 6517 | 6537 |
| 6518 #undef __ | 6538 #undef __ |
| 6519 | 6539 |
| 6520 } } // namespace v8::internal | 6540 } } // namespace v8::internal |
| 6521 | 6541 |
| 6522 #endif // V8_TARGET_ARCH_IA32 | 6542 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |