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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 Register name, | 372 Register name, |
373 Handle<JSObject> holder_obj) { | 373 Handle<JSObject> holder_obj) { |
374 __ push(name); | 374 __ push(name); |
375 Handle<InterceptorInfo> interceptor(holder_obj->GetNamedInterceptor()); | 375 Handle<InterceptorInfo> interceptor(holder_obj->GetNamedInterceptor()); |
376 ASSERT(!masm->isolate()->heap()->InNewSpace(*interceptor)); | 376 ASSERT(!masm->isolate()->heap()->InNewSpace(*interceptor)); |
377 __ Move(kScratchRegister, interceptor); | 377 __ Move(kScratchRegister, interceptor); |
378 __ push(kScratchRegister); | 378 __ push(kScratchRegister); |
379 __ push(receiver); | 379 __ push(receiver); |
380 __ push(holder); | 380 __ push(holder); |
381 __ push(FieldOperand(kScratchRegister, InterceptorInfo::kDataOffset)); | 381 __ push(FieldOperand(kScratchRegister, InterceptorInfo::kDataOffset)); |
| 382 __ push(Immediate(reinterpret_cast<intptr_t>(masm->isolate()))); |
382 } | 383 } |
383 | 384 |
384 | 385 |
385 static void CompileCallLoadPropertyWithInterceptor( | 386 static void CompileCallLoadPropertyWithInterceptor( |
386 MacroAssembler* masm, | 387 MacroAssembler* masm, |
387 Register receiver, | 388 Register receiver, |
388 Register holder, | 389 Register holder, |
389 Register name, | 390 Register name, |
390 Handle<JSObject> holder_obj) { | 391 Handle<JSObject> holder_obj) { |
391 PushInterceptorArguments(masm, receiver, holder, name, holder_obj); | 392 PushInterceptorArguments(masm, receiver, holder, name, holder_obj); |
392 | 393 |
393 ExternalReference ref = | 394 ExternalReference ref = |
394 ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptorOnly), | 395 ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptorOnly), |
395 masm->isolate()); | 396 masm->isolate()); |
396 __ Set(rax, 5); | 397 __ Set(rax, 6); |
397 __ LoadAddress(rbx, ref); | 398 __ LoadAddress(rbx, ref); |
398 | 399 |
399 CEntryStub stub(1); | 400 CEntryStub stub(1); |
400 __ CallStub(&stub); | 401 __ CallStub(&stub); |
401 } | 402 } |
402 | 403 |
403 | 404 |
404 // Number of pointers to be reserved on stack for fast API call. | 405 // Number of pointers to be reserved on stack for fast API call. |
405 static const int kFastApiCallArguments = 3; | 406 static const int kFastApiCallArguments = 4; |
406 | 407 |
407 | 408 |
408 // Reserves space for the extra arguments to API function in the | 409 // Reserves space for the extra arguments to API function in the |
409 // caller's frame. | 410 // caller's frame. |
410 // | 411 // |
411 // These arguments are set by CheckPrototypes and GenerateFastApiCall. | 412 // These arguments are set by CheckPrototypes and GenerateFastApiCall. |
412 static void ReserveSpaceForFastApiCall(MacroAssembler* masm, Register scratch) { | 413 static void ReserveSpaceForFastApiCall(MacroAssembler* masm, Register scratch) { |
413 // ----------- S t a t e ------------- | 414 // ----------- S t a t e ------------- |
414 // -- rsp[0] : return address | 415 // -- rsp[0] : return address |
415 // -- rsp[8] : last argument in the internal frame of the caller | 416 // -- rsp[8] : last argument in the internal frame of the caller |
(...skipping 29 matching lines...) Expand all Loading... |
445 const CallOptimization& optimization, | 446 const CallOptimization& optimization, |
446 int argc) { | 447 int argc) { |
447 // ----------- S t a t e ------------- | 448 // ----------- S t a t e ------------- |
448 // -- rsp[0] : return address | 449 // -- rsp[0] : return address |
449 // -- rsp[8] : object passing the type check | 450 // -- rsp[8] : object passing the type check |
450 // (last fast api call extra argument, | 451 // (last fast api call extra argument, |
451 // set by CheckPrototypes) | 452 // set by CheckPrototypes) |
452 // -- rsp[16] : api function | 453 // -- rsp[16] : api function |
453 // (first fast api call extra argument) | 454 // (first fast api call extra argument) |
454 // -- rsp[24] : api call data | 455 // -- rsp[24] : api call data |
455 // -- rsp[32] : last argument | 456 // -- rsp[32] : isolate |
| 457 // -- rsp[40] : last argument |
456 // -- ... | 458 // -- ... |
457 // -- rsp[(argc + 3) * 8] : first argument | 459 // -- rsp[(argc + 4) * 8] : first argument |
458 // -- rsp[(argc + 4) * 8] : receiver | 460 // -- rsp[(argc + 5) * 8] : receiver |
459 // ----------------------------------- | 461 // ----------------------------------- |
460 // Get the function and setup the context. | 462 // Get the function and setup the context. |
461 Handle<JSFunction> function = optimization.constant_function(); | 463 Handle<JSFunction> function = optimization.constant_function(); |
462 __ LoadHeapObject(rdi, function); | 464 __ LoadHeapObject(rdi, function); |
463 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); | 465 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); |
464 | 466 |
465 // Pass the additional arguments. | 467 // Pass the additional arguments. |
466 __ movq(Operand(rsp, 2 * kPointerSize), rdi); | 468 __ movq(Operand(rsp, 2 * kPointerSize), rdi); |
467 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); | 469 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); |
468 Handle<Object> call_data(api_call_info->data()); | 470 Handle<Object> call_data(api_call_info->data()); |
469 if (masm->isolate()->heap()->InNewSpace(*call_data)) { | 471 if (masm->isolate()->heap()->InNewSpace(*call_data)) { |
470 __ Move(rcx, api_call_info); | 472 __ Move(rcx, api_call_info); |
471 __ movq(rbx, FieldOperand(rcx, CallHandlerInfo::kDataOffset)); | 473 __ movq(rbx, FieldOperand(rcx, CallHandlerInfo::kDataOffset)); |
472 __ movq(Operand(rsp, 3 * kPointerSize), rbx); | 474 __ movq(Operand(rsp, 3 * kPointerSize), rbx); |
473 } else { | 475 } else { |
474 __ Move(Operand(rsp, 3 * kPointerSize), call_data); | 476 __ Move(Operand(rsp, 3 * kPointerSize), call_data); |
475 } | 477 } |
| 478 __ movq(Operand(rsp, 4 * kPointerSize), |
| 479 Immediate(reinterpret_cast<intptr_t>(masm->isolate()))); |
476 | 480 |
477 // Prepare arguments. | 481 // Prepare arguments. |
478 __ lea(rbx, Operand(rsp, 3 * kPointerSize)); | 482 __ lea(rbx, Operand(rsp, 4 * kPointerSize)); |
479 | 483 |
480 #ifdef _WIN64 | 484 #ifdef _WIN64 |
481 // Win64 uses first register--rcx--for returned value. | 485 // Win64 uses first register--rcx--for returned value. |
482 Register arguments_arg = rdx; | 486 Register arguments_arg = rdx; |
483 #else | 487 #else |
484 Register arguments_arg = rdi; | 488 Register arguments_arg = rdi; |
485 #endif | 489 #endif |
486 | 490 |
487 // Allocate the v8::Arguments structure in the arguments' space since | 491 // Allocate the v8::Arguments structure in the arguments' space since |
488 // it's not controlled by GC. | 492 // it's not controlled by GC. |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 | 660 |
657 FrameScope scope(masm, StackFrame::INTERNAL); | 661 FrameScope scope(masm, StackFrame::INTERNAL); |
658 // Save the name_ register across the call. | 662 // Save the name_ register across the call. |
659 __ push(name_); | 663 __ push(name_); |
660 | 664 |
661 PushInterceptorArguments(masm, receiver, holder, name_, interceptor_holder); | 665 PushInterceptorArguments(masm, receiver, holder, name_, interceptor_holder); |
662 | 666 |
663 __ CallExternalReference( | 667 __ CallExternalReference( |
664 ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptorForCall), | 668 ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptorForCall), |
665 masm->isolate()), | 669 masm->isolate()), |
666 5); | 670 6); |
667 | 671 |
668 // Restore the name_ register. | 672 // Restore the name_ register. |
669 __ pop(name_); | 673 __ pop(name_); |
670 | 674 |
671 // Leave the internal frame. | 675 // Leave the internal frame. |
672 } | 676 } |
673 | 677 |
674 void LoadWithInterceptor(MacroAssembler* masm, | 678 void LoadWithInterceptor(MacroAssembler* masm, |
675 Register receiver, | 679 Register receiver, |
676 Register holder, | 680 Register holder, |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 __ pop(scratch2); // Get return address to place it below. | 1000 __ pop(scratch2); // Get return address to place it below. |
997 | 1001 |
998 __ push(receiver); // receiver | 1002 __ push(receiver); // receiver |
999 __ push(reg); // holder | 1003 __ push(reg); // holder |
1000 if (heap()->InNewSpace(callback->data())) { | 1004 if (heap()->InNewSpace(callback->data())) { |
1001 __ Move(scratch1, callback); | 1005 __ Move(scratch1, callback); |
1002 __ push(FieldOperand(scratch1, AccessorInfo::kDataOffset)); // data | 1006 __ push(FieldOperand(scratch1, AccessorInfo::kDataOffset)); // data |
1003 } else { | 1007 } else { |
1004 __ Push(Handle<Object>(callback->data())); | 1008 __ Push(Handle<Object>(callback->data())); |
1005 } | 1009 } |
| 1010 __ push(Immediate(reinterpret_cast<intptr_t>(isolate()))); // isolate |
1006 __ push(name_reg); // name | 1011 __ push(name_reg); // name |
1007 // Save a pointer to where we pushed the arguments pointer. | 1012 // Save a pointer to where we pushed the arguments pointer. |
1008 // This will be passed as the const AccessorInfo& to the C++ callback. | 1013 // This will be passed as the const AccessorInfo& to the C++ callback. |
1009 | 1014 |
1010 #ifdef _WIN64 | 1015 #ifdef _WIN64 |
1011 // Win64 uses first register--rcx--for returned value. | 1016 // Win64 uses first register--rcx--for returned value. |
1012 Register accessor_info_arg = r8; | 1017 Register accessor_info_arg = r8; |
1013 Register name_arg = rdx; | 1018 Register name_arg = rdx; |
1014 #else | 1019 #else |
1015 Register accessor_info_arg = rsi; | 1020 Register accessor_info_arg = rsi; |
1016 Register name_arg = rdi; | 1021 Register name_arg = rdi; |
1017 #endif | 1022 #endif |
1018 | 1023 |
1019 ASSERT(!name_arg.is(scratch2)); | 1024 ASSERT(!name_arg.is(scratch2)); |
1020 __ movq(name_arg, rsp); | 1025 __ movq(name_arg, rsp); |
1021 __ push(scratch2); // Restore return address. | 1026 __ push(scratch2); // Restore return address. |
1022 | 1027 |
1023 // 3 elements array for v8::Arguments::values_ and handler for name. | 1028 // 4 elements array for v8::Arguments::values_ and handler for name. |
1024 const int kStackSpace = 4; | 1029 const int kStackSpace = 5; |
1025 | 1030 |
1026 // Allocate v8::AccessorInfo in non-GCed stack space. | 1031 // Allocate v8::AccessorInfo in non-GCed stack space. |
1027 const int kArgStackSpace = 1; | 1032 const int kArgStackSpace = 1; |
1028 | 1033 |
1029 __ PrepareCallApiFunction(kArgStackSpace); | 1034 __ PrepareCallApiFunction(kArgStackSpace); |
1030 __ lea(rax, Operand(name_arg, 3 * kPointerSize)); | 1035 __ lea(rax, Operand(name_arg, 4 * kPointerSize)); |
1031 | 1036 |
1032 // v8::AccessorInfo::args_. | 1037 // v8::AccessorInfo::args_. |
1033 __ movq(StackSpaceOperand(0), rax); | 1038 __ movq(StackSpaceOperand(0), rax); |
1034 | 1039 |
1035 // The context register (rsi) has been saved in PrepareCallApiFunction and | 1040 // The context register (rsi) has been saved in PrepareCallApiFunction and |
1036 // could be used to pass arguments. | 1041 // could be used to pass arguments. |
1037 __ lea(accessor_info_arg, StackSpaceOperand(0)); | 1042 __ lea(accessor_info_arg, StackSpaceOperand(0)); |
1038 | 1043 |
1039 Address getter_address = v8::ToCData<Address>(callback->getter()); | 1044 Address getter_address = v8::ToCData<Address>(callback->getter()); |
1040 __ CallApiFunctionAndReturn(getter_address, kStackSpace); | 1045 __ CallApiFunctionAndReturn(getter_address, kStackSpace); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 ASSERT(callback->getter() != NULL); | 1175 ASSERT(callback->getter() != NULL); |
1171 | 1176 |
1172 // Tail call to runtime. | 1177 // Tail call to runtime. |
1173 // Important invariant in CALLBACKS case: the code above must be | 1178 // Important invariant in CALLBACKS case: the code above must be |
1174 // structured to never clobber |receiver| register. | 1179 // structured to never clobber |receiver| register. |
1175 __ pop(scratch2); // return address | 1180 __ pop(scratch2); // return address |
1176 __ push(receiver); | 1181 __ push(receiver); |
1177 __ push(holder_reg); | 1182 __ push(holder_reg); |
1178 __ Move(holder_reg, callback); | 1183 __ Move(holder_reg, callback); |
1179 __ push(FieldOperand(holder_reg, AccessorInfo::kDataOffset)); | 1184 __ push(FieldOperand(holder_reg, AccessorInfo::kDataOffset)); |
| 1185 __ push(Immediate(reinterpret_cast<intptr_t>(isolate()))); |
1180 __ push(holder_reg); | 1186 __ push(holder_reg); |
1181 __ push(name_reg); | 1187 __ push(name_reg); |
1182 __ push(scratch2); // restore return address | 1188 __ push(scratch2); // restore return address |
1183 | 1189 |
1184 ExternalReference ref = | 1190 ExternalReference ref = |
1185 ExternalReference(IC_Utility(IC::kLoadCallbackProperty), | 1191 ExternalReference(IC_Utility(IC::kLoadCallbackProperty), |
1186 isolate()); | 1192 isolate()); |
1187 __ TailCallExternalReference(ref, 5, 1); | 1193 __ TailCallExternalReference(ref, 6, 1); |
1188 } | 1194 } |
1189 } else { // !compile_followup_inline | 1195 } else { // !compile_followup_inline |
1190 // Call the runtime system to load the interceptor. | 1196 // Call the runtime system to load the interceptor. |
1191 // Check that the maps haven't changed. | 1197 // Check that the maps haven't changed. |
1192 Register holder_reg = CheckPrototypes(object, receiver, interceptor_holder, | 1198 Register holder_reg = CheckPrototypes(object, receiver, interceptor_holder, |
1193 scratch1, scratch2, scratch3, | 1199 scratch1, scratch2, scratch3, |
1194 name, miss); | 1200 name, miss); |
1195 __ pop(scratch2); // save old return address | 1201 __ pop(scratch2); // save old return address |
1196 PushInterceptorArguments(masm(), receiver, holder_reg, | 1202 PushInterceptorArguments(masm(), receiver, holder_reg, |
1197 name_reg, interceptor_holder); | 1203 name_reg, interceptor_holder); |
1198 __ push(scratch2); // restore old return address | 1204 __ push(scratch2); // restore old return address |
1199 | 1205 |
1200 ExternalReference ref = ExternalReference( | 1206 ExternalReference ref = ExternalReference( |
1201 IC_Utility(IC::kLoadPropertyWithInterceptorForLoad), isolate()); | 1207 IC_Utility(IC::kLoadPropertyWithInterceptorForLoad), isolate()); |
1202 __ TailCallExternalReference(ref, 5, 1); | 1208 __ TailCallExternalReference(ref, 6, 1); |
1203 } | 1209 } |
1204 } | 1210 } |
1205 | 1211 |
1206 | 1212 |
1207 void CallStubCompiler::GenerateNameCheck(Handle<String> name, Label* miss) { | 1213 void CallStubCompiler::GenerateNameCheck(Handle<String> name, Label* miss) { |
1208 if (kind_ == Code::KEYED_CALL_IC) { | 1214 if (kind_ == Code::KEYED_CALL_IC) { |
1209 __ Cmp(rcx, name); | 1215 __ Cmp(rcx, name); |
1210 __ j(not_equal, miss); | 1216 __ j(not_equal, miss); |
1211 } | 1217 } |
1212 } | 1218 } |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1984 | 1990 |
1985 // Allocate space for v8::Arguments implicit values. Must be initialized | 1991 // Allocate space for v8::Arguments implicit values. Must be initialized |
1986 // before calling any runtime function. | 1992 // before calling any runtime function. |
1987 __ subq(rsp, Immediate(kFastApiCallArguments * kPointerSize)); | 1993 __ subq(rsp, Immediate(kFastApiCallArguments * kPointerSize)); |
1988 | 1994 |
1989 // Check that the maps haven't changed and find a Holder as a side effect. | 1995 // Check that the maps haven't changed and find a Holder as a side effect. |
1990 CheckPrototypes(Handle<JSObject>::cast(object), rdx, holder, rbx, rax, rdi, | 1996 CheckPrototypes(Handle<JSObject>::cast(object), rdx, holder, rbx, rax, rdi, |
1991 name, depth, &miss); | 1997 name, depth, &miss); |
1992 | 1998 |
1993 // Move the return address on top of the stack. | 1999 // Move the return address on top of the stack. |
1994 __ movq(rax, Operand(rsp, 3 * kPointerSize)); | 2000 __ movq(rax, Operand(rsp, 4 * kPointerSize)); |
1995 __ movq(Operand(rsp, 0 * kPointerSize), rax); | 2001 __ movq(Operand(rsp, 0 * kPointerSize), rax); |
1996 | 2002 |
1997 GenerateFastApiCall(masm(), optimization, argc); | 2003 GenerateFastApiCall(masm(), optimization, argc); |
1998 | 2004 |
1999 __ bind(&miss); | 2005 __ bind(&miss); |
2000 __ addq(rsp, Immediate(kFastApiCallArguments * kPointerSize)); | 2006 __ addq(rsp, Immediate(kFastApiCallArguments * kPointerSize)); |
2001 | 2007 |
2002 __ bind(&miss_before_stack_reserved); | 2008 __ bind(&miss_before_stack_reserved); |
2003 GenerateMissBranch(); | 2009 GenerateMissBranch(); |
2004 | 2010 |
(...skipping 1807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3812 __ jmp(ic_slow, RelocInfo::CODE_TARGET); | 3818 __ jmp(ic_slow, RelocInfo::CODE_TARGET); |
3813 } | 3819 } |
3814 } | 3820 } |
3815 | 3821 |
3816 | 3822 |
3817 #undef __ | 3823 #undef __ |
3818 | 3824 |
3819 } } // namespace v8::internal | 3825 } } // namespace v8::internal |
3820 | 3826 |
3821 #endif // V8_TARGET_ARCH_X64 | 3827 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |