OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 void MacroAssembler::Set(const Operand& dst, int64_t x) { | 951 void MacroAssembler::Set(const Operand& dst, int64_t x) { |
952 if (is_int32(x)) { | 952 if (is_int32(x)) { |
953 movq(dst, Immediate(static_cast<int32_t>(x))); | 953 movq(dst, Immediate(static_cast<int32_t>(x))); |
954 } else { | 954 } else { |
955 Set(kScratchRegister, x); | 955 Set(kScratchRegister, x); |
956 movq(dst, kScratchRegister); | 956 movq(dst, kScratchRegister); |
957 } | 957 } |
958 } | 958 } |
959 | 959 |
960 | 960 |
961 bool MacroAssembler::IsUnsafeInt(const int x) { | 961 // ---------------------------------------------------------------------------- |
| 962 // Smi tagging, untagging and tag detection. |
| 963 |
| 964 bool MacroAssembler::IsUnsafeInt(const int32_t x) { |
962 static const int kMaxBits = 17; | 965 static const int kMaxBits = 17; |
963 return !is_intn(x, kMaxBits); | 966 return !is_intn(x, kMaxBits); |
964 } | 967 } |
965 | 968 |
966 | 969 |
967 void MacroAssembler::SafeMove(Register dst, Smi* src) { | 970 void MacroAssembler::SafeMove(Register dst, Smi* src) { |
968 ASSERT(!dst.is(kScratchRegister)); | 971 ASSERT(!dst.is(kScratchRegister)); |
969 ASSERT(SmiValuesAre32Bits()); // JIT cookie can be converted to Smi. | 972 ASSERT(SmiValuesAre32Bits()); // JIT cookie can be converted to Smi. |
970 if (IsUnsafeInt(src->value()) && jit_cookie() != 0) { | 973 if (IsUnsafeInt(src->value()) && jit_cookie() != 0) { |
971 Move(dst, Smi::FromInt(src->value() ^ jit_cookie())); | 974 Move(dst, Smi::FromInt(src->value() ^ jit_cookie())); |
(...skipping 10 matching lines...) Expand all Loading... |
982 if (IsUnsafeInt(src->value()) && jit_cookie() != 0) { | 985 if (IsUnsafeInt(src->value()) && jit_cookie() != 0) { |
983 Push(Smi::FromInt(src->value() ^ jit_cookie())); | 986 Push(Smi::FromInt(src->value() ^ jit_cookie())); |
984 Move(kScratchRegister, Smi::FromInt(jit_cookie())); | 987 Move(kScratchRegister, Smi::FromInt(jit_cookie())); |
985 xor_(Operand(rsp, 0), kScratchRegister); | 988 xor_(Operand(rsp, 0), kScratchRegister); |
986 } else { | 989 } else { |
987 Push(src); | 990 Push(src); |
988 } | 991 } |
989 } | 992 } |
990 | 993 |
991 | 994 |
992 // ---------------------------------------------------------------------------- | |
993 // Smi tagging, untagging and tag detection. | |
994 | |
995 Register MacroAssembler::GetSmiConstant(Smi* source) { | 995 Register MacroAssembler::GetSmiConstant(Smi* source) { |
996 int value = source->value(); | 996 int value = source->value(); |
997 if (value == 0) { | 997 if (value == 0) { |
998 xorl(kScratchRegister, kScratchRegister); | 998 xorl(kScratchRegister, kScratchRegister); |
999 return kScratchRegister; | 999 return kScratchRegister; |
1000 } | 1000 } |
1001 if (value == 1) { | 1001 if (value == 1) { |
1002 return kSmiConstantRegister; | 1002 return kSmiConstantRegister; |
1003 } | 1003 } |
1004 LoadSmiConstant(kScratchRegister, source); | 1004 LoadSmiConstant(kScratchRegister, source); |
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2189 return SmiIndex(dst, times_1); | 2189 return SmiIndex(dst, times_1); |
2190 } | 2190 } |
2191 | 2191 |
2192 | 2192 |
2193 void MacroAssembler::AddSmiField(Register dst, const Operand& src) { | 2193 void MacroAssembler::AddSmiField(Register dst, const Operand& src) { |
2194 ASSERT_EQ(0, kSmiShift % kBitsPerByte); | 2194 ASSERT_EQ(0, kSmiShift % kBitsPerByte); |
2195 addl(dst, Operand(src, kSmiShift / kBitsPerByte)); | 2195 addl(dst, Operand(src, kSmiShift / kBitsPerByte)); |
2196 } | 2196 } |
2197 | 2197 |
2198 | 2198 |
| 2199 void MacroAssembler::Push(Smi* source) { |
| 2200 intptr_t smi = reinterpret_cast<intptr_t>(source); |
| 2201 if (is_int32(smi)) { |
| 2202 push(Immediate(static_cast<int32_t>(smi))); |
| 2203 } else { |
| 2204 Register constant = GetSmiConstant(source); |
| 2205 push(constant); |
| 2206 } |
| 2207 } |
| 2208 |
| 2209 |
2199 void MacroAssembler::PushInt64AsTwoSmis(Register src, Register scratch) { | 2210 void MacroAssembler::PushInt64AsTwoSmis(Register src, Register scratch) { |
2200 movq(scratch, src); | 2211 movq(scratch, src); |
2201 // High bits. | 2212 // High bits. |
2202 shr(src, Immediate(64 - kSmiShift)); | 2213 shr(src, Immediate(64 - kSmiShift)); |
2203 shl(src, Immediate(kSmiShift)); | 2214 shl(src, Immediate(kSmiShift)); |
2204 push(src); | 2215 push(src); |
2205 // Low bits. | 2216 // Low bits. |
2206 shl(scratch, Immediate(kSmiShift)); | 2217 shl(scratch, Immediate(kSmiShift)); |
2207 push(scratch); | 2218 push(scratch); |
2208 } | 2219 } |
2209 | 2220 |
2210 | 2221 |
2211 void MacroAssembler::PopInt64AsTwoSmis(Register dst, Register scratch) { | 2222 void MacroAssembler::PopInt64AsTwoSmis(Register dst, Register scratch) { |
2212 pop(scratch); | 2223 pop(scratch); |
2213 // Low bits. | 2224 // Low bits. |
2214 shr(scratch, Immediate(kSmiShift)); | 2225 shr(scratch, Immediate(kSmiShift)); |
2215 pop(dst); | 2226 pop(dst); |
2216 shr(dst, Immediate(kSmiShift)); | 2227 shr(dst, Immediate(kSmiShift)); |
2217 // High bits. | 2228 // High bits. |
2218 shl(dst, Immediate(64 - kSmiShift)); | 2229 shl(dst, Immediate(64 - kSmiShift)); |
2219 or_(dst, scratch); | 2230 or_(dst, scratch); |
2220 } | 2231 } |
2221 | 2232 |
2222 | 2233 |
| 2234 void MacroAssembler::Test(const Operand& src, Smi* source) { |
| 2235 testl(Operand(src, kIntSize), Immediate(source->value())); |
| 2236 } |
| 2237 |
| 2238 |
| 2239 // ---------------------------------------------------------------------------- |
| 2240 |
| 2241 |
2223 void MacroAssembler::JumpIfNotString(Register object, | 2242 void MacroAssembler::JumpIfNotString(Register object, |
2224 Register object_map, | 2243 Register object_map, |
2225 Label* not_string, | 2244 Label* not_string, |
2226 Label::Distance near_jump) { | 2245 Label::Distance near_jump) { |
2227 Condition is_smi = CheckSmi(object); | 2246 Condition is_smi = CheckSmi(object); |
2228 j(is_smi, not_string, near_jump); | 2247 j(is_smi, not_string, near_jump); |
2229 CmpObjectType(object, FIRST_NONSTRING_TYPE, object_map); | 2248 CmpObjectType(object, FIRST_NONSTRING_TYPE, object_map); |
2230 j(above_equal, not_string, near_jump); | 2249 j(above_equal, not_string, near_jump); |
2231 } | 2250 } |
2232 | 2251 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2452 if (dst.is(rax)) { | 2471 if (dst.is(rax)) { |
2453 AllowDeferredHandleDereference embedding_raw_address; | 2472 AllowDeferredHandleDereference embedding_raw_address; |
2454 load_rax(cell.location(), RelocInfo::CELL); | 2473 load_rax(cell.location(), RelocInfo::CELL); |
2455 } else { | 2474 } else { |
2456 movq(dst, cell, RelocInfo::CELL); | 2475 movq(dst, cell, RelocInfo::CELL); |
2457 movq(dst, Operand(dst, 0)); | 2476 movq(dst, Operand(dst, 0)); |
2458 } | 2477 } |
2459 } | 2478 } |
2460 | 2479 |
2461 | 2480 |
2462 void MacroAssembler::Push(Smi* source) { | |
2463 intptr_t smi = reinterpret_cast<intptr_t>(source); | |
2464 if (is_int32(smi)) { | |
2465 push(Immediate(static_cast<int32_t>(smi))); | |
2466 } else { | |
2467 Register constant = GetSmiConstant(source); | |
2468 push(constant); | |
2469 } | |
2470 } | |
2471 | |
2472 | |
2473 void MacroAssembler::Drop(int stack_elements) { | 2481 void MacroAssembler::Drop(int stack_elements) { |
2474 if (stack_elements > 0) { | 2482 if (stack_elements > 0) { |
2475 addq(rsp, Immediate(stack_elements * kPointerSize)); | 2483 addq(rsp, Immediate(stack_elements * kPointerSize)); |
2476 } | 2484 } |
2477 } | 2485 } |
2478 | 2486 |
2479 | 2487 |
2480 void MacroAssembler::Test(const Operand& src, Smi* source) { | |
2481 testl(Operand(src, kIntSize), Immediate(source->value())); | |
2482 } | |
2483 | |
2484 | |
2485 void MacroAssembler::TestBit(const Operand& src, int bits) { | 2488 void MacroAssembler::TestBit(const Operand& src, int bits) { |
2486 int byte_offset = bits / kBitsPerByte; | 2489 int byte_offset = bits / kBitsPerByte; |
2487 int bit_in_byte = bits & (kBitsPerByte - 1); | 2490 int bit_in_byte = bits & (kBitsPerByte - 1); |
2488 testb(Operand(src, byte_offset), Immediate(1 << bit_in_byte)); | 2491 testb(Operand(src, byte_offset), Immediate(1 << bit_in_byte)); |
2489 } | 2492 } |
2490 | 2493 |
2491 | 2494 |
2492 void MacroAssembler::Jump(ExternalReference ext) { | 2495 void MacroAssembler::Jump(ExternalReference ext) { |
2493 LoadAddress(kScratchRegister, ext); | 2496 LoadAddress(kScratchRegister, ext); |
2494 jmp(kScratchRegister); | 2497 jmp(kScratchRegister); |
(...skipping 2197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4692 j(greater, &no_memento_available); | 4695 j(greater, &no_memento_available); |
4693 CompareRoot(MemOperand(scratch_reg, -AllocationMemento::kSize), | 4696 CompareRoot(MemOperand(scratch_reg, -AllocationMemento::kSize), |
4694 Heap::kAllocationMementoMapRootIndex); | 4697 Heap::kAllocationMementoMapRootIndex); |
4695 bind(&no_memento_available); | 4698 bind(&no_memento_available); |
4696 } | 4699 } |
4697 | 4700 |
4698 | 4701 |
4699 } } // namespace v8::internal | 4702 } } // namespace v8::internal |
4700 | 4703 |
4701 #endif // V8_TARGET_ARCH_X64 | 4704 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |