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

Side by Side Diff: src/ic.cc

Issue 10545080: Optimize call sites that only ever have a single elements transition (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 6 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 | « no previous file | test/mjsunit/elements-kind.js » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after
1560 1560
1561 // Don't handle megamorphic property accesses for INTERCEPTORS or CALLBACKS 1561 // Don't handle megamorphic property accesses for INTERCEPTORS or CALLBACKS
1562 // via megamorphic stubs, since they don't have a map in their relocation info 1562 // via megamorphic stubs, since they don't have a map in their relocation info
1563 // and so the stubs can't be harvested for the object needed for a map check. 1563 // and so the stubs can't be harvested for the object needed for a map check.
1564 if (target()->type() != NORMAL) { 1564 if (target()->type() != NORMAL) {
1565 TRACE_GENERIC_IC("KeyedIC", "non-NORMAL target type"); 1565 TRACE_GENERIC_IC("KeyedIC", "non-NORMAL target type");
1566 return generic_stub; 1566 return generic_stub;
1567 } 1567 }
1568 1568
1569 bool monomorphic = false; 1569 bool monomorphic = false;
1570 bool maybe_monomorphic = false;
1570 MapHandleList target_receiver_maps; 1571 MapHandleList target_receiver_maps;
1571 if (ic_state != UNINITIALIZED && ic_state != PREMONOMORPHIC) { 1572 if (ic_state != UNINITIALIZED && ic_state != PREMONOMORPHIC) {
1572 GetReceiverMapsForStub(Handle<Code>(target()), &target_receiver_maps); 1573 GetReceiverMapsForStub(Handle<Code>(target()), &target_receiver_maps);
1573 } 1574 }
1574 if (!IsTransitionStubKind(stub_kind)) { 1575 if (!IsTransitionStubKind(stub_kind)) {
1575 if (ic_state == UNINITIALIZED || ic_state == PREMONOMORPHIC) { 1576 if (ic_state == UNINITIALIZED || ic_state == PREMONOMORPHIC) {
1576 monomorphic = true; 1577 monomorphic = true;
1577 } else { 1578 } else {
1578 if (ic_state == MONOMORPHIC) { 1579 if (ic_state == MONOMORPHIC) {
1579 // The first time a receiver is seen that is a transitioned version of 1580 // The first time a receiver is seen that is a transitioned version of
1580 // the previous monomorphic receiver type, assume the new ElementsKind 1581 // the previous monomorphic receiver type, assume the new ElementsKind
1581 // is the monomorphic type. This benefits global arrays that only 1582 // is the monomorphic type. This benefits global arrays that only
1582 // transition once, and all call sites accessing them are faster if they 1583 // transition once, and all call sites accessing them are faster if they
1583 // remain monomorphic. If this optimistic assumption is not true, the IC 1584 // remain monomorphic. If this optimistic assumption is not true, the IC
1584 // will miss again and it will become polymorphic and support both the 1585 // will miss again and it will become polymorphic and support both the
1585 // untransitioned and transitioned maps. 1586 // untransitioned and transitioned maps.
1586 monomorphic = IsMoreGeneralElementsKindTransition( 1587 monomorphic = IsMoreGeneralElementsKindTransition(
1587 target_receiver_maps.at(0)->elements_kind(), 1588 target_receiver_maps.at(0)->elements_kind(),
1588 receiver->GetElementsKind()); 1589 receiver->GetElementsKind());
1589 } 1590 }
1590 } 1591 }
1592 } else {
1593 if (ic_state == UNINITIALIZED || ic_state == PREMONOMORPHIC) {
1594 maybe_monomorphic = true;
1595 }
1591 } 1596 }
1592 1597
1593 if (monomorphic) { 1598 if (monomorphic) {
1594 return ComputeMonomorphicStub( 1599 return ComputeMonomorphicStub(
1595 receiver, stub_kind, strict_mode, generic_stub); 1600 receiver, stub_kind, strict_mode, generic_stub);
1596 } 1601 }
1597 ASSERT(target() != *generic_stub); 1602 ASSERT(target() != *generic_stub);
1598 1603
1599 // Determine the list of receiver maps that this call site has seen, 1604 // Determine the list of receiver maps that this call site has seen,
1600 // adding the map that was just encountered. 1605 // adding the map that was just encountered.
1601 Handle<Map> receiver_map(receiver->map()); 1606 Handle<Map> receiver_map(receiver->map());
1602 bool map_added = 1607 bool map_added =
1608 maybe_monomorphic ? false :
1603 AddOneReceiverMapIfMissing(&target_receiver_maps, receiver_map); 1609 AddOneReceiverMapIfMissing(&target_receiver_maps, receiver_map);
1604 if (IsTransitionStubKind(stub_kind)) { 1610 if (IsTransitionStubKind(stub_kind)) {
1605 Handle<Map> new_map = ComputeTransitionedMap(receiver, stub_kind); 1611 Handle<Map> new_map = ComputeTransitionedMap(receiver, stub_kind);
1606 map_added |= AddOneReceiverMapIfMissing(&target_receiver_maps, new_map); 1612 map_added |= AddOneReceiverMapIfMissing(&target_receiver_maps, new_map);
1607 } 1613 }
1608 if (!map_added) { 1614 if (!map_added) {
1609 // If the miss wasn't due to an unseen map, a polymorphic stub 1615 // If the miss wasn't due to an unseen map, a polymorphic stub
1610 // won't help, use the generic stub. 1616 // won't help, use the generic stub.
1611 TRACE_GENERIC_IC("KeyedIC", "same map added twice"); 1617 TRACE_GENERIC_IC("KeyedIC", "same map added twice");
1612 return generic_stub; 1618 return generic_stub;
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
2643 #undef ADDR 2649 #undef ADDR
2644 }; 2650 };
2645 2651
2646 2652
2647 Address IC::AddressFromUtilityId(IC::UtilityId id) { 2653 Address IC::AddressFromUtilityId(IC::UtilityId id) {
2648 return IC_utilities[id]; 2654 return IC_utilities[id];
2649 } 2655 }
2650 2656
2651 2657
2652 } } // namespace v8::internal 2658 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/elements-kind.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698