| 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 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 ASSERT(!receiver.is(scratch)); | 904 ASSERT(!receiver.is(scratch)); |
| 905 | 905 |
| 906 typedef FunctionCallbackArguments FCA; | 906 typedef FunctionCallbackArguments FCA; |
| 907 const int stack_space = kFastApiCallArguments + argc + 1; | 907 const int stack_space = kFastApiCallArguments + argc + 1; |
| 908 // Assign stack space for the call arguments. | 908 // Assign stack space for the call arguments. |
| 909 __ sub(sp, sp, Operand(stack_space * kPointerSize)); | 909 __ sub(sp, sp, Operand(stack_space * kPointerSize)); |
| 910 // Write holder to stack frame. | 910 // Write holder to stack frame. |
| 911 __ str(receiver, MemOperand(sp, FCA::kHolderIndex * kPointerSize)); | 911 __ str(receiver, MemOperand(sp, FCA::kHolderIndex * kPointerSize)); |
| 912 // Write receiver to stack frame. | 912 // Write receiver to stack frame. |
| 913 int index = stack_space - 1; | 913 int index = stack_space - 1; |
| 914 __ str(receiver, MemOperand(sp, index * kPointerSize)); | 914 __ str(receiver, MemOperand(sp, index-- * kPointerSize)); |
| 915 // Write the arguments to stack frame. | 915 // Write the arguments to stack frame. |
| 916 for (int i = 0; i < argc; i++) { | 916 for (int i = 0; i < argc; i++) { |
| 917 ASSERT(!receiver.is(values[i])); | 917 ASSERT(!receiver.is(values[i])); |
| 918 ASSERT(!scratch.is(values[i])); | 918 ASSERT(!scratch.is(values[i])); |
| 919 __ str(receiver, MemOperand(sp, index-- * kPointerSize)); | 919 __ str(values[i], MemOperand(sp, index-- * kPointerSize)); |
| 920 } | 920 } |
| 921 | 921 |
| 922 GenerateFastApiDirectCall(masm, optimization, argc, true); | 922 GenerateFastApiDirectCall(masm, optimization, argc, true); |
| 923 } | 923 } |
| 924 | 924 |
| 925 | 925 |
| 926 class CallInterceptorCompiler BASE_EMBEDDED { | 926 class CallInterceptorCompiler BASE_EMBEDDED { |
| 927 public: | 927 public: |
| 928 CallInterceptorCompiler(CallStubCompiler* stub_compiler, | 928 CallInterceptorCompiler(CallStubCompiler* stub_compiler, |
| 929 const ParameterCount& arguments, | 929 const ParameterCount& arguments, |
| 930 Register name, | 930 Register name) |
| 931 ExtraICState extra_ic_state) | |
| 932 : stub_compiler_(stub_compiler), | 931 : stub_compiler_(stub_compiler), |
| 933 arguments_(arguments), | 932 arguments_(arguments), |
| 934 name_(name), | 933 name_(name) {} |
| 935 extra_ic_state_(extra_ic_state) {} | |
| 936 | 934 |
| 937 void Compile(MacroAssembler* masm, | 935 void Compile(MacroAssembler* masm, |
| 938 Handle<JSObject> object, | 936 Handle<JSObject> object, |
| 939 Handle<JSObject> holder, | 937 Handle<JSObject> holder, |
| 940 Handle<Name> name, | 938 Handle<Name> name, |
| 941 LookupResult* lookup, | 939 LookupResult* lookup, |
| 942 Register receiver, | 940 Register receiver, |
| 943 Register scratch1, | 941 Register scratch1, |
| 944 Register scratch2, | 942 Register scratch2, |
| 945 Register scratch3, | 943 Register scratch3, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 LoadWithInterceptor(masm, receiver, holder, interceptor_holder, scratch2, | 1012 LoadWithInterceptor(masm, receiver, holder, interceptor_holder, scratch2, |
| 1015 ®ular_invoke); | 1013 ®ular_invoke); |
| 1016 | 1014 |
| 1017 // Interceptor returned nothing for this property. Try to use cached | 1015 // Interceptor returned nothing for this property. Try to use cached |
| 1018 // constant function. | 1016 // constant function. |
| 1019 | 1017 |
| 1020 // Check that the maps from interceptor's holder to constant function's | 1018 // Check that the maps from interceptor's holder to constant function's |
| 1021 // holder haven't changed and thus we can use cached constant function. | 1019 // holder haven't changed and thus we can use cached constant function. |
| 1022 if (*interceptor_holder != lookup->holder()) { | 1020 if (*interceptor_holder != lookup->holder()) { |
| 1023 stub_compiler_->CheckPrototypes( | 1021 stub_compiler_->CheckPrototypes( |
| 1024 IC::CurrentTypeOf(interceptor_holder, masm->isolate()), receiver, | 1022 IC::CurrentTypeOf(interceptor_holder, masm->isolate()), holder, |
| 1025 handle(lookup->holder()), scratch1, scratch2, scratch3, | 1023 handle(lookup->holder()), scratch1, scratch2, scratch3, |
| 1026 name, depth2, miss); | 1024 name, depth2, miss); |
| 1027 } else { | 1025 } else { |
| 1028 // CheckPrototypes has a side effect of fetching a 'holder' | 1026 // CheckPrototypes has a side effect of fetching a 'holder' |
| 1029 // for API (object which is instanceof for the signature). It's | 1027 // for API (object which is instanceof for the signature). It's |
| 1030 // safe to omit it here, as if present, it should be fetched | 1028 // safe to omit it here, as if present, it should be fetched |
| 1031 // by the previous CheckPrototypes. | 1029 // by the previous CheckPrototypes. |
| 1032 ASSERT(depth2 == kInvalidProtoDepth); | 1030 ASSERT(depth2 == kInvalidProtoDepth); |
| 1033 } | 1031 } |
| 1034 | 1032 |
| 1035 // Invoke function. | 1033 // Invoke function. |
| 1036 if (can_do_fast_api_call) { | 1034 if (can_do_fast_api_call) { |
| 1037 GenerateFastApiDirectCall( | 1035 GenerateFastApiDirectCall( |
| 1038 masm, optimization, arguments_.immediate(), false); | 1036 masm, optimization, arguments_.immediate(), false); |
| 1039 } else { | 1037 } else { |
| 1040 Handle<JSFunction> function = optimization.constant_function(); | 1038 Handle<JSFunction> function = optimization.constant_function(); |
| 1041 stub_compiler_->GenerateJumpFunctionIgnoreReceiver(function); | 1039 __ Move(r0, receiver); |
| 1040 stub_compiler_->GenerateJumpFunction(object, function); |
| 1042 } | 1041 } |
| 1043 | 1042 |
| 1044 // Deferred code for fast API call case---clean preallocated space. | 1043 // Deferred code for fast API call case---clean preallocated space. |
| 1045 if (can_do_fast_api_call) { | 1044 if (can_do_fast_api_call) { |
| 1046 __ bind(&miss_cleanup); | 1045 __ bind(&miss_cleanup); |
| 1047 FreeSpaceForFastApiCall(masm); | 1046 FreeSpaceForFastApiCall(masm); |
| 1048 __ b(miss_label); | 1047 __ b(miss_label); |
| 1049 } | 1048 } |
| 1050 | 1049 |
| 1051 // Invoke a regular function. | 1050 // Invoke a regular function. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 } | 1083 } |
| 1085 | 1084 |
| 1086 void LoadWithInterceptor(MacroAssembler* masm, | 1085 void LoadWithInterceptor(MacroAssembler* masm, |
| 1087 Register receiver, | 1086 Register receiver, |
| 1088 Register holder, | 1087 Register holder, |
| 1089 Handle<JSObject> holder_obj, | 1088 Handle<JSObject> holder_obj, |
| 1090 Register scratch, | 1089 Register scratch, |
| 1091 Label* interceptor_succeeded) { | 1090 Label* interceptor_succeeded) { |
| 1092 { | 1091 { |
| 1093 FrameScope scope(masm, StackFrame::INTERNAL); | 1092 FrameScope scope(masm, StackFrame::INTERNAL); |
| 1093 __ Push(receiver); |
| 1094 __ Push(holder, name_); | 1094 __ Push(holder, name_); |
| 1095 CompileCallLoadPropertyWithInterceptor( | 1095 CompileCallLoadPropertyWithInterceptor( |
| 1096 masm, receiver, holder, name_, holder_obj, | 1096 masm, receiver, holder, name_, holder_obj, |
| 1097 IC::kLoadPropertyWithInterceptorOnly); | 1097 IC::kLoadPropertyWithInterceptorOnly); |
| 1098 __ pop(name_); // Restore the name. | 1098 __ pop(name_); |
| 1099 __ pop(receiver); // Restore the holder. | 1099 __ pop(holder); |
| 1100 __ pop(receiver); |
| 1100 } | 1101 } |
| 1101 // If interceptor returns no-result sentinel, call the constant function. | 1102 // If interceptor returns no-result sentinel, call the constant function. |
| 1102 __ LoadRoot(scratch, Heap::kNoInterceptorResultSentinelRootIndex); | 1103 __ LoadRoot(scratch, Heap::kNoInterceptorResultSentinelRootIndex); |
| 1103 __ cmp(r0, scratch); | 1104 __ cmp(r0, scratch); |
| 1104 __ b(ne, interceptor_succeeded); | 1105 __ b(ne, interceptor_succeeded); |
| 1105 } | 1106 } |
| 1106 | 1107 |
| 1107 CallStubCompiler* stub_compiler_; | 1108 CallStubCompiler* stub_compiler_; |
| 1108 const ParameterCount& arguments_; | 1109 const ParameterCount& arguments_; |
| 1109 Register name_; | 1110 Register name_; |
| 1110 ExtraICState extra_ic_state_; | |
| 1111 }; | 1111 }; |
| 1112 | 1112 |
| 1113 | 1113 |
| 1114 void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) { | 1114 void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) { |
| 1115 __ Jump(code, RelocInfo::CODE_TARGET); | 1115 __ Jump(code, RelocInfo::CODE_TARGET); |
| 1116 } | 1116 } |
| 1117 | 1117 |
| 1118 | 1118 |
| 1119 #undef __ | 1119 #undef __ |
| 1120 #define __ ACCESS_MASM(masm()) | 1120 #define __ ACCESS_MASM(masm()) |
| (...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2459 GenerateNameCheck(name, &miss); | 2459 GenerateNameCheck(name, &miss); |
| 2460 | 2460 |
| 2461 // Get the number of arguments. | 2461 // Get the number of arguments. |
| 2462 const int argc = arguments().immediate(); | 2462 const int argc = arguments().immediate(); |
| 2463 LookupResult lookup(isolate()); | 2463 LookupResult lookup(isolate()); |
| 2464 LookupPostInterceptor(holder, name, &lookup); | 2464 LookupPostInterceptor(holder, name, &lookup); |
| 2465 | 2465 |
| 2466 // Get the receiver from the stack. | 2466 // Get the receiver from the stack. |
| 2467 __ ldr(r1, MemOperand(sp, argc * kPointerSize)); | 2467 __ ldr(r1, MemOperand(sp, argc * kPointerSize)); |
| 2468 | 2468 |
| 2469 CallInterceptorCompiler compiler(this, arguments(), r2, extra_state()); | 2469 CallInterceptorCompiler compiler(this, arguments(), r2); |
| 2470 compiler.Compile(masm(), object, holder, name, &lookup, r1, r3, r4, r0, | 2470 compiler.Compile(masm(), object, holder, name, &lookup, r1, r3, r4, r0, |
| 2471 &miss); | 2471 &miss); |
| 2472 | 2472 |
| 2473 // Move returned value, the function to call, to r1. | 2473 // Move returned value, the function to call, to r1. |
| 2474 __ mov(r1, r0); | 2474 __ mov(r1, r0); |
| 2475 // Restore receiver. | 2475 // Restore receiver. |
| 2476 __ ldr(r0, MemOperand(sp, argc * kPointerSize)); | 2476 __ ldr(r0, MemOperand(sp, argc * kPointerSize)); |
| 2477 | 2477 |
| 2478 GenerateJumpFunction(object, r1, &miss); | 2478 GenerateJumpFunction(object, r1, &miss); |
| 2479 | 2479 |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2891 // ----------------------------------- | 2891 // ----------------------------------- |
| 2892 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); | 2892 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); |
| 2893 } | 2893 } |
| 2894 | 2894 |
| 2895 | 2895 |
| 2896 #undef __ | 2896 #undef __ |
| 2897 | 2897 |
| 2898 } } // namespace v8::internal | 2898 } } // namespace v8::internal |
| 2899 | 2899 |
| 2900 #endif // V8_TARGET_ARCH_ARM | 2900 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |