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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
8 | 8 |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 1958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1969 j(sign, then_label); | 1969 j(sign, then_label); |
1970 bind(&ok); | 1970 bind(&ok); |
1971 } | 1971 } |
1972 | 1972 |
1973 | 1973 |
1974 void MacroAssembler::TryGetFunctionPrototype(Register function, | 1974 void MacroAssembler::TryGetFunctionPrototype(Register function, |
1975 Register result, | 1975 Register result, |
1976 Register scratch, | 1976 Register scratch, |
1977 Label* miss, | 1977 Label* miss, |
1978 bool miss_on_bound_function) { | 1978 bool miss_on_bound_function) { |
1979 // Check that the receiver isn't a smi. | 1979 Label non_instance; |
1980 JumpIfSmi(function, miss); | 1980 if (miss_on_bound_function) { |
| 1981 // Check that the receiver isn't a smi. |
| 1982 JumpIfSmi(function, miss); |
1981 | 1983 |
1982 // Check that the function really is a function. | 1984 // Check that the function really is a function. |
1983 CmpObjectType(function, JS_FUNCTION_TYPE, result); | 1985 CmpObjectType(function, JS_FUNCTION_TYPE, result); |
1984 j(not_equal, miss); | 1986 j(not_equal, miss); |
1985 | 1987 |
1986 if (miss_on_bound_function) { | |
1987 // If a bound function, go to miss label. | 1988 // If a bound function, go to miss label. |
1988 mov(scratch, | 1989 mov(scratch, |
1989 FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); | 1990 FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); |
1990 BooleanBitTest(scratch, SharedFunctionInfo::kCompilerHintsOffset, | 1991 BooleanBitTest(scratch, SharedFunctionInfo::kCompilerHintsOffset, |
1991 SharedFunctionInfo::kBoundFunction); | 1992 SharedFunctionInfo::kBoundFunction); |
1992 j(not_zero, miss); | 1993 j(not_zero, miss); |
| 1994 |
| 1995 // Make sure that the function has an instance prototype. |
| 1996 movzx_b(scratch, FieldOperand(result, Map::kBitFieldOffset)); |
| 1997 test(scratch, Immediate(1 << Map::kHasNonInstancePrototype)); |
| 1998 j(not_zero, &non_instance); |
1993 } | 1999 } |
1994 | 2000 |
1995 // Make sure that the function has an instance prototype. | |
1996 Label non_instance; | |
1997 movzx_b(scratch, FieldOperand(result, Map::kBitFieldOffset)); | |
1998 test(scratch, Immediate(1 << Map::kHasNonInstancePrototype)); | |
1999 j(not_zero, &non_instance); | |
2000 | |
2001 // Get the prototype or initial map from the function. | 2001 // Get the prototype or initial map from the function. |
2002 mov(result, | 2002 mov(result, |
2003 FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); | 2003 FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); |
2004 | 2004 |
2005 // If the prototype or initial map is the hole, don't return it and | 2005 // If the prototype or initial map is the hole, don't return it and |
2006 // simply miss the cache instead. This will allow us to allocate a | 2006 // simply miss the cache instead. This will allow us to allocate a |
2007 // prototype object on-demand in the runtime system. | 2007 // prototype object on-demand in the runtime system. |
2008 cmp(result, Immediate(isolate()->factory()->the_hole_value())); | 2008 cmp(result, Immediate(isolate()->factory()->the_hole_value())); |
2009 j(equal, miss); | 2009 j(equal, miss); |
2010 | 2010 |
2011 // If the function does not have an initial map, we're done. | 2011 // If the function does not have an initial map, we're done. |
2012 Label done; | 2012 Label done; |
2013 CmpObjectType(result, MAP_TYPE, scratch); | 2013 CmpObjectType(result, MAP_TYPE, scratch); |
2014 j(not_equal, &done); | 2014 j(not_equal, &done); |
2015 | 2015 |
2016 // Get the prototype from the initial map. | 2016 // Get the prototype from the initial map. |
2017 mov(result, FieldOperand(result, Map::kPrototypeOffset)); | 2017 mov(result, FieldOperand(result, Map::kPrototypeOffset)); |
2018 jmp(&done); | |
2019 | 2018 |
2020 // Non-instance prototype: Fetch prototype from constructor field | 2019 if (miss_on_bound_function) { |
2021 // in initial map. | 2020 jmp(&done); |
2022 bind(&non_instance); | 2021 |
2023 mov(result, FieldOperand(result, Map::kConstructorOffset)); | 2022 // Non-instance prototype: Fetch prototype from constructor field |
| 2023 // in initial map. |
| 2024 bind(&non_instance); |
| 2025 mov(result, FieldOperand(result, Map::kConstructorOffset)); |
| 2026 } |
2024 | 2027 |
2025 // All done. | 2028 // All done. |
2026 bind(&done); | 2029 bind(&done); |
2027 } | 2030 } |
2028 | 2031 |
2029 | 2032 |
2030 void MacroAssembler::CallStub(CodeStub* stub, TypeFeedbackId ast_id) { | 2033 void MacroAssembler::CallStub(CodeStub* stub, TypeFeedbackId ast_id) { |
2031 ASSERT(AllowThisStubCall(stub)); // Calls are not allowed in some stubs. | 2034 ASSERT(AllowThisStubCall(stub)); // Calls are not allowed in some stubs. |
2032 call(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id); | 2035 call(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id); |
2033 } | 2036 } |
(...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3427 if (ms.shift() > 0) sar(edx, ms.shift()); | 3430 if (ms.shift() > 0) sar(edx, ms.shift()); |
3428 mov(eax, dividend); | 3431 mov(eax, dividend); |
3429 shr(eax, 31); | 3432 shr(eax, 31); |
3430 add(edx, eax); | 3433 add(edx, eax); |
3431 } | 3434 } |
3432 | 3435 |
3433 | 3436 |
3434 } } // namespace v8::internal | 3437 } } // namespace v8::internal |
3435 | 3438 |
3436 #endif // V8_TARGET_ARCH_IA32 | 3439 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |