~ubuntu-branches/ubuntu/saucy/libv8/saucy

« back to all changes in this revision

Viewing changes to src/arm/builtins-arm.cc

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2012-04-07 16:26:13 UTC
  • mfrom: (15.1.27 sid)
  • Revision ID: package-import@ubuntu.com-20120407162613-dqo1m6w9r3fh8tst
Tags: 3.8.9.16-3
* mipsel build fixes :
  + v8_use_mips_abi_hardfloat=false, this lowers EABI requirements.
  + v8_can_use_fpu_instructions=false, detect if FPU is present.
  + set -Wno-unused-but-set-variable only on mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
4
4
// met:
72
72
}
73
73
 
74
74
 
 
75
// Load the built-in InternalArray function from the current context.
 
76
static void GenerateLoadInternalArrayFunction(MacroAssembler* masm,
 
77
                                              Register result) {
 
78
  // Load the global context.
 
79
 
 
80
  __ ldr(result, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX)));
 
81
  __ ldr(result,
 
82
         FieldMemOperand(result, GlobalObject::kGlobalContextOffset));
 
83
  // Load the InternalArray function from the global context.
 
84
  __ ldr(result,
 
85
         MemOperand(result,
 
86
                    Context::SlotOffset(
 
87
                        Context::INTERNAL_ARRAY_FUNCTION_INDEX)));
 
88
}
 
89
 
 
90
 
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,
 
320
      has_non_smi_element;
304
321
 
305
322
  // Check for array construction with zero arguments or one.
306
323
  __ cmp(r0, Operand(0, RelocInfo::NONE));
316
333
                       r5,
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.
320
337
  __ mov(r0, r2);
321
338
  __ add(sp, sp, Operand(kPointerSize));
322
339
  __ Jump(lr);
359
376
                  true,
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.
363
380
  __ mov(r0, r3);
364
381
  __ add(sp, sp, Operand(2 * kPointerSize));
365
382
  __ Jump(lr);
394
411
  // r5: elements_array_end (untagged)
395
412
  // sp[0]: last argument
396
413
  Label loop, entry;
 
414
  __ mov(r7, sp);
397
415
  __ jmp(&entry);
398
416
  __ bind(&loop);
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);
 
420
  }
400
421
  __ str(r2, MemOperand(r5, -kPointerSize, PreIndex));
401
422
  __ bind(&entry);
402
423
  __ cmp(r4, r5);
403
424
  __ b(lt, &loop);
 
425
  __ mov(sp, r7);
404
426
 
405
427
  // Remove caller arguments and receiver from the stack, setup return value and
406
428
  // return.
410
432
  __ add(sp, sp, Operand(kPointerSize));
411
433
  __ mov(r0, r3);
412
434
  __ Jump(lr);
 
435
 
 
436
  __ bind(&has_non_smi_element);
 
437
  __ UndoAllocationInNewSpace(r3, r4);
 
438
  __ b(call_generic_code);
 
439
}
 
440
 
 
441
 
 
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;
 
449
 
 
450
  // Get the InternalArray function.
 
451
  GenerateLoadInternalArrayFunction(masm, r1);
 
452
 
 
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");
 
460
  }
 
461
 
 
462
  // Run the native code for the InternalArray function called as a normal
 
463
  // function.
 
464
  ArrayNativeCode(masm, &generic_array_code);
 
465
 
 
466
  // Jump to the generic array code if the specialized code cannot handle the
 
467
  // construction.
 
468
  __ bind(&generic_array_code);
 
469
 
 
470
  Handle<Code> array_code =
 
471
      masm->isolate()->builtins()->InternalArrayCodeGeneric();
 
472
  __ Jump(array_code, RelocInfo::CODE_TARGET);
413
473
}
414
474
 
415
475
 
891
951
    // sp[4]: number of arguments (smi-tagged)
892
952
    __ ldr(r3, MemOperand(sp, 4 * kPointerSize));
893
953
 
894
 
    // Setup pointer to last argument.
 
954
    // Set up pointer to last argument.
895
955
    __ add(r2, fp, Operand(StandardFrameConstants::kCallerSPOffset));
896
956
 
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));
899
959
 
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));
1024
1084
 
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();
1029
1086
 
1030
1087
    // Push the function and the receiver onto the stack.
1031
1088
    __ push(r1);
1703
1760
  __ bind(&invoke);
1704
1761
  __ Call(r3);
1705
1762
 
 
1763
  masm->isolate()->heap()->SetArgumentsAdaptorDeoptPCOffset(masm->pc_offset());
1706
1764
  // Exit frame and return.
1707
1765
  LeaveArgumentsAdaptorFrame(masm);
1708
1766
  __ Jump(lr);