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 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback); | 521 Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback); |
522 | 522 |
523 __ CallApiFunctionAndReturn(function_address, | 523 __ CallApiFunctionAndReturn(function_address, |
524 thunk_address, | 524 thunk_address, |
525 callback_arg, | 525 callback_arg, |
526 api_call_argc + 1, | 526 api_call_argc + 1, |
527 kFastApiCallArguments + 1); | 527 kFastApiCallArguments + 1); |
528 } | 528 } |
529 | 529 |
530 | 530 |
| 531 // Generate call to api function. |
| 532 static void GenerateFastApiCall(MacroAssembler* masm, |
| 533 const CallOptimization& optimization, |
| 534 Register receiver, |
| 535 Register scratch, |
| 536 int argc, |
| 537 Register* values) { |
| 538 ASSERT(!receiver.is(scratch)); |
| 539 |
| 540 const int stack_space = kFastApiCallArguments + argc + 1; |
| 541 // Copy return value. |
| 542 __ movq(scratch, Operand(rsp, 0)); |
| 543 // Assign stack space for the call arguments. |
| 544 __ subq(rsp, Immediate(stack_space * kPointerSize)); |
| 545 // Move the return address on top of the stack. |
| 546 __ movq(Operand(rsp, 0), scratch); |
| 547 // Write holder to stack frame. |
| 548 __ movq(Operand(rsp, 1 * kPointerSize), receiver); |
| 549 // Write receiver to stack frame. |
| 550 int index = stack_space; |
| 551 __ movq(Operand(rsp, index-- * kPointerSize), receiver); |
| 552 // Write the arguments to stack frame. |
| 553 for (int i = 0; i < argc; i++) { |
| 554 ASSERT(!receiver.is(values[i])); |
| 555 ASSERT(!scratch.is(values[i])); |
| 556 __ movq(Operand(rsp, index-- * kPointerSize), values[i]); |
| 557 } |
| 558 |
| 559 GenerateFastApiCall(masm, optimization, argc); |
| 560 } |
| 561 |
| 562 |
531 class CallInterceptorCompiler BASE_EMBEDDED { | 563 class CallInterceptorCompiler BASE_EMBEDDED { |
532 public: | 564 public: |
533 CallInterceptorCompiler(StubCompiler* stub_compiler, | 565 CallInterceptorCompiler(StubCompiler* stub_compiler, |
534 const ParameterCount& arguments, | 566 const ParameterCount& arguments, |
535 Register name, | 567 Register name, |
536 Code::ExtraICState extra_ic_state) | 568 Code::ExtraICState extra_ic_state) |
537 : stub_compiler_(stub_compiler), | 569 : stub_compiler_(stub_compiler), |
538 arguments_(arguments), | 570 arguments_(arguments), |
539 name_(name), | 571 name_(name), |
540 extra_ic_state_(extra_ic_state) {} | 572 extra_ic_state_(extra_ic_state) {} |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1270 KeyedLoadFieldStub stub(field.is_inobject(holder), | 1302 KeyedLoadFieldStub stub(field.is_inobject(holder), |
1271 field.translate(holder), | 1303 field.translate(holder), |
1272 representation); | 1304 representation); |
1273 GenerateTailCall(masm(), stub.GetCode(isolate())); | 1305 GenerateTailCall(masm(), stub.GetCode(isolate())); |
1274 } | 1306 } |
1275 } | 1307 } |
1276 | 1308 |
1277 | 1309 |
1278 void BaseLoadStubCompiler::GenerateLoadCallback( | 1310 void BaseLoadStubCompiler::GenerateLoadCallback( |
1279 const CallOptimization& call_optimization) { | 1311 const CallOptimization& call_optimization) { |
1280 ASSERT(call_optimization.is_simple_api_call()); | 1312 GenerateFastApiCall( |
1281 | 1313 masm(), call_optimization, receiver(), scratch3(), 0, NULL); |
1282 // Copy return value. | |
1283 __ movq(scratch3(), Operand(rsp, 0)); | |
1284 // Assign stack space for the call arguments. | |
1285 __ subq(rsp, Immediate((kFastApiCallArguments + 1) * kPointerSize)); | |
1286 // Move the return address on top of the stack. | |
1287 __ movq(Operand(rsp, 0), scratch3()); | |
1288 | |
1289 int argc = 0; | |
1290 int api_call_argc = argc + kFastApiCallArguments; | |
1291 StackArgumentsAccessor args(rsp, api_call_argc); | |
1292 // Write holder to stack frame. | |
1293 __ movq(args.GetArgumentOperand(api_call_argc), receiver()); | |
1294 // Write receiver to stack frame. | |
1295 __ movq(args.GetArgumentOperand(api_call_argc - 6), receiver()); | |
1296 | |
1297 GenerateFastApiCall(masm(), call_optimization, argc); | |
1298 } | 1314 } |
1299 | 1315 |
1300 | 1316 |
1301 void BaseLoadStubCompiler::GenerateLoadCallback( | 1317 void BaseLoadStubCompiler::GenerateLoadCallback( |
1302 Register reg, | 1318 Register reg, |
1303 Handle<ExecutableAccessorInfo> callback) { | 1319 Handle<ExecutableAccessorInfo> callback) { |
1304 // Insert additional parameters into the stack frame above return address. | 1320 // Insert additional parameters into the stack frame above return address. |
1305 ASSERT(!scratch4().is(reg)); | 1321 ASSERT(!scratch4().is(reg)); |
1306 __ PopReturnAddressTo(scratch4()); | 1322 __ PopReturnAddressTo(scratch4()); |
1307 | 1323 |
(...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2788 // Do tail-call to the runtime system. | 2804 // Do tail-call to the runtime system. |
2789 ExternalReference store_callback_property = | 2805 ExternalReference store_callback_property = |
2790 ExternalReference(IC_Utility(IC::kStoreCallbackProperty), isolate()); | 2806 ExternalReference(IC_Utility(IC::kStoreCallbackProperty), isolate()); |
2791 __ TailCallExternalReference(store_callback_property, 4, 1); | 2807 __ TailCallExternalReference(store_callback_property, 4, 1); |
2792 | 2808 |
2793 // Return the generated code. | 2809 // Return the generated code. |
2794 return GetCode(kind(), Code::CALLBACKS, name); | 2810 return GetCode(kind(), Code::CALLBACKS, name); |
2795 } | 2811 } |
2796 | 2812 |
2797 | 2813 |
| 2814 Handle<Code> StoreStubCompiler::CompileStoreCallback( |
| 2815 Handle<JSObject> object, |
| 2816 Handle<JSObject> holder, |
| 2817 Handle<Name> name, |
| 2818 const CallOptimization& call_optimization) { |
| 2819 Label success; |
| 2820 HandlerFrontend(object, receiver(), holder, name, &success); |
| 2821 __ bind(&success); |
| 2822 |
| 2823 Register values[] = { value() }; |
| 2824 GenerateFastApiCall( |
| 2825 masm(), call_optimization, receiver(), scratch3(), 1, values); |
| 2826 |
| 2827 // Return the generated code. |
| 2828 return GetCode(kind(), Code::CALLBACKS, name); |
| 2829 } |
| 2830 |
| 2831 |
2798 #undef __ | 2832 #undef __ |
2799 #define __ ACCESS_MASM(masm) | 2833 #define __ ACCESS_MASM(masm) |
2800 | 2834 |
2801 | 2835 |
2802 void StoreStubCompiler::GenerateStoreViaSetter( | 2836 void StoreStubCompiler::GenerateStoreViaSetter( |
2803 MacroAssembler* masm, | 2837 MacroAssembler* masm, |
2804 Handle<JSFunction> setter) { | 2838 Handle<JSFunction> setter) { |
2805 // ----------- S t a t e ------------- | 2839 // ----------- S t a t e ------------- |
2806 // -- rax : value | 2840 // -- rax : value |
2807 // -- rcx : name | 2841 // -- rcx : name |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3164 // ----------------------------------- | 3198 // ----------------------------------- |
3165 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); | 3199 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); |
3166 } | 3200 } |
3167 | 3201 |
3168 | 3202 |
3169 #undef __ | 3203 #undef __ |
3170 | 3204 |
3171 } } // namespace v8::internal | 3205 } } // namespace v8::internal |
3172 | 3206 |
3173 #endif // V8_TARGET_ARCH_X64 | 3207 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |