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 1936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1947 __ jmp(&done); | 1947 __ jmp(&done); |
1948 | 1948 |
1949 // Smi to XMM conversion | 1949 // Smi to XMM conversion |
1950 __ bind(&load_smi); | 1950 __ bind(&load_smi); |
1951 __ SmiToInteger32(kScratchRegister, input_reg); // Untag smi first. | 1951 __ SmiToInteger32(kScratchRegister, input_reg); // Untag smi first. |
1952 __ cvtlsi2sd(result_reg, kScratchRegister); | 1952 __ cvtlsi2sd(result_reg, kScratchRegister); |
1953 __ bind(&done); | 1953 __ bind(&done); |
1954 } | 1954 } |
1955 | 1955 |
1956 | 1956 |
1957 class DeferredTaggedToI: public LDeferredCode { | |
1958 public: | |
1959 DeferredTaggedToI(LCodeGen* codegen, LTaggedToI* instr) | |
1960 : LDeferredCode(codegen), instr_(instr) { } | |
1961 virtual void Generate() { codegen()->DoDeferredTaggedToI(instr_); } | |
1962 private: | |
1963 LTaggedToI* instr_; | |
1964 }; | |
1965 | |
1966 | |
1957 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) { | 1967 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) { |
1958 Abort("Unimplemented: %s", "DoDeferredTaggedToI"); | 1968 NearLabel done, heap_number; |
1969 Register input_reg = ToRegister(instr->InputAt(0)); | |
1970 | |
1971 // Heap number map check. | |
1972 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset), | |
1973 Heap::kHeapNumberMapRootIndex); | |
Lasse Reichstein
2011/02/04 12:57:55
indentation.
William Hesse
2011/02/04 13:16:39
Done.
| |
1974 | |
1975 if (instr->truncating()) { | |
1976 __ j(equal, &heap_number); | |
1977 // Check for undefined. Undefined is converted to zero for truncating | |
1978 // conversions. | |
1979 __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex); | |
1980 DeoptimizeIf(not_equal, instr->environment()); | |
1981 __ movl(input_reg, Immediate(0)); | |
1982 __ jmp(&done); | |
1983 | |
1984 __ bind(&heap_number); | |
1985 if (CpuFeatures::IsSupported(SSE3)) { | |
1986 CpuFeatures::Scope scope(SSE3); | |
Lasse Reichstein
2011/02/04 12:57:55
Fisttp isn't any "more powerful" than cvttsd2si in
William Hesse
2011/02/04 13:16:39
Done.
| |
1987 NearLabel convert; | |
1988 // Use more powerful conversion when sse3 is available. | |
1989 // Load x87 register with heap number. | |
1990 __ fld_d(FieldOperand(input_reg, HeapNumber::kValueOffset)); | |
1991 // Get exponent alone and check for too-big exponent. | |
1992 __ movl(input_reg, FieldOperand(input_reg, HeapNumber::kExponentOffset)); | |
1993 __ andl(input_reg, Immediate(HeapNumber::kExponentMask)); | |
1994 const uint32_t kTooBigExponent = | |
1995 (HeapNumber::kExponentBias + 63) << HeapNumber::kExponentShift; | |
1996 __ cmpl(input_reg, Immediate(kTooBigExponent)); | |
1997 __ j(less, &convert); | |
1998 // Pop FPU stack before deoptimizing. | |
1999 __ ffree(0); | |
2000 __ fincstp(); | |
Lasse Reichstein
2011/02/04 12:57:55
Use
__ fstp(0);
to drop the top of the FPU stack
William Hesse
2011/02/04 13:16:39
Entire block of code deleted.
On 2011/02/04 12:57:
| |
2001 DeoptimizeIf(no_condition, instr->environment()); | |
2002 | |
2003 // Reserve space for 64 bit answer. | |
2004 __ bind(&convert); | |
2005 __ subq(rsp, Immediate(kDoubleSize)); | |
2006 // Do conversion, which cannot fail because we checked the exponent. | |
2007 __ fisttp_d(Operand(rsp, 0)); | |
2008 __ movl(input_reg, Operand(rsp, 0)); // Low word of answer is the result. | |
2009 __ addq(rsp, Immediate(kDoubleSize)); | |
2010 } else { | |
2011 NearLabel deopt; | |
2012 XMMRegister xmm_temp = ToDoubleRegister(instr->TempAt(0)); | |
2013 __ movsd(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset)); | |
2014 __ cvttsd2si(input_reg, xmm0); | |
Lasse Reichstein
2011/02/04 12:57:55
Use the 64-bit version and compare to 0x8000000000
William Hesse
2011/02/04 13:16:39
Done.
| |
2015 __ cmpl(input_reg, Immediate(0x80000000u)); | |
2016 __ j(not_equal, &done); | |
2017 // Check if the input was 0x8000000 (kMinInt). | |
2018 // If no, then we got an overflow and we deoptimize. | |
2019 ExternalReference min_int = ExternalReference::address_of_min_int(); | |
2020 __ movq(kScratchRegister, min_int); | |
2021 __ movsd(xmm_temp, Operand(kScratchRegister, 0)); | |
2022 __ ucomisd(xmm_temp, xmm0); | |
2023 DeoptimizeIf(not_equal, instr->environment()); | |
2024 DeoptimizeIf(parity_even, instr->environment()); // NaN. | |
2025 } | |
2026 } else { | |
2027 // Deoptimize if we don't have a heap number. | |
2028 DeoptimizeIf(not_equal, instr->environment()); | |
2029 | |
2030 XMMRegister xmm_temp = ToDoubleRegister(instr->TempAt(0)); | |
2031 __ movsd(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset)); | |
2032 __ cvttsd2si(input_reg, xmm0); | |
2033 __ cvtlsi2sd(xmm_temp, input_reg); | |
2034 __ ucomisd(xmm0, xmm_temp); | |
2035 DeoptimizeIf(not_equal, instr->environment()); | |
2036 DeoptimizeIf(parity_even, instr->environment()); // NaN. | |
2037 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | |
2038 __ testl(input_reg, input_reg); | |
2039 __ j(not_zero, &done); | |
2040 __ movmskpd(input_reg, xmm0); | |
2041 __ andl(input_reg, Immediate(1)); | |
2042 DeoptimizeIf(not_zero, instr->environment()); | |
2043 } | |
2044 } | |
2045 __ bind(&done); | |
1959 } | 2046 } |
1960 | 2047 |
1961 | 2048 |
1962 void LCodeGen::DoTaggedToI(LTaggedToI* instr) { | 2049 void LCodeGen::DoTaggedToI(LTaggedToI* instr) { |
1963 Abort("Unimplemented: %s", "DoTaggedToI"); | 2050 LOperand* input = instr->InputAt(0); |
2051 ASSERT(input->IsRegister()); | |
2052 ASSERT(input->Equals(instr->result())); | |
2053 | |
2054 Register input_reg = ToRegister(input); | |
2055 DeferredTaggedToI* deferred = new DeferredTaggedToI(this, instr); | |
2056 __ JumpIfNotSmi(input_reg, deferred->entry()); | |
2057 __ SmiToInteger32(input_reg, input_reg); | |
2058 __ bind(deferred->exit()); | |
1964 } | 2059 } |
1965 | 2060 |
1966 | 2061 |
1967 void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) { | 2062 void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) { |
1968 Abort("Unimplemented: %s", "DoNumberUntagD"); | 2063 Abort("Unimplemented: %s", "DoNumberUntagD"); |
1969 } | 2064 } |
1970 | 2065 |
1971 | 2066 |
1972 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { | 2067 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { |
1973 Abort("Unimplemented: %s", "DoDoubleToI"); | 2068 Abort("Unimplemented: %s", "DoDoubleToI"); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2210 | 2305 |
2211 | 2306 |
2212 void LCodeGen::DoDeleteProperty(LDeleteProperty* instr) { | 2307 void LCodeGen::DoDeleteProperty(LDeleteProperty* instr) { |
2213 Abort("Unimplemented: %s", "DoDeleteProperty"); | 2308 Abort("Unimplemented: %s", "DoDeleteProperty"); |
2214 } | 2309 } |
2215 | 2310 |
2216 | 2311 |
2217 void LCodeGen::DoStackCheck(LStackCheck* instr) { | 2312 void LCodeGen::DoStackCheck(LStackCheck* instr) { |
2218 // Perform stack overflow check. | 2313 // Perform stack overflow check. |
2219 NearLabel done; | 2314 NearLabel done; |
2220 ExternalReference stack_limit = ExternalReference::address_of_stack_limit(); | |
2221 __ CompareRoot(rsp, Heap::kStackLimitRootIndex); | 2315 __ CompareRoot(rsp, Heap::kStackLimitRootIndex); |
2222 __ j(above_equal, &done); | 2316 __ j(above_equal, &done); |
2223 | 2317 |
2224 StackCheckStub stub; | 2318 StackCheckStub stub; |
2225 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 2319 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
2226 __ bind(&done); | 2320 __ bind(&done); |
2227 } | 2321 } |
2228 | 2322 |
2229 | 2323 |
2230 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { | 2324 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { |
2231 Abort("Unimplemented: %s", "DoOsrEntry"); | 2325 Abort("Unimplemented: %s", "DoOsrEntry"); |
2232 } | 2326 } |
2233 | 2327 |
2234 #undef __ | 2328 #undef __ |
2235 | 2329 |
2236 } } // namespace v8::internal | 2330 } } // namespace v8::internal |
2237 | 2331 |
2238 #endif // V8_TARGET_ARCH_X64 | 2332 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |