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 1637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1648 ASSERT(!obj.is(ip)); | 1648 ASSERT(!obj.is(ip)); |
1649 LoadRoot(ip, index); | 1649 LoadRoot(ip, index); |
1650 cmp(obj, ip); | 1650 cmp(obj, ip); |
1651 } | 1651 } |
1652 | 1652 |
1653 | 1653 |
1654 void MacroAssembler::CheckMap(Register obj, | 1654 void MacroAssembler::CheckMap(Register obj, |
1655 Register scratch, | 1655 Register scratch, |
1656 Handle<Map> map, | 1656 Handle<Map> map, |
1657 Label* fail, | 1657 Label* fail, |
1658 bool is_heap_object) { | 1658 SmiCheckType smi_check_type) { |
1659 if (!is_heap_object) { | 1659 if (smi_check_type == DO_SMI_CHECK) { |
1660 JumpIfSmi(obj, fail); | 1660 JumpIfSmi(obj, fail); |
1661 } | 1661 } |
1662 ldr(scratch, FieldMemOperand(obj, HeapObject::kMapOffset)); | 1662 ldr(scratch, FieldMemOperand(obj, HeapObject::kMapOffset)); |
1663 mov(ip, Operand(map)); | 1663 mov(ip, Operand(map)); |
1664 cmp(scratch, ip); | 1664 cmp(scratch, ip); |
1665 b(ne, fail); | 1665 b(ne, fail); |
1666 } | 1666 } |
1667 | 1667 |
1668 | 1668 |
1669 void MacroAssembler::CheckMap(Register obj, | 1669 void MacroAssembler::CheckMap(Register obj, |
1670 Register scratch, | 1670 Register scratch, |
1671 Heap::RootListIndex index, | 1671 Heap::RootListIndex index, |
1672 Label* fail, | 1672 Label* fail, |
1673 bool is_heap_object) { | 1673 SmiCheckType smi_check_type) { |
1674 if (!is_heap_object) { | 1674 if (smi_check_type == DO_SMI_CHECK) { |
1675 JumpIfSmi(obj, fail); | 1675 JumpIfSmi(obj, fail); |
1676 } | 1676 } |
1677 ldr(scratch, FieldMemOperand(obj, HeapObject::kMapOffset)); | 1677 ldr(scratch, FieldMemOperand(obj, HeapObject::kMapOffset)); |
1678 LoadRoot(ip, index); | 1678 LoadRoot(ip, index); |
1679 cmp(scratch, ip); | 1679 cmp(scratch, ip); |
1680 b(ne, fail); | 1680 b(ne, fail); |
1681 } | 1681 } |
1682 | 1682 |
1683 | 1683 |
1684 void MacroAssembler::TryGetFunctionPrototype(Register function, | 1684 void MacroAssembler::TryGetFunctionPrototype(Register function, |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2514 } | 2514 } |
2515 | 2515 |
2516 | 2516 |
2517 void MacroAssembler::LoadGlobalFunctionInitialMap(Register function, | 2517 void MacroAssembler::LoadGlobalFunctionInitialMap(Register function, |
2518 Register map, | 2518 Register map, |
2519 Register scratch) { | 2519 Register scratch) { |
2520 // Load the initial map. The global functions all have initial maps. | 2520 // Load the initial map. The global functions all have initial maps. |
2521 ldr(map, FieldMemOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); | 2521 ldr(map, FieldMemOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); |
2522 if (emit_debug_code()) { | 2522 if (emit_debug_code()) { |
2523 Label ok, fail; | 2523 Label ok, fail; |
2524 CheckMap(map, scratch, Heap::kMetaMapRootIndex, &fail, false); | 2524 CheckMap(map, scratch, Heap::kMetaMapRootIndex, &fail, DO_SMI_CHECK); |
2525 b(&ok); | 2525 b(&ok); |
2526 bind(&fail); | 2526 bind(&fail); |
2527 Abort("Global functions must have initial map"); | 2527 Abort("Global functions must have initial map"); |
2528 bind(&ok); | 2528 bind(&ok); |
2529 } | 2529 } |
2530 } | 2530 } |
2531 | 2531 |
2532 | 2532 |
2533 void MacroAssembler::JumpIfNotPowerOfTwoOrZero( | 2533 void MacroAssembler::JumpIfNotPowerOfTwoOrZero( |
2534 Register reg, | 2534 Register reg, |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3021 // Result was clobbered. Restore it. | 3021 // Result was clobbered. Restore it. |
3022 ldr(result, MemOperand(ldr_location)); | 3022 ldr(result, MemOperand(ldr_location)); |
3023 } | 3023 } |
3024 // Get the address of the constant. | 3024 // Get the address of the constant. |
3025 and_(result, result, Operand(kLdrOffsetMask)); | 3025 and_(result, result, Operand(kLdrOffsetMask)); |
3026 add(result, ldr_location, Operand(result)); | 3026 add(result, ldr_location, Operand(result)); |
3027 add(result, result, Operand(kPCRegOffset)); | 3027 add(result, result, Operand(kPCRegOffset)); |
3028 } | 3028 } |
3029 | 3029 |
3030 | 3030 |
| 3031 void MacroAssembler::ClampUint8(Register output_reg, Register input_reg) { |
| 3032 Usat(output_reg, 8, Operand(input_reg)); |
| 3033 } |
| 3034 |
| 3035 |
| 3036 void MacroAssembler::ClampDoubleToUint8(Register result_reg, |
| 3037 DoubleRegister input_reg, |
| 3038 DoubleRegister temp_double_reg) { |
| 3039 Label above_zero; |
| 3040 Label done; |
| 3041 Label in_bounds; |
| 3042 |
| 3043 vmov(temp_double_reg, 0.0); |
| 3044 VFPCompareAndSetFlags(input_reg, temp_double_reg); |
| 3045 b(gt, &above_zero); |
| 3046 |
| 3047 // Double value is less than zero, NaN or Inf, return 0. |
| 3048 mov(result_reg, Operand(0)); |
| 3049 b(al, &done); |
| 3050 |
| 3051 // Double value is >= 255, return 255. |
| 3052 bind(&above_zero); |
| 3053 vmov(temp_double_reg, 255.0); |
| 3054 VFPCompareAndSetFlags(input_reg, temp_double_reg); |
| 3055 b(le, &in_bounds); |
| 3056 mov(result_reg, Operand(255)); |
| 3057 b(al, &done); |
| 3058 |
| 3059 // In 0-255 range, round and truncate. |
| 3060 bind(&in_bounds); |
| 3061 vmov(temp_double_reg, 0.5); |
| 3062 vadd(temp_double_reg, input_reg, temp_double_reg); |
| 3063 vcvt_u32_f64(s0, temp_double_reg); |
| 3064 vmov(result_reg, s0); |
| 3065 bind(&done); |
| 3066 } |
| 3067 |
| 3068 |
3031 CodePatcher::CodePatcher(byte* address, int instructions) | 3069 CodePatcher::CodePatcher(byte* address, int instructions) |
3032 : address_(address), | 3070 : address_(address), |
3033 instructions_(instructions), | 3071 instructions_(instructions), |
3034 size_(instructions * Assembler::kInstrSize), | 3072 size_(instructions * Assembler::kInstrSize), |
3035 masm_(Isolate::Current(), address, size_ + Assembler::kGap) { | 3073 masm_(Isolate::Current(), address, size_ + Assembler::kGap) { |
3036 // Create a new macro assembler pointing to the address of the code to patch. | 3074 // Create a new macro assembler pointing to the address of the code to patch. |
3037 // The size is adjusted with kGap on order for the assembler to generate size | 3075 // The size is adjusted with kGap on order for the assembler to generate size |
3038 // bytes of instructions without failing with buffer size constraints. | 3076 // bytes of instructions without failing with buffer size constraints. |
3039 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 3077 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
3040 } | 3078 } |
(...skipping 22 matching lines...) Expand all Loading... |
3063 void CodePatcher::EmitCondition(Condition cond) { | 3101 void CodePatcher::EmitCondition(Condition cond) { |
3064 Instr instr = Assembler::instr_at(masm_.pc_); | 3102 Instr instr = Assembler::instr_at(masm_.pc_); |
3065 instr = (instr & ~kCondMask) | cond; | 3103 instr = (instr & ~kCondMask) | cond; |
3066 masm_.emit(instr); | 3104 masm_.emit(instr); |
3067 } | 3105 } |
3068 | 3106 |
3069 | 3107 |
3070 } } // namespace v8::internal | 3108 } } // namespace v8::internal |
3071 | 3109 |
3072 #endif // V8_TARGET_ARCH_ARM | 3110 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |