Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(896)

Side by Side Diff: src/ia32/lithium-ia32.cc

Issue 10701054: Enable stub generation using Hydrogen/Lithium (again) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merge with latest Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/lithium-ia32.h ('k') | src/ia32/macro-assembler-ia32.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 26 matching lines...) Expand all
37 namespace internal { 37 namespace internal {
38 38
39 #define DEFINE_COMPILE(type) \ 39 #define DEFINE_COMPILE(type) \
40 void L##type::CompileToNative(LCodeGen* generator) { \ 40 void L##type::CompileToNative(LCodeGen* generator) { \
41 generator->Do##type(this); \ 41 generator->Do##type(this); \
42 } 42 }
43 LITHIUM_CONCRETE_INSTRUCTION_LIST(DEFINE_COMPILE) 43 LITHIUM_CONCRETE_INSTRUCTION_LIST(DEFINE_COMPILE)
44 #undef DEFINE_COMPILE 44 #undef DEFINE_COMPILE
45 45
46 LOsrEntry::LOsrEntry() { 46 LOsrEntry::LOsrEntry() {
47 for (int i = 0; i < Register::kNumAllocatableRegisters; ++i) { 47 for (int i = 0; i < Register::NumAllocatableRegisters(); ++i) {
48 register_spills_[i] = NULL; 48 register_spills_[i] = NULL;
49 } 49 }
50 for (int i = 0; i < DoubleRegister::kNumAllocatableRegisters; ++i) { 50 for (int i = 0; i < DoubleRegister::NumAllocatableRegisters(); ++i) {
51 double_register_spills_[i] = NULL; 51 double_register_spills_[i] = NULL;
52 } 52 }
53 } 53 }
54 54
55 55
56 void LOsrEntry::MarkSpilledRegister(int allocation_index, 56 void LOsrEntry::MarkSpilledRegister(int allocation_index,
57 LOperand* spill_operand) { 57 LOperand* spill_operand) {
58 ASSERT(spill_operand->IsStackSlot()); 58 ASSERT(spill_operand->IsStackSlot());
59 ASSERT(register_spills_[allocation_index] == NULL); 59 ASSERT(register_spills_[allocation_index] == NULL);
60 register_spills_[allocation_index] = spill_operand; 60 register_spills_[allocation_index] = spill_operand;
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 } 453 }
454 454
455 455
456 LPlatformChunk* LChunkBuilder::Build() { 456 LPlatformChunk* LChunkBuilder::Build() {
457 ASSERT(is_unused()); 457 ASSERT(is_unused());
458 chunk_ = new(zone()) LPlatformChunk(info(), graph()); 458 chunk_ = new(zone()) LPlatformChunk(info(), graph());
459 HPhase phase("L_Building chunk", chunk_); 459 HPhase phase("L_Building chunk", chunk_);
460 status_ = BUILDING; 460 status_ = BUILDING;
461 461
462 // Reserve the first spill slot for the state of dynamic alignment. 462 // Reserve the first spill slot for the state of dynamic alignment.
463 int alignment_state_index = chunk_->GetNextSpillIndex(false); 463 if (info()->IsOptimizing()) {
464 ASSERT_EQ(alignment_state_index, 0); 464 int alignment_state_index = chunk_->GetNextSpillIndex(false);
465 USE(alignment_state_index); 465 ASSERT_EQ(alignment_state_index, 0);
466 USE(alignment_state_index);
467 }
466 468
467 const ZoneList<HBasicBlock*>* blocks = graph()->blocks(); 469 const ZoneList<HBasicBlock*>* blocks = graph()->blocks();
468 for (int i = 0; i < blocks->length(); i++) { 470 for (int i = 0; i < blocks->length(); i++) {
469 HBasicBlock* next = NULL; 471 HBasicBlock* next = NULL;
470 if (i < blocks->length() - 1) next = blocks->at(i + 1); 472 if (i < blocks->length() - 1) next = blocks->at(i + 1);
471 DoBasicBlock(blocks->at(i), next); 473 DoBasicBlock(blocks->at(i), next);
472 if (is_aborted()) return NULL; 474 if (is_aborted()) return NULL;
473 } 475 }
474 status_ = DONE; 476 status_ = DONE;
475 return chunk_; 477 return chunk_;
(...skipping 11 matching lines...) Expand all
487 Register::ToAllocationIndex(reg)); 489 Register::ToAllocationIndex(reg));
488 } 490 }
489 491
490 492
491 LUnallocated* LChunkBuilder::ToUnallocated(XMMRegister reg) { 493 LUnallocated* LChunkBuilder::ToUnallocated(XMMRegister reg) {
492 return new(zone()) LUnallocated(LUnallocated::FIXED_DOUBLE_REGISTER, 494 return new(zone()) LUnallocated(LUnallocated::FIXED_DOUBLE_REGISTER,
493 XMMRegister::ToAllocationIndex(reg)); 495 XMMRegister::ToAllocationIndex(reg));
494 } 496 }
495 497
496 498
499 LUnallocated* LChunkBuilder::ToUnallocated(X87TopOfStackRegister reg) {
500 return new(zone()) LUnallocated(LUnallocated::FIXED_DOUBLE_REGISTER,
501 X87TopOfStackRegister::ToAllocationIndex(reg));
502 }
503
504
497 LOperand* LChunkBuilder::UseFixed(HValue* value, Register fixed_register) { 505 LOperand* LChunkBuilder::UseFixed(HValue* value, Register fixed_register) {
498 return Use(value, ToUnallocated(fixed_register)); 506 return Use(value, ToUnallocated(fixed_register));
499 } 507 }
500 508
501 509
502 LOperand* LChunkBuilder::UseFixedDouble(HValue* value, XMMRegister reg) { 510 LOperand* LChunkBuilder::UseFixedDouble(HValue* value, XMMRegister reg) {
503 return Use(value, ToUnallocated(reg)); 511 return Use(value, ToUnallocated(reg));
504 } 512 }
505 513
506 514
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 627
620 628
621 template<int I, int T> 629 template<int I, int T>
622 LInstruction* LChunkBuilder::DefineFixedDouble( 630 LInstruction* LChunkBuilder::DefineFixedDouble(
623 LTemplateInstruction<1, I, T>* instr, 631 LTemplateInstruction<1, I, T>* instr,
624 XMMRegister reg) { 632 XMMRegister reg) {
625 return Define(instr, ToUnallocated(reg)); 633 return Define(instr, ToUnallocated(reg));
626 } 634 }
627 635
628 636
637 template<int I, int T>
638 LInstruction* LChunkBuilder::DefineX87TOS(
639 LTemplateInstruction<1, I, T>* instr) {
640 return Define(instr, ToUnallocated(x87tos));
641 }
642
643
629 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { 644 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) {
630 HEnvironment* hydrogen_env = current_block_->last_environment(); 645 HEnvironment* hydrogen_env = current_block_->last_environment();
631 int argument_index_accumulator = 0; 646 int argument_index_accumulator = 0;
632 instr->set_environment(CreateEnvironment(hydrogen_env, 647 instr->set_environment(CreateEnvironment(hydrogen_env,
633 &argument_index_accumulator)); 648 &argument_index_accumulator));
634 return instr; 649 return instr;
635 } 650 }
636 651
637 652
638 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, 653 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr,
639 HInstruction* hinstr, 654 HInstruction* hinstr,
640 CanDeoptimize can_deoptimize) { 655 CanDeoptimize can_deoptimize) {
656 info()->MarkAsNonDeferredCalling();
657
641 #ifdef DEBUG 658 #ifdef DEBUG
642 instr->VerifyCall(); 659 instr->VerifyCall();
643 #endif 660 #endif
644 instr->MarkAsCall(); 661 instr->MarkAsCall();
645 instr = AssignPointerMap(instr); 662 instr = AssignPointerMap(instr);
646 663
647 if (hinstr->HasObservableSideEffects()) { 664 if (hinstr->HasObservableSideEffects()) {
648 ASSERT(hinstr->next()->IsSimulate()); 665 ASSERT(hinstr->next()->IsSimulate());
649 HSimulate* sim = HSimulate::cast(hinstr->next()); 666 HSimulate* sim = HSimulate::cast(hinstr->next());
650 ASSERT(instruction_pending_deoptimization_environment_ == NULL); 667 ASSERT(instruction_pending_deoptimization_environment_ == NULL);
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after
1673 // All HForceRepresentation instructions should be eliminated in the 1690 // All HForceRepresentation instructions should be eliminated in the
1674 // representation change phase of Hydrogen. 1691 // representation change phase of Hydrogen.
1675 UNREACHABLE(); 1692 UNREACHABLE();
1676 return NULL; 1693 return NULL;
1677 } 1694 }
1678 1695
1679 1696
1680 LInstruction* LChunkBuilder::DoChange(HChange* instr) { 1697 LInstruction* LChunkBuilder::DoChange(HChange* instr) {
1681 Representation from = instr->from(); 1698 Representation from = instr->from();
1682 Representation to = instr->to(); 1699 Representation to = instr->to();
1700 // Only mark conversions that might need to allocate as calling rather than
1701 // all changes. This makes simple, non-allocating conversion not have to force
1702 // building a stack frame.
1683 if (from.IsTagged()) { 1703 if (from.IsTagged()) {
1684 if (to.IsDouble()) { 1704 if (to.IsDouble()) {
1705 info()->MarkAsDeferredCalling();
1685 LOperand* value = UseRegister(instr->value()); 1706 LOperand* value = UseRegister(instr->value());
1686 // Temp register only necessary for minus zero check. 1707 // Temp register only necessary for minus zero check.
1687 LOperand* temp = instr->deoptimize_on_minus_zero() 1708 LOperand* temp = instr->deoptimize_on_minus_zero()
1688 ? TempRegister() 1709 ? TempRegister()
1689 : NULL; 1710 : NULL;
1690 LNumberUntagD* res = new(zone()) LNumberUntagD(value, temp); 1711 LNumberUntagD* res = new(zone()) LNumberUntagD(value, temp);
1691 return AssignEnvironment(DefineAsRegister(res)); 1712 return AssignEnvironment(DefineAsRegister(res));
1692 } else { 1713 } else {
1693 ASSERT(to.IsInteger32()); 1714 ASSERT(to.IsInteger32());
1694 LOperand* value = UseRegister(instr->value()); 1715 LOperand* value = UseRegister(instr->value());
1695 if (instr->value()->type().IsSmi()) { 1716 if (instr->value()->type().IsSmi()) {
1696 return DefineSameAsFirst(new(zone()) LSmiUntag(value, false)); 1717 return DefineSameAsFirst(new(zone()) LSmiUntag(value, false));
1697 } else { 1718 } else {
1698 bool truncating = instr->CanTruncateToInt32(); 1719 bool truncating = instr->CanTruncateToInt32();
1699 LOperand* xmm_temp = 1720 LOperand* xmm_temp =
1700 (truncating && CpuFeatures::IsSupported(SSE3)) 1721 (truncating && CpuFeatures::IsSupported(SSE3))
1701 ? NULL 1722 ? NULL
1702 : FixedTemp(xmm1); 1723 : FixedTemp(xmm1);
1703 LTaggedToI* res = new(zone()) LTaggedToI(value, xmm_temp); 1724 LTaggedToI* res = new(zone()) LTaggedToI(value, xmm_temp);
1704 return AssignEnvironment(DefineSameAsFirst(res)); 1725 return AssignEnvironment(DefineSameAsFirst(res));
1705 } 1726 }
1706 } 1727 }
1707 } else if (from.IsDouble()) { 1728 } else if (from.IsDouble()) {
1708 if (to.IsTagged()) { 1729 if (to.IsTagged()) {
1709 LOperand* value = UseRegister(instr->value()); 1730 info()->MarkAsDeferredCalling();
1731 LOperand* value = CpuFeatures::IsSupported(SSE2)
1732 ? UseRegisterAtStart(instr->value())
1733 : UseAtStart(instr->value());
1710 LOperand* temp = TempRegister(); 1734 LOperand* temp = TempRegister();
1711 1735
1712 // Make sure that temp and result_temp are different registers. 1736 // Make sure that temp and result_temp are different registers.
1713 LUnallocated* result_temp = TempRegister(); 1737 LUnallocated* result_temp = TempRegister();
1714 LNumberTagD* result = new(zone()) LNumberTagD(value, temp); 1738 LNumberTagD* result = new(zone()) LNumberTagD(value, temp);
1715 return AssignPointerMap(Define(result, result_temp)); 1739 return AssignPointerMap(Define(result, result_temp));
1716 } else { 1740 } else {
1717 ASSERT(to.IsInteger32()); 1741 ASSERT(to.IsInteger32());
1718 bool truncating = instr->CanTruncateToInt32(); 1742 bool truncating = instr->CanTruncateToInt32();
1719 bool needs_temp = truncating && !CpuFeatures::IsSupported(SSE3); 1743 bool needs_temp = truncating && !CpuFeatures::IsSupported(SSE3);
1720 LOperand* value = needs_temp ? 1744 LOperand* value = needs_temp ?
1721 UseTempRegister(instr->value()) : UseRegister(instr->value()); 1745 UseTempRegister(instr->value()) : UseRegister(instr->value());
1722 LOperand* temp = needs_temp ? TempRegister() : NULL; 1746 LOperand* temp = needs_temp ? TempRegister() : NULL;
1723 return AssignEnvironment( 1747 return AssignEnvironment(
1724 DefineAsRegister(new(zone()) LDoubleToI(value, temp))); 1748 DefineAsRegister(new(zone()) LDoubleToI(value, temp)));
1725 } 1749 }
1726 } else if (from.IsInteger32()) { 1750 } else if (from.IsInteger32()) {
1751 info()->MarkAsDeferredCalling();
1727 if (to.IsTagged()) { 1752 if (to.IsTagged()) {
1728 HValue* val = instr->value(); 1753 HValue* val = instr->value();
1729 LOperand* value = UseRegister(val); 1754 LOperand* value = UseRegister(val);
1730 if (val->HasRange() && val->range()->IsInSmiRange()) { 1755 if (val->HasRange() && val->range()->IsInSmiRange()) {
1731 return DefineSameAsFirst(new(zone()) LSmiTag(value)); 1756 return DefineSameAsFirst(new(zone()) LSmiTag(value));
1732 } else if (val->CheckFlag(HInstruction::kUint32)) { 1757 } else if (val->CheckFlag(HInstruction::kUint32)) {
1733 LOperand* temp = FixedTemp(xmm1); 1758 LOperand* temp = FixedTemp(xmm1);
1734 LNumberTagU* result = new(zone()) LNumberTagU(value, temp); 1759 LNumberTagU* result = new(zone()) LNumberTagU(value, temp);
1735 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); 1760 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result)));
1736 } else { 1761 } else {
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
2233 2258
2234 LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) { 2259 LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) {
2235 ASSERT(argument_count_ == 0); 2260 ASSERT(argument_count_ == 0);
2236 allocator_->MarkAsOsrEntry(); 2261 allocator_->MarkAsOsrEntry();
2237 current_block_->last_environment()->set_ast_id(instr->ast_id()); 2262 current_block_->last_environment()->set_ast_id(instr->ast_id());
2238 return AssignEnvironment(new(zone()) LOsrEntry); 2263 return AssignEnvironment(new(zone()) LOsrEntry);
2239 } 2264 }
2240 2265
2241 2266
2242 LInstruction* LChunkBuilder::DoParameter(HParameter* instr) { 2267 LInstruction* LChunkBuilder::DoParameter(HParameter* instr) {
2243 int spill_index = chunk()->GetParameterStackSlot(instr->index()); 2268 LParameter* result = new(zone()) LParameter;
2244 return DefineAsSpilled(new(zone()) LParameter, spill_index); 2269 if (info()->IsOptimizing()) {
2270 int spill_index = chunk()->GetParameterStackSlot(instr->index());
2271 return DefineAsSpilled(result, spill_index);
2272 } else {
2273 ASSERT(info()->IsStub());
2274 CodeStubInterfaceDescriptor* descriptor =
2275 info()->code_stub()->GetInterfaceDescriptor(info()->isolate());
2276 Register reg = descriptor->register_params[instr->index()];
2277 return DefineFixed(result, reg);
2278 }
2245 } 2279 }
2246 2280
2247 2281
2248 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { 2282 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) {
2249 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width. 2283 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width.
2250 if (spill_index > LUnallocated::kMaxFixedIndex) { 2284 if (spill_index > LUnallocated::kMaxFixedIndex) {
2251 Abort("Too many spill slots needed for OSR"); 2285 Abort("Too many spill slots needed for OSR");
2252 spill_index = 0; 2286 spill_index = 0;
2253 } 2287 }
2254 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); 2288 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2335 instruction_pending_deoptimization_environment_ = NULL; 2369 instruction_pending_deoptimization_environment_ = NULL;
2336 pending_deoptimization_ast_id_ = BailoutId::None(); 2370 pending_deoptimization_ast_id_ = BailoutId::None();
2337 return result; 2371 return result;
2338 } 2372 }
2339 2373
2340 return NULL; 2374 return NULL;
2341 } 2375 }
2342 2376
2343 2377
2344 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { 2378 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) {
2379 info()->MarkAsDeferredCalling();
2345 if (instr->is_function_entry()) { 2380 if (instr->is_function_entry()) {
2346 LOperand* context = UseFixed(instr->context(), esi); 2381 LOperand* context = UseFixed(instr->context(), esi);
2347 return MarkAsCall(new(zone()) LStackCheck(context), instr); 2382 return MarkAsCall(new(zone()) LStackCheck(context), instr);
2348 } else { 2383 } else {
2349 ASSERT(instr->is_backwards_branch()); 2384 ASSERT(instr->is_backwards_branch());
2350 LOperand* context = UseAny(instr->context()); 2385 LOperand* context = UseAny(instr->context());
2351 return AssignEnvironment( 2386 return AssignEnvironment(
2352 AssignPointerMap(new(zone()) LStackCheck(context))); 2387 AssignPointerMap(new(zone()) LStackCheck(context)));
2353 } 2388 }
2354 } 2389 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2425 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2460 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2426 LOperand* object = UseRegister(instr->object()); 2461 LOperand* object = UseRegister(instr->object());
2427 LOperand* index = UseTempRegister(instr->index()); 2462 LOperand* index = UseTempRegister(instr->index());
2428 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); 2463 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index));
2429 } 2464 }
2430 2465
2431 2466
2432 } } // namespace v8::internal 2467 } } // namespace v8::internal
2433 2468
2434 #endif // V8_TARGET_ARCH_IA32 2469 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-ia32.h ('k') | src/ia32/macro-assembler-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698