Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/x64/stub-cache-x64.cc

Issue 23588002: cleanup api callbacks now that handles are never returned directly (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: nits Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex); 486 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex);
487 __ movq(args.GetArgumentOperand(api_call_argc - 4), kScratchRegister); 487 __ movq(args.GetArgumentOperand(api_call_argc - 4), kScratchRegister);
488 __ movq(args.GetArgumentOperand(api_call_argc - 5), kScratchRegister); 488 __ movq(args.GetArgumentOperand(api_call_argc - 5), kScratchRegister);
489 489
490 // Prepare arguments. 490 // Prepare arguments.
491 STATIC_ASSERT(kFastApiCallArguments == 6); 491 STATIC_ASSERT(kFastApiCallArguments == 6);
492 __ lea(rbx, Operand(rsp, kFastApiCallArguments * kPointerSize)); 492 __ lea(rbx, Operand(rsp, kFastApiCallArguments * kPointerSize));
493 493
494 // Function address is a foreign pointer outside V8's heap. 494 // Function address is a foreign pointer outside V8's heap.
495 Address function_address = v8::ToCData<Address>(api_call_info->callback()); 495 Address function_address = v8::ToCData<Address>(api_call_info->callback());
496 // TODO(dcarney): fix signatures using returns_handle
497 const bool returns_handle = false;
498 496
499 #if defined(__MINGW64__) 497 #if defined(__MINGW64__) || defined(_WIN64)
500 Register arguments_arg = rcx; 498 Register arguments_arg = rcx;
501 Register callback_arg = rdx; 499 Register callback_arg = rdx;
502 #elif defined(_WIN64)
503 // Win64 uses first register--rcx--for returned value.
504 Register arguments_arg = returns_handle ? rdx : rcx;
505 Register callback_arg = returns_handle ? r8 : rdx;
506 #else 500 #else
507 Register arguments_arg = rdi; 501 Register arguments_arg = rdi;
508 Register callback_arg = rsi; 502 Register callback_arg = rsi;
509 #endif 503 #endif
510 504
511 // Allocate the v8::Arguments structure in the arguments' space since 505 // Allocate the v8::Arguments structure in the arguments' space since
512 // it's not controlled by GC. 506 // it's not controlled by GC.
513 const int kApiStackSpace = 4; 507 const int kApiStackSpace = 4;
514 508
515 __ PrepareCallApiFunction(kApiStackSpace, returns_handle); 509 __ PrepareCallApiFunction(kApiStackSpace);
516 510
517 __ movq(StackSpaceOperand(0), rbx); // v8::Arguments::implicit_args_. 511 __ movq(StackSpaceOperand(0), rbx); // v8::Arguments::implicit_args_.
518 __ addq(rbx, Immediate(argc * kPointerSize)); 512 __ addq(rbx, Immediate(argc * kPointerSize));
519 __ movq(StackSpaceOperand(1), rbx); // v8::Arguments::values_. 513 __ movq(StackSpaceOperand(1), rbx); // v8::Arguments::values_.
520 __ Set(StackSpaceOperand(2), argc); // v8::Arguments::length_. 514 __ Set(StackSpaceOperand(2), argc); // v8::Arguments::length_.
521 // v8::Arguments::is_construct_call_. 515 // v8::Arguments::is_construct_call_.
522 __ Set(StackSpaceOperand(3), 0); 516 __ Set(StackSpaceOperand(3), 0);
523 517
524 // v8::InvocationCallback's argument. 518 // v8::InvocationCallback's argument.
525 __ lea(arguments_arg, StackSpaceOperand(0)); 519 __ lea(arguments_arg, StackSpaceOperand(0));
526 520
527 Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback); 521 Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback);
528 522
529 __ CallApiFunctionAndReturn(function_address, 523 __ CallApiFunctionAndReturn(function_address,
530 thunk_address, 524 thunk_address,
531 callback_arg, 525 callback_arg,
532 api_call_argc + 1, 526 api_call_argc + 1,
533 returns_handle,
534 kFastApiCallArguments + 1); 527 kFastApiCallArguments + 1);
535 } 528 }
536 529
537 530
538 class CallInterceptorCompiler BASE_EMBEDDED { 531 class CallInterceptorCompiler BASE_EMBEDDED {
539 public: 532 public:
540 CallInterceptorCompiler(StubCompiler* stub_compiler, 533 CallInterceptorCompiler(StubCompiler* stub_compiler,
541 const ParameterCount& arguments, 534 const ParameterCount& arguments,
542 Register name, 535 Register name,
543 Code::ExtraICState extra_ic_state) 536 Code::ExtraICState extra_ic_state)
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 } 1293 }
1301 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex); 1294 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex);
1302 __ push(kScratchRegister); // return value 1295 __ push(kScratchRegister); // return value
1303 __ push(kScratchRegister); // return value default 1296 __ push(kScratchRegister); // return value default
1304 __ PushAddress(ExternalReference::isolate_address(isolate())); 1297 __ PushAddress(ExternalReference::isolate_address(isolate()));
1305 __ push(name()); // name 1298 __ push(name()); // name
1306 // Save a pointer to where we pushed the arguments pointer. This will be 1299 // Save a pointer to where we pushed the arguments pointer. This will be
1307 // passed as the const ExecutableAccessorInfo& to the C++ callback. 1300 // passed as the const ExecutableAccessorInfo& to the C++ callback.
1308 1301
1309 Address getter_address = v8::ToCData<Address>(callback->getter()); 1302 Address getter_address = v8::ToCData<Address>(callback->getter());
1310 // TODO(dcarney): fix signatures using returns_handle
1311 const bool returns_handle = false;
1312 1303
1313 #if defined(__MINGW64__) 1304 #if defined(__MINGW64__) || defined(_WIN64)
1314 Register getter_arg = r8; 1305 Register getter_arg = r8;
1315 Register accessor_info_arg = rdx; 1306 Register accessor_info_arg = rdx;
1316 Register name_arg = rcx; 1307 Register name_arg = rcx;
1317 #elif defined(_WIN64)
1318 // Win64 uses first register--rcx--for returned value.
1319 Register getter_arg = returns_handle ? r9 : r8;
1320 Register accessor_info_arg = returns_handle ? r8 : rdx;
1321 Register name_arg = returns_handle ? rdx : rcx;
1322 #else 1308 #else
1323 Register getter_arg = rdx; 1309 Register getter_arg = rdx;
1324 Register accessor_info_arg = rsi; 1310 Register accessor_info_arg = rsi;
1325 Register name_arg = rdi; 1311 Register name_arg = rdi;
1326 #endif 1312 #endif
1327 1313
1328 ASSERT(!name_arg.is(scratch4())); 1314 ASSERT(!name_arg.is(scratch4()));
1329 __ movq(name_arg, rsp); 1315 __ movq(name_arg, rsp);
1330 __ PushReturnAddressFrom(scratch4()); 1316 __ PushReturnAddressFrom(scratch4());
1331 1317
1332 // v8::Arguments::values_ and handler for name. 1318 // v8::Arguments::values_ and handler for name.
1333 const int kStackSpace = PropertyCallbackArguments::kArgsLength + 1; 1319 const int kStackSpace = PropertyCallbackArguments::kArgsLength + 1;
1334 1320
1335 // Allocate v8::AccessorInfo in non-GCed stack space. 1321 // Allocate v8::AccessorInfo in non-GCed stack space.
1336 const int kArgStackSpace = 1; 1322 const int kArgStackSpace = 1;
1337 1323
1338 __ PrepareCallApiFunction(kArgStackSpace, returns_handle); 1324 __ PrepareCallApiFunction(kArgStackSpace);
1339 STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 6); 1325 STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 6);
1340 __ lea(rax, Operand(name_arg, 6 * kPointerSize)); 1326 __ lea(rax, Operand(name_arg, 6 * kPointerSize));
1341 1327
1342 // v8::AccessorInfo::args_. 1328 // v8::AccessorInfo::args_.
1343 __ movq(StackSpaceOperand(0), rax); 1329 __ movq(StackSpaceOperand(0), rax);
1344 1330
1345 // The context register (rsi) has been saved in PrepareCallApiFunction and 1331 // The context register (rsi) has been saved in PrepareCallApiFunction and
1346 // could be used to pass arguments. 1332 // could be used to pass arguments.
1347 __ lea(accessor_info_arg, StackSpaceOperand(0)); 1333 __ lea(accessor_info_arg, StackSpaceOperand(0));
1348 1334
1349 Address thunk_address = FUNCTION_ADDR(&InvokeAccessorGetterCallback); 1335 Address thunk_address = FUNCTION_ADDR(&InvokeAccessorGetterCallback);
1350 1336
1351 __ CallApiFunctionAndReturn(getter_address, 1337 __ CallApiFunctionAndReturn(getter_address,
1352 thunk_address, 1338 thunk_address,
1353 getter_arg, 1339 getter_arg,
1354 kStackSpace, 1340 kStackSpace,
1355 returns_handle,
1356 5); 1341 5);
1357 } 1342 }
1358 1343
1359 1344
1360 void BaseLoadStubCompiler::GenerateLoadConstant(Handle<Object> value) { 1345 void BaseLoadStubCompiler::GenerateLoadConstant(Handle<Object> value) {
1361 // Return the constant value. 1346 // Return the constant value.
1362 __ LoadObject(rax, value); 1347 __ LoadObject(rax, value);
1363 __ ret(0); 1348 __ ret(0);
1364 } 1349 }
1365 1350
(...skipping 1790 matching lines...) Expand 10 before | Expand all | Expand 10 after
3156 // ----------------------------------- 3141 // -----------------------------------
3157 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); 3142 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric);
3158 } 3143 }
3159 3144
3160 3145
3161 #undef __ 3146 #undef __
3162 3147
3163 } } // namespace v8::internal 3148 } } // namespace v8::internal
3164 3149
3165 #endif // V8_TARGET_ARCH_X64 3150 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698