OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_X87 | 5 #if V8_TARGET_ARCH_X87 |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/base/division-by-constant.h" | 8 #include "src/base/division-by-constant.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 1934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1945 jmp(done, done_near); | 1945 jmp(done, done_near); |
1946 } | 1946 } |
1947 } else { | 1947 } else { |
1948 jmp(adaptor, RelocInfo::CODE_TARGET); | 1948 jmp(adaptor, RelocInfo::CODE_TARGET); |
1949 } | 1949 } |
1950 bind(&invoke); | 1950 bind(&invoke); |
1951 } | 1951 } |
1952 } | 1952 } |
1953 | 1953 |
1954 | 1954 |
1955 void MacroAssembler::InvokeCode(const Operand& code, | 1955 void MacroAssembler::InvokeCode(const Operand& code, Register new_target, |
1956 const ParameterCount& expected, | 1956 const ParameterCount& expected, |
1957 const ParameterCount& actual, | 1957 const ParameterCount& actual, InvokeFlag flag, |
1958 InvokeFlag flag, | |
1959 const CallWrapper& call_wrapper) { | 1958 const CallWrapper& call_wrapper) { |
1960 // You can't call a function without a valid frame. | 1959 // You can't call a function without a valid frame. |
1961 DCHECK(flag == JUMP_FUNCTION || has_frame()); | 1960 DCHECK(flag == JUMP_FUNCTION || has_frame()); |
1962 | 1961 |
| 1962 // Ensure new target is passed in the correct register. Otherwise clear the |
| 1963 // appropriate register in case new target is not given. |
| 1964 DCHECK_IMPLIES(new_target.is_valid(), new_target.is(edx)); |
| 1965 if (!new_target.is_valid()) { |
| 1966 mov(edx, isolate()->factory()->undefined_value()); |
| 1967 } |
| 1968 |
1963 Label done; | 1969 Label done; |
1964 bool definitely_mismatches = false; | 1970 bool definitely_mismatches = false; |
1965 InvokePrologue(expected, actual, &done, &definitely_mismatches, flag, | 1971 InvokePrologue(expected, actual, &done, &definitely_mismatches, flag, |
1966 Label::kNear, call_wrapper); | 1972 Label::kNear, call_wrapper); |
1967 if (!definitely_mismatches) { | 1973 if (!definitely_mismatches) { |
1968 if (flag == CALL_FUNCTION) { | 1974 if (flag == CALL_FUNCTION) { |
1969 call_wrapper.BeforeCall(CallSize(code)); | 1975 call_wrapper.BeforeCall(CallSize(code)); |
1970 call(code); | 1976 call(code); |
1971 call_wrapper.AfterCall(); | 1977 call_wrapper.AfterCall(); |
1972 } else { | 1978 } else { |
1973 DCHECK(flag == JUMP_FUNCTION); | 1979 DCHECK(flag == JUMP_FUNCTION); |
1974 jmp(code); | 1980 jmp(code); |
1975 } | 1981 } |
1976 bind(&done); | 1982 bind(&done); |
1977 } | 1983 } |
1978 } | 1984 } |
1979 | 1985 |
1980 | 1986 |
1981 void MacroAssembler::InvokeFunction(Register fun, | 1987 void MacroAssembler::InvokeFunction(Register fun, Register new_target, |
1982 const ParameterCount& actual, | 1988 const ParameterCount& actual, |
1983 InvokeFlag flag, | 1989 InvokeFlag flag, |
1984 const CallWrapper& call_wrapper) { | 1990 const CallWrapper& call_wrapper) { |
1985 // You can't call a function without a valid frame. | 1991 // You can't call a function without a valid frame. |
1986 DCHECK(flag == JUMP_FUNCTION || has_frame()); | 1992 DCHECK(flag == JUMP_FUNCTION || has_frame()); |
1987 | 1993 |
1988 DCHECK(fun.is(edi)); | 1994 DCHECK(fun.is(edi)); |
1989 mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | 1995 mov(ebx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
1990 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); | 1996 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); |
1991 mov(ebx, FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset)); | 1997 mov(ebx, FieldOperand(ebx, SharedFunctionInfo::kFormalParameterCountOffset)); |
1992 SmiUntag(ebx); | 1998 SmiUntag(ebx); |
1993 | 1999 |
1994 ParameterCount expected(ebx); | 2000 ParameterCount expected(ebx); |
1995 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), | 2001 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), new_target, |
1996 expected, actual, flag, call_wrapper); | 2002 expected, actual, flag, call_wrapper); |
1997 } | 2003 } |
1998 | 2004 |
1999 | 2005 |
2000 void MacroAssembler::InvokeFunction(Register fun, | 2006 void MacroAssembler::InvokeFunction(Register fun, |
2001 const ParameterCount& expected, | 2007 const ParameterCount& expected, |
2002 const ParameterCount& actual, | 2008 const ParameterCount& actual, |
2003 InvokeFlag flag, | 2009 InvokeFlag flag, |
2004 const CallWrapper& call_wrapper) { | 2010 const CallWrapper& call_wrapper) { |
2005 // You can't call a function without a valid frame. | 2011 // You can't call a function without a valid frame. |
2006 DCHECK(flag == JUMP_FUNCTION || has_frame()); | 2012 DCHECK(flag == JUMP_FUNCTION || has_frame()); |
2007 | 2013 |
2008 DCHECK(fun.is(edi)); | 2014 DCHECK(fun.is(edi)); |
2009 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); | 2015 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); |
2010 | 2016 |
2011 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), | 2017 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), no_reg, expected, |
2012 expected, actual, flag, call_wrapper); | 2018 actual, flag, call_wrapper); |
2013 } | 2019 } |
2014 | 2020 |
2015 | 2021 |
2016 void MacroAssembler::InvokeFunction(Handle<JSFunction> function, | 2022 void MacroAssembler::InvokeFunction(Handle<JSFunction> function, |
2017 const ParameterCount& expected, | 2023 const ParameterCount& expected, |
2018 const ParameterCount& actual, | 2024 const ParameterCount& actual, |
2019 InvokeFlag flag, | 2025 InvokeFlag flag, |
2020 const CallWrapper& call_wrapper) { | 2026 const CallWrapper& call_wrapper) { |
2021 LoadHeapObject(edi, function); | 2027 LoadHeapObject(edi, function); |
2022 InvokeFunction(edi, expected, actual, flag, call_wrapper); | 2028 InvokeFunction(edi, expected, actual, flag, call_wrapper); |
2023 } | 2029 } |
2024 | 2030 |
2025 | 2031 |
2026 void MacroAssembler::InvokeBuiltin(int native_context_index, InvokeFlag flag, | 2032 void MacroAssembler::InvokeBuiltin(int native_context_index, InvokeFlag flag, |
2027 const CallWrapper& call_wrapper) { | 2033 const CallWrapper& call_wrapper) { |
2028 // You can't call a builtin without a valid frame. | 2034 // You can't call a builtin without a valid frame. |
2029 DCHECK(flag == JUMP_FUNCTION || has_frame()); | 2035 DCHECK(flag == JUMP_FUNCTION || has_frame()); |
2030 | 2036 |
2031 // Rely on the assertion to check that the number of provided | 2037 // Rely on the assertion to check that the number of provided |
2032 // arguments match the expected number of arguments. Fake a | 2038 // arguments match the expected number of arguments. Fake a |
2033 // parameter count to avoid emitting code to do the check. | 2039 // parameter count to avoid emitting code to do the check. |
2034 ParameterCount expected(0); | 2040 ParameterCount expected(0); |
2035 GetBuiltinFunction(edi, native_context_index); | 2041 GetBuiltinFunction(edi, native_context_index); |
2036 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), | 2042 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), no_reg, expected, |
2037 expected, expected, flag, call_wrapper); | 2043 expected, flag, call_wrapper); |
2038 } | 2044 } |
2039 | 2045 |
2040 | 2046 |
2041 void MacroAssembler::GetBuiltinFunction(Register target, | 2047 void MacroAssembler::GetBuiltinFunction(Register target, |
2042 int native_context_index) { | 2048 int native_context_index) { |
2043 // Load the JavaScript builtin function from the builtins object. | 2049 // Load the JavaScript builtin function from the builtins object. |
2044 mov(target, Operand(esi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 2050 mov(target, Operand(esi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
2045 mov(target, FieldOperand(target, JSGlobalObject::kNativeContextOffset)); | 2051 mov(target, FieldOperand(target, JSGlobalObject::kNativeContextOffset)); |
2046 mov(target, ContextOperand(target, native_context_index)); | 2052 mov(target, ContextOperand(target, native_context_index)); |
2047 } | 2053 } |
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3011 mov(eax, dividend); | 3017 mov(eax, dividend); |
3012 shr(eax, 31); | 3018 shr(eax, 31); |
3013 add(edx, eax); | 3019 add(edx, eax); |
3014 } | 3020 } |
3015 | 3021 |
3016 | 3022 |
3017 } // namespace internal | 3023 } // namespace internal |
3018 } // namespace v8 | 3024 } // namespace v8 |
3019 | 3025 |
3020 #endif // V8_TARGET_ARCH_X87 | 3026 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |