| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
| 9 #include "src/ast.h" | 9 #include "src/ast.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 Frontend(receiver(), name); | 886 Frontend(receiver(), name); |
| 887 Handle<Map> receiver_map = IC::TypeToMap(*type(), isolate()); | 887 Handle<Map> receiver_map = IC::TypeToMap(*type(), isolate()); |
| 888 GenerateFastApiCall( | 888 GenerateFastApiCall( |
| 889 masm(), call_optimization, receiver_map, | 889 masm(), call_optimization, receiver_map, |
| 890 receiver(), scratch1(), false, 0, NULL); | 890 receiver(), scratch1(), false, 0, NULL); |
| 891 return GetCode(kind(), Code::FAST, name); | 891 return GetCode(kind(), Code::FAST, name); |
| 892 } | 892 } |
| 893 | 893 |
| 894 | 894 |
| 895 Handle<Code> NamedLoadHandlerCompiler::CompileLoadInterceptor( | 895 Handle<Code> NamedLoadHandlerCompiler::CompileLoadInterceptor( |
| 896 Handle<Name> name) { | 896 LookupIterator* it, Handle<Name> name) { |
| 897 // Perform a lookup after the interceptor. | 897 // So far the most popular follow ups for interceptor loads are FIELD and |
| 898 LookupResult lookup(isolate()); | 898 // ExecutableAccessorInfo, so inline only them. Other cases may be added |
| 899 holder()->LookupOwnRealNamedProperty(name, &lookup); | 899 // later. |
| 900 if (!lookup.IsFound()) { | 900 bool inline_followup = it->state() == LookupIterator::PROPERTY; |
| 901 PrototypeIterator iter(holder()->GetIsolate(), holder()); | 901 if (inline_followup) { |
| 902 if (!iter.IsAtEnd()) { | 902 switch (it->property_kind()) { |
| 903 PrototypeIterator::GetCurrent(iter)->Lookup(name, &lookup); | 903 case LookupIterator::DATA: |
| 904 inline_followup = it->property_details().type() == FIELD; |
| 905 break; |
| 906 case LookupIterator::ACCESSOR: { |
| 907 Handle<Object> accessors = it->GetAccessors(); |
| 908 inline_followup = accessors->IsExecutableAccessorInfo(); |
| 909 if (!inline_followup) break; |
| 910 Handle<ExecutableAccessorInfo> info = |
| 911 Handle<ExecutableAccessorInfo>::cast(accessors); |
| 912 inline_followup = info->getter() != NULL && |
| 913 ExecutableAccessorInfo::IsCompatibleReceiverType( |
| 914 isolate(), info, type()); |
| 915 } |
| 904 } | 916 } |
| 905 } | 917 } |
| 906 | 918 |
| 907 Register reg = Frontend(receiver(), name); | 919 Register reg = Frontend(receiver(), name); |
| 908 // TODO(368): Compile in the whole chain: all the interceptors in | 920 if (inline_followup) { |
| 909 // prototypes and ultimate answer. | 921 // TODO(368): Compile in the whole chain: all the interceptors in |
| 910 GenerateLoadInterceptor(reg, &lookup, name); | 922 // prototypes and ultimate answer. |
| 923 GenerateLoadInterceptorWithFollowup(it, reg); |
| 924 } else { |
| 925 GenerateLoadInterceptor(reg); |
| 926 } |
| 911 return GetCode(kind(), Code::FAST, name); | 927 return GetCode(kind(), Code::FAST, name); |
| 912 } | 928 } |
| 913 | 929 |
| 914 | 930 |
| 915 void NamedLoadHandlerCompiler::GenerateLoadPostInterceptor( | 931 void NamedLoadHandlerCompiler::GenerateLoadPostInterceptor( |
| 916 Register interceptor_reg, Handle<Name> name, LookupResult* lookup) { | 932 LookupIterator* it, Register interceptor_reg) { |
| 917 Handle<JSObject> real_named_property_holder(lookup->holder()); | 933 Handle<JSObject> real_named_property_holder(it->GetHolder<JSObject>()); |
| 918 | 934 |
| 919 set_type_for_object(holder()); | 935 set_type_for_object(holder()); |
| 920 set_holder(real_named_property_holder); | 936 set_holder(real_named_property_holder); |
| 921 Register reg = Frontend(interceptor_reg, name); | 937 Register reg = Frontend(interceptor_reg, it->name()); |
| 922 | 938 |
| 923 if (lookup->IsField()) { | 939 switch (it->property_kind()) { |
| 924 __ Move(receiver(), reg); | 940 case LookupIterator::DATA: { |
| 925 LoadFieldStub stub(isolate(), lookup->GetFieldIndex()); | 941 DCHECK_EQ(FIELD, it->property_details().type()); |
| 926 GenerateTailCall(masm(), stub.GetCode()); | 942 __ Move(receiver(), reg); |
| 927 } else { | 943 LoadFieldStub stub(isolate(), it->GetFieldIndex()); |
| 928 DCHECK(lookup->type() == CALLBACKS); | 944 GenerateTailCall(masm(), stub.GetCode()); |
| 929 Handle<ExecutableAccessorInfo> callback( | 945 break; |
| 930 ExecutableAccessorInfo::cast(lookup->GetCallbackObject())); | 946 } |
| 931 DCHECK(callback->getter() != NULL); | 947 case LookupIterator::ACCESSOR: |
| 932 GenerateLoadCallback(reg, callback); | 948 Handle<ExecutableAccessorInfo> info = |
| 949 Handle<ExecutableAccessorInfo>::cast(it->GetAccessors()); |
| 950 DCHECK_NE(NULL, info->getter()); |
| 951 GenerateLoadCallback(reg, info); |
| 933 } | 952 } |
| 934 } | 953 } |
| 935 | 954 |
| 936 | 955 |
| 937 Handle<Code> PropertyICCompiler::CompileMonomorphic(Handle<HeapType> type, | 956 Handle<Code> PropertyICCompiler::CompileMonomorphic(Handle<HeapType> type, |
| 938 Handle<Code> handler, | 957 Handle<Code> handler, |
| 939 Handle<Name> name, | 958 Handle<Name> name, |
| 940 IcCheckType check) { | 959 IcCheckType check) { |
| 941 TypeHandleList types(1); | 960 TypeHandleList types(1); |
| 942 CodeHandleList handlers(1); | 961 CodeHandleList handlers(1); |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1284 Handle<FunctionTemplateInfo>( | 1303 Handle<FunctionTemplateInfo>( |
| 1285 FunctionTemplateInfo::cast(signature->receiver())); | 1304 FunctionTemplateInfo::cast(signature->receiver())); |
| 1286 } | 1305 } |
| 1287 } | 1306 } |
| 1288 | 1307 |
| 1289 is_simple_api_call_ = true; | 1308 is_simple_api_call_ = true; |
| 1290 } | 1309 } |
| 1291 | 1310 |
| 1292 | 1311 |
| 1293 } } // namespace v8::internal | 1312 } } // namespace v8::internal |
| OLD | NEW |