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

Side by Side Diff: src/ppc/builtins-ppc.cc

Issue 1425353002: PPC: [es6] Better support for built-ins subclassing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 __ TailCallRuntime(Runtime::kSymbolDescriptiveString, 1, 1); 215 __ TailCallRuntime(Runtime::kSymbolDescriptiveString, 1, 1);
216 } 216 }
217 } 217 }
218 218
219 219
220 // static 220 // static
221 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { 221 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) {
222 // ----------- S t a t e ------------- 222 // ----------- S t a t e -------------
223 // -- r3 : number of arguments 223 // -- r3 : number of arguments
224 // -- r4 : constructor function 224 // -- r4 : constructor function
225 // -- r6 : original constructor
225 // -- lr : return address 226 // -- lr : return address
226 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) 227 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based)
227 // -- sp[argc * 4] : receiver 228 // -- sp[argc * 4] : receiver
228 // ----------------------------------- 229 // -----------------------------------
229 230
230 // 1. Load the first argument into r3 and get rid of the rest (including the 231 // 1. Load the first argument into r5 and get rid of the rest (including the
231 // receiver). 232 // receiver).
232 { 233 {
233 Label no_arguments, done; 234 Label no_arguments, done;
234 __ cmpi(r3, Operand::Zero()); 235 __ cmpi(r3, Operand::Zero());
235 __ beq(&no_arguments); 236 __ beq(&no_arguments);
236 __ subi(r3, r3, Operand(1)); 237 __ subi(r3, r3, Operand(1));
237 __ ShiftLeftImm(r3, r3, Operand(kPointerSizeLog2)); 238 __ ShiftLeftImm(r5, r3, Operand(kPointerSizeLog2));
238 __ LoadPUX(r3, MemOperand(sp, r3)); 239 __ LoadPUX(r5, MemOperand(sp, r5));
239 __ Drop(2); 240 __ Drop(2);
240 __ b(&done); 241 __ b(&done);
241 __ bind(&no_arguments); 242 __ bind(&no_arguments);
242 __ LoadRoot(r3, Heap::kempty_stringRootIndex); 243 __ LoadRoot(r5, Heap::kempty_stringRootIndex);
243 __ Drop(1); 244 __ Drop(1);
244 __ bind(&done); 245 __ bind(&done);
245 } 246 }
246 247
247 // 2. Make sure r3 is a string. 248 // 2. Make sure r5 is a string.
248 { 249 {
249 Label convert, done_convert; 250 Label convert, done_convert;
250 __ JumpIfSmi(r3, &convert); 251 __ JumpIfSmi(r5, &convert);
251 __ CompareObjectType(r3, r5, r5, FIRST_NONSTRING_TYPE); 252 __ CompareObjectType(r5, r7, r7, FIRST_NONSTRING_TYPE);
252 __ blt(&done_convert); 253 __ blt(&done_convert);
253 __ bind(&convert); 254 __ bind(&convert);
254 { 255 {
255 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); 256 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
256 ToStringStub stub(masm->isolate()); 257 ToStringStub stub(masm->isolate());
257 __ push(r4); 258 __ Push(r4, r6);
259 __ mr(r3, r5);
258 __ CallStub(&stub); 260 __ CallStub(&stub);
259 __ pop(r4); 261 __ mr(r5, r3);
262 __ Pop(r4, r6);
260 } 263 }
261 __ bind(&done_convert); 264 __ bind(&done_convert);
262 } 265 }
263 266
264 // 3. Allocate a JSValue wrapper for the string. 267 // 3. Allocate a JSValue wrapper for the string.
265 { 268 {
266 // ----------- S t a t e ------------- 269 // ----------- S t a t e -------------
267 // -- r3 : the first argument 270 // -- r5 : the first argument
268 // -- r4 : constructor function 271 // -- r4 : constructor function
272 // -- r6 : original constructor
269 // -- lr : return address 273 // -- lr : return address
270 // ----------------------------------- 274 // -----------------------------------
271 275
272 Label allocate, done_allocate; 276 Label allocate, done_allocate, rt_call;
273 __ mr(r5, r3); 277
278 // Fall back to runtime if the original constructor and function differ.
279 __ cmp(r4, r6);
280 __ bne(&rt_call);
281
274 __ Allocate(JSValue::kSize, r3, r6, r7, &allocate, TAG_OBJECT); 282 __ Allocate(JSValue::kSize, r3, r6, r7, &allocate, TAG_OBJECT);
275 __ bind(&done_allocate); 283 __ bind(&done_allocate);
276 284
277 // Initialize the JSValue in r3. 285 // Initialize the JSValue in r3.
278 __ LoadGlobalFunctionInitialMap(r4, r6, r7); 286 __ LoadGlobalFunctionInitialMap(r4, r6, r7);
279 __ StoreP(r6, FieldMemOperand(r3, HeapObject::kMapOffset), r0); 287 __ StoreP(r6, FieldMemOperand(r3, HeapObject::kMapOffset), r0);
280 __ LoadRoot(r6, Heap::kEmptyFixedArrayRootIndex); 288 __ LoadRoot(r6, Heap::kEmptyFixedArrayRootIndex);
281 __ StoreP(r6, FieldMemOperand(r3, JSObject::kPropertiesOffset), r0); 289 __ StoreP(r6, FieldMemOperand(r3, JSObject::kPropertiesOffset), r0);
282 __ StoreP(r6, FieldMemOperand(r3, JSObject::kElementsOffset), r0); 290 __ StoreP(r6, FieldMemOperand(r3, JSObject::kElementsOffset), r0);
283 __ StoreP(r5, FieldMemOperand(r3, JSValue::kValueOffset), r0); 291 __ StoreP(r5, FieldMemOperand(r3, JSValue::kValueOffset), r0);
284 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); 292 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize);
285 __ Ret(); 293 __ Ret();
286 294
287 // Fallback to the runtime to allocate in new space. 295 // Fallback to the runtime to allocate in new space.
288 __ bind(&allocate); 296 __ bind(&allocate);
289 { 297 {
290 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); 298 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
291 __ LoadSmiLiteral(r6, Smi::FromInt(JSValue::kSize)); 299 __ LoadSmiLiteral(r6, Smi::FromInt(JSValue::kSize));
292 __ Push(r4, r5, r6); 300 __ Push(r4, r5, r6);
293 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); 301 __ CallRuntime(Runtime::kAllocateInNewSpace, 1);
294 __ Pop(r4, r5); 302 __ Pop(r4, r5);
295 } 303 }
296 __ b(&done_allocate); 304 __ b(&done_allocate);
305
306 // Fallback to the runtime to create new object.
307 __ bind(&rt_call);
308 {
309 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
310 __ Push(r4, r5, r4, r6); // constructor function, original constructor
311 __ CallRuntime(Runtime::kNewObject, 2);
312 __ Pop(r4, r5);
313 }
314 __ StoreP(r5, FieldMemOperand(r3, JSValue::kValueOffset), r0);
315 __ Ret();
297 } 316 }
298 } 317 }
299 318
300 319
301 static void CallRuntimePassFunction(MacroAssembler* masm, 320 static void CallRuntimePassFunction(MacroAssembler* masm,
302 Runtime::FunctionId function_id) { 321 Runtime::FunctionId function_id) {
303 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); 322 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
304 // Push a copy of the function onto the stack. 323 // Push a copy of the function onto the stack.
305 // Push function as parameter to the runtime call. 324 // Push function as parameter to the runtime call.
306 __ Push(r4, r4); 325 __ Push(r4, r4);
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 521
503 // Reload the original constructor and fall-through. 522 // Reload the original constructor and fall-through.
504 __ bind(&rt_call_reload_new_target); 523 __ bind(&rt_call_reload_new_target);
505 __ LoadP(r6, MemOperand(sp, 0 * kPointerSize)); 524 __ LoadP(r6, MemOperand(sp, 0 * kPointerSize));
506 } 525 }
507 526
508 // Allocate the new receiver object using the runtime call. 527 // Allocate the new receiver object using the runtime call.
509 // r4: constructor function 528 // r4: constructor function
510 // r6: original constructor 529 // r6: original constructor
511 __ bind(&rt_call); 530 __ bind(&rt_call);
512 __ Push(r4, r6); 531 __ Push(r4, r6); // constructor function, original constructor
513 __ CallRuntime(Runtime::kNewObject, 2); 532 __ CallRuntime(Runtime::kNewObject, 2);
514 __ mr(r7, r3); 533 __ mr(r7, r3);
515 534
516 // Receiver for constructor call allocated. 535 // Receiver for constructor call allocated.
517 // r7: JSObject 536 // r7: JSObject
518 __ bind(&allocated); 537 __ bind(&allocated);
519 538
520 // Restore the parameters. 539 // Restore the parameters.
521 __ Pop(r4, ip); 540 __ Pop(r4, ip);
522 541
(...skipping 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1945 __ bkpt(0); 1964 __ bkpt(0);
1946 } 1965 }
1947 } 1966 }
1948 1967
1949 1968
1950 #undef __ 1969 #undef __
1951 } // namespace internal 1970 } // namespace internal
1952 } // namespace v8 1971 } // namespace v8
1953 1972
1954 #endif // V8_TARGET_ARCH_PPC 1973 #endif // V8_TARGET_ARCH_PPC
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698