OLD | NEW |
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 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1534 #ifdef DEBUG | 1534 #ifdef DEBUG |
1535 TraceIC("KeyedStoreIC", name, state, target()); | 1535 TraceIC("KeyedStoreIC", name, state, target()); |
1536 #endif | 1536 #endif |
1537 } | 1537 } |
1538 | 1538 |
1539 | 1539 |
1540 // ---------------------------------------------------------------------------- | 1540 // ---------------------------------------------------------------------------- |
1541 // Static IC stub generators. | 1541 // Static IC stub generators. |
1542 // | 1542 // |
1543 | 1543 |
1544 static Object* CompileFunction(Object* result, | 1544 static JSFunction* CompileFunction(JSFunction* function, |
1545 Handle<Object> object, | 1545 InLoopFlag in_loop) { |
1546 InLoopFlag in_loop) { | |
1547 // Compile now with optimization. | 1546 // Compile now with optimization. |
1548 HandleScope scope; | 1547 HandleScope scope; |
1549 Handle<JSFunction> function = Handle<JSFunction>(JSFunction::cast(result)); | 1548 Handle<JSFunction> function_handle(function); |
1550 if (in_loop == IN_LOOP) { | 1549 if (in_loop == IN_LOOP) { |
1551 CompileLazyInLoop(function, object, CLEAR_EXCEPTION); | 1550 CompileLazyInLoop(function_handle, CLEAR_EXCEPTION); |
1552 } else { | 1551 } else { |
1553 CompileLazy(function, object, CLEAR_EXCEPTION); | 1552 CompileLazy(function_handle, CLEAR_EXCEPTION); |
1554 } | 1553 } |
1555 return *function; | 1554 return *function_handle; |
1556 } | 1555 } |
1557 | 1556 |
1558 | 1557 |
1559 // Used from ic-<arch>.cc. | 1558 // Used from ic-<arch>.cc. |
1560 Object* CallIC_Miss(Arguments args) { | 1559 Object* CallIC_Miss(Arguments args) { |
1561 NoHandleAllocation na; | 1560 NoHandleAllocation na; |
1562 ASSERT(args.length() == 2); | 1561 ASSERT(args.length() == 2); |
1563 CallIC ic; | 1562 CallIC ic; |
1564 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); | 1563 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); |
1565 Object* result = | 1564 Object* result = |
1566 ic.LoadFunction(state, args.at<Object>(0), args.at<String>(1)); | 1565 ic.LoadFunction(state, args.at<Object>(0), args.at<String>(1)); |
1567 | 1566 |
1568 // The first time the inline cache is updated may be the first time the | 1567 // The first time the inline cache is updated may be the first time the |
1569 // function it references gets called. If the function was lazily compiled | 1568 // function it references gets called. If the function was lazily compiled |
1570 // then the first call will trigger a compilation. We check for this case | 1569 // then the first call will trigger a compilation. We check for this case |
1571 // and we do the compilation immediately, instead of waiting for the stub | 1570 // and we do the compilation immediately, instead of waiting for the stub |
1572 // currently attached to the JSFunction object to trigger compilation. We | 1571 // currently attached to the JSFunction object to trigger compilation. We |
1573 // do this in the case where we know that the inline cache is inside a loop, | 1572 // do this in the case where we know that the inline cache is inside a loop, |
1574 // because then we know that we want to optimize the function. | 1573 // because then we know that we want to optimize the function. |
1575 if (!result->IsJSFunction() || JSFunction::cast(result)->is_compiled()) { | 1574 if (!result->IsJSFunction() || JSFunction::cast(result)->is_compiled()) { |
1576 return result; | 1575 return result; |
1577 } | 1576 } |
1578 return CompileFunction(result, args.at<Object>(0), ic.target()->ic_in_loop()); | 1577 return CompileFunction(JSFunction::cast(result), ic.target()->ic_in_loop()); |
1579 } | 1578 } |
1580 | 1579 |
1581 | 1580 |
1582 // Used from ic-<arch>.cc. | 1581 // Used from ic-<arch>.cc. |
1583 Object* KeyedCallIC_Miss(Arguments args) { | 1582 Object* KeyedCallIC_Miss(Arguments args) { |
1584 NoHandleAllocation na; | 1583 NoHandleAllocation na; |
1585 ASSERT(args.length() == 2); | 1584 ASSERT(args.length() == 2); |
1586 KeyedCallIC ic; | 1585 KeyedCallIC ic; |
1587 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); | 1586 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); |
1588 Object* result = | 1587 Object* result = |
1589 ic.LoadFunction(state, args.at<Object>(0), args.at<Object>(1)); | 1588 ic.LoadFunction(state, args.at<Object>(0), args.at<Object>(1)); |
1590 | 1589 |
1591 if (!result->IsJSFunction() || JSFunction::cast(result)->is_compiled()) { | 1590 if (!result->IsJSFunction() || JSFunction::cast(result)->is_compiled()) { |
1592 return result; | 1591 return result; |
1593 } | 1592 } |
1594 return CompileFunction(result, args.at<Object>(0), ic.target()->ic_in_loop()); | 1593 return CompileFunction(JSFunction::cast(result), ic.target()->ic_in_loop()); |
1595 } | 1594 } |
1596 | 1595 |
1597 | 1596 |
1598 // Used from ic-<arch>.cc. | 1597 // Used from ic-<arch>.cc. |
1599 Object* LoadIC_Miss(Arguments args) { | 1598 Object* LoadIC_Miss(Arguments args) { |
1600 NoHandleAllocation na; | 1599 NoHandleAllocation na; |
1601 ASSERT(args.length() == 2); | 1600 ASSERT(args.length() == 2); |
1602 LoadIC ic; | 1601 LoadIC ic; |
1603 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); | 1602 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); |
1604 return ic.Load(state, args.at<Object>(0), args.at<String>(1)); | 1603 return ic.Load(state, args.at<Object>(0), args.at<String>(1)); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1833 #undef ADDR | 1832 #undef ADDR |
1834 }; | 1833 }; |
1835 | 1834 |
1836 | 1835 |
1837 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 1836 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
1838 return IC_utilities[id]; | 1837 return IC_utilities[id]; |
1839 } | 1838 } |
1840 | 1839 |
1841 | 1840 |
1842 } } // namespace v8::internal | 1841 } } // namespace v8::internal |
OLD | NEW |