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_X87 | 7 #if V8_TARGET_ARCH_X87 |
8 | 8 |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 1851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1862 j(sign, then_label); | 1862 j(sign, then_label); |
1863 bind(&ok); | 1863 bind(&ok); |
1864 } | 1864 } |
1865 | 1865 |
1866 | 1866 |
1867 void MacroAssembler::TryGetFunctionPrototype(Register function, | 1867 void MacroAssembler::TryGetFunctionPrototype(Register function, |
1868 Register result, | 1868 Register result, |
1869 Register scratch, | 1869 Register scratch, |
1870 Label* miss, | 1870 Label* miss, |
1871 bool miss_on_bound_function) { | 1871 bool miss_on_bound_function) { |
1872 // Check that the receiver isn't a smi. | 1872 Label non_instance; |
1873 JumpIfSmi(function, miss); | 1873 if (miss_on_bound_function) { |
| 1874 // Check that the receiver isn't a smi. |
| 1875 JumpIfSmi(function, miss); |
1874 | 1876 |
1875 // Check that the function really is a function. | 1877 // Check that the function really is a function. |
1876 CmpObjectType(function, JS_FUNCTION_TYPE, result); | 1878 CmpObjectType(function, JS_FUNCTION_TYPE, result); |
1877 j(not_equal, miss); | 1879 j(not_equal, miss); |
1878 | 1880 |
1879 if (miss_on_bound_function) { | |
1880 // If a bound function, go to miss label. | 1881 // If a bound function, go to miss label. |
1881 mov(scratch, | 1882 mov(scratch, |
1882 FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); | 1883 FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); |
1883 BooleanBitTest(scratch, SharedFunctionInfo::kCompilerHintsOffset, | 1884 BooleanBitTest(scratch, SharedFunctionInfo::kCompilerHintsOffset, |
1884 SharedFunctionInfo::kBoundFunction); | 1885 SharedFunctionInfo::kBoundFunction); |
1885 j(not_zero, miss); | 1886 j(not_zero, miss); |
| 1887 |
| 1888 // Make sure that the function has an instance prototype. |
| 1889 movzx_b(scratch, FieldOperand(result, Map::kBitFieldOffset)); |
| 1890 test(scratch, Immediate(1 << Map::kHasNonInstancePrototype)); |
| 1891 j(not_zero, &non_instance); |
1886 } | 1892 } |
1887 | 1893 |
1888 // Make sure that the function has an instance prototype. | |
1889 Label non_instance; | |
1890 movzx_b(scratch, FieldOperand(result, Map::kBitFieldOffset)); | |
1891 test(scratch, Immediate(1 << Map::kHasNonInstancePrototype)); | |
1892 j(not_zero, &non_instance); | |
1893 | |
1894 // Get the prototype or initial map from the function. | 1894 // Get the prototype or initial map from the function. |
1895 mov(result, | 1895 mov(result, |
1896 FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); | 1896 FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); |
1897 | 1897 |
1898 // If the prototype or initial map is the hole, don't return it and | 1898 // If the prototype or initial map is the hole, don't return it and |
1899 // simply miss the cache instead. This will allow us to allocate a | 1899 // simply miss the cache instead. This will allow us to allocate a |
1900 // prototype object on-demand in the runtime system. | 1900 // prototype object on-demand in the runtime system. |
1901 cmp(result, Immediate(isolate()->factory()->the_hole_value())); | 1901 cmp(result, Immediate(isolate()->factory()->the_hole_value())); |
1902 j(equal, miss); | 1902 j(equal, miss); |
1903 | 1903 |
1904 // If the function does not have an initial map, we're done. | 1904 // If the function does not have an initial map, we're done. |
1905 Label done; | 1905 Label done; |
1906 CmpObjectType(result, MAP_TYPE, scratch); | 1906 CmpObjectType(result, MAP_TYPE, scratch); |
1907 j(not_equal, &done); | 1907 j(not_equal, &done); |
1908 | 1908 |
1909 // Get the prototype from the initial map. | 1909 // Get the prototype from the initial map. |
1910 mov(result, FieldOperand(result, Map::kPrototypeOffset)); | 1910 mov(result, FieldOperand(result, Map::kPrototypeOffset)); |
1911 jmp(&done); | |
1912 | 1911 |
1913 // Non-instance prototype: Fetch prototype from constructor field | 1912 if (miss_on_bound_function) { |
1914 // in initial map. | 1913 jmp(&done); |
1915 bind(&non_instance); | 1914 |
1916 mov(result, FieldOperand(result, Map::kConstructorOffset)); | 1915 // Non-instance prototype: Fetch prototype from constructor field |
| 1916 // in initial map. |
| 1917 bind(&non_instance); |
| 1918 mov(result, FieldOperand(result, Map::kConstructorOffset)); |
| 1919 } |
1917 | 1920 |
1918 // All done. | 1921 // All done. |
1919 bind(&done); | 1922 bind(&done); |
1920 } | 1923 } |
1921 | 1924 |
1922 | 1925 |
1923 void MacroAssembler::CallStub(CodeStub* stub, TypeFeedbackId ast_id) { | 1926 void MacroAssembler::CallStub(CodeStub* stub, TypeFeedbackId ast_id) { |
1924 ASSERT(AllowThisStubCall(stub)); // Calls are not allowed in some stubs. | 1927 ASSERT(AllowThisStubCall(stub)); // Calls are not allowed in some stubs. |
1925 call(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id); | 1928 call(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id); |
1926 } | 1929 } |
(...skipping 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3314 if (ms.shift() > 0) sar(edx, ms.shift()); | 3317 if (ms.shift() > 0) sar(edx, ms.shift()); |
3315 mov(eax, dividend); | 3318 mov(eax, dividend); |
3316 shr(eax, 31); | 3319 shr(eax, 31); |
3317 add(edx, eax); | 3320 add(edx, eax); |
3318 } | 3321 } |
3319 | 3322 |
3320 | 3323 |
3321 } } // namespace v8::internal | 3324 } } // namespace v8::internal |
3322 | 3325 |
3323 #endif // V8_TARGET_ARCH_X87 | 3326 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |