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 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 STATIC_ASSERT(kFastApiCallArguments == 6); | 484 STATIC_ASSERT(kFastApiCallArguments == 6); |
485 __ lea(rbx, Operand(rsp, kFastApiCallArguments * kPointerSize)); | 485 __ lea(rbx, Operand(rsp, kFastApiCallArguments * kPointerSize)); |
486 | 486 |
487 // Function address is a foreign pointer outside V8's heap. | 487 // Function address is a foreign pointer outside V8's heap. |
488 Address function_address = v8::ToCData<Address>(api_call_info->callback()); | 488 Address function_address = v8::ToCData<Address>(api_call_info->callback()); |
489 bool returns_handle = | 489 bool returns_handle = |
490 !CallbackTable::ReturnsVoid(masm->isolate(), function_address); | 490 !CallbackTable::ReturnsVoid(masm->isolate(), function_address); |
491 | 491 |
492 #if defined(__MINGW64__) | 492 #if defined(__MINGW64__) |
493 Register arguments_arg = rcx; | 493 Register arguments_arg = rcx; |
494 Register callback_arg = rdx; | |
495 #elif defined(_WIN64) | 494 #elif defined(_WIN64) |
496 // Win64 uses first register--rcx--for returned value. | 495 // Win64 uses first register--rcx--for returned value. |
497 Register arguments_arg = returns_handle ? rdx : rcx; | 496 Register arguments_arg = returns_handle ? rdx : rcx; |
498 Register callback_arg = returns_handle ? r8 : rdx; | |
499 #else | 497 #else |
500 Register arguments_arg = rdi; | 498 Register arguments_arg = rdi; |
501 Register callback_arg = rsi; | |
502 #endif | 499 #endif |
503 | 500 |
504 // Allocate the v8::Arguments structure in the arguments' space since | 501 // Allocate the v8::Arguments structure in the arguments' space since |
505 // it's not controlled by GC. | 502 // it's not controlled by GC. |
506 const int kApiStackSpace = 4; | 503 const int kApiStackSpace = 4; |
507 | 504 |
508 __ PrepareCallApiFunction(kApiStackSpace, returns_handle); | 505 __ PrepareCallApiFunction(kApiStackSpace, returns_handle); |
509 | 506 |
510 __ movq(StackSpaceOperand(0), rbx); // v8::Arguments::implicit_args_. | 507 __ movq(StackSpaceOperand(0), rbx); // v8::Arguments::implicit_args_. |
511 __ addq(rbx, Immediate(argc * kPointerSize)); | 508 __ addq(rbx, Immediate(argc * kPointerSize)); |
512 __ movq(StackSpaceOperand(1), rbx); // v8::Arguments::values_. | 509 __ movq(StackSpaceOperand(1), rbx); // v8::Arguments::values_. |
513 __ Set(StackSpaceOperand(2), argc); // v8::Arguments::length_. | 510 __ Set(StackSpaceOperand(2), argc); // v8::Arguments::length_. |
514 // v8::Arguments::is_construct_call_. | 511 // v8::Arguments::is_construct_call_. |
515 __ Set(StackSpaceOperand(3), 0); | 512 __ Set(StackSpaceOperand(3), 0); |
516 | 513 |
517 // v8::InvocationCallback's argument. | 514 // v8::InvocationCallback's argument. |
518 __ lea(arguments_arg, StackSpaceOperand(0)); | 515 __ lea(arguments_arg, StackSpaceOperand(0)); |
519 | 516 |
520 Address thunk_address = returns_handle | |
521 ? FUNCTION_ADDR(&InvokeInvocationCallback) | |
522 : FUNCTION_ADDR(&InvokeFunctionCallback); | |
523 | |
524 __ CallApiFunctionAndReturn(function_address, | 517 __ CallApiFunctionAndReturn(function_address, |
525 thunk_address, | |
526 callback_arg, | |
527 argc + kFastApiCallArguments + 1, | 518 argc + kFastApiCallArguments + 1, |
528 returns_handle, | 519 returns_handle, |
529 kFastApiCallArguments + 1); | 520 kFastApiCallArguments + 1); |
530 } | 521 } |
531 | 522 |
532 | 523 |
533 class CallInterceptorCompiler BASE_EMBEDDED { | 524 class CallInterceptorCompiler BASE_EMBEDDED { |
534 public: | 525 public: |
535 CallInterceptorCompiler(StubCompiler* stub_compiler, | 526 CallInterceptorCompiler(StubCompiler* stub_compiler, |
536 const ParameterCount& arguments, | 527 const ParameterCount& arguments, |
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 __ PushAddress(ExternalReference::isolate_address(isolate())); | 1311 __ PushAddress(ExternalReference::isolate_address(isolate())); |
1321 __ push(name()); // name | 1312 __ push(name()); // name |
1322 // Save a pointer to where we pushed the arguments pointer. This will be | 1313 // Save a pointer to where we pushed the arguments pointer. This will be |
1323 // passed as the const ExecutableAccessorInfo& to the C++ callback. | 1314 // passed as the const ExecutableAccessorInfo& to the C++ callback. |
1324 | 1315 |
1325 Address getter_address = v8::ToCData<Address>(callback->getter()); | 1316 Address getter_address = v8::ToCData<Address>(callback->getter()); |
1326 bool returns_handle = | 1317 bool returns_handle = |
1327 !CallbackTable::ReturnsVoid(isolate(), getter_address); | 1318 !CallbackTable::ReturnsVoid(isolate(), getter_address); |
1328 | 1319 |
1329 #if defined(__MINGW64__) | 1320 #if defined(__MINGW64__) |
1330 Register getter_arg = r8; | |
1331 Register accessor_info_arg = rdx; | 1321 Register accessor_info_arg = rdx; |
1332 Register name_arg = rcx; | 1322 Register name_arg = rcx; |
1333 #elif defined(_WIN64) | 1323 #elif defined(_WIN64) |
1334 // Win64 uses first register--rcx--for returned value. | 1324 // Win64 uses first register--rcx--for returned value. |
1335 Register getter_arg = returns_handle ? r9 : r8; | |
1336 Register accessor_info_arg = returns_handle ? r8 : rdx; | 1325 Register accessor_info_arg = returns_handle ? r8 : rdx; |
1337 Register name_arg = returns_handle ? rdx : rcx; | 1326 Register name_arg = returns_handle ? rdx : rcx; |
1338 #else | 1327 #else |
1339 Register getter_arg = rdx; | |
1340 Register accessor_info_arg = rsi; | 1328 Register accessor_info_arg = rsi; |
1341 Register name_arg = rdi; | 1329 Register name_arg = rdi; |
1342 #endif | 1330 #endif |
1343 | 1331 |
1344 ASSERT(!name_arg.is(scratch2())); | 1332 ASSERT(!name_arg.is(scratch2())); |
1345 __ movq(name_arg, rsp); | 1333 __ movq(name_arg, rsp); |
1346 __ push(scratch2()); // Restore return address. | 1334 __ push(scratch2()); // Restore return address. |
1347 | 1335 |
1348 // v8::Arguments::values_ and handler for name. | 1336 // v8::Arguments::values_ and handler for name. |
1349 const int kStackSpace = PropertyCallbackArguments::kArgsLength + 1; | 1337 const int kStackSpace = PropertyCallbackArguments::kArgsLength + 1; |
1350 | 1338 |
1351 // Allocate v8::AccessorInfo in non-GCed stack space. | 1339 // Allocate v8::AccessorInfo in non-GCed stack space. |
1352 const int kArgStackSpace = 1; | 1340 const int kArgStackSpace = 1; |
1353 | 1341 |
1354 __ PrepareCallApiFunction(kArgStackSpace, returns_handle); | 1342 __ PrepareCallApiFunction(kArgStackSpace, returns_handle); |
1355 STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 6); | 1343 STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 6); |
1356 __ lea(rax, Operand(name_arg, 6 * kPointerSize)); | 1344 __ lea(rax, Operand(name_arg, 6 * kPointerSize)); |
1357 | 1345 |
1358 // v8::AccessorInfo::args_. | 1346 // v8::AccessorInfo::args_. |
1359 __ movq(StackSpaceOperand(0), rax); | 1347 __ movq(StackSpaceOperand(0), rax); |
1360 | 1348 |
1361 // The context register (rsi) has been saved in PrepareCallApiFunction and | 1349 // The context register (rsi) has been saved in PrepareCallApiFunction and |
1362 // could be used to pass arguments. | 1350 // could be used to pass arguments. |
1363 __ lea(accessor_info_arg, StackSpaceOperand(0)); | 1351 __ lea(accessor_info_arg, StackSpaceOperand(0)); |
1364 | 1352 |
1365 Address thunk_address = returns_handle | |
1366 ? FUNCTION_ADDR(&InvokeAccessorGetter) | |
1367 : FUNCTION_ADDR(&InvokeAccessorGetterCallback); | |
1368 | |
1369 __ CallApiFunctionAndReturn(getter_address, | 1353 __ CallApiFunctionAndReturn(getter_address, |
1370 thunk_address, | |
1371 getter_arg, | |
1372 kStackSpace, | 1354 kStackSpace, |
1373 returns_handle, | 1355 returns_handle, |
1374 5); | 1356 5); |
1375 } | 1357 } |
1376 | 1358 |
1377 | 1359 |
1378 void BaseLoadStubCompiler::GenerateLoadConstant(Handle<JSFunction> value) { | 1360 void BaseLoadStubCompiler::GenerateLoadConstant(Handle<JSFunction> value) { |
1379 // Return the constant value. | 1361 // Return the constant value. |
1380 __ LoadHeapObject(rax, value); | 1362 __ LoadHeapObject(rax, value); |
1381 __ ret(0); | 1363 __ ret(0); |
(...skipping 2122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3504 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); | 3486 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); |
3505 } | 3487 } |
3506 } | 3488 } |
3507 | 3489 |
3508 | 3490 |
3509 #undef __ | 3491 #undef __ |
3510 | 3492 |
3511 } } // namespace v8::internal | 3493 } } // namespace v8::internal |
3512 | 3494 |
3513 #endif // V8_TARGET_ARCH_X64 | 3495 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |