| 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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 instr->hydrogen_value()->id(), | 375 instr->hydrogen_value()->id(), |
| 376 instr->Mnemonic()); | 376 instr->Mnemonic()); |
| 377 } | 377 } |
| 378 | 378 |
| 379 if (!CpuFeatures::IsSupported(SSE2)) FlushX87StackIfNecessary(instr); | 379 if (!CpuFeatures::IsSupported(SSE2)) FlushX87StackIfNecessary(instr); |
| 380 | 380 |
| 381 RecordAndUpdatePosition(instr->position()); | 381 RecordAndUpdatePosition(instr->position()); |
| 382 | 382 |
| 383 instr->CompileToNative(this); | 383 instr->CompileToNative(this); |
| 384 | 384 |
| 385 if (!CpuFeatures::IsSupported(SSE2) && | 385 if (!CpuFeatures::IsSupported(SSE2)) { |
| 386 FLAG_debug_code && FLAG_enable_slow_asserts) { | 386 if (instr->IsGoto()) { |
| 387 x87_stack_.LeavingBlock(current_block_, LGoto::cast(instr)); |
| 388 } else if (FLAG_debug_code && FLAG_enable_slow_asserts && |
| 389 !instr->IsGap() && !instr->IsReturn()) { |
| 387 __ VerifyX87StackDepth(x87_stack_.depth()); | 390 __ VerifyX87StackDepth(x87_stack_.depth()); |
| 391 } |
| 388 } | 392 } |
| 389 } | 393 } |
| 390 EnsureSpaceForLazyDeopt(); | 394 EnsureSpaceForLazyDeopt(); |
| 391 return !is_aborted(); | 395 return !is_aborted(); |
| 392 } | 396 } |
| 393 | 397 |
| 394 | 398 |
| 395 bool LCodeGen::GenerateJumpTable() { | 399 bool LCodeGen::GenerateJumpTable() { |
| 396 Label needs_frame; | 400 Label needs_frame; |
| 397 if (jump_table_.length() > 0) { | 401 if (jump_table_.length() > 0) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 ASSERT(info()->IsStub()); | 468 ASSERT(info()->IsStub()); |
| 465 frame_is_built_ = true; | 469 frame_is_built_ = true; |
| 466 // Build the frame in such a way that esi isn't trashed. | 470 // Build the frame in such a way that esi isn't trashed. |
| 467 __ push(ebp); // Caller's frame pointer. | 471 __ push(ebp); // Caller's frame pointer. |
| 468 __ push(Operand(ebp, StandardFrameConstants::kContextOffset)); | 472 __ push(Operand(ebp, StandardFrameConstants::kContextOffset)); |
| 469 __ push(Immediate(Smi::FromInt(StackFrame::STUB))); | 473 __ push(Immediate(Smi::FromInt(StackFrame::STUB))); |
| 470 __ lea(ebp, Operand(esp, 2 * kPointerSize)); | 474 __ lea(ebp, Operand(esp, 2 * kPointerSize)); |
| 471 Comment(";;; Deferred code"); | 475 Comment(";;; Deferred code"); |
| 472 } | 476 } |
| 473 code->Generate(); | 477 code->Generate(); |
| 474 __ bind(code->done()); | |
| 475 if (NeedsDeferredFrame()) { | 478 if (NeedsDeferredFrame()) { |
| 479 __ bind(code->done()); |
| 476 Comment(";;; Destroy frame"); | 480 Comment(";;; Destroy frame"); |
| 477 ASSERT(frame_is_built_); | 481 ASSERT(frame_is_built_); |
| 478 frame_is_built_ = false; | 482 frame_is_built_ = false; |
| 479 __ mov(esp, ebp); | 483 __ mov(esp, ebp); |
| 480 __ pop(ebp); | 484 __ pop(ebp); |
| 481 } | 485 } |
| 482 __ jmp(code->exit()); | 486 __ jmp(code->exit()); |
| 483 } | 487 } |
| 484 } | 488 } |
| 485 | 489 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 } | 679 } |
| 676 Free(reg); | 680 Free(reg); |
| 677 if (i < stack_depth_-1) i++; | 681 if (i < stack_depth_-1) i++; |
| 678 } | 682 } |
| 679 } | 683 } |
| 680 if (instr->IsReturn()) { | 684 if (instr->IsReturn()) { |
| 681 while (stack_depth_ > 0) { | 685 while (stack_depth_ > 0) { |
| 682 __ fstp(0); | 686 __ fstp(0); |
| 683 stack_depth_--; | 687 stack_depth_--; |
| 684 } | 688 } |
| 689 __ VerifyX87StackDepth(0); |
| 685 } | 690 } |
| 686 } | 691 } |
| 687 | 692 |
| 693 |
| 694 void LCodeGen::X87Stack::LeavingBlock(int current_block_id, LGoto* goto_instr) { |
| 695 ASSERT(stack_depth_ <= 1); |
| 696 // If ever used for new stubs producing two pairs of doubles joined into two |
| 697 // phis this assert hits. That situation is not handled, since the two stacks |
| 698 // might have st0 and st1 swapped. |
| 699 if (current_block_id + 1 != goto_instr->block_id()) { |
| 700 // If we have a value on the x87 stack on leaving a block, it must be a |
| 701 // phi input. If the next block we compile is not the join block, we have |
| 702 // to discard the stack state. |
| 703 stack_depth_ = 0; |
| 704 } |
| 705 } |
| 706 |
| 688 | 707 |
| 689 void LCodeGen::EmitFlushX87ForDeopt() { | 708 void LCodeGen::EmitFlushX87ForDeopt() { |
| 690 // The deoptimizer does not support X87 Registers. But as long as we | 709 // The deoptimizer does not support X87 Registers. But as long as we |
| 691 // deopt from a stub its not a problem, since we will re-materialize the | 710 // deopt from a stub its not a problem, since we will re-materialize the |
| 692 // original stub inputs, which can't be double registers. | 711 // original stub inputs, which can't be double registers. |
| 693 ASSERT(info()->IsStub()); | 712 ASSERT(info()->IsStub()); |
| 694 if (FLAG_debug_code && FLAG_enable_slow_asserts) { | 713 if (FLAG_debug_code && FLAG_enable_slow_asserts) { |
| 695 __ pushfd(); | 714 __ pushfd(); |
| 696 __ VerifyX87StackDepth(x87_stack_.depth()); | 715 __ VerifyX87StackDepth(x87_stack_.depth()); |
| 697 __ popfd(); | 716 __ popfd(); |
| (...skipping 1527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2225 break; | 2244 break; |
| 2226 } | 2245 } |
| 2227 default: | 2246 default: |
| 2228 UNREACHABLE(); | 2247 UNREACHABLE(); |
| 2229 break; | 2248 break; |
| 2230 } | 2249 } |
| 2231 } else { | 2250 } else { |
| 2232 X87Register left = ToX87Register(instr->left()); | 2251 X87Register left = ToX87Register(instr->left()); |
| 2233 X87Register right = ToX87Register(instr->right()); | 2252 X87Register right = ToX87Register(instr->right()); |
| 2234 X87Register result = ToX87Register(instr->result()); | 2253 X87Register result = ToX87Register(instr->result()); |
| 2235 X87PrepareBinaryOp(left, right, result); | 2254 if (instr->op() != Token::MOD) { |
| 2255 X87PrepareBinaryOp(left, right, result); |
| 2256 } |
| 2236 switch (instr->op()) { | 2257 switch (instr->op()) { |
| 2258 case Token::ADD: |
| 2259 __ fadd_i(1); |
| 2260 break; |
| 2261 case Token::SUB: |
| 2262 __ fsub_i(1); |
| 2263 break; |
| 2237 case Token::MUL: | 2264 case Token::MUL: |
| 2238 __ fmul_i(1); | 2265 __ fmul_i(1); |
| 2239 break; | 2266 break; |
| 2267 case Token::DIV: |
| 2268 __ fdiv_i(1); |
| 2269 break; |
| 2270 case Token::MOD: { |
| 2271 // Pass two doubles as arguments on the stack. |
| 2272 __ PrepareCallCFunction(4, eax); |
| 2273 X87Mov(Operand(esp, 1 * kDoubleSize), right); |
| 2274 X87Mov(Operand(esp, 0), left); |
| 2275 X87PrepareToWrite(result); |
| 2276 __ CallCFunction( |
| 2277 ExternalReference::double_fp_operation(Token::MOD, isolate()), |
| 2278 4); |
| 2279 |
| 2280 // Return value is in st(0) on ia32. |
| 2281 X87CommitWrite(result); |
| 2282 break; |
| 2283 } |
| 2240 default: | 2284 default: |
| 2241 UNREACHABLE(); | 2285 UNREACHABLE(); |
| 2242 break; | 2286 break; |
| 2243 } | 2287 } |
| 2244 } | 2288 } |
| 2245 } | 2289 } |
| 2246 | 2290 |
| 2247 | 2291 |
| 2248 void LCodeGen::DoArithmeticT(LArithmeticT* instr) { | 2292 void LCodeGen::DoArithmeticT(LArithmeticT* instr) { |
| 2249 ASSERT(ToRegister(instr->context()).is(esi)); | 2293 ASSERT(ToRegister(instr->context()).is(esi)); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2454 } | 2498 } |
| 2455 | 2499 |
| 2456 | 2500 |
| 2457 void LCodeGen::EmitGoto(int block) { | 2501 void LCodeGen::EmitGoto(int block) { |
| 2458 if (!IsNextEmittedBlock(block)) { | 2502 if (!IsNextEmittedBlock(block)) { |
| 2459 __ jmp(chunk_->GetAssemblyLabel(LookupDestination(block))); | 2503 __ jmp(chunk_->GetAssemblyLabel(LookupDestination(block))); |
| 2460 } | 2504 } |
| 2461 } | 2505 } |
| 2462 | 2506 |
| 2463 | 2507 |
| 2508 void LCodeGen::DoClobberDoubles(LClobberDoubles* instr) { |
| 2509 } |
| 2510 |
| 2511 |
| 2464 void LCodeGen::DoGoto(LGoto* instr) { | 2512 void LCodeGen::DoGoto(LGoto* instr) { |
| 2465 EmitGoto(instr->block_id()); | 2513 EmitGoto(instr->block_id()); |
| 2466 } | 2514 } |
| 2467 | 2515 |
| 2468 | 2516 |
| 2469 Condition LCodeGen::TokenToCondition(Token::Value op, bool is_unsigned) { | 2517 Condition LCodeGen::TokenToCondition(Token::Value op, bool is_unsigned) { |
| 2470 Condition cond = no_condition; | 2518 Condition cond = no_condition; |
| 2471 switch (op) { | 2519 switch (op) { |
| 2472 case Token::EQ: | 2520 case Token::EQ: |
| 2473 case Token::EQ_STRICT: | 2521 case Token::EQ_STRICT: |
| (...skipping 3851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6325 FixedArray::kHeaderSize - kPointerSize)); | 6373 FixedArray::kHeaderSize - kPointerSize)); |
| 6326 __ bind(&done); | 6374 __ bind(&done); |
| 6327 } | 6375 } |
| 6328 | 6376 |
| 6329 | 6377 |
| 6330 #undef __ | 6378 #undef __ |
| 6331 | 6379 |
| 6332 } } // namespace v8::internal | 6380 } } // namespace v8::internal |
| 6333 | 6381 |
| 6334 #endif // V8_TARGET_ARCH_IA32 | 6382 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |