| 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 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 if (result->IsJSFunction()) return *result; | 627 if (result->IsJSFunction()) return *result; |
| 628 | 628 |
| 629 return TypeError("property_not_function", object, name); | 629 return TypeError("property_not_function", object, name); |
| 630 } | 630 } |
| 631 | 631 |
| 632 | 632 |
| 633 bool CallICBase::TryUpdateExtraICState(LookupResult* lookup, | 633 bool CallICBase::TryUpdateExtraICState(LookupResult* lookup, |
| 634 Handle<Object> object, | 634 Handle<Object> object, |
| 635 Code::ExtraICState* extra_ic_state) { | 635 Code::ExtraICState* extra_ic_state) { |
| 636 ASSERT(kind_ == Code::CALL_IC); | 636 ASSERT(kind_ == Code::CALL_IC); |
| 637 if (lookup->type() != CONSTANT_FUNCTION) return false; | 637 if (!lookup->IsConstantFunction()) return false; |
| 638 JSFunction* function = lookup->GetConstantFunction(); | 638 JSFunction* function = lookup->GetConstantFunction(); |
| 639 if (!function->shared()->HasBuiltinFunctionId()) return false; | 639 if (!function->shared()->HasBuiltinFunctionId()) return false; |
| 640 | 640 |
| 641 // Fetch the arguments passed to the called function. | 641 // Fetch the arguments passed to the called function. |
| 642 const int argc = target()->arguments_count(); | 642 const int argc = target()->arguments_count(); |
| 643 Address entry = isolate()->c_entry_fp(isolate()->thread_local_top()); | 643 Address entry = isolate()->c_entry_fp(isolate()->thread_local_top()); |
| 644 Address fp = Memory::Address_at(entry + ExitFrameConstants::kCallerFPOffset); | 644 Address fp = Memory::Address_at(entry + ExitFrameConstants::kCallerFPOffset); |
| 645 Arguments args(argc + 1, | 645 Arguments args(argc + 1, |
| 646 &Memory::Object_at(fp + | 646 &Memory::Object_at(fp + |
| 647 StandardFrameConstants::kCallerSPOffset + | 647 StandardFrameConstants::kCallerSPOffset + |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 Handle<Object> object, | 680 Handle<Object> object, |
| 681 Handle<String> name) { | 681 Handle<String> name) { |
| 682 int argc = target()->arguments_count(); | 682 int argc = target()->arguments_count(); |
| 683 Handle<JSObject> holder(lookup->holder(), isolate()); | 683 Handle<JSObject> holder(lookup->holder(), isolate()); |
| 684 switch (lookup->type()) { | 684 switch (lookup->type()) { |
| 685 case FIELD: { | 685 case FIELD: { |
| 686 PropertyIndex index = lookup->GetFieldIndex(); | 686 PropertyIndex index = lookup->GetFieldIndex(); |
| 687 return isolate()->stub_cache()->ComputeCallField( | 687 return isolate()->stub_cache()->ComputeCallField( |
| 688 argc, kind_, extra_state, name, object, holder, index); | 688 argc, kind_, extra_state, name, object, holder, index); |
| 689 } | 689 } |
| 690 case CONSTANT_FUNCTION: { | 690 case CONSTANT: { |
| 691 if (!lookup->IsConstantFunction()) return Handle<Code>::null(); |
| 691 // Get the constant function and compute the code stub for this | 692 // Get the constant function and compute the code stub for this |
| 692 // call; used for rewriting to monomorphic state and making sure | 693 // call; used for rewriting to monomorphic state and making sure |
| 693 // that the code stub is in the stub cache. | 694 // that the code stub is in the stub cache. |
| 694 Handle<JSFunction> function(lookup->GetConstantFunction(), isolate()); | 695 Handle<JSFunction> function(lookup->GetConstantFunction(), isolate()); |
| 695 return isolate()->stub_cache()->ComputeCallConstant( | 696 return isolate()->stub_cache()->ComputeCallConstant( |
| 696 argc, kind_, extra_state, name, object, holder, function); | 697 argc, kind_, extra_state, name, object, holder, function); |
| 697 } | 698 } |
| 698 case NORMAL: { | 699 case NORMAL: { |
| 699 // If we return a null handle, the IC will not be patched. | 700 // If we return a null handle, the IC will not be patched. |
| 700 if (!object->IsJSObject()) return Handle<Code>::null(); | 701 if (!object->IsJSObject()) return Handle<Code>::null(); |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1305 return isolate()->stub_cache()->ComputeLoadNonexistent(name, receiver); | 1306 return isolate()->stub_cache()->ComputeLoadNonexistent(name, receiver); |
| 1306 } | 1307 } |
| 1307 | 1308 |
| 1308 // Compute monomorphic stub. | 1309 // Compute monomorphic stub. |
| 1309 Handle<JSObject> holder(lookup->holder()); | 1310 Handle<JSObject> holder(lookup->holder()); |
| 1310 switch (lookup->type()) { | 1311 switch (lookup->type()) { |
| 1311 case FIELD: | 1312 case FIELD: |
| 1312 return isolate()->stub_cache()->ComputeLoadField( | 1313 return isolate()->stub_cache()->ComputeLoadField( |
| 1313 name, receiver, holder, | 1314 name, receiver, holder, |
| 1314 lookup->GetFieldIndex(), lookup->representation()); | 1315 lookup->GetFieldIndex(), lookup->representation()); |
| 1315 case CONSTANT_FUNCTION: { | 1316 case CONSTANT: { |
| 1316 Handle<JSFunction> constant(lookup->GetConstantFunction()); | 1317 Handle<Object> constant(lookup->GetConstant(), isolate()); |
| 1318 // TODO(2803): Don't compute a stub for cons strings because they cannot |
| 1319 // be embedded into code. |
| 1320 if (constant->IsConsString()) return Handle<Code>::null(); |
| 1317 return isolate()->stub_cache()->ComputeLoadConstant( | 1321 return isolate()->stub_cache()->ComputeLoadConstant( |
| 1318 name, receiver, holder, constant); | 1322 name, receiver, holder, constant); |
| 1319 } | 1323 } |
| 1320 case NORMAL: | 1324 case NORMAL: |
| 1321 if (holder->IsGlobalObject()) { | 1325 if (holder->IsGlobalObject()) { |
| 1322 Handle<GlobalObject> global = Handle<GlobalObject>::cast(holder); | 1326 Handle<GlobalObject> global = Handle<GlobalObject>::cast(holder); |
| 1323 Handle<PropertyCell> cell( | 1327 Handle<PropertyCell> cell( |
| 1324 global->GetPropertyCell(lookup), isolate()); | 1328 global->GetPropertyCell(lookup), isolate()); |
| 1325 return isolate()->stub_cache()->ComputeLoadGlobal( | 1329 return isolate()->stub_cache()->ComputeLoadGlobal( |
| 1326 name, receiver, global, cell, lookup->IsDontDelete()); | 1330 name, receiver, global, cell, lookup->IsDontDelete()); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1515 // Bail out if we didn't find a result. | 1519 // Bail out if we didn't find a result. |
| 1516 if (!lookup->IsProperty()) return Handle<Code>::null(); | 1520 if (!lookup->IsProperty()) return Handle<Code>::null(); |
| 1517 | 1521 |
| 1518 // Compute a monomorphic stub. | 1522 // Compute a monomorphic stub. |
| 1519 Handle<JSObject> holder(lookup->holder(), isolate()); | 1523 Handle<JSObject> holder(lookup->holder(), isolate()); |
| 1520 switch (lookup->type()) { | 1524 switch (lookup->type()) { |
| 1521 case FIELD: | 1525 case FIELD: |
| 1522 return isolate()->stub_cache()->ComputeKeyedLoadField( | 1526 return isolate()->stub_cache()->ComputeKeyedLoadField( |
| 1523 name, receiver, holder, | 1527 name, receiver, holder, |
| 1524 lookup->GetFieldIndex(), lookup->representation()); | 1528 lookup->GetFieldIndex(), lookup->representation()); |
| 1525 case CONSTANT_FUNCTION: { | 1529 case CONSTANT: { |
| 1526 Handle<JSFunction> constant(lookup->GetConstantFunction(), isolate()); | 1530 Handle<Object> constant(lookup->GetConstant(), isolate()); |
| 1531 // TODO(2803): Don't compute a stub for cons strings because they cannot |
| 1532 // be embedded into code. |
| 1533 if (constant->IsConsString()) return Handle<Code>::null(); |
| 1527 return isolate()->stub_cache()->ComputeKeyedLoadConstant( | 1534 return isolate()->stub_cache()->ComputeKeyedLoadConstant( |
| 1528 name, receiver, holder, constant); | 1535 name, receiver, holder, constant); |
| 1529 } | 1536 } |
| 1530 case CALLBACKS: { | 1537 case CALLBACKS: { |
| 1531 Handle<Object> callback_object(lookup->GetCallbackObject(), isolate()); | 1538 Handle<Object> callback_object(lookup->GetCallbackObject(), isolate()); |
| 1532 // TODO(dcarney): Handle DeclaredAccessorInfo correctly. | 1539 // TODO(dcarney): Handle DeclaredAccessorInfo correctly. |
| 1533 if (!callback_object->IsExecutableAccessorInfo()) break; | 1540 if (!callback_object->IsExecutableAccessorInfo()) break; |
| 1534 Handle<ExecutableAccessorInfo> callback = | 1541 Handle<ExecutableAccessorInfo> callback = |
| 1535 Handle<ExecutableAccessorInfo>::cast(callback_object); | 1542 Handle<ExecutableAccessorInfo>::cast(callback_object); |
| 1536 if (v8::ToCData<Address>(callback->getter()) == 0) break; | 1543 if (v8::ToCData<Address>(callback->getter()) == 0) break; |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1791 // TODO(dcarney): Handle correctly. | 1798 // TODO(dcarney): Handle correctly. |
| 1792 if (callback->IsDeclaredAccessorInfo()) break; | 1799 if (callback->IsDeclaredAccessorInfo()) break; |
| 1793 ASSERT(callback->IsForeign()); | 1800 ASSERT(callback->IsForeign()); |
| 1794 // No IC support for old-style native accessors. | 1801 // No IC support for old-style native accessors. |
| 1795 break; | 1802 break; |
| 1796 } | 1803 } |
| 1797 case INTERCEPTOR: | 1804 case INTERCEPTOR: |
| 1798 ASSERT(!receiver->GetNamedInterceptor()->setter()->IsUndefined()); | 1805 ASSERT(!receiver->GetNamedInterceptor()->setter()->IsUndefined()); |
| 1799 return isolate()->stub_cache()->ComputeStoreInterceptor( | 1806 return isolate()->stub_cache()->ComputeStoreInterceptor( |
| 1800 name, receiver, strict_mode); | 1807 name, receiver, strict_mode); |
| 1801 case CONSTANT_FUNCTION: | 1808 case CONSTANT: |
| 1802 break; | 1809 break; |
| 1803 case TRANSITION: { | 1810 case TRANSITION: { |
| 1804 // Explicitly pass in the receiver map since LookupForWrite may have | 1811 // Explicitly pass in the receiver map since LookupForWrite may have |
| 1805 // stored something else than the receiver in the holder. | 1812 // stored something else than the receiver in the holder. |
| 1806 Handle<Map> transition( | 1813 Handle<Map> transition( |
| 1807 lookup->GetTransitionTarget(receiver->map()), isolate()); | 1814 lookup->GetTransitionTarget(receiver->map()), isolate()); |
| 1808 int descriptor = transition->LastAdded(); | 1815 int descriptor = transition->LastAdded(); |
| 1809 | 1816 |
| 1810 DescriptorArray* target_descriptors = transition->instance_descriptors(); | 1817 DescriptorArray* target_descriptors = transition->instance_descriptors(); |
| 1811 PropertyDetails details = target_descriptors->GetDetails(descriptor); | 1818 PropertyDetails details = target_descriptors->GetDetails(descriptor); |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2177 DescriptorArray* target_descriptors = transition->instance_descriptors(); | 2184 DescriptorArray* target_descriptors = transition->instance_descriptors(); |
| 2178 PropertyDetails details = target_descriptors->GetDetails(descriptor); | 2185 PropertyDetails details = target_descriptors->GetDetails(descriptor); |
| 2179 | 2186 |
| 2180 if (details.type() != CALLBACKS && details.attributes() == NONE) { | 2187 if (details.type() != CALLBACKS && details.attributes() == NONE) { |
| 2181 return isolate()->stub_cache()->ComputeKeyedStoreTransition( | 2188 return isolate()->stub_cache()->ComputeKeyedStoreTransition( |
| 2182 name, receiver, lookup, transition, strict_mode); | 2189 name, receiver, lookup, transition, strict_mode); |
| 2183 } | 2190 } |
| 2184 // fall through. | 2191 // fall through. |
| 2185 } | 2192 } |
| 2186 case NORMAL: | 2193 case NORMAL: |
| 2187 case CONSTANT_FUNCTION: | 2194 case CONSTANT: |
| 2188 case CALLBACKS: | 2195 case CALLBACKS: |
| 2189 case INTERCEPTOR: | 2196 case INTERCEPTOR: |
| 2190 // Always rewrite to the generic case so that we do not | 2197 // Always rewrite to the generic case so that we do not |
| 2191 // repeatedly try to rewrite. | 2198 // repeatedly try to rewrite. |
| 2192 return (strict_mode == kStrictMode) | 2199 return (strict_mode == kStrictMode) |
| 2193 ? generic_stub_strict() | 2200 ? generic_stub_strict() |
| 2194 : generic_stub(); | 2201 : generic_stub(); |
| 2195 case HANDLER: | 2202 case HANDLER: |
| 2196 case NONEXISTENT: | 2203 case NONEXISTENT: |
| 2197 UNREACHABLE(); | 2204 UNREACHABLE(); |
| (...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3115 #undef ADDR | 3122 #undef ADDR |
| 3116 }; | 3123 }; |
| 3117 | 3124 |
| 3118 | 3125 |
| 3119 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 3126 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 3120 return IC_utilities[id]; | 3127 return IC_utilities[id]; |
| 3121 } | 3128 } |
| 3122 | 3129 |
| 3123 | 3130 |
| 3124 } } // namespace v8::internal | 3131 } } // namespace v8::internal |
| OLD | NEW |