OLD | NEW |
---|---|
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 1926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1937 __ bind(&miss); | 1937 __ bind(&miss); |
1938 // ecx: function name. | 1938 // ecx: function name. |
1939 Object* obj = GenerateMissBranch(); | 1939 Object* obj = GenerateMissBranch(); |
1940 if (obj->IsFailure()) return obj; | 1940 if (obj->IsFailure()) return obj; |
1941 | 1941 |
1942 // Return the generated code. | 1942 // Return the generated code. |
1943 return (cell == NULL) ? GetCode(function) : GetCode(NORMAL, name); | 1943 return (cell == NULL) ? GetCode(function) : GetCode(NORMAL, name); |
1944 } | 1944 } |
1945 | 1945 |
1946 | 1946 |
1947 Object* CallStubCompiler::CompileMathAbsCall(Object* object, | |
1948 JSObject* holder, | |
1949 JSGlobalPropertyCell* cell, | |
1950 JSFunction* function, | |
1951 String* name) { | |
1952 // ----------- S t a t e ------------- | |
1953 // -- ecx : name | |
1954 // -- esp[0] : return address | |
1955 // -- esp[(argc - n) * 4] : arg[n] (zero-based) | |
1956 // -- ... | |
1957 // -- esp[(argc + 1) * 4] : receiver | |
1958 // ----------------------------------- | |
1959 | |
1960 const int argc = arguments().immediate(); | |
1961 | |
1962 // If the object is not a JSObject or we got an unexpected number of | |
1963 // arguments, bail out to the regular call. | |
1964 if (!object->IsJSObject() || argc != 1) return Heap::undefined_value(); | |
1965 | |
1966 Label miss; | |
1967 GenerateNameCheck(name, &miss); | |
1968 | |
1969 if (cell == NULL) { | |
1970 __ mov(edx, Operand(esp, 2 * kPointerSize)); | |
antonm
2010/09/28 12:04:17
should you load receiver into edx? Maybe check fo
| |
1971 | |
1972 STATIC_ASSERT(kSmiTag == 0); | |
1973 __ test(edx, Immediate(kSmiTagMask)); | |
1974 __ j(zero, &miss); | |
1975 | |
1976 CheckPrototypes(JSObject::cast(object), edx, holder, ebx, eax, edi, name, | |
1977 &miss); | |
1978 } else { | |
1979 ASSERT(cell->value() == function); | |
1980 GenerateGlobalReceiverCheck(JSObject::cast(object), holder, name, &miss); | |
1981 GenerateLoadFunctionFromCell(cell, function, &miss); | |
1982 } | |
1983 | |
1984 // Load the (only) argument into eax. | |
1985 __ mov(eax, Operand(esp, 1 * kPointerSize)); | |
1986 | |
1987 // Check if the argument is a smi. | |
1988 Label not_smi; | |
1989 STATIC_ASSERT(kSmiTag == 0); | |
1990 __ test(eax, Immediate(kSmiTagMask)); | |
1991 __ j(not_zero, ¬_smi); | |
1992 | |
1993 // Set ebx to 1...1 (== -1) if the argument is negative, or to 0...0 | |
1994 // otherwise. | |
1995 __ mov(ebx, eax); | |
1996 __ sar(ebx, kBitsPerInt - 1); | |
1997 | |
1998 // Do bitwise not or do nothing depending on ebx. | |
1999 __ xor_(eax, Operand(ebx)); | |
2000 | |
2001 // Add 1 or do nothing depending on ebx. | |
2002 __ sub(eax, Operand(ebx)); | |
2003 | |
2004 // If the result is still negative, go to the slow case. | |
2005 // This only happens for the most negative smi. | |
2006 Label slow; | |
2007 __ j(negative, &slow); | |
2008 | |
2009 // Smi case done. | |
2010 __ ret(2 * kPointerSize); | |
antonm
2010/09/28 12:04:17
Maybe unify this and ARM ret: in ARM code you use
| |
2011 | |
2012 // Check if the argument is a heap number and load its exponent and | |
2013 // sign into ebx. | |
2014 __ bind(¬_smi); | |
2015 __ CheckMap(eax, Factory::heap_number_map(), &slow, true); | |
2016 __ mov(ebx, FieldOperand(eax, HeapNumber::kExponentOffset)); | |
2017 | |
2018 // Check the sign of the argument. If the argument is positive, | |
2019 // just return it. | |
2020 Label negative_sign; | |
2021 __ test(ebx, Immediate(HeapNumber::kSignMask)); | |
2022 __ j(not_zero, &negative_sign); | |
2023 __ ret(2 * kPointerSize); | |
2024 | |
2025 // If the argument is negative, clear the sign, and return a new | |
2026 // number. | |
2027 __ bind(&negative_sign); | |
2028 __ and_(ebx, ~HeapNumber::kSignMask); | |
2029 __ mov(ecx, FieldOperand(eax, HeapNumber::kMantissaOffset)); | |
2030 __ AllocateHeapNumber(eax, edi, edx, &slow); | |
2031 __ mov(FieldOperand(eax, HeapNumber::kExponentOffset), ebx); | |
2032 __ mov(FieldOperand(eax, HeapNumber::kMantissaOffset), ecx); | |
2033 __ ret(2 * kPointerSize); | |
2034 | |
2035 // Tail call the full function. We do not have to patch the receiver | |
2036 // because the function makes no use of it. | |
2037 __ bind(&slow); | |
2038 __ InvokeFunction(function, arguments(), JUMP_FUNCTION); | |
2039 | |
2040 __ bind(&miss); | |
2041 // ecx: function name. | |
2042 Object* obj = GenerateMissBranch(); | |
2043 if (obj->IsFailure()) return obj; | |
2044 | |
2045 // Return the generated code. | |
2046 return (cell == NULL) ? GetCode(function) : GetCode(NORMAL, name); | |
2047 } | |
2048 | |
2049 | |
1947 Object* CallStubCompiler::CompileCallConstant(Object* object, | 2050 Object* CallStubCompiler::CompileCallConstant(Object* object, |
1948 JSObject* holder, | 2051 JSObject* holder, |
1949 JSFunction* function, | 2052 JSFunction* function, |
1950 String* name, | 2053 String* name, |
1951 CheckType check) { | 2054 CheckType check) { |
1952 // ----------- S t a t e ------------- | 2055 // ----------- S t a t e ------------- |
1953 // -- ecx : name | 2056 // -- ecx : name |
1954 // -- esp[0] : return address | 2057 // -- esp[0] : return address |
1955 // -- esp[(argc - n) * 4] : arg[n] (zero-based) | 2058 // -- esp[(argc - n) * 4] : arg[n] (zero-based) |
1956 // -- ... | 2059 // -- ... |
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2961 // Return the generated code. | 3064 // Return the generated code. |
2962 return GetCode(); | 3065 return GetCode(); |
2963 } | 3066 } |
2964 | 3067 |
2965 | 3068 |
2966 #undef __ | 3069 #undef __ |
2967 | 3070 |
2968 } } // namespace v8::internal | 3071 } } // namespace v8::internal |
2969 | 3072 |
2970 #endif // V8_TARGET_ARCH_IA32 | 3073 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |