OLD | NEW |
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 |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include "virtual-frame-inl.h" | 36 #include "virtual-frame-inl.h" |
37 | 37 |
38 namespace v8 { | 38 namespace v8 { |
39 namespace internal { | 39 namespace internal { |
40 | 40 |
41 // ------------------------------------------------------------------------- | 41 // ------------------------------------------------------------------------- |
42 // JumpTarget implementation. | 42 // JumpTarget implementation. |
43 | 43 |
44 #define __ ACCESS_MASM(cgen()->masm()) | 44 #define __ ACCESS_MASM(cgen()->masm()) |
45 | 45 |
| 46 // BRANCH_ARGS_CHECK checks that conditional jump arguments are correct. |
| 47 #define BRANCH_ARGS_CHECK(cond, rs, rt) ASSERT( \ |
| 48 (cond == cc_always && rs.is(zero_reg) && rt.rm().is(zero_reg)) || \ |
| 49 (cond != cc_always && (!rs.is(zero_reg) || !rt.rm().is(zero_reg)))) |
| 50 |
| 51 |
46 void JumpTarget::DoJump() { | 52 void JumpTarget::DoJump() { |
47 ASSERT(cgen()->has_valid_frame()); | 53 UNIMPLEMENTED_MIPS(); |
48 // Live non-frame registers are not allowed at unconditional jumps | |
49 // because we have no way of invalidating the corresponding results | |
50 // which are still live in the C++ code. | |
51 ASSERT(cgen()->HasValidEntryRegisters()); | |
52 | |
53 if (is_bound()) { | |
54 // Backward jump. There already a frame expectation at the target. | |
55 ASSERT(direction_ == BIDIRECTIONAL); | |
56 cgen()->frame()->MergeTo(entry_frame_); | |
57 cgen()->DeleteFrame(); | |
58 } else { | |
59 // Use the current frame as the expected one at the target if necessary. | |
60 if (entry_frame_ == NULL) { | |
61 entry_frame_ = cgen()->frame(); | |
62 RegisterFile empty; | |
63 cgen()->SetFrame(NULL, &empty); | |
64 } else { | |
65 cgen()->frame()->MergeTo(entry_frame_); | |
66 cgen()->DeleteFrame(); | |
67 } | |
68 | |
69 // The predicate is_linked() should be made true. Its implementation | |
70 // detects the presence of a frame pointer in the reaching_frames_ list. | |
71 if (!is_linked()) { | |
72 reaching_frames_.Add(NULL); | |
73 ASSERT(is_linked()); | |
74 } | |
75 } | |
76 __ b(&entry_label_); | |
77 __ nop(); // Branch delay slot nop. | |
78 } | 54 } |
79 | 55 |
80 | 56 // Original prototype for mips, needs arch-indep change. Leave out for now. |
| 57 // void JumpTarget::DoBranch(Condition cc, Hint ignored, |
| 58 // Register src1, const Operand& src2) { |
81 void JumpTarget::DoBranch(Condition cc, Hint ignored) { | 59 void JumpTarget::DoBranch(Condition cc, Hint ignored) { |
82 UNIMPLEMENTED_MIPS(); | 60 UNIMPLEMENTED_MIPS(); |
83 } | 61 } |
84 | 62 |
85 | 63 |
86 void JumpTarget::Call() { | 64 void JumpTarget::Call() { |
87 UNIMPLEMENTED_MIPS(); | 65 UNIMPLEMENTED_MIPS(); |
88 } | 66 } |
89 | 67 |
90 | 68 |
91 void JumpTarget::DoBind() { | 69 void JumpTarget::DoBind() { |
92 ASSERT(!is_bound()); | |
93 | |
94 // Live non-frame registers are not allowed at the start of a basic | |
95 // block. | |
96 ASSERT(!cgen()->has_valid_frame() || cgen()->HasValidEntryRegisters()); | |
97 | |
98 if (cgen()->has_valid_frame()) { | |
99 // If there is a current frame we can use it on the fall through. | |
100 if (entry_frame_ == NULL) { | |
101 entry_frame_ = new VirtualFrame(cgen()->frame()); | |
102 } else { | |
103 ASSERT(cgen()->frame()->Equals(entry_frame_)); | |
104 } | |
105 } else { | |
106 // If there is no current frame we must have an entry frame which we can | |
107 // copy. | |
108 ASSERT(entry_frame_ != NULL); | |
109 RegisterFile empty; | |
110 cgen()->SetFrame(new VirtualFrame(entry_frame_), &empty); | |
111 } | |
112 | |
113 // The predicate is_linked() should be made false. Its implementation | |
114 // detects the presence (or absence) of frame pointers in the | |
115 // reaching_frames_ list. If we inserted a bogus frame to make | |
116 // is_linked() true, remove it now. | |
117 if (is_linked()) { | |
118 reaching_frames_.Clear(); | |
119 } | |
120 | |
121 __ bind(&entry_label_); | |
122 } | |
123 | |
124 | |
125 void BreakTarget::Jump() { | |
126 // On ARM we do not currently emit merge code for jumps, so we need to do | |
127 // it explicitly here. The only merging necessary is to drop extra | |
128 // statement state from the stack. | |
129 ASSERT(cgen()->has_valid_frame()); | |
130 int count = cgen()->frame()->height() - expected_height_; | |
131 cgen()->frame()->Drop(count); | |
132 DoJump(); | |
133 } | |
134 | |
135 | |
136 void BreakTarget::Jump(Result* arg) { | |
137 UNIMPLEMENTED_MIPS(); | |
138 } | |
139 | |
140 | |
141 void BreakTarget::Bind() { | |
142 #ifdef DEBUG | |
143 // All the forward-reaching frames should have been adjusted at the | |
144 // jumps to this target. | |
145 for (int i = 0; i < reaching_frames_.length(); i++) { | |
146 ASSERT(reaching_frames_[i] == NULL || | |
147 reaching_frames_[i]->height() == expected_height_); | |
148 } | |
149 #endif | |
150 // Drop leftover statement state from the frame before merging, even | |
151 // on the fall through. This is so we can bind the return target | |
152 // with state on the frame. | |
153 if (cgen()->has_valid_frame()) { | |
154 int count = cgen()->frame()->height() - expected_height_; | |
155 // On ARM we do not currently emit merge code at binding sites, so we need | |
156 // to do it explicitly here. The only merging necessary is to drop extra | |
157 // statement state from the stack. | |
158 cgen()->frame()->Drop(count); | |
159 } | |
160 | |
161 DoBind(); | |
162 } | |
163 | |
164 | |
165 void BreakTarget::Bind(Result* arg) { | |
166 UNIMPLEMENTED_MIPS(); | 70 UNIMPLEMENTED_MIPS(); |
167 } | 71 } |
168 | 72 |
169 | 73 |
170 #undef __ | 74 #undef __ |
| 75 #undef BRANCH_ARGS_CHECK |
171 | 76 |
172 | 77 |
173 } } // namespace v8::internal | 78 } } // namespace v8::internal |
174 | 79 |
175 #endif // V8_TARGET_ARCH_MIPS | 80 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |