| 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_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
| 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 1969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1980 } | 1980 } |
| 1981 } else { | 1981 } else { |
| 1982 jmp(adaptor, RelocInfo::CODE_TARGET); | 1982 jmp(adaptor, RelocInfo::CODE_TARGET); |
| 1983 } | 1983 } |
| 1984 bind(&invoke); | 1984 bind(&invoke); |
| 1985 } | 1985 } |
| 1986 } | 1986 } |
| 1987 | 1987 |
| 1988 | 1988 |
| 1989 void MacroAssembler::InvokeCode(const Operand& code, | 1989 void MacroAssembler::InvokeCode(const Operand& code, |
| 1990 Register new_target, |
| 1990 const ParameterCount& expected, | 1991 const ParameterCount& expected, |
| 1991 const ParameterCount& actual, | 1992 const ParameterCount& actual, |
| 1992 InvokeFlag flag, | 1993 InvokeFlag flag, |
| 1993 const CallWrapper& call_wrapper) { | 1994 const CallWrapper& call_wrapper) { |
| 1994 // You can't call a function without a valid frame. | 1995 // You can't call a function without a valid frame. |
| 1995 DCHECK(flag == JUMP_FUNCTION || has_frame()); | 1996 DCHECK(flag == JUMP_FUNCTION || has_frame()); |
| 1996 | 1997 |
| 1998 // Ensure new target is passed in the correct register. Otherwise clear the |
| 1999 // appropriate register in case new target is not given. |
| 2000 DCHECK_IMPLIES(new_target.is_valid(), new_target.is(edx)); |
| 2001 if (!new_target.is_valid()) { |
| 2002 mov(edx, isolate()->factory()->undefined_value()); |
| 2003 } |
| 2004 |
| 1997 Label done; | 2005 Label done; |
| 1998 bool definitely_mismatches = false; | 2006 bool definitely_mismatches = false; |
| 1999 InvokePrologue(expected, actual, &done, &definitely_mismatches, flag, | 2007 InvokePrologue(expected, actual, &done, &definitely_mismatches, flag, |
| 2000 Label::kNear, call_wrapper); | 2008 Label::kNear, call_wrapper); |
| 2001 if (!definitely_mismatches) { | 2009 if (!definitely_mismatches) { |
| 2002 if (flag == CALL_FUNCTION) { | 2010 if (flag == CALL_FUNCTION) { |
| 2003 call_wrapper.BeforeCall(CallSize(code)); | 2011 call_wrapper.BeforeCall(CallSize(code)); |
| 2004 call(code); | 2012 call(code); |
| 2005 call_wrapper.AfterCall(); | 2013 call_wrapper.AfterCall(); |
| 2006 } else { | 2014 } else { |
| 2007 DCHECK(flag == JUMP_FUNCTION); | 2015 DCHECK(flag == JUMP_FUNCTION); |
| 2008 jmp(code); | 2016 jmp(code); |
| 2009 } | 2017 } |
| 2010 bind(&done); | 2018 bind(&done); |
| 2011 } | 2019 } |
| 2012 } | 2020 } |
| 2013 | 2021 |
| 2014 | 2022 |
| 2015 void MacroAssembler::InvokeFunction(Register fun, | 2023 void MacroAssembler::InvokeFunction(Register fun, |
| 2024 Register new_target, |
| 2016 const ParameterCount& actual, | 2025 const ParameterCount& actual, |
| 2017 InvokeFlag flag, | 2026 InvokeFlag flag, |
| 2018 const CallWrapper& call_wrapper) { | 2027 const CallWrapper& call_wrapper) { |
| 2019 // You can't call a function without a valid frame. | 2028 // You can't call a function without a valid frame. |
| 2020 DCHECK(flag == JUMP_FUNCTION || has_frame()); | 2029 DCHECK(flag == JUMP_FUNCTION || has_frame()); |
| 2021 | 2030 |
| 2022 DCHECK(fun.is(edi)); | 2031 DCHECK(fun.is(edi)); |
| 2023 mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | 2032 mov(ebx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
| 2024 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); | 2033 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); |
| 2025 mov(ebx, FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset)); | 2034 mov(ebx, FieldOperand(ebx, SharedFunctionInfo::kFormalParameterCountOffset)); |
| 2026 SmiUntag(ebx); | 2035 SmiUntag(ebx); |
| 2027 | 2036 |
| 2028 ParameterCount expected(ebx); | 2037 ParameterCount expected(ebx); |
| 2029 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), | 2038 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), new_target, |
| 2030 expected, actual, flag, call_wrapper); | 2039 expected, actual, flag, call_wrapper); |
| 2031 } | 2040 } |
| 2032 | 2041 |
| 2033 | 2042 |
| 2034 void MacroAssembler::InvokeFunction(Register fun, | 2043 void MacroAssembler::InvokeFunction(Register fun, |
| 2035 const ParameterCount& expected, | 2044 const ParameterCount& expected, |
| 2036 const ParameterCount& actual, | 2045 const ParameterCount& actual, |
| 2037 InvokeFlag flag, | 2046 InvokeFlag flag, |
| 2038 const CallWrapper& call_wrapper) { | 2047 const CallWrapper& call_wrapper) { |
| 2039 // You can't call a function without a valid frame. | 2048 // You can't call a function without a valid frame. |
| 2040 DCHECK(flag == JUMP_FUNCTION || has_frame()); | 2049 DCHECK(flag == JUMP_FUNCTION || has_frame()); |
| 2041 | 2050 |
| 2042 DCHECK(fun.is(edi)); | 2051 DCHECK(fun.is(edi)); |
| 2043 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); | 2052 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); |
| 2044 | 2053 |
| 2045 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), | 2054 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), no_reg, |
| 2046 expected, actual, flag, call_wrapper); | 2055 expected, actual, flag, call_wrapper); |
| 2047 } | 2056 } |
| 2048 | 2057 |
| 2049 | 2058 |
| 2050 void MacroAssembler::InvokeFunction(Handle<JSFunction> function, | 2059 void MacroAssembler::InvokeFunction(Handle<JSFunction> function, |
| 2051 const ParameterCount& expected, | 2060 const ParameterCount& expected, |
| 2052 const ParameterCount& actual, | 2061 const ParameterCount& actual, |
| 2053 InvokeFlag flag, | 2062 InvokeFlag flag, |
| 2054 const CallWrapper& call_wrapper) { | 2063 const CallWrapper& call_wrapper) { |
| 2055 LoadHeapObject(edi, function); | 2064 LoadHeapObject(edi, function); |
| 2056 InvokeFunction(edi, expected, actual, flag, call_wrapper); | 2065 InvokeFunction(edi, expected, actual, flag, call_wrapper); |
| 2057 } | 2066 } |
| 2058 | 2067 |
| 2059 | 2068 |
| 2060 void MacroAssembler::InvokeBuiltin(int native_context_index, InvokeFlag flag, | 2069 void MacroAssembler::InvokeBuiltin(int native_context_index, InvokeFlag flag, |
| 2061 const CallWrapper& call_wrapper) { | 2070 const CallWrapper& call_wrapper) { |
| 2062 // You can't call a builtin without a valid frame. | 2071 // You can't call a builtin without a valid frame. |
| 2063 DCHECK(flag == JUMP_FUNCTION || has_frame()); | 2072 DCHECK(flag == JUMP_FUNCTION || has_frame()); |
| 2064 | 2073 |
| 2065 // Rely on the assertion to check that the number of provided | 2074 // Rely on the assertion to check that the number of provided |
| 2066 // arguments match the expected number of arguments. Fake a | 2075 // arguments match the expected number of arguments. Fake a |
| 2067 // parameter count to avoid emitting code to do the check. | 2076 // parameter count to avoid emitting code to do the check. |
| 2068 ParameterCount expected(0); | 2077 ParameterCount expected(0); |
| 2069 GetBuiltinFunction(edi, native_context_index); | 2078 GetBuiltinFunction(edi, native_context_index); |
| 2070 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), | 2079 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), no_reg, |
| 2071 expected, expected, flag, call_wrapper); | 2080 expected, expected, flag, call_wrapper); |
| 2072 } | 2081 } |
| 2073 | 2082 |
| 2074 | 2083 |
| 2075 void MacroAssembler::GetBuiltinFunction(Register target, | 2084 void MacroAssembler::GetBuiltinFunction(Register target, |
| 2076 int native_context_index) { | 2085 int native_context_index) { |
| 2077 // Load the JavaScript builtin function from the builtins object. | 2086 // Load the JavaScript builtin function from the builtins object. |
| 2078 mov(target, GlobalObjectOperand()); | 2087 mov(target, GlobalObjectOperand()); |
| 2079 mov(target, FieldOperand(target, JSGlobalObject::kNativeContextOffset)); | 2088 mov(target, FieldOperand(target, JSGlobalObject::kNativeContextOffset)); |
| 2080 mov(target, ContextOperand(target, native_context_index)); | 2089 mov(target, ContextOperand(target, native_context_index)); |
| (...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3137 mov(eax, dividend); | 3146 mov(eax, dividend); |
| 3138 shr(eax, 31); | 3147 shr(eax, 31); |
| 3139 add(edx, eax); | 3148 add(edx, eax); |
| 3140 } | 3149 } |
| 3141 | 3150 |
| 3142 | 3151 |
| 3143 } // namespace internal | 3152 } // namespace internal |
| 3144 } // namespace v8 | 3153 } // namespace v8 |
| 3145 | 3154 |
| 3146 #endif // V8_TARGET_ARCH_IA32 | 3155 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |