Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2444 | 2444 |
| 2445 | 2445 |
| 2446 void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) { | 2446 void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) { |
| 2447 ASSERT(ToRegister(instr->result()).is(r0)); | 2447 ASSERT(ToRegister(instr->result()).is(r0)); |
| 2448 __ mov(r1, Operand(instr->function())); | 2448 __ mov(r1, Operand(instr->function())); |
| 2449 CallKnownFunction(instr->function(), instr->arity(), instr); | 2449 CallKnownFunction(instr->function(), instr->arity(), instr); |
| 2450 } | 2450 } |
| 2451 | 2451 |
| 2452 | 2452 |
| 2453 void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr) { | 2453 void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr) { |
| 2454 Abort("DoDeferredMathAbsTaggedHeapNumber unimplemented."); | 2454 Register input = ToRegister(instr->input()); |
| 2455 Register scratch = scratch0(); | |
| 2456 | |
| 2457 // Deoptimize if not a heap number. | |
| 2458 __ ldr(scratch, FieldMemOperand(input, HeapObject::kMapOffset)); | |
| 2459 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); | |
| 2460 __ cmp(scratch, Operand(ip)); | |
| 2461 DeoptimizeIf(ne, instr->environment()); | |
| 2462 | |
| 2463 Label done; | |
| 2464 Register tmp = input.is(r0) ? r1 : r0; | |
| 2465 Register tmp2 = r2; | |
| 2466 Register tmp3 = r3; | |
| 2467 | |
| 2468 // Preserve the value of all registers. | |
| 2469 __ PushSafepointRegisters(); | |
| 2470 | |
| 2471 Label negative; | |
| 2472 __ ldr(scratch, FieldMemOperand(input, HeapNumber::kExponentOffset)); | |
| 2473 // Check the sign of the argument. If the argument is positive, just | |
| 2474 // return it. We do not need to patch the stack since |input| and | |
| 2475 // |result| are the same register and |input| will be restored | |
| 2476 // unchanged by popping safepoint registers. | |
| 2477 __ tst(scratch, Operand(HeapNumber::kSignMask)); | |
| 2478 __ b(ne, &negative); | |
| 2479 __ jmp(&done); | |
|
Søren Thygesen Gjesse
2011/01/20 08:03:22
Can't you move the PushSafepointRegisters() to her
Mads Ager (chromium)
2011/01/20 08:07:31
Great! Yes I can!
| |
| 2480 | |
| 2481 __ bind(&negative); | |
| 2482 | |
| 2483 Label allocated, slow; | |
| 2484 __ LoadRoot(scratch, Heap::kHeapNumberMapRootIndex); | |
| 2485 __ AllocateHeapNumber(tmp, tmp2, tmp3, scratch, &slow); | |
| 2486 __ b(&allocated); | |
| 2487 | |
| 2488 // Slow case: Call the runtime system to do the number allocation. | |
| 2489 __ bind(&slow); | |
| 2490 | |
| 2491 __ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber); | |
| 2492 RecordSafepointWithRegisters( | |
| 2493 instr->pointer_map(), 0, Safepoint::kNoDeoptimizationIndex); | |
| 2494 // Set the pointer to the new heap number in tmp. | |
| 2495 if (!tmp.is(r0)) __ mov(tmp, Operand(r0)); | |
| 2496 | |
| 2497 // Restore input_reg after call to runtime. | |
| 2498 MemOperand input_register_slot = masm()->SafepointRegisterSlot(input); | |
| 2499 __ ldr(input, input_register_slot); | |
| 2500 | |
| 2501 __ bind(&allocated); | |
| 2502 __ ldr(tmp2, FieldMemOperand(input, HeapNumber::kExponentOffset)); | |
| 2503 __ bic(tmp2, tmp2, Operand(HeapNumber::kSignMask)); | |
| 2504 __ str(tmp2, FieldMemOperand(tmp, HeapNumber::kExponentOffset)); | |
| 2505 __ ldr(tmp2, FieldMemOperand(input, HeapNumber::kMantissaOffset)); | |
| 2506 __ str(tmp2, FieldMemOperand(tmp, HeapNumber::kMantissaOffset)); | |
| 2507 | |
| 2508 __ str(tmp, input_register_slot); | |
| 2509 | |
| 2510 __ bind(&done); | |
| 2511 __ PopSafepointRegisters(); | |
| 2512 } | |
| 2513 | |
| 2514 | |
| 2515 void LCodeGen::EmitIntegerMathAbs(LUnaryMathOperation* instr) { | |
| 2516 Label is_positive; | |
| 2517 uint32_t kSignMask = 0x80000000u; | |
| 2518 Register input = ToRegister(instr->input()); | |
| 2519 __ tst(input, Operand(kSignMask)); | |
| 2520 __ b(eq, &is_positive); | |
| 2521 __ rsb(input, input, Operand(0), SetCC); | |
| 2522 // Deoptimize on overflow. | |
| 2523 DeoptimizeIf(vs, instr->environment()); | |
| 2524 __ bind(&is_positive); | |
| 2455 } | 2525 } |
| 2456 | 2526 |
| 2457 | 2527 |
| 2458 void LCodeGen::DoMathAbs(LUnaryMathOperation* instr) { | 2528 void LCodeGen::DoMathAbs(LUnaryMathOperation* instr) { |
| 2459 Abort("DoMathAbs unimplemented."); | 2529 // Class for deferred case. |
| 2530 class DeferredMathAbsTaggedHeapNumber: public LDeferredCode { | |
| 2531 public: | |
| 2532 DeferredMathAbsTaggedHeapNumber(LCodeGen* codegen, | |
| 2533 LUnaryMathOperation* instr) | |
| 2534 : LDeferredCode(codegen), instr_(instr) { } | |
| 2535 virtual void Generate() { | |
| 2536 codegen()->DoDeferredMathAbsTaggedHeapNumber(instr_); | |
| 2537 } | |
| 2538 private: | |
| 2539 LUnaryMathOperation* instr_; | |
| 2540 }; | |
| 2541 | |
| 2542 ASSERT(instr->input()->Equals(instr->result())); | |
| 2543 Representation r = instr->hydrogen()->value()->representation(); | |
| 2544 if (r.IsDouble()) { | |
| 2545 DwVfpRegister input = ToDoubleRegister(instr->input()); | |
| 2546 // __ vabs(input, input); | |
| 2547 Abort("Double DoMathAbs unimplemented"); | |
| 2548 } else if (r.IsInteger32()) { | |
| 2549 EmitIntegerMathAbs(instr); | |
| 2550 } else { | |
| 2551 // Representation is tagged. | |
| 2552 DeferredMathAbsTaggedHeapNumber* deferred = | |
| 2553 new DeferredMathAbsTaggedHeapNumber(this, instr); | |
| 2554 Register input = ToRegister(instr->input()); | |
| 2555 // Smi check. | |
| 2556 __ BranchOnNotSmi(input, deferred->entry()); | |
| 2557 // If smi, handle it directly. | |
| 2558 EmitIntegerMathAbs(instr); | |
| 2559 __ bind(deferred->exit()); | |
| 2560 } | |
| 2460 } | 2561 } |
| 2461 | 2562 |
| 2462 | 2563 |
| 2463 void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) { | 2564 void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) { |
| 2464 DoubleRegister input = ToDoubleRegister(instr->input()); | 2565 DoubleRegister input = ToDoubleRegister(instr->input()); |
| 2465 Register result = ToRegister(instr->result()); | 2566 Register result = ToRegister(instr->result()); |
| 2466 Register prev_fpscr = ToRegister(instr->temp()); | 2567 Register prev_fpscr = ToRegister(instr->temp()); |
| 2467 SwVfpRegister single_scratch = double_scratch0().low(); | 2568 SwVfpRegister single_scratch = double_scratch0().low(); |
| 2468 Register scratch = scratch0(); | 2569 Register scratch = scratch0(); |
| 2469 | 2570 |
| (...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3364 | 3465 |
| 3365 | 3466 |
| 3366 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { | 3467 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { |
| 3367 Abort("DoOsrEntry unimplemented."); | 3468 Abort("DoOsrEntry unimplemented."); |
| 3368 } | 3469 } |
| 3369 | 3470 |
| 3370 | 3471 |
| 3371 #undef __ | 3472 #undef __ |
| 3372 | 3473 |
| 3373 } } // namespace v8::internal | 3474 } } // namespace v8::internal |
| OLD | NEW |