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

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

Issue 24488006: Refactor PropertyCallbackInfo & FunctionCallbackInfo, part 3. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 7 years, 2 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/ia32/stub-cache-ia32.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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 } 440 }
441 441
442 442
443 // Generates call to API function. 443 // Generates call to API function.
444 static void GenerateFastApiCall(MacroAssembler* masm, 444 static void GenerateFastApiCall(MacroAssembler* masm,
445 const CallOptimization& optimization, 445 const CallOptimization& optimization,
446 int argc, 446 int argc,
447 bool restore_context) { 447 bool restore_context) {
448 // ----------- S t a t e ------------- 448 // ----------- S t a t e -------------
449 // -- rsp[0] : return address 449 // -- rsp[0] : return address
450 // -- rsp[8] - rsp[58] : FunctionCallbackInfo, incl. 450 // -- rsp[8] - rsp[56] : FunctionCallbackInfo, incl.
451 // : object passing the type check 451 // : object passing the type check
452 // (set by CheckPrototypes) 452 // (set by CheckPrototypes)
453 // -- rsp[64] : last argument 453 // -- rsp[64] : last argument
454 // -- ... 454 // -- ...
455 // -- rsp[(argc + 7) * 8] : first argument 455 // -- rsp[(argc + 7) * 8] : first argument
456 // -- rsp[(argc + 8) * 8] : receiver 456 // -- rsp[(argc + 8) * 8] : receiver
457 // ----------------------------------- 457 // -----------------------------------
458 typedef FunctionCallbackArguments FCA; 458 typedef FunctionCallbackArguments FCA;
459 StackArgumentsAccessor args(rsp, argc + kFastApiCallArguments); 459 StackArgumentsAccessor args(rsp, argc + kFastApiCallArguments);
460 460
461 // Save calling context. 461 // Save calling context.
462 __ movq(args.GetArgumentOperand(argc + 1 - FCA::kContextSaveIndex), rsi); 462 int offset = argc + kFastApiCallArguments;
463 __ movq(args.GetArgumentOperand(offset - FCA::kContextSaveIndex), rsi);
463 464
464 // Get the function and setup the context. 465 // Get the function and setup the context.
465 Handle<JSFunction> function = optimization.constant_function(); 466 Handle<JSFunction> function = optimization.constant_function();
466 __ LoadHeapObject(rdi, function); 467 __ LoadHeapObject(rdi, function);
467 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); 468 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
468 // Construct the FunctionCallbackInfo on the stack. 469 // Construct the FunctionCallbackInfo on the stack.
469 __ movq(args.GetArgumentOperand(argc + 1 - FCA::kCalleeIndex), rdi); 470 __ movq(args.GetArgumentOperand(offset - FCA::kCalleeIndex), rdi);
470 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); 471 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info();
471 Handle<Object> call_data(api_call_info->data(), masm->isolate()); 472 Handle<Object> call_data(api_call_info->data(), masm->isolate());
472 if (masm->isolate()->heap()->InNewSpace(*call_data)) { 473 if (masm->isolate()->heap()->InNewSpace(*call_data)) {
473 __ Move(rcx, api_call_info); 474 __ Move(rcx, api_call_info);
474 __ movq(rbx, FieldOperand(rcx, CallHandlerInfo::kDataOffset)); 475 __ movq(rbx, FieldOperand(rcx, CallHandlerInfo::kDataOffset));
475 __ movq(args.GetArgumentOperand(argc + 1 - FCA::kDataIndex), rbx); 476 __ movq(args.GetArgumentOperand(offset - FCA::kDataIndex), rbx);
476 } else { 477 } else {
477 __ Move(args.GetArgumentOperand(argc + 1 - FCA::kDataIndex), call_data); 478 __ Move(args.GetArgumentOperand(offset - FCA::kDataIndex), call_data);
478 } 479 }
479 __ movq(kScratchRegister, 480 __ movq(kScratchRegister,
480 ExternalReference::isolate_address(masm->isolate())); 481 ExternalReference::isolate_address(masm->isolate()));
481 __ movq(args.GetArgumentOperand(argc + 1 - FCA::kIsolateIndex), 482 __ movq(args.GetArgumentOperand(offset - FCA::kIsolateIndex),
482 kScratchRegister); 483 kScratchRegister);
483 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex); 484 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex);
484 __ movq( 485 __ movq(args.GetArgumentOperand(offset - FCA::kReturnValueDefaultValueIndex),
485 args.GetArgumentOperand(argc + 1 - FCA::kReturnValueDefaultValueIndex), 486 kScratchRegister);
486 kScratchRegister); 487 __ movq(args.GetArgumentOperand(offset - FCA::kReturnValueOffset),
487 __ movq(args.GetArgumentOperand(argc + 1 - FCA::kReturnValueOffset),
488 kScratchRegister); 488 kScratchRegister);
489 489
490 // Prepare arguments. 490 // Prepare arguments.
491 STATIC_ASSERT(kFastApiCallArguments == 7); 491 STATIC_ASSERT(kFastApiCallArguments == 7);
492 __ lea(rbx, Operand(rsp, kFastApiCallArguments * kPointerSize)); 492 __ lea(rbx, Operand(rsp, 1 * 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 496
497 // Allocate the v8::Arguments structure in the arguments' space since 497 // Allocate the v8::Arguments structure in the arguments' space since
498 // it's not controlled by GC. 498 // it's not controlled by GC.
499 const int kApiStackSpace = 4; 499 const int kApiStackSpace = 4;
500 500
501 __ PrepareCallApiFunction(kApiStackSpace); 501 __ PrepareCallApiFunction(kApiStackSpace);
502 502
503 __ movq(StackSpaceOperand(0), rbx); // v8::Arguments::implicit_args_. 503 __ movq(StackSpaceOperand(0), rbx); // FunctionCallbackInfo::implicit_args_.
504 __ addq(rbx, Immediate(argc * kPointerSize)); 504 __ addq(rbx, Immediate((argc + kFastApiCallArguments - 1) * kPointerSize));
505 __ movq(StackSpaceOperand(1), rbx); // v8::Arguments::values_. 505 __ movq(StackSpaceOperand(1), rbx); // FunctionCallbackInfo::values_.
506 __ Set(StackSpaceOperand(2), argc); // v8::Arguments::length_. 506 __ Set(StackSpaceOperand(2), argc); // FunctionCallbackInfo::length_.
507 // v8::Arguments::is_construct_call_. 507 // FunctionCallbackInfo::is_construct_call_.
508 __ Set(StackSpaceOperand(3), 0); 508 __ Set(StackSpaceOperand(3), 0);
509 509
510 #if defined(__MINGW64__) || defined(_WIN64) 510 #if defined(__MINGW64__) || defined(_WIN64)
511 Register arguments_arg = rcx; 511 Register arguments_arg = rcx;
512 Register callback_arg = rdx; 512 Register callback_arg = rdx;
513 #else 513 #else
514 Register arguments_arg = rdi; 514 Register arguments_arg = rdi;
515 Register callback_arg = rsi; 515 Register callback_arg = rsi;
516 #endif 516 #endif
517 517
518 // v8::InvocationCallback's argument. 518 // v8::InvocationCallback's argument.
519 __ lea(arguments_arg, StackSpaceOperand(0)); 519 __ lea(arguments_arg, StackSpaceOperand(0));
520 520
521 Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback); 521 Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback);
522 522
523 Operand context_restore_operand( 523 Operand context_restore_operand(rbp,
524 rbp, (kFastApiCallArguments + 1 + FCA::kContextSaveIndex) * kPointerSize); 524 (2 + FCA::kContextSaveIndex) * kPointerSize);
525 Operand return_value_operand( 525 Operand return_value_operand(rbp,
526 rbp, 526 (2 + FCA::kReturnValueOffset) * kPointerSize);
527 (kFastApiCallArguments + 1 + FCA::kReturnValueOffset) * kPointerSize);
528 __ CallApiFunctionAndReturn( 527 __ CallApiFunctionAndReturn(
529 function_address, 528 function_address,
530 thunk_address, 529 thunk_address,
531 callback_arg, 530 callback_arg,
532 argc + kFastApiCallArguments + 1, 531 argc + kFastApiCallArguments + 1,
533 return_value_operand, 532 return_value_operand,
534 restore_context ? &context_restore_operand : NULL); 533 restore_context ? &context_restore_operand : NULL);
535 } 534 }
536 535
537 536
538 // Generate call to api function. 537 // Generate call to api function.
539 static void GenerateFastApiCall(MacroAssembler* masm, 538 static void GenerateFastApiCall(MacroAssembler* masm,
540 const CallOptimization& optimization, 539 const CallOptimization& optimization,
541 Register receiver, 540 Register receiver,
542 Register scratch, 541 Register scratch,
543 int argc, 542 int argc,
544 Register* values) { 543 Register* values) {
545 ASSERT(optimization.is_simple_api_call()); 544 ASSERT(optimization.is_simple_api_call());
546 ASSERT(!receiver.is(scratch)); 545 ASSERT(!receiver.is(scratch));
547 546
548 const int stack_space = kFastApiCallArguments + argc + 1; 547 const int stack_space = kFastApiCallArguments + argc + 1;
549 const int kHolderIndex = kFastApiCallArguments + 548 const int kHolderIndex = FunctionCallbackArguments::kHolderIndex + 1;
550 FunctionCallbackArguments::kHolderIndex;
551 // Copy return value. 549 // Copy return value.
552 __ movq(scratch, Operand(rsp, 0)); 550 __ movq(scratch, Operand(rsp, 0));
553 // Assign stack space for the call arguments. 551 // Assign stack space for the call arguments.
554 __ subq(rsp, Immediate(stack_space * kPointerSize)); 552 __ subq(rsp, Immediate(stack_space * kPointerSize));
555 // Move the return address on top of the stack. 553 // Move the return address on top of the stack.
556 __ movq(Operand(rsp, 0), scratch); 554 __ movq(Operand(rsp, 0), scratch);
557 // Write holder to stack frame. 555 // Write holder to stack frame.
558 __ movq(Operand(rsp, kHolderIndex * kPointerSize), receiver); 556 __ movq(Operand(rsp, kHolderIndex * kPointerSize), receiver);
559 // Write receiver to stack frame. 557 // Write receiver to stack frame.
560 int index = stack_space; 558 int index = stack_space;
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 Register StubCompiler::CheckPrototypes(Handle<JSObject> object, 1087 Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
1090 Register object_reg, 1088 Register object_reg,
1091 Handle<JSObject> holder, 1089 Handle<JSObject> holder,
1092 Register holder_reg, 1090 Register holder_reg,
1093 Register scratch1, 1091 Register scratch1,
1094 Register scratch2, 1092 Register scratch2,
1095 Handle<Name> name, 1093 Handle<Name> name,
1096 int save_at_depth, 1094 int save_at_depth,
1097 Label* miss, 1095 Label* miss,
1098 PrototypeCheckType check) { 1096 PrototypeCheckType check) {
1099 const int kHolderIndex = kFastApiCallArguments + 1097 const int kHolderIndex = FunctionCallbackArguments::kHolderIndex + 1;
1100 FunctionCallbackArguments::kHolderIndex;
1101 // Make sure that the type feedback oracle harvests the receiver map. 1098 // Make sure that the type feedback oracle harvests the receiver map.
1102 // TODO(svenpanne) Remove this hack when all ICs are reworked. 1099 // TODO(svenpanne) Remove this hack when all ICs are reworked.
1103 __ Move(scratch1, Handle<Map>(object->map())); 1100 __ Move(scratch1, Handle<Map>(object->map()));
1104 1101
1105 Handle<JSObject> first = object; 1102 Handle<JSObject> first = object;
1106 // Make sure there's no overlap between holder and object registers. 1103 // Make sure there's no overlap between holder and object registers.
1107 ASSERT(!scratch1.is(object_reg) && !scratch1.is(holder_reg)); 1104 ASSERT(!scratch1.is(object_reg) && !scratch1.is(holder_reg));
1108 ASSERT(!scratch2.is(object_reg) && !scratch2.is(holder_reg) 1105 ASSERT(!scratch2.is(object_reg) && !scratch2.is(holder_reg)
1109 && !scratch2.is(scratch1)); 1106 && !scratch2.is(scratch1));
1110 1107
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 } 1323 }
1327 1324
1328 1325
1329 void BaseLoadStubCompiler::GenerateLoadCallback( 1326 void BaseLoadStubCompiler::GenerateLoadCallback(
1330 Register reg, 1327 Register reg,
1331 Handle<ExecutableAccessorInfo> callback) { 1328 Handle<ExecutableAccessorInfo> callback) {
1332 // Insert additional parameters into the stack frame above return address. 1329 // Insert additional parameters into the stack frame above return address.
1333 ASSERT(!scratch4().is(reg)); 1330 ASSERT(!scratch4().is(reg));
1334 __ PopReturnAddressTo(scratch4()); 1331 __ PopReturnAddressTo(scratch4());
1335 1332
1336 STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 0); 1333 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 0);
1337 STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == -1); 1334 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 1);
1338 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == -2); 1335 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 2);
1339 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == -3); 1336 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 3);
1340 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == -4); 1337 STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 4);
1341 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == -5); 1338 STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 5);
1339 STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 6);
1342 __ push(receiver()); // receiver 1340 __ push(receiver()); // receiver
1343 if (heap()->InNewSpace(callback->data())) { 1341 if (heap()->InNewSpace(callback->data())) {
1344 ASSERT(!scratch2().is(reg)); 1342 ASSERT(!scratch2().is(reg));
1345 __ Move(scratch2(), callback); 1343 __ Move(scratch2(), callback);
1346 __ push(FieldOperand(scratch2(), 1344 __ push(FieldOperand(scratch2(),
1347 ExecutableAccessorInfo::kDataOffset)); // data 1345 ExecutableAccessorInfo::kDataOffset)); // data
1348 } else { 1346 } else {
1349 __ Push(Handle<Object>(callback->data(), isolate())); 1347 __ Push(Handle<Object>(callback->data(), isolate()));
1350 } 1348 }
1351 ASSERT(!kScratchRegister.is(reg)); 1349 ASSERT(!kScratchRegister.is(reg));
1352 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex); 1350 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex);
1353 __ push(kScratchRegister); // return value 1351 __ push(kScratchRegister); // return value
1354 __ push(kScratchRegister); // return value default 1352 __ push(kScratchRegister); // return value default
1355 __ PushAddress(ExternalReference::isolate_address(isolate())); 1353 __ PushAddress(ExternalReference::isolate_address(isolate()));
1356 __ push(reg); // holder 1354 __ push(reg); // holder
1357 __ push(name()); // name 1355 __ push(name()); // name
1358 // Save a pointer to where we pushed the arguments pointer. This will be 1356 // Save a pointer to where we pushed the arguments pointer. This will be
1359 // passed as the const ExecutableAccessorInfo& to the C++ callback. 1357 // passed as the const PropertyAccessorInfo& to the C++ callback.
1360 1358
1361 Address getter_address = v8::ToCData<Address>(callback->getter()); 1359 Address getter_address = v8::ToCData<Address>(callback->getter());
1362 1360
1363 #if defined(__MINGW64__) || defined(_WIN64) 1361 #if defined(__MINGW64__) || defined(_WIN64)
1364 Register getter_arg = r8; 1362 Register getter_arg = r8;
1365 Register accessor_info_arg = rdx; 1363 Register accessor_info_arg = rdx;
1366 Register name_arg = rcx; 1364 Register name_arg = rcx;
1367 #else 1365 #else
1368 Register getter_arg = rdx; 1366 Register getter_arg = rdx;
1369 Register accessor_info_arg = rsi; 1367 Register accessor_info_arg = rsi;
1370 Register name_arg = rdi; 1368 Register name_arg = rdi;
1371 #endif 1369 #endif
1372 1370
1373 ASSERT(!name_arg.is(scratch4())); 1371 ASSERT(!name_arg.is(scratch4()));
1374 __ movq(name_arg, rsp); 1372 __ movq(name_arg, rsp);
1375 __ PushReturnAddressFrom(scratch4()); 1373 __ PushReturnAddressFrom(scratch4());
1376 1374
1377 // v8::Arguments::values_ and handler for name. 1375 // v8::Arguments::values_ and handler for name.
1378 const int kStackSpace = PropertyCallbackArguments::kArgsLength + 1; 1376 const int kStackSpace = PropertyCallbackArguments::kArgsLength + 1;
1379 1377
1380 // Allocate v8::AccessorInfo in non-GCed stack space. 1378 // Allocate v8::AccessorInfo in non-GCed stack space.
1381 const int kArgStackSpace = 1; 1379 const int kArgStackSpace = 1;
1382 1380
1383 __ PrepareCallApiFunction(kArgStackSpace); 1381 __ PrepareCallApiFunction(kArgStackSpace);
1384 STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 6); 1382 __ lea(rax, Operand(name_arg, 1 * kPointerSize));
1385 __ lea(rax, Operand(name_arg, 6 * kPointerSize));
1386 1383
1387 // v8::AccessorInfo::args_. 1384 // v8::PropertyAccessorInfo::args_.
1388 __ movq(StackSpaceOperand(0), rax); 1385 __ movq(StackSpaceOperand(0), rax);
1389 1386
1390 // The context register (rsi) has been saved in PrepareCallApiFunction and 1387 // The context register (rsi) has been saved in PrepareCallApiFunction and
1391 // could be used to pass arguments. 1388 // could be used to pass arguments.
1392 __ lea(accessor_info_arg, StackSpaceOperand(0)); 1389 __ lea(accessor_info_arg, StackSpaceOperand(0));
1393 1390
1394 Address thunk_address = FUNCTION_ADDR(&InvokeAccessorGetterCallback); 1391 Address thunk_address = FUNCTION_ADDR(&InvokeAccessorGetterCallback);
1395 1392
1396 __ CallApiFunctionAndReturn(getter_address, 1393 __ CallApiFunctionAndReturn(getter_address,
1397 thunk_address, 1394 thunk_address,
(...skipping 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after
3170 // ----------------------------------- 3167 // -----------------------------------
3171 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); 3168 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric);
3172 } 3169 }
3173 3170
3174 3171
3175 #undef __ 3172 #undef __
3176 3173
3177 } } // namespace v8::internal 3174 } } // namespace v8::internal
3178 3175
3179 #endif // V8_TARGET_ARCH_X64 3176 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/ia32/stub-cache-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698