1
// Copyright 2011 the V8 project authors. All rights reserved.
1
// Copyright 2012 the V8 project authors. All rights reserved.
2
2
// Redistribution and use in source and binary forms, with or without
3
3
// modification, are permitted provided that the following conditions are
75
// Load the built-in InternalArray function from the current context.
76
static void GenerateLoadInternalArrayFunction(MacroAssembler* masm,
78
// Load the global context.
80
__ ldr(result, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX)));
82
FieldMemOperand(result, GlobalObject::kGlobalContextOffset));
83
// Load the InternalArray function from the global context.
87
Context::INTERNAL_ARRAY_FUNCTION_INDEX)));
75
91
// Load the built-in Array function from the current context.
76
92
static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) {
77
93
// Load the global context.
300
316
static void ArrayNativeCode(MacroAssembler* masm,
301
317
Label* call_generic_code) {
302
318
Counters* counters = masm->isolate()->counters();
303
Label argc_one_or_more, argc_two_or_more, not_empty_array, empty_array;
319
Label argc_one_or_more, argc_two_or_more, not_empty_array, empty_array,
305
322
// Check for array construction with zero arguments or one.
306
323
__ cmp(r0, Operand(0, RelocInfo::NONE));
317
334
call_generic_code);
318
335
__ IncrementCounter(counters->array_function_native(), 1, r3, r4);
319
// Setup return value, remove receiver from stack and return.
336
// Set up return value, remove receiver from stack and return.
321
338
__ add(sp, sp, Operand(kPointerSize));
360
377
call_generic_code);
361
378
__ IncrementCounter(counters->array_function_native(), 1, r2, r4);
362
// Setup return value, remove receiver and argument from stack and return.
379
// Set up return value, remove receiver and argument from stack and return.
364
381
__ add(sp, sp, Operand(2 * kPointerSize));
394
411
// r5: elements_array_end (untagged)
395
412
// sp[0]: last argument
396
413
Label loop, entry;
399
__ ldr(r2, MemOperand(sp, kPointerSize, PostIndex));
417
__ ldr(r2, MemOperand(r7, kPointerSize, PostIndex));
418
if (FLAG_smi_only_arrays) {
419
__ JumpIfNotSmi(r2, &has_non_smi_element);
400
421
__ str(r2, MemOperand(r5, -kPointerSize, PreIndex));
405
427
// Remove caller arguments and receiver from the stack, setup return value and
410
432
__ add(sp, sp, Operand(kPointerSize));
436
__ bind(&has_non_smi_element);
437
__ UndoAllocationInNewSpace(r3, r4);
438
__ b(call_generic_code);
442
void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
443
// ----------- S t a t e -------------
444
// -- r0 : number of arguments
445
// -- lr : return address
446
// -- sp[...]: constructor arguments
447
// -----------------------------------
448
Label generic_array_code, one_or_more_arguments, two_or_more_arguments;
450
// Get the InternalArray function.
451
GenerateLoadInternalArrayFunction(masm, r1);
453
if (FLAG_debug_code) {
454
// Initial map for the builtin InternalArray functions should be maps.
455
__ ldr(r2, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset));
456
__ tst(r2, Operand(kSmiTagMask));
457
__ Assert(ne, "Unexpected initial map for InternalArray function");
458
__ CompareObjectType(r2, r3, r4, MAP_TYPE);
459
__ Assert(eq, "Unexpected initial map for InternalArray function");
462
// Run the native code for the InternalArray function called as a normal
464
ArrayNativeCode(masm, &generic_array_code);
466
// Jump to the generic array code if the specialized code cannot handle the
468
__ bind(&generic_array_code);
470
Handle<Code> array_code =
471
masm->isolate()->builtins()->InternalArrayCodeGeneric();
472
__ Jump(array_code, RelocInfo::CODE_TARGET);
891
951
// sp[4]: number of arguments (smi-tagged)
892
952
__ ldr(r3, MemOperand(sp, 4 * kPointerSize));
894
// Setup pointer to last argument.
954
// Set up pointer to last argument.
895
955
__ add(r2, fp, Operand(StandardFrameConstants::kCallerSPOffset));
897
// Setup number of arguments for function call below
957
// Set up number of arguments for function call below
898
958
__ mov(r0, Operand(r3, LSR, kSmiTagSize));
900
960
// Copy arguments and receiver to the expression stack.
1022
1082
// Set up the context from the function argument.
1023
1083
__ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset));
1025
// Set up the roots register.
1026
ExternalReference roots_array_start =
1027
ExternalReference::roots_array_start(masm->isolate());
1028
__ mov(r10, Operand(roots_array_start));
1085
__ InitializeRootRegister();
1030
1087
// Push the function and the receiver onto the stack.