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

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

Issue 6880010: Merge (7265, 7271] from bleeding_edge to experimental/gc branch.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 years, 8 months 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
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "v8.h"
28 #include "lithium-allocator-inl.h" 29 #include "lithium-allocator-inl.h"
29 30
30 #include "hydrogen.h" 31 #include "hydrogen.h"
31 #include "string-stream.h" 32 #include "string-stream.h"
32 33
33 #if V8_TARGET_ARCH_IA32 34 #if V8_TARGET_ARCH_IA32
34 #include "ia32/lithium-ia32.h" 35 #include "ia32/lithium-ia32.h"
35 #elif V8_TARGET_ARCH_X64 36 #elif V8_TARGET_ARCH_X64
36 #include "x64/lithium-x64.h" 37 #include "x64/lithium-x64.h"
37 #elif V8_TARGET_ARCH_ARM 38 #elif V8_TARGET_ARCH_ARM
38 #include "arm/lithium-arm.h" 39 #include "arm/lithium-arm.h"
39 #else 40 #else
40 #error "Unknown architecture." 41 #error "Unknown architecture."
41 #endif 42 #endif
42 43
43 namespace v8 { 44 namespace v8 {
44 namespace internal { 45 namespace internal {
45 46
46 47
47 #define DEFINE_OPERAND_CACHE(name, type) \ 48 #define DEFINE_OPERAND_CACHE(name, type) \
48 name name::cache[name::kNumCachedOperands]; \ 49 name name::cache[name::kNumCachedOperands]; \
49 void name::SetupCache() { \ 50 void name::SetupCache() { \
50 for (int i = 0; i < kNumCachedOperands; i++) { \ 51 for (int i = 0; i < kNumCachedOperands; i++) { \
51 cache[i].ConvertTo(type, i); \ 52 cache[i].ConvertTo(type, i); \
52 } \ 53 } \
53 } 54 } \
55 static bool name##_initialize() { \
56 name::SetupCache(); \
57 return true; \
58 } \
59 static bool name##_cache_initialized = name##_initialize();
54 60
55 DEFINE_OPERAND_CACHE(LConstantOperand, CONSTANT_OPERAND) 61 DEFINE_OPERAND_CACHE(LConstantOperand, CONSTANT_OPERAND)
56 DEFINE_OPERAND_CACHE(LStackSlot, STACK_SLOT) 62 DEFINE_OPERAND_CACHE(LStackSlot, STACK_SLOT)
57 DEFINE_OPERAND_CACHE(LDoubleStackSlot, DOUBLE_STACK_SLOT) 63 DEFINE_OPERAND_CACHE(LDoubleStackSlot, DOUBLE_STACK_SLOT)
58 DEFINE_OPERAND_CACHE(LRegister, REGISTER) 64 DEFINE_OPERAND_CACHE(LRegister, REGISTER)
59 DEFINE_OPERAND_CACHE(LDoubleRegister, DOUBLE_REGISTER) 65 DEFINE_OPERAND_CACHE(LDoubleRegister, DOUBLE_REGISTER)
60 66
61 #undef DEFINE_OPERAND_CACHE 67 #undef DEFINE_OPERAND_CACHE
62 68
63 69
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 LUnallocated* unalloc = new LUnallocated(LUnallocated::NONE); 1020 LUnallocated* unalloc = new LUnallocated(LUnallocated::NONE);
1015 unalloc->set_virtual_register(op->id()); 1021 unalloc->set_virtual_register(op->id());
1016 operand = unalloc; 1022 operand = unalloc;
1017 } 1023 }
1018 HBasicBlock* cur_block = block->predecessors()->at(j); 1024 HBasicBlock* cur_block = block->predecessors()->at(j);
1019 // The gap move must be added without any special processing as in 1025 // The gap move must be added without any special processing as in
1020 // the AddConstraintsGapMove. 1026 // the AddConstraintsGapMove.
1021 chunk_->AddGapMove(cur_block->last_instruction_index() - 1, 1027 chunk_->AddGapMove(cur_block->last_instruction_index() - 1,
1022 operand, 1028 operand,
1023 phi_operand); 1029 phi_operand);
1030
1031 // We are going to insert a move before the branch instruction.
1032 // Some branch instructions (e.g. loops' back edges)
1033 // can potentially cause a GC so they have a pointer map.
1034 // By insterting a move we essentially create a copy of a
1035 // value which is invisible to PopulatePointerMaps(), because we store
1036 // it into a location different from the operand of a live range
1037 // covering a branch instruction.
1038 // Thus we need to manually record a pointer.
1039 if (phi->representation().IsTagged()) {
1040 LInstruction* branch =
1041 InstructionAt(cur_block->last_instruction_index());
1042 if (branch->HasPointerMap()) {
1043 branch->pointer_map()->RecordPointer(phi_operand);
1044 }
1045 }
1024 } 1046 }
1025 1047
1026 LiveRange* live_range = LiveRangeFor(phi->id()); 1048 LiveRange* live_range = LiveRangeFor(phi->id());
1027 LLabel* label = chunk_->GetLabel(phi->block()->block_id()); 1049 LLabel* label = chunk_->GetLabel(phi->block()->block_id());
1028 label->GetOrCreateParallelMove(LGap::START)-> 1050 label->GetOrCreateParallelMove(LGap::START)->
1029 AddMove(phi_operand, live_range->GetSpillOperand()); 1051 AddMove(phi_operand, live_range->GetSpillOperand());
1030 live_range->SetSpillStartIndex(phi->block()->first_instruction_index()); 1052 live_range->SetSpillStartIndex(phi->block()->first_instruction_index());
1031 } 1053 }
1032 } 1054 }
1033 1055
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 AddToActive(current); 1565 AddToActive(current);
1544 } 1566 }
1545 } 1567 }
1546 1568
1547 reusable_slots_.Rewind(0); 1569 reusable_slots_.Rewind(0);
1548 active_live_ranges_.Rewind(0); 1570 active_live_ranges_.Rewind(0);
1549 inactive_live_ranges_.Rewind(0); 1571 inactive_live_ranges_.Rewind(0);
1550 } 1572 }
1551 1573
1552 1574
1553 void LAllocator::Setup() {
1554 LConstantOperand::SetupCache();
1555 LStackSlot::SetupCache();
1556 LDoubleStackSlot::SetupCache();
1557 LRegister::SetupCache();
1558 LDoubleRegister::SetupCache();
1559 }
1560
1561
1562 const char* LAllocator::RegisterName(int allocation_index) { 1575 const char* LAllocator::RegisterName(int allocation_index) {
1563 ASSERT(mode_ != NONE); 1576 ASSERT(mode_ != NONE);
1564 if (mode_ == GENERAL_REGISTERS) { 1577 if (mode_ == GENERAL_REGISTERS) {
1565 return Register::AllocationIndexToString(allocation_index); 1578 return Register::AllocationIndexToString(allocation_index);
1566 } else { 1579 } else {
1567 return DoubleRegister::AllocationIndexToString(allocation_index); 1580 return DoubleRegister::AllocationIndexToString(allocation_index);
1568 } 1581 }
1569 } 1582 }
1570 1583
1571 1584
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
2097 LiveRange* current = live_ranges()->at(i); 2110 LiveRange* current = live_ranges()->at(i);
2098 if (current != NULL) current->Verify(); 2111 if (current != NULL) current->Verify();
2099 } 2112 }
2100 } 2113 }
2101 2114
2102 2115
2103 #endif 2116 #endif
2104 2117
2105 2118
2106 } } // namespace v8::internal 2119 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698