OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_PPC | 5 #if V8_TARGET_ARCH_PPC |
6 | 6 |
7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 125 |
126 __ mr(r6, r4); | 126 __ mr(r6, r4); |
127 // Run the native code for the Array function called as a normal function. | 127 // Run the native code for the Array function called as a normal function. |
128 // tail call a stub | 128 // tail call a stub |
129 __ LoadRoot(r5, Heap::kUndefinedValueRootIndex); | 129 __ LoadRoot(r5, Heap::kUndefinedValueRootIndex); |
130 ArrayConstructorStub stub(masm->isolate()); | 130 ArrayConstructorStub stub(masm->isolate()); |
131 __ TailCallStub(&stub); | 131 __ TailCallStub(&stub); |
132 } | 132 } |
133 | 133 |
134 | 134 |
135 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { | 135 // static |
| 136 void Builtins::Generate_StringConstructor(MacroAssembler* masm) { |
136 // ----------- S t a t e ------------- | 137 // ----------- S t a t e ------------- |
137 // -- r3 : number of arguments | 138 // -- r3 : number of arguments |
138 // -- r4 : constructor function | 139 // -- r4 : constructor function |
| 140 // -- lr : return address |
| 141 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) |
| 142 // -- sp[argc * 4] : receiver |
| 143 // ----------------------------------- |
| 144 |
| 145 // 1. Load the first argument into r3 and get rid of the rest (including the |
| 146 // receiver). |
| 147 Label no_arguments; |
| 148 { |
| 149 __ cmpi(r3, Operand::Zero()); |
| 150 __ beq(&no_arguments); |
| 151 __ subi(r3, r3, Operand(1)); |
| 152 __ ShiftLeftImm(r3, r3, Operand(kPointerSizeLog2)); |
| 153 __ LoadPUX(r3, MemOperand(sp, r3)); |
| 154 __ Drop(2); |
| 155 } |
| 156 |
| 157 // 2a. At least one argument, return r3 if it's a string, otherwise |
| 158 // dispatch to appropriate conversion. |
| 159 Label to_string, symbol_descriptive_string; |
| 160 { |
| 161 __ JumpIfSmi(r3, &to_string); |
| 162 STATIC_ASSERT(FIRST_NONSTRING_TYPE == SYMBOL_TYPE); |
| 163 __ CompareObjectType(r3, r4, r4, FIRST_NONSTRING_TYPE); |
| 164 __ bgt(&to_string); |
| 165 __ beq(&symbol_descriptive_string); |
| 166 __ Ret(); |
| 167 } |
| 168 |
| 169 // 2b. No arguments, return the empty string (and pop the receiver). |
| 170 __ bind(&no_arguments); |
| 171 { |
| 172 __ LoadRoot(r3, Heap::kempty_stringRootIndex); |
| 173 __ Ret(1); |
| 174 } |
| 175 |
| 176 // 3a. Convert r3 to a string. |
| 177 __ bind(&to_string); |
| 178 { |
| 179 ToStringStub stub(masm->isolate()); |
| 180 __ TailCallStub(&stub); |
| 181 } |
| 182 |
| 183 // 3b. Convert symbol in r3 to a string. |
| 184 __ bind(&symbol_descriptive_string); |
| 185 { |
| 186 __ Push(r3); |
| 187 __ TailCallRuntime(Runtime::kSymbolDescriptiveString, 1, 1); |
| 188 } |
| 189 } |
| 190 |
| 191 |
| 192 // static |
| 193 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { |
| 194 // ----------- S t a t e ------------- |
| 195 // -- r3 : number of arguments |
| 196 // -- r4 : constructor function |
139 // -- lr : return address | 197 // -- lr : return address |
140 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) | 198 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) |
141 // -- sp[argc * 4] : receiver | 199 // -- sp[argc * 4] : receiver |
142 // ----------------------------------- | 200 // ----------------------------------- |
143 | 201 |
144 // 1. Load the first argument into r5 and get rid of the rest (including the | 202 // 1. Load the first argument into r3 and get rid of the rest (including the |
145 // receiver). | 203 // receiver). |
146 { | 204 { |
147 Label no_arguments, done; | 205 Label no_arguments, done; |
148 __ cmpi(r3, Operand::Zero()); | 206 __ cmpi(r3, Operand::Zero()); |
149 __ beq(&no_arguments); | 207 __ beq(&no_arguments); |
150 __ subi(r5, r3, Operand(1)); | 208 __ subi(r3, r3, Operand(1)); |
151 __ ShiftLeftImm(r5, r5, Operand(kPointerSizeLog2)); | 209 __ ShiftLeftImm(r3, r3, Operand(kPointerSizeLog2)); |
152 __ LoadPUX(r5, MemOperand(sp, r5)); | 210 __ LoadPUX(r3, MemOperand(sp, r3)); |
153 __ Drop(2); | 211 __ Drop(2); |
154 __ b(&done); | 212 __ b(&done); |
155 __ bind(&no_arguments); | 213 __ bind(&no_arguments); |
156 __ LoadRoot(r5, Heap::kempty_stringRootIndex); | 214 __ LoadRoot(r3, Heap::kempty_stringRootIndex); |
157 __ Drop(1); | 215 __ Drop(1); |
158 __ bind(&done); | 216 __ bind(&done); |
159 } | 217 } |
160 | 218 |
161 // 2. Make sure r5 is a string. | 219 // 2. Make sure r3 is a string. |
162 { | 220 { |
163 Label convert, done_convert; | 221 Label convert, done_convert; |
164 __ JumpIfSmi(r5, &convert); | 222 __ JumpIfSmi(r3, &convert); |
165 __ CompareObjectType(r5, r6, r6, FIRST_NONSTRING_TYPE); | 223 __ CompareObjectType(r3, r5, r5, FIRST_NONSTRING_TYPE); |
166 __ blt(&done_convert); | 224 __ blt(&done_convert); |
167 __ bind(&convert); | 225 __ bind(&convert); |
168 { | 226 { |
169 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 227 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
170 ToStringStub stub(masm->isolate()); | 228 ToStringStub stub(masm->isolate()); |
171 __ push(r4); | 229 __ push(r4); |
172 __ mr(r3, r5); | |
173 __ CallStub(&stub); | 230 __ CallStub(&stub); |
174 __ mr(r5, r3); | |
175 __ pop(r4); | 231 __ pop(r4); |
176 } | 232 } |
177 __ bind(&done_convert); | 233 __ bind(&done_convert); |
178 } | 234 } |
179 | 235 |
180 // 3. Allocate a JSValue wrapper for the string. | 236 // 3. Allocate a JSValue wrapper for the string. |
181 { | 237 { |
182 // ----------- S t a t e ------------- | 238 // ----------- S t a t e ------------- |
| 239 // -- r3 : the first argument |
183 // -- r4 : constructor function | 240 // -- r4 : constructor function |
184 // -- r5 : the first argument | |
185 // -- lr : return address | 241 // -- lr : return address |
186 // ----------------------------------- | 242 // ----------------------------------- |
187 | 243 |
188 Label allocate, done_allocate; | 244 Label allocate, done_allocate; |
| 245 __ mr(r5, r3); |
189 __ Allocate(JSValue::kSize, r3, r6, r7, &allocate, TAG_OBJECT); | 246 __ Allocate(JSValue::kSize, r3, r6, r7, &allocate, TAG_OBJECT); |
190 __ bind(&done_allocate); | 247 __ bind(&done_allocate); |
191 | 248 |
192 // Initialize the JSValue in eax. | 249 // Initialize the JSValue in r3. |
193 __ LoadGlobalFunctionInitialMap(r4, r6, r7); | 250 __ LoadGlobalFunctionInitialMap(r4, r6, r7); |
194 __ StoreP(r6, FieldMemOperand(r3, HeapObject::kMapOffset), r0); | 251 __ StoreP(r6, FieldMemOperand(r3, HeapObject::kMapOffset), r0); |
195 __ LoadRoot(r6, Heap::kEmptyFixedArrayRootIndex); | 252 __ LoadRoot(r6, Heap::kEmptyFixedArrayRootIndex); |
196 __ StoreP(r6, FieldMemOperand(r3, JSObject::kPropertiesOffset), r0); | 253 __ StoreP(r6, FieldMemOperand(r3, JSObject::kPropertiesOffset), r0); |
197 __ StoreP(r6, FieldMemOperand(r3, JSObject::kElementsOffset), r0); | 254 __ StoreP(r6, FieldMemOperand(r3, JSObject::kElementsOffset), r0); |
198 __ StoreP(r5, FieldMemOperand(r3, JSValue::kValueOffset), r0); | 255 __ StoreP(r5, FieldMemOperand(r3, JSValue::kValueOffset), r0); |
199 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); | 256 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); |
200 __ Ret(); | 257 __ Ret(); |
201 | 258 |
202 // Fallback to the runtime to allocate in new space. | 259 // Fallback to the runtime to allocate in new space. |
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1810 __ bkpt(0); | 1867 __ bkpt(0); |
1811 } | 1868 } |
1812 } | 1869 } |
1813 | 1870 |
1814 | 1871 |
1815 #undef __ | 1872 #undef __ |
1816 } // namespace internal | 1873 } // namespace internal |
1817 } // namespace v8 | 1874 } // namespace v8 |
1818 | 1875 |
1819 #endif // V8_TARGET_ARCH_PPC | 1876 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |