| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 ASSERT(!AreAliased(receiver, scratch)); | 884 ASSERT(!AreAliased(receiver, scratch)); |
| 885 | 885 |
| 886 typedef FunctionCallbackArguments FCA; | 886 typedef FunctionCallbackArguments FCA; |
| 887 const int stack_space = kFastApiCallArguments + argc + 1; | 887 const int stack_space = kFastApiCallArguments + argc + 1; |
| 888 // Assign stack space for the call arguments. | 888 // Assign stack space for the call arguments. |
| 889 __ Claim(stack_space); | 889 __ Claim(stack_space); |
| 890 // Write holder to stack frame. | 890 // Write holder to stack frame. |
| 891 __ Poke(receiver, FCA::kHolderIndex * kPointerSize); | 891 __ Poke(receiver, FCA::kHolderIndex * kPointerSize); |
| 892 // Write receiver to stack frame. | 892 // Write receiver to stack frame. |
| 893 int index = stack_space - 1; | 893 int index = stack_space - 1; |
| 894 __ Poke(receiver, index * kPointerSize); | 894 __ Poke(receiver, index-- * kPointerSize); |
| 895 // Write the arguments to stack frame. | 895 // Write the arguments to stack frame. |
| 896 for (int i = 0; i < argc; i++) { | 896 for (int i = 0; i < argc; i++) { |
| 897 // TODO(jbramley): This is broken, but it is broken on ARM too. | |
| 898 ASSERT(!AreAliased(receiver, scratch, values[i])); | 897 ASSERT(!AreAliased(receiver, scratch, values[i])); |
| 899 __ Poke(receiver, index-- * kPointerSize); | 898 __ Poke(values[i], index-- * kPointerSize); |
| 900 } | 899 } |
| 901 | 900 |
| 902 GenerateFastApiDirectCall(masm, optimization, argc, true); | 901 GenerateFastApiDirectCall(masm, optimization, argc, true); |
| 903 } | 902 } |
| 904 | 903 |
| 905 | 904 |
| 906 class CallInterceptorCompiler BASE_EMBEDDED { | 905 class CallInterceptorCompiler BASE_EMBEDDED { |
| 907 public: | 906 public: |
| 908 CallInterceptorCompiler(CallStubCompiler* stub_compiler, | 907 CallInterceptorCompiler(CallStubCompiler* stub_compiler, |
| 909 const ParameterCount& arguments, | 908 const ParameterCount& arguments, |
| 910 Register name, | 909 Register name) |
| 911 ExtraICState extra_ic_state) | |
| 912 : stub_compiler_(stub_compiler), | 910 : stub_compiler_(stub_compiler), |
| 913 arguments_(arguments), | 911 arguments_(arguments), |
| 914 name_(name), | 912 name_(name) { } |
| 915 extra_ic_state_(extra_ic_state) {} | |
| 916 | 913 |
| 917 void Compile(MacroAssembler* masm, | 914 void Compile(MacroAssembler* masm, |
| 918 Handle<JSObject> object, | 915 Handle<JSObject> object, |
| 919 Handle<JSObject> holder, | 916 Handle<JSObject> holder, |
| 920 Handle<Name> name, | 917 Handle<Name> name, |
| 921 LookupResult* lookup, | 918 LookupResult* lookup, |
| 922 Register receiver, | 919 Register receiver, |
| 923 Register scratch1, | 920 Register scratch1, |
| 924 Register scratch2, | 921 Register scratch2, |
| 925 Register scratch3, | 922 Register scratch3, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 LoadWithInterceptor(masm, receiver, holder, interceptor_holder, scratch2, | 994 LoadWithInterceptor(masm, receiver, holder, interceptor_holder, scratch2, |
| 998 ®ular_invoke); | 995 ®ular_invoke); |
| 999 | 996 |
| 1000 // Interceptor returned nothing for this property. Try to use cached | 997 // Interceptor returned nothing for this property. Try to use cached |
| 1001 // constant function. | 998 // constant function. |
| 1002 | 999 |
| 1003 // Check that the maps from interceptor's holder to constant function's | 1000 // Check that the maps from interceptor's holder to constant function's |
| 1004 // holder haven't changed and thus we can use cached constant function. | 1001 // holder haven't changed and thus we can use cached constant function. |
| 1005 if (*interceptor_holder != lookup->holder()) { | 1002 if (*interceptor_holder != lookup->holder()) { |
| 1006 stub_compiler_->CheckPrototypes( | 1003 stub_compiler_->CheckPrototypes( |
| 1007 IC::CurrentTypeOf(interceptor_holder, masm->isolate()), receiver, | 1004 IC::CurrentTypeOf(interceptor_holder, masm->isolate()), holder, |
| 1008 handle(lookup->holder()), scratch1, scratch2, scratch3, | 1005 handle(lookup->holder()), scratch1, scratch2, scratch3, |
| 1009 name, depth2, miss); | 1006 name, depth2, miss); |
| 1010 } else { | 1007 } else { |
| 1011 // CheckPrototypes has a side effect of fetching a 'holder' | 1008 // CheckPrototypes has a side effect of fetching a 'holder' |
| 1012 // for API (object which is instanceof for the signature). It's | 1009 // for API (object which is instanceof for the signature). It's |
| 1013 // safe to omit it here, as if present, it should be fetched | 1010 // safe to omit it here, as if present, it should be fetched |
| 1014 // by the previous CheckPrototypes. | 1011 // by the previous CheckPrototypes. |
| 1015 ASSERT(depth2 == kInvalidProtoDepth); | 1012 ASSERT(depth2 == kInvalidProtoDepth); |
| 1016 } | 1013 } |
| 1017 | 1014 |
| 1018 // Invoke function. | 1015 // Invoke function. |
| 1019 if (can_do_fast_api_call) { | 1016 if (can_do_fast_api_call) { |
| 1020 GenerateFastApiDirectCall( | 1017 GenerateFastApiDirectCall( |
| 1021 masm, optimization, arguments_.immediate(), false); | 1018 masm, optimization, arguments_.immediate(), false); |
| 1022 } else { | 1019 } else { |
| 1023 Handle<JSFunction> function = optimization.constant_function(); | 1020 Handle<JSFunction> function = optimization.constant_function(); |
| 1024 stub_compiler_->GenerateJumpFunctionIgnoreReceiver(function); | 1021 __ Mov(x0, receiver); |
| 1022 stub_compiler_->GenerateJumpFunction(object, function); |
| 1025 } | 1023 } |
| 1026 | 1024 |
| 1027 // Deferred code for fast API call case, clean preallocated space. | 1025 // Deferred code for fast API call case, clean preallocated space. |
| 1028 if (can_do_fast_api_call) { | 1026 if (can_do_fast_api_call) { |
| 1029 __ Bind(&miss_cleanup); | 1027 __ Bind(&miss_cleanup); |
| 1030 FreeSpaceForFastApiCall(masm); | 1028 FreeSpaceForFastApiCall(masm); |
| 1031 __ B(miss_label); | 1029 __ B(miss_label); |
| 1032 } | 1030 } |
| 1033 | 1031 |
| 1034 // Invoke a regular function. | 1032 // Invoke a regular function. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1066 | 1064 |
| 1067 | 1065 |
| 1068 void LoadWithInterceptor(MacroAssembler* masm, | 1066 void LoadWithInterceptor(MacroAssembler* masm, |
| 1069 Register receiver, | 1067 Register receiver, |
| 1070 Register holder, | 1068 Register holder, |
| 1071 Handle<JSObject> holder_obj, | 1069 Handle<JSObject> holder_obj, |
| 1072 Register scratch, | 1070 Register scratch, |
| 1073 Label* interceptor_succeeded) { | 1071 Label* interceptor_succeeded) { |
| 1074 { | 1072 { |
| 1075 FrameScope scope(masm, StackFrame::INTERNAL); | 1073 FrameScope scope(masm, StackFrame::INTERNAL); |
| 1076 __ Push(holder, name_); | 1074 __ Push(receiver, holder, name_); |
| 1077 CompileCallLoadPropertyWithInterceptor( | 1075 CompileCallLoadPropertyWithInterceptor( |
| 1078 masm, receiver, holder, name_, holder_obj, | 1076 masm, receiver, holder, name_, holder_obj, |
| 1079 IC::kLoadPropertyWithInterceptorOnly); | 1077 IC::kLoadPropertyWithInterceptorOnly); |
| 1080 __ Pop(name_, receiver); | 1078 // TODO(jbramley): We need two pops because holder and receiver can be |
| 1079 // the same. In that case, we only need to preserve it once, but this is |
| 1080 // fixed on ARM later anyway so I've left it alone for now. |
| 1081 __ Pop(name_, holder); |
| 1082 __ Pop(receiver); |
| 1081 } | 1083 } |
| 1082 | 1084 |
| 1083 // If interceptor returns no-result sentinel, call the constant function. | 1085 // If interceptor returns no-result sentinel, call the constant function. |
| 1084 __ JumpIfNotRoot(x0, | 1086 __ JumpIfNotRoot(x0, |
| 1085 Heap::kNoInterceptorResultSentinelRootIndex, | 1087 Heap::kNoInterceptorResultSentinelRootIndex, |
| 1086 interceptor_succeeded); | 1088 interceptor_succeeded); |
| 1087 } | 1089 } |
| 1088 | 1090 |
| 1089 CallStubCompiler* stub_compiler_; | 1091 CallStubCompiler* stub_compiler_; |
| 1090 const ParameterCount& arguments_; | 1092 const ParameterCount& arguments_; |
| 1091 Register name_; | 1093 Register name_; |
| 1092 ExtraICState extra_ic_state_; | |
| 1093 }; | 1094 }; |
| 1094 | 1095 |
| 1095 | 1096 |
| 1096 void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) { | 1097 void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) { |
| 1097 __ Jump(code, RelocInfo::CODE_TARGET); | 1098 __ Jump(code, RelocInfo::CODE_TARGET); |
| 1098 } | 1099 } |
| 1099 | 1100 |
| 1100 | 1101 |
| 1101 #undef __ | 1102 #undef __ |
| 1102 #define __ ACCESS_MASM(masm()) | 1103 #define __ ACCESS_MASM(masm()) |
| (...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2501 GenerateNameCheck(name, &miss); | 2502 GenerateNameCheck(name, &miss); |
| 2502 | 2503 |
| 2503 const int argc = arguments().immediate(); | 2504 const int argc = arguments().immediate(); |
| 2504 LookupResult lookup(isolate()); | 2505 LookupResult lookup(isolate()); |
| 2505 LookupPostInterceptor(holder, name, &lookup); | 2506 LookupPostInterceptor(holder, name, &lookup); |
| 2506 | 2507 |
| 2507 // Get the receiver from the stack. | 2508 // Get the receiver from the stack. |
| 2508 Register receiver = x5; | 2509 Register receiver = x5; |
| 2509 __ Peek(receiver, argc * kPointerSize); | 2510 __ Peek(receiver, argc * kPointerSize); |
| 2510 | 2511 |
| 2511 CallInterceptorCompiler compiler(this, arguments(), name_reg, extra_state()); | 2512 CallInterceptorCompiler compiler(this, arguments(), name_reg); |
| 2512 compiler.Compile( | 2513 compiler.Compile( |
| 2513 masm(), object, holder, name, &lookup, receiver, x3, x4, x0, &miss); | 2514 masm(), object, holder, name, &lookup, receiver, x3, x4, x0, &miss); |
| 2514 | 2515 |
| 2515 // Move returned value, the function to call, to x1 (this is required by | 2516 // Move returned value, the function to call, to x1 (this is required by |
| 2516 // GenerateCallFunction). | 2517 // GenerateCallFunction). |
| 2517 Register function = x1; | 2518 Register function = x1; |
| 2518 __ Mov(function, x0); | 2519 __ Mov(function, x0); |
| 2519 | 2520 |
| 2520 // Restore receiver. | 2521 // Restore receiver. |
| 2521 __ Peek(receiver, argc * kPointerSize); | 2522 __ Peek(receiver, argc * kPointerSize); |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2928 | 2929 |
| 2929 // Miss case, call the runtime. | 2930 // Miss case, call the runtime. |
| 2930 __ Bind(&miss); | 2931 __ Bind(&miss); |
| 2931 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); | 2932 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); |
| 2932 } | 2933 } |
| 2933 | 2934 |
| 2934 | 2935 |
| 2935 } } // namespace v8::internal | 2936 } } // namespace v8::internal |
| 2936 | 2937 |
| 2937 #endif // V8_TARGET_ARCH_A64 | 2938 #endif // V8_TARGET_ARCH_A64 |
| OLD | NEW |