 Chromium Code Reviews
 Chromium Code Reviews Issue 19485008:
  Replace CONSTANT_FUNCTION by CONSTANT  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
    
  
    Issue 19485008:
  Replace CONSTANT_FUNCTION by CONSTANT  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge| 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 if (constant->IsConsString()) return Handle<Code>::null(); | |
| 
Yang
2013/07/24 11:59:45
why do you check for cons string here?
 
Toon Verwaest
2013/07/24 12:25:17
Because we cannot embed cons strings into code. I'
 | |
| 1317 return isolate()->stub_cache()->ComputeLoadConstant( | 1319 return isolate()->stub_cache()->ComputeLoadConstant( | 
| 1318 name, receiver, holder, constant); | 1320 name, receiver, holder, constant); | 
| 1319 } | 1321 } | 
| 1320 case NORMAL: | 1322 case NORMAL: | 
| 1321 if (holder->IsGlobalObject()) { | 1323 if (holder->IsGlobalObject()) { | 
| 1322 Handle<GlobalObject> global = Handle<GlobalObject>::cast(holder); | 1324 Handle<GlobalObject> global = Handle<GlobalObject>::cast(holder); | 
| 1323 Handle<PropertyCell> cell( | 1325 Handle<PropertyCell> cell( | 
| 1324 global->GetPropertyCell(lookup), isolate()); | 1326 global->GetPropertyCell(lookup), isolate()); | 
| 1325 return isolate()->stub_cache()->ComputeLoadGlobal( | 1327 return isolate()->stub_cache()->ComputeLoadGlobal( | 
| 1326 name, receiver, global, cell, lookup->IsDontDelete()); | 1328 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. | 1517 // Bail out if we didn't find a result. | 
| 1516 if (!lookup->IsProperty()) return Handle<Code>::null(); | 1518 if (!lookup->IsProperty()) return Handle<Code>::null(); | 
| 1517 | 1519 | 
| 1518 // Compute a monomorphic stub. | 1520 // Compute a monomorphic stub. | 
| 1519 Handle<JSObject> holder(lookup->holder(), isolate()); | 1521 Handle<JSObject> holder(lookup->holder(), isolate()); | 
| 1520 switch (lookup->type()) { | 1522 switch (lookup->type()) { | 
| 1521 case FIELD: | 1523 case FIELD: | 
| 1522 return isolate()->stub_cache()->ComputeKeyedLoadField( | 1524 return isolate()->stub_cache()->ComputeKeyedLoadField( | 
| 1523 name, receiver, holder, | 1525 name, receiver, holder, | 
| 1524 lookup->GetFieldIndex(), lookup->representation()); | 1526 lookup->GetFieldIndex(), lookup->representation()); | 
| 1525 case CONSTANT_FUNCTION: { | 1527 case CONSTANT: { | 
| 1526 Handle<JSFunction> constant(lookup->GetConstantFunction(), isolate()); | 1528 Handle<Object> constant(lookup->GetConstant(), isolate()); | 
| 1529 if (constant->IsConsString()) return Handle<Code>::null(); | |
| 
Yang
2013/07/24 11:59:45
ditto.
 | |
| 1527 return isolate()->stub_cache()->ComputeKeyedLoadConstant( | 1530 return isolate()->stub_cache()->ComputeKeyedLoadConstant( | 
| 1528 name, receiver, holder, constant); | 1531 name, receiver, holder, constant); | 
| 1529 } | 1532 } | 
| 1530 case CALLBACKS: { | 1533 case CALLBACKS: { | 
| 1531 Handle<Object> callback_object(lookup->GetCallbackObject(), isolate()); | 1534 Handle<Object> callback_object(lookup->GetCallbackObject(), isolate()); | 
| 1532 // TODO(dcarney): Handle DeclaredAccessorInfo correctly. | 1535 // TODO(dcarney): Handle DeclaredAccessorInfo correctly. | 
| 1533 if (!callback_object->IsExecutableAccessorInfo()) break; | 1536 if (!callback_object->IsExecutableAccessorInfo()) break; | 
| 1534 Handle<ExecutableAccessorInfo> callback = | 1537 Handle<ExecutableAccessorInfo> callback = | 
| 1535 Handle<ExecutableAccessorInfo>::cast(callback_object); | 1538 Handle<ExecutableAccessorInfo>::cast(callback_object); | 
| 1536 if (v8::ToCData<Address>(callback->getter()) == 0) break; | 1539 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. | 1794 // TODO(dcarney): Handle correctly. | 
| 1792 if (callback->IsDeclaredAccessorInfo()) break; | 1795 if (callback->IsDeclaredAccessorInfo()) break; | 
| 1793 ASSERT(callback->IsForeign()); | 1796 ASSERT(callback->IsForeign()); | 
| 1794 // No IC support for old-style native accessors. | 1797 // No IC support for old-style native accessors. | 
| 1795 break; | 1798 break; | 
| 1796 } | 1799 } | 
| 1797 case INTERCEPTOR: | 1800 case INTERCEPTOR: | 
| 1798 ASSERT(!receiver->GetNamedInterceptor()->setter()->IsUndefined()); | 1801 ASSERT(!receiver->GetNamedInterceptor()->setter()->IsUndefined()); | 
| 1799 return isolate()->stub_cache()->ComputeStoreInterceptor( | 1802 return isolate()->stub_cache()->ComputeStoreInterceptor( | 
| 1800 name, receiver, strict_mode); | 1803 name, receiver, strict_mode); | 
| 1801 case CONSTANT_FUNCTION: | 1804 case CONSTANT: | 
| 1802 break; | 1805 break; | 
| 1803 case TRANSITION: { | 1806 case TRANSITION: { | 
| 1804 // Explicitly pass in the receiver map since LookupForWrite may have | 1807 // Explicitly pass in the receiver map since LookupForWrite may have | 
| 1805 // stored something else than the receiver in the holder. | 1808 // stored something else than the receiver in the holder. | 
| 1806 Handle<Map> transition( | 1809 Handle<Map> transition( | 
| 1807 lookup->GetTransitionTarget(receiver->map()), isolate()); | 1810 lookup->GetTransitionTarget(receiver->map()), isolate()); | 
| 1808 int descriptor = transition->LastAdded(); | 1811 int descriptor = transition->LastAdded(); | 
| 1809 | 1812 | 
| 1810 DescriptorArray* target_descriptors = transition->instance_descriptors(); | 1813 DescriptorArray* target_descriptors = transition->instance_descriptors(); | 
| 1811 PropertyDetails details = target_descriptors->GetDetails(descriptor); | 1814 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(); | 2180 DescriptorArray* target_descriptors = transition->instance_descriptors(); | 
| 2178 PropertyDetails details = target_descriptors->GetDetails(descriptor); | 2181 PropertyDetails details = target_descriptors->GetDetails(descriptor); | 
| 2179 | 2182 | 
| 2180 if (details.type() != CALLBACKS && details.attributes() == NONE) { | 2183 if (details.type() != CALLBACKS && details.attributes() == NONE) { | 
| 2181 return isolate()->stub_cache()->ComputeKeyedStoreTransition( | 2184 return isolate()->stub_cache()->ComputeKeyedStoreTransition( | 
| 2182 name, receiver, lookup, transition, strict_mode); | 2185 name, receiver, lookup, transition, strict_mode); | 
| 2183 } | 2186 } | 
| 2184 // fall through. | 2187 // fall through. | 
| 2185 } | 2188 } | 
| 2186 case NORMAL: | 2189 case NORMAL: | 
| 2187 case CONSTANT_FUNCTION: | 2190 case CONSTANT: | 
| 2188 case CALLBACKS: | 2191 case CALLBACKS: | 
| 2189 case INTERCEPTOR: | 2192 case INTERCEPTOR: | 
| 2190 // Always rewrite to the generic case so that we do not | 2193 // Always rewrite to the generic case so that we do not | 
| 2191 // repeatedly try to rewrite. | 2194 // repeatedly try to rewrite. | 
| 2192 return (strict_mode == kStrictMode) | 2195 return (strict_mode == kStrictMode) | 
| 2193 ? generic_stub_strict() | 2196 ? generic_stub_strict() | 
| 2194 : generic_stub(); | 2197 : generic_stub(); | 
| 2195 case HANDLER: | 2198 case HANDLER: | 
| 2196 case NONEXISTENT: | 2199 case NONEXISTENT: | 
| 2197 UNREACHABLE(); | 2200 UNREACHABLE(); | 
| (...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3115 #undef ADDR | 3118 #undef ADDR | 
| 3116 }; | 3119 }; | 
| 3117 | 3120 | 
| 3118 | 3121 | 
| 3119 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 3122 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 
| 3120 return IC_utilities[id]; | 3123 return IC_utilities[id]; | 
| 3121 } | 3124 } | 
| 3122 | 3125 | 
| 3123 | 3126 | 
| 3124 } } // namespace v8::internal | 3127 } } // namespace v8::internal | 
| OLD | NEW |