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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 masm->isolate()); | 389 masm->isolate()); |
390 __ Set(rax, 6); | 390 __ Set(rax, 6); |
391 __ LoadAddress(rbx, ref); | 391 __ LoadAddress(rbx, ref); |
392 | 392 |
393 CEntryStub stub(1); | 393 CEntryStub stub(1); |
394 __ CallStub(&stub); | 394 __ CallStub(&stub); |
395 } | 395 } |
396 | 396 |
397 | 397 |
398 // Number of pointers to be reserved on stack for fast API call. | 398 // Number of pointers to be reserved on stack for fast API call. |
399 static const int kFastApiCallArguments = 4; | 399 static const int kFastApiCallArguments = FunctionCallbackArguments::kArgsLength; |
400 | 400 |
401 | 401 |
402 // Reserves space for the extra arguments to API function in the | 402 // Reserves space for the extra arguments to API function in the |
403 // caller's frame. | 403 // caller's frame. |
404 // | 404 // |
405 // These arguments are set by CheckPrototypes and GenerateFastApiCall. | 405 // These arguments are set by CheckPrototypes and GenerateFastApiCall. |
406 static void ReserveSpaceForFastApiCall(MacroAssembler* masm, Register scratch) { | 406 static void ReserveSpaceForFastApiCall(MacroAssembler* masm, Register scratch) { |
407 // ----------- S t a t e ------------- | 407 // ----------- S t a t e ------------- |
408 // -- rsp[0] : return address | 408 // -- rsp[0] : return address |
409 // -- rsp[8] : last argument in the internal frame of the caller | 409 // -- rsp[8] : last argument in the internal frame of the caller |
(...skipping 30 matching lines...) Expand all Loading... |
440 int argc) { | 440 int argc) { |
441 // ----------- S t a t e ------------- | 441 // ----------- S t a t e ------------- |
442 // -- rsp[0] : return address | 442 // -- rsp[0] : return address |
443 // -- rsp[8] : object passing the type check | 443 // -- rsp[8] : object passing the type check |
444 // (last fast api call extra argument, | 444 // (last fast api call extra argument, |
445 // set by CheckPrototypes) | 445 // set by CheckPrototypes) |
446 // -- rsp[16] : api function | 446 // -- rsp[16] : api function |
447 // (first fast api call extra argument) | 447 // (first fast api call extra argument) |
448 // -- rsp[24] : api call data | 448 // -- rsp[24] : api call data |
449 // -- rsp[32] : isolate | 449 // -- rsp[32] : isolate |
450 // -- rsp[40] : last argument | 450 // -- rsp[40] : ReturnValue |
| 451 // |
| 452 // -- rsp[48] : last argument |
451 // -- ... | 453 // -- ... |
452 // -- rsp[(argc + 4) * 8] : first argument | 454 // -- rsp[(argc + 5) * 8] : first argument |
453 // -- rsp[(argc + 5) * 8] : receiver | 455 // -- rsp[(argc + 6) * 8] : receiver |
454 // ----------------------------------- | 456 // ----------------------------------- |
455 // Get the function and setup the context. | 457 // Get the function and setup the context. |
456 Handle<JSFunction> function = optimization.constant_function(); | 458 Handle<JSFunction> function = optimization.constant_function(); |
457 __ LoadHeapObject(rdi, function); | 459 __ LoadHeapObject(rdi, function); |
458 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); | 460 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); |
459 | 461 |
460 // Pass the additional arguments. | 462 // Pass the additional arguments. |
461 __ movq(Operand(rsp, 2 * kPointerSize), rdi); | 463 __ movq(Operand(rsp, 2 * kPointerSize), rdi); |
462 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); | 464 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); |
463 Handle<Object> call_data(api_call_info->data(), masm->isolate()); | 465 Handle<Object> call_data(api_call_info->data(), masm->isolate()); |
464 if (masm->isolate()->heap()->InNewSpace(*call_data)) { | 466 if (masm->isolate()->heap()->InNewSpace(*call_data)) { |
465 __ Move(rcx, api_call_info); | 467 __ Move(rcx, api_call_info); |
466 __ movq(rbx, FieldOperand(rcx, CallHandlerInfo::kDataOffset)); | 468 __ movq(rbx, FieldOperand(rcx, CallHandlerInfo::kDataOffset)); |
467 __ movq(Operand(rsp, 3 * kPointerSize), rbx); | 469 __ movq(Operand(rsp, 3 * kPointerSize), rbx); |
468 } else { | 470 } else { |
469 __ Move(Operand(rsp, 3 * kPointerSize), call_data); | 471 __ Move(Operand(rsp, 3 * kPointerSize), call_data); |
470 } | 472 } |
471 __ movq(kScratchRegister, | 473 __ movq(kScratchRegister, |
472 ExternalReference::isolate_address(masm->isolate())); | 474 ExternalReference::isolate_address(masm->isolate())); |
473 __ movq(Operand(rsp, 4 * kPointerSize), kScratchRegister); | 475 __ movq(Operand(rsp, 4 * kPointerSize), kScratchRegister); |
| 476 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex); |
| 477 __ movq(Operand(rsp, 5 * kPointerSize), kScratchRegister); |
474 | 478 |
475 // Prepare arguments. | 479 // Prepare arguments. |
476 __ lea(rbx, Operand(rsp, 4 * kPointerSize)); | 480 STATIC_ASSERT(kFastApiCallArguments == 5); |
| 481 __ lea(rbx, Operand(rsp, kFastApiCallArguments * kPointerSize)); |
477 | 482 |
478 #if defined(__MINGW64__) | 483 #if defined(__MINGW64__) |
479 Register arguments_arg = rcx; | 484 Register arguments_arg = rcx; |
480 #elif defined(_WIN64) | 485 #elif defined(_WIN64) |
481 // Win64 uses first register--rcx--for returned value. | 486 // Win64 uses first register--rcx--for returned value. |
482 Register arguments_arg = rdx; | 487 Register arguments_arg = rdx; |
483 #else | 488 #else |
484 Register arguments_arg = rdi; | 489 Register arguments_arg = rdi; |
485 #endif | 490 #endif |
486 | 491 |
487 // Allocate the v8::Arguments structure in the arguments' space since | 492 // Allocate the v8::Arguments structure in the arguments' space since |
488 // it's not controlled by GC. | 493 // it's not controlled by GC. |
489 const int kApiStackSpace = 4; | 494 const int kApiStackSpace = 4; |
490 | 495 |
491 __ PrepareCallApiFunction(kApiStackSpace); | 496 __ PrepareCallApiFunction(kApiStackSpace); |
492 | 497 |
493 __ movq(StackSpaceOperand(0), rbx); // v8::Arguments::implicit_args_. | 498 __ movq(StackSpaceOperand(0), rbx); // v8::Arguments::implicit_args_. |
494 __ addq(rbx, Immediate(argc * kPointerSize)); | 499 __ addq(rbx, Immediate(argc * kPointerSize)); |
495 __ movq(StackSpaceOperand(1), rbx); // v8::Arguments::values_. | 500 __ movq(StackSpaceOperand(1), rbx); // v8::Arguments::values_. |
496 __ Set(StackSpaceOperand(2), argc); // v8::Arguments::length_. | 501 __ Set(StackSpaceOperand(2), argc); // v8::Arguments::length_. |
497 // v8::Arguments::is_construct_call_. | 502 // v8::Arguments::is_construct_call_. |
498 __ Set(StackSpaceOperand(3), 0); | 503 __ Set(StackSpaceOperand(3), 0); |
499 | 504 |
500 // v8::InvocationCallback's argument. | 505 // v8::InvocationCallback's argument. |
501 __ lea(arguments_arg, StackSpaceOperand(0)); | 506 __ lea(arguments_arg, StackSpaceOperand(0)); |
502 | 507 |
503 // Function address is a foreign pointer outside V8's heap. | 508 // Function address is a foreign pointer outside V8's heap. |
504 Address function_address = v8::ToCData<Address>(api_call_info->callback()); | 509 Address function_address = v8::ToCData<Address>(api_call_info->callback()); |
505 __ CallApiFunctionAndReturn(function_address, | 510 __ CallApiFunctionAndReturn(function_address, |
506 argc + kFastApiCallArguments + 1); | 511 argc + kFastApiCallArguments + 1, |
| 512 FunctionCallbackArguments::kReturnValueOffset); |
507 } | 513 } |
508 | 514 |
509 | 515 |
510 class CallInterceptorCompiler BASE_EMBEDDED { | 516 class CallInterceptorCompiler BASE_EMBEDDED { |
511 public: | 517 public: |
512 CallInterceptorCompiler(StubCompiler* stub_compiler, | 518 CallInterceptorCompiler(StubCompiler* stub_compiler, |
513 const ParameterCount& arguments, | 519 const ParameterCount& arguments, |
514 Register name, | 520 Register name, |
515 Code::ExtraICState extra_ic_state) | 521 Code::ExtraICState extra_ic_state) |
516 : stub_compiler_(stub_compiler), | 522 : stub_compiler_(stub_compiler), |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1173 | 1179 |
1174 __ push(receiver()); // receiver | 1180 __ push(receiver()); // receiver |
1175 __ push(reg); // holder | 1181 __ push(reg); // holder |
1176 if (heap()->InNewSpace(callback->data())) { | 1182 if (heap()->InNewSpace(callback->data())) { |
1177 __ Move(scratch1(), callback); | 1183 __ Move(scratch1(), callback); |
1178 __ push(FieldOperand(scratch1(), | 1184 __ push(FieldOperand(scratch1(), |
1179 ExecutableAccessorInfo::kDataOffset)); // data | 1185 ExecutableAccessorInfo::kDataOffset)); // data |
1180 } else { | 1186 } else { |
1181 __ Push(Handle<Object>(callback->data(), isolate())); | 1187 __ Push(Handle<Object>(callback->data(), isolate())); |
1182 } | 1188 } |
1183 __ PushAddress(ExternalReference::isolate_address(isolate())); // isolate | 1189 __ PushAddress(ExternalReference::isolate_address(isolate())); |
| 1190 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex); |
| 1191 __ push(kScratchRegister); // return value |
1184 __ push(name()); // name | 1192 __ push(name()); // name |
1185 // Save a pointer to where we pushed the arguments pointer. This will be | 1193 // Save a pointer to where we pushed the arguments pointer. This will be |
1186 // passed as the const ExecutableAccessorInfo& to the C++ callback. | 1194 // passed as the const ExecutableAccessorInfo& to the C++ callback. |
1187 | 1195 |
1188 #if defined(__MINGW64__) | 1196 #if defined(__MINGW64__) |
1189 Register accessor_info_arg = rdx; | 1197 Register accessor_info_arg = rdx; |
1190 Register name_arg = rcx; | 1198 Register name_arg = rcx; |
1191 #elif defined(_WIN64) | 1199 #elif defined(_WIN64) |
1192 // Win64 uses first register--rcx--for returned value. | 1200 // Win64 uses first register--rcx--for returned value. |
1193 Register accessor_info_arg = r8; | 1201 Register accessor_info_arg = r8; |
1194 Register name_arg = rdx; | 1202 Register name_arg = rdx; |
1195 #else | 1203 #else |
1196 Register accessor_info_arg = rsi; | 1204 Register accessor_info_arg = rsi; |
1197 Register name_arg = rdi; | 1205 Register name_arg = rdi; |
1198 #endif | 1206 #endif |
1199 | 1207 |
1200 ASSERT(!name_arg.is(scratch2())); | 1208 ASSERT(!name_arg.is(scratch2())); |
1201 __ movq(name_arg, rsp); | 1209 __ movq(name_arg, rsp); |
1202 __ push(scratch2()); // Restore return address. | 1210 __ push(scratch2()); // Restore return address. |
1203 | 1211 |
1204 // 4 elements array for v8::Arguments::values_ and handler for name. | 1212 // v8::Arguments::values_ and handler for name. |
1205 const int kStackSpace = 5; | 1213 const int kStackSpace = PropertyCallbackArguments::kArgsLength + 1; |
1206 | 1214 |
1207 // Allocate v8::AccessorInfo in non-GCed stack space. | 1215 // Allocate v8::AccessorInfo in non-GCed stack space. |
1208 const int kArgStackSpace = 1; | 1216 const int kArgStackSpace = 1; |
1209 | 1217 |
1210 __ PrepareCallApiFunction(kArgStackSpace); | 1218 __ PrepareCallApiFunction(kArgStackSpace); |
1211 __ lea(rax, Operand(name_arg, 4 * kPointerSize)); | 1219 STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 5); |
| 1220 __ lea(rax, Operand(name_arg, 5 * kPointerSize)); |
1212 | 1221 |
1213 // v8::AccessorInfo::args_. | 1222 // v8::AccessorInfo::args_. |
1214 __ movq(StackSpaceOperand(0), rax); | 1223 __ movq(StackSpaceOperand(0), rax); |
1215 | 1224 |
1216 // The context register (rsi) has been saved in PrepareCallApiFunction and | 1225 // The context register (rsi) has been saved in PrepareCallApiFunction and |
1217 // could be used to pass arguments. | 1226 // could be used to pass arguments. |
1218 __ lea(accessor_info_arg, StackSpaceOperand(0)); | 1227 __ lea(accessor_info_arg, StackSpaceOperand(0)); |
1219 | 1228 |
1220 Address getter_address = v8::ToCData<Address>(callback->getter()); | 1229 Address getter_address = v8::ToCData<Address>(callback->getter()); |
1221 __ CallApiFunctionAndReturn(getter_address, kStackSpace); | 1230 __ CallApiFunctionAndReturn(getter_address, |
| 1231 kStackSpace, |
| 1232 PropertyCallbackArguments::kReturnValueOffset); |
1222 } | 1233 } |
1223 | 1234 |
1224 | 1235 |
1225 void BaseLoadStubCompiler::GenerateLoadConstant(Handle<JSFunction> value) { | 1236 void BaseLoadStubCompiler::GenerateLoadConstant(Handle<JSFunction> value) { |
1226 // Return the constant value. | 1237 // Return the constant value. |
1227 __ LoadHeapObject(rax, value); | 1238 __ LoadHeapObject(rax, value); |
1228 __ ret(0); | 1239 __ ret(0); |
1229 } | 1240 } |
1230 | 1241 |
1231 | 1242 |
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2156 | 2167 |
2157 // Allocate space for v8::Arguments implicit values. Must be initialized | 2168 // Allocate space for v8::Arguments implicit values. Must be initialized |
2158 // before calling any runtime function. | 2169 // before calling any runtime function. |
2159 __ subq(rsp, Immediate(kFastApiCallArguments * kPointerSize)); | 2170 __ subq(rsp, Immediate(kFastApiCallArguments * kPointerSize)); |
2160 | 2171 |
2161 // Check that the maps haven't changed and find a Holder as a side effect. | 2172 // Check that the maps haven't changed and find a Holder as a side effect. |
2162 CheckPrototypes(Handle<JSObject>::cast(object), rdx, holder, rbx, rax, rdi, | 2173 CheckPrototypes(Handle<JSObject>::cast(object), rdx, holder, rbx, rax, rdi, |
2163 name, depth, &miss); | 2174 name, depth, &miss); |
2164 | 2175 |
2165 // Move the return address on top of the stack. | 2176 // Move the return address on top of the stack. |
2166 __ movq(rax, Operand(rsp, 4 * kPointerSize)); | 2177 __ movq(rax, Operand(rsp, kFastApiCallArguments * kPointerSize)); |
2167 __ movq(Operand(rsp, 0 * kPointerSize), rax); | 2178 __ movq(Operand(rsp, 0 * kPointerSize), rax); |
2168 | 2179 |
2169 GenerateFastApiCall(masm(), optimization, argc); | 2180 GenerateFastApiCall(masm(), optimization, argc); |
2170 | 2181 |
2171 __ bind(&miss); | 2182 __ bind(&miss); |
2172 __ addq(rsp, Immediate(kFastApiCallArguments * kPointerSize)); | 2183 __ addq(rsp, Immediate(kFastApiCallArguments * kPointerSize)); |
2173 | 2184 |
2174 __ bind(&miss_before_stack_reserved); | 2185 __ bind(&miss_before_stack_reserved); |
2175 GenerateMissBranch(); | 2186 GenerateMissBranch(); |
2176 | 2187 |
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3478 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); | 3489 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); |
3479 } | 3490 } |
3480 } | 3491 } |
3481 | 3492 |
3482 | 3493 |
3483 #undef __ | 3494 #undef __ |
3484 | 3495 |
3485 } } // namespace v8::internal | 3496 } } // namespace v8::internal |
3486 | 3497 |
3487 #endif // V8_TARGET_ARCH_X64 | 3498 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |