OLD | NEW |
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 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1541 if (lookup->IsFound() && | 1541 if (lookup->IsFound() && |
1542 lookup->IsCacheable() && | 1542 lookup->IsCacheable() && |
1543 lookup->type() == CONSTANT_FUNCTION) { | 1543 lookup->type() == CONSTANT_FUNCTION) { |
1544 // We only optimize constant function calls. | 1544 // We only optimize constant function calls. |
1545 Initialize(Handle<JSFunction>(lookup->GetConstantFunction())); | 1545 Initialize(Handle<JSFunction>(lookup->GetConstantFunction())); |
1546 } else { | 1546 } else { |
1547 Initialize(Handle<JSFunction>::null()); | 1547 Initialize(Handle<JSFunction>::null()); |
1548 } | 1548 } |
1549 } | 1549 } |
1550 | 1550 |
| 1551 |
1551 CallOptimization::CallOptimization(Handle<JSFunction> function) { | 1552 CallOptimization::CallOptimization(Handle<JSFunction> function) { |
1552 Initialize(function); | 1553 Initialize(function); |
1553 } | 1554 } |
1554 | 1555 |
1555 | 1556 |
1556 int CallOptimization::GetPrototypeDepthOfExpectedType( | |
1557 Handle<JSObject> object, | |
1558 Handle<JSObject> holder) const { | |
1559 ASSERT(is_simple_api_call()); | |
1560 if (expected_receiver_type_.is_null()) return 0; | |
1561 int depth = 0; | |
1562 while (!object.is_identical_to(holder)) { | |
1563 if (object->IsInstanceOf(*expected_receiver_type_)) return depth; | |
1564 object = Handle<JSObject>(JSObject::cast(object->GetPrototype())); | |
1565 ++depth; | |
1566 } | |
1567 if (holder->IsInstanceOf(*expected_receiver_type_)) return depth; | |
1568 return kInvalidProtoDepth; | |
1569 } | |
1570 | |
1571 | |
1572 void CallOptimization::Initialize(Handle<JSFunction> function) { | 1557 void CallOptimization::Initialize(Handle<JSFunction> function) { |
1573 constant_function_ = Handle<JSFunction>::null(); | 1558 constant_function_ = Handle<JSFunction>::null(); |
1574 is_simple_api_call_ = false; | 1559 is_simple_api_call_ = false; |
1575 expected_receiver_type_ = Handle<FunctionTemplateInfo>::null(); | 1560 expected_receiver_type_ = Handle<FunctionTemplateInfo>::null(); |
1576 api_call_info_ = Handle<CallHandlerInfo>::null(); | 1561 api_call_info_ = Handle<CallHandlerInfo>::null(); |
1577 | 1562 |
1578 if (function.is_null() || !function->is_compiled()) return; | 1563 if (function.is_null() || !function->is_compiled()) return; |
1579 | 1564 |
1580 constant_function_ = function; | 1565 constant_function_ = function; |
1581 AnalyzePossibleApiFunction(function); | 1566 AnalyzePossibleApiFunction(function); |
(...skipping 20 matching lines...) Expand all Loading... |
1602 Handle<FunctionTemplateInfo>( | 1587 Handle<FunctionTemplateInfo>( |
1603 FunctionTemplateInfo::cast(signature->receiver())); | 1588 FunctionTemplateInfo::cast(signature->receiver())); |
1604 } | 1589 } |
1605 } | 1590 } |
1606 | 1591 |
1607 is_simple_api_call_ = true; | 1592 is_simple_api_call_ = true; |
1608 } | 1593 } |
1609 | 1594 |
1610 | 1595 |
1611 } } // namespace v8::internal | 1596 } } // namespace v8::internal |
OLD | NEW |