Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(320)

Side by Side Diff: src/ia32/stub-cache-ia32.cc

Issue 6713004: Shorten bail out checks when calling code which can fail. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Next round Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/stub-cache-arm.cc ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 if (object->IsGlobalObject()) { 1402 if (object->IsGlobalObject()) {
1403 __ mov(edx, FieldOperand(edx, GlobalObject::kGlobalReceiverOffset)); 1403 __ mov(edx, FieldOperand(edx, GlobalObject::kGlobalReceiverOffset));
1404 __ mov(Operand(esp, (argc + 1) * kPointerSize), edx); 1404 __ mov(Operand(esp, (argc + 1) * kPointerSize), edx);
1405 } 1405 }
1406 1406
1407 // Invoke the function. 1407 // Invoke the function.
1408 __ InvokeFunction(edi, arguments(), JUMP_FUNCTION); 1408 __ InvokeFunction(edi, arguments(), JUMP_FUNCTION);
1409 1409
1410 // Handle call cache miss. 1410 // Handle call cache miss.
1411 __ bind(&miss); 1411 __ bind(&miss);
1412 Object* obj; 1412 MaybeObject* maybe_result = GenerateMissBranch();
1413 { MaybeObject* maybe_obj = GenerateMissBranch(); 1413 if (maybe_result->IsFailure()) return maybe_result;
1414 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
1415 }
1416 1414
1417 // Return the generated code. 1415 // Return the generated code.
1418 return GetCode(FIELD, name); 1416 return GetCode(FIELD, name);
1419 } 1417 }
1420 1418
1421 1419
1422 MaybeObject* CallStubCompiler::CompileArrayPushCall(Object* object, 1420 MaybeObject* CallStubCompiler::CompileArrayPushCall(Object* object,
1423 JSObject* holder, 1421 JSObject* holder,
1424 JSGlobalPropertyCell* cell, 1422 JSGlobalPropertyCell* cell,
1425 JSFunction* function, 1423 JSFunction* function,
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 __ ret((argc + 1) * kPointerSize); 1552 __ ret((argc + 1) * kPointerSize);
1555 } 1553 }
1556 1554
1557 __ bind(&call_builtin); 1555 __ bind(&call_builtin);
1558 __ TailCallExternalReference(ExternalReference(Builtins::c_ArrayPush), 1556 __ TailCallExternalReference(ExternalReference(Builtins::c_ArrayPush),
1559 argc + 1, 1557 argc + 1,
1560 1); 1558 1);
1561 } 1559 }
1562 1560
1563 __ bind(&miss); 1561 __ bind(&miss);
1564 Object* obj; 1562 MaybeObject* maybe_result = GenerateMissBranch();
1565 { MaybeObject* maybe_obj = GenerateMissBranch(); 1563 if (maybe_result->IsFailure()) return maybe_result;
1566 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
1567 }
1568 1564
1569 // Return the generated code. 1565 // Return the generated code.
1570 return GetCode(function); 1566 return GetCode(function);
1571 } 1567 }
1572 1568
1573 1569
1574 MaybeObject* CallStubCompiler::CompileArrayPopCall(Object* object, 1570 MaybeObject* CallStubCompiler::CompileArrayPopCall(Object* object,
1575 JSObject* holder, 1571 JSObject* holder,
1576 JSGlobalPropertyCell* cell, 1572 JSGlobalPropertyCell* cell,
1577 JSFunction* function, 1573 JSFunction* function,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1637 __ bind(&return_undefined); 1633 __ bind(&return_undefined);
1638 __ mov(eax, Immediate(FACTORY->undefined_value())); 1634 __ mov(eax, Immediate(FACTORY->undefined_value()));
1639 __ ret((argc + 1) * kPointerSize); 1635 __ ret((argc + 1) * kPointerSize);
1640 1636
1641 __ bind(&call_builtin); 1637 __ bind(&call_builtin);
1642 __ TailCallExternalReference(ExternalReference(Builtins::c_ArrayPop), 1638 __ TailCallExternalReference(ExternalReference(Builtins::c_ArrayPop),
1643 argc + 1, 1639 argc + 1,
1644 1); 1640 1);
1645 1641
1646 __ bind(&miss); 1642 __ bind(&miss);
1647 Object* obj; 1643 MaybeObject* maybe_result = GenerateMissBranch();
1648 { MaybeObject* maybe_obj = GenerateMissBranch(); 1644 if (maybe_result->IsFailure()) return maybe_result;
1649 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
1650 }
1651 1645
1652 // Return the generated code. 1646 // Return the generated code.
1653 return GetCode(function); 1647 return GetCode(function);
1654 } 1648 }
1655 1649
1656 1650
1657 MaybeObject* CallStubCompiler::CompileStringCharCodeAtCall( 1651 MaybeObject* CallStubCompiler::CompileStringCharCodeAtCall(
1658 Object* object, 1652 Object* object,
1659 JSObject* holder, 1653 JSObject* holder,
1660 JSGlobalPropertyCell* cell, 1654 JSGlobalPropertyCell* cell,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1721 if (index_out_of_range.is_linked()) { 1715 if (index_out_of_range.is_linked()) {
1722 __ bind(&index_out_of_range); 1716 __ bind(&index_out_of_range);
1723 __ Set(eax, Immediate(FACTORY->nan_value())); 1717 __ Set(eax, Immediate(FACTORY->nan_value()));
1724 __ ret((argc + 1) * kPointerSize); 1718 __ ret((argc + 1) * kPointerSize);
1725 } 1719 }
1726 1720
1727 __ bind(&miss); 1721 __ bind(&miss);
1728 // Restore function name in ecx. 1722 // Restore function name in ecx.
1729 __ Set(ecx, Immediate(Handle<String>(name))); 1723 __ Set(ecx, Immediate(Handle<String>(name)));
1730 __ bind(&name_miss); 1724 __ bind(&name_miss);
1731 Object* obj; 1725 MaybeObject* maybe_result = GenerateMissBranch();
1732 { MaybeObject* maybe_obj = GenerateMissBranch(); 1726 if (maybe_result->IsFailure()) return maybe_result;
1733 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
1734 }
1735 1727
1736 // Return the generated code. 1728 // Return the generated code.
1737 return GetCode(function); 1729 return GetCode(function);
1738 } 1730 }
1739 1731
1740 1732
1741 MaybeObject* CallStubCompiler::CompileStringCharAtCall( 1733 MaybeObject* CallStubCompiler::CompileStringCharAtCall(
1742 Object* object, 1734 Object* object,
1743 JSObject* holder, 1735 JSObject* holder,
1744 JSGlobalPropertyCell* cell, 1736 JSGlobalPropertyCell* cell,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 if (index_out_of_range.is_linked()) { 1799 if (index_out_of_range.is_linked()) {
1808 __ bind(&index_out_of_range); 1800 __ bind(&index_out_of_range);
1809 __ Set(eax, Immediate(FACTORY->empty_string())); 1801 __ Set(eax, Immediate(FACTORY->empty_string()));
1810 __ ret((argc + 1) * kPointerSize); 1802 __ ret((argc + 1) * kPointerSize);
1811 } 1803 }
1812 1804
1813 __ bind(&miss); 1805 __ bind(&miss);
1814 // Restore function name in ecx. 1806 // Restore function name in ecx.
1815 __ Set(ecx, Immediate(Handle<String>(name))); 1807 __ Set(ecx, Immediate(Handle<String>(name)));
1816 __ bind(&name_miss); 1808 __ bind(&name_miss);
1817 Object* obj; 1809 MaybeObject* maybe_result = GenerateMissBranch();
1818 { MaybeObject* maybe_obj = GenerateMissBranch(); 1810 if (maybe_result->IsFailure()) return maybe_result;
1819 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
1820 }
1821 1811
1822 // Return the generated code. 1812 // Return the generated code.
1823 return GetCode(function); 1813 return GetCode(function);
1824 } 1814 }
1825 1815
1826 1816
1827 MaybeObject* CallStubCompiler::CompileStringFromCharCodeCall( 1817 MaybeObject* CallStubCompiler::CompileStringFromCharCodeCall(
1828 Object* object, 1818 Object* object,
1829 JSObject* holder, 1819 JSObject* holder,
1830 JSGlobalPropertyCell* cell, 1820 JSGlobalPropertyCell* cell,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1882 StubRuntimeCallHelper call_helper; 1872 StubRuntimeCallHelper call_helper;
1883 char_from_code_generator.GenerateSlow(masm(), call_helper); 1873 char_from_code_generator.GenerateSlow(masm(), call_helper);
1884 1874
1885 // Tail call the full function. We do not have to patch the receiver 1875 // Tail call the full function. We do not have to patch the receiver
1886 // because the function makes no use of it. 1876 // because the function makes no use of it.
1887 __ bind(&slow); 1877 __ bind(&slow);
1888 __ InvokeFunction(function, arguments(), JUMP_FUNCTION); 1878 __ InvokeFunction(function, arguments(), JUMP_FUNCTION);
1889 1879
1890 __ bind(&miss); 1880 __ bind(&miss);
1891 // ecx: function name. 1881 // ecx: function name.
1892 Object* obj; 1882 MaybeObject* maybe_result = GenerateMissBranch();
1893 { MaybeObject* maybe_obj = GenerateMissBranch(); 1883 if (maybe_result->IsFailure()) return maybe_result;
1894 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
1895 }
1896 1884
1897 // Return the generated code. 1885 // Return the generated code.
1898 return (cell == NULL) ? GetCode(function) : GetCode(NORMAL, name); 1886 return (cell == NULL) ? GetCode(function) : GetCode(NORMAL, name);
1899 } 1887 }
1900 1888
1901 1889
1902 MaybeObject* CallStubCompiler::CompileMathFloorCall(Object* object, 1890 MaybeObject* CallStubCompiler::CompileMathFloorCall(Object* object,
1903 JSObject* holder, 1891 JSObject* holder,
1904 JSGlobalPropertyCell* cell, 1892 JSGlobalPropertyCell* cell,
1905 JSFunction* function, 1893 JSFunction* function,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
2010 __ mov(eax, Operand(esp, 1 * kPointerSize)); 1998 __ mov(eax, Operand(esp, 1 * kPointerSize));
2011 __ ret(2 * kPointerSize); 1999 __ ret(2 * kPointerSize);
2012 2000
2013 // Tail call the full function. We do not have to patch the receiver 2001 // Tail call the full function. We do not have to patch the receiver
2014 // because the function makes no use of it. 2002 // because the function makes no use of it.
2015 __ bind(&slow); 2003 __ bind(&slow);
2016 __ InvokeFunction(function, arguments(), JUMP_FUNCTION); 2004 __ InvokeFunction(function, arguments(), JUMP_FUNCTION);
2017 2005
2018 __ bind(&miss); 2006 __ bind(&miss);
2019 // ecx: function name. 2007 // ecx: function name.
2020 Object* obj; 2008 MaybeObject* maybe_result = GenerateMissBranch();
2021 { MaybeObject* maybe_obj = GenerateMissBranch(); 2009 if (maybe_result->IsFailure()) return maybe_result;
2022 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
2023 }
2024 2010
2025 // Return the generated code. 2011 // Return the generated code.
2026 return (cell == NULL) ? GetCode(function) : GetCode(NORMAL, name); 2012 return (cell == NULL) ? GetCode(function) : GetCode(NORMAL, name);
2027 } 2013 }
2028 2014
2029 2015
2030 MaybeObject* CallStubCompiler::CompileMathAbsCall(Object* object, 2016 MaybeObject* CallStubCompiler::CompileMathAbsCall(Object* object,
2031 JSObject* holder, 2017 JSObject* holder,
2032 JSGlobalPropertyCell* cell, 2018 JSGlobalPropertyCell* cell,
2033 JSFunction* function, 2019 JSFunction* function,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
2115 __ mov(FieldOperand(eax, HeapNumber::kMantissaOffset), ecx); 2101 __ mov(FieldOperand(eax, HeapNumber::kMantissaOffset), ecx);
2116 __ ret(2 * kPointerSize); 2102 __ ret(2 * kPointerSize);
2117 2103
2118 // Tail call the full function. We do not have to patch the receiver 2104 // Tail call the full function. We do not have to patch the receiver
2119 // because the function makes no use of it. 2105 // because the function makes no use of it.
2120 __ bind(&slow); 2106 __ bind(&slow);
2121 __ InvokeFunction(function, arguments(), JUMP_FUNCTION); 2107 __ InvokeFunction(function, arguments(), JUMP_FUNCTION);
2122 2108
2123 __ bind(&miss); 2109 __ bind(&miss);
2124 // ecx: function name. 2110 // ecx: function name.
2125 Object* obj; 2111 MaybeObject* maybe_result = GenerateMissBranch();
2126 { MaybeObject* maybe_obj = GenerateMissBranch(); 2112 if (maybe_result->IsFailure()) return maybe_result;
2127 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
2128 }
2129 2113
2130 // Return the generated code. 2114 // Return the generated code.
2131 return (cell == NULL) ? GetCode(function) : GetCode(NORMAL, name); 2115 return (cell == NULL) ? GetCode(function) : GetCode(NORMAL, name);
2132 } 2116 }
2133 2117
2134 2118
2135 MaybeObject* CallStubCompiler::CompileFastApiCall( 2119 MaybeObject* CallStubCompiler::CompileFastApiCall(
2136 const CallOptimization& optimization, 2120 const CallOptimization& optimization,
2137 Object* object, 2121 Object* object,
2138 JSObject* holder, 2122 JSObject* holder,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2177 2161
2178 // esp[2 * kPointerSize] is uninitialized, esp[3 * kPointerSize] contains 2162 // esp[2 * kPointerSize] is uninitialized, esp[3 * kPointerSize] contains
2179 // duplicate of return address and will be overwritten. 2163 // duplicate of return address and will be overwritten.
2180 MaybeObject* result = GenerateFastApiCall(masm(), optimization, argc); 2164 MaybeObject* result = GenerateFastApiCall(masm(), optimization, argc);
2181 if (result->IsFailure()) return result; 2165 if (result->IsFailure()) return result;
2182 2166
2183 __ bind(&miss); 2167 __ bind(&miss);
2184 __ add(Operand(esp), Immediate(kFastApiCallArguments * kPointerSize)); 2168 __ add(Operand(esp), Immediate(kFastApiCallArguments * kPointerSize));
2185 2169
2186 __ bind(&miss_before_stack_reserved); 2170 __ bind(&miss_before_stack_reserved);
2187 Object* obj; 2171 MaybeObject* maybe_result = GenerateMissBranch();
2188 { MaybeObject* maybe_obj = GenerateMissBranch(); 2172 if (maybe_result->IsFailure()) return maybe_result;
2189 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
2190 }
2191 2173
2192 // Return the generated code. 2174 // Return the generated code.
2193 return GetCode(function); 2175 return GetCode(function);
2194 } 2176 }
2195 2177
2196 2178
2197 MaybeObject* CallStubCompiler::CompileCallConstant(Object* object, 2179 MaybeObject* CallStubCompiler::CompileCallConstant(Object* object,
2198 JSObject* holder, 2180 JSObject* holder,
2199 JSFunction* function, 2181 JSFunction* function,
2200 String* name, 2182 String* name,
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
2313 } 2295 }
2314 2296
2315 default: 2297 default:
2316 UNREACHABLE(); 2298 UNREACHABLE();
2317 } 2299 }
2318 2300
2319 __ InvokeFunction(function, arguments(), JUMP_FUNCTION); 2301 __ InvokeFunction(function, arguments(), JUMP_FUNCTION);
2320 2302
2321 // Handle call cache miss. 2303 // Handle call cache miss.
2322 __ bind(&miss); 2304 __ bind(&miss);
2323 Object* obj; 2305 MaybeObject* maybe_result = GenerateMissBranch();
2324 { MaybeObject* maybe_obj = GenerateMissBranch(); 2306 if (maybe_result->IsFailure()) return maybe_result;
2325 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
2326 }
2327 2307
2328 // Return the generated code. 2308 // Return the generated code.
2329 return GetCode(function); 2309 return GetCode(function);
2330 } 2310 }
2331 2311
2332 2312
2333 MaybeObject* CallStubCompiler::CompileCallInterceptor(JSObject* object, 2313 MaybeObject* CallStubCompiler::CompileCallInterceptor(JSObject* object,
2334 JSObject* holder, 2314 JSObject* holder,
2335 String* name) { 2315 String* name) {
2336 // ----------- S t a t e ------------- 2316 // ----------- S t a t e -------------
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2381 __ mov(edx, FieldOperand(edx, GlobalObject::kGlobalReceiverOffset)); 2361 __ mov(edx, FieldOperand(edx, GlobalObject::kGlobalReceiverOffset));
2382 __ mov(Operand(esp, (argc + 1) * kPointerSize), edx); 2362 __ mov(Operand(esp, (argc + 1) * kPointerSize), edx);
2383 } 2363 }
2384 2364
2385 // Invoke the function. 2365 // Invoke the function.
2386 __ mov(edi, eax); 2366 __ mov(edi, eax);
2387 __ InvokeFunction(edi, arguments(), JUMP_FUNCTION); 2367 __ InvokeFunction(edi, arguments(), JUMP_FUNCTION);
2388 2368
2389 // Handle load cache miss. 2369 // Handle load cache miss.
2390 __ bind(&miss); 2370 __ bind(&miss);
2391 Object* obj; 2371 MaybeObject* maybe_result = GenerateMissBranch();
2392 { MaybeObject* maybe_obj = GenerateMissBranch(); 2372 if (maybe_result->IsFailure()) return maybe_result;
2393 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
2394 }
2395 2373
2396 // Return the generated code. 2374 // Return the generated code.
2397 return GetCode(INTERCEPTOR, name); 2375 return GetCode(INTERCEPTOR, name);
2398 } 2376 }
2399 2377
2400 2378
2401 MaybeObject* CallStubCompiler::CompileCallGlobal(JSObject* object, 2379 MaybeObject* CallStubCompiler::CompileCallGlobal(JSObject* object,
2402 GlobalObject* holder, 2380 GlobalObject* holder,
2403 JSGlobalPropertyCell* cell, 2381 JSGlobalPropertyCell* cell,
2404 JSFunction* function, 2382 JSFunction* function,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2452 expected, arguments(), JUMP_FUNCTION); 2430 expected, arguments(), JUMP_FUNCTION);
2453 } else { 2431 } else {
2454 Handle<Code> code(function->code()); 2432 Handle<Code> code(function->code());
2455 __ InvokeCode(code, expected, arguments(), 2433 __ InvokeCode(code, expected, arguments(),
2456 RelocInfo::CODE_TARGET, JUMP_FUNCTION); 2434 RelocInfo::CODE_TARGET, JUMP_FUNCTION);
2457 } 2435 }
2458 2436
2459 // Handle call cache miss. 2437 // Handle call cache miss.
2460 __ bind(&miss); 2438 __ bind(&miss);
2461 __ IncrementCounter(COUNTERS->call_global_inline_miss(), 1); 2439 __ IncrementCounter(COUNTERS->call_global_inline_miss(), 1);
2462 Object* obj; 2440 MaybeObject* maybe_result = GenerateMissBranch();
2463 { MaybeObject* maybe_obj = GenerateMissBranch(); 2441 if (maybe_result->IsFailure()) return maybe_result;
2464 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
2465 }
2466 2442
2467 // Return the generated code. 2443 // Return the generated code.
2468 return GetCode(NORMAL, name); 2444 return GetCode(NORMAL, name);
2469 } 2445 }
2470 2446
2471 2447
2472 MaybeObject* StoreStubCompiler::CompileStoreField(JSObject* object, 2448 MaybeObject* StoreStubCompiler::CompileStoreField(JSObject* object,
2473 int index, 2449 int index,
2474 Map* transition, 2450 Map* transition,
2475 String* name) { 2451 String* name) {
(...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after
3691 3667
3692 return GetCode(flags); 3668 return GetCode(flags);
3693 } 3669 }
3694 3670
3695 3671
3696 #undef __ 3672 #undef __
3697 3673
3698 } } // namespace v8::internal 3674 } } // namespace v8::internal
3699 3675
3700 #endif // V8_TARGET_ARCH_IA32 3676 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/arm/stub-cache-arm.cc ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698